@better-auth/electron 1.6.10 → 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-Bwp02oze.mjs";
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-Bwp02oze.mjs";
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";
@@ -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,18 @@ 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. 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>;
4866
4912
  updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
4867
4913
  refreshUserSessions(user: User): Promise<void>;
4868
4914
  }
@@ -5433,12 +5479,13 @@ type BetterAuthAdvancedOptions = {
5433
5479
  */
5434
5480
  disableIpTracking?: boolean;
5435
5481
  /**
5436
- * IPv6 subnet prefix length for rate limiting.
5437
- * IPv6 addresses will be normalized to this subnet.
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).
5438
5485
  *
5439
5486
  * @default 64
5440
5487
  */
5441
- ipv6Subnet?: 128 | 64 | 48 | 32;
5488
+ ipv6Subnet?: number;
5442
5489
  } | undefined;
5443
5490
  /**
5444
5491
  * Force cookies to always use the `Secure` attribute. By default,
@@ -6187,6 +6234,25 @@ type BetterAuthOptions = {
6187
6234
  * @default false
6188
6235
  */
6189
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;
6190
6256
  /**
6191
6257
  * List of trusted providers. Can be a static array or a function
6192
6258
  * that returns providers dynamically. The function is called
@@ -6766,6 +6832,18 @@ interface SecondaryStorage {
6766
6832
  * @returns - Value of the key
6767
6833
  */
6768
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>;
6769
6847
  set: (
6770
6848
  /**
6771
6849
  * Key to store
package/dist/proxy.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as PACKAGE_VERSION } from "./version-Bwp02oze.mjs";
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
@@ -1,5 +1,5 @@
1
1
  //#endregion
2
2
  //#region src/version.ts
3
- const PACKAGE_VERSION = "1.6.10";
3
+ const PACKAGE_VERSION = "1.6.11";
4
4
  //#endregion
5
5
  export { PACKAGE_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/electron",
3
- "version": "1.6.10",
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.10",
84
- "better-auth": "1.6.10"
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.10",
93
- "better-auth": "^1.6.10"
92
+ "@better-auth/core": "^1.6.11",
93
+ "better-auth": "^1.6.11"
94
94
  },
95
95
  "peerDependenciesMeta": {
96
96
  "electron": {