@finueva/auth 0.32.0 → 0.34.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/index.js CHANGED
@@ -61,27 +61,149 @@ const messages = {
61
61
  organization_closure_confirmation_mismatch: "The confirmation does not match the organization.",
62
62
  organization_closure_cancellation_ended: "The closure cancellation period has ended.",
63
63
  ceremony_return_refused: "The return address is not registered for this application.",
64
- password_sign_in_required: "A password sign-in method is required for this passkey change."
64
+ password_sign_in_required: "A password sign-in method is required for this passkey change.",
65
+ account_deletion_pending: "This account is scheduled for deletion.",
66
+ account_restore_unavailable: "The restore ticket or link is used or expired, or the account is not scheduled for deletion."
65
67
  };
66
68
  var AuthError = class extends Error {
67
69
  code;
68
70
  status;
69
71
  retryAfterSeconds;
70
- constructor(code, status, retryAfterSeconds) {
72
+ accountDeletion;
73
+ constructor(code, status, retryAfterSeconds, details) {
71
74
  super(messages[code]);
72
75
  this.name = "AuthError";
73
76
  this.code = code;
74
77
  this.status = status;
75
78
  this.retryAfterSeconds = retryAfterSeconds;
79
+ if (details?.accountDeletion) this.accountDeletion = details.accountDeletion;
76
80
  }
77
81
  };
78
82
  //#endregion
83
+ //#region src/account-deletion.ts
84
+ function isObject$1(value) {
85
+ return typeof value === "object" && value !== null && !Array.isArray(value);
86
+ }
87
+ function authorityUnavailable$1() {
88
+ return new AuthError("identity_authority_unavailable", 503);
89
+ }
90
+ const idPattern$3 = /^[A-Za-z0-9_-]{1,128}$(?![\s\S])/;
91
+ const tokenPattern = /^[A-Za-z0-9_-]{43}$(?![\s\S])/;
92
+ const idempotencyPattern = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$(?![\s\S])/;
93
+ const MAX_SOLE_ORGANIZATIONS = 20;
94
+ const MAX_BLOCKING_ORGANIZATIONS = 100;
95
+ const organizationBlockers = new Set(["owner_with_members", "enterprise_connection"]);
96
+ const accountBlockers = new Set(["managed_account", "platform_role"]);
97
+ const stepUps = new Set([
98
+ "recent_sign_in",
99
+ "password",
100
+ "sign_in_again"
101
+ ]);
102
+ function exact$5(value, keys) {
103
+ return isObject$1(value) && Object.keys(value).length === keys.length && keys.every((key) => {
104
+ return Object.hasOwn(value, key);
105
+ });
106
+ }
107
+ function isoDate(value) {
108
+ if (typeof value !== "string") throw authorityUnavailable$1();
109
+ const parsed = new Date(value);
110
+ if (!Number.isFinite(parsed.getTime()) || parsed.toISOString() !== value) throw authorityUnavailable$1();
111
+ return parsed;
112
+ }
113
+ function organization(value, keys) {
114
+ if (!exact$5(value, keys) || typeof value.id !== "string" || !idPattern$3.test(value.id) || typeof value.name !== "string" || value.name.length === 0 || value.name.length > 255 || value.slug !== null && (typeof value.slug !== "string" || value.slug.length === 0 || value.slug.length > 255)) throw authorityUnavailable$1();
115
+ return {
116
+ id: value.id,
117
+ name: value.name,
118
+ slug: value.slug
119
+ };
120
+ }
121
+ function normalizeAccountDeletionStartRequest(value) {
122
+ if (!isObject$1(value) || typeof value.idempotencyKey !== "string" || !idempotencyPattern.test(value.idempotencyKey)) throw new TypeError("idempotencyKey is invalid");
123
+ const ids = value.soleOrganizationIds;
124
+ if (!Array.isArray(ids) || ids.length > MAX_SOLE_ORGANIZATIONS || !ids.every((id) => {
125
+ return typeof id === "string" && idPattern$3.test(id);
126
+ })) throw new TypeError("soleOrganizationIds is invalid");
127
+ return {
128
+ idempotencyKey: value.idempotencyKey,
129
+ soleOrganizationIds: [...ids]
130
+ };
131
+ }
132
+ function normalizeAccountDeletionEligibility(value) {
133
+ if (!exact$5(value, [
134
+ "accountBlocker",
135
+ "blockingOrganizations",
136
+ "deleteAfter",
137
+ "eligible",
138
+ "soleOrganizations",
139
+ "stepUp"
140
+ ]) || typeof value.eligible !== "boolean" || value.accountBlocker !== null && !accountBlockers.has(value.accountBlocker) || !Array.isArray(value.blockingOrganizations) || value.blockingOrganizations.length > MAX_BLOCKING_ORGANIZATIONS || !Array.isArray(value.soleOrganizations) || value.soleOrganizations.length > MAX_SOLE_ORGANIZATIONS || !stepUps.has(value.stepUp)) throw authorityUnavailable$1();
141
+ const blockingOrganizations = value.blockingOrganizations.map((entry) => {
142
+ const summary = organization(entry, [
143
+ "id",
144
+ "name",
145
+ "reason",
146
+ "slug"
147
+ ]);
148
+ const reason = entry.reason;
149
+ if (!organizationBlockers.has(reason)) throw authorityUnavailable$1();
150
+ return {
151
+ ...summary,
152
+ reason
153
+ };
154
+ });
155
+ return {
156
+ eligible: value.eligible,
157
+ accountBlocker: value.accountBlocker,
158
+ blockingOrganizations,
159
+ soleOrganizations: value.soleOrganizations.map((entry) => {
160
+ return organization(entry, [
161
+ "id",
162
+ "name",
163
+ "slug"
164
+ ]);
165
+ }),
166
+ stepUp: value.stepUp,
167
+ deleteAfter: isoDate(value.deleteAfter)
168
+ };
169
+ }
170
+ function normalizeAccountDeletionRestoreInput(value) {
171
+ if (exact$5(value, ["restoreTicket"]) && typeof value.restoreTicket === "string" && tokenPattern.test(value.restoreTicket)) return { restoreTicket: value.restoreTicket };
172
+ if (exact$5(value, ["restoreLinkToken"]) && typeof value.restoreLinkToken === "string" && tokenPattern.test(value.restoreLinkToken)) return { restoreLinkToken: value.restoreLinkToken };
173
+ throw new TypeError("restore input is invalid");
174
+ }
175
+ function normalizeAccountDeletionRestore(value) {
176
+ if (!exact$5(value, ["status"]) || value.status !== "restored") throw authorityUnavailable$1();
177
+ }
178
+ function accountDeletionPending(value, status) {
179
+ if (status !== 403 || !isObject$1(value) || value.code !== "ACCOUNT_DELETION_PENDING") return null;
180
+ let deleteAfter;
181
+ try {
182
+ deleteAfter = isoDate(value.deleteAfter);
183
+ } catch {
184
+ return null;
185
+ }
186
+ const restoreTicket = typeof value.restoreTicket === "string" && tokenPattern.test(value.restoreTicket) ? value.restoreTicket : null;
187
+ return {
188
+ deleteAfter,
189
+ restoreTicket
190
+ };
191
+ }
192
+ function fromAccountDeletionError(value, status) {
193
+ const code = isObject$1(value) ? value.code : void 0;
194
+ if (status === 401) return new AuthError("authentication_required", 401);
195
+ if (status === 403) return new AuthError("request_origin_denied", 403);
196
+ if (status === 404 && code === "RESTORE_UNAVAILABLE") return new AuthError("account_restore_unavailable", 404);
197
+ if (status === 400 || status === 413 || status === 415) return new AuthError("invalid_request", 400);
198
+ return authorityUnavailable$1();
199
+ }
200
+ //#endregion
79
201
  //#region src/shared.ts
80
202
  const DRIVE_CREDENTIAL_LIFETIME_SECONDS = 840;
81
203
  const id = /^[A-Za-z0-9_-]{1,128}$/;
82
204
  const email = /^[^\s@]+@[^\s@]+$/;
83
205
  const passwordResetToken = /^[A-Za-z0-9_-]{1,512}$/;
84
- const MAX_SOCIAL_ID_TOKEN_BYTES = 16 * 1024;
206
+ const MAX_SOCIAL_ID_TOKEN_BYTES = 16384;
85
207
  function normalizeEmail(value) {
86
208
  if (typeof value !== "string") throw new TypeError("email is invalid");
87
209
  const normalized = value.trim().toLowerCase();
@@ -95,7 +217,9 @@ function normalizePassword(value, name = "password", minLength = 8) {
95
217
  function normalizeSocialIdTokenInput(value) {
96
218
  if (!isObject(value)) throw new TypeError("social ID token input is invalid");
97
219
  const keys = Object.keys(value);
98
- if (keys.length !== 3 && keys.length !== 4 || keys.some((key) => key !== "provider" && key !== "idToken" && key !== "nonce" && key !== "signUp") || value.provider !== "google" && value.provider !== "apple" || typeof value.signUp !== "boolean" || typeof value.idToken !== "string" || value.idToken.length < 1 || new TextEncoder().encode(value.idToken).byteLength > MAX_SOCIAL_ID_TOKEN_BYTES || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.idToken) || value.nonce !== void 0 && (typeof value.nonce !== "string" || value.nonce.length < 1 || value.nonce.length > 256 || !/^[\x20-\x7e]+$/.test(value.nonce))) throw new TypeError("social ID token input is invalid");
220
+ if (keys.length !== 3 && keys.length !== 4 || keys.some((key) => {
221
+ return key !== "provider" && key !== "idToken" && key !== "nonce" && key !== "signUp";
222
+ }) || value.provider !== "google" && value.provider !== "apple" || typeof value.signUp !== "boolean" || typeof value.idToken !== "string" || value.idToken.length < 1 || new TextEncoder().encode(value.idToken).byteLength > MAX_SOCIAL_ID_TOKEN_BYTES || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.idToken) || value.nonce !== void 0 && (typeof value.nonce !== "string" || value.nonce.length < 1 || value.nonce.length > 256 || !/^[\x20-\x7e]+$/.test(value.nonce))) throw new TypeError("social ID token input is invalid");
99
223
  return {
100
224
  provider: value.provider,
101
225
  idToken: value.idToken,
@@ -122,7 +246,9 @@ function normalizeName(value) {
122
246
  function normalizeProfileInput(value) {
123
247
  if (!isObject(value)) throw new TypeError("profile input is invalid");
124
248
  const keys = Object.keys(value);
125
- if (keys.length === 0 || keys.length > 2 || keys.some((key) => key !== "name" && key !== "image") || value.name === void 0 && value.image === void 0) throw new TypeError("profile input is invalid");
249
+ if (keys.length === 0 || keys.length > 2 || keys.some((key) => {
250
+ return key !== "name" && key !== "image";
251
+ }) || value.name === void 0 && value.image === void 0) throw new TypeError("profile input is invalid");
126
252
  const result = {};
127
253
  if (value.name !== void 0) result.name = normalizeName(value.name);
128
254
  if (value.image !== void 0) result.image = value.image === null ? null : normalizeProfileImage(value.image);
@@ -143,7 +269,15 @@ function normalizeSameAppURL(value, appOrigin, name) {
143
269
  if (url.origin !== appOrigin || url.username || url.password || url.toString() !== value) throw new TypeError(`${name} must belong to appOrigin`);
144
270
  return value;
145
271
  }
146
- function normalizeOrigin(value, name) {
272
+ function isPrivateIpv4(hostname) {
273
+ const parts = hostname.split(".").map(Number);
274
+ if (parts.length !== 4 || parts.some((part) => {
275
+ return !Number.isInteger(part) || part < 0 || part > 255;
276
+ })) return false;
277
+ const [first, second] = parts;
278
+ return first === 10 || first === 172 && second >= 16 && second <= 31 || first === 192 && second === 168;
279
+ }
280
+ function normalizeOrigin(value, name, allowPrivateNetwork = false) {
147
281
  if (value.length === 0 || value.length > 2048 || /[^\x20-\x7e]/.test(value)) throw new TypeError(`${name} must be an ASCII HTTP origin`);
148
282
  let url;
149
283
  try {
@@ -152,7 +286,7 @@ function normalizeOrigin(value, name) {
152
286
  throw new TypeError(`${name} must be an ASCII HTTP origin`);
153
287
  }
154
288
  const local = url.hostname === "localhost" || url.hostname.endsWith(".localhost") || url.hostname === "127.0.0.1";
155
- if (url.protocol !== "https:" && !(local && url.protocol === "http:") || url.username || url.password || url.pathname !== "/" || url.search || url.hash || url.origin !== value) throw new TypeError(`${name} must be an ASCII HTTP origin`);
289
+ if (url.protocol !== "https:" && !((local || allowPrivateNetwork && isPrivateIpv4(url.hostname)) && url.protocol === "http:") || url.username || url.password || url.pathname !== "/" || url.search || url.hash || url.origin !== value) throw new TypeError(`${name} must be an ASCII HTTP origin`);
156
290
  return url.origin;
157
291
  }
158
292
  function normalizeTimeout(value) {
@@ -179,7 +313,7 @@ function normalizeSession(value) {
179
313
  };
180
314
  }
181
315
  function normalizeDriveCredential(value, now) {
182
- if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || new TextEncoder().encode(`Bearer ${value.token}`).byteLength > 16 * 1024) throw authorityUnavailable();
316
+ if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || new TextEncoder().encode(`Bearer ${value.token}`).byteLength > 16384) throw authorityUnavailable();
183
317
  return {
184
318
  tokenType: "Bearer",
185
319
  token: value.token,
@@ -188,7 +322,9 @@ function normalizeDriveCredential(value, now) {
188
322
  }
189
323
  function normalizeOrganizationPageInput(value) {
190
324
  if (value === void 0) return new URLSearchParams();
191
- if (!isObject(value) || Object.keys(value).some((key) => key !== "limit" && key !== "cursor")) throw new AuthError("invalid_request", 400);
325
+ if (!isObject(value) || Object.keys(value).some((key) => {
326
+ return key !== "limit" && key !== "cursor";
327
+ })) throw new AuthError("invalid_request", 400);
192
328
  const input = value;
193
329
  const query = new URLSearchParams();
194
330
  if (input.limit !== void 0) {
@@ -203,17 +339,23 @@ function normalizeOrganizationPageInput(value) {
203
339
  }
204
340
  function normalizeOrganizationMemberPageInput(value) {
205
341
  if (value === void 0) return new URLSearchParams();
206
- if (!isObject(value) || Object.keys(value).some((key) => ![
207
- "limit",
208
- "cursor",
209
- "search"
210
- ].includes(key))) throw new AuthError("invalid_request", 400);
342
+ if (!isObject(value) || Object.keys(value).some((key) => {
343
+ return ![
344
+ "limit",
345
+ "cursor",
346
+ "search"
347
+ ].includes(key);
348
+ })) throw new AuthError("invalid_request", 400);
211
349
  const { search, ...page } = value;
212
350
  const query = normalizeOrganizationPageInput(page);
213
351
  if (search !== void 0) {
214
352
  if (typeof search !== "string") throw new AuthError("invalid_request", 400);
215
- const prefix = search.trim().replace(/[A-Z]/g, (character) => character.toLowerCase());
216
- if (!prefix || prefix.length > 128 || Array.from(prefix).some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) throw new AuthError("invalid_request", 400);
353
+ const prefix = search.trim().replace(/[A-Z]/g, (character) => {
354
+ return character.toLowerCase();
355
+ });
356
+ if (!prefix || prefix.length > 128 || Array.from(prefix).some((character) => {
357
+ return character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127;
358
+ })) throw new AuthError("invalid_request", 400);
217
359
  query.set("search", prefix);
218
360
  }
219
361
  return query;
@@ -333,7 +475,9 @@ function normalizeOrganizationMemberInvitationCreationInput(value) {
333
475
  throw new AuthError("invalid_request", 400);
334
476
  }
335
477
  if (new TextEncoder().encode(normalizedEmail).byteLength > 320 || !boundedString(value.idempotencyKey, 255) || value.teamIds !== void 0 && (!Array.isArray(value.teamIds) || value.teamIds.length > 100)) throw new AuthError("invalid_request", 400);
336
- const teamIds = value.teamIds?.map((teamId) => normalizeIdInput(teamId));
478
+ const teamIds = value.teamIds?.map((teamId) => {
479
+ return normalizeIdInput(teamId);
480
+ });
337
481
  if (teamIds && new Set(teamIds).size !== teamIds.length) throw new AuthError("invalid_request", 400);
338
482
  return {
339
483
  email: normalizedEmail,
@@ -409,10 +553,16 @@ function normalizeSuspendedOrganizationMembers(value) {
409
553
  email: member.email,
410
554
  image: nullableHttpsUrl(member.image),
411
555
  role: member.role,
412
- teamIds: unique(member.teamIds.map((teamId) => normalizeResponseId(teamId)), (item) => item),
556
+ teamIds: unique(member.teamIds.map((teamId) => {
557
+ return normalizeResponseId(teamId);
558
+ }), (item) => {
559
+ return item;
560
+ }),
413
561
  suspendedAt: responseDate(member.suspendedAt)
414
562
  };
415
- }), (item) => item.id),
563
+ }), (item) => {
564
+ return item.id;
565
+ }),
416
566
  nextCursor: nullableCursor(value.nextCursor)
417
567
  };
418
568
  }
@@ -438,7 +588,9 @@ function normalizeDepartedOrganizationMembers(value) {
438
588
  departure: member.departure,
439
589
  departedAt: responseDate(member.departedAt)
440
590
  };
441
- }), (item) => item.userId),
591
+ }), (item) => {
592
+ return item.userId;
593
+ }),
442
594
  nextCursor: nullableCursor(value.nextCursor)
443
595
  };
444
596
  }
@@ -470,7 +622,9 @@ function normalizeOrganizations(value) {
470
622
  exact$4(value, ["nextCursor", "organizations"]);
471
623
  if (!Array.isArray(value.organizations) || value.organizations.length > 100) throw authorityUnavailable();
472
624
  return {
473
- organizations: unique(value.organizations.map(normalizeOrganization), (item) => item.id),
625
+ organizations: unique(value.organizations.map(normalizeOrganization), (item) => {
626
+ return item.id;
627
+ }),
474
628
  nextCursor: nullableCursor(value.nextCursor)
475
629
  };
476
630
  }
@@ -491,7 +645,11 @@ function normalizeOrganizationMembers(value) {
491
645
  "userId"
492
646
  ]);
493
647
  if (!isId(member.id) || !isId(member.userId) || !boundedString(member.name, 255) || typeof member.email !== "string" || member.email.length > 320 || !email.test(member.email) || !role(member.role) || typeof member.owner !== "boolean" || !Array.isArray(member.teamIds) || member.teamIds.length > 100) throw authorityUnavailable();
494
- const teamIds = unique(member.teamIds.map((teamId) => normalizeResponseId(teamId)), (item) => item);
648
+ const teamIds = unique(member.teamIds.map((teamId) => {
649
+ return normalizeResponseId(teamId);
650
+ }), (item) => {
651
+ return item;
652
+ });
495
653
  return {
496
654
  id: member.id,
497
655
  userId: member.userId,
@@ -503,7 +661,9 @@ function normalizeOrganizationMembers(value) {
503
661
  joinedAt: responseDate(member.joinedAt),
504
662
  teamIds
505
663
  };
506
- }), (item) => item.id),
664
+ }), (item) => {
665
+ return item.id;
666
+ }),
507
667
  nextCursor: nullableCursor(value.nextCursor)
508
668
  };
509
669
  }
@@ -525,7 +685,9 @@ function normalizeOrganizationTeams(value) {
525
685
  category: team.category,
526
686
  createdAt: responseDate(team.createdAt)
527
687
  };
528
- }), (item) => item.id),
688
+ }), (item) => {
689
+ return item.id;
690
+ }),
529
691
  nextCursor: nullableCursor(value.nextCursor)
530
692
  };
531
693
  }
@@ -533,7 +695,11 @@ function normalizeOrganizationTeamMembers(value) {
533
695
  exact$4(value, ["memberIds", "nextCursor"]);
534
696
  if (!Array.isArray(value.memberIds) || value.memberIds.length > 100) throw authorityUnavailable();
535
697
  return {
536
- memberIds: unique(value.memberIds.map((item) => normalizeResponseId(item)), (item) => item),
698
+ memberIds: unique(value.memberIds.map((item) => {
699
+ return normalizeResponseId(item);
700
+ }), (item) => {
701
+ return item;
702
+ }),
537
703
  nextCursor: nullableCursor(value.nextCursor)
538
704
  };
539
705
  }
@@ -555,7 +721,9 @@ function normalizeOrganizationInvitation(value) {
555
721
  id: value.id,
556
722
  email: value.email,
557
723
  role: value.role,
558
- teamIds: unique(value.teamIds.map(normalizeResponseId), (item) => item),
724
+ teamIds: unique(value.teamIds.map(normalizeResponseId), (item) => {
725
+ return item;
726
+ }),
559
727
  inviter: {
560
728
  membershipId: value.inviter.membershipId,
561
729
  name: value.inviter.name
@@ -569,7 +737,9 @@ function normalizeOrganizationInvitations(value) {
569
737
  exact$4(value, ["invitations", "nextCursor"]);
570
738
  if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
571
739
  return {
572
- invitations: unique(value.invitations.map(normalizeOrganizationInvitation), (item) => item.id),
740
+ invitations: unique(value.invitations.map(normalizeOrganizationInvitation), (item) => {
741
+ return item.id;
742
+ }),
573
743
  nextCursor: nullableCursor(value.nextCursor)
574
744
  };
575
745
  }
@@ -606,7 +776,9 @@ function normalizeReceivedInvitation(value) {
606
776
  id: team.id,
607
777
  name: team.name
608
778
  };
609
- }), (item) => item.id),
779
+ }), (item) => {
780
+ return item.id;
781
+ }),
610
782
  inviterName: value.inviterName,
611
783
  expiresAt: responseDate(value.expiresAt)
612
784
  };
@@ -615,7 +787,9 @@ function normalizeReceivedInvitations(value) {
615
787
  exact$4(value, ["invitations", "nextCursor"]);
616
788
  if (!Array.isArray(value.invitations) || value.invitations.length > 100) throw authorityUnavailable();
617
789
  return {
618
- invitations: unique(value.invitations.map(normalizeReceivedInvitation), (item) => item.id),
790
+ invitations: unique(value.invitations.map(normalizeReceivedInvitation), (item) => {
791
+ return item.id;
792
+ }),
619
793
  nextCursor: nullableCursor(value.nextCursor)
620
794
  };
621
795
  }
@@ -661,6 +835,8 @@ function fromAuthorityError(value, fallbackStatus, retryAfter) {
661
835
  }
662
836
  function fromAccountAuthorityError(value, status, retryAfter) {
663
837
  const code = isObject(value) && typeof value.code === "string" ? value.code : void 0;
838
+ const pendingDeletion = accountDeletionPending(value, status);
839
+ if (pendingDeletion) return new AuthError("account_deletion_pending", 403, void 0, { accountDeletion: pendingDeletion });
664
840
  if (status === 403 && (code === "INVALID_ORIGIN" || code === "MISSING_OR_NULL_ORIGIN")) return new AuthError("request_origin_denied", 403);
665
841
  if (code === "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL") return new AuthError("account_conflict", 409);
666
842
  if (code === "INVALID_TOKEN") return new AuthError("password_reset_invalid", 422);
@@ -737,7 +913,7 @@ function normalizeOrganizationClosureCancelInput(value) {
737
913
  function closureWindow(value) {
738
914
  const startedAt = responseDate(value.startedAt);
739
915
  const cancelUntil = responseDate(value.cancelUntil);
740
- if (cancelUntil.getTime() - startedAt.getTime() !== 720 * 60 * 60 * 1e3 || typeof value.canCancel !== "boolean") throw authorityUnavailable();
916
+ if (cancelUntil.getTime() - startedAt.getTime() !== 2592e6 || typeof value.canCancel !== "boolean") throw authorityUnavailable();
741
917
  return {
742
918
  startedAt: startedAt.toISOString(),
743
919
  cancelUntil: cancelUntil.toISOString(),
@@ -780,12 +956,16 @@ function normalizeClosingOrganizations(value) {
780
956
  slug: item.slug,
781
957
  ...closureWindow(item)
782
958
  };
783
- }), (item) => item.id) };
959
+ }), (item) => {
960
+ return item.id;
961
+ }) };
784
962
  }
785
963
  function normalizePlatformRoleChangeRecentAuthenticationInput(value) {
786
964
  if (!isObject(value) || Object.keys(value).sort().join(",") !== "changeReference,expectedGlobalRevision,expectedTargetRevision,idempotencyKey,reasonCategory,requestedRoles,targetUserId") throw new TypeError("recent authentication input is invalid");
787
965
  if (!isId(value.targetUserId)) throw new TypeError("targetUserId is invalid");
788
- if (!Array.isArray(value.requestedRoles) || value.requestedRoles.length < 1 || value.requestedRoles.length > 2 || value.requestedRoles.some((role) => role !== "administrator" && role !== "investigator") || new Set(value.requestedRoles).size !== value.requestedRoles.length) throw new TypeError("requestedRoles is invalid");
966
+ if (!Array.isArray(value.requestedRoles) || value.requestedRoles.length < 1 || value.requestedRoles.length > 2 || value.requestedRoles.some((role) => {
967
+ return role !== "administrator" && role !== "investigator";
968
+ }) || new Set(value.requestedRoles).size !== value.requestedRoles.length) throw new TypeError("requestedRoles is invalid");
789
969
  for (const field of ["expectedTargetRevision", "expectedGlobalRevision"]) if (!Number.isSafeInteger(value[field]) || value[field] < 0 || value[field] >= Number.MAX_SAFE_INTEGER) throw new TypeError(`${field} is invalid`);
790
970
  if (!(typeof value.reasonCategory === "string" && [
791
971
  "initial_bootstrap",
@@ -1081,7 +1261,7 @@ function mapError(code, status) {
1081
1261
  };
1082
1262
  }
1083
1263
  function parseRetryAfter(value) {
1084
- if (!value || !/^\d+$/.test(value)) return void 0;
1264
+ if (!value || !/^\d+$/.test(value)) return;
1085
1265
  const seconds = Number(value);
1086
1266
  return Number.isSafeInteger(seconds) && seconds >= 1 && seconds <= 3600 ? seconds : void 0;
1087
1267
  }
@@ -1146,7 +1326,7 @@ function unique(items, key) {
1146
1326
  }
1147
1327
  function credentialSessionId(token) {
1148
1328
  const parts = token.split(".");
1149
- if (parts.length !== 3 || !/^[A-Za-z0-9_-]+$/.test(parts[1])) return void 0;
1329
+ if (parts.length !== 3 || !/^[A-Za-z0-9_-]+$/.test(parts[1])) return;
1150
1330
  try {
1151
1331
  const base64 = parts[1].replaceAll("-", "+").replaceAll("_", "/");
1152
1332
  const decoded = atob(base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "="));
@@ -1165,7 +1345,9 @@ function record(value) {
1165
1345
  return value !== null && typeof value === "object" && !Array.isArray(value);
1166
1346
  }
1167
1347
  function exact$3(value, keys) {
1168
- return record(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
1348
+ return record(value) && Object.keys(value).length === keys.length && keys.every((key) => {
1349
+ return Object.hasOwn(value, key);
1350
+ });
1169
1351
  }
1170
1352
  function directoryId(value) {
1171
1353
  return typeof value === "string" && /^[A-Za-z0-9_-]{1,128}$(?![\s\S])/.test(value);
@@ -1230,7 +1412,7 @@ function normalizeRegisteredOrganizationApplication(value, organizationId, appli
1230
1412
  };
1231
1413
  }
1232
1414
  //#endregion
1233
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/broadcast-channel.mjs
1415
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/broadcast-channel.mjs
1234
1416
  const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
1235
1417
  const now$1 = () => Math.floor(Date.now() / 1e3);
1236
1418
  var WindowBroadcastChannel = class {
@@ -1437,7 +1619,7 @@ let onMount = ($store, initialize) => {
1437
1619
  });
1438
1620
  };
1439
1621
  //#endregion
1440
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/equality.mjs
1622
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/equality.mjs
1441
1623
  function isPlainObject$1(value) {
1442
1624
  if (typeof value !== "object" || value === null) return false;
1443
1625
  const prototype = Object.getPrototypeOf(value);
@@ -1465,7 +1647,7 @@ function withEquality(store, isEqual) {
1465
1647
  });
1466
1648
  }
1467
1649
  //#endregion
1468
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/focus-manager.mjs
1650
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/focus-manager.mjs
1469
1651
  const kFocusManager = Symbol.for("better-auth:focus-manager");
1470
1652
  var WindowFocusManager = class {
1471
1653
  listeners = new Set();
@@ -1494,7 +1676,7 @@ function getGlobalFocusManager() {
1494
1676
  return globalThis[kFocusManager];
1495
1677
  }
1496
1678
  //#endregion
1497
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/online-manager.mjs
1679
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/online-manager.mjs
1498
1680
  const kOnlineManager = Symbol.for("better-auth:online-manager");
1499
1681
  var WindowOnlineManager = class {
1500
1682
  listeners = new Set();
@@ -1526,7 +1708,7 @@ function getGlobalOnlineManager() {
1526
1708
  return globalThis[kOnlineManager];
1527
1709
  }
1528
1710
  //#endregion
1529
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/parser.mjs
1711
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/parser.mjs
1530
1712
  const PROTO_POLLUTION_PATTERNS = {
1531
1713
  proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
1532
1714
  constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
@@ -1595,7 +1777,7 @@ function parseJSON(value, options = { strict: true }) {
1595
1777
  return betterJSONParse(value, options);
1596
1778
  }
1597
1779
  //#endregion
1598
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/query.mjs
1780
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/query.mjs
1599
1781
  const isServer$1 = () => typeof window === "undefined";
1600
1782
  function isAuthQueryStateEqual(a, b) {
1601
1783
  return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
@@ -1698,7 +1880,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
1698
1880
  return value;
1699
1881
  };
1700
1882
  //#endregion
1701
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/session-refresh.mjs
1883
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/session-refresh.mjs
1702
1884
  const now = () => Math.floor(Date.now() / 1e3);
1703
1885
  const FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
1704
1886
  function createSessionRefreshManager(opts) {
@@ -1822,7 +2004,7 @@ function createSessionRefreshManager(opts) {
1822
2004
  };
1823
2005
  }
1824
2006
  //#endregion
1825
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_17975d57218030f5a353914665f207d6/node_modules/@better-auth/core/dist/env/env-impl.mjs
2007
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_a77e2cbc2dff6985c9110d681072429e/node_modules/@better-auth/core/dist/env/env-impl.mjs
1826
2008
  const _envShim = Object.create(null);
1827
2009
  const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
1828
2010
  const env = new Proxy(_envShim, {
@@ -1879,7 +2061,7 @@ Object.freeze({
1879
2061
  }
1880
2062
  });
1881
2063
  //#endregion
1882
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_17975d57218030f5a353914665f207d6/node_modules/@better-auth/core/dist/utils/error-codes.mjs
2064
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_a77e2cbc2dff6985c9110d681072429e/node_modules/@better-auth/core/dist/utils/error-codes.mjs
1883
2065
  function defineErrorCodes(codes) {
1884
2066
  return Object.fromEntries(Object.entries(codes).map(([key, value]) => [key, {
1885
2067
  code: key,
@@ -1888,7 +2070,7 @@ function defineErrorCodes(codes) {
1888
2070
  }]));
1889
2071
  }
1890
2072
  //#endregion
1891
- //#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.4.3/node_modules/better-call/dist/error.mjs
2073
+ //#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.6.7/node_modules/better-call/dist/error.mjs
1892
2074
  function isErrorStackTraceLimitWritable() {
1893
2075
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
1894
2076
  if (desc === void 0) return Object.isExtensible(Error);
@@ -1994,7 +2176,7 @@ var InternalAPIError = class extends Error {
1994
2176
  };
1995
2177
  makeErrorForHideStackFrame(InternalAPIError, Error);
1996
2178
  //#endregion
1997
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_17975d57218030f5a353914665f207d6/node_modules/@better-auth/core/dist/error/index.mjs
2179
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_a77e2cbc2dff6985c9110d681072429e/node_modules/@better-auth/core/dist/error/index.mjs
1998
2180
  var BetterAuthError = class extends Error {
1999
2181
  constructor(message, options) {
2000
2182
  super(message, options);
@@ -2004,7 +2186,7 @@ var BetterAuthError = class extends Error {
2004
2186
  }
2005
2187
  };
2006
2188
  //#endregion
2007
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/utils/url.mjs
2189
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/utils/url.mjs
2008
2190
  const SLASH_CHAR_CODE = "/".charCodeAt(0);
2009
2191
  function trimTrailingSlashes(value) {
2010
2192
  let end = value.length;
@@ -2082,7 +2264,7 @@ function getOrigin(url) {
2082
2264
  }
2083
2265
  }
2084
2266
  //#endregion
2085
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_17975d57218030f5a353914665f207d6/node_modules/@better-auth/core/dist/utils/url.mjs
2267
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_a77e2cbc2dff6985c9110d681072429e/node_modules/@better-auth/core/dist/utils/url.mjs
2086
2268
  const DANGEROUS_URL_SCHEMES = [
2087
2269
  "javascript:",
2088
2270
  "data:",
@@ -2098,7 +2280,7 @@ function isSafeUrlScheme(value) {
2098
2280
  return !DANGEROUS_URL_SCHEMES.includes(parsed.protocol);
2099
2281
  }
2100
2282
  //#endregion
2101
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/fetch-plugins.mjs
2283
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/fetch-plugins.mjs
2102
2284
  const redirectPlugin = {
2103
2285
  id: "redirect",
2104
2286
  name: "Redirect",
@@ -2113,7 +2295,7 @@ const redirectPlugin = {
2113
2295
  } }
2114
2296
  };
2115
2297
  //#endregion
2116
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/session-atom.mjs
2298
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/session-atom.mjs
2117
2299
  const isServer = () => typeof window === "undefined";
2118
2300
  function normalizeSessionResponse(res) {
2119
2301
  if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
@@ -2652,13 +2834,15 @@ function getURL2(url, option) {
2652
2834
  queryParams.set(key, serializedValue);
2653
2835
  }
2654
2836
  const pathParams = new Map();
2655
- if (params) if (Array.isArray(params)) {
2656
- const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
2657
- for (const [index, key] of paramPaths.entries()) {
2658
- const value = params[index];
2659
- pathParams.set(key, String(value));
2660
- }
2661
- } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
2837
+ if (params) {
2838
+ if (Array.isArray(params)) {
2839
+ const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
2840
+ for (const [index, key] of paramPaths.entries()) {
2841
+ const value = params[index];
2842
+ pathParams.set(key, String(value));
2843
+ }
2844
+ } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
2845
+ }
2662
2846
  path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
2663
2847
  path = path.replace(/^\/+/, "");
2664
2848
  let queryParamString = queryParams.toString();
@@ -2761,7 +2945,7 @@ var betterFetch = async (url, options) => {
2761
2945
  };
2762
2946
  };
2763
2947
  //#endregion
2764
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/config.mjs
2948
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/config.mjs
2765
2949
  const resolvePublicAuthUrl = (basePath) => {
2766
2950
  if (typeof process === "undefined") return void 0;
2767
2951
  const path = basePath ?? "/api/auth";
@@ -2859,12 +3043,12 @@ const getClientConfig = (options, loadEnv) => {
2859
3043
  };
2860
3044
  };
2861
3045
  //#endregion
2862
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/utils/is-atom.mjs
3046
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/utils/is-atom.mjs
2863
3047
  function isAtom(value) {
2864
3048
  return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
2865
3049
  }
2866
3050
  //#endregion
2867
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_17975d57218030f5a353914665f207d6/node_modules/@better-auth/core/dist/utils/string.mjs
3051
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_better-call_a77e2cbc2dff6985c9110d681072429e/node_modules/@better-auth/core/dist/utils/string.mjs
2868
3052
  function capitalizeFirstLetter(str) {
2869
3053
  return str.charAt(0).toUpperCase() + str.slice(1);
2870
3054
  }
@@ -2877,7 +3061,7 @@ function toKebabCase(input) {
2877
3061
  return splitWords(input).map((word) => word.toLowerCase()).join("-");
2878
3062
  }
2879
3063
  //#endregion
2880
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/proxy.mjs
3064
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/proxy.mjs
2881
3065
  function getMethod(path, knownPathMethods, args) {
2882
3066
  const method = knownPathMethods[path];
2883
3067
  const { fetchOptions, query: _query, ...body } = args || {};
@@ -2946,7 +3130,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
2946
3130
  return createProxy();
2947
3131
  }
2948
3132
  //#endregion
2949
- //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/vanilla.mjs
3133
+ //#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.11_drizzle-orm@0.45.4_@libsql+client@0.17.4_kysely@_da7fa90773149f2e7e31ce000ac5bb37/node_modules/better-auth/dist/client/vanilla.mjs
2950
3134
  function createAuthClient$1(options) {
2951
3135
  const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
2952
3136
  const resolvedHooks = {};
@@ -2959,7 +3143,7 @@ function createAuthClient$1(options) {
2959
3143
  }, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
2960
3144
  }
2961
3145
  //#endregion
2962
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.22_@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-f_9dcb641568b0468b4b3f2fd37291240f/node_modules/@better-auth/passkey/dist/version-uW-pDlTC.mjs
3146
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.22_@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-f_8db206d544b09d03eee70498f68bff74/node_modules/@better-auth/passkey/dist/version-uW-pDlTC.mjs
2963
3147
  const PASSKEY_ERROR_CODES = defineErrorCodes({
2964
3148
  CHALLENGE_NOT_FOUND: "Challenge not found",
2965
3149
  YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: "You are not allowed to register this passkey",
@@ -3315,7 +3499,7 @@ async function startAuthentication(options) {
3315
3499
  };
3316
3500
  }
3317
3501
  //#endregion
3318
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.22_@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-f_9dcb641568b0468b4b3f2fd37291240f/node_modules/@better-auth/passkey/dist/client.mjs
3502
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.22_@better-auth+core@1.6.22_@better-auth+utils@0.4.2_@better-f_8db206d544b09d03eee70498f68bff74/node_modules/@better-auth/passkey/dist/client.mjs
3319
3503
  const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
3320
3504
  const signInPasskey = async (opts, options) => {
3321
3505
  const response = await $fetch("/passkey/generate-authenticate-options", {
@@ -3503,7 +3687,7 @@ const passkeyClient = () => {
3503
3687
  };
3504
3688
  };
3505
3689
  //#endregion
3506
- //#region ../../node_modules/.pnpm/@chiballc+utils@2.5.1_@hono+zod-openapi@1.5.1_hono@4.13.0_zod@4.4.3__hono@4.13.0_magic-_80fa16dd1813631ddeb36d2ee29b8660/node_modules/@chiballc/utils/dist/index.mjs
3690
+ //#region ../../node_modules/.pnpm/@chiballc+utils@2.5.1_@hono+zod-openapi@1.6.3_hono@4.13.14_zod@4.6.7__hono@4.13.14_magi_47a03f1f8de0b7557e1d609897e1fe54/node_modules/@chiballc/utils/dist/index.mjs
3507
3691
  function isPromise(arg) {
3508
3692
  return arg && typeof arg.then === "function";
3509
3693
  }
@@ -3876,8 +4060,10 @@ function mergeHeaders(input, defaults, Headers) {
3876
4060
  return headers;
3877
4061
  }
3878
4062
  async function callHooks(context, hooks) {
3879
- if (hooks) if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
3880
- else await hooks(context);
4063
+ if (hooks) {
4064
+ if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
4065
+ else await hooks(context);
4066
+ }
3881
4067
  }
3882
4068
  const retryStatusCodes = new Set([
3883
4069
  408,
@@ -4008,7 +4194,7 @@ function createFetch(globalOptions = {}) {
4008
4194
  }
4009
4195
  //#endregion
4010
4196
  //#region src/http.ts
4011
- const MAX_RESPONSE_BYTES = 64 * 1024;
4197
+ const MAX_RESPONSE_BYTES = 65536;
4012
4198
  async function requestJson(url, options) {
4013
4199
  return (await requestJsonResponse(url, options)).value;
4014
4200
  }
@@ -4034,7 +4220,7 @@ async function requestJsonResponse(url, options) {
4034
4220
  const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
4035
4221
  if (response.status >= 300 || response.status < 200 || contentType !== "application/json") {
4036
4222
  const body = contentType === "application/json" ? await readJson(response, options.maxResponseBytes, options.signal) : void 0;
4037
- response.body?.cancel().catch(() => void 0);
4223
+ response.body?.cancel().catch(() => {});
4038
4224
  throw (options.mapError ?? fromAuthorityError)(body, response.status, response.headers.get("retry-after"));
4039
4225
  }
4040
4226
  return {
@@ -4045,17 +4231,17 @@ async function requestJsonResponse(url, options) {
4045
4231
  async function readJson(response, maximum = MAX_RESPONSE_BYTES, signal) {
4046
4232
  const length = response.headers.get("content-length");
4047
4233
  if (length && (!/^\d+$/.test(length) || Number(length) > maximum)) {
4048
- response.body?.cancel().catch(() => void 0);
4234
+ response.body?.cancel().catch(() => {});
4049
4235
  throw authorityUnavailable();
4050
4236
  }
4051
4237
  if (!response.body) throw authorityUnavailable();
4052
4238
  if (signal?.aborted) {
4053
- response.body.cancel().catch(() => void 0);
4239
+ response.body.cancel().catch(() => {});
4054
4240
  throw authorityUnavailable();
4055
4241
  }
4056
4242
  const reader = response.body.getReader();
4057
4243
  const cancel = () => {
4058
- reader.cancel().catch(() => void 0);
4244
+ reader.cancel().catch(() => {});
4059
4245
  };
4060
4246
  signal?.addEventListener("abort", cancel, { once: true });
4061
4247
  const chunks = [];
@@ -4070,7 +4256,7 @@ async function readJson(response, maximum = MAX_RESPONSE_BYTES, signal) {
4070
4256
  chunks.push(value);
4071
4257
  }
4072
4258
  } catch (error) {
4073
- reader.cancel().catch(() => void 0);
4259
+ reader.cancel().catch(() => {});
4074
4260
  throw error;
4075
4261
  } finally {
4076
4262
  signal?.removeEventListener("abort", cancel);
@@ -4089,7 +4275,7 @@ async function readJson(response, maximum = MAX_RESPONSE_BYTES, signal) {
4089
4275
  }
4090
4276
  }
4091
4277
  //#endregion
4092
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs
4278
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/dist/shared/unstorage.lWbgcyKt.mjs
4093
4279
  function wrapToPromise(value) {
4094
4280
  if (!value || typeof value.then !== "function") return Promise.resolve(value);
4095
4281
  return value;
@@ -4137,6 +4323,9 @@ function normalizeKey$1(key) {
4137
4323
  if (!key) return "";
4138
4324
  return key.split("?")[0]?.replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || "";
4139
4325
  }
4326
+ function hasDotSegment(key) {
4327
+ return key.split(":").some((segment) => segment === "." || segment === "..");
4328
+ }
4140
4329
  function joinKeys(...keys) {
4141
4330
  return normalizeKey$1(keys.join(":"));
4142
4331
  }
@@ -4159,7 +4348,7 @@ function filterKeyByBase(key, base) {
4159
4348
  return key[key.length - 1] !== "$";
4160
4349
  }
4161
4350
  //#endregion
4162
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/dist/index.mjs
4351
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/dist/index.mjs
4163
4352
  function defineDriver$1(factory) {
4164
4353
  return factory;
4165
4354
  }
@@ -4206,6 +4395,16 @@ function createStorage(options = {}) {
4206
4395
  watchListeners: [],
4207
4396
  unwatch: {}
4208
4397
  };
4398
+ const normalizeItemKey = (key) => {
4399
+ const normalizedKey = normalizeKey$1(key);
4400
+ if (!normalizedKey || hasDotSegment(normalizedKey)) throw new Error(`[unstorage] Invalid key: ${JSON.stringify(key)}`);
4401
+ return normalizedKey;
4402
+ };
4403
+ const normalizeBase = (base) => {
4404
+ const normalizedBase = normalizeBaseKey(base);
4405
+ if (hasDotSegment(normalizedBase)) throw new Error(`[unstorage] Invalid base: ${JSON.stringify(base)}`);
4406
+ return normalizedBase;
4407
+ };
4209
4408
  const getMount = (key) => {
4210
4409
  for (const base of context.mountpoints) if (key.startsWith(base)) return {
4211
4410
  base,
@@ -4257,7 +4456,7 @@ function createStorage(options = {}) {
4257
4456
  };
4258
4457
  for (const item of items) {
4259
4458
  const isStringItem = typeof item === "string";
4260
- const key = normalizeKey$1(isStringItem ? item : item.key);
4459
+ const key = normalizeItemKey(isStringItem ? item : item.key);
4261
4460
  const value = isStringItem ? void 0 : item.value;
4262
4461
  const options2 = isStringItem || !item.options ? commonOptions : {
4263
4462
  ...commonOptions,
@@ -4274,17 +4473,17 @@ function createStorage(options = {}) {
4274
4473
  return Promise.all([...batches.values()].map((batch) => cb(batch))).then((r) => r.flat());
4275
4474
  };
4276
4475
  const storage = {
4277
- hasItem(key, opts = {}) {
4278
- key = normalizeKey$1(key);
4476
+ async hasItem(key, opts = {}) {
4477
+ key = normalizeItemKey(key);
4279
4478
  const { relativeKey, driver } = getMount(key);
4280
4479
  return asyncCall(driver.hasItem, relativeKey, opts);
4281
4480
  },
4282
- getItem(key, opts = {}) {
4283
- key = normalizeKey$1(key);
4481
+ async getItem(key, opts = {}) {
4482
+ key = normalizeItemKey(key);
4284
4483
  const { relativeKey, driver } = getMount(key);
4285
4484
  return asyncCall(driver.getItem, relativeKey, opts).then((value) => destr(value));
4286
4485
  },
4287
- getItems(items, commonOptions = {}) {
4486
+ async getItems(items, commonOptions = {}) {
4288
4487
  return runBatch(items, commonOptions, (batch) => {
4289
4488
  if (batch.driver.getItems) return asyncCall(batch.driver.getItems, batch.items.map((item) => ({
4290
4489
  key: item.relativeKey,
@@ -4301,15 +4500,15 @@ function createStorage(options = {}) {
4301
4500
  }));
4302
4501
  });
4303
4502
  },
4304
- getItemRaw(key, opts = {}) {
4305
- key = normalizeKey$1(key);
4503
+ async getItemRaw(key, opts = {}) {
4504
+ key = normalizeItemKey(key);
4306
4505
  const { relativeKey, driver } = getMount(key);
4307
4506
  if (driver.getItemRaw) return asyncCall(driver.getItemRaw, relativeKey, opts);
4308
4507
  return asyncCall(driver.getItem, relativeKey, opts).then((value) => deserializeRaw(value));
4309
4508
  },
4310
4509
  async setItem(key, value, opts = {}) {
4311
4510
  if (value === void 0) return storage.removeItem(key);
4312
- key = normalizeKey$1(key);
4511
+ key = normalizeItemKey(key);
4313
4512
  const { relativeKey, driver } = getMount(key);
4314
4513
  if (!driver.setItem) return;
4315
4514
  await asyncCall(driver.setItem, relativeKey, stringify(value), opts);
@@ -4330,7 +4529,7 @@ function createStorage(options = {}) {
4330
4529
  },
4331
4530
  async setItemRaw(key, value, opts = {}) {
4332
4531
  if (value === void 0) return storage.removeItem(key, opts);
4333
- key = normalizeKey$1(key);
4532
+ key = normalizeItemKey(key);
4334
4533
  const { relativeKey, driver } = getMount(key);
4335
4534
  if (driver.setItemRaw) await asyncCall(driver.setItemRaw, relativeKey, value, opts);
4336
4535
  else if (driver.setItem) await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts);
@@ -4339,7 +4538,7 @@ function createStorage(options = {}) {
4339
4538
  },
4340
4539
  async removeItem(key, opts = {}) {
4341
4540
  if (typeof opts === "boolean") opts = { removeMeta: opts };
4342
- key = normalizeKey$1(key);
4541
+ key = normalizeItemKey(key);
4343
4542
  const { relativeKey, driver } = getMount(key);
4344
4543
  if (!driver.removeItem) return;
4345
4544
  await asyncCall(driver.removeItem, relativeKey, opts);
@@ -4348,7 +4547,7 @@ function createStorage(options = {}) {
4348
4547
  },
4349
4548
  async getMeta(key, opts = {}) {
4350
4549
  if (typeof opts === "boolean") opts = { nativeOnly: opts };
4351
- key = normalizeKey$1(key);
4550
+ key = normalizeItemKey(key);
4352
4551
  const { relativeKey, driver } = getMount(key);
4353
4552
  const meta = Object.create(null);
4354
4553
  if (driver.getMeta) Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts));
@@ -4362,14 +4561,14 @@ function createStorage(options = {}) {
4362
4561
  }
4363
4562
  return meta;
4364
4563
  },
4365
- setMeta(key, value, opts = {}) {
4366
- return this.setItem(key + "$", value, opts);
4564
+ async setMeta(key, value, opts = {}) {
4565
+ return this.setItem(normalizeItemKey(key) + "$", value, opts);
4367
4566
  },
4368
- removeMeta(key, opts = {}) {
4369
- return this.removeItem(key + "$", opts);
4567
+ async removeMeta(key, opts = {}) {
4568
+ return this.removeItem(normalizeItemKey(key) + "$", opts);
4370
4569
  },
4371
4570
  async getKeys(base, opts = {}) {
4372
- base = normalizeBaseKey(base);
4571
+ base = normalizeBase(base);
4373
4572
  const mounts = getMounts(base, true);
4374
4573
  let maskedMounts = [];
4375
4574
  const allKeys = [];
@@ -4387,7 +4586,7 @@ function createStorage(options = {}) {
4387
4586
  return allKeys.filter((key) => (!shouldFilterByDepth || filterKeyByDepth(key, opts.maxDepth)) && filterKeyByBase(key, base));
4388
4587
  },
4389
4588
  async clear(base, opts = {}) {
4390
- base = normalizeBaseKey(base);
4589
+ base = normalizeBase(base);
4391
4590
  await Promise.all(getMounts(base, false).map(async (m) => {
4392
4591
  if (m.driver.clear) return asyncCall(m.driver.clear, m.relativeBase, opts);
4393
4592
  if (m.driver.removeItem) {
@@ -4412,7 +4611,7 @@ function createStorage(options = {}) {
4412
4611
  await stopWatch();
4413
4612
  },
4414
4613
  mount(base, driver) {
4415
- base = normalizeBaseKey(base);
4614
+ base = normalizeBase(base);
4416
4615
  if (base && context.mounts[base]) throw new Error(`already mounted at ${base}`);
4417
4616
  if (base) {
4418
4617
  context.mountpoints.push(base);
@@ -4466,7 +4665,7 @@ async function dispose(driver) {
4466
4665
  if (typeof driver.dispose === "function") await asyncCall(driver.dispose);
4467
4666
  }
4468
4667
  //#endregion
4469
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/utils/index.mjs
4668
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/drivers/utils/index.mjs
4470
4669
  function defineDriver(factory) {
4471
4670
  return factory;
4472
4671
  }
@@ -4485,7 +4684,7 @@ function createRequiredError(driver, name) {
4485
4684
  }
4486
4685
  var init_utils = __esmMin((() => {}));
4487
4686
  //#endregion
4488
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/memory.mjs
4687
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/drivers/memory.mjs
4489
4688
  var memory_exports = __exportAll({ default: () => memory_default });
4490
4689
  var DRIVER_NAME$2, memory_default;
4491
4690
  var init_memory = __esmMin((() => {
@@ -4527,7 +4726,7 @@ var init_memory = __esmMin((() => {
4527
4726
  });
4528
4727
  }));
4529
4728
  //#endregion
4530
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/localstorage.mjs
4729
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/drivers/localstorage.mjs
4531
4730
  var localstorage_exports = __exportAll({ default: () => localstorage_default });
4532
4731
  var DRIVER_NAME$1, localstorage_default;
4533
4732
  var init_localstorage = __esmMin((() => {
@@ -4584,7 +4783,7 @@ var init_localstorage = __esmMin((() => {
4584
4783
  });
4585
4784
  }));
4586
4785
  //#endregion
4587
- //#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/session-storage.mjs
4786
+ //#region ../../node_modules/.pnpm/unstorage@1.17.6/node_modules/unstorage/drivers/session-storage.mjs
4588
4787
  var session_storage_exports = __exportAll({ default: () => session_storage_default });
4589
4788
  var DRIVER_NAME, session_storage_default;
4590
4789
  var init_session_storage = __esmMin((() => {
@@ -4604,8 +4803,8 @@ var init_session_storage = __esmMin((() => {
4604
4803
  //#endregion
4605
4804
  //#region src/persistence.ts
4606
4805
  const KEY = "finueva-auth:session:v1";
4607
- const MAX_SNAPSHOT_BYTES = 16 * 1024;
4608
- const MAX_FUTURE_SKEW_MS = 300 * 1e3;
4806
+ const MAX_SNAPSHOT_BYTES = 16384;
4807
+ const MAX_FUTURE_SKEW_MS = 3e5;
4609
4808
  function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
4610
4809
  validatePersistence(persistence);
4611
4810
  const storageCache = {};
@@ -4630,7 +4829,9 @@ function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
4630
4829
  let timeout;
4631
4830
  try {
4632
4831
  await Promise.race([work, new Promise((_, reject) => {
4633
- timeout = setTimeout(() => reject(new Error("persistence timeout")), operationTimeoutMs);
4832
+ timeout = setTimeout(() => {
4833
+ return reject(new Error("persistence timeout"));
4834
+ }, operationTimeoutMs);
4634
4835
  })]);
4635
4836
  return true;
4636
4837
  } catch {
@@ -4643,12 +4844,16 @@ function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
4643
4844
  const operationGeneration = ++generation;
4644
4845
  queue = queue.then(async () => {
4645
4846
  if (!enabled || operationGeneration !== generation) return;
4646
- const isCurrent = () => enabled && operationGeneration === generation;
4647
- const work = Promise.resolve().then(() => operation(isCurrent));
4847
+ const isCurrent = () => {
4848
+ return enabled && operationGeneration === generation;
4849
+ };
4850
+ const work = Promise.resolve().then(() => {
4851
+ return operation(isCurrent);
4852
+ });
4648
4853
  if (!await finishesWithin(work)) {
4649
4854
  enabled = false;
4650
4855
  finishesWithin(cleanup());
4651
- work.then(cleanup, cleanup).then(() => void 0, () => void 0);
4856
+ work.then(cleanup, cleanup).then(() => {}, () => {});
4652
4857
  return;
4653
4858
  }
4654
4859
  if (!isCurrent() && !await finishesWithin(cleanup())) enabled = false;
@@ -4750,7 +4955,7 @@ async function selectDriver(persistence) {
4750
4955
  }
4751
4956
  function browserStorage(mode) {
4752
4957
  try {
4753
- if (typeof window === "undefined" || typeof document === "undefined") return void 0;
4958
+ if (typeof window === "undefined" || typeof document === "undefined") return;
4754
4959
  const storage = mode === "local" ? window.localStorage : window.sessionStorage;
4755
4960
  storage.getItem(KEY);
4756
4961
  return storage;
@@ -4762,11 +4967,21 @@ function adaptDriver(driver) {
4762
4967
  if (typeof driver.getItem !== "function" || typeof driver.setItem !== "function" || typeof driver.removeItem !== "function") throw new TypeError("persistence driver must implement getItem, setItem, and removeItem");
4763
4968
  return {
4764
4969
  name: "finueva-auth-custom",
4765
- hasItem: async (key) => await driver.getItem(key) !== null,
4766
- getItem: (key) => driver.getItem(key),
4767
- getKeys: () => [],
4768
- setItem: (key, value) => driver.setItem(key, value),
4769
- removeItem: (key) => driver.removeItem(key)
4970
+ hasItem: async (key) => {
4971
+ return await driver.getItem(key) !== null;
4972
+ },
4973
+ getItem: (key) => {
4974
+ return driver.getItem(key);
4975
+ },
4976
+ getKeys: () => {
4977
+ return [];
4978
+ },
4979
+ setItem: (key, value) => {
4980
+ return driver.setItem(key, value);
4981
+ },
4982
+ removeItem: (key) => {
4983
+ return driver.removeItem(key);
4984
+ }
4770
4985
  };
4771
4986
  }
4772
4987
  function guardRawValues(driver) {
@@ -4821,7 +5036,9 @@ function readSnapshot(value, authOrigin, currentTime) {
4821
5036
  function exactObject(value, fields) {
4822
5037
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
4823
5038
  const keys = Object.keys(value);
4824
- return keys.length === fields.length && fields.every((field) => keys.includes(field));
5039
+ return keys.length === fields.length && fields.every((field) => {
5040
+ return keys.includes(field);
5041
+ });
4825
5042
  }
4826
5043
  function byteLength(value) {
4827
5044
  return new TextEncoder().encode(value).byteLength;
@@ -4840,7 +5057,9 @@ const itemKeys$1 = [
4840
5057
  "userAgent"
4841
5058
  ];
4842
5059
  function exact$2(value, keys) {
4843
- return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
5060
+ return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => {
5061
+ return Object.hasOwn(value, key);
5062
+ });
4844
5063
  }
4845
5064
  function date$2(value) {
4846
5065
  if (typeof value !== "string") throw authorityUnavailable();
@@ -4873,8 +5092,12 @@ function normalizeSessionSummary(value) {
4873
5092
  function normalizeSessionInventory(value) {
4874
5093
  if (!exact$2(value, ["sessions", "truncated"]) || !Array.isArray(value.sessions) || value.sessions.length > MAX_SESSIONS || typeof value.truncated !== "boolean") throw authorityUnavailable();
4875
5094
  const sessions = value.sessions.map(normalizeSessionSummary);
4876
- if (new Set(sessions.map((session) => session.id)).size !== sessions.length) throw authorityUnavailable();
4877
- if (sessions.filter((session) => session.current).length !== 1) throw authorityUnavailable();
5095
+ if (new Set(sessions.map((session) => {
5096
+ return session.id;
5097
+ })).size !== sessions.length) throw authorityUnavailable();
5098
+ if (sessions.filter((session) => {
5099
+ return session.current;
5100
+ }).length !== 1) throw authorityUnavailable();
4878
5101
  return {
4879
5102
  sessions,
4880
5103
  truncated: value.truncated
@@ -4909,7 +5132,9 @@ const itemKeys = [
4909
5132
  "name"
4910
5133
  ];
4911
5134
  function exact$1(value, keys) {
4912
- return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
5135
+ return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => {
5136
+ return Object.hasOwn(value, key);
5137
+ });
4913
5138
  }
4914
5139
  function date$1(value) {
4915
5140
  if (typeof value !== "string") throw authorityUnavailable();
@@ -4982,6 +5207,11 @@ function normalizeCeremonyHandoffInput(value) {
4982
5207
  }
4983
5208
  throw new TypeError("request action is invalid");
4984
5209
  }
5210
+ case "user_closure": return {
5211
+ purpose: input.purpose,
5212
+ ...base,
5213
+ request: normalizeAccountDeletionStartRequest(input.request)
5214
+ };
4985
5215
  default: throw new TypeError("purpose is invalid");
4986
5216
  }
4987
5217
  }
@@ -5026,7 +5256,9 @@ function normalizePasskeySummary(value) {
5026
5256
  function normalizePasskeyInventory(value) {
5027
5257
  if (!exact$1(value, ["passkeys", "truncated"]) || !Array.isArray(value.passkeys) || value.passkeys.length > MAX_PASSKEYS || typeof value.truncated !== "boolean") throw authorityUnavailable();
5028
5258
  const passkeys = value.passkeys.map(normalizePasskeySummary);
5029
- if (new Set(passkeys.map((passkey) => passkey.id)).size !== passkeys.length) throw authorityUnavailable();
5259
+ if (new Set(passkeys.map((passkey) => {
5260
+ return passkey.id;
5261
+ })).size !== passkeys.length) throw authorityUnavailable();
5030
5262
  return {
5031
5263
  passkeys,
5032
5264
  truncated: value.truncated
@@ -5043,6 +5275,7 @@ function fromCeremonyHandoffError(value, status, retryAfter) {
5043
5275
  if (status === 403) return new AuthError("request_origin_denied", 403);
5044
5276
  if (status === 404) return new AuthError("state_conflict", 409);
5045
5277
  if (status === 409 && code === "PASSWORD_REQUIRED") return new AuthError("password_sign_in_required", 409);
5278
+ if (status === 409 && code === "RECENT_SIGN_IN_REQUIRED") return new AuthError("recent_sign_in_required", 409);
5046
5279
  if (status === 409) return new AuthError("state_conflict", 409);
5047
5280
  if (status === 429) return new AuthError("auth_request_rate_limited", 429, parseRetryAfter(retryAfter));
5048
5281
  return authorityUnavailable();
@@ -5086,7 +5319,9 @@ function isTwoFactorChallenge(value) {
5086
5319
  return isObject(value) && value.twoFactorRedirect === true;
5087
5320
  }
5088
5321
  function normalizeBackupCodes(value) {
5089
- if (!Array.isArray(value) || value.length !== BACKUP_CODE_COUNT || value.some((code) => typeof code !== "string" || !backupCode.test(code)) || new Set(value).size !== value.length) throw authorityUnavailable();
5322
+ if (!Array.isArray(value) || value.length !== BACKUP_CODE_COUNT || value.some((code) => {
5323
+ return typeof code !== "string" || !backupCode.test(code);
5324
+ }) || new Set(value).size !== value.length) throw authorityUnavailable();
5090
5325
  return [...value];
5091
5326
  }
5092
5327
  function normalizeRegeneratedBackupCodes(value) {
@@ -5149,7 +5384,9 @@ const stateKeys = [
5149
5384
  "status"
5150
5385
  ];
5151
5386
  function exact(value, keys) {
5152
- return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
5387
+ return isObject(value) && Object.keys(value).length === keys.length && keys.every((key) => {
5388
+ return Object.hasOwn(value, key);
5389
+ });
5153
5390
  }
5154
5391
  function date(value, nullable) {
5155
5392
  if (value === null && nullable) return null;
@@ -5275,9 +5512,13 @@ function enterpriseDomainInput(value) {
5275
5512
  function normalizeEnterpriseConnectionSetup(value) {
5276
5513
  if (!exact(value, setupKeys) || value.capability !== "federated_sign_in" && value.capability !== "managed_lifecycle" || typeof value.id !== "string" || !idPattern.test(value.id) || typeof value.issuer !== "string" || value.issuer.length > 2048 || !value.issuer.startsWith("https://") || typeof value.clientId !== "string" || value.clientId.length < 1 || value.clientId.length > 256 || value.domain !== null && (typeof value.domain !== "string" || !domainPattern.test(value.domain) || value.domain.length > 253 || value.dnsRecordName !== `_finueva-sso.${value.domain}` || typeof value.dnsRecordValue !== "string" || !/^finueva-sso=[A-Za-z0-9_-]{43}$/.test(value.dnsRecordValue)) || value.domain === null && (value.dnsRecordName !== null || value.dnsRecordValue !== null || value.challengeExpiresAt !== null || value.domainVerified !== false) || !Array.isArray(value.domains) || value.domains.length > 10 || typeof value.redirectUri !== "string" || value.redirectUri.length > 2048 || !Number.isSafeInteger(value.revision) || value.revision < 0) throw authorityUnavailable();
5277
5514
  const domains = value.domains.map(normalizeConnectionDomain);
5278
- const primary = domains.filter((domain) => domain.primary);
5515
+ const primary = domains.filter((domain) => {
5516
+ return domain.primary;
5517
+ });
5279
5518
  const challengeExpiresAt = date(value.challengeExpiresAt, value.domain === null);
5280
- if (new Set(domains.map((domain) => domain.domain)).size !== domains.length || (value.domain === null ? primary.length !== 0 : primary.length !== 1 || primary[0].domain !== value.domain || primary[0].dnsRecordName !== value.dnsRecordName || primary[0].dnsRecordValue !== value.dnsRecordValue || primary[0].verified !== value.domainVerified || primary[0].challengeExpiresAt.getTime() !== challengeExpiresAt?.getTime())) throw authorityUnavailable();
5519
+ if (new Set(domains.map((domain) => {
5520
+ return domain.domain;
5521
+ })).size !== domains.length || (value.domain === null ? primary.length !== 0 : primary.length !== 1 || primary[0].domain !== value.domain || primary[0].dnsRecordName !== value.dnsRecordName || primary[0].dnsRecordValue !== value.dnsRecordValue || primary[0].verified !== value.domainVerified || primary[0].challengeExpiresAt.getTime() !== challengeExpiresAt?.getTime())) throw authorityUnavailable();
5281
5522
  let redirect;
5282
5523
  try {
5283
5524
  redirect = new URL(value.redirectUri);
@@ -5352,23 +5593,27 @@ function userApiApplication(input) {
5352
5593
  return input.applicationId;
5353
5594
  }
5354
5595
  function normalizeUserApiCredential(value, startedAt) {
5355
- if (!value || typeof value !== "object" || Array.isArray(value) || !("tokenType" in value) || value.tokenType !== "Bearer" || !("token" in value) || typeof value.token !== "string" || value.token.length + 7 > 16 * 1024 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.token) || !("expiresIn" in value) || typeof value.expiresIn !== "number" || !Number.isInteger(value.expiresIn) || value.expiresIn < 1 || value.expiresIn > 840 || Object.keys(value).sort().join(",") !== "expiresIn,token,tokenType") throw new AuthError("identity_authority_unavailable", 503);
5596
+ if (!value || typeof value !== "object" || Array.isArray(value) || !("tokenType" in value) || value.tokenType !== "Bearer" || !("token" in value) || typeof value.token !== "string" || value.token.length + 7 > 16384 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.token) || !("expiresIn" in value) || typeof value.expiresIn !== "number" || !Number.isInteger(value.expiresIn) || value.expiresIn < 1 || value.expiresIn > 840 || Object.keys(value).sort().join(",") !== "expiresIn,token,tokenType") throw new AuthError("identity_authority_unavailable", 503);
5356
5597
  return {
5357
5598
  tokenType: "Bearer",
5358
5599
  token: value.token,
5359
5600
  expiresAt: new Date(startedAt + value.expiresIn * 1e3)
5360
5601
  };
5361
5602
  }
5362
- function createUserApiCredentialCache(issue, now, currentSessionId = () => void 0) {
5603
+ function createUserApiCredentialCache(issue, now, currentSessionId = () => {}) {
5363
5604
  let generation = 0;
5364
5605
  let cached;
5365
5606
  let pending;
5366
- const copy = (value) => ({
5367
- ...value,
5368
- expiresAt: new Date(value.expiresAt)
5369
- });
5607
+ const copy = (value) => {
5608
+ return {
5609
+ ...value,
5610
+ expiresAt: new Date(value.expiresAt)
5611
+ };
5612
+ };
5370
5613
  return {
5371
- hasAuthority: () => Boolean(cached || pending),
5614
+ hasAuthority: () => {
5615
+ return Boolean(cached || pending);
5616
+ },
5372
5617
  retainSession(sessionId) {
5373
5618
  if (cached?.sessionId === sessionId && !pending) return;
5374
5619
  generation += 1;
@@ -5421,7 +5666,7 @@ function createUserApiCredentialCache(issue, now, currentSessionId = () => void
5421
5666
  }
5422
5667
  //#endregion
5423
5668
  //#region src/client.ts
5424
- const REFRESH_WINDOW_MS = 120 * 1e3;
5669
+ const REFRESH_WINDOW_MS = 12e4;
5425
5670
  const RECENT_AUTHENTICATION_BROWSER_HEADER = "x-finueva-recent-auth-browser";
5426
5671
  const RECENT_AUTHENTICATION_REQUEST_HEADER = "x-finueva-recent-auth-request";
5427
5672
  function createAuthClient(options) {
@@ -5432,13 +5677,17 @@ function createAuthClient(options) {
5432
5677
  if (typeof fetchImpl !== "function") throw new TypeError("fetch is required");
5433
5678
  const now = options.now ?? Date.now;
5434
5679
  const timeoutMs = normalizeTimeout(options.timeoutMs);
5435
- const userApiCredentials = createUserApiCredentialCache((applicationId) => requestJson(joinURL(authOrigin, "api/v1/auth/user-api-credential"), {
5436
- fetch: fetchImpl,
5437
- timeoutMs,
5438
- method: "POST",
5439
- headers: { "content-type": "application/json; charset=utf-8" },
5440
- body: { applicationId }
5441
- }), now, () => sessionId);
5680
+ const userApiCredentials = createUserApiCredentialCache((applicationId) => {
5681
+ return requestJson(joinURL(authOrigin, "api/v1/auth/user-api-credential"), {
5682
+ fetch: fetchImpl,
5683
+ timeoutMs,
5684
+ method: "POST",
5685
+ headers: { "content-type": "application/json; charset=utf-8" },
5686
+ body: { applicationId }
5687
+ });
5688
+ }, now, () => {
5689
+ return sessionId;
5690
+ });
5442
5691
  const betterAuth = createAuthClient$1({
5443
5692
  baseURL: authOrigin,
5444
5693
  basePath: "/api/v1/auth",
@@ -5549,7 +5798,7 @@ function createAuthClient(options) {
5549
5798
  authoritative: false
5550
5799
  });
5551
5800
  });
5552
- if (typeof window === "undefined") getSession().catch(() => void 0);
5801
+ if (typeof window === "undefined") getSession().catch(() => {});
5553
5802
  }
5554
5803
  function subscribeToSessionSignals() {
5555
5804
  if (sessionSignalSubscribed) return;
@@ -5586,7 +5835,7 @@ function createAuthClient(options) {
5586
5835
  signalRefreshScheduled = false;
5587
5836
  if (!signalRefreshPending || signalRefreshRequest || signOutRequest || activeAccountMutationGeneration !== void 0) return;
5588
5837
  signalRefreshPending = false;
5589
- const request = refreshAuthoritySession(authorityGeneration).then(() => void 0, () => void 0).finally(() => {
5838
+ const request = refreshAuthoritySession(authorityGeneration).then(() => {}, () => {}).finally(() => {
5590
5839
  if (signalRefreshRequest === request) signalRefreshRequest = void 0;
5591
5840
  if (signalRefreshPending) queueSignalRefresh();
5592
5841
  });
@@ -5666,7 +5915,7 @@ function createAuthClient(options) {
5666
5915
  });
5667
5916
  emitSession(null);
5668
5917
  const request = (async () => {
5669
- await pendingInvitation?.catch(() => void 0);
5918
+ await pendingInvitation?.catch(() => {});
5670
5919
  let result;
5671
5920
  try {
5672
5921
  result = await betterAuth.signOut();
@@ -5713,7 +5962,7 @@ function createAuthClient(options) {
5713
5962
  });
5714
5963
  emitSession(null);
5715
5964
  try {
5716
- await pendingInvitation?.catch(() => void 0);
5965
+ await pendingInvitation?.catch(() => {});
5717
5966
  try {
5718
5967
  const data = await operation();
5719
5968
  if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
@@ -5789,7 +6038,7 @@ function createAuthClient(options) {
5789
6038
  timeoutMs,
5790
6039
  method: "GET",
5791
6040
  mapError: fromOrganizationReadAuthorityError,
5792
- maxResponseBytes: 256 * 1024
6041
+ maxResponseBytes: 262144
5793
6042
  });
5794
6043
  if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5795
6044
  try {
@@ -5815,6 +6064,18 @@ function createAuthClient(options) {
5815
6064
  if (generation !== authorityGeneration) throw new AuthError("state_conflict", 409);
5816
6065
  return normalize(value);
5817
6066
  }
6067
+ async function accountDeletionRequest(method, path, body, normalize) {
6068
+ return normalize(await requestJson(joinURL(authOrigin, "api/v1/auth/user/closure", path), {
6069
+ fetch: fetchImpl,
6070
+ timeoutMs,
6071
+ method,
6072
+ ...body ? {
6073
+ headers: { "content-type": "application/json" },
6074
+ body
6075
+ } : {},
6076
+ mapError: fromAccountDeletionError
6077
+ }));
6078
+ }
5818
6079
  async function ceremonyRequest(method, path, body, normalize) {
5819
6080
  if (signOutRequest || activeAccountMutationGeneration !== void 0 || invitationRequest) throw new AuthError("state_conflict", 409);
5820
6081
  const generation = authorityGeneration;
@@ -6086,15 +6347,23 @@ function createAuthClient(options) {
6086
6347
  async getOrganizationMemberAuthority(organizationId, memberId) {
6087
6348
  const organization = normalizeIdInput(organizationId);
6088
6349
  const member = normalizeIdInput(memberId);
6089
- return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthority(value, organization, member));
6350
+ return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => {
6351
+ return normalizeOrganizationMemberAuthority(value, organization, member);
6352
+ });
6090
6353
  },
6091
6354
  async getOrganizationMemberAuthorityV2(organizationId, memberId) {
6092
6355
  const organization = normalizeIdInput(organizationId);
6093
6356
  const member = normalizeIdInput(memberId);
6094
- return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => normalizeOrganizationMemberAuthorityV2(value, organization, member), () => new URLSearchParams({ version: "2" }));
6357
+ return organizationRead(`${organization}/members/${member}/authority`, void 0, (value) => {
6358
+ return normalizeOrganizationMemberAuthorityV2(value, organization, member);
6359
+ }, () => {
6360
+ return new URLSearchParams({ version: "2" });
6361
+ });
6095
6362
  },
6096
6363
  getOrganizationApplicationRegistration(organizationId, applicationId) {
6097
- return organizationRead(registrationTarget(organizationId, applicationId), void 0, (value) => normalizeOrganizationApplicationRegistration(value, organizationId, applicationId));
6364
+ return organizationRead(registrationTarget(organizationId, applicationId), void 0, (value) => {
6365
+ return normalizeOrganizationApplicationRegistration(value, organizationId, applicationId);
6366
+ });
6098
6367
  },
6099
6368
  async registerOrganizationApplication(organizationId, applicationId, input) {
6100
6369
  const path = registrationTarget(organizationId, applicationId);
@@ -6261,17 +6530,23 @@ function createAuthClient(options) {
6261
6530
  organizationId,
6262
6531
  teamId,
6263
6532
  memberId
6264
- ], idempotencyKey, (organization, team, member) => joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "members", member, "add")));
6533
+ ], idempotencyKey, (organization, team, member) => {
6534
+ return joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "members", member, "add");
6535
+ }));
6265
6536
  },
6266
6537
  async removeOrganizationTeamMember(organizationId, teamId, memberId, idempotencyKey) {
6267
6538
  return normalizeRemovedOrganizationTeamMember(await teamMembershipMutation([
6268
6539
  organizationId,
6269
6540
  teamId,
6270
6541
  memberId
6271
- ], idempotencyKey, (organization, team, member) => joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "members", member, "remove")));
6542
+ ], idempotencyKey, (organization, team, member) => {
6543
+ return joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "members", member, "remove");
6544
+ }));
6272
6545
  },
6273
6546
  async deleteOrganizationTeam(organizationId, teamId, idempotencyKey) {
6274
- return normalizeDeletedOrganizationTeam(await teamMembershipMutation([organizationId, teamId], idempotencyKey, (organization, team) => joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "delete")));
6547
+ return normalizeDeletedOrganizationTeam(await teamMembershipMutation([organizationId, teamId], idempotencyKey, (organization, team) => {
6548
+ return joinURL(authOrigin, "api/v1/auth/organizations", organization, "teams", team, "delete");
6549
+ }));
6275
6550
  },
6276
6551
  async updateOrganizationDisplay(organizationId, input) {
6277
6552
  const id = normalizeIdInput(organizationId);
@@ -6464,7 +6739,9 @@ function createAuthClient(options) {
6464
6739
  }, normalizeEnterpriseConnectionSetup);
6465
6740
  },
6466
6741
  async getScimCredential(organizationId, connectionId) {
6467
- return enterpriseRequest("GET", scimCredentialPath(organizationId, connectionId), void 0, (value) => normalizeScimCredentialState(value));
6742
+ return enterpriseRequest("GET", scimCredentialPath(organizationId, connectionId), void 0, (value) => {
6743
+ return normalizeScimCredentialState(value);
6744
+ });
6468
6745
  },
6469
6746
  async issueScimCredential(organizationId, connectionId) {
6470
6747
  return enterpriseRequest("POST", scimCredentialPath(organizationId, connectionId), {}, normalizeScimCredentialIssuance);
@@ -6478,7 +6755,9 @@ function createAuthClient(options) {
6478
6755
  },
6479
6756
  async revokeScimCredential(organizationId, connectionId, input) {
6480
6757
  const body = { expectedRevision: normalizeRevision(input?.expectedRevision) };
6481
- return enterpriseRequest("POST", `${scimCredentialPath(organizationId, connectionId)}/revoke`, body, (value) => normalizeScimCredentialState(value));
6758
+ return enterpriseRequest("POST", `${scimCredentialPath(organizationId, connectionId)}/revoke`, body, (value) => {
6759
+ return normalizeScimCredentialState(value);
6760
+ });
6482
6761
  },
6483
6762
  async signIn(input) {
6484
6763
  const body = {
@@ -6505,7 +6784,9 @@ function createAuthClient(options) {
6505
6784
  },
6506
6785
  async verifyTwoFactor(code) {
6507
6786
  const normalized = normalizeTwoFactorCode(code);
6508
- const result = await runAccountMutation(() => accountRequest(normalized.route, { code: normalized.code }, fromTwoFactorAuthorityError));
6787
+ const result = await runAccountMutation(() => {
6788
+ return accountRequest(normalized.route, { code: normalized.code }, fromTwoFactorAuthorityError);
6789
+ });
6509
6790
  if (!result.session) throw new AuthError("authentication_required", 401);
6510
6791
  return result.session;
6511
6792
  },
@@ -6531,13 +6812,17 @@ function createAuthClient(options) {
6531
6812
  },
6532
6813
  async confirmTwoFactorEnrollment(code) {
6533
6814
  const body = { code: normalizeTotpCode(code) };
6534
- const result = await runAccountMutation(() => accountRequest("two-factor/verify-totp", body, fromTwoFactorAuthorityError));
6815
+ const result = await runAccountMutation(() => {
6816
+ return accountRequest("two-factor/verify-totp", body, fromTwoFactorAuthorityError);
6817
+ });
6535
6818
  if (!result.session) throw new AuthError("authentication_required", 401);
6536
6819
  return result.session;
6537
6820
  },
6538
6821
  async disableTwoFactor(input) {
6539
6822
  const body = normalizeTwoFactorStepUp(input);
6540
- const result = await runAccountMutation(() => accountRequest("two-factor/disable", body, fromTwoFactorAuthorityError));
6823
+ const result = await runAccountMutation(() => {
6824
+ return accountRequest("two-factor/disable", body, fromTwoFactorAuthorityError);
6825
+ });
6541
6826
  if (!result.session) throw new AuthError("authentication_required", 401);
6542
6827
  return result.session;
6543
6828
  },
@@ -6564,6 +6849,12 @@ function createAuthClient(options) {
6564
6849
  async listPasskeys() {
6565
6850
  return ceremonyRequest("GET", "passkeys", void 0, normalizePasskeyInventory);
6566
6851
  },
6852
+ async getAccountDeletionEligibility() {
6853
+ return accountDeletionRequest("GET", "eligibility", void 0, normalizeAccountDeletionEligibility);
6854
+ },
6855
+ async restoreAccount(input) {
6856
+ await accountDeletionRequest("POST", "restore", normalizeAccountDeletionRestoreInput(input), normalizeAccountDeletionRestore);
6857
+ },
6567
6858
  async renamePasskey(passkeyId, name) {
6568
6859
  const id = normalizePasskeyId(passkeyId);
6569
6860
  const body = { name: normalizePasskeyName(name) };
@@ -6571,7 +6862,9 @@ function createAuthClient(options) {
6571
6862
  },
6572
6863
  async signInWithSocialIdToken(input) {
6573
6864
  const body = socialIdTokenRequest(normalizeSocialIdTokenInput(input));
6574
- const result = await runAccountMutation(() => accountRequest("sign-in/social", body, fromSocialIdTokenAuthorityError));
6865
+ const result = await runAccountMutation(() => {
6866
+ return accountRequest("sign-in/social", body, fromSocialIdTokenAuthorityError);
6867
+ });
6575
6868
  if (!result.session) throw new AuthError("authentication_required", 401);
6576
6869
  return result.session;
6577
6870
  },
@@ -6581,13 +6874,17 @@ function createAuthClient(options) {
6581
6874
  password: normalizePassword(password, "password", 10),
6582
6875
  name: normalizeName(name)
6583
6876
  };
6584
- const result = await runAccountMutation(() => accountRequest("sign-up/email", body));
6877
+ const result = await runAccountMutation(() => {
6878
+ return accountRequest("sign-up/email", body);
6879
+ });
6585
6880
  if (!result.session) throw new AuthError("authentication_required", 401);
6586
6881
  return result.session;
6587
6882
  },
6588
6883
  async updateProfile(input) {
6589
6884
  const body = normalizeProfileInput(input);
6590
- const result = await runAccountMutation(() => accountRequest("update-user", body));
6885
+ const result = await runAccountMutation(() => {
6886
+ return accountRequest("update-user", body);
6887
+ });
6591
6888
  if (!result.session) throw new AuthError("authentication_required", 401);
6592
6889
  return result.session;
6593
6890
  },
@@ -6595,11 +6892,13 @@ function createAuthClient(options) {
6595
6892
  const current = normalizePassword(currentPassword, "currentPassword");
6596
6893
  const next = normalizePassword(newPassword, "newPassword", 10);
6597
6894
  if (typeof revokeOtherSessions !== "boolean") throw new TypeError("revokeOtherSessions is invalid");
6598
- const result = await runAccountMutation(() => accountRequest("change-password", {
6599
- currentPassword: current,
6600
- newPassword: next,
6601
- revokeOtherSessions
6602
- }));
6895
+ const result = await runAccountMutation(() => {
6896
+ return accountRequest("change-password", {
6897
+ currentPassword: current,
6898
+ newPassword: next,
6899
+ revokeOtherSessions
6900
+ });
6901
+ });
6603
6902
  if (!result.session) throw new AuthError("authentication_required", 401);
6604
6903
  return result.session;
6605
6904
  },
@@ -6614,7 +6913,9 @@ function createAuthClient(options) {
6614
6913
  token: normalizePasswordResetToken(token),
6615
6914
  newPassword: normalizePassword(newPassword, "newPassword", 10)
6616
6915
  };
6617
- normalizeVerificationEmailResponse((await runAccountMutation(() => accountRequest("reset-password", body))).data);
6916
+ normalizeVerificationEmailResponse((await runAccountMutation(() => {
6917
+ return accountRequest("reset-password", body);
6918
+ })).data);
6618
6919
  },
6619
6920
  async sendVerificationEmail(input) {
6620
6921
  const body = normalizeVerificationEmailInput(input, appOrigin);
@@ -6682,7 +6983,9 @@ function createAuthClient(options) {
6682
6983
  listener(authState);
6683
6984
  } catch {}
6684
6985
  startAuthState();
6685
- return () => authStateListeners.delete(listener);
6986
+ return () => {
6987
+ return authStateListeners.delete(listener);
6988
+ };
6686
6989
  },
6687
6990
  onSessionChange(listener) {
6688
6991
  sessionListeners.add(listener);
@@ -6691,7 +6994,9 @@ function createAuthClient(options) {
6691
6994
  else if (authState.status === "unauthenticated") listener(null);
6692
6995
  } catch {}
6693
6996
  startAuthState();
6694
- return () => sessionListeners.delete(listener);
6997
+ return () => {
6998
+ return sessionListeners.delete(listener);
6999
+ };
6695
7000
  }
6696
7001
  };
6697
7002
  }