|
1 | 1 | import { JSONValue } from "../values/index.js"; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * The value exported by your Convex project in `auth.config.ts`. |
| 5 | + * |
| 6 | + * ```ts |
| 7 | + * import { AuthConfig } from "convex/server"; |
| 8 | + * |
| 9 | + * export default { |
| 10 | + * providers: [ |
| 11 | + * { |
| 12 | + * domain: "https://your.issuer.url.com", |
| 13 | + * applicationID: "your-application-id", |
| 14 | + * }, |
| 15 | + * ], |
| 16 | + * } satisfies AuthConfig; |
| 17 | + * ``` |
| 18 | + */ |
| 19 | +export type AuthConfig = { |
| 20 | + providers: AuthProvider[]; |
| 21 | +}; |
| 22 | + |
| 23 | +/** |
| 24 | + * An authentication provider allowed to issue JWTs for your app. |
| 25 | + * |
| 26 | + * See: https://docs.convex.dev/auth/advanced/custom-auth and https://docs.convex.dev/auth/advanced/custom-jwt |
| 27 | + */ |
| 28 | +export type AuthProvider = |
| 29 | + // OIDC provider |
| 30 | + | { |
| 31 | + /** |
| 32 | + * Tokens issued by the auth provider must have this application ID |
| 33 | + * in their audiences. |
| 34 | + */ |
| 35 | + applicationID: string; |
| 36 | + |
| 37 | + /** |
| 38 | + * The domain of the OIDC auth provider. |
| 39 | + */ |
| 40 | + domain: string; |
| 41 | + } |
| 42 | + // Custom JWT provider (see https://docs.convex.dev/auth/advanced/custom-jwt) |
| 43 | + | { |
| 44 | + type: "customJwt"; |
| 45 | + |
| 46 | + /** |
| 47 | + * Tokens issued by the auth provider must have this application ID |
| 48 | + * in their audiences. |
| 49 | + * |
| 50 | + * Warning: omitting applicationID is often insecure |
| 51 | + * (see https://docs.convex.dev/auth/advanced/custom-jwt#warning-omitting-applicationid-is-often-insecure). |
| 52 | + */ |
| 53 | + applicationID?: string; |
| 54 | + |
| 55 | + /** |
| 56 | + * The issuer of the JWT auth provider (e.g. `https://auth.example.com`) |
| 57 | + */ |
| 58 | + issuer: string; |
| 59 | + |
| 60 | + /** |
| 61 | + * The URL to fetch the JWKS (e.g. `https://auth.example.com/.well-known/jwks.json`) |
| 62 | + */ |
| 63 | + jwks: string; |
| 64 | + |
| 65 | + /** |
| 66 | + * The algorithm used to sign the JWT tokens. Convex currently only |
| 67 | + * supports RS256 and ES256. |
| 68 | + */ |
| 69 | + algorithm: "RS256" | "ES256"; |
| 70 | + }; |
| 71 | + |
3 | 72 | /** |
4 | 73 | * Information about an authenticated user, derived from a |
5 | 74 | * [JWT](https://datatracker.ietf.org/doc/html/rfc7519). |
|
0 commit comments