@draftlab/auth 0.0.3 → 0.1.0

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.
Files changed (78) hide show
  1. package/dist/allow.d.ts +58 -1
  2. package/dist/allow.js +61 -2
  3. package/dist/client.d.ts +2 -3
  4. package/dist/client.js +2 -2
  5. package/dist/core.d.ts +128 -8
  6. package/dist/core.js +496 -12
  7. package/dist/error.d.ts +242 -1
  8. package/dist/error.js +235 -1
  9. package/dist/index.d.ts +1 -8
  10. package/dist/index.js +1 -12
  11. package/dist/keys.d.ts +1 -1
  12. package/dist/keys.js +138 -3
  13. package/dist/pkce.js +160 -1
  14. package/dist/provider/code.d.ts +227 -3
  15. package/dist/provider/code.js +27 -14
  16. package/dist/provider/facebook.d.ts +2 -3
  17. package/dist/provider/facebook.js +1 -5
  18. package/dist/provider/github.d.ts +2 -3
  19. package/dist/provider/github.js +1 -5
  20. package/dist/provider/google.d.ts +2 -3
  21. package/dist/provider/google.js +1 -5
  22. package/dist/provider/oauth2.d.ts +175 -3
  23. package/dist/provider/oauth2.js +153 -5
  24. package/dist/provider/password.d.ts +384 -3
  25. package/dist/provider/password.js +4 -4
  26. package/dist/provider/provider.d.ts +226 -2
  27. package/dist/random.js +85 -1
  28. package/dist/storage/memory.d.ts +2 -2
  29. package/dist/storage/memory.js +1 -1
  30. package/dist/storage/storage.d.ts +161 -1
  31. package/dist/storage/storage.js +60 -1
  32. package/dist/storage/turso.d.ts +1 -1
  33. package/dist/storage/turso.js +1 -1
  34. package/dist/storage/unstorage.d.ts +2 -2
  35. package/dist/storage/unstorage.js +2 -2
  36. package/dist/subject.d.ts +61 -2
  37. package/dist/themes/theme.d.ts +208 -1
  38. package/dist/themes/theme.js +118 -1
  39. package/dist/ui/base.d.ts +22 -35
  40. package/dist/ui/base.js +388 -3
  41. package/dist/ui/code.d.ts +22 -137
  42. package/dist/ui/code.js +199 -161
  43. package/dist/ui/form.d.ts +8 -6
  44. package/dist/ui/form.js +57 -1
  45. package/dist/ui/icon.d.ts +7 -84
  46. package/dist/ui/icon.js +69 -2
  47. package/dist/ui/password.d.ts +30 -37
  48. package/dist/ui/password.js +340 -237
  49. package/dist/ui/select.d.ts +19 -218
  50. package/dist/ui/select.js +91 -4
  51. package/dist/util.d.ts +71 -1
  52. package/dist/util.js +106 -1
  53. package/package.json +5 -3
  54. package/dist/allow-CixonwTW.d.ts +0 -59
  55. package/dist/allow-DX5cehSc.js +0 -63
  56. package/dist/base-DRutbxgL.js +0 -422
  57. package/dist/code-DJxdFR7p.d.ts +0 -212
  58. package/dist/core-BZHEAefX.d.ts +0 -129
  59. package/dist/core-CDM5o4rs.js +0 -498
  60. package/dist/error-CWAdNAzm.d.ts +0 -243
  61. package/dist/error-DgAKK7b2.js +0 -237
  62. package/dist/form-6XKM_cOk.js +0 -61
  63. package/dist/icon-Ci5uqGB_.js +0 -192
  64. package/dist/keys-EEfxEGfO.js +0 -140
  65. package/dist/oauth2-B7-6Z7Lc.js +0 -155
  66. package/dist/oauth2-CXHukHf2.d.ts +0 -176
  67. package/dist/password-C4KLmO0O.d.ts +0 -385
  68. package/dist/pkce-276Za_rZ.js +0 -162
  69. package/dist/provider-tndlqCzp.d.ts +0 -227
  70. package/dist/random-SXMYlaVr.js +0 -87
  71. package/dist/select-BjySLL8I.js +0 -280
  72. package/dist/storage-BEaqEPNQ.js +0 -62
  73. package/dist/storage-CxKerLlc.d.ts +0 -162
  74. package/dist/subject-DMIMVtaT.d.ts +0 -62
  75. package/dist/theme-C9by7VXf.d.ts +0 -209
  76. package/dist/theme-CswaLtbW.js +0 -120
  77. package/dist/util-CSdHUFOo.js +0 -108
  78. package/dist/util-DbSKG1Xm.d.ts +0 -72
package/dist/random.js CHANGED
@@ -1,3 +1,87 @@
1
- import { generateSecureToken, generateUnbiasedDigits, timingSafeCompare } from "./random-SXMYlaVr.js";
1
+ import { timingSafeEqual } from "node:crypto";
2
2
 
3
+ //#region src/random.ts
4
+ /**
5
+ * Cryptographic utilities for secure random generation and comparison operations.
6
+ * These functions are designed to prevent timing attacks and provide unbiased randomness.
7
+ */
8
+ /**
9
+ * Generates a cryptographically secure token with enhanced entropy.
10
+ * Uses Web Crypto API and provides 256 bits of entropy
11
+ *
12
+ * @param length - Length of random data in bytes (default: 32 for 256-bit security)
13
+ * @returns Base64url-encoded secure token
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const authCode = generateSecureToken()
18
+ * // Returns: "7B8kJ9mN3pQ2rS5tU8vW0xY1zA3bC6dE9fG2hI5jK8lM" (example)
19
+ *
20
+ * const refreshToken = generateSecureToken(24) // 192-bit token
21
+ * // Returns: "4A7bC9dF2gH5iJ8kL1mN4pQ7rS0tU" (example)
22
+ * ```
23
+ */
24
+ const generateSecureToken = (length = 32) => {
25
+ if (length <= 0 || !Number.isInteger(length)) throw new RangeError("Token length must be a positive integer");
26
+ const randomBytes$1 = new Uint8Array(length);
27
+ crypto.getRandomValues(randomBytes$1);
28
+ const base64 = btoa(String.fromCharCode.apply(null, Array.from(randomBytes$1)));
29
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
30
+ };
31
+ /**
32
+ * Generates a cryptographically secure string of random digits without modulo bias.
33
+ * Uses rejection sampling to ensure each digit (0-9) has an equal probability of being selected.
34
+ *
35
+ * @param length - Number of digits to generate (must be positive)
36
+ * @returns String containing exactly the specified number of random digits
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const pinCode = generateUnbiasedDigits(6)
41
+ * // Returns: "492847" (example - actual result is random)
42
+ *
43
+ * const shortCode = generateUnbiasedDigits(4)
44
+ * // Returns: "7291" (example - actual result is random)
45
+ * ```
46
+ *
47
+ * @throws {RangeError} If length is not a positive number
48
+ */
49
+ const generateUnbiasedDigits = (length) => {
50
+ if (length <= 0 || !Number.isInteger(length)) throw new RangeError("Length must be a positive integer");
51
+ const result = [];
52
+ while (result.length < length) {
53
+ const buffer = crypto.getRandomValues(new Uint8Array(length * 2));
54
+ for (const byte of buffer) if (byte < 250 && result.length < length) result.push(byte % 10);
55
+ }
56
+ return result.join("");
57
+ };
58
+ /**
59
+ * Performs a timing-safe comparison of two strings to prevent timing attacks.
60
+ * Always takes the same amount of time regardless of where the strings differ,
61
+ * making it safe for comparing sensitive values like tokens or passwords.
62
+ *
63
+ * @param a - First string to compare
64
+ * @param b - Second string to compare
65
+ * @returns True if strings are identical, false otherwise
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * // Safe for comparing sensitive values
70
+ * const isValidToken = timingSafeCompare(userToken, expectedToken)
71
+ *
72
+ * // Safe for password verification
73
+ * const isValidPassword = timingSafeCompare(hashedInput, storedHash)
74
+ *
75
+ * // Returns false for different types or lengths
76
+ * timingSafeCompare("abc", 123 as any) // false
77
+ * timingSafeCompare("abc", "abcd") // false
78
+ * ```
79
+ */
80
+ const timingSafeCompare = (a, b) => {
81
+ if (typeof a !== "string" || typeof b !== "string") return false;
82
+ if (a.length !== b.length) return false;
83
+ return timingSafeEqual(Buffer.from(a), Buffer.from(b));
84
+ };
85
+
86
+ //#endregion
3
87
  export { generateSecureToken, generateUnbiasedDigits, timingSafeCompare };
@@ -1,4 +1,4 @@
1
- import { StorageAdapter } from "../storage-CxKerLlc.js";
1
+ import { StorageAdapter } from "./storage.js";
2
2
 
3
3
  //#region src/storage/memory.d.ts
4
4
 
@@ -9,7 +9,7 @@ import { StorageAdapter } from "../storage-CxKerLlc.js";
9
9
  *
10
10
  * ### Basic in-memory storage (development only)
11
11
  * ```ts
12
- * import { MemoryStorage } from "@draftauth/core/storage/memory"
12
+ * import { MemoryStorage } from "@draftlab/auth/storage/memory"
13
13
  *
14
14
  * const storage = MemoryStorage()
15
15
  *
@@ -1,4 +1,4 @@
1
- import { joinKey, splitKey } from "../storage-BEaqEPNQ.js";
1
+ import { joinKey, splitKey } from "./storage.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { writeFile } from "node:fs/promises";
4
4
 
@@ -1,2 +1,162 @@
1
- import { Storage, StorageAdapter, joinKey, splitKey } from "../storage-CxKerLlc.js";
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
2
162
  export { Storage, StorageAdapter, joinKey, splitKey };
@@ -1,3 +1,62 @@
1
- import { Storage, joinKey, splitKey } from "../storage-BEaqEPNQ.js";
1
+ //#region src/storage/storage.ts
2
+ /**
3
+ * ASCII unit separator character used to join key segments.
4
+ * Using a control character ensures it won't conflict with user data.
5
+ */
6
+ const SEPARATOR = String.fromCharCode(31);
7
+ /**
8
+ * Joins an array of key segments into a single string using the separator.
9
+ *
10
+ * @param key - Array of key segments to join
11
+ * @returns Single string representing the full key path
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * joinKey(['user', 'session', '123'])
16
+ * // Returns: "user\x1fsession\x1f123"
17
+ * ```
18
+ */
19
+ const joinKey = (key) => {
20
+ return key.join(SEPARATOR);
21
+ };
22
+ /**
23
+ * Splits a joined key string back into its component segments.
24
+ *
25
+ * @param key - Joined key string to split
26
+ * @returns Array of individual key segments
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * splitKey("user\x1fsession\x1f123")
31
+ * // Returns: ['user', 'session', '123']
32
+ * ```
33
+ */
34
+ const splitKey = (key) => {
35
+ return key.split(SEPARATOR);
36
+ };
37
+ /**
38
+ * High-level storage operations with key encoding and type safety.
39
+ * Provides a convenient interface over storage adapters with additional features
40
+ * like TTL conversion and key sanitization.
41
+ */
42
+ const Storage = {
43
+ encode: (key) => {
44
+ return key.map((segment) => segment.replaceAll(SEPARATOR, ""));
45
+ },
46
+ get: (adapter, key) => {
47
+ return adapter.get(Storage.encode(key));
48
+ },
49
+ set: (adapter, key, value, ttlSeconds) => {
50
+ const expiry = ttlSeconds ? new Date(Date.now() + ttlSeconds * 1e3) : void 0;
51
+ return adapter.set(Storage.encode(key), value, expiry);
52
+ },
53
+ remove: (adapter, key) => {
54
+ return adapter.remove(Storage.encode(key));
55
+ },
56
+ scan: (adapter, prefix) => {
57
+ return adapter.scan(Storage.encode(prefix));
58
+ }
59
+ };
2
60
 
61
+ //#endregion
3
62
  export { Storage, joinKey, splitKey };
@@ -1,4 +1,4 @@
1
- import { StorageAdapter } from "../storage-CxKerLlc.js";
1
+ import { StorageAdapter } from "./storage.js";
2
2
  import { Client } from "@libsql/client";
3
3
 
4
4
  //#region src/storage/turso.d.ts
@@ -1,4 +1,4 @@
1
- import { joinKey, splitKey } from "../storage-BEaqEPNQ.js";
1
+ import { joinKey, splitKey } from "./storage.js";
2
2
 
3
3
  //#region src/storage/turso.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { StorageAdapter } from "../storage-CxKerLlc.js";
1
+ import { StorageAdapter } from "./storage.js";
2
2
  import { Driver } from "unstorage";
3
3
 
4
4
  //#region src/storage/unstorage.d.ts
@@ -13,7 +13,7 @@ import { Driver } from "unstorage";
13
13
  *
14
14
  * @example
15
15
  * ```ts
16
- * import { UnStorage } from "@draftauth/core/storage/unstorage"
16
+ * import { UnStorage } from "@draftlab/auth/storage/unstorage"
17
17
  * import redisDriver from "unstorage/drivers/redis"
18
18
  *
19
19
  * // Using Redis driver
@@ -1,4 +1,4 @@
1
- import { joinKey, splitKey } from "../storage-BEaqEPNQ.js";
1
+ import { joinKey, splitKey } from "./storage.js";
2
2
  import { createStorage } from "unstorage";
3
3
 
4
4
  //#region src/storage/unstorage.ts
@@ -12,7 +12,7 @@ import { createStorage } from "unstorage";
12
12
  *
13
13
  * @example
14
14
  * ```ts
15
- * import { UnStorage } from "@draftauth/core/storage/unstorage"
15
+ * import { UnStorage } from "@draftlab/auth/storage/unstorage"
16
16
  * import redisDriver from "unstorage/drivers/redis"
17
17
  *
18
18
  * // Using Redis driver
package/dist/subject.d.ts CHANGED
@@ -1,3 +1,62 @@
1
- import "./util-DbSKG1Xm.js";
2
- import { SubjectPayload, SubjectSchema, createSubjects } from "./subject-DMIMVtaT.js";
1
+ import { Prettify } from "./util.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
3
62
  export { SubjectPayload, SubjectSchema, createSubjects };
@@ -1,2 +1,209 @@
1
- import { ColorScheme, THEME_DRAFTAUTH, THEME_SST, THEME_SUPABASE, THEME_TERMINAL, THEME_VERCEL, Theme, getTheme, setTheme } from "../theme-C9by7VXf.js";
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 "@draftlab/auth/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 "@draftlab/auth/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
2
209
  export { ColorScheme, THEME_DRAFTAUTH, THEME_SST, THEME_SUPABASE, THEME_TERMINAL, THEME_VERCEL, Theme, getTheme, setTheme };