@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,50 +2,49 @@ import { Provider } from "./provider.mjs";
|
|
|
2
2
|
import { Oauth2UserData, Oauth2WrappedConfig } from "./oauth2.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/provider/twitch.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration options for Twitch OAuth 2.0 provider.
|
|
8
7
|
* Extends the base OAuth 2.0 configuration with Twitch-specific documentation.
|
|
9
8
|
*/
|
|
10
9
|
interface TwitchConfig extends Oauth2WrappedConfig {
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
* Twitch application client ID.
|
|
12
|
+
* Get this from your Twitch Console at https://dev.twitch.tv/console
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* {
|
|
17
|
+
* clientID: "abcdef123456"
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
22
21
|
readonly clientID: string;
|
|
23
22
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
* Twitch application client secret.
|
|
24
|
+
* Keep this secure and never expose it to client-side code.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* {
|
|
29
|
+
* clientSecret: process.env.TWITCH_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
|
-
|
|
35
|
+
* Twitch 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
|
+
* "user:read:email", // Access user email
|
|
43
|
+
* "user:read:subscriptions" // View subscriptions
|
|
44
|
+
* ]
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
49
48
|
readonly scopes: string[];
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
@@ -2,84 +2,83 @@ import { Provider } from "./provider.mjs";
|
|
|
2
2
|
import { Oauth2UserData, Oauth2WrappedConfig } from "./oauth2.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/provider/vercel.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Configuration options for Vercel OAuth 2.0 + OpenID Connect provider.
|
|
8
7
|
* Extends the base OAuth 2.0 configuration with Vercel-specific documentation.
|
|
9
8
|
*/
|
|
10
9
|
interface VercelConfig extends Oauth2WrappedConfig {
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
* Vercel OAuth App client ID.
|
|
12
|
+
* Found in your Vercel App settings under the Authentication tab.
|
|
13
|
+
*
|
|
14
|
+
* To create an app:
|
|
15
|
+
* 1. Go to Team Settings → Apps → Create
|
|
16
|
+
* 2. Configure app details and callback URLs
|
|
17
|
+
* 3. Copy the Client ID from the Authentication tab
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* {
|
|
22
|
+
* clientID: "oac_abc123xyz789" // Vercel OAuth App Client ID
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
27
26
|
readonly clientID: string;
|
|
28
27
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
* Vercel OAuth App client secret.
|
|
29
|
+
* Generated in your Vercel App settings under the Authentication tab.
|
|
30
|
+
* Keep this secure and never expose it to client-side code.
|
|
31
|
+
*
|
|
32
|
+
* To generate:
|
|
33
|
+
* 1. Go to your app's Authentication tab
|
|
34
|
+
* 2. Click "Generate Client Secret"
|
|
35
|
+
* 3. Copy and store securely (shown only once)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* {
|
|
40
|
+
* clientSecret: process.env.VERCEL_CLIENT_SECRET
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
45
44
|
readonly clientSecret: string;
|
|
46
45
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
* OpenID Connect scopes to request.
|
|
47
|
+
* Controls what user information is included in the ID Token.
|
|
48
|
+
*
|
|
49
|
+
* Available scopes (must be enabled in Vercel App dashboard first):
|
|
50
|
+
* - `openid`: Required for ID Token issuance
|
|
51
|
+
* - `email`: User's email address
|
|
52
|
+
* - `profile`: Name, username, and avatar
|
|
53
|
+
* - `offline_access`: Refresh token for long-lived access (optional)
|
|
54
|
+
*
|
|
55
|
+
* **Important**: Enable scopes in: Vercel App → Permissions page
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* {
|
|
60
|
+
* // Basic scopes (usually sufficient)
|
|
61
|
+
* scopes: ["openid", "email", "profile"]
|
|
62
|
+
*
|
|
63
|
+
* // With refresh token support (enable offline_access in dashboard first)
|
|
64
|
+
* scopes: ["openid", "email", "profile", "offline_access"]
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
69
68
|
readonly scopes: string[];
|
|
70
69
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
* Additional query parameters for Vercel OAuth authorization.
|
|
71
|
+
* Useful for customizing the authorization flow.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* {
|
|
76
|
+
* query: {
|
|
77
|
+
* prompt: "consent" // Force consent screen every time
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
83
82
|
readonly query?: Record<string, string>;
|
|
84
83
|
}
|
|
85
84
|
/**
|
package/dist/revocation.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { StorageAdapter } from "./storage/storage.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/revocation.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Data stored for a revoked token.
|
|
7
6
|
* Tracks when the token was revoked and when it naturally expires.
|
|
@@ -18,37 +17,37 @@ interface RevocationRecord {
|
|
|
18
17
|
*/
|
|
19
18
|
declare const Revocation: {
|
|
20
19
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
* Revokes a token, preventing it from being used even if not yet expired.
|
|
21
|
+
*
|
|
22
|
+
* @param storage - Storage adapter to use
|
|
23
|
+
* @param token - The token to revoke (access or refresh token)
|
|
24
|
+
* @param expiresAt - When the token naturally expires (milliseconds since epoch)
|
|
25
|
+
* @returns Promise that resolves when revocation is stored
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Revoke a refresh token on logout
|
|
30
|
+
* await Revocation.revoke(storage, refreshToken, expiresAt)
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
34
33
|
readonly revoke: (storage: StorageAdapter, token: string, expiresAt: number) => Promise<void>;
|
|
35
34
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
* Checks if a token has been revoked.
|
|
36
|
+
* Returns false if token is not in revocation list (never revoked or already expired).
|
|
37
|
+
*
|
|
38
|
+
* @param storage - Storage adapter to use
|
|
39
|
+
* @param token - The token to check
|
|
40
|
+
* @returns Promise resolving to true if token is revoked, false otherwise
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Check if token was revoked before using it
|
|
45
|
+
* const isRevoked = await Revocation.isRevoked(storage, accessToken)
|
|
46
|
+
* if (isRevoked) {
|
|
47
|
+
* throw new InvalidAccessTokenError()
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
52
51
|
readonly isRevoked: (storage: StorageAdapter, token: string) => Promise<boolean>;
|
|
53
52
|
};
|
|
54
53
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { StorageAdapter } from "./storage.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/storage/memory.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* In-memory storage adapter for Draft Auth with optional file persistence.
|
|
7
6
|
*
|
|
@@ -40,17 +39,17 @@ import { StorageAdapter } from "./storage.mjs";
|
|
|
40
39
|
*/
|
|
41
40
|
interface MemoryStorageOptions {
|
|
42
41
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
* File path for persisting the in-memory store to disk.
|
|
43
|
+
* When specified, the store will be saved to this file on changes
|
|
44
|
+
* and loaded from it on startup if it exists.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* {
|
|
49
|
+
* persist: "./data/auth-storage.json"
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
54
53
|
readonly persist?: string;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
@@ -10,34 +10,34 @@
|
|
|
10
10
|
*/
|
|
11
11
|
interface StorageAdapter {
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
* Retrieves a value by its key path.
|
|
14
|
+
*
|
|
15
|
+
* @param key - Array of key segments forming the storage path
|
|
16
|
+
* @returns Promise resolving to the stored value or undefined if not found
|
|
17
|
+
*/
|
|
18
18
|
get(key: string[]): Promise<Record<string, unknown> | undefined>;
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
* Removes a value by its key path.
|
|
21
|
+
*
|
|
22
|
+
* @param key - Array of key segments forming the storage path
|
|
23
|
+
* @returns Promise that resolves when removal is complete
|
|
24
|
+
*/
|
|
25
25
|
remove(key: string[]): Promise<void>;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
* Stores a value with an optional expiration date.
|
|
28
|
+
*
|
|
29
|
+
* @param key - Array of key segments forming the storage path
|
|
30
|
+
* @param value - The value to store
|
|
31
|
+
* @param expiry - Optional expiration date for automatic cleanup
|
|
32
|
+
* @returns Promise that resolves when storage is complete
|
|
33
|
+
*/
|
|
34
34
|
set(key: string[], value: unknown, expiry?: Date): Promise<void>;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
* Scans for keys matching a prefix pattern.
|
|
37
|
+
*
|
|
38
|
+
* @param prefix - Array of key segments to use as prefix filter
|
|
39
|
+
* @returns Async iterable of key-value pairs matching the prefix
|
|
40
|
+
*/
|
|
41
41
|
scan(prefix: string[]): AsyncIterable<readonly [string[], unknown]>;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -75,104 +75,104 @@ declare const splitKey: (key: string) => string[];
|
|
|
75
75
|
*/
|
|
76
76
|
declare const Storage: {
|
|
77
77
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
* Encodes key segments by escaping special characters.
|
|
79
|
+
* Ensures storage keys don't contain unescaped separator characters that could cause collisions.
|
|
80
|
+
*
|
|
81
|
+
* @param key - Array of key segments to encode
|
|
82
|
+
* @returns Array of properly escaped key segments
|
|
83
|
+
*
|
|
84
|
+
* @throws {Error} If any segment is empty or whitespace-only
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* Storage.encode(['user', 'data\x1fwith\x1fseparators'])
|
|
89
|
+
* // Returns: ['user', 'data\\x1fwith\\x1fseparators']
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
92
|
readonly encode: (key: string[]) => string[];
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
* Decodes key segments by unescaping special characters.
|
|
95
|
+
* Reverse operation of encode().
|
|
96
|
+
*
|
|
97
|
+
* @param key - Array of encoded key segments
|
|
98
|
+
* @returns Array of decoded key segments
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
102
|
readonly decode: (key: string[]) => string[];
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
104
|
+
* Retrieves a typed value from storage.
|
|
105
|
+
*
|
|
106
|
+
* @template T - Expected type of the stored value
|
|
107
|
+
* @param adapter - Storage adapter to use
|
|
108
|
+
* @param key - Array of key segments identifying the value
|
|
109
|
+
* @returns Promise resolving to the typed value or null if not found
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* interface UserSession {
|
|
114
|
+
* userId: string
|
|
115
|
+
* expiresAt: number
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* const session = await Storage.get<UserSession>(adapter, ['sessions', sessionId])
|
|
119
|
+
* if (session) {
|
|
120
|
+
* // Fully typed: session.userId
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
124
|
readonly get: <T = Record<string, unknown>>(adapter: StorageAdapter, key: string[]) => Promise<T | null>;
|
|
125
125
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
* Stores a value with optional time-to-live in seconds.
|
|
127
|
+
* Validates that TTL is a positive integer to prevent edge cases like negative or overflow values.
|
|
128
|
+
*
|
|
129
|
+
* @param adapter - Storage adapter to use
|
|
130
|
+
* @param key - Array of key segments identifying where to store
|
|
131
|
+
* @param value - The value to store
|
|
132
|
+
* @param ttlSeconds - Optional TTL in seconds for automatic expiration
|
|
133
|
+
* @returns Promise that resolves when storage is complete
|
|
134
|
+
*
|
|
135
|
+
* @throws {RangeError} If TTL is invalid (negative, non-integer, or exceeds maximum)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* // Store with 1 hour TTL
|
|
140
|
+
* await Storage.set(adapter, ['sessions', sessionId], sessionData, 3600)
|
|
141
|
+
*
|
|
142
|
+
* // Store permanently (no expiration)
|
|
143
|
+
* await Storage.set(adapter, ['users', userId], userData)
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
146
|
readonly set: (adapter: StorageAdapter, key: string[], value: unknown, ttlSeconds?: number) => Promise<void>;
|
|
147
147
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
* Removes a value from storage.
|
|
149
|
+
*
|
|
150
|
+
* @param adapter - Storage adapter to use
|
|
151
|
+
* @param key - Array of key segments identifying the value to remove
|
|
152
|
+
* @returns Promise that resolves when removal is complete
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* await Storage.remove(adapter, ['sessions', expiredSessionId])
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
159
|
readonly remove: (adapter: StorageAdapter, key: string[]) => Promise<void>;
|
|
160
160
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
* Scans for entries matching a key prefix with type safety.
|
|
162
|
+
*
|
|
163
|
+
* @template T - Expected type of the stored values
|
|
164
|
+
* @param adapter - Storage adapter to use
|
|
165
|
+
* @param prefix - Array of key segments to use as prefix filter
|
|
166
|
+
* @returns Async iterable of typed key-value pairs
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* // Find all user sessions
|
|
171
|
+
* for await (const [key, session] of Storage.scan<UserSession>(adapter, ['sessions'])) {
|
|
172
|
+
* // Session: `${key.join('/')} expires at ${session.expiresAt}`
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
176
|
readonly scan: <T = Record<string, unknown>>(adapter: StorageAdapter, prefix: string[]) => AsyncIterable<readonly [string[], T]>;
|
|
177
177
|
};
|
|
178
178
|
//#endregion
|
package/dist/storage/turso.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { StorageAdapter } from "./storage.mjs";
|
|
|
2
2
|
import { Client } from "@libsql/client";
|
|
3
3
|
|
|
4
4
|
//#region src/storage/turso.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Creates a Turso storage adapter using the provided LibSQL client.
|
|
8
7
|
* Automatically initializes the required database table and implements
|
|
@@ -2,7 +2,6 @@ import { StorageAdapter } from "./storage.mjs";
|
|
|
2
2
|
import { Driver } from "unstorage";
|
|
3
3
|
|
|
4
4
|
//#region src/storage/unstorage.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Creates a Draft Auth storage adapter using Unstorage drivers.
|
|
8
7
|
* Supports automatic expiration, error handling, and any Unstorage driver.
|
package/dist/subject.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { Prettify } from "./util.mjs";
|
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/subject.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Schema definition for subjects, mapping subject type names to their validation schemas.
|
|
8
7
|
* Each key represents a subject type, and each value is a schema that validates
|