@better-auth/electron 1.5.0 → 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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/preload.d.mts +1 -2
- 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
|
-
priority?: RequestPriority | undefined;
|
|
15
|
-
cache?: RequestCache | undefined;
|
|
16
|
-
credentials?: RequestCredentials | undefined;
|
|
17
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
18
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
19
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
20
|
-
authorization: "Bearer" | "Basic";
|
|
21
|
-
})) | undefined;
|
|
22
|
-
integrity?: string | undefined;
|
|
23
|
-
keepalive?: boolean | undefined;
|
|
24
|
-
method?: string | undefined;
|
|
25
|
-
mode?: RequestMode | 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
|
-
priority?: RequestPriority | undefined;
|
|
70
|
-
cache?: RequestCache | undefined;
|
|
71
|
-
credentials?: RequestCredentials | undefined;
|
|
72
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
73
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
74
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
75
|
-
authorization: "Bearer" | "Basic";
|
|
76
|
-
})) | undefined;
|
|
77
|
-
integrity?: string | undefined;
|
|
78
|
-
keepalive?: boolean | undefined;
|
|
79
|
-
method?: string | undefined;
|
|
80
|
-
mode?: RequestMode | 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";
|
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
|
@@ -1213,9 +1213,8 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
1213
1213
|
updateAccount(id: string, data: Partial<Account>): Promise<Account>;
|
|
1214
1214
|
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|
|
1215
1215
|
findVerificationValue(identifier: string): Promise<Verification | null>;
|
|
1216
|
-
deleteVerificationValue(id: string): Promise<void>;
|
|
1217
1216
|
deleteVerificationByIdentifier(identifier: string): Promise<void>;
|
|
1218
|
-
|
|
1217
|
+
updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
|
|
1219
1218
|
}
|
|
1220
1219
|
type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
1221
1220
|
type CheckPasswordFn<Options extends BetterAuthOptions = BetterAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
|
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": {
|