@draftlab/auth 0.0.2 → 0.0.4
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/allow.d.ts +58 -1
- package/dist/allow.js +61 -2
- package/dist/client.d.ts +2 -3
- package/dist/client.js +2 -2
- package/dist/core.d.ts +128 -8
- package/dist/core.js +496 -12
- package/dist/error.d.ts +242 -1
- package/dist/error.js +235 -1
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -12
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +138 -3
- package/dist/pkce.js +160 -1
- package/dist/provider/code.d.ts +211 -3
- package/dist/provider/code.js +1 -1
- package/dist/provider/facebook.d.ts +2 -3
- package/dist/provider/facebook.js +1 -5
- package/dist/provider/github.d.ts +2 -3
- package/dist/provider/github.js +1 -5
- package/dist/provider/google.d.ts +2 -3
- package/dist/provider/google.js +1 -5
- package/dist/provider/oauth2.d.ts +175 -3
- package/dist/provider/oauth2.js +153 -5
- package/dist/provider/password.d.ts +384 -3
- package/dist/provider/password.js +4 -4
- package/dist/provider/provider.d.ts +226 -2
- package/dist/random.js +85 -1
- package/dist/storage/memory.d.ts +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/storage.d.ts +161 -1
- package/dist/storage/storage.js +60 -1
- package/dist/storage/turso.d.ts +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/unstorage.d.ts +1 -1
- package/dist/storage/unstorage.js +1 -1
- package/dist/subject.d.ts +61 -2
- package/dist/themes/theme.d.ts +208 -1
- package/dist/themes/theme.js +118 -1
- package/dist/ui/base.js +420 -2
- package/dist/ui/code.d.ts +1 -3
- package/dist/ui/code.js +3 -4
- package/dist/ui/form.js +59 -1
- package/dist/ui/icon.js +190 -1
- package/dist/ui/password.d.ts +1 -3
- package/dist/ui/password.js +2 -3
- package/dist/ui/select.js +278 -4
- package/dist/util.d.ts +71 -1
- package/dist/util.js +106 -1
- package/package.json +2 -4
- package/dist/allow-CixonwTW.d.ts +0 -59
- package/dist/allow-DX5cehSc.js +0 -63
- package/dist/base-DRutbxgL.js +0 -422
- package/dist/code-DJxdFR7p.d.ts +0 -212
- package/dist/core-BZHEAefX.d.ts +0 -129
- package/dist/core-CDM5o4rs.js +0 -498
- package/dist/error-CWAdNAzm.d.ts +0 -243
- package/dist/error-DgAKK7b2.js +0 -237
- package/dist/form-6XKM_cOk.js +0 -61
- package/dist/icon-Ci5uqGB_.js +0 -192
- package/dist/keys-EEfxEGfO.js +0 -140
- package/dist/oauth2-B7-6Z7Lc.js +0 -155
- package/dist/oauth2-CXHukHf2.d.ts +0 -176
- package/dist/password-C4KLmO0O.d.ts +0 -385
- package/dist/pkce-276Za_rZ.js +0 -162
- package/dist/provider-tndlqCzp.d.ts +0 -227
- package/dist/random-SXMYlaVr.js +0 -87
- package/dist/select-BjySLL8I.js +0 -280
- package/dist/storage-BEaqEPNQ.js +0 -62
- package/dist/storage-CxKerLlc.d.ts +0 -162
- package/dist/subject-DMIMVtaT.d.ts +0 -62
- package/dist/theme-C9by7VXf.d.ts +0 -209
- package/dist/theme-CswaLtbW.js +0 -120
- package/dist/util-CSdHUFOo.js +0 -108
- package/dist/util-DbSKG1Xm.d.ts +0 -72
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
//#region src/storage/storage.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Storage abstraction layer for Draft Auth persistence operations.
|
|
4
|
-
* Provides a unified interface for different storage backends with key encoding,
|
|
5
|
-
* TTL support, and type-safe operations.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Abstract storage adapter interface that must be implemented by all storage backends.
|
|
9
|
-
* Defines the core operations needed for OAuth data persistence.
|
|
10
|
-
*/
|
|
11
|
-
interface StorageAdapter {
|
|
12
|
-
/**
|
|
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
|
-
get(key: string[]): Promise<Record<string, unknown> | undefined>;
|
|
19
|
-
/**
|
|
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
|
-
remove(key: string[]): Promise<void>;
|
|
26
|
-
/**
|
|
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
|
-
set(key: string[], value: unknown, expiry?: Date): Promise<void>;
|
|
35
|
-
/**
|
|
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
|
-
scan(prefix: string[]): AsyncIterable<readonly [string[], unknown]>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Joins an array of key segments into a single string using the separator.
|
|
45
|
-
*
|
|
46
|
-
* @param key - Array of key segments to join
|
|
47
|
-
* @returns Single string representing the full key path
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```ts
|
|
51
|
-
* joinKey(['user', 'session', '123'])
|
|
52
|
-
* // Returns: "user\x1fsession\x1f123"
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
declare const joinKey: (key: string[]) => string;
|
|
56
|
-
/**
|
|
57
|
-
* Splits a joined key string back into its component segments.
|
|
58
|
-
*
|
|
59
|
-
* @param key - Joined key string to split
|
|
60
|
-
* @returns Array of individual key segments
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* splitKey("user\x1fsession\x1f123")
|
|
65
|
-
* // Returns: ['user', 'session', '123']
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
declare const splitKey: (key: string) => string[];
|
|
69
|
-
/**
|
|
70
|
-
* High-level storage operations with key encoding and type safety.
|
|
71
|
-
* Provides a convenient interface over storage adapters with additional features
|
|
72
|
-
* like TTL conversion and key sanitization.
|
|
73
|
-
*/
|
|
74
|
-
declare const Storage: {
|
|
75
|
-
/**
|
|
76
|
-
* Encodes key segments by removing any separator characters to prevent conflicts.
|
|
77
|
-
* Ensures storage keys don't contain characters that could break key parsing.
|
|
78
|
-
*
|
|
79
|
-
* @param key - Array of key segments to encode
|
|
80
|
-
* @returns Array of sanitized key segments
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* Storage.encode(['user', 'data\x1fwith\x1fseparators'])
|
|
85
|
-
* // Returns: ['user', 'datawithseparators']
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
readonly encode: (key: string[]) => string[];
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves a typed value from storage.
|
|
91
|
-
*
|
|
92
|
-
* @template T - Expected type of the stored value
|
|
93
|
-
* @param adapter - Storage adapter to use
|
|
94
|
-
* @param key - Array of key segments identifying the value
|
|
95
|
-
* @returns Promise resolving to the typed value or null if not found
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* interface UserSession {
|
|
100
|
-
* userId: string
|
|
101
|
-
* expiresAt: number
|
|
102
|
-
* }
|
|
103
|
-
*
|
|
104
|
-
* const session = await Storage.get<UserSession>(adapter, ['sessions', sessionId])
|
|
105
|
-
* if (session) {
|
|
106
|
-
* // Fully typed: session.userId
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
readonly get: <T = Record<string, unknown>>(adapter: StorageAdapter, key: string[]) => Promise<T | null>;
|
|
111
|
-
/**
|
|
112
|
-
* Stores a value with optional time-to-live in seconds.
|
|
113
|
-
*
|
|
114
|
-
* @param adapter - Storage adapter to use
|
|
115
|
-
* @param key - Array of key segments identifying where to store
|
|
116
|
-
* @param value - The value to store
|
|
117
|
-
* @param ttlSeconds - Optional TTL in seconds for automatic expiration
|
|
118
|
-
* @returns Promise that resolves when storage is complete
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* // Store with 1 hour TTL
|
|
123
|
-
* await Storage.set(adapter, ['sessions', sessionId], sessionData, 3600)
|
|
124
|
-
*
|
|
125
|
-
* // Store permanently
|
|
126
|
-
* await Storage.set(adapter, ['users', userId], userData)
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
readonly set: (adapter: StorageAdapter, key: string[], value: unknown, ttlSeconds?: number) => Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Removes a value from storage.
|
|
132
|
-
*
|
|
133
|
-
* @param adapter - Storage adapter to use
|
|
134
|
-
* @param key - Array of key segments identifying the value to remove
|
|
135
|
-
* @returns Promise that resolves when removal is complete
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* await Storage.remove(adapter, ['sessions', expiredSessionId])
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
readonly remove: (adapter: StorageAdapter, key: string[]) => Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* Scans for entries matching a key prefix with type safety.
|
|
145
|
-
*
|
|
146
|
-
* @template T - Expected type of the stored values
|
|
147
|
-
* @param adapter - Storage adapter to use
|
|
148
|
-
* @param prefix - Array of key segments to use as prefix filter
|
|
149
|
-
* @returns Async iterable of typed key-value pairs
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* // Find all user sessions
|
|
154
|
-
* for await (const [key, session] of Storage.scan<UserSession>(adapter, ['sessions'])) {
|
|
155
|
-
* // Session: `${key.join('/')} expires at ${session.expiresAt}`
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
readonly scan: <T = Record<string, unknown>>(adapter: StorageAdapter, prefix: string[]) => AsyncIterable<readonly [string[], T]>;
|
|
160
|
-
};
|
|
161
|
-
//#endregion
|
|
162
|
-
export { Storage, StorageAdapter, joinKey, splitKey };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Prettify } from "./util-DbSKG1Xm.js";
|
|
2
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
|
|
4
|
-
//#region src/subject.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Schema definition for subjects, mapping subject type names to their validation schemas.
|
|
8
|
-
* Each key represents a subject type, and each value is a schema that validates
|
|
9
|
-
* the properties for that subject type.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const schema: SubjectSchema = {
|
|
14
|
-
* user: object({ userID: string() }),
|
|
15
|
-
* admin: object({ userID: string(), workspaceID: string() })
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
type SubjectSchema = Record<string, StandardSchemaV1>;
|
|
20
|
-
/**
|
|
21
|
-
* Internal type that transforms a SubjectSchema into a union of subject payload objects.
|
|
22
|
-
* Each payload contains the subject type and its validated properties.
|
|
23
|
-
*
|
|
24
|
-
* @template T - The subject schema to transform
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
type SubjectPayload<T extends SubjectSchema> = Prettify<{ [K in keyof T & string]: {
|
|
28
|
-
type: K;
|
|
29
|
-
properties: StandardSchemaV1.InferOutput<T[K]>;
|
|
30
|
-
} }[keyof T & string]>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a strongly-typed subject schema that can be used throughout your application.
|
|
33
|
-
* The returned schema maintains type information for excellent IDE support and runtime validation.
|
|
34
|
-
*
|
|
35
|
-
* @template Schema - The subject schema type being created
|
|
36
|
-
* @param types - Object mapping subject type names to their validation schemas
|
|
37
|
-
* @returns The same schema object with preserved type information
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { object, string, number } from "valibot"
|
|
42
|
-
*
|
|
43
|
-
* const subjects = createSubjects({
|
|
44
|
-
* user: object({
|
|
45
|
-
* userID: string(),
|
|
46
|
-
* createdAt: number()
|
|
47
|
-
* }),
|
|
48
|
-
* admin: object({
|
|
49
|
-
* userID: string(),
|
|
50
|
-
* workspaceID: string(),
|
|
51
|
-
* permissions: array(string())
|
|
52
|
-
* }),
|
|
53
|
-
* service: object({
|
|
54
|
-
* serviceID: string(),
|
|
55
|
-
* apiVersion: string()
|
|
56
|
-
* })
|
|
57
|
-
* })
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
declare const createSubjects: <Schema extends SubjectSchema>(types: Schema) => Schema;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { SubjectPayload, SubjectSchema, createSubjects };
|
package/dist/theme-C9by7VXf.d.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
//#region src/themes/theme.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Use one of the built-in themes.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { THEME_SST } from "@draftauth/core/themes/theme"
|
|
9
|
-
*
|
|
10
|
-
* export default issuer({
|
|
11
|
-
* theme: THEME_SST,
|
|
12
|
-
* // ...
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Or define your own.
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* import type { Theme } from "@draftauth/core/themes/theme"
|
|
20
|
-
*
|
|
21
|
-
* const MY_THEME: Theme = {
|
|
22
|
-
* title: "Acne",
|
|
23
|
-
* radius: "none",
|
|
24
|
-
* favicon: "https://www.example.com/favicon.svg",
|
|
25
|
-
* // ...
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* export default issuer({
|
|
29
|
-
* theme: MY_THEME,
|
|
30
|
-
* // ...
|
|
31
|
-
* })
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @packageDocumentation
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* A type to define values for light and dark mode.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* {
|
|
42
|
-
* light: "#FFF",
|
|
43
|
-
* dark: "#000"
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
interface ColorScheme {
|
|
48
|
-
/**
|
|
49
|
-
* The value for dark mode.
|
|
50
|
-
*/
|
|
51
|
-
dark: string;
|
|
52
|
-
/**
|
|
53
|
-
* The value for light mode.
|
|
54
|
-
*/
|
|
55
|
-
light: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* A type to define your custom theme.
|
|
59
|
-
*/
|
|
60
|
-
interface Theme {
|
|
61
|
-
/**
|
|
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
|
-
title?: string;
|
|
72
|
-
/**
|
|
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
|
-
favicon?: string;
|
|
83
|
-
/**
|
|
84
|
-
* The border radius of the UI elements.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* {
|
|
89
|
-
* radius: "none"
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
radius?: "none" | "sm" | "md" | "lg" | "full";
|
|
94
|
-
/**
|
|
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
|
-
primary: string | ColorScheme;
|
|
107
|
-
/**
|
|
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
|
-
background?: string | ColorScheme;
|
|
120
|
-
/**
|
|
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
|
-
logo?: string | ColorScheme;
|
|
133
|
-
/**
|
|
134
|
-
* The font family and scale of the theme.
|
|
135
|
-
*/
|
|
136
|
-
font?: {
|
|
137
|
-
/**
|
|
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
|
-
family?: string;
|
|
150
|
-
/**
|
|
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
|
-
scale?: string;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
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
|
-
css?: string;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Built-in default Draft Auth theme.
|
|
182
|
-
*/
|
|
183
|
-
declare const THEME_DRAFTAUTH: Theme;
|
|
184
|
-
/**
|
|
185
|
-
* Built-in theme based on [Terminal](https://terminal.shop).
|
|
186
|
-
*/
|
|
187
|
-
declare const THEME_TERMINAL: Theme;
|
|
188
|
-
/**
|
|
189
|
-
* Built-in theme based on [SST](https://sst.dev).
|
|
190
|
-
*/
|
|
191
|
-
declare const THEME_SST: Theme;
|
|
192
|
-
/**
|
|
193
|
-
* Built-in theme based on [Supabase](https://supabase.com).
|
|
194
|
-
*/
|
|
195
|
-
declare const THEME_SUPABASE: Theme;
|
|
196
|
-
/**
|
|
197
|
-
* Built-in theme based on [Vercel](https://vercel.com).
|
|
198
|
-
*/
|
|
199
|
-
declare const THEME_VERCEL: Theme;
|
|
200
|
-
/**
|
|
201
|
-
* @internal
|
|
202
|
-
*/
|
|
203
|
-
declare const setTheme: (value: Theme) => void;
|
|
204
|
-
/**
|
|
205
|
-
* @internal
|
|
206
|
-
*/
|
|
207
|
-
declare const getTheme: () => any;
|
|
208
|
-
//#endregion
|
|
209
|
-
export { ColorScheme, THEME_DRAFTAUTH, THEME_SST, THEME_SUPABASE, THEME_TERMINAL, THEME_VERCEL, Theme, getTheme, setTheme };
|
package/dist/theme-CswaLtbW.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
//#region src/themes/theme.ts
|
|
2
|
-
/**
|
|
3
|
-
* Built-in default Draft Auth theme.
|
|
4
|
-
*/
|
|
5
|
-
const THEME_DRAFTAUTH = {
|
|
6
|
-
title: "Draft Auth",
|
|
7
|
-
radius: "none",
|
|
8
|
-
background: {
|
|
9
|
-
dark: "black",
|
|
10
|
-
light: "white"
|
|
11
|
-
},
|
|
12
|
-
primary: {
|
|
13
|
-
dark: "white",
|
|
14
|
-
light: "black"
|
|
15
|
-
},
|
|
16
|
-
font: { family: "IBM Plex Sans, sans-serif" },
|
|
17
|
-
css: `
|
|
18
|
-
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@100;200;300;400;500;600;700&display=swap');
|
|
19
|
-
`
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Built-in theme based on [Terminal](https://terminal.shop).
|
|
23
|
-
*/
|
|
24
|
-
const THEME_TERMINAL = {
|
|
25
|
-
title: "terminal",
|
|
26
|
-
radius: "none",
|
|
27
|
-
favicon: "https://www.terminal.shop/favicon.svg",
|
|
28
|
-
logo: {
|
|
29
|
-
dark: "https://www.terminal.shop/images/logo-white.svg",
|
|
30
|
-
light: "https://www.terminal.shop/images/logo-black.svg"
|
|
31
|
-
},
|
|
32
|
-
primary: "#ff5e00",
|
|
33
|
-
background: {
|
|
34
|
-
dark: "rgb(0, 0, 0)",
|
|
35
|
-
light: "rgb(255, 255, 255)"
|
|
36
|
-
},
|
|
37
|
-
font: { family: "Geist Mono, monospace" },
|
|
38
|
-
css: `
|
|
39
|
-
@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100;200;300;400;500;600;700;800;900&display=swap');
|
|
40
|
-
`
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Built-in theme based on [SST](https://sst.dev).
|
|
44
|
-
*/
|
|
45
|
-
const THEME_SST = {
|
|
46
|
-
title: "SST",
|
|
47
|
-
favicon: "https://sst.dev/favicon.svg",
|
|
48
|
-
logo: {
|
|
49
|
-
dark: "https://sst.dev/favicon.svg",
|
|
50
|
-
light: "https://sst.dev/favicon.svg"
|
|
51
|
-
},
|
|
52
|
-
background: {
|
|
53
|
-
dark: "#1a1a2d",
|
|
54
|
-
light: "rgb(255, 255, 255)"
|
|
55
|
-
},
|
|
56
|
-
primary: "#f3663f",
|
|
57
|
-
font: { family: "Rubik, sans-serif" },
|
|
58
|
-
css: `
|
|
59
|
-
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@100;200;300;400;500;600;700;800;900&display=swap');
|
|
60
|
-
`
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Built-in theme based on [Supabase](https://supabase.com).
|
|
64
|
-
*/
|
|
65
|
-
const THEME_SUPABASE = {
|
|
66
|
-
title: "Supabase",
|
|
67
|
-
logo: {
|
|
68
|
-
dark: "https://supabase.com/dashboard/_next/image?url=%2Fdashboard%2Fimg%2Fsupabase-dark.svg&w=128&q=75",
|
|
69
|
-
light: "https://supabase.com/dashboard/_next/image?url=%2Fdashboard%2Fimg%2Fsupabase-light.svg&w=128&q=75"
|
|
70
|
-
},
|
|
71
|
-
background: {
|
|
72
|
-
dark: "#171717",
|
|
73
|
-
light: "#f8f8f8"
|
|
74
|
-
},
|
|
75
|
-
primary: {
|
|
76
|
-
dark: "#006239",
|
|
77
|
-
light: "#72e3ad"
|
|
78
|
-
},
|
|
79
|
-
font: { family: "Varela Round, sans-serif" },
|
|
80
|
-
css: `
|
|
81
|
-
@import url('https://fonts.googleapis.com/css2?family=Varela+Round:wght@100;200;300;400;500;600;700;800;900&display=swap');
|
|
82
|
-
`
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Built-in theme based on [Vercel](https://vercel.com).
|
|
86
|
-
*/
|
|
87
|
-
const THEME_VERCEL = {
|
|
88
|
-
title: "Vercel",
|
|
89
|
-
logo: {
|
|
90
|
-
dark: "https://vercel.com/mktng/_next/static/media/vercel-logotype-dark.e8c0a742.svg",
|
|
91
|
-
light: "https://vercel.com/mktng/_next/static/media/vercel-logotype-light.700a8d26.svg"
|
|
92
|
-
},
|
|
93
|
-
background: {
|
|
94
|
-
dark: "black",
|
|
95
|
-
light: "white"
|
|
96
|
-
},
|
|
97
|
-
primary: {
|
|
98
|
-
dark: "white",
|
|
99
|
-
light: "black"
|
|
100
|
-
},
|
|
101
|
-
font: { family: "Geist, sans-serif" },
|
|
102
|
-
css: `
|
|
103
|
-
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100;200;300;400;500;600;700;800;900&display=swap');
|
|
104
|
-
`
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* @internal
|
|
108
|
-
*/
|
|
109
|
-
const setTheme = (value) => {
|
|
110
|
-
globalThis.DRAFTAUTH_THEME = value;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
const getTheme = () => {
|
|
116
|
-
return globalThis.DRAFTAUTH_THEME || THEME_DRAFTAUTH;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
export { THEME_DRAFTAUTH, THEME_SST, THEME_SUPABASE, THEME_TERMINAL, THEME_VERCEL, getTheme, setTheme };
|
package/dist/util-CSdHUFOo.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
//#region src/util.ts
|
|
2
|
-
/**
|
|
3
|
-
* Constructs a complete URL relative to the current request context.
|
|
4
|
-
* Handles proxy headers (x-forwarded-*) to ensure correct URL generation
|
|
5
|
-
* in containerized and load-balanced environments.
|
|
6
|
-
*
|
|
7
|
-
* @param ctx - Router context containing request information
|
|
8
|
-
* @param path - Relative path to append to the base URL
|
|
9
|
-
* @returns Complete URL string with proper protocol, host, and port
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const callbackUrl = getRelativeUrl(ctx, "/callback")
|
|
14
|
-
* // Returns: "https://myapp.com/auth/callback"
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
const getRelativeUrl = (ctx, path) => {
|
|
18
|
-
const result = new URL(path, ctx.request.url);
|
|
19
|
-
result.host = ctx.header("x-forwarded-host") || result.host;
|
|
20
|
-
result.protocol = ctx.header("x-forwarded-proto") || result.protocol;
|
|
21
|
-
result.port = ctx.header("x-forwarded-port") || result.port;
|
|
22
|
-
return result.toString();
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* List of known two-part top-level domains that require special handling
|
|
26
|
-
* for domain matching. These domains have an additional level that should
|
|
27
|
-
* be considered when determining effective domain boundaries.
|
|
28
|
-
*/
|
|
29
|
-
const twoPartTlds = [
|
|
30
|
-
"co.uk",
|
|
31
|
-
"co.jp",
|
|
32
|
-
"co.kr",
|
|
33
|
-
"co.nz",
|
|
34
|
-
"co.za",
|
|
35
|
-
"co.in",
|
|
36
|
-
"com.au",
|
|
37
|
-
"com.br",
|
|
38
|
-
"com.cn",
|
|
39
|
-
"com.mx",
|
|
40
|
-
"com.tw",
|
|
41
|
-
"net.au",
|
|
42
|
-
"org.uk",
|
|
43
|
-
"ne.jp",
|
|
44
|
-
"ac.uk",
|
|
45
|
-
"gov.uk",
|
|
46
|
-
"edu.au",
|
|
47
|
-
"gov.au"
|
|
48
|
-
];
|
|
49
|
-
/**
|
|
50
|
-
* Determines if two domain names are considered a match for security purposes.
|
|
51
|
-
* Uses effective TLD+1 matching to allow subdomains while preventing
|
|
52
|
-
* unauthorized cross-domain requests.
|
|
53
|
-
*
|
|
54
|
-
* @param a - First domain name to compare
|
|
55
|
-
* @param b - Second domain name to compare
|
|
56
|
-
* @returns True if domains are considered a security match
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* isDomainMatch("app.example.com", "auth.example.com") // true
|
|
61
|
-
* isDomainMatch("example.com", "evil.com") // false
|
|
62
|
-
* isDomainMatch("app.co.uk", "auth.co.uk") // true (handles two-part TLD)
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
const isDomainMatch = (a, b) => {
|
|
66
|
-
if (a === b) return true;
|
|
67
|
-
const partsA = a.split(".");
|
|
68
|
-
const partsB = b.split(".");
|
|
69
|
-
const hasTwoPartTld = twoPartTlds.some((tld) => a.endsWith(`.${tld}`) || b.endsWith(`.${tld}`));
|
|
70
|
-
const numParts = hasTwoPartTld ? -3 : -2;
|
|
71
|
-
const min = Math.min(partsA.length, partsB.length, numParts);
|
|
72
|
-
const tailA = partsA.slice(min).join(".");
|
|
73
|
-
const tailB = partsB.slice(min).join(".");
|
|
74
|
-
return tailA === tailB;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Creates a lazy-evaluated function that caches the result of the first execution.
|
|
78
|
-
* Subsequent calls return the cached value without re-executing the function.
|
|
79
|
-
*
|
|
80
|
-
* @template T - The return type of the lazy function
|
|
81
|
-
* @param fn - Function to execute lazily
|
|
82
|
-
* @returns Function that returns the cached result
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* const expensiveOperation = lazy(() => {
|
|
87
|
-
* // Computing... (only logs once)
|
|
88
|
-
* return heavyComputation()
|
|
89
|
-
* })
|
|
90
|
-
*
|
|
91
|
-
* const result1 = expensiveOperation() // Executes and caches
|
|
92
|
-
* const result2 = expensiveOperation() // Returns cached value
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
const lazy = (fn) => {
|
|
96
|
-
let value;
|
|
97
|
-
let hasValue = false;
|
|
98
|
-
return () => {
|
|
99
|
-
if (!hasValue) {
|
|
100
|
-
value = fn();
|
|
101
|
-
hasValue = true;
|
|
102
|
-
}
|
|
103
|
-
return value;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
export { getRelativeUrl, isDomainMatch, lazy };
|