@better-auth/electron 1.6.10 → 1.6.12
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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-dnGn0OgM.mjs";
|
|
2
2
|
import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-DxDKRT6e.mjs";
|
|
3
3
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
4
4
|
import { base64, base64Url } from "@better-auth/utils/base64";
|
|
@@ -8,7 +8,7 @@ import * as z from "zod";
|
|
|
8
8
|
import { Buffer } from "node:buffer";
|
|
9
9
|
import { createHash } from "@better-auth/utils/hash";
|
|
10
10
|
import { signInSocial } from "better-auth/api";
|
|
11
|
-
import { parseSetCookieHeader } from "better-auth/cookies";
|
|
11
|
+
import { cookieNameRegex, parseSetCookieHeader } from "better-auth/cookies";
|
|
12
12
|
import electron, { shell } from "electron";
|
|
13
13
|
import { isDevelopment as isDevelopment$1 } from "@better-auth/core/env";
|
|
14
14
|
import { isPublicRoutableHost } from "@better-auth/core/utils/host";
|
|
@@ -474,10 +474,13 @@ function getCookie(cookie) {
|
|
|
474
474
|
try {
|
|
475
475
|
parsed = JSON.parse(cookie);
|
|
476
476
|
} catch (_e) {}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
477
|
+
const pairs = [];
|
|
478
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
479
|
+
if (value.expires && new Date(value.expires) < /* @__PURE__ */ new Date()) continue;
|
|
480
|
+
if (!cookieNameRegex.test(key)) continue;
|
|
481
|
+
pairs.push(`${key}=${encodeURIComponent(value.value)}`);
|
|
482
|
+
}
|
|
483
|
+
return pairs.join("; ");
|
|
481
484
|
}
|
|
482
485
|
/**
|
|
483
486
|
* Compare if session cookies have actually changed by comparing their values.
|
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-dnGn0OgM.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";
|
package/dist/preload.d.mts
CHANGED
|
@@ -30,6 +30,7 @@ type DBAdapterDebugLogOption = boolean | {
|
|
|
30
30
|
findMany?: boolean | undefined;
|
|
31
31
|
delete?: boolean | undefined;
|
|
32
32
|
deleteMany?: boolean | undefined;
|
|
33
|
+
consumeOne?: boolean | undefined;
|
|
33
34
|
count?: boolean | undefined;
|
|
34
35
|
} | {
|
|
35
36
|
/**
|
|
@@ -205,7 +206,7 @@ interface DBAdapterFactoryConfig<Options extends BetterAuthOptions = BetterAuthO
|
|
|
205
206
|
/**
|
|
206
207
|
* The action which was called from the adapter.
|
|
207
208
|
*/
|
|
208
|
-
action: "create" | "update" | "findOne" | "findMany" | "updateMany" | "delete" | "deleteMany" | "count";
|
|
209
|
+
action: "create" | "update" | "findOne" | "findMany" | "updateMany" | "delete" | "deleteMany" | "consumeOne" | "count";
|
|
209
210
|
/**
|
|
210
211
|
* The model name.
|
|
211
212
|
*/
|
|
@@ -423,6 +424,26 @@ type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
|
423
424
|
model: string;
|
|
424
425
|
where: Where[];
|
|
425
426
|
}) => Promise<number>;
|
|
427
|
+
/**
|
|
428
|
+
* Atomically consume a single row matching the where clause: delete it and
|
|
429
|
+
* return the deleted row, or return `null` if no row matched.
|
|
430
|
+
* Implementations MUST NOT delete any additional rows that also match a
|
|
431
|
+
* non-unique predicate.
|
|
432
|
+
*
|
|
433
|
+
* Under concurrent invocation against the same row, exactly one caller
|
|
434
|
+
* receives the row; subsequent racers receive `null`. This is the
|
|
435
|
+
* race-safe primitive for consuming single-use credentials
|
|
436
|
+
* (verification tokens, authorization codes, one-time tokens).
|
|
437
|
+
*
|
|
438
|
+
* Always defined on the factory-wrapped adapter. When the underlying
|
|
439
|
+
* `CustomAdapter` does not implement `consumeOne`, the factory provides
|
|
440
|
+
* a fallback that wraps `findMany + deleteMany` in `transaction(...)`
|
|
441
|
+
* and returns the row only when the delete reports an affected row.
|
|
442
|
+
*/
|
|
443
|
+
consumeOne: <T>(data: {
|
|
444
|
+
model: string;
|
|
445
|
+
where: Where[];
|
|
446
|
+
}) => Promise<T | null>;
|
|
426
447
|
/**
|
|
427
448
|
* Execute multiple operations in a transaction.
|
|
428
449
|
* If the adapter doesn't support transactions, operations will be executed sequentially.
|
|
@@ -504,6 +525,19 @@ interface CustomAdapter {
|
|
|
504
525
|
model: string;
|
|
505
526
|
where: CleanedWhere[];
|
|
506
527
|
}) => Promise<number>;
|
|
528
|
+
/**
|
|
529
|
+
* Optional native atomic single-row consume. When omitted, the adapter
|
|
530
|
+
* factory falls back to `transaction(findMany + deleteMany)`.
|
|
531
|
+
* Implementing this method natively (e.g. `DELETE ... RETURNING *`,
|
|
532
|
+
* `findOneAndDelete`, `OUTPUT deleted.*`) gives one round trip and the
|
|
533
|
+
* strongest race-safety guarantee. Implementations must delete at most
|
|
534
|
+
* one matching row. TODO(consume-one-required): tighten to required in the
|
|
535
|
+
* next minor on `next`.
|
|
536
|
+
*/
|
|
537
|
+
consumeOne?: <T>(data: {
|
|
538
|
+
model: string;
|
|
539
|
+
where: CleanedWhere[];
|
|
540
|
+
}) => Promise<T | null>;
|
|
507
541
|
count: ({
|
|
508
542
|
model,
|
|
509
543
|
where
|
|
@@ -4863,6 +4897,20 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
4863
4897
|
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|
|
4864
4898
|
findVerificationValue(identifier: string): Promise<Verification | null>;
|
|
4865
4899
|
deleteVerificationByIdentifier(identifier: string): Promise<void>;
|
|
4900
|
+
/**
|
|
4901
|
+
* Atomically consume a single-use verification row by `identifier` and
|
|
4902
|
+
* return it. Only the first concurrent caller receives the latest row;
|
|
4903
|
+
* subsequent callers receive `null`. Consuming one row invalidates the
|
|
4904
|
+
* whole identifier so stale rows cannot be replayed. Rows past their
|
|
4905
|
+
* `expiresAt` are treated as already invalid: the row is deleted but
|
|
4906
|
+
* `null` is returned, so callers do not need to gate on `expiresAt`
|
|
4907
|
+
* themselves. Callers MUST gate any state change (issue session, mint
|
|
4908
|
+
* token, change password) on a non-null result.
|
|
4909
|
+
*
|
|
4910
|
+
* Replaces the racy `findVerificationValue` + `deleteVerificationByIdentifier`
|
|
4911
|
+
* pair at single-use credential consumption sites.
|
|
4912
|
+
*/
|
|
4913
|
+
consumeVerificationValue(identifier: string): Promise<Verification | null>;
|
|
4866
4914
|
updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
|
|
4867
4915
|
refreshUserSessions(user: User): Promise<void>;
|
|
4868
4916
|
}
|
|
@@ -5433,12 +5481,13 @@ type BetterAuthAdvancedOptions = {
|
|
|
5433
5481
|
*/
|
|
5434
5482
|
disableIpTracking?: boolean;
|
|
5435
5483
|
/**
|
|
5436
|
-
* IPv6
|
|
5437
|
-
*
|
|
5484
|
+
* IPv6 prefix length used to collapse addresses before rate-limit keying.
|
|
5485
|
+
* Any integer from 0 to 128 is accepted; common values are 32, 48, 56, 64, 128.
|
|
5486
|
+
* Out-of-range values fall back to safe behavior (negative -> mask all, > 128 -> no mask).
|
|
5438
5487
|
*
|
|
5439
5488
|
* @default 64
|
|
5440
5489
|
*/
|
|
5441
|
-
ipv6Subnet?:
|
|
5490
|
+
ipv6Subnet?: number;
|
|
5442
5491
|
} | undefined;
|
|
5443
5492
|
/**
|
|
5444
5493
|
* Force cookies to always use the `Secure` attribute. By default,
|
|
@@ -6187,6 +6236,25 @@ type BetterAuthOptions = {
|
|
|
6187
6236
|
* @default false
|
|
6188
6237
|
*/
|
|
6189
6238
|
disableImplicitLinking?: boolean;
|
|
6239
|
+
/**
|
|
6240
|
+
* Require the existing local user row to have
|
|
6241
|
+
* `emailVerified: true` before implicit account linking
|
|
6242
|
+
* uses the IdP's `email_verified` claim as ownership
|
|
6243
|
+
* proof. Defaults to `true` so an attacker who
|
|
6244
|
+
* pre-registers an unverified account at a victim's
|
|
6245
|
+
* email cannot have the victim's OAuth identity linked
|
|
6246
|
+
* into the attacker-owned row on first sign-in. Set to
|
|
6247
|
+
* `false` for backward compatibility on apps whose
|
|
6248
|
+
* users sign up via OAuth without verifying their email
|
|
6249
|
+
* locally; understand the takeover risk before doing
|
|
6250
|
+
* so.
|
|
6251
|
+
*
|
|
6252
|
+
* @default true
|
|
6253
|
+
*
|
|
6254
|
+
* @deprecated The option will be removed on the next
|
|
6255
|
+
* minor; the gate will become unconditional.
|
|
6256
|
+
*/
|
|
6257
|
+
requireLocalEmailVerified?: boolean;
|
|
6190
6258
|
/**
|
|
6191
6259
|
* List of trusted providers. Can be a static array or a function
|
|
6192
6260
|
* that returns providers dynamically. The function is called
|
|
@@ -6766,6 +6834,18 @@ interface SecondaryStorage {
|
|
|
6766
6834
|
* @returns - Value of the key
|
|
6767
6835
|
*/
|
|
6768
6836
|
get: (key: string) => Awaitable<unknown>;
|
|
6837
|
+
/**
|
|
6838
|
+
* Atomically get a value and delete it from storage.
|
|
6839
|
+
*
|
|
6840
|
+
* This is optional for backwards compatibility with existing secondary
|
|
6841
|
+
* storage implementations. Single-use credential consumers use it when
|
|
6842
|
+
* present to avoid a read-then-delete race.
|
|
6843
|
+
*
|
|
6844
|
+
* TODO(secondary-storage-atomic-consume): make this required in the next
|
|
6845
|
+
* breaking release, or require database-backed verification storage for
|
|
6846
|
+
* security-sensitive consume paths.
|
|
6847
|
+
*/
|
|
6848
|
+
getAndDelete?: (key: string) => Awaitable<unknown>;
|
|
6769
6849
|
set: (
|
|
6770
6850
|
/**
|
|
6771
6851
|
* Key to store
|
package/dist/proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-dnGn0OgM.mjs";
|
|
2
2
|
import { r as parseProtocolScheme } from "./utils-DxDKRT6e.mjs";
|
|
3
3
|
import { parseCookies } from "better-auth/cookies";
|
|
4
4
|
//#region src/proxy.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/electron",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.12",
|
|
4
4
|
"description": "Better Auth integration for Electron applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"better-sqlite3": "^12.6.2",
|
|
81
81
|
"electron": "^41.2.2",
|
|
82
82
|
"tsdown": "0.21.1",
|
|
83
|
-
"@better-auth/core": "1.6.
|
|
84
|
-
"better-auth": "1.6.
|
|
83
|
+
"@better-auth/core": "1.6.12",
|
|
84
|
+
"better-auth": "1.6.12"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@better-auth/utils": "0.4.
|
|
87
|
+
"@better-auth/utils": "0.4.1",
|
|
88
88
|
"@better-fetch/fetch": "1.1.21",
|
|
89
89
|
"better-call": "1.3.5",
|
|
90
90
|
"conf": "^15.0.2",
|
|
91
91
|
"electron": ">=36.0.0",
|
|
92
|
-
"@better-auth/core": "^1.6.
|
|
93
|
-
"better-auth": "^1.6.
|
|
92
|
+
"@better-auth/core": "^1.6.12",
|
|
93
|
+
"better-auth": "^1.6.12"
|
|
94
94
|
},
|
|
95
95
|
"peerDependenciesMeta": {
|
|
96
96
|
"electron": {
|