@better-auth/electron 1.5.7-beta.1 → 1.6.0

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,7 +241,14 @@ 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
- [x: string]: any;
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>>;
245
252
  }, z.core.$strip>;
246
253
  type ElectronRequestAuthOptions = z.infer<typeof requestAuthOptionsSchema>;
247
254
  /**
@@ -307,11 +314,13 @@ declare function handleDeepLink({
307
314
  //#region src/client.d.ts
308
315
  declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
309
316
  id: "electron";
317
+ version: string;
310
318
  fetchPlugins: {
311
319
  id: string;
312
320
  name: string;
313
321
  init(url: string, options: ({
314
322
  priority?: RequestPriority | undefined;
323
+ mode?: RequestMode | undefined;
315
324
  cache?: RequestCache | undefined;
316
325
  credentials?: RequestCredentials | undefined;
317
326
  headers?: (HeadersInit & (HeadersInit | {
@@ -322,7 +331,6 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
322
331
  integrity?: string | undefined;
323
332
  keepalive?: boolean | undefined;
324
333
  method?: string | undefined;
325
- mode?: RequestMode | undefined;
326
334
  redirect?: RequestRedirect | undefined;
327
335
  referrer?: string | undefined;
328
336
  referrerPolicy?: ReferrerPolicy | undefined;
@@ -367,6 +375,7 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
367
375
  url: string;
368
376
  options: {
369
377
  priority?: RequestPriority | undefined;
378
+ mode?: RequestMode | undefined;
370
379
  cache?: RequestCache | undefined;
371
380
  credentials?: RequestCredentials | undefined;
372
381
  headers?: (HeadersInit & (HeadersInit | {
@@ -377,7 +386,6 @@ declare const electronClient: <O extends ElectronClientOptions>(options: O) => {
377
386
  integrity?: string | undefined;
378
387
  keepalive?: boolean | undefined;
379
388
  method?: string | undefined;
380
- mode?: RequestMode | undefined;
381
389
  redirect?: RequestRedirect | undefined;
382
390
  referrer?: string | undefined;
383
391
  referrerPolicy?: ReferrerPolicy | undefined;
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-D8BB_eSV.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-D6xRwPM0.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,5 @@
1
- import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-CRzg_SlK.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-Cf5gNNxE.mjs";
2
+ import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-DxDKRT6e.mjs";
2
3
  import { BetterAuthError } from "@better-auth/core/error";
3
4
  import { base64, base64Url } from "@better-auth/utils/base64";
4
5
  import { APIError as APIError$1, getBaseURL, isDevelopment, isTest, safeJSONParse } from "better-auth";
@@ -596,6 +597,7 @@ const electronClient = (options) => {
596
597
  if ((isDevelopment() || isTest()) && /^(?!\.)(?!.*\.\.)(?!.*\.$)[^.]+\.[^.]+$/.test(scheme)) console.warn("The provided scheme does not follow the reverse domain name notation. For example: `app.example.com` -> `com.example.app`.");
597
598
  return {
598
599
  id: "electron",
600
+ version: PACKAGE_VERSION,
599
601
  fetchPlugins: [{
600
602
  id: "electron",
601
603
  name: "Electron",
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-D8BB_eSV.mjs";
1
+ import { f as FetchUserImageResult, m as normalizeUserOutput, p as fetchUserImage, v as ElectronOptions, y as ElectronSharedOptions } from "./client-D6xRwPM0.mjs";
2
2
  import * as better_auth0 from "better-auth";
3
+ import * as z from "zod";
3
4
  import * as _better_auth_core0 from "@better-auth/core";
4
5
  import { HookEndpointContext } from "@better-auth/core";
5
6
  import * as better_call0 from "better-call";
@@ -14,16 +15,17 @@ declare module "@better-auth/core" {
14
15
  }
15
16
  declare const electron: (options?: ElectronOptions | undefined) => {
16
17
  id: "electron";
18
+ version: string;
17
19
  onRequest(request: Request, _ctx: better_auth0.AuthContext): Promise<{
18
20
  request: Request;
19
21
  } | undefined>;
20
22
  hooks: {
21
23
  after: ({
22
24
  matcher: (ctx: HookEndpointContext) => boolean;
23
- handler: better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>;
25
+ handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>;
24
26
  } | {
25
27
  matcher: (ctx: HookEndpointContext) => boolean;
26
- handler: better_call0.Middleware<(inputContext: Record<string, any>) => Promise<better_call0.MiddlewareContext<{
28
+ handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<better_call0.MiddlewareContext<better_call0.MiddlewareOptions, {
27
29
  returned?: unknown | undefined;
28
30
  responseHeaders?: Headers | undefined;
29
31
  } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
@@ -153,156 +155,171 @@ declare const electron: (options?: ElectronOptions | undefined) => {
153
155
  runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
154
156
  }> | {
155
157
  electron_authorization_code: string;
156
- } | undefined>>;
158
+ } | undefined>;
157
159
  })[];
158
160
  };
159
161
  endpoints: {
160
- electronToken: better_call0.Endpoint<"/electron/token", "POST", {
161
- token: string;
162
- state: string;
163
- code_verifier: string;
164
- }, Record<string, any> | undefined, [], {
165
- token: string;
166
- user: better_auth0.User & Record<string, any>;
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;
162
+ electronToken: better_call0.StrictEndpoint<"/electron/token", {
163
+ method: "POST";
164
+ body: z.ZodObject<{
165
+ token: z.ZodString;
166
+ state: z.ZodString;
167
+ code_verifier: z.ZodString;
168
+ }, z.core.$strip>;
169
+ metadata: {
170
+ scope: "http";
171
+ openapi: {
172
+ description: string;
173
+ operationId: string;
174
+ responses: {
175
+ 200: {
176
+ description: string;
177
+ content: {
178
+ "application/json": {
179
+ schema: {
180
+ type: "object";
181
+ properties: {
182
+ token: {
183
+ type: string;
184
+ };
185
+ user: {
186
+ type: string;
187
+ $ref: string;
188
+ };
186
189
  };
190
+ required: string[];
187
191
  };
188
- required: string[];
189
192
  };
190
193
  };
191
194
  };
192
195
  };
193
196
  };
194
197
  };
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
- }, [], {
202
- url: string | undefined;
203
- redirect: boolean;
204
- user?: better_auth0.User & Record<string, any>;
205
- token?: string;
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;
198
+ }, {
199
+ token: string;
200
+ user: better_auth0.User & Record<string, any>;
201
+ }>;
202
+ electronInitOAuthProxy: better_call0.StrictEndpoint<"/electron/init-oauth-proxy", {
203
+ method: "GET";
204
+ query: z.ZodObject<{
205
+ provider: z.ZodString;
206
+ state: z.ZodString;
207
+ code_challenge: z.ZodString;
208
+ code_challenge_method: z.ZodOptional<z.ZodString>;
209
+ }, z.core.$strip>;
210
+ metadata: {
211
+ scope: "http";
212
+ openapi: {
213
+ description: string;
214
+ operationId: string;
215
+ responses: {
216
+ 200: {
217
+ description: string;
218
+ content: {
219
+ "application/json": {
220
+ schema: {
221
+ type: "object";
222
+ properties: {
223
+ url: {
224
+ type: string;
225
+ nullable: boolean;
226
+ };
227
+ redirect: {
228
+ type: string;
229
+ };
230
+ user: {
231
+ type: string;
232
+ $ref: string;
233
+ };
234
+ token: {
235
+ type: string;
236
+ };
232
237
  };
238
+ required: string[];
233
239
  };
234
- required: string[];
235
240
  };
236
241
  };
237
242
  };
238
243
  };
239
244
  };
240
245
  };
241
- }, undefined>;
242
- electronTransferUser: better_call0.Endpoint<"/electron/transfer-user", "POST", {
243
- callbackURL?: string | undefined;
244
246
  }, {
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
- }>>], {
272
- url: string | null;
247
+ url: string | undefined;
273
248
  redirect: boolean;
274
- electron_authorization_code: string;
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;
249
+ user?: better_auth0.User & Record<string, any>;
250
+ token?: string;
251
+ } | undefined>;
252
+ electronTransferUser: better_call0.StrictEndpoint<"/electron/transfer-user", {
253
+ method: "POST";
254
+ query: z.ZodObject<{
255
+ client_id: z.ZodString;
256
+ state: z.ZodString;
257
+ code_challenge: z.ZodString;
258
+ code_challenge_method: z.ZodOptional<z.ZodString>;
259
+ }, z.core.$strip>;
260
+ body: z.ZodObject<{
261
+ callbackURL: z.ZodOptional<z.ZodString>;
262
+ }, z.core.$strip>;
263
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
264
+ session: {
265
+ session: Record<string, any> & {
266
+ id: string;
267
+ createdAt: Date;
268
+ updatedAt: Date;
269
+ userId: string;
270
+ expiresAt: Date;
271
+ token: string;
272
+ ipAddress?: string | null | undefined;
273
+ userAgent?: string | null | undefined;
274
+ };
275
+ user: Record<string, any> & {
276
+ id: string;
277
+ createdAt: Date;
278
+ updatedAt: Date;
279
+ email: string;
280
+ emailVerified: boolean;
281
+ name: string;
282
+ image?: string | null | undefined;
283
+ };
284
+ };
285
+ }>)[];
286
+ requireHeaders: true;
287
+ metadata: {
288
+ openapi: {
289
+ description: string;
290
+ operationId: string;
291
+ responses: {
292
+ 200: {
293
+ description: string;
294
+ content: {
295
+ "application/json": {
296
+ schema: {
297
+ type: "object";
298
+ properties: {
299
+ url: {
300
+ type: string;
301
+ nullable: boolean;
302
+ };
303
+ redirect: {
304
+ type: string;
305
+ };
306
+ electron_authorization_code: {
307
+ type: string;
308
+ };
296
309
  };
310
+ required: string[];
297
311
  };
298
- required: string[];
299
312
  };
300
313
  };
301
314
  };
302
315
  };
303
316
  };
304
317
  };
305
- }, undefined>;
318
+ }, {
319
+ url: string | null;
320
+ redirect: boolean;
321
+ electron_authorization_code: string;
322
+ }>;
306
323
  };
307
324
  options: {
308
325
  codeExpiresIn: number;
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { t as PACKAGE_VERSION } from "./version-Cf5gNNxE.mjs";
1
2
  import { createAuthMiddleware } from "@better-auth/core/api";
2
3
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
3
4
  import { base64Url } from "@better-auth/utils/base64";
@@ -235,6 +236,7 @@ const electron = (options) => {
235
236
  };
236
237
  return {
237
238
  id: "electron",
239
+ version: PACKAGE_VERSION,
238
240
  async onRequest(request, _ctx) {
239
241
  if (opts.disableOriginOverride || request.headers.get("origin")) return;
240
242
  const electronOrigin = request.headers.get("electron-origin");