@better-auth/electron 1.5.6 → 1.5.7-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.
@@ -241,14 +241,7 @@ interface ElectronProxyClientOptions extends ElectronSharedClientOptions {
241
241
  //#region src/authenticate.d.ts
242
242
  declare const kElectron: unique symbol;
243
243
  declare const requestAuthOptionsSchema: z.ZodObject<{
244
- provider: z.ZodOptional<z.ZodString>;
245
- callbackURL: z.ZodOptional<z.ZodString>;
246
- newUserCallbackURL: z.ZodOptional<z.ZodString>;
247
- errorCallbackURL: z.ZodOptional<z.ZodString>;
248
- disableRedirect: z.ZodOptional<z.ZodBoolean>;
249
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
250
- requestSignUp: z.ZodOptional<z.ZodBoolean>;
251
- additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
244
+ [x: string]: any;
252
245
  }, z.core.$strip>;
253
246
  type ElectronRequestAuthOptions = z.infer<typeof requestAuthOptionsSchema>;
254
247
  /**
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-DVs5eLfi.mjs";
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-D8BB_eSV.mjs";
2
2
  export { ElectronAuthenticateOptions, ElectronClientOptions, ElectronProxyClientOptions, ElectronRequestAuthOptions, ElectronSharedClientOptions, ElectronSharedOptions, ExposedBridges, FetchUserImageResult, SetupRendererConfig, Storage, authenticate, electronClient, fetchUserImage, handleDeepLink, kElectron, normalizeUserOutput, requestAuth, setupRenderer };
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-DecLU66o.mjs";
1
+ import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-CRzg_SlK.mjs";
2
2
  import { BetterAuthError } from "@better-auth/core/error";
3
3
  import { base64, base64Url } from "@better-auth/utils/base64";
4
4
  import { APIError as APIError$1, getBaseURL, isDevelopment, isTest, safeJSONParse } from "better-auth";
@@ -11,7 +11,6 @@ import { parseSetCookieHeader } from "better-auth/cookies";
11
11
  import electron, { shell } from "electron";
12
12
  import { isDevelopment as isDevelopment$1 } from "@better-auth/core/env";
13
13
  import { resolve } from "node:path";
14
-
15
14
  //#region src/user.ts
16
15
  const { net } = electron;
17
16
  const DEFAULT_MAX_BYTES = 1024 * 1024 * 5;
@@ -151,7 +150,6 @@ function detectImageType(bytes) {
151
150
  if (brand === "heix" || brand === "hevc" || brand === "mif1" || brand === "msf1") return "image/heic";
152
151
  return null;
153
152
  }
154
-
155
153
  //#endregion
156
154
  //#region src/authenticate.ts
157
155
  const kElectron = Symbol.for("better-auth:electron");
@@ -224,7 +222,6 @@ async function authenticate({ $fetch, options, token, getWindow, fetchOptions })
224
222
  }
225
223
  });
226
224
  }
227
-
228
225
  //#endregion
229
226
  //#region src/browser.ts
230
227
  const { app: app$1, session, protocol, BrowserWindow, ipcMain, webContents: webContents$1 } = electron;
@@ -467,7 +464,6 @@ function setupUserImageProxy(ctx, opts, clientOptions) {
467
464
  });
468
465
  });
469
466
  }
470
-
471
467
  //#endregion
472
468
  //#region src/cookies.ts
473
469
  function getSetCookie(header, prevCookie) {
@@ -553,7 +549,6 @@ function hasBetterAuthCookies(setCookieHeader, cookiePrefix) {
553
549
  }
554
550
  return false;
555
551
  }
556
-
557
552
  //#endregion
558
553
  //#region src/client.ts
559
554
  const { app, safeStorage, webContents } = electron;
@@ -683,6 +678,5 @@ const electronClient = (options) => {
683
678
  }
684
679
  };
685
680
  };
686
-
687
681
  //#endregion
688
- export { electronClient, handleDeepLink, normalizeUserOutput };
682
+ export { electronClient, handleDeepLink, normalizeUserOutput };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-DVs5eLfi.mjs";
1
+ import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-D8BB_eSV.mjs";
2
2
  import * as better_auth0 from "better-auth";
3
- import * as z from "zod";
4
3
  import * as _better_auth_core0 from "@better-auth/core";
5
4
  import { HookEndpointContext } from "@better-auth/core";
6
5
  import * as better_call0 from "better-call";
@@ -21,10 +20,10 @@ declare const electron: (options?: ElectronOptions | undefined) => {
21
20
  hooks: {
22
21
  after: ({
23
22
  matcher: (ctx: HookEndpointContext) => boolean;
24
- handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>;
23
+ handler: better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>;
25
24
  } | {
26
25
  matcher: (ctx: HookEndpointContext) => boolean;
27
- handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<better_call0.MiddlewareContext<better_call0.MiddlewareOptions, {
26
+ handler: better_call0.Middleware<(inputContext: Record<string, any>) => Promise<better_call0.MiddlewareContext<{
28
27
  returned?: unknown | undefined;
29
28
  responseHeaders?: Headers | undefined;
30
29
  } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
@@ -154,171 +153,156 @@ declare const electron: (options?: ElectronOptions | undefined) => {
154
153
  runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
155
154
  }> | {
156
155
  electron_authorization_code: string;
157
- } | undefined>;
156
+ } | undefined>>;
158
157
  })[];
159
158
  };
160
159
  endpoints: {
161
- electronToken: better_call0.StrictEndpoint<"/electron/token", {
162
- method: "POST";
163
- body: z.ZodObject<{
164
- token: z.ZodString;
165
- state: z.ZodString;
166
- code_verifier: z.ZodString;
167
- }, z.core.$strip>;
168
- metadata: {
169
- scope: "http";
170
- openapi: {
171
- description: string;
172
- operationId: string;
173
- responses: {
174
- 200: {
175
- description: string;
176
- content: {
177
- "application/json": {
178
- schema: {
179
- type: "object";
180
- properties: {
181
- token: {
182
- type: string;
183
- };
184
- user: {
185
- type: string;
186
- $ref: string;
187
- };
188
- };
189
- required: string[];
190
- };
191
- };
192
- };
193
- };
194
- };
195
- };
196
- };
197
- }, {
160
+ electronToken: better_call0.Endpoint<"/electron/token", "POST", {
161
+ token: string;
162
+ state: string;
163
+ code_verifier: string;
164
+ }, Record<string, any> | undefined, [], {
198
165
  token: string;
199
166
  user: better_auth0.User & Record<string, any>;
200
- }>;
201
- electronInitOAuthProxy: better_call0.StrictEndpoint<"/electron/init-oauth-proxy", {
202
- method: "GET";
203
- query: z.ZodObject<{
204
- provider: z.ZodString;
205
- state: z.ZodString;
206
- code_challenge: z.ZodString;
207
- code_challenge_method: z.ZodOptional<z.ZodString>;
208
- }, z.core.$strip>;
209
- metadata: {
210
- scope: "http";
211
- openapi: {
212
- description: string;
213
- operationId: string;
214
- responses: {
215
- 200: {
216
- description: string;
217
- content: {
218
- "application/json": {
219
- schema: {
220
- type: "object";
221
- properties: {
222
- url: {
223
- type: string;
224
- nullable: boolean;
225
- };
226
- redirect: {
227
- type: string;
228
- };
229
- user: {
230
- type: string;
231
- $ref: string;
232
- };
233
- token: {
234
- type: string;
235
- };
167
+ }, {
168
+ scope: "http";
169
+ openapi: {
170
+ description: string;
171
+ operationId: string;
172
+ responses: {
173
+ 200: {
174
+ description: string;
175
+ content: {
176
+ "application/json": {
177
+ schema: {
178
+ type: "object";
179
+ properties: {
180
+ token: {
181
+ type: string;
182
+ };
183
+ user: {
184
+ type: string;
185
+ $ref: string;
236
186
  };
237
- required: string[];
238
187
  };
188
+ required: string[];
239
189
  };
240
190
  };
241
191
  };
242
192
  };
243
193
  };
244
194
  };
245
- }, {
195
+ }, undefined>;
196
+ electronInitOAuthProxy: better_call0.Endpoint<"/electron/init-oauth-proxy", "GET", undefined, {
197
+ provider: string;
198
+ state: string;
199
+ code_challenge: string;
200
+ code_challenge_method?: string | undefined;
201
+ }, [], {
246
202
  url: string | undefined;
247
203
  redirect: boolean;
248
204
  user?: better_auth0.User & Record<string, any>;
249
205
  token?: string;
250
- } | undefined>;
251
- electronTransferUser: better_call0.StrictEndpoint<"/electron/transfer-user", {
252
- method: "POST";
253
- query: z.ZodObject<{
254
- client_id: z.ZodString;
255
- state: z.ZodString;
256
- code_challenge: z.ZodString;
257
- code_challenge_method: z.ZodOptional<z.ZodString>;
258
- }, z.core.$strip>;
259
- body: z.ZodObject<{
260
- callbackURL: z.ZodOptional<z.ZodString>;
261
- }, z.core.$strip>;
262
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
263
- session: {
264
- session: Record<string, any> & {
265
- id: string;
266
- createdAt: Date;
267
- updatedAt: Date;
268
- userId: string;
269
- expiresAt: Date;
270
- token: string;
271
- ipAddress?: string | null | undefined;
272
- userAgent?: string | null | undefined;
273
- };
274
- user: Record<string, any> & {
275
- id: string;
276
- createdAt: Date;
277
- updatedAt: Date;
278
- email: string;
279
- emailVerified: boolean;
280
- name: string;
281
- image?: string | null | undefined;
282
- };
283
- };
284
- }>)[];
285
- requireHeaders: true;
286
- metadata: {
287
- openapi: {
288
- description: string;
289
- operationId: string;
290
- responses: {
291
- 200: {
292
- description: string;
293
- content: {
294
- "application/json": {
295
- schema: {
296
- type: "object";
297
- properties: {
298
- url: {
299
- type: string;
300
- nullable: boolean;
301
- };
302
- redirect: {
303
- type: string;
304
- };
305
- electron_authorization_code: {
306
- type: string;
307
- };
206
+ } | undefined, {
207
+ scope: "http";
208
+ openapi: {
209
+ description: string;
210
+ operationId: string;
211
+ responses: {
212
+ 200: {
213
+ description: string;
214
+ content: {
215
+ "application/json": {
216
+ schema: {
217
+ type: "object";
218
+ properties: {
219
+ url: {
220
+ type: string;
221
+ nullable: boolean;
222
+ };
223
+ redirect: {
224
+ type: string;
225
+ };
226
+ user: {
227
+ type: string;
228
+ $ref: string;
229
+ };
230
+ token: {
231
+ type: string;
308
232
  };
309
- required: string[];
310
233
  };
234
+ required: string[];
311
235
  };
312
236
  };
313
237
  };
314
238
  };
315
239
  };
316
240
  };
241
+ }, undefined>;
242
+ electronTransferUser: better_call0.Endpoint<"/electron/transfer-user", "POST", {
243
+ callbackURL?: string | undefined;
317
244
  }, {
245
+ client_id: string;
246
+ state: string;
247
+ code_challenge: string;
248
+ code_challenge_method?: string | undefined;
249
+ }, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
250
+ session: {
251
+ session: Record<string, any> & {
252
+ id: string;
253
+ createdAt: Date;
254
+ updatedAt: Date;
255
+ userId: string;
256
+ expiresAt: Date;
257
+ token: string;
258
+ ipAddress?: string | null | undefined;
259
+ userAgent?: string | null | undefined;
260
+ };
261
+ user: Record<string, any> & {
262
+ id: string;
263
+ createdAt: Date;
264
+ updatedAt: Date;
265
+ email: string;
266
+ emailVerified: boolean;
267
+ name: string;
268
+ image?: string | null | undefined;
269
+ };
270
+ };
271
+ }>>], {
318
272
  url: string | null;
319
273
  redirect: boolean;
320
274
  electron_authorization_code: string;
321
- }>;
275
+ }, {
276
+ openapi: {
277
+ description: string;
278
+ operationId: string;
279
+ responses: {
280
+ 200: {
281
+ description: string;
282
+ content: {
283
+ "application/json": {
284
+ schema: {
285
+ type: "object";
286
+ properties: {
287
+ url: {
288
+ type: string;
289
+ nullable: boolean;
290
+ };
291
+ redirect: {
292
+ type: string;
293
+ };
294
+ electron_authorization_code: {
295
+ type: string;
296
+ };
297
+ };
298
+ required: string[];
299
+ };
300
+ };
301
+ };
302
+ };
303
+ };
304
+ };
305
+ }, undefined>;
322
306
  };
323
307
  options: {
324
308
  codeExpiresIn: number;
package/dist/index.mjs CHANGED
@@ -13,7 +13,6 @@ import { betterFetch } from "@better-fetch/fetch";
13
13
  import { createAuthEndpoint, sessionMiddleware } from "better-auth/api";
14
14
  import { setSessionCookie } from "better-auth/cookies";
15
15
  import { parseUserOutput } from "better-auth/db";
16
-
17
16
  //#region src/error-codes.ts
18
17
  const ELECTRON_ERROR_CODES = defineErrorCodes({
19
18
  INVALID_CLIENT_ID: "Invalid client ID",
@@ -24,7 +23,6 @@ const ELECTRON_ERROR_CODES = defineErrorCodes({
24
23
  MISSING_STATE: "state is required",
25
24
  MISSING_PKCE: "pkce is required"
26
25
  });
27
-
28
26
  //#endregion
29
27
  //#region src/routes.ts
30
28
  const electronTokenBodySchema = z.object({
@@ -191,7 +189,6 @@ const electronTransferUser = (_opts, { handleTransfer }) => createAuthEndpoint("
191
189
  electron_authorization_code: identifier
192
190
  });
193
191
  });
194
-
195
192
  //#endregion
196
193
  //#region src/index.ts
197
194
  const electron = (options) => {
@@ -298,6 +295,5 @@ const electron = (options) => {
298
295
  $ERROR_CODES: ELECTRON_ERROR_CODES
299
296
  };
300
297
  };
301
-
302
298
  //#endregion
303
- export { electron };
299
+ export { electron };