@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
package/dist/themes/theme.d.mts
CHANGED
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
*/
|
|
47
47
|
interface ColorScheme {
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
* The value for dark mode.
|
|
50
|
+
*/
|
|
51
51
|
dark: string;
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
* The value for light mode.
|
|
54
|
+
*/
|
|
55
55
|
light: string;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -59,122 +59,122 @@ interface ColorScheme {
|
|
|
59
59
|
*/
|
|
60
60
|
interface Theme {
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
* The name of your app. Also used as the title of the page.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* {
|
|
67
|
+
* title: "Acne"
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
71
|
title?: string;
|
|
72
72
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
* A URL to the favicon of your app.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* {
|
|
78
|
+
* favicon: "https://www.example.com/favicon.svg"
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
82
|
favicon?: string;
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
* The border radius of the UI elements.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* {
|
|
89
|
+
* radius: "none"
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
93
|
radius?: "none" | "sm" | "md" | "lg" | "full";
|
|
94
94
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
* The primary color of the theme.
|
|
96
|
+
*
|
|
97
|
+
* Takes a color or both light and dark colors.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* {
|
|
102
|
+
* primary: "#FF5E00"
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
106
|
primary: string | ColorScheme;
|
|
107
107
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
* The background color of the theme.
|
|
109
|
+
*
|
|
110
|
+
* Takes a color or both light and dark colors.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* {
|
|
115
|
+
* background: "#FFF"
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
119
|
background?: string | ColorScheme;
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
* A URL to the logo of your app.
|
|
122
|
+
*
|
|
123
|
+
* Takes a single image or both light and dark mode versions.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* {
|
|
128
|
+
* logo: "https://www.example.com/logo.svg"
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
132
|
logo?: string | ColorScheme;
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
* The font family and scale of the theme.
|
|
135
|
+
*/
|
|
136
136
|
font?: {
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
* The font family of the theme.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* {
|
|
143
|
+
* font: {
|
|
144
|
+
* family: "Geist Mono, monospace"
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
149
|
family?: string;
|
|
150
150
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
* The font scale of the theme. Can be used to increase or decrease the font sizes across
|
|
152
|
+
* the UI.
|
|
153
|
+
*
|
|
154
|
+
* @default "1"
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* {
|
|
158
|
+
* font: {
|
|
159
|
+
* scale: "1.25"
|
|
160
|
+
* }
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
164
|
scale?: string;
|
|
165
165
|
};
|
|
166
166
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
* Custom CSS that's added to the page in a `<style>` tag.
|
|
168
|
+
*
|
|
169
|
+
* This can be used to import custom fonts.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* {
|
|
174
|
+
* css: `@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@100;200;300;400;500;600;700;800;900&display=swap');`
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
178
|
css?: string;
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
@@ -2,7 +2,6 @@ import { OAuthStrategy } from "./providers/strategy.mjs";
|
|
|
2
2
|
import { AuthStorage } from "./storage.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/toolkit/client.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration for a single OAuth provider.
|
|
8
7
|
*/
|
|
@@ -60,69 +59,69 @@ interface OAuthClientConfig<TProviders extends Record<string, ProviderConfig<OAu
|
|
|
60
59
|
*/
|
|
61
60
|
interface OAuthClient<TProviders extends Record<string, ProviderConfig<OAuthStrategy>>> {
|
|
62
61
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
* Initiate OAuth authorization flow.
|
|
63
|
+
*
|
|
64
|
+
* @param provider - Provider name (key from providers config)
|
|
65
|
+
* @param options - Authorization options
|
|
66
|
+
* @returns Authorization URL to redirect user to
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* // Basic usage
|
|
71
|
+
* const { url } = await client.authorize('github')
|
|
72
|
+
* window.location.href = url
|
|
73
|
+
*
|
|
74
|
+
* // With custom scopes
|
|
75
|
+
* const { url } = await client.authorize('google', {
|
|
76
|
+
* scopes: ['openid', 'email', 'profile']
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
79
|
+
* // With additional params
|
|
80
|
+
* const { url } = await client.authorize('github', {
|
|
81
|
+
* params: { prompt: 'consent' }
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
86
85
|
authorize(provider: (string & {}) | keyof TProviders, options?: AuthorizeOptions): Promise<{
|
|
87
86
|
url: string;
|
|
88
87
|
state: string;
|
|
89
88
|
}>;
|
|
90
89
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
* Handle OAuth callback and exchange code for tokens.
|
|
91
|
+
*
|
|
92
|
+
* @param callbackUrl - Full callback URL with query parameters
|
|
93
|
+
* @returns Token exchange result
|
|
94
|
+
*
|
|
95
|
+
* @throws {Error} If callback URL is invalid, state mismatch, or token exchange fails
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* // Client-side
|
|
100
|
+
* const result = await client.handleCallback(window.location.href)
|
|
101
|
+
* console.log(result.accessToken, result.provider)
|
|
102
|
+
*
|
|
103
|
+
* // Server-side (Next.js)
|
|
104
|
+
* export async function GET(req: Request) {
|
|
105
|
+
* const result = await client.handleCallback(req.url)
|
|
106
|
+
* // Store tokens, create session, etc.
|
|
107
|
+
* return Response.redirect('/')
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
112
111
|
handleCallback(callbackUrl: string): Promise<CallbackResult>;
|
|
113
112
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
* Get user info from OAuth provider using access token.
|
|
114
|
+
*
|
|
115
|
+
* @param provider - Provider name
|
|
116
|
+
* @param accessToken - Access token from provider
|
|
117
|
+
* @returns User info from provider
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const userInfo = await client.getUserInfo('github', accessToken)
|
|
122
|
+
* console.log(userInfo.email, userInfo.name)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
126
125
|
getUserInfo(provider: (string & {}) | keyof TProviders, accessToken: string): Promise<Record<string, unknown>>;
|
|
127
126
|
}
|
|
128
127
|
/**
|
|
@@ -23,18 +23,18 @@ interface PKCEState {
|
|
|
23
23
|
*/
|
|
24
24
|
interface AuthStorage {
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
* Store PKCE state data.
|
|
27
|
+
* @param state - PKCE state to persist
|
|
28
|
+
*/
|
|
29
29
|
set(state: PKCEState): void | Promise<void>;
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
* Retrieve stored PKCE state data.
|
|
32
|
+
* @returns Stored state or null if not found
|
|
33
|
+
*/
|
|
34
34
|
get(): PKCEState | null | Promise<PKCEState | null>;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Clear stored PKCE state data.
|
|
37
|
+
*/
|
|
38
38
|
clear(): void | Promise<void>;
|
|
39
39
|
}
|
|
40
40
|
/**
|
package/dist/ui/base.d.mts
CHANGED
package/dist/ui/code.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CodeProviderOptions } from "../provider/code.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/ui/code.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Type for customizable UI copy text
|
|
7
6
|
*/
|
|
@@ -26,13 +25,13 @@ type CodeUIMode = "email" | "phone";
|
|
|
26
25
|
*/
|
|
27
26
|
interface CodeUIOptions extends Pick<CodeProviderOptions, "sendCode"> {
|
|
28
27
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
* Input mode determining the type of contact information to collect
|
|
29
|
+
* @default "email"
|
|
30
|
+
*/
|
|
32
31
|
readonly mode?: CodeUIMode;
|
|
33
32
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
* Custom text copy for UI labels, messages, and errors
|
|
34
|
+
*/
|
|
36
35
|
readonly copy?: Partial<CodeUICopy>;
|
|
37
36
|
}
|
|
38
37
|
/**
|
package/dist/ui/form.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ComponentChildren } from "preact";
|
|
2
2
|
|
|
3
3
|
//#region src/ui/form.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Alert color variant determining the visual style and icon.
|
|
7
6
|
*/
|
|
@@ -11,14 +10,14 @@ type FormAlertColor = "danger" | "success";
|
|
|
11
10
|
*/
|
|
12
11
|
interface FormAlertProps {
|
|
13
12
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
* The message text to display in the alert.
|
|
14
|
+
* If not provided, the alert will not render.
|
|
15
|
+
*/
|
|
17
16
|
readonly message?: string;
|
|
18
17
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
* Visual style variant for the alert.
|
|
19
|
+
* @default "danger"
|
|
20
|
+
*/
|
|
22
21
|
readonly color?: FormAlertColor;
|
|
23
22
|
}
|
|
24
23
|
/**
|
package/dist/ui/icon.d.mts
CHANGED
package/dist/ui/magiclink.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MagicLinkConfig } from "../provider/magiclink.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/ui/magiclink.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Type for customizable UI copy text
|
|
7
6
|
*/
|
|
@@ -24,13 +23,13 @@ type MagicLinkUIMode = "email" | "phone";
|
|
|
24
23
|
*/
|
|
25
24
|
interface MagicLinkUIOptions<Claims extends Record<string, string> = Record<string, string>> extends Pick<MagicLinkConfig<Claims>, "sendLink"> {
|
|
26
25
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* Input mode determining the type of contact information to collect
|
|
27
|
+
* @default "email"
|
|
28
|
+
*/
|
|
30
29
|
readonly mode?: MagicLinkUIMode;
|
|
31
30
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
* Custom text copy for UI labels, messages, and errors
|
|
32
|
+
*/
|
|
34
33
|
readonly copy?: Partial<MagicLinkUICopy>;
|
|
35
34
|
}
|
|
36
35
|
/**
|
package/dist/ui/passkey.d.mts
CHANGED
package/dist/ui/password.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PasswordConfig } from "../provider/password.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/ui/password.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Strongly typed copy text configuration for password UI
|
|
7
6
|
*/
|
|
@@ -30,8 +29,8 @@ interface PasswordUICopy {
|
|
|
30
29
|
*/
|
|
31
30
|
interface PasswordUIOptions extends Pick<PasswordConfig, "sendCode" | "validatePassword"> {
|
|
32
31
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
* Custom text copy for UI labels, messages, and errors
|
|
33
|
+
*/
|
|
35
34
|
readonly copy?: Partial<PasswordUICopy>;
|
|
36
35
|
}
|
|
37
36
|
/**
|
package/dist/ui/select.d.mts
CHANGED
package/dist/ui/totp.d.mts
CHANGED
package/dist/util.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftlab/auth",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core implementation for @draftlab/auth",
|
|
6
6
|
"author": "Matheus Pergoli",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^25.0.
|
|
40
|
+
"@types/node": "^25.0.9",
|
|
41
41
|
"@types/qrcode": "^1.5.6",
|
|
42
|
-
"tsdown": "0.
|
|
42
|
+
"tsdown": "0.20.0-beta.3",
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
44
|
"@draftlab/tsconfig": "0.1.0"
|
|
45
45
|
},
|