@better-auth/electron 1.7.0-rc.0 → 1.7.0-rc.2

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.
@@ -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
  /**
@@ -256,13 +253,7 @@ interface ElectronAuthenticateOptions {
256
253
  /**
257
254
  * Exchanges the authorization code for a session.
258
255
  */
259
- declare function authenticate({
260
- $fetch,
261
- options,
262
- token,
263
- getWindow,
264
- fetchOptions
265
- }: ElectronAuthenticateOptions & {
256
+ declare function authenticate({ $fetch, options, token, getWindow, fetchOptions }: ElectronAuthenticateOptions & {
266
257
  $fetch: BetterFetch;
267
258
  options: ElectronClientOptions;
268
259
  getWindow: () => Electron.BrowserWindow | null | undefined;
@@ -291,13 +282,7 @@ type SetupMainConfig = {
291
282
  /**
292
283
  * Handles the deep link URL for authentication.
293
284
  */
294
- declare function handleDeepLink({
295
- $fetch,
296
- options,
297
- url,
298
- getWindow,
299
- clientOptions
300
- }: {
285
+ declare function handleDeepLink({ $fetch, options, url, getWindow, clientOptions }: {
301
286
  $fetch: BetterFetch;
302
287
  options: ElectronClientOptions;
303
288
  url: string;
@@ -325,17 +310,17 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
325
310
  referrerPolicy?: ReferrerPolicy | undefined;
326
311
  signal?: (AbortSignal | null) | undefined;
327
312
  window?: null | undefined;
328
- onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
329
- onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
330
- onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
331
- onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
332
- onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
313
+ 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;
314
+ onResponse?: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
315
+ onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
316
+ onError?: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
317
+ onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
333
318
  hookOptions?: {
334
319
  cloneResponse?: boolean;
335
320
  } | undefined;
336
321
  timeout?: number | undefined;
337
- customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
338
- plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
322
+ customFetchImpl?: import("@better-fetch/fetch").FetchEsque | undefined;
323
+ plugins?: import("@better-fetch/fetch").BetterFetchPlugin[] | undefined;
339
324
  baseURL?: string | undefined;
340
325
  throw?: boolean | undefined;
341
326
  auth?: ({
@@ -361,10 +346,10 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
361
346
  params?: any;
362
347
  duplex?: "full" | "half" | undefined;
363
348
  jsonParser?: ((text: string) => Promise<any> | any) | undefined;
364
- retry?: _better_fetch_fetch0.RetryOptions | undefined;
349
+ retry?: import("@better-fetch/fetch").RetryOptions | undefined;
365
350
  retryAttempt?: number | undefined;
366
- output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
367
- errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
351
+ output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
352
+ errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
368
353
  disableValidation?: boolean | undefined;
369
354
  } & Record<string, any>) | undefined): Promise<{
370
355
  url: string;
@@ -381,17 +366,17 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
381
366
  referrerPolicy?: ReferrerPolicy | undefined;
382
367
  signal?: (AbortSignal | null) | undefined;
383
368
  window?: null | undefined;
384
- onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
385
- onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
386
- onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
387
- onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
388
- onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
369
+ 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;
370
+ onResponse?: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
371
+ onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
372
+ onError?: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
373
+ onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
389
374
  hookOptions?: {
390
375
  cloneResponse?: boolean;
391
376
  } | undefined;
392
377
  timeout?: number | undefined;
393
- customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
394
- plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
378
+ customFetchImpl?: import("@better-fetch/fetch").FetchEsque | undefined;
379
+ plugins?: import("@better-fetch/fetch").BetterFetchPlugin[] | undefined;
395
380
  baseURL?: string | undefined;
396
381
  throw?: boolean | undefined;
397
382
  auth?: ({
@@ -417,19 +402,19 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
417
402
  params?: any;
418
403
  duplex?: "full" | "half" | undefined;
419
404
  jsonParser?: ((text: string) => Promise<any> | any) | undefined;
420
- retry?: _better_fetch_fetch0.RetryOptions | undefined;
405
+ retry?: import("@better-fetch/fetch").RetryOptions | undefined;
421
406
  retryAttempt?: number | undefined;
422
- output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
423
- errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
407
+ output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
408
+ errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
424
409
  disableValidation?: boolean | undefined;
425
410
  } & Record<string, any>;
426
411
  }>;
427
412
  hooks: {
428
- onSuccess: (context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void>;
429
- onError: (context: _better_fetch_fetch0.ErrorContext) => Promise<void>;
413
+ onSuccess: (context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void>;
414
+ onError: (context: import("@better-fetch/fetch").ErrorContext) => Promise<void>;
430
415
  };
431
416
  }[];
432
- getActions: ($fetch: _better_fetch_fetch0.BetterFetch, $store: ClientStore, clientOptions: better_auth0.BetterAuthClientOptions | undefined) => {
417
+ getActions: ($fetch: import("@better-fetch/fetch").BetterFetch, $store: ClientStore, clientOptions: import("better-auth").BetterAuthClientOptions | undefined) => {
433
418
  /**
434
419
  * Gets the stored cookie.
435
420
  *
@@ -467,7 +452,7 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
467
452
  } | {
468
453
  data: {
469
454
  token: string;
470
- user: better_auth0.User & Record<string, any>;
455
+ user: import("better-auth").User & Record<string, any>;
471
456
  };
472
457
  error: null;
473
458
  }>;
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-D5QKMJbp.mjs";
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-CjmDjYiG.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-BDD29zmX.mjs";
2
- import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-DxDKRT6e.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-m-Zfjx6T.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";
@@ -577,7 +577,7 @@ const electronClient = (options) => {
577
577
  let store = null;
578
578
  const cookieName = `${opts.storagePrefix}.cookie`;
579
579
  const localCacheName = `${opts.storagePrefix}.local_cache`;
580
- const { getDecrypted, setEncrypted } = storageAdapter(opts.storage, new Set([cookieName, localCacheName]));
580
+ const { getDecrypted, setEncrypted } = storageAdapter(opts.storage, /* @__PURE__ */ new Set([cookieName, localCacheName]));
581
581
  const clearSessionCache = () => {
582
582
  setEncrypted(cookieName, "{}");
583
583
  store?.atoms.session?.set({
@@ -647,7 +647,33 @@ const electronClient = (options) => {
647
647
  return getCookie(getDecrypted(cookieName) || "{}");
648
648
  };
649
649
  return {
650
+ /**
651
+ * Gets the stored cookie.
652
+ *
653
+ * You can use this to get the cookie stored in
654
+ * the device and use it in your fetch requests.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * const cookie = client.getCookie();
659
+ * await fetch("https://api.example.com", {
660
+ * headers: {
661
+ * cookie,
662
+ * },
663
+ * });
664
+ * ```
665
+ */
650
666
  getCookie: getCookieFn,
667
+ /**
668
+ * Exchanges the authorization code for a session.
669
+ *
670
+ * Use this when you need to manually complete the exchange
671
+ * (e.g., when another app registered the scheme or deep linking fails).
672
+ *
673
+ * The authorization code is returned when the user is authorized in the browser. (`electron_authorization_code`)
674
+ *
675
+ * Note: Must be called after `requestAuth`, since the code verifier and state are stored when the auth flow is initiated.
676
+ */
651
677
  authenticate: async (data) => {
652
678
  return await authenticate({
653
679
  ...data,
@@ -656,7 +682,18 @@ const electronClient = (options) => {
656
682
  getWindow: withGetWindowFallback(getWindow)
657
683
  });
658
684
  },
685
+ /**
686
+ * Initiates the authentication process.
687
+ * Opens the system's default browser for user authentication.
688
+ */
659
689
  requestAuth: (options) => requestAuth(clientOptions, opts, options),
690
+ /**
691
+ * Sets up the main process.
692
+ *
693
+ * - Registers custom protocol scheme.
694
+ * - Registers IPC bridge handlers.
695
+ * - Handles content security policy if needed.
696
+ */
660
697
  setupMain: (cfg) => {
661
698
  if (cfg?.getWindow) getWindow = cfg.getWindow;
662
699
  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-D5QKMJbp.mjs";
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-CjmDjYiG.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> {
@@ -19,14 +15,14 @@ declare const electron: (options?: ElectronOptions | undefined) => {
19
15
  hooks: {
20
16
  after: ({
21
17
  matcher: (ctx: HookEndpointContext) => boolean;
22
- handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>;
18
+ handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
23
19
  } | {
24
20
  matcher: (ctx: HookEndpointContext) => boolean;
25
- handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<better_call0.MiddlewareContext<better_call0.MiddlewareOptions, {
21
+ handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, {
26
22
  returned?: unknown | undefined;
27
23
  responseHeaders?: Headers | undefined;
28
- } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
29
- options: better_auth0.BetterAuthOptions;
24
+ } & import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
25
+ options: import("better-auth").BetterAuthOptions;
30
26
  trustedOrigins: string[];
31
27
  trustedProviders: string[];
32
28
  isTrustedOrigin: (url: string, settings?: {
@@ -99,20 +95,20 @@ declare const electron: (options?: ElectronOptions | undefined) => {
99
95
  image?: string | null | undefined;
100
96
  } & Record<string, any>;
101
97
  } | null) => void;
102
- socialProviders: better_auth0.OAuthProvider[];
103
- authCookies: better_auth0.BetterAuthCookies;
104
- logger: ReturnType<typeof better_auth0.createLogger>;
98
+ socialProviders: import("better-auth").OAuthProvider[];
99
+ authCookies: import("better-auth").BetterAuthCookies;
100
+ logger: ReturnType<typeof import("better-auth").createLogger>;
105
101
  rateLimit: {
106
102
  enabled: boolean;
107
103
  window: number;
108
104
  max: number;
109
105
  storage: "memory" | "database" | "secondary-storage";
110
- } & Omit<better_auth0.BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
111
- adapter: better_auth0.DBAdapter<better_auth0.BetterAuthOptions>;
112
- internalAdapter: better_auth0.InternalAdapter<better_auth0.BetterAuthOptions>;
113
- createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => better_auth0.BetterAuthCookie;
106
+ } & Omit<import("better-auth").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
107
+ adapter: import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
108
+ internalAdapter: import("better-auth").InternalAdapter<import("better-auth").BetterAuthOptions>;
109
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
114
110
  secret: string;
115
- secretConfig: string | better_auth0.SecretConfig;
111
+ secretConfig: string | import("better-auth").SecretConfig;
116
112
  sessionConfig: {
117
113
  updateAge: number;
118
114
  expiresIn: number;
@@ -123,10 +119,10 @@ declare const electron: (options?: ElectronOptions | undefined) => {
123
119
  };
124
120
  };
125
121
  generateId: (options: {
126
- model: better_auth0.ModelNames;
122
+ model: import("better-auth").ModelNames;
127
123
  size?: number | undefined;
128
124
  }) => string | false;
129
- secondaryStorage: better_auth0.SecondaryStorage | undefined;
125
+ secondaryStorage: import("better-auth").SecondaryStorage | undefined;
130
126
  password: {
131
127
  hash: (password: string) => Promise<string>;
132
128
  verify: (data: {
@@ -137,9 +133,9 @@ declare const electron: (options?: ElectronOptions | undefined) => {
137
133
  minPasswordLength: number;
138
134
  maxPasswordLength: number;
139
135
  };
140
- checkPassword: (userId: string, ctx: _better_auth_core0.GenericEndpointContext<better_auth0.BetterAuthOptions>) => Promise<boolean>;
136
+ checkPassword: (userId: string, ctx: import("@better-auth/core").GenericEndpointContext<import("better-auth").BetterAuthOptions>) => Promise<boolean>;
141
137
  };
142
- tables: better_auth0.BetterAuthDBSchema;
138
+ tables: import("better-auth").BetterAuthDBSchema;
143
139
  runMigrations: () => Promise<void>;
144
140
  publishTelemetry: (event: {
145
141
  type: string;
@@ -149,14 +145,14 @@ declare const electron: (options?: ElectronOptions | undefined) => {
149
145
  skipOriginCheck: boolean | string[];
150
146
  skipCSRFCheck: boolean;
151
147
  runInBackground: (promise: Promise<unknown>) => void;
152
- runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
148
+ runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
153
149
  }> | {
154
150
  electron_authorization_code: string;
155
151
  } | undefined>;
156
152
  })[];
157
153
  };
158
154
  endpoints: {
159
- electronToken: better_call0.StrictEndpoint<"/electron/token", {
155
+ electronToken: import("better-call").StrictEndpoint<"/electron/token", {
160
156
  method: "POST";
161
157
  body: z.ZodObject<{
162
158
  token: z.ZodString;
@@ -194,9 +190,9 @@ declare const electron: (options?: ElectronOptions | undefined) => {
194
190
  };
195
191
  }, {
196
192
  token: string;
197
- user: better_auth0.User & Record<string, any>;
193
+ user: import("better-auth").User & Record<string, any>;
198
194
  }>;
199
- electronInitOAuthProxy: better_call0.StrictEndpoint<"/electron/init-oauth-proxy", {
195
+ electronInitOAuthProxy: import("better-call").StrictEndpoint<"/electron/init-oauth-proxy", {
200
196
  method: "GET";
201
197
  query: z.ZodObject<{
202
198
  provider: z.ZodString;
@@ -242,10 +238,10 @@ declare const electron: (options?: ElectronOptions | undefined) => {
242
238
  }, {
243
239
  url: string | undefined;
244
240
  redirect: boolean;
245
- user?: better_auth0.User & Record<string, any>;
241
+ user?: import("better-auth").User & Record<string, any>;
246
242
  token?: string;
247
243
  } | undefined>;
248
- electronTransferUser: better_call0.StrictEndpoint<"/electron/transfer-user", {
244
+ electronTransferUser: import("better-call").StrictEndpoint<"/electron/transfer-user", {
249
245
  method: "POST";
250
246
  query: z.ZodObject<{
251
247
  client_id: z.ZodString;
@@ -255,7 +251,7 @@ declare const electron: (options?: ElectronOptions | undefined) => {
255
251
  body: z.ZodObject<{
256
252
  callbackURL: z.ZodOptional<z.ZodString>;
257
253
  }, z.core.$strip>;
258
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
254
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
259
255
  session: {
260
256
  session: Record<string, any> & {
261
257
  id: string;
@@ -323,14 +319,14 @@ declare const electron: (options?: ElectronOptions | undefined) => {
323
319
  clientID: string;
324
320
  };
325
321
  $ERROR_CODES: {
326
- INVALID_TOKEN: better_auth0.RawError<"INVALID_TOKEN">;
327
- INVALID_CLIENT_ID: better_auth0.RawError<"INVALID_CLIENT_ID">;
328
- STATE_MISMATCH: better_auth0.RawError<"STATE_MISMATCH">;
329
- MISSING_CODE_CHALLENGE: better_auth0.RawError<"MISSING_CODE_CHALLENGE">;
330
- INVALID_CODE_VERIFIER: better_auth0.RawError<"INVALID_CODE_VERIFIER">;
331
- MISSING_STATE: better_auth0.RawError<"MISSING_STATE">;
332
- MISSING_PKCE: better_auth0.RawError<"MISSING_PKCE">;
322
+ INVALID_TOKEN: import("better-auth").RawError<"INVALID_TOKEN">;
323
+ INVALID_CLIENT_ID: import("better-auth").RawError<"INVALID_CLIENT_ID">;
324
+ STATE_MISMATCH: import("better-auth").RawError<"STATE_MISMATCH">;
325
+ MISSING_CODE_CHALLENGE: import("better-auth").RawError<"MISSING_CODE_CHALLENGE">;
326
+ INVALID_CODE_VERIFIER: import("better-auth").RawError<"INVALID_CODE_VERIFIER">;
327
+ MISSING_STATE: import("better-auth").RawError<"MISSING_STATE">;
328
+ MISSING_PKCE: import("better-auth").RawError<"MISSING_PKCE">;
333
329
  };
334
330
  };
335
331
  //#endregion
336
- export { ElectronOptions, ElectronSharedOptions, FetchUserImageResult, electron, fetchUserImage, normalizeUserOutput };
332
+ 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-BDD29zmX.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-m-Zfjx6T.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";
@@ -8,7 +8,7 @@ import * as z from "zod";
8
8
  import { safeJSONParse as safeJSONParse$1 } from "@better-auth/core/utils/json";
9
9
  import { betterFetch } from "@better-fetch/fetch";
10
10
  import { createAuthEndpoint, sessionMiddleware } from "better-auth/api";
11
- import { setSessionCookie } from "better-auth/cookies";
11
+ import { parseSetCookieHeader, setSessionCookie, toCookieOptions } from "better-auth/cookies";
12
12
  import { parseUserOutput } from "better-auth/db";
13
13
  import { generateCodeChallenge } from "better-auth/oauth2";
14
14
  //#region src/error-codes.ts
@@ -110,7 +110,7 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
110
110
  }, async (ctx) => {
111
111
  const headers = new Headers(ctx.request?.headers);
112
112
  headers.set("origin", new URL(ctx.context.baseURL).origin);
113
- let setCookie = null;
113
+ let setCookies = [];
114
114
  const searchParams = new URLSearchParams();
115
115
  searchParams.set("client_id", opts.clientID || "electron");
116
116
  searchParams.set("code_challenge", ctx.query.code_challenge);
@@ -119,13 +119,15 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
119
119
  baseURL: ctx.context.baseURL,
120
120
  method: "POST",
121
121
  body: { provider: ctx.query.provider },
122
- onResponse: (ctx) => {
123
- setCookie = ctx.response.headers.get("set-cookie") ?? null;
122
+ onResponse: (innerCtx) => {
123
+ setCookies = innerCtx.response.headers.getSetCookie();
124
124
  },
125
125
  headers
126
126
  });
127
127
  if (res.error) throw new APIError("INTERNAL_SERVER_ERROR", { message: res.error.message || "An unknown error occurred." });
128
- if (setCookie) ctx.setHeader("set-cookie", setCookie);
128
+ for (const cookieStr of setCookies) parseSetCookieHeader(cookieStr).forEach((attrs, name) => {
129
+ ctx.setCookie(name, attrs.value, toCookieOptions(attrs));
130
+ });
129
131
  if (res.data.url && res.data.redirect) {
130
132
  ctx.setHeader("Location", res.data.url);
131
133
  ctx.setStatus(302);