Skip to content

Commit ceb3aba

Browse files
NicolappsConvex, Inc.
authored andcommitted
Export an AuthConfig TypeScript type (#41609)
GitOrigin-RevId: d27f59744282518bcae108fe9ed6e9cd32e7edb2
1 parent 9b37e8f commit ceb3aba

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

src/server/authentication.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,74 @@
11
import { JSONValue } from "../values/index.js";
22

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+
372
/**
473
* Information about an authenticated user, derived from a
574
* [JWT](https://datatracker.ietf.org/doc/html/rfc7519).

src/server/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353

5454
export type {
5555
Auth,
56+
AuthConfig,
57+
AuthProvider,
5658
UserIdentity,
5759
UserIdentityAttributes,
5860
} from "./authentication.js";

0 commit comments

Comments
 (0)