@better-auth/electron 1.5.0-beta.20 → 1.5.1-beta.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/{browser-CCZQ2aoV.d.mts → client-DVs5eLfi.d.mts} +191 -1
- package/dist/client.d.mts +1 -193
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/preload.d.mts +75 -5
- package/dist/proxy.d.mts +1 -1
- package/dist/storage.d.mts +1 -2
- package/package.json +6 -6
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import * as better_auth0 from "better-auth";
|
|
2
|
+
import { ClientStore } from "better-auth";
|
|
1
3
|
import * as z from "zod";
|
|
4
|
+
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
2
5
|
import { BetterFetch, BetterFetchError, CreateFetchOption } from "@better-fetch/fetch";
|
|
3
6
|
import electron from "electron";
|
|
4
7
|
import { Awaitable, BetterAuthClientOptions } from "@better-auth/core";
|
|
@@ -308,4 +311,191 @@ declare function handleDeepLink({
|
|
|
308
311
|
clientOptions?: BetterAuthClientOptions | undefined;
|
|
309
312
|
}): Promise<void>;
|
|
310
313
|
//#endregion
|
|
311
|
-
|
|
314
|
+
//#region src/client.d.ts
|
|
315
|
+
declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
316
|
+
id: "electron";
|
|
317
|
+
fetchPlugins: {
|
|
318
|
+
id: string;
|
|
319
|
+
name: string;
|
|
320
|
+
init(url: string, options: ({
|
|
321
|
+
priority?: RequestPriority | undefined;
|
|
322
|
+
cache?: RequestCache | undefined;
|
|
323
|
+
credentials?: RequestCredentials | undefined;
|
|
324
|
+
headers?: (HeadersInit & (HeadersInit | {
|
|
325
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
326
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
327
|
+
authorization: "Bearer" | "Basic";
|
|
328
|
+
})) | undefined;
|
|
329
|
+
integrity?: string | undefined;
|
|
330
|
+
keepalive?: boolean | undefined;
|
|
331
|
+
method?: string | undefined;
|
|
332
|
+
mode?: RequestMode | undefined;
|
|
333
|
+
redirect?: RequestRedirect | undefined;
|
|
334
|
+
referrer?: string | undefined;
|
|
335
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
336
|
+
signal?: (AbortSignal | null) | undefined;
|
|
337
|
+
window?: null | undefined;
|
|
338
|
+
onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
|
|
339
|
+
onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
340
|
+
onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
341
|
+
onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
342
|
+
onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
343
|
+
hookOptions?: {
|
|
344
|
+
cloneResponse?: boolean;
|
|
345
|
+
} | undefined;
|
|
346
|
+
timeout?: number | undefined;
|
|
347
|
+
customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
|
|
348
|
+
plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
|
|
349
|
+
baseURL?: string | undefined;
|
|
350
|
+
throw?: boolean | undefined;
|
|
351
|
+
auth?: ({
|
|
352
|
+
type: "Bearer";
|
|
353
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
354
|
+
} | {
|
|
355
|
+
type: "Basic";
|
|
356
|
+
username: string | (() => string | undefined) | undefined;
|
|
357
|
+
password: string | (() => string | undefined) | undefined;
|
|
358
|
+
} | {
|
|
359
|
+
type: "Custom";
|
|
360
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
361
|
+
value: string | (() => string | undefined) | undefined;
|
|
362
|
+
}) | undefined;
|
|
363
|
+
body?: any;
|
|
364
|
+
query?: any;
|
|
365
|
+
params?: any;
|
|
366
|
+
duplex?: "full" | "half" | undefined;
|
|
367
|
+
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
368
|
+
retry?: _better_fetch_fetch0.RetryOptions | undefined;
|
|
369
|
+
retryAttempt?: number | undefined;
|
|
370
|
+
output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
371
|
+
errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
372
|
+
disableValidation?: boolean | undefined;
|
|
373
|
+
} & Record<string, any>) | undefined): Promise<{
|
|
374
|
+
url: string;
|
|
375
|
+
options: {
|
|
376
|
+
priority?: RequestPriority | undefined;
|
|
377
|
+
cache?: RequestCache | undefined;
|
|
378
|
+
credentials?: RequestCredentials | undefined;
|
|
379
|
+
headers?: (HeadersInit & (HeadersInit | {
|
|
380
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
381
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
382
|
+
authorization: "Bearer" | "Basic";
|
|
383
|
+
})) | undefined;
|
|
384
|
+
integrity?: string | undefined;
|
|
385
|
+
keepalive?: boolean | undefined;
|
|
386
|
+
method?: string | undefined;
|
|
387
|
+
mode?: RequestMode | undefined;
|
|
388
|
+
redirect?: RequestRedirect | undefined;
|
|
389
|
+
referrer?: string | undefined;
|
|
390
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
391
|
+
signal?: (AbortSignal | null) | undefined;
|
|
392
|
+
window?: null | undefined;
|
|
393
|
+
onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
|
|
394
|
+
onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
395
|
+
onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
396
|
+
onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
397
|
+
onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
398
|
+
hookOptions?: {
|
|
399
|
+
cloneResponse?: boolean;
|
|
400
|
+
} | undefined;
|
|
401
|
+
timeout?: number | undefined;
|
|
402
|
+
customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
|
|
403
|
+
plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
|
|
404
|
+
baseURL?: string | undefined;
|
|
405
|
+
throw?: boolean | undefined;
|
|
406
|
+
auth?: ({
|
|
407
|
+
type: "Bearer";
|
|
408
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
409
|
+
} | {
|
|
410
|
+
type: "Basic";
|
|
411
|
+
username: string | (() => string | undefined) | undefined;
|
|
412
|
+
password: string | (() => string | undefined) | undefined;
|
|
413
|
+
} | {
|
|
414
|
+
type: "Custom";
|
|
415
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
416
|
+
value: string | (() => string | undefined) | undefined;
|
|
417
|
+
}) | undefined;
|
|
418
|
+
body?: any;
|
|
419
|
+
query?: any;
|
|
420
|
+
params?: any;
|
|
421
|
+
duplex?: "full" | "half" | undefined;
|
|
422
|
+
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
423
|
+
retry?: _better_fetch_fetch0.RetryOptions | undefined;
|
|
424
|
+
retryAttempt?: number | undefined;
|
|
425
|
+
output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
426
|
+
errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
427
|
+
disableValidation?: boolean | undefined;
|
|
428
|
+
} & Record<string, any>;
|
|
429
|
+
}>;
|
|
430
|
+
hooks: {
|
|
431
|
+
onSuccess: (context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void>;
|
|
432
|
+
onError: (context: _better_fetch_fetch0.ErrorContext) => Promise<void>;
|
|
433
|
+
};
|
|
434
|
+
}[];
|
|
435
|
+
getActions: ($fetch: _better_fetch_fetch0.BetterFetch, $store: ClientStore, clientOptions: better_auth0.BetterAuthClientOptions | undefined) => {
|
|
436
|
+
/**
|
|
437
|
+
* Gets the stored cookie.
|
|
438
|
+
*
|
|
439
|
+
* You can use this to get the cookie stored in
|
|
440
|
+
* the device and use it in your fetch requests.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* const cookie = client.getCookie();
|
|
445
|
+
* await fetch("https://api.example.com", {
|
|
446
|
+
* headers: {
|
|
447
|
+
* cookie,
|
|
448
|
+
* },
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
getCookie: () => string;
|
|
453
|
+
/**
|
|
454
|
+
* Exchanges the authorization code for a session.
|
|
455
|
+
*
|
|
456
|
+
* Use this when you need to manually complete the exchange
|
|
457
|
+
* (e.g., when another app registered the scheme or deep linking fails).
|
|
458
|
+
*
|
|
459
|
+
* The authorization code is returned when the user is authorized in the browser. (`electron_authorization_code`)
|
|
460
|
+
*
|
|
461
|
+
* Note: Must be called after `requestAuth`, since the code verifier and state are stored when the auth flow is initiated.
|
|
462
|
+
*/
|
|
463
|
+
authenticate: (data: ElectronAuthenticateOptions) => Promise<{
|
|
464
|
+
data: null;
|
|
465
|
+
error: {
|
|
466
|
+
message?: string | undefined;
|
|
467
|
+
status: number;
|
|
468
|
+
statusText: string;
|
|
469
|
+
};
|
|
470
|
+
} | {
|
|
471
|
+
data: {
|
|
472
|
+
token: string;
|
|
473
|
+
user: better_auth0.User & Record<string, any>;
|
|
474
|
+
};
|
|
475
|
+
error: null;
|
|
476
|
+
}>;
|
|
477
|
+
/**
|
|
478
|
+
* Initiates the authentication process.
|
|
479
|
+
* Opens the system's default browser for user authentication.
|
|
480
|
+
*/
|
|
481
|
+
requestAuth: (options?: ElectronRequestAuthOptions | undefined) => Promise<void>;
|
|
482
|
+
/**
|
|
483
|
+
* Sets up the main process.
|
|
484
|
+
*
|
|
485
|
+
* - Registers custom protocol scheme.
|
|
486
|
+
* - Registers IPC bridge handlers.
|
|
487
|
+
* - Handles content security policy if needed.
|
|
488
|
+
*/
|
|
489
|
+
setupMain: (cfg?: {
|
|
490
|
+
csp?: boolean | undefined;
|
|
491
|
+
bridges?: boolean | undefined;
|
|
492
|
+
scheme?: boolean | undefined;
|
|
493
|
+
getWindow?: () => electron.BrowserWindow | null | undefined;
|
|
494
|
+
}) => void;
|
|
495
|
+
$Infer: {
|
|
496
|
+
Bridges: ExposedBridges<O>;
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
//#endregion
|
|
501
|
+
export { setupRenderer as _, authenticate as a, ElectronClientOptions as c, Storage as d, FetchUserImageResult as f, SetupRendererConfig as g, ExposedBridges as h, ElectronRequestAuthOptions as i, ElectronProxyClientOptions as l, normalizeUserOutput as m, handleDeepLink as n, kElectron as o, fetchUserImage as p, ElectronAuthenticateOptions as r, requestAuth as s, electronClient as t, ElectronSharedClientOptions as u, ElectronOptions as v, ElectronSharedOptions as y };
|
package/dist/client.d.mts
CHANGED
|
@@ -1,194 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import * as better_auth0 from "better-auth";
|
|
3
|
-
import { ClientStore } from "better-auth";
|
|
4
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
5
|
-
import electron from "electron";
|
|
6
|
-
|
|
7
|
-
//#region src/client.d.ts
|
|
8
|
-
declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
9
|
-
id: "electron";
|
|
10
|
-
fetchPlugins: {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
init(url: string, options: ({
|
|
14
|
-
cache?: RequestCache | undefined;
|
|
15
|
-
credentials?: RequestCredentials | undefined;
|
|
16
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
17
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
18
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
19
|
-
authorization: "Bearer" | "Basic";
|
|
20
|
-
})) | undefined;
|
|
21
|
-
integrity?: string | undefined;
|
|
22
|
-
keepalive?: boolean | undefined;
|
|
23
|
-
method?: string | undefined;
|
|
24
|
-
mode?: RequestMode | undefined;
|
|
25
|
-
priority?: RequestPriority | undefined;
|
|
26
|
-
redirect?: RequestRedirect | undefined;
|
|
27
|
-
referrer?: string | undefined;
|
|
28
|
-
referrerPolicy?: ReferrerPolicy | undefined;
|
|
29
|
-
signal?: (AbortSignal | null) | undefined;
|
|
30
|
-
window?: null | undefined;
|
|
31
|
-
onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
|
|
32
|
-
onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
33
|
-
onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
34
|
-
onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
35
|
-
onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
36
|
-
hookOptions?: {
|
|
37
|
-
cloneResponse?: boolean;
|
|
38
|
-
} | undefined;
|
|
39
|
-
timeout?: number | undefined;
|
|
40
|
-
customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
|
|
41
|
-
plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
|
|
42
|
-
baseURL?: string | undefined;
|
|
43
|
-
throw?: boolean | undefined;
|
|
44
|
-
auth?: ({
|
|
45
|
-
type: "Bearer";
|
|
46
|
-
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
47
|
-
} | {
|
|
48
|
-
type: "Basic";
|
|
49
|
-
username: string | (() => string | undefined) | undefined;
|
|
50
|
-
password: string | (() => string | undefined) | undefined;
|
|
51
|
-
} | {
|
|
52
|
-
type: "Custom";
|
|
53
|
-
prefix: string | (() => string | undefined) | undefined;
|
|
54
|
-
value: string | (() => string | undefined) | undefined;
|
|
55
|
-
}) | undefined;
|
|
56
|
-
body?: any;
|
|
57
|
-
query?: any;
|
|
58
|
-
params?: any;
|
|
59
|
-
duplex?: "full" | "half" | undefined;
|
|
60
|
-
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
61
|
-
retry?: _better_fetch_fetch0.RetryOptions | undefined;
|
|
62
|
-
retryAttempt?: number | undefined;
|
|
63
|
-
output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
64
|
-
errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
65
|
-
disableValidation?: boolean | undefined;
|
|
66
|
-
} & Record<string, any>) | undefined): Promise<{
|
|
67
|
-
url: string;
|
|
68
|
-
options: {
|
|
69
|
-
cache?: RequestCache | undefined;
|
|
70
|
-
credentials?: RequestCredentials | undefined;
|
|
71
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
72
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
73
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
74
|
-
authorization: "Bearer" | "Basic";
|
|
75
|
-
})) | undefined;
|
|
76
|
-
integrity?: string | undefined;
|
|
77
|
-
keepalive?: boolean | undefined;
|
|
78
|
-
method?: string | undefined;
|
|
79
|
-
mode?: RequestMode | undefined;
|
|
80
|
-
priority?: RequestPriority | undefined;
|
|
81
|
-
redirect?: RequestRedirect | undefined;
|
|
82
|
-
referrer?: string | undefined;
|
|
83
|
-
referrerPolicy?: ReferrerPolicy | undefined;
|
|
84
|
-
signal?: (AbortSignal | null) | undefined;
|
|
85
|
-
window?: null | undefined;
|
|
86
|
-
onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
|
|
87
|
-
onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
88
|
-
onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
89
|
-
onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
90
|
-
onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
91
|
-
hookOptions?: {
|
|
92
|
-
cloneResponse?: boolean;
|
|
93
|
-
} | undefined;
|
|
94
|
-
timeout?: number | undefined;
|
|
95
|
-
customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
|
|
96
|
-
plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
|
|
97
|
-
baseURL?: string | undefined;
|
|
98
|
-
throw?: boolean | undefined;
|
|
99
|
-
auth?: ({
|
|
100
|
-
type: "Bearer";
|
|
101
|
-
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
102
|
-
} | {
|
|
103
|
-
type: "Basic";
|
|
104
|
-
username: string | (() => string | undefined) | undefined;
|
|
105
|
-
password: string | (() => string | undefined) | undefined;
|
|
106
|
-
} | {
|
|
107
|
-
type: "Custom";
|
|
108
|
-
prefix: string | (() => string | undefined) | undefined;
|
|
109
|
-
value: string | (() => string | undefined) | undefined;
|
|
110
|
-
}) | undefined;
|
|
111
|
-
body?: any;
|
|
112
|
-
query?: any;
|
|
113
|
-
params?: any;
|
|
114
|
-
duplex?: "full" | "half" | undefined;
|
|
115
|
-
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
116
|
-
retry?: _better_fetch_fetch0.RetryOptions | undefined;
|
|
117
|
-
retryAttempt?: number | undefined;
|
|
118
|
-
output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
119
|
-
errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
120
|
-
disableValidation?: boolean | undefined;
|
|
121
|
-
} & Record<string, any>;
|
|
122
|
-
}>;
|
|
123
|
-
hooks: {
|
|
124
|
-
onSuccess: (context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void>;
|
|
125
|
-
onError: (context: _better_fetch_fetch0.ErrorContext) => Promise<void>;
|
|
126
|
-
};
|
|
127
|
-
}[];
|
|
128
|
-
getActions: ($fetch: _better_fetch_fetch0.BetterFetch, $store: ClientStore, clientOptions: better_auth0.BetterAuthClientOptions | undefined) => {
|
|
129
|
-
/**
|
|
130
|
-
* Gets the stored cookie.
|
|
131
|
-
*
|
|
132
|
-
* You can use this to get the cookie stored in
|
|
133
|
-
* the device and use it in your fetch requests.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```ts
|
|
137
|
-
* const cookie = client.getCookie();
|
|
138
|
-
* await fetch("https://api.example.com", {
|
|
139
|
-
* headers: {
|
|
140
|
-
* cookie,
|
|
141
|
-
* },
|
|
142
|
-
* });
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
getCookie: () => string;
|
|
146
|
-
/**
|
|
147
|
-
* Exchanges the authorization code for a session.
|
|
148
|
-
*
|
|
149
|
-
* Use this when you need to manually complete the exchange
|
|
150
|
-
* (e.g., when another app registered the scheme or deep linking fails).
|
|
151
|
-
*
|
|
152
|
-
* The authorization code is returned when the user is authorized in the browser. (`electron_authorization_code`)
|
|
153
|
-
*
|
|
154
|
-
* Note: Must be called after `requestAuth`, since the code verifier and state are stored when the auth flow is initiated.
|
|
155
|
-
*/
|
|
156
|
-
authenticate: (data: ElectronAuthenticateOptions) => Promise<{
|
|
157
|
-
data: null;
|
|
158
|
-
error: {
|
|
159
|
-
message?: string | undefined;
|
|
160
|
-
status: number;
|
|
161
|
-
statusText: string;
|
|
162
|
-
};
|
|
163
|
-
} | {
|
|
164
|
-
data: {
|
|
165
|
-
token: string;
|
|
166
|
-
user: better_auth0.User & Record<string, any>;
|
|
167
|
-
};
|
|
168
|
-
error: null;
|
|
169
|
-
}>;
|
|
170
|
-
/**
|
|
171
|
-
* Initiates the authentication process.
|
|
172
|
-
* Opens the system's default browser for user authentication.
|
|
173
|
-
*/
|
|
174
|
-
requestAuth: (options?: ElectronRequestAuthOptions | undefined) => Promise<void>;
|
|
175
|
-
/**
|
|
176
|
-
* Sets up the main process.
|
|
177
|
-
*
|
|
178
|
-
* - Registers custom protocol scheme.
|
|
179
|
-
* - Registers IPC bridge handlers.
|
|
180
|
-
* - Handles content security policy if needed.
|
|
181
|
-
*/
|
|
182
|
-
setupMain: (cfg?: {
|
|
183
|
-
csp?: boolean | undefined;
|
|
184
|
-
bridges?: boolean | undefined;
|
|
185
|
-
scheme?: boolean | undefined;
|
|
186
|
-
getWindow?: () => electron.BrowserWindow | null | undefined;
|
|
187
|
-
}) => void;
|
|
188
|
-
$Infer: {
|
|
189
|
-
Bridges: ExposedBridges<O>;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
//#endregion
|
|
1
|
+
import { _ as setupRenderer, a as authenticate, c as ElectronClientOptions, d as Storage, f as FetchUserImageResult, g as SetupRendererConfig, h as ExposedBridges, i as ElectronRequestAuthOptions, l as ElectronProxyClientOptions, m as normalizeUserOutput, n as handleDeepLink, o as kElectron, p as fetchUserImage, r as ElectronAuthenticateOptions, s as requestAuth, t as electronClient, u as ElectronSharedClientOptions, y as ElectronSharedOptions } from "./client-DVs5eLfi.mjs";
|
|
194
2
|
export { ElectronAuthenticateOptions, ElectronClientOptions, ElectronProxyClientOptions, ElectronRequestAuthOptions, ElectronSharedClientOptions, ElectronSharedOptions, ExposedBridges, FetchUserImageResult, SetupRendererConfig, Storage, authenticate, electronClient, fetchUserImage, handleDeepLink, kElectron, normalizeUserOutput, requestAuth, setupRenderer };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-DVs5eLfi.mjs";
|
|
2
2
|
import * as better_auth0 from "better-auth";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import * as _better_auth_core0 from "@better-auth/core";
|
|
@@ -114,6 +114,7 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
114
114
|
internalAdapter: better_auth0.InternalAdapter<better_auth0.BetterAuthOptions>;
|
|
115
115
|
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => better_auth0.BetterAuthCookie;
|
|
116
116
|
secret: string;
|
|
117
|
+
secretConfig: string | better_auth0.SecretConfig;
|
|
117
118
|
sessionConfig: {
|
|
118
119
|
updateAge: number;
|
|
119
120
|
expiresIn: number;
|
package/dist/index.mjs
CHANGED
|
@@ -68,7 +68,7 @@ const electronToken = (_opts) => createAuthEndpoint("/electron/token", {
|
|
|
68
68
|
const codeVerifier = Buffer.from(await createHash("SHA-256").digest(ctx.body.code_verifier));
|
|
69
69
|
if (codeChallenge.length !== codeVerifier.length || !timingSafeEqual(codeChallenge, codeVerifier)) throw APIError.from("BAD_REQUEST", ELECTRON_ERROR_CODES.INVALID_CODE_VERIFIER);
|
|
70
70
|
} else if (tokenRecord.codeChallenge !== ctx.body.code_verifier) throw APIError.from("BAD_REQUEST", ELECTRON_ERROR_CODES.INVALID_CODE_VERIFIER);
|
|
71
|
-
await ctx.context.internalAdapter.
|
|
71
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(`electron:${ctx.body.token}`);
|
|
72
72
|
const user = await ctx.context.internalAdapter.findUserById(tokenRecord.userId);
|
|
73
73
|
if (!user) throw APIError.from("INTERNAL_SERVER_ERROR", BASE_ERROR_CODES.USER_NOT_FOUND);
|
|
74
74
|
const session = await ctx.context.internalAdapter.createSession(user.id);
|
package/dist/preload.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ import "nanostores";
|
|
|
6
6
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
7
|
import { Database } from "bun:sqlite";
|
|
8
8
|
import { DatabaseSync } from "node:sqlite";
|
|
9
|
+
import { D1Database } from "@cloudflare/workers-types";
|
|
9
10
|
import { Dialect, Kysely, Migration, MysqlPool, PostgresPool, SqliteDatabase } from "kysely";
|
|
10
11
|
import "better-auth";
|
|
11
12
|
|
|
@@ -827,6 +828,17 @@ type BetterAuthCookies = {
|
|
|
827
828
|
dontRememberToken: BetterAuthCookie;
|
|
828
829
|
}; //#endregion
|
|
829
830
|
//#endregion
|
|
831
|
+
//#region ../core/dist/types/secret.d.mts
|
|
832
|
+
//#region src/types/secret.d.ts
|
|
833
|
+
interface SecretConfig {
|
|
834
|
+
/** Map of version number → secret value */
|
|
835
|
+
keys: Map<number, string>;
|
|
836
|
+
/** Version to use for new encryption (first entry in secrets array) */
|
|
837
|
+
currentVersion: number;
|
|
838
|
+
/** Legacy secret for bare-hex fallback (from BETTER_AUTH_SECRET) */
|
|
839
|
+
legacySecret?: string;
|
|
840
|
+
} //#endregion
|
|
841
|
+
//#endregion
|
|
830
842
|
//#region ../core/dist/db/schema/session.d.mts
|
|
831
843
|
//#region src/db/schema/session.d.ts
|
|
832
844
|
declare const sessionSchema: z.ZodObject<{
|
|
@@ -1153,7 +1165,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
1153
1165
|
}>;
|
|
1154
1166
|
createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>): Promise<T & User>;
|
|
1155
1167
|
createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
|
|
1156
|
-
listSessions(userId: string
|
|
1168
|
+
listSessions(userId: string, options?: {
|
|
1169
|
+
onlyActiveSessions?: boolean | undefined;
|
|
1170
|
+
} | undefined): Promise<Session[]>;
|
|
1157
1171
|
listUsers(limit?: number | undefined, offset?: number | undefined, sortBy?: {
|
|
1158
1172
|
field: string;
|
|
1159
1173
|
direction: "asc" | "desc";
|
|
@@ -1165,7 +1179,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
1165
1179
|
session: Session & Record<string, any>;
|
|
1166
1180
|
user: User & Record<string, any>;
|
|
1167
1181
|
} | null>;
|
|
1168
|
-
findSessions(sessionTokens: string[]
|
|
1182
|
+
findSessions(sessionTokens: string[], options?: {
|
|
1183
|
+
onlyActiveSessions?: boolean | undefined;
|
|
1184
|
+
} | undefined): Promise<{
|
|
1169
1185
|
session: Session;
|
|
1170
1186
|
user: User;
|
|
1171
1187
|
}[]>;
|
|
@@ -1197,9 +1213,8 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
1197
1213
|
updateAccount(id: string, data: Partial<Account>): Promise<Account>;
|
|
1198
1214
|
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|
|
1199
1215
|
findVerificationValue(identifier: string): Promise<Verification | null>;
|
|
1200
|
-
deleteVerificationValue(id: string): Promise<void>;
|
|
1201
1216
|
deleteVerificationByIdentifier(identifier: string): Promise<void>;
|
|
1202
|
-
|
|
1217
|
+
updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
|
|
1203
1218
|
}
|
|
1204
1219
|
type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
1205
1220
|
type CheckPasswordFn<Options extends BetterAuthOptions = BetterAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
|
|
@@ -1290,6 +1305,7 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
|
|
|
1290
1305
|
internalAdapter: InternalAdapter<Options>;
|
|
1291
1306
|
createAuthCookie: CreateCookieGetterFn;
|
|
1292
1307
|
secret: string;
|
|
1308
|
+
secretConfig: string | SecretConfig;
|
|
1293
1309
|
sessionConfig: {
|
|
1294
1310
|
updateAge: number;
|
|
1295
1311
|
expiresIn: number;
|
|
@@ -4982,6 +4998,7 @@ declare const createAuthMiddleware: {
|
|
|
4982
4998
|
internalAdapter: InternalAdapter<BetterAuthOptions>;
|
|
4983
4999
|
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
4984
5000
|
secret: string;
|
|
5001
|
+
secretConfig: string | SecretConfig;
|
|
4985
5002
|
sessionConfig: {
|
|
4986
5003
|
updateAge: number;
|
|
4987
5004
|
expiresIn: number;
|
|
@@ -5110,6 +5127,7 @@ declare const createAuthMiddleware: {
|
|
|
5110
5127
|
internalAdapter: InternalAdapter<BetterAuthOptions>;
|
|
5111
5128
|
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
5112
5129
|
secret: string;
|
|
5130
|
+
secretConfig: string | SecretConfig;
|
|
5113
5131
|
sessionConfig: {
|
|
5114
5132
|
updateAge: number;
|
|
5115
5133
|
expiresIn: number;
|
|
@@ -5512,10 +5530,26 @@ type BetterAuthOptions = {
|
|
|
5512
5530
|
* ```
|
|
5513
5531
|
*/
|
|
5514
5532
|
secret?: string | undefined;
|
|
5533
|
+
/**
|
|
5534
|
+
* Versioned secrets for non-destructive secret rotation.
|
|
5535
|
+
* When set, encryption uses an envelope format with key IDs.
|
|
5536
|
+
* First entry is the current key used for new encryption.
|
|
5537
|
+
* Remaining entries are decryption-only (previous rotations).
|
|
5538
|
+
*
|
|
5539
|
+
* Can also be set via BETTER_AUTH_SECRETS env var:
|
|
5540
|
+
* `BETTER_AUTH_SECRETS=2:base64secret,1:base64secret`
|
|
5541
|
+
*
|
|
5542
|
+
* When set, `secret` is only used as legacy fallback
|
|
5543
|
+
* for decrypting bare-hex payloads that predate the envelope format.
|
|
5544
|
+
*/
|
|
5545
|
+
secrets?: Array<{
|
|
5546
|
+
version: number;
|
|
5547
|
+
value: string;
|
|
5548
|
+
}> | undefined;
|
|
5515
5549
|
/**
|
|
5516
5550
|
* Database configuration
|
|
5517
5551
|
*/
|
|
5518
|
-
database?: (PostgresPool | MysqlPool | SqliteDatabase | Dialect | DBAdapterInstance | Database | DatabaseSync | {
|
|
5552
|
+
database?: (PostgresPool | MysqlPool | SqliteDatabase | Dialect | DBAdapterInstance | Database | DatabaseSync | D1Database | {
|
|
5519
5553
|
dialect: Dialect;
|
|
5520
5554
|
type: KyselyDatabaseType;
|
|
5521
5555
|
/**
|
|
@@ -5754,6 +5788,42 @@ type BetterAuthOptions = {
|
|
|
5754
5788
|
data: {
|
|
5755
5789
|
user: User;
|
|
5756
5790
|
}, request?: Request) => Promise<void>;
|
|
5791
|
+
/**
|
|
5792
|
+
* Build a custom synthetic user for email enumeration
|
|
5793
|
+
* protection. When a sign-up attempt is made with an
|
|
5794
|
+
* email that already exists, this function is called
|
|
5795
|
+
* to build the fake user response.
|
|
5796
|
+
*
|
|
5797
|
+
* Use this when plugins add fields to the user table
|
|
5798
|
+
* (e.g. admin plugin adds `role`, `banned`, etc.)
|
|
5799
|
+
* to ensure the fake response is indistinguishable
|
|
5800
|
+
* from a real sign-up.
|
|
5801
|
+
*
|
|
5802
|
+
* @example
|
|
5803
|
+
* ```ts
|
|
5804
|
+
* customSyntheticUser: ({ coreFields, additionalFields, id }) => ({
|
|
5805
|
+
* ...coreFields,
|
|
5806
|
+
* role: "user",
|
|
5807
|
+
* banned: false,
|
|
5808
|
+
* banReason: null,
|
|
5809
|
+
* banExpires: null,
|
|
5810
|
+
* ...additionalFields,
|
|
5811
|
+
* id,
|
|
5812
|
+
* })
|
|
5813
|
+
* ```
|
|
5814
|
+
*/
|
|
5815
|
+
customSyntheticUser?: (params: {
|
|
5816
|
+
/** Core user fields: name, email, emailVerified, image, createdAt, updatedAt */coreFields: {
|
|
5817
|
+
name: string;
|
|
5818
|
+
email: string;
|
|
5819
|
+
emailVerified: boolean;
|
|
5820
|
+
image: string | null;
|
|
5821
|
+
createdAt: Date;
|
|
5822
|
+
updatedAt: Date;
|
|
5823
|
+
}; /** Processed additional fields from options.user.additionalFields (with defaults applied) */
|
|
5824
|
+
additionalFields: Record<string, unknown>; /** Generated user ID */
|
|
5825
|
+
id: string;
|
|
5826
|
+
}) => Record<string, unknown>;
|
|
5757
5827
|
} | undefined;
|
|
5758
5828
|
/**
|
|
5759
5829
|
* list of social providers
|
package/dist/proxy.d.mts
CHANGED
package/dist/storage.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/electron",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1-beta.1",
|
|
4
4
|
"description": "Better Auth integration for Electron applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
"@types/better-sqlite3": "^7.6.13",
|
|
79
79
|
"better-sqlite3": "^12.6.2",
|
|
80
80
|
"electron": "^38.8.4",
|
|
81
|
-
"tsdown": "
|
|
82
|
-
"@better-auth/core": "1.5.
|
|
83
|
-
"better-auth": "1.5.
|
|
81
|
+
"tsdown": "0.21.0-beta.2",
|
|
82
|
+
"@better-auth/core": "1.5.1-beta.1",
|
|
83
|
+
"better-auth": "1.5.1-beta.1"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@better-auth/utils": "0.3.1",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"better-call": "1.3.2",
|
|
89
89
|
"conf": "^15.0.2",
|
|
90
90
|
"electron": ">=36.0.0",
|
|
91
|
-
"@better-auth/core": "1.5.
|
|
92
|
-
"better-auth": "1.5.
|
|
91
|
+
"@better-auth/core": "1.5.1-beta.1",
|
|
92
|
+
"better-auth": "1.5.1-beta.1"
|
|
93
93
|
},
|
|
94
94
|
"peerDependenciesMeta": {
|
|
95
95
|
"electron": {
|