@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.
- package/dist/{client-D8BB_eSV.d.mts → client-D6xRwPM0.d.mts} +11 -3
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +3 -1
- package/dist/index.d.mts +141 -124
- package/dist/index.mjs +2 -0
- package/dist/preload.d.mts +766 -562
- package/dist/preload.mjs +2 -61
- package/dist/proxy.d.mts +2 -1
- package/dist/proxy.mjs +3 -1
- package/dist/storage.d.mts +1 -1
- package/dist/version-Cf5gNNxE.mjs +5 -0
- package/package.json +9 -8
- /package/dist/{utils-CRzg_SlK.mjs → utils-DxDKRT6e.mjs} +0 -0
|
@@ -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
|
-
|
|
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-
|
|
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 {
|
|
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-
|
|
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:
|
|
25
|
+
handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>;
|
|
24
26
|
} | {
|
|
25
27
|
matcher: (ctx: HookEndpointContext) => boolean;
|
|
26
|
-
handler:
|
|
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.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
},
|
|
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");
|