@draftlab/auth 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/node.d.mts +0 -1
- package/dist/client.d.mts +293 -287
- package/dist/client.mjs +1 -0
- package/dist/core.d.mts +22 -23
- package/dist/core.mjs +3 -3
- package/dist/error.d.mts +53 -53
- package/dist/keys.d.mts +0 -1
- package/dist/mutex.d.mts +14 -14
- package/dist/provider/apple.d.mts +34 -35
- package/dist/provider/code.d.mts +75 -85
- package/dist/provider/discord.d.mts +49 -50
- package/dist/provider/facebook.d.mts +49 -50
- package/dist/provider/github.d.mts +50 -51
- package/dist/provider/gitlab.d.mts +34 -35
- package/dist/provider/google.d.mts +49 -50
- package/dist/provider/linkedin.d.mts +47 -48
- package/dist/provider/magiclink.d.mts +28 -38
- package/dist/provider/microsoft.d.mts +67 -68
- package/dist/provider/oauth2.d.mts +75 -76
- package/dist/provider/passkey.d.mts +20 -21
- package/dist/provider/password.d.mts +174 -202
- package/dist/provider/provider.d.mts +105 -107
- package/dist/provider/reddit.d.mts +33 -34
- package/dist/provider/slack.d.mts +34 -35
- package/dist/provider/spotify.d.mts +34 -35
- package/dist/provider/totp.d.mts +43 -44
- package/dist/provider/twitch.d.mts +33 -34
- package/dist/provider/vercel.d.mts +65 -66
- package/dist/revocation.d.mts +29 -30
- package/dist/storage/memory.d.mts +11 -12
- package/dist/storage/storage.d.mts +110 -110
- package/dist/storage/turso.d.mts +0 -1
- package/dist/storage/unstorage.d.mts +0 -1
- package/dist/subject.d.mts +0 -1
- package/dist/themes/theme.d.mts +101 -101
- package/dist/toolkit/client.d.mts +56 -57
- package/dist/toolkit/providers/facebook.d.mts +0 -1
- package/dist/toolkit/providers/github.d.mts +0 -1
- package/dist/toolkit/providers/google.d.mts +0 -1
- package/dist/toolkit/storage.d.mts +8 -8
- package/dist/ui/base.d.mts +0 -1
- package/dist/ui/code.d.mts +5 -6
- package/dist/ui/form.d.mts +6 -7
- package/dist/ui/icon.d.mts +0 -1
- package/dist/ui/magiclink.d.mts +5 -6
- package/dist/ui/passkey.d.mts +0 -1
- package/dist/ui/password.d.mts +2 -3
- package/dist/ui/select.d.mts +0 -1
- package/dist/ui/totp.d.mts +0 -1
- package/dist/util.d.mts +0 -1
- package/package.json +3 -3
|
@@ -2,66 +2,65 @@ import { Provider } from "./provider.mjs";
|
|
|
2
2
|
import { Oauth2UserData, Oauth2WrappedConfig } from "./oauth2.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/provider/linkedin.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration options for LinkedIn OAuth 2.0 provider.
|
|
8
7
|
* Extends the base OAuth 2.0 configuration with LinkedIn-specific documentation.
|
|
9
8
|
*/
|
|
10
9
|
interface LinkedInConfig extends Oauth2WrappedConfig {
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
* LinkedIn OAuth 2.0 client ID from LinkedIn Developer Console.
|
|
12
|
+
* Found in your LinkedIn app settings.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* {
|
|
17
|
+
* clientID: "78abc123456789"
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
22
21
|
readonly clientID: string;
|
|
23
22
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
* LinkedIn OAuth 2.0 client secret from LinkedIn Developer Console.
|
|
24
|
+
* Keep this secure and never expose it to client-side code.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* {
|
|
29
|
+
* clientSecret: process.env.LINKEDIN_CLIENT_SECRET
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
34
33
|
readonly clientSecret: string;
|
|
35
34
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
* LinkedIn OAuth scopes to request access for.
|
|
36
|
+
* Determines what data and actions your app can access.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* {
|
|
41
|
+
* scopes: [
|
|
42
|
+
* "r_liteprofile", // Basic profile information
|
|
43
|
+
* "r_emailaddress", // Email address
|
|
44
|
+
* "w_member_social", // Share content on behalf of user
|
|
45
|
+
* "r_organization_social" // Organization content access
|
|
46
|
+
* ]
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
51
50
|
readonly scopes: string[];
|
|
52
51
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
* Additional query parameters for LinkedIn OAuth authorization.
|
|
53
|
+
* Useful for LinkedIn-specific options.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* {
|
|
58
|
+
* query: {
|
|
59
|
+
* state: "custom-state-value" // Custom state parameter
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
65
64
|
readonly query?: Record<string, string>;
|
|
66
65
|
}
|
|
67
66
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Provider } from "./provider.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/provider/magiclink.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Configuration options for the Magic Link authentication provider.
|
|
7
6
|
*
|
|
@@ -9,31 +8,31 @@ import { Provider } from "./provider.mjs";
|
|
|
9
8
|
*/
|
|
10
9
|
interface MagicLinkConfig<Claims extends Record<string, string> = Record<string, string>> {
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
* Token expiration time in seconds.
|
|
12
|
+
* After this time, the magic link becomes invalid.
|
|
13
|
+
*
|
|
14
|
+
* @default 900 (15 minutes)
|
|
15
|
+
*/
|
|
17
16
|
readonly expiry?: number;
|
|
18
17
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
* Request handler for rendering the magic link UI.
|
|
19
|
+
* Handles both the initial claim collection and "check your email" screens.
|
|
20
|
+
*
|
|
21
|
+
* @param req - The HTTP request object
|
|
22
|
+
* @param state - Current authentication state
|
|
23
|
+
* @param form - Form data from POST requests (if any)
|
|
24
|
+
* @param error - Authentication error to display (if any)
|
|
25
|
+
* @returns Promise resolving to the authentication page response
|
|
26
|
+
*/
|
|
28
27
|
request: (req: Request, state: MagicLinkState, form?: FormData, error?: MagicLinkError) => Promise<Response>;
|
|
29
28
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
* Callback for sending magic links to users.
|
|
30
|
+
* Should handle delivery via email, SMS, or other communication channels.
|
|
31
|
+
*
|
|
32
|
+
* @param claims - User claims containing contact information
|
|
33
|
+
* @param magicUrl - The magic link URL to send
|
|
34
|
+
* @returns Promise resolving to undefined on success, or error object on failure
|
|
35
|
+
*/
|
|
37
36
|
sendLink: (claims: Claims, magicUrl: string) => Promise<MagicLinkError | undefined>;
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
@@ -41,30 +40,21 @@ interface MagicLinkConfig<Claims extends Record<string, string> = Record<string,
|
|
|
41
40
|
* The provider transitions between these states during authentication.
|
|
42
41
|
*/
|
|
43
42
|
type MagicLinkState = {
|
|
44
|
-
/** Initial state: user enters their claims (email, phone, etc.) */
|
|
45
|
-
readonly type: "start";
|
|
43
|
+
/** Initial state: user enters their claims (email, phone, etc.) */readonly type: "start";
|
|
46
44
|
} | {
|
|
47
|
-
/** Link sent state: user checks their email/phone */
|
|
48
|
-
readonly
|
|
49
|
-
/**
|
|
50
|
-
readonly resend?: boolean;
|
|
51
|
-
/** The secure token for verification */
|
|
52
|
-
readonly token: string;
|
|
53
|
-
/** User claims collected during the start phase */
|
|
45
|
+
/** Link sent state: user checks their email/phone */readonly type: "sent"; /** Whether this is a resend request */
|
|
46
|
+
readonly resend?: boolean; /** The secure token for verification */
|
|
47
|
+
readonly token: string; /** User claims collected during the start phase */
|
|
54
48
|
readonly claims: Record<string, string>;
|
|
55
49
|
};
|
|
56
50
|
/**
|
|
57
51
|
* Possible errors during magic link authentication.
|
|
58
52
|
*/
|
|
59
53
|
type MagicLinkError = {
|
|
60
|
-
/** The magic link is invalid or expired */
|
|
61
|
-
readonly type: "invalid_link";
|
|
54
|
+
/** The magic link is invalid or expired */readonly type: "invalid_link";
|
|
62
55
|
} | {
|
|
63
|
-
/** A user claim is invalid or missing */
|
|
64
|
-
readonly
|
|
65
|
-
/** The claim field that failed validation */
|
|
66
|
-
readonly key: string;
|
|
67
|
-
/** The invalid value or error description */
|
|
56
|
+
/** A user claim is invalid or missing */readonly type: "invalid_claim"; /** The claim field that failed validation */
|
|
57
|
+
readonly key: string; /** The invalid value or error description */
|
|
68
58
|
readonly value: string;
|
|
69
59
|
};
|
|
70
60
|
/**
|
|
@@ -2,88 +2,87 @@ import { Provider } from "./provider.mjs";
|
|
|
2
2
|
import { Oauth2UserData, Oauth2WrappedConfig } from "./oauth2.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/provider/microsoft.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration options for Microsoft OAuth 2.0 provider.
|
|
8
7
|
* Extends the base OAuth 2.0 configuration with Microsoft-specific documentation.
|
|
9
8
|
*/
|
|
10
9
|
interface MicrosoftConfig extends Oauth2WrappedConfig {
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
* Microsoft Azure AD tenant ID or tenant type.
|
|
12
|
+
* Determines which types of accounts can sign in.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* {
|
|
17
|
+
* tenant: "common" // Personal + work/school accounts
|
|
18
|
+
* // or
|
|
19
|
+
* tenant: "organizations" // Work/school accounts only
|
|
20
|
+
* // or
|
|
21
|
+
* tenant: "consumers" // Personal accounts only
|
|
22
|
+
* // or
|
|
23
|
+
* tenant: "12345678-1234-1234-1234-123456789012" // Specific tenant
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
28
27
|
readonly tenant: string;
|
|
29
28
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
* Microsoft OAuth 2.0 client ID from Azure App Registration.
|
|
30
|
+
* Found in your Azure portal app registration.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* {
|
|
35
|
+
* clientID: "12345678-1234-1234-1234-123456789012"
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
40
39
|
readonly clientID: string;
|
|
41
40
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
* Microsoft OAuth 2.0 client secret from Azure App Registration.
|
|
42
|
+
* Keep this secure and never expose it to client-side code.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* {
|
|
47
|
+
* clientSecret: process.env.MICROSOFT_CLIENT_SECRET
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
52
51
|
readonly clientSecret: string;
|
|
53
52
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
* Microsoft OAuth scopes to request access for.
|
|
54
|
+
* Determines what data and actions your app can access via Microsoft Graph.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* {
|
|
59
|
+
* scopes: [
|
|
60
|
+
* "openid", // OpenID Connect sign-in
|
|
61
|
+
* "profile", // Basic profile
|
|
62
|
+
* "email", // Email address
|
|
63
|
+
* "User.Read", // Read user profile
|
|
64
|
+
* "Mail.Read", // Read user mail
|
|
65
|
+
* "Calendars.Read" // Read user calendars
|
|
66
|
+
* ]
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
71
70
|
readonly scopes: string[];
|
|
72
71
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
* Additional query parameters for Microsoft OAuth authorization.
|
|
73
|
+
* Useful for Microsoft-specific options like domain hints.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* {
|
|
78
|
+
* query: {
|
|
79
|
+
* domain_hint: "contoso.com", // Pre-fill domain
|
|
80
|
+
* login_hint: "user@contoso.com", // Pre-fill username
|
|
81
|
+
* prompt: "consent" // Force consent screen
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
87
86
|
readonly query?: Record<string, string>;
|
|
88
87
|
}
|
|
89
88
|
/**
|
|
@@ -1,106 +1,105 @@
|
|
|
1
1
|
import { Provider } from "./provider.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/provider/oauth2.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Configuration options for the OAuth 2.0 provider.
|
|
7
6
|
*/
|
|
8
7
|
interface Oauth2Config {
|
|
9
8
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* Provider type identifier for internal use.
|
|
10
|
+
* @internal
|
|
11
|
+
* @default "oauth2"
|
|
12
|
+
*/
|
|
14
13
|
readonly type?: string;
|
|
15
14
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
* The client ID registered with the OAuth 2.0 provider.
|
|
16
|
+
* This public identifier is used in authorization requests.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* {
|
|
21
|
+
* clientID: "github-app-12345"
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
26
25
|
readonly clientID: string;
|
|
27
26
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
* The client secret for authenticating with the OAuth 2.0 provider.
|
|
28
|
+
* This private credential must be kept secure and not exposed to clients.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* {
|
|
33
|
+
* clientSecret: process.env.OAUTH_CLIENT_SECRET
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
38
37
|
readonly clientSecret: string;
|
|
39
38
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* OAuth 2.0 endpoint URLs for the authorization and token flows.
|
|
40
|
+
*/
|
|
42
41
|
readonly endpoint: {
|
|
43
42
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
* The authorization endpoint where users are redirected for authentication.
|
|
44
|
+
*
|
|
45
|
+
* @example "https://github.com/login/oauth/authorize"
|
|
46
|
+
*/
|
|
48
47
|
readonly authorization: string;
|
|
49
48
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
* The token endpoint for exchanging authorization codes for access tokens.
|
|
50
|
+
*
|
|
51
|
+
* @example "https://github.com/login/oauth/access_token"
|
|
52
|
+
*/
|
|
54
53
|
readonly token: string;
|
|
55
54
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
* Optional JWKS endpoint for verifying ID tokens.
|
|
56
|
+
* Required only if the provider returns ID tokens that need verification.
|
|
57
|
+
*
|
|
58
|
+
* @example "https://provider.com/.well-known/jwks.json"
|
|
59
|
+
*/
|
|
61
60
|
readonly jwks?: string;
|
|
62
61
|
};
|
|
63
62
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
* OAuth 2.0 scopes to request during authorization.
|
|
64
|
+
* Scopes define the level of access being requested.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* {
|
|
69
|
+
* scopes: ["user:email", "read:user", "repo"]
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
74
73
|
readonly scopes: string[];
|
|
75
74
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
* Whether to use PKCE (Proof Key for Code Exchange) for enhanced security.
|
|
76
|
+
* Recommended for public clients and required by some providers.
|
|
77
|
+
*
|
|
78
|
+
* @default false
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* {
|
|
83
|
+
* pkce: true // Required for Twitter/X, recommended for mobile apps
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
88
87
|
readonly pkce?: boolean;
|
|
89
88
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
* Additional query parameters to include in the authorization request.
|
|
90
|
+
* Useful for provider-specific parameters or customizing the auth flow.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* {
|
|
95
|
+
* query: {
|
|
96
|
+
* access_type: "offline", // Request refresh token
|
|
97
|
+
* prompt: "consent", // Force consent screen
|
|
98
|
+
* hd: "mycompany.com" // Google Workspace domain
|
|
99
|
+
* }
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
104
103
|
readonly query?: Record<string, string>;
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
@@ -2,7 +2,6 @@ import { Provider } from "./provider.mjs";
|
|
|
2
2
|
import { AuthenticatorSelectionCriteria, AuthenticatorTransportFuture, Base64URLString, CredentialDeviceType } from "@simplewebauthn/server";
|
|
3
3
|
|
|
4
4
|
//#region src/provider/passkey.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* User model for passkey authentication.
|
|
8
7
|
* Contains the core user data needed for WebAuthn operations.
|
|
@@ -41,44 +40,44 @@ declare const DEFAULT_COPY: {
|
|
|
41
40
|
*/
|
|
42
41
|
interface PasskeyProviderConfig {
|
|
43
42
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
* Custom authorization handler that generates the UI for authorization.
|
|
44
|
+
*/
|
|
46
45
|
authorize: (req: Request) => Promise<Response>;
|
|
47
46
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
* Custom registration handler that generates the UI for registration.
|
|
48
|
+
*/
|
|
50
49
|
register: (req: Request) => Promise<Response>;
|
|
51
50
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
* The human-readable name of the relying party (your application).
|
|
52
|
+
*/
|
|
54
53
|
rpName: string;
|
|
55
54
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* The ID of the relying party, typically the domain name without protocol.
|
|
56
|
+
*/
|
|
58
57
|
rpID?: string;
|
|
59
58
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
* The origin URL(s) that are allowed to initiate WebAuthn ceremonies.
|
|
60
|
+
*/
|
|
62
61
|
origin?: string | string[];
|
|
63
62
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
* Optional function to check if a user is allowed to register a passkey.
|
|
64
|
+
*/
|
|
66
65
|
userCanRegisterPasskey?: (userId: string, req: Request) => Promise<boolean>;
|
|
67
66
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
* Optional WebAuthn authenticator selection criteria.
|
|
68
|
+
*/
|
|
70
69
|
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
71
70
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
* Optional attestation type.
|
|
72
|
+
*/
|
|
74
73
|
attestationType?: "none" | "direct" | "enterprise";
|
|
75
74
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
* Optional timeout for challenges in milliseconds.
|
|
76
|
+
*/
|
|
78
77
|
timeout?: number;
|
|
79
78
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
* Custom copy texts for error messages and UI elements.
|
|
80
|
+
*/
|
|
82
81
|
copy?: Partial<typeof DEFAULT_COPY>;
|
|
83
82
|
}
|
|
84
83
|
/**
|