@better-auth/electron 1.6.9 → 1.6.11
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-D_ggtAOl.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";
|
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-D_ggtAOl.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
|
|
@@ -4832,7 +4866,12 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
4832
4866
|
updateSession(sessionToken: string, session: Partial<Session> & Record<string, any>): Promise<Session | null>;
|
|
4833
4867
|
deleteSession(token: string): Promise<void>;
|
|
4834
4868
|
deleteAccounts(userId: string): Promise<void>;
|
|
4835
|
-
|
|
4869
|
+
/**
|
|
4870
|
+
* Delete an account by its primary key.
|
|
4871
|
+
*
|
|
4872
|
+
* @param id - The account row's primary key (the `id` column, not the `accountId` column).
|
|
4873
|
+
*/
|
|
4874
|
+
deleteAccount(id: string): Promise<void>;
|
|
4836
4875
|
deleteSessions(userIdOrSessionTokens: string | string[]): Promise<void>;
|
|
4837
4876
|
findOAuthUser(email: string, accountId: string, providerId: string): Promise<{
|
|
4838
4877
|
user: User;
|
|
@@ -4858,7 +4897,20 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
4858
4897
|
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|
|
4859
4898
|
findVerificationValue(identifier: string): Promise<Verification | null>;
|
|
4860
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. Callers MUST gate any
|
|
4905
|
+
* state change (issue session, mint token, change password) on a non-null
|
|
4906
|
+
* result.
|
|
4907
|
+
*
|
|
4908
|
+
* Replaces the racy `findVerificationValue` + `deleteVerificationByIdentifier`
|
|
4909
|
+
* pair at single-use credential consumption sites.
|
|
4910
|
+
*/
|
|
4911
|
+
consumeVerificationValue(identifier: string): Promise<Verification | null>;
|
|
4861
4912
|
updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
|
|
4913
|
+
refreshUserSessions(user: User): Promise<void>;
|
|
4862
4914
|
}
|
|
4863
4915
|
type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
4864
4916
|
type CheckPasswordFn<Options extends BetterAuthOptions = BetterAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
|
|
@@ -5427,12 +5479,13 @@ type BetterAuthAdvancedOptions = {
|
|
|
5427
5479
|
*/
|
|
5428
5480
|
disableIpTracking?: boolean;
|
|
5429
5481
|
/**
|
|
5430
|
-
* IPv6
|
|
5431
|
-
*
|
|
5482
|
+
* IPv6 prefix length used to collapse addresses before rate-limit keying.
|
|
5483
|
+
* Any integer from 0 to 128 is accepted; common values are 32, 48, 56, 64, 128.
|
|
5484
|
+
* Out-of-range values fall back to safe behavior (negative -> mask all, > 128 -> no mask).
|
|
5432
5485
|
*
|
|
5433
5486
|
* @default 64
|
|
5434
5487
|
*/
|
|
5435
|
-
ipv6Subnet?:
|
|
5488
|
+
ipv6Subnet?: number;
|
|
5436
5489
|
} | undefined;
|
|
5437
5490
|
/**
|
|
5438
5491
|
* Force cookies to always use the `Secure` attribute. By default,
|
|
@@ -6181,6 +6234,25 @@ type BetterAuthOptions = {
|
|
|
6181
6234
|
* @default false
|
|
6182
6235
|
*/
|
|
6183
6236
|
disableImplicitLinking?: boolean;
|
|
6237
|
+
/**
|
|
6238
|
+
* Require the existing local user row to have
|
|
6239
|
+
* `emailVerified: true` before implicit account linking
|
|
6240
|
+
* uses the IdP's `email_verified` claim as ownership
|
|
6241
|
+
* proof. Defaults to `true` so an attacker who
|
|
6242
|
+
* pre-registers an unverified account at a victim's
|
|
6243
|
+
* email cannot have the victim's OAuth identity linked
|
|
6244
|
+
* into the attacker-owned row on first sign-in. Set to
|
|
6245
|
+
* `false` for backward compatibility on apps whose
|
|
6246
|
+
* users sign up via OAuth without verifying their email
|
|
6247
|
+
* locally; understand the takeover risk before doing
|
|
6248
|
+
* so.
|
|
6249
|
+
*
|
|
6250
|
+
* @default true
|
|
6251
|
+
*
|
|
6252
|
+
* @deprecated The option will be removed on the next
|
|
6253
|
+
* minor; the gate will become unconditional.
|
|
6254
|
+
*/
|
|
6255
|
+
requireLocalEmailVerified?: boolean;
|
|
6184
6256
|
/**
|
|
6185
6257
|
* List of trusted providers. Can be a static array or a function
|
|
6186
6258
|
* that returns providers dynamically. The function is called
|
|
@@ -6760,6 +6832,18 @@ interface SecondaryStorage {
|
|
|
6760
6832
|
* @returns - Value of the key
|
|
6761
6833
|
*/
|
|
6762
6834
|
get: (key: string) => Awaitable<unknown>;
|
|
6835
|
+
/**
|
|
6836
|
+
* Atomically get a value and delete it from storage.
|
|
6837
|
+
*
|
|
6838
|
+
* This is optional for backwards compatibility with existing secondary
|
|
6839
|
+
* storage implementations. Single-use credential consumers use it when
|
|
6840
|
+
* present to avoid a read-then-delete race.
|
|
6841
|
+
*
|
|
6842
|
+
* TODO(secondary-storage-atomic-consume): make this required in the next
|
|
6843
|
+
* breaking release, or require database-backed verification storage for
|
|
6844
|
+
* security-sensitive consume paths.
|
|
6845
|
+
*/
|
|
6846
|
+
getAndDelete?: (key: string) => Awaitable<unknown>;
|
|
6763
6847
|
set: (
|
|
6764
6848
|
/**
|
|
6765
6849
|
* 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-D_ggtAOl.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.11",
|
|
4
4
|
"description": "Better Auth integration for Electron applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,8 +80,8 @@
|
|
|
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.11",
|
|
84
|
+
"better-auth": "1.6.11"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@better-auth/utils": "0.4.0",
|
|
@@ -89,8 +89,8 @@
|
|
|
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.11",
|
|
93
|
+
"better-auth": "^1.6.11"
|
|
94
94
|
},
|
|
95
95
|
"peerDependenciesMeta": {
|
|
96
96
|
"electron": {
|