-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { OAuth2Provider, OAuth2ProviderWithPKCE } from "arctic"; | ||
|
||
export function defineProvider< | ||
OAuthClient extends OAuth2Provider | OAuth2ProviderWithPKCE, | ||
Env extends Record<string, string> | ||
>({ | ||
id, | ||
displayName, | ||
env, | ||
oAuthClient, | ||
}: { | ||
id: string; | ||
displayName: string; | ||
env: Env; | ||
oAuthClient: OAuthClient; | ||
}) { | ||
return { | ||
id, | ||
displayName, | ||
env, | ||
oAuthClient, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
{{={= =}=}} | ||
import { Discord } from "arctic"; | ||
|
||
import { defineProvider } from "../provider.js"; | ||
import { ensureEnvVarsForProvider } from "../env.js"; | ||
import { getRedirectUriForCallback } from "../redirect.js"; | ||
|
||
export const id = "{= providerId =}"; | ||
export const displayName = "{= displayName =}"; | ||
const id = "{= providerId =}"; | ||
const displayName = "{= displayName =}"; | ||
|
||
const env = ensureEnvVarsForProvider( | ||
["DISCORD_CLIENT_ID", "DISCORD_CLIENT_SECRET"], | ||
displayName | ||
); | ||
|
||
export const oAuthClient = new Discord( | ||
const oAuthClient = new Discord( | ||
env.DISCORD_CLIENT_ID, | ||
env.DISCORD_CLIENT_SECRET, | ||
getRedirectUriForCallback(id).toString(), | ||
); | ||
|
||
// PUBLIC API | ||
export const discord = defineProvider({ | ||
id, | ||
displayName, | ||
env, | ||
oAuthClient, | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.