@better-auth/electron 1.6.22 → 1.6.24
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/{client-hpd3q6M8.d.mts → client-Dfn6XsLf.d.mts} +26 -41
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +40 -3
- package/dist/index.d.mts +34 -38
- package/dist/index.mjs +8 -6
- package/dist/preload.d.mts +4 -7167
- package/dist/proxy.d.mts +1 -2
- package/dist/proxy.mjs +14 -3
- package/dist/storage.d.mts +1 -2
- package/dist/{version-CD3Z0v2C.mjs → version-DsNmK8I4.mjs} +1 -1
- package/package.json +7 -7
- /package/dist/{utils-DxDKRT6e.mjs → utils-C5XBRvIU.mjs} +0 -0
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import * as better_auth0 from "better-auth";
|
|
2
1
|
import { ClientStore } from "better-auth";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
5
3
|
import { BetterFetch, BetterFetchError, CreateFetchOption } from "@better-fetch/fetch";
|
|
6
4
|
import electron from "electron";
|
|
7
5
|
import { Awaitable, BetterAuthClientOptions } from "@better-auth/core";
|
|
8
6
|
import { User } from "@better-auth/core/db";
|
|
9
|
-
|
|
10
7
|
//#region src/types/options.d.ts
|
|
11
8
|
interface ElectronSharedOptions {
|
|
12
9
|
/**
|
|
@@ -262,13 +259,7 @@ interface ElectronAuthenticateOptions {
|
|
|
262
259
|
/**
|
|
263
260
|
* Exchanges the authorization code for a session.
|
|
264
261
|
*/
|
|
265
|
-
declare function authenticate({
|
|
266
|
-
$fetch,
|
|
267
|
-
options,
|
|
268
|
-
token,
|
|
269
|
-
getWindow,
|
|
270
|
-
fetchOptions
|
|
271
|
-
}: ElectronAuthenticateOptions & {
|
|
262
|
+
declare function authenticate({ $fetch, options, token, getWindow, fetchOptions }: ElectronAuthenticateOptions & {
|
|
272
263
|
$fetch: BetterFetch;
|
|
273
264
|
options: ElectronClientOptions;
|
|
274
265
|
getWindow: () => Electron.BrowserWindow | null | undefined;
|
|
@@ -297,13 +288,7 @@ type SetupMainConfig = {
|
|
|
297
288
|
/**
|
|
298
289
|
* Handles the deep link URL for authentication.
|
|
299
290
|
*/
|
|
300
|
-
declare function handleDeepLink({
|
|
301
|
-
$fetch,
|
|
302
|
-
options,
|
|
303
|
-
url,
|
|
304
|
-
getWindow,
|
|
305
|
-
clientOptions
|
|
306
|
-
}: {
|
|
291
|
+
declare function handleDeepLink({ $fetch, options, url, getWindow, clientOptions }: {
|
|
307
292
|
$fetch: BetterFetch;
|
|
308
293
|
options: ElectronClientOptions;
|
|
309
294
|
url: string;
|
|
@@ -331,17 +316,17 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
|
331
316
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
332
317
|
signal?: (AbortSignal | null) | undefined;
|
|
333
318
|
window?: null | undefined;
|
|
334
|
-
onRequest?: (<T extends Record<string, any>>(context:
|
|
335
|
-
onResponse?: ((context:
|
|
336
|
-
onSuccess?: ((context:
|
|
337
|
-
onError?: ((context:
|
|
338
|
-
onRetry?: ((response:
|
|
319
|
+
onRequest?: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
|
|
320
|
+
onResponse?: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
321
|
+
onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
322
|
+
onError?: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
323
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
339
324
|
hookOptions?: {
|
|
340
325
|
cloneResponse?: boolean;
|
|
341
326
|
} | undefined;
|
|
342
327
|
timeout?: number | undefined;
|
|
343
|
-
customFetchImpl?:
|
|
344
|
-
plugins?:
|
|
328
|
+
customFetchImpl?: import("@better-fetch/fetch").FetchEsque | undefined;
|
|
329
|
+
plugins?: import("@better-fetch/fetch").BetterFetchPlugin[] | undefined;
|
|
345
330
|
baseURL?: string | undefined;
|
|
346
331
|
throw?: boolean | undefined;
|
|
347
332
|
auth?: ({
|
|
@@ -367,10 +352,10 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
|
367
352
|
params?: any;
|
|
368
353
|
duplex?: "full" | "half" | undefined;
|
|
369
354
|
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
370
|
-
retry?:
|
|
355
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
371
356
|
retryAttempt?: number | undefined;
|
|
372
|
-
output?: (
|
|
373
|
-
errorSchema?:
|
|
357
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
358
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
374
359
|
disableValidation?: boolean | undefined;
|
|
375
360
|
} & Record<string, any>) | undefined): Promise<{
|
|
376
361
|
url: string;
|
|
@@ -387,17 +372,17 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
|
387
372
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
388
373
|
signal?: (AbortSignal | null) | undefined;
|
|
389
374
|
window?: null | undefined;
|
|
390
|
-
onRequest?: (<T extends Record<string, any>>(context:
|
|
391
|
-
onResponse?: ((context:
|
|
392
|
-
onSuccess?: ((context:
|
|
393
|
-
onError?: ((context:
|
|
394
|
-
onRetry?: ((response:
|
|
375
|
+
onRequest?: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
|
|
376
|
+
onResponse?: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
377
|
+
onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
378
|
+
onError?: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
379
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
395
380
|
hookOptions?: {
|
|
396
381
|
cloneResponse?: boolean;
|
|
397
382
|
} | undefined;
|
|
398
383
|
timeout?: number | undefined;
|
|
399
|
-
customFetchImpl?:
|
|
400
|
-
plugins?:
|
|
384
|
+
customFetchImpl?: import("@better-fetch/fetch").FetchEsque | undefined;
|
|
385
|
+
plugins?: import("@better-fetch/fetch").BetterFetchPlugin[] | undefined;
|
|
401
386
|
baseURL?: string | undefined;
|
|
402
387
|
throw?: boolean | undefined;
|
|
403
388
|
auth?: ({
|
|
@@ -423,19 +408,19 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
|
423
408
|
params?: any;
|
|
424
409
|
duplex?: "full" | "half" | undefined;
|
|
425
410
|
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
426
|
-
retry?:
|
|
411
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
427
412
|
retryAttempt?: number | undefined;
|
|
428
|
-
output?: (
|
|
429
|
-
errorSchema?:
|
|
413
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
414
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
430
415
|
disableValidation?: boolean | undefined;
|
|
431
416
|
} & Record<string, any>;
|
|
432
417
|
}>;
|
|
433
418
|
hooks: {
|
|
434
|
-
onSuccess: (context:
|
|
435
|
-
onError: (context:
|
|
419
|
+
onSuccess: (context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void>;
|
|
420
|
+
onError: (context: import("@better-fetch/fetch").ErrorContext) => Promise<void>;
|
|
436
421
|
};
|
|
437
422
|
}[];
|
|
438
|
-
getActions: ($fetch:
|
|
423
|
+
getActions: ($fetch: import("@better-fetch/fetch").BetterFetch, $store: ClientStore, clientOptions: import("better-auth").BetterAuthClientOptions | undefined) => {
|
|
439
424
|
/**
|
|
440
425
|
* Gets the stored cookie.
|
|
441
426
|
*
|
|
@@ -473,7 +458,7 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
|
|
|
473
458
|
} | {
|
|
474
459
|
data: {
|
|
475
460
|
token: string;
|
|
476
|
-
user:
|
|
461
|
+
user: import("better-auth").User & Record<string, any>;
|
|
477
462
|
};
|
|
478
463
|
error: null;
|
|
479
464
|
}>;
|
package/dist/client.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
2
|
-
export { ElectronAuthenticateOptions, ElectronClientOptions, ElectronProxyClientOptions, ElectronRequestAuthOptions, ElectronSharedClientOptions, ElectronSharedOptions, ExposedBridges, FetchUserImageResult, SetupRendererConfig, Storage, authenticate, electronClient, fetchUserImage, handleDeepLink, kElectron, normalizeUserOutput, requestAuth, setupRenderer };
|
|
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-Dfn6XsLf.mjs";
|
|
2
|
+
export { type ElectronAuthenticateOptions, type ElectronClientOptions, type ElectronProxyClientOptions, type ElectronRequestAuthOptions, type ElectronSharedClientOptions, type ElectronSharedOptions, type ExposedBridges, type FetchUserImageResult, type SetupRendererConfig, type Storage, type authenticate, electronClient, type fetchUserImage, handleDeepLink, type kElectron, normalizeUserOutput, type requestAuth, type setupRenderer };
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
2
|
-
import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-DsNmK8I4.mjs";
|
|
2
|
+
import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-C5XBRvIU.mjs";
|
|
3
3
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
4
4
|
import { base64, base64Url } from "@better-auth/utils/base64";
|
|
5
5
|
import { APIError as APIError$1, getBaseURL, isDevelopment, isTest, safeJSONParse } from "better-auth";
|
|
@@ -578,7 +578,7 @@ const electronClient = (options) => {
|
|
|
578
578
|
let store = null;
|
|
579
579
|
const cookieName = `${opts.storagePrefix}.cookie`;
|
|
580
580
|
const localCacheName = `${opts.storagePrefix}.local_cache`;
|
|
581
|
-
const { getDecrypted, setEncrypted } = storageAdapter(opts.storage, new Set([cookieName, localCacheName]));
|
|
581
|
+
const { getDecrypted, setEncrypted } = storageAdapter(opts.storage, /* @__PURE__ */ new Set([cookieName, localCacheName]));
|
|
582
582
|
const clearSessionCache = () => {
|
|
583
583
|
setEncrypted(cookieName, "{}");
|
|
584
584
|
store?.atoms.session?.set({
|
|
@@ -648,7 +648,33 @@ const electronClient = (options) => {
|
|
|
648
648
|
return getCookie(getDecrypted(cookieName) || "{}");
|
|
649
649
|
};
|
|
650
650
|
return {
|
|
651
|
+
/**
|
|
652
|
+
* Gets the stored cookie.
|
|
653
|
+
*
|
|
654
|
+
* You can use this to get the cookie stored in
|
|
655
|
+
* the device and use it in your fetch requests.
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* const cookie = client.getCookie();
|
|
660
|
+
* await fetch("https://api.example.com", {
|
|
661
|
+
* headers: {
|
|
662
|
+
* cookie,
|
|
663
|
+
* },
|
|
664
|
+
* });
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
651
667
|
getCookie: getCookieFn,
|
|
668
|
+
/**
|
|
669
|
+
* Exchanges the authorization code for a session.
|
|
670
|
+
*
|
|
671
|
+
* Use this when you need to manually complete the exchange
|
|
672
|
+
* (e.g., when another app registered the scheme or deep linking fails).
|
|
673
|
+
*
|
|
674
|
+
* The authorization code is returned when the user is authorized in the browser. (`electron_authorization_code`)
|
|
675
|
+
*
|
|
676
|
+
* Note: Must be called after `requestAuth`, since the code verifier and state are stored when the auth flow is initiated.
|
|
677
|
+
*/
|
|
652
678
|
authenticate: async (data) => {
|
|
653
679
|
return await authenticate({
|
|
654
680
|
...data,
|
|
@@ -657,7 +683,18 @@ const electronClient = (options) => {
|
|
|
657
683
|
getWindow: withGetWindowFallback(getWindow)
|
|
658
684
|
});
|
|
659
685
|
},
|
|
686
|
+
/**
|
|
687
|
+
* Initiates the authentication process.
|
|
688
|
+
* Opens the system's default browser for user authentication.
|
|
689
|
+
*/
|
|
660
690
|
requestAuth: (options) => requestAuth(clientOptions, opts, options),
|
|
691
|
+
/**
|
|
692
|
+
* Sets up the main process.
|
|
693
|
+
*
|
|
694
|
+
* - Registers custom protocol scheme.
|
|
695
|
+
* - Registers IPC bridge handlers.
|
|
696
|
+
* - Handles content security policy if needed.
|
|
697
|
+
*/
|
|
661
698
|
setupMain: (cfg) => {
|
|
662
699
|
if (cfg?.getWindow) getWindow = cfg.getWindow;
|
|
663
700
|
return setupMain($fetch, store, getCookieFn, opts, clientOptions, cfg);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-
|
|
2
|
-
import * as better_auth0 from "better-auth";
|
|
1
|
+
import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-Dfn6XsLf.mjs";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
5
3
|
import { HookEndpointContext } from "@better-auth/core";
|
|
6
|
-
import * as better_call0 from "better-call";
|
|
7
|
-
|
|
8
4
|
//#region src/index.d.ts
|
|
9
5
|
declare module "@better-auth/core" {
|
|
10
6
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -16,20 +12,20 @@ declare module "@better-auth/core" {
|
|
|
16
12
|
declare const electron: (options?: ElectronOptions | undefined) => {
|
|
17
13
|
id: "electron";
|
|
18
14
|
version: string;
|
|
19
|
-
onRequest(request: Request, _ctx:
|
|
15
|
+
onRequest(request: Request, _ctx: import("better-auth").AuthContext): Promise<{
|
|
20
16
|
request: Request;
|
|
21
17
|
} | undefined>;
|
|
22
18
|
hooks: {
|
|
23
19
|
after: ({
|
|
24
20
|
matcher: (ctx: HookEndpointContext) => boolean;
|
|
25
|
-
handler: (inputContext:
|
|
21
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
26
22
|
} | {
|
|
27
23
|
matcher: (ctx: HookEndpointContext) => boolean;
|
|
28
|
-
handler: (inputContext:
|
|
24
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, {
|
|
29
25
|
returned?: unknown | undefined;
|
|
30
26
|
responseHeaders?: Headers | undefined;
|
|
31
|
-
} &
|
|
32
|
-
options:
|
|
27
|
+
} & import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
|
|
28
|
+
options: import("better-auth").BetterAuthOptions;
|
|
33
29
|
trustedOrigins: string[];
|
|
34
30
|
trustedProviders: string[];
|
|
35
31
|
isTrustedOrigin: (url: string, settings?: {
|
|
@@ -102,20 +98,20 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
102
98
|
image?: string | null | undefined;
|
|
103
99
|
} & Record<string, any>;
|
|
104
100
|
} | null) => void;
|
|
105
|
-
socialProviders:
|
|
106
|
-
authCookies:
|
|
107
|
-
logger: ReturnType<typeof
|
|
101
|
+
socialProviders: import("better-auth").OAuthProvider[];
|
|
102
|
+
authCookies: import("better-auth").BetterAuthCookies;
|
|
103
|
+
logger: ReturnType<typeof import("better-auth").createLogger>;
|
|
108
104
|
rateLimit: {
|
|
109
105
|
enabled: boolean;
|
|
110
106
|
window: number;
|
|
111
107
|
max: number;
|
|
112
108
|
storage: "memory" | "database" | "secondary-storage";
|
|
113
|
-
} & Omit<
|
|
114
|
-
adapter:
|
|
115
|
-
internalAdapter:
|
|
116
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<
|
|
109
|
+
} & Omit<import("better-auth").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
110
|
+
adapter: import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
|
|
111
|
+
internalAdapter: import("better-auth").InternalAdapter<import("better-auth").BetterAuthOptions>;
|
|
112
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
|
|
117
113
|
secret: string;
|
|
118
|
-
secretConfig: string |
|
|
114
|
+
secretConfig: string | import("better-auth").SecretConfig;
|
|
119
115
|
sessionConfig: {
|
|
120
116
|
updateAge: number;
|
|
121
117
|
expiresIn: number;
|
|
@@ -126,10 +122,10 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
126
122
|
};
|
|
127
123
|
};
|
|
128
124
|
generateId: (options: {
|
|
129
|
-
model:
|
|
125
|
+
model: import("better-auth").ModelNames;
|
|
130
126
|
size?: number | undefined;
|
|
131
127
|
}) => string | false;
|
|
132
|
-
secondaryStorage:
|
|
128
|
+
secondaryStorage: import("better-auth").SecondaryStorage | undefined;
|
|
133
129
|
password: {
|
|
134
130
|
hash: (password: string) => Promise<string>;
|
|
135
131
|
verify: (data: {
|
|
@@ -140,9 +136,9 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
140
136
|
minPasswordLength: number;
|
|
141
137
|
maxPasswordLength: number;
|
|
142
138
|
};
|
|
143
|
-
checkPassword: (userId: string, ctx:
|
|
139
|
+
checkPassword: (userId: string, ctx: import("@better-auth/core").GenericEndpointContext<import("better-auth").BetterAuthOptions>) => Promise<boolean>;
|
|
144
140
|
};
|
|
145
|
-
tables:
|
|
141
|
+
tables: import("better-auth").BetterAuthDBSchema;
|
|
146
142
|
runMigrations: () => Promise<void>;
|
|
147
143
|
publishTelemetry: (event: {
|
|
148
144
|
type: string;
|
|
@@ -152,14 +148,14 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
152
148
|
skipOriginCheck: boolean | string[];
|
|
153
149
|
skipCSRFCheck: boolean;
|
|
154
150
|
runInBackground: (promise: Promise<unknown>) => void;
|
|
155
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) =>
|
|
151
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
|
|
156
152
|
}> | {
|
|
157
153
|
electron_authorization_code: string;
|
|
158
154
|
} | undefined>;
|
|
159
155
|
})[];
|
|
160
156
|
};
|
|
161
157
|
endpoints: {
|
|
162
|
-
electronToken:
|
|
158
|
+
electronToken: import("better-call").StrictEndpoint<"/electron/token", {
|
|
163
159
|
method: "POST";
|
|
164
160
|
body: z.ZodObject<{
|
|
165
161
|
token: z.ZodString;
|
|
@@ -197,9 +193,9 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
197
193
|
};
|
|
198
194
|
}, {
|
|
199
195
|
token: string;
|
|
200
|
-
user:
|
|
196
|
+
user: import("better-auth").User & Record<string, any>;
|
|
201
197
|
}>;
|
|
202
|
-
electronInitOAuthProxy:
|
|
198
|
+
electronInitOAuthProxy: import("better-call").StrictEndpoint<"/electron/init-oauth-proxy", {
|
|
203
199
|
method: "GET";
|
|
204
200
|
query: z.ZodObject<{
|
|
205
201
|
provider: z.ZodString;
|
|
@@ -246,10 +242,10 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
246
242
|
}, {
|
|
247
243
|
url: string | undefined;
|
|
248
244
|
redirect: boolean;
|
|
249
|
-
user?:
|
|
245
|
+
user?: import("better-auth").User & Record<string, any>;
|
|
250
246
|
token?: string;
|
|
251
247
|
} | undefined>;
|
|
252
|
-
electronTransferUser:
|
|
248
|
+
electronTransferUser: import("better-call").StrictEndpoint<"/electron/transfer-user", {
|
|
253
249
|
method: "POST";
|
|
254
250
|
query: z.ZodObject<{
|
|
255
251
|
client_id: z.ZodString;
|
|
@@ -260,7 +256,7 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
260
256
|
body: z.ZodObject<{
|
|
261
257
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
262
258
|
}, z.core.$strip>;
|
|
263
|
-
use: ((inputContext:
|
|
259
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
264
260
|
session: {
|
|
265
261
|
session: Record<string, any> & {
|
|
266
262
|
id: string;
|
|
@@ -329,15 +325,15 @@ declare const electron: (options?: ElectronOptions | undefined) => {
|
|
|
329
325
|
clientID: string;
|
|
330
326
|
};
|
|
331
327
|
$ERROR_CODES: {
|
|
332
|
-
INVALID_TOKEN:
|
|
333
|
-
INVALID_CLIENT_ID:
|
|
334
|
-
STATE_MISMATCH:
|
|
335
|
-
MISSING_CODE_CHALLENGE:
|
|
336
|
-
INVALID_CODE_VERIFIER:
|
|
337
|
-
MISSING_STATE:
|
|
338
|
-
MISSING_PKCE:
|
|
339
|
-
INVALID_PKCE_METHOD:
|
|
328
|
+
INVALID_TOKEN: import("better-auth").RawError<"INVALID_TOKEN">;
|
|
329
|
+
INVALID_CLIENT_ID: import("better-auth").RawError<"INVALID_CLIENT_ID">;
|
|
330
|
+
STATE_MISMATCH: import("better-auth").RawError<"STATE_MISMATCH">;
|
|
331
|
+
MISSING_CODE_CHALLENGE: import("better-auth").RawError<"MISSING_CODE_CHALLENGE">;
|
|
332
|
+
INVALID_CODE_VERIFIER: import("better-auth").RawError<"INVALID_CODE_VERIFIER">;
|
|
333
|
+
MISSING_STATE: import("better-auth").RawError<"MISSING_STATE">;
|
|
334
|
+
MISSING_PKCE: import("better-auth").RawError<"MISSING_PKCE">;
|
|
335
|
+
INVALID_PKCE_METHOD: import("better-auth").RawError<"INVALID_PKCE_METHOD">;
|
|
340
336
|
};
|
|
341
337
|
};
|
|
342
338
|
//#endregion
|
|
343
|
-
export { ElectronOptions, ElectronSharedOptions, FetchUserImageResult, electron, fetchUserImage, normalizeUserOutput };
|
|
339
|
+
export { type ElectronOptions, type ElectronSharedOptions, type FetchUserImageResult, electron, type fetchUserImage, type normalizeUserOutput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-DsNmK8I4.mjs";
|
|
2
2
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
3
3
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
4
4
|
import { base64Url } from "@better-auth/utils/base64";
|
|
@@ -12,7 +12,7 @@ import { safeJSONParse as safeJSONParse$1 } from "@better-auth/core/utils/json";
|
|
|
12
12
|
import { createHash } from "@better-auth/utils/hash";
|
|
13
13
|
import { betterFetch } from "@better-fetch/fetch";
|
|
14
14
|
import { createAuthEndpoint, sessionMiddleware } from "better-auth/api";
|
|
15
|
-
import { setSessionCookie } from "better-auth/cookies";
|
|
15
|
+
import { parseSetCookieHeader, setSessionCookie, toCookieOptions } from "better-auth/cookies";
|
|
16
16
|
import { parseUserOutput } from "better-auth/db";
|
|
17
17
|
//#region src/error-codes.ts
|
|
18
18
|
const ELECTRON_ERROR_CODES = defineErrorCodes({
|
|
@@ -121,7 +121,7 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
|
|
|
121
121
|
if (ctx.query.code_challenge_method && ctx.query.code_challenge_method.toLowerCase() !== "s256") throw APIError.from("BAD_REQUEST", ELECTRON_ERROR_CODES.INVALID_PKCE_METHOD);
|
|
122
122
|
const headers = new Headers(ctx.request?.headers);
|
|
123
123
|
headers.set("origin", new URL(ctx.context.baseURL).origin);
|
|
124
|
-
let
|
|
124
|
+
let setCookies = [];
|
|
125
125
|
const searchParams = new URLSearchParams();
|
|
126
126
|
searchParams.set("client_id", opts.clientID || "electron");
|
|
127
127
|
searchParams.set("code_challenge", ctx.query.code_challenge);
|
|
@@ -131,13 +131,15 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
|
|
|
131
131
|
baseURL: ctx.context.baseURL,
|
|
132
132
|
method: "POST",
|
|
133
133
|
body: { provider: ctx.query.provider },
|
|
134
|
-
onResponse: (
|
|
135
|
-
|
|
134
|
+
onResponse: (innerCtx) => {
|
|
135
|
+
setCookies = innerCtx.response.headers.getSetCookie();
|
|
136
136
|
},
|
|
137
137
|
headers
|
|
138
138
|
});
|
|
139
139
|
if (res.error) throw new APIError("INTERNAL_SERVER_ERROR", { message: res.error.message || "An unknown error occurred." });
|
|
140
|
-
|
|
140
|
+
for (const cookieStr of setCookies) parseSetCookieHeader(cookieStr).forEach((attrs, name) => {
|
|
141
|
+
ctx.setCookie(name, attrs.value, toCookieOptions(attrs));
|
|
142
|
+
});
|
|
141
143
|
if (res.data.url && res.data.redirect) {
|
|
142
144
|
ctx.setHeader("Location", res.data.url);
|
|
143
145
|
ctx.setStatus(302);
|