@codemem/core 0.48.1 → 0.49.0-beta.1

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.
Files changed (64) hide show
  1. package/dist/coordinator-account-connection-schema.d.ts +1 -1
  2. package/dist/{coordinator-runtime-DjVICtRs.js → coordinator-runtime-Bdad5KeL.js} +164 -163
  3. package/dist/{coordinator-runtime-DjVICtRs.js.map → coordinator-runtime-Bdad5KeL.js.map} +1 -1
  4. package/dist/db.d.ts.map +1 -1
  5. package/dist/feed-contract.d.ts +59 -0
  6. package/dist/feed-contract.d.ts.map +1 -0
  7. package/dist/feed-contract.js +187 -0
  8. package/dist/feed-contract.js.map +1 -0
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +6553 -6534
  12. package/dist/index.js.map +1 -1
  13. package/dist/internal/cloudflare-coordinator.js +1015 -1014
  14. package/dist/internal/cloudflare-coordinator.js.map +1 -1
  15. package/dist/internal/relay-runtime.js +36 -36
  16. package/dist/{owner-enrollment-start-DFVkODlJ.js → owner-enrollment-start-DgToUaFZ.js} +884 -884
  17. package/dist/{owner-enrollment-start-DFVkODlJ.js.map → owner-enrollment-start-DgToUaFZ.js.map} +1 -1
  18. package/dist/raw-event-ingest.d.ts.map +1 -1
  19. package/dist/{relay-health-DhxMrW_S.js → relay-health-zrKtNQLQ.js} +16 -16
  20. package/dist/{relay-health-DhxMrW_S.js.map → relay-health-zrKtNQLQ.js.map} +1 -1
  21. package/dist/{relay-peer-client-CpY-lVbi.js → relay-peer-client-DdhDwDFz.js} +4437 -1978
  22. package/dist/relay-peer-client-DdhDwDFz.js.map +1 -0
  23. package/dist/schema-bootstrap.d.ts.map +1 -1
  24. package/dist/scope-membership-cache-read-B6z47l2W.js +4114 -0
  25. package/dist/scope-membership-cache-read-B6z47l2W.js.map +1 -0
  26. package/dist/scope-membership-cache-read.d.ts +60 -0
  27. package/dist/scope-membership-cache-read.d.ts.map +1 -0
  28. package/dist/scope-membership-cache.d.ts +2 -57
  29. package/dist/scope-membership-cache.d.ts.map +1 -1
  30. package/dist/scope-membership-semantics-B8qXaMqx.js +205 -0
  31. package/dist/scope-membership-semantics-B8qXaMqx.js.map +1 -0
  32. package/dist/semantic-worker-entry.js +1 -1
  33. package/dist/{semantic-worker-job-BmwXMG7v.js → semantic-worker-job-CMjFE5cp.js} +3 -3
  34. package/dist/{semantic-worker-job-BmwXMG7v.js.map → semantic-worker-job-CMjFE5cp.js.map} +1 -1
  35. package/dist/{semantic-worker-ranking-D31rfYAT.js → semantic-worker-ranking-it8Zs3qb.js} +18 -18
  36. package/dist/{semantic-worker-ranking-D31rfYAT.js.map → semantic-worker-ranking-it8Zs3qb.js.map} +1 -1
  37. package/dist/store.d.ts.map +1 -1
  38. package/dist/{sync-auth-constants-Cb8-a8lE.js → sync-auth-constants-WKqJ9CX5.js} +2387 -2514
  39. package/dist/sync-auth-constants-WKqJ9CX5.js.map +1 -0
  40. package/dist/sync-reachability-pass-CQe7nZnN.js +2 -0
  41. package/dist/{sync-reachability-pass-EOj3hEau.js → sync-reachability-pass-CSg85Qmd.js} +2466 -2565
  42. package/dist/sync-reachability-pass-CSg85Qmd.js.map +1 -0
  43. package/dist/sync-status-indexes.d.ts +4 -0
  44. package/dist/sync-status-indexes.d.ts.map +1 -0
  45. package/dist/{validated-vector-index-audit-OuQct6jU.js → validated-vector-index-audit-B64yhEBF.js} +50 -50
  46. package/dist/validated-vector-index-audit-B64yhEBF.js.map +1 -0
  47. package/dist/vector-backfill-queue.d.ts +6 -0
  48. package/dist/vector-backfill-queue.d.ts.map +1 -1
  49. package/dist/vector-cutover-validation.d.ts +1 -0
  50. package/dist/vector-cutover-validation.d.ts.map +1 -1
  51. package/dist/vector-migration.d.ts +1 -0
  52. package/dist/vector-migration.d.ts.map +1 -1
  53. package/dist/vectors.d.ts +8 -2
  54. package/dist/vectors.d.ts.map +1 -1
  55. package/package.json +9 -4
  56. package/dist/relay-admission-proof-DjvC-e6G.js +0 -78
  57. package/dist/relay-admission-proof-DjvC-e6G.js.map +0 -1
  58. package/dist/relay-peer-client-CpY-lVbi.js.map +0 -1
  59. package/dist/scope-membership-cache-ByHJl5gt.js +0 -6549
  60. package/dist/scope-membership-cache-ByHJl5gt.js.map +0 -1
  61. package/dist/sync-auth-constants-Cb8-a8lE.js.map +0 -1
  62. package/dist/sync-reachability-pass-C6SYfltg.js +0 -2
  63. package/dist/sync-reachability-pass-EOj3hEau.js.map +0 -1
  64. package/dist/validated-vector-index-audit-OuQct6jU.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { $n as e, A as t, Ai as n, An as r, D as i, Dr as a, Ei as o, Er as s, Fn as c, G as l, Gn as u, Gr as d, Hi as f, Hn as p, Ii as m, Jn as h, Kr as g, Li as _, Ln as v, Lr as y, Mn as b, Mr as x, O as S, Pi as ee, Qn as te, Ri as ne, Rn as re, Rr as C, S as ie, T as ae, Tr as oe, Un as se, Wr as ce, Xn as le, Yr as ue, Zn as de, _ as fe, _n as pe, bi as me, ca as he, gi as w, gn as ge, gr as _e, hi as ve, hn as ye, it as be, jn as xe, k as Se, kn as Ce, la as we, mn as Te, oa as Ee, or as De, pn as Oe, pr as ke, qr as T, r as Ae, rr as je, rt as Me, sa as Ne, tt as Pe, un as Fe, vn as Ie, vr as Le, wi as Re, xi as ze, yi as Be, zi as Ve, zr as He } from "./sync-auth-constants-Cb8-a8lE.js";
2
- import { n as Ue, r as We } from "./relay-ed25519-BNMhPehl.js";
3
- import { t as Ge } from "./workspace-identity-DI8bBR0Y.js";
4
- import { n as Ke, t as E } from "./relay-admission-clock-C4rCAFdM.js";
5
- import { _ as qe, g as Je, h as Ye, s as Xe, t as Ze, v as Qe, y as $e } from "./relay-admission-reply-CHCEakzd.js";
6
- import { t as et } from "./relay-admission-proof-DjvC-e6G.js";
1
+ import { g as e, h as t, m as n, n as r, p as i, v as a } from "./scope-membership-semantics-B8qXaMqx.js";
2
+ import { $t as o, Ai as s, Bn as c, C as l, D as u, Di as d, Dn as f, Dr as p, E as m, Ei as h, En as g, Er as _, Fr as v, Hn as y, Ir as b, K as x, Kn as ee, Ln as S, Mn as te, Nr as ne, O as re, Or as C, P as ie, Pn as ae, Pr as w, Si as oe, T as se, Ti as ce, Vn as le, W as ue, Yn as de, an as fe, ar as pe, b as me, bn as he, ci as ge, fi as _e, gr as ve, h as ye, hr as be, ii as T, in as xe, jn as Se, li as Ce, mi as we, mr as Te, n as Ee, nn as De, nr as Oe, on as ke, q as Ae, ri as je, rn as Me, si as Ne, sn as Pe, sr as Fe, vi as Ie, vn as Le, wi as Re, wn as ze, xn as Be, xr as Ve, yn as He, zn as Ue } from "./sync-auth-constants-WKqJ9CX5.js";
3
+ import { n as We, r as Ge } from "./relay-ed25519-BNMhPehl.js";
4
+ import { t as Ke } from "./workspace-identity-DI8bBR0Y.js";
5
+ import { n as qe, t as E } from "./relay-admission-clock-C4rCAFdM.js";
6
+ import { _ as Je, g as Ye, h as Xe, s as Ze, t as Qe, v as $e, y as et } from "./relay-admission-reply-CHCEakzd.js";
7
7
  import { createHash as tt } from "node:crypto";
8
8
  //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/compose.js
9
9
  var nt = (e, t, n) => (r, i) => {
@@ -880,7 +880,7 @@ function mn(e) {
880
880
  function hn(e, t) {
881
881
  let n = t.legacyHistory;
882
882
  if (!n) return [];
883
- let r = /* @__PURE__ */ new Set([n.fingerprint, ...n.keys.map((e) => e.fingerprint)]), i = e.flatMap((e) => e.manifest.device_decisions.filter((e) => m(e) && (e.device_id === n.deviceId || r.has(e.key_fingerprint))).flatMap((e) => e.identity_id ? [e.identity_id] : []));
883
+ let r = /* @__PURE__ */ new Set([n.fingerprint, ...n.keys.map((e) => e.fingerprint)]), i = e.flatMap((e) => e.manifest.device_decisions.filter((e) => Re(e) && (e.device_id === n.deviceId || r.has(e.key_fingerprint))).flatMap((e) => e.identity_id ? [e.identity_id] : []));
884
884
  return [...new Set(i)].sort();
885
885
  }
886
886
  //#endregion
@@ -903,7 +903,7 @@ function bn(e) {
903
903
  let t = Sn(e);
904
904
  if (!t || !_n.every((e) => Object.hasOwn(t, e))) return null;
905
905
  let { group_id: n, device_id: r, identity_id: i, fingerprint: a } = t;
906
- if (!w(n) || !w(r) || !w(i) || !yn(a) || Object.hasOwn(t, "confirm_evidence_digest") && !yn(t.confirm_evidence_digest) || Object.hasOwn(t, "purpose") && t.purpose !== "existing_account_owner") return null;
906
+ if (!T(n) || !T(r) || !T(i) || !yn(a) || Object.hasOwn(t, "confirm_evidence_digest") && !yn(t.confirm_evidence_digest) || Object.hasOwn(t, "purpose") && t.purpose !== "existing_account_owner") return null;
907
907
  let o = {
908
908
  group_id: n,
909
909
  device_id: r,
@@ -1010,7 +1010,7 @@ async function kn(e, t, n, r) {
1010
1010
  t.identity_id,
1011
1011
  {
1012
1012
  ...d,
1013
- legacyHistory: Re(d.legacyHistory)
1013
+ legacyHistory: _e(d.legacyHistory)
1014
1014
  }
1015
1015
  ])), {
1016
1016
  result: m,
@@ -1055,13 +1055,13 @@ async function Mn(e) {
1055
1055
  deviceId: n.device_id,
1056
1056
  publicKey: n.public_key,
1057
1057
  fingerprint: n.fingerprint
1058
- }), i.legacyHistory.records.map((e) => o(e, r));
1058
+ }), i.legacyHistory.records.map((e) => we(e, r));
1059
1059
  } catch {
1060
1060
  return a.push("legacy_history_invalid"), [];
1061
1061
  }
1062
1062
  }
1063
1063
  function Nn(e, t) {
1064
- ve(e) || t.push("invite_evidence_invalid");
1064
+ je(e) || t.push("invite_evidence_invalid");
1065
1065
  }
1066
1066
  function Pn(e, t) {
1067
1067
  return {
@@ -1148,15 +1148,15 @@ async function Rn(e, t) {
1148
1148
  let i = await t.readRequestBytes(e, 4096);
1149
1149
  if (!i) return e.json({ error: "body_too_large" }, 413);
1150
1150
  let a = bn(t.parseJsonObject(i));
1151
- return a ? (n = t.storeFactory(), await _e(n), a.resolution_scope ? await zn(e, n, a, t.config) : await Fn(e, n, a, t.config.coordinatorId, t.config)) : e.json({ error: "review_invalid_input" }, 400);
1151
+ return a ? (n = t.storeFactory(), await pe(n), a.resolution_scope ? await zn(e, n, a, t.config) : await Fn(e, n, a, t.config.coordinatorId, t.config)) : e.json({ error: "review_invalid_input" }, 400);
1152
1152
  } finally {
1153
1153
  await n?.close();
1154
1154
  }
1155
1155
  } catch (t) {
1156
- return t instanceof Pe ? t.code === "review_stale" ? e.json({ error: t.code }, 409) : e.json({
1156
+ return t instanceof ue ? t.code === "review_stale" ? e.json({ error: t.code }, 409) : e.json({
1157
1157
  error: t.code,
1158
1158
  action: "Preview status before confirming again"
1159
- }, 503) : t instanceof x ? Le() : e.json({ error: "review_unavailable" }, 503);
1159
+ }, 503) : t instanceof Ve ? Fe() : e.json({ error: "review_unavailable" }, 503);
1160
1160
  }
1161
1161
  }
1162
1162
  async function zn(e, t, n, r) {
@@ -1181,7 +1181,7 @@ async function Bn(e, t, n) {
1181
1181
  try {
1182
1182
  return await e.confirmOwnerResolutionReview(t, n);
1183
1183
  } catch (e) {
1184
- throw e instanceof Pe || e instanceof x ? e : new Pe("owner_resolution_outcome_unknown");
1184
+ throw e instanceof ue || e instanceof Ve ? e : new ue("owner_resolution_outcome_unknown");
1185
1185
  }
1186
1186
  }
1187
1187
  function Vn(e, t) {
@@ -1267,20 +1267,20 @@ async function Xn(e, t, n) {
1267
1267
  } : Yn(e);
1268
1268
  }
1269
1269
  function Zn(e, t) {
1270
- return w(t) && w(e.group_id) && w(e.identity_id);
1270
+ return T(t) && T(e.group_id) && T(e.identity_id);
1271
1271
  }
1272
1272
  function Qn(e, t, n, r) {
1273
- return t === "capabilities" ? w(e.group_id) && w(e.identity_id) : Zn(e, n) ? t === "unlink" ? w(e.target_link_id) : t === "finalize" ? e.purpose === "coordinator-account-change-v1" && e.coordinator_id === r.config.coordinatorId && e.attempt_id === n && w(e.device_id) && Gn(e.fingerprint) && d(e.runtime_verifier) !== null && d(e.completion) !== null : Gn(e.runtime_verifier_hash) ? t !== "create" || (e.intent === "refresh" || e.intent === "disconnect") && Gn(e.browser_start_hash) && h(e.loopback_redirect).ok : !1 : !1;
1273
+ return t === "capabilities" ? T(e.group_id) && T(e.identity_id) : Zn(e, n) ? t === "unlink" ? T(e.target_link_id) : t === "finalize" ? e.purpose === "coordinator-account-change-v1" && e.coordinator_id === r.config.coordinatorId && e.attempt_id === n && T(e.device_id) && Gn(e.fingerprint) && w(e.runtime_verifier) !== null && w(e.completion) !== null : Gn(e.runtime_verifier_hash) ? t !== "create" || (e.intent === "refresh" || e.intent === "disconnect") && Gn(e.browser_start_hash) && S(e.loopback_redirect).ok : !1 : !1;
1274
1274
  }
1275
1275
  async function $n(e, t, n, r, i) {
1276
1276
  if (t.device_id !== n.signer.deviceId || t.fingerprint !== n.signer.fingerprint) return Jn(e);
1277
- let a = d(t.runtime_verifier), o = d(t.completion);
1277
+ let a = w(t.runtime_verifier), o = w(t.completion);
1278
1278
  if (!a || !o) return Yn(e);
1279
- let s = await T(a);
1279
+ let s = await b(a);
1280
1280
  return await r.finalize({
1281
1281
  ...n,
1282
1282
  runtimeVerifierHash: s,
1283
- completionSecretHash: await T(o)
1283
+ completionSecretHash: await b(o)
1284
1284
  }, i.config) ? s : Jn(e);
1285
1285
  }
1286
1286
  async function er(e, t, n, r, i, a, o) {
@@ -1410,7 +1410,7 @@ var ar = [
1410
1410
  "resolution_evidence_digest"
1411
1411
  ];
1412
1412
  function or(e) {
1413
- return l({
1413
+ return ie({
1414
1414
  attestationId: e.attestation_id,
1415
1415
  reviewReceiptId: e.review_receipt_id,
1416
1416
  reviewEvidenceDigest: e.review_evidence_digest,
@@ -1448,10 +1448,10 @@ function lr(e) {
1448
1448
  return typeof e == "string" && e.length === 64 && /^[a-f0-9]{64}$/.test(e);
1449
1449
  }
1450
1450
  function ur(e, t, n, r) {
1451
- return !w(t.group_id) || !w(n) ? !1 : e === "create" ? cr(t, sr.create) && w(t.identity_id) && (t.authority === "device_claim" || t.authority === "controller_attestation") && lr(t.runtime_verifier_hash) && lr(t.browser_start_hash) && h(t.loopback_redirect).ok : e !== "finalize" || cr(t, sr.finalize) && dr(t, n, r);
1451
+ return !T(t.group_id) || !T(n) ? !1 : e === "create" ? cr(t, sr.create) && T(t.identity_id) && (t.authority === "device_claim" || t.authority === "controller_attestation") && lr(t.runtime_verifier_hash) && lr(t.browser_start_hash) && S(t.loopback_redirect).ok : e !== "finalize" || cr(t, sr.finalize) && dr(t, n, r);
1452
1452
  }
1453
1453
  function dr(e, t, n) {
1454
- return e.purpose === "coordinator-account-link-v1" && e.coordinator_id === n.coordinatorId && e.attempt_id === t && w(e.identity_id) && w(e.device_id) && lr(e.fingerprint) && d(e.runtime_verifier) !== null && d(e.completion) !== null;
1454
+ return e.purpose === "coordinator-account-link-v1" && e.coordinator_id === n.coordinatorId && e.attempt_id === t && T(e.identity_id) && T(e.device_id) && lr(e.fingerprint) && w(e.runtime_verifier) !== null && w(e.completion) !== null;
1455
1455
  }
1456
1456
  function fr(e, t, n = {}) {
1457
1457
  return t.error === "attempt_limited" ? e.json({ error: "auth_link_limited" }, 429) : t.error === "attempt_conflict" || t.error === "link_conflict" ? e.json({ error: "auth_link_conflict" }, 409) : n.reviewRequired && t.error === "controller_not_active" ? e.json({ error: "auth_link_review_required" }, 403) : e.json({ error: "auth_link_unavailable" }, 403);
@@ -1532,17 +1532,17 @@ async function yr(e, t, n, r, i, a) {
1532
1532
  return s.kind === "rejected" ? fr(e, s, { reviewRequired: !0 }) : e.json({ status: s.status });
1533
1533
  }
1534
1534
  async function br(e, t, n, r) {
1535
- let i = d(e.runtime_verifier), a = d(e.completion);
1535
+ let i = w(e.runtime_verifier), a = w(e.completion);
1536
1536
  return !i || !a ? null : {
1537
- purpose: He,
1537
+ purpose: C,
1538
1538
  coordinatorId: r.coordinatorId,
1539
1539
  attemptId: t,
1540
1540
  groupId: e.group_id,
1541
1541
  identityId: e.identity_id,
1542
1542
  deviceId: e.device_id,
1543
1543
  fingerprint: e.fingerprint,
1544
- runtimeVerifierHash: await T(i),
1545
- completionSecretHash: await T(a),
1544
+ runtimeVerifierHash: await b(i),
1545
+ completionSecretHash: await b(a),
1546
1546
  signer: n
1547
1547
  };
1548
1548
  }
@@ -1583,7 +1583,7 @@ async function Sr(e, t, n, r) {
1583
1583
  } : e.json({ error: "auth_link_invalid_input" }, 400);
1584
1584
  }
1585
1585
  function Cr(e, t, n, r) {
1586
- return e === "resolved_owner_status" ? w(t.group_id) && w(t.owner_identity_id) : e === "resolved_owner_receipt_status" ? w(t.group_id) && w(t.owner_identity_id) && or(t) !== null : e === "account_status" ? w(t.group_id) && w(t.identity_id) : w(n) && ur(e, t, n, r);
1586
+ return e === "resolved_owner_status" ? T(t.group_id) && T(t.owner_identity_id) : e === "resolved_owner_receipt_status" ? T(t.group_id) && T(t.owner_identity_id) && or(t) !== null : e === "account_status" ? T(t.group_id) && T(t.identity_id) : T(n) && ur(e, t, n, r);
1587
1587
  }
1588
1588
  function wr(e, t, n) {
1589
1589
  return Tr(e, n, {
@@ -1615,7 +1615,7 @@ async function Tr(e, t, n) {
1615
1615
  if (i instanceof Response) return i;
1616
1616
  r ??= t.storeFactory();
1617
1617
  let a = await Er(e, t, r, i, n.label);
1618
- return a instanceof Response ? a : (await _e(r), await n.apply(r, a, i));
1618
+ return a instanceof Response ? a : (await pe(r), await n.apply(r, a, i));
1619
1619
  } finally {
1620
1620
  await r?.close();
1621
1621
  }
@@ -1644,7 +1644,7 @@ async function Er(e, t, n, r, i) {
1644
1644
  };
1645
1645
  }
1646
1646
  function Dr(e, t) {
1647
- return t instanceof x ? Le() : e.json({ error: "auth_link_unavailable" }, 503);
1647
+ return t instanceof Ve ? Fe() : e.json({ error: "auth_link_unavailable" }, 503);
1648
1648
  }
1649
1649
  function Or(e, t) {
1650
1650
  if (!t.config.enabled) return;
@@ -1700,25 +1700,25 @@ var Mr = Object.freeze({
1700
1700
  confirm: "/auth/link/device/confirm"
1701
1701
  }), Nr = 16;
1702
1702
  async function Pr(e) {
1703
- if (!r(e.csrfToken)) throw Error("auth_browser_view_invalid_input");
1703
+ if (!He(e.csrfToken)) throw Error("auth_browser_view_invalid_input");
1704
1704
  let t = e.rejected ? "<p role=\"alert\"><strong>Code not recognized or expired.</strong></p>" : "";
1705
- return Te("Link a device", `<h1>Link a device</h1><p>Enter the code shown on your device.</p>${t}<form method="post" action="${Mr.code}"><input type="hidden" name="csrf" value="${ye(e.csrfToken)}"><label for="user_code">Code</label><input id="user_code" name="user_code" type="text" autocomplete="off" autocapitalize="characters" spellcheck="false" maxlength="${Nr}" required autofocus><div class="actions"><button type="submit">Continue with Google</button></div></form><p class="note">Only enter a code from a device you are setting up yourself.</p>`, void 0, { referrerPolicy: "same-origin" });
1705
+ return Me("Link a device", `<h1>Link a device</h1><p>Enter the code shown on your device.</p>${t}<form method="post" action="${Mr.code}"><input type="hidden" name="csrf" value="${xe(e.csrfToken)}"><label for="user_code">Code</label><input id="user_code" name="user_code" type="text" autocomplete="off" autocapitalize="characters" spellcheck="false" maxlength="${Nr}" required autofocus><div class="actions"><button type="submit">Continue with Google</button></div></form><p class="note">Only enter a code from a device you are setting up yourself.</p>`, void 0, { referrerPolicy: "same-origin" });
1706
1706
  }
1707
1707
  async function Fr() {
1708
- return Te("Too many attempts", "<h1>Too many attempts</h1><p>Too many codes were entered. Wait a few minutes, then try again.</p>");
1708
+ return Me("Too many attempts", "<h1>Too many attempts</h1><p>Too many codes were entered. Wait a few minutes, then try again.</p>");
1709
1709
  }
1710
1710
  var Ir = /sha-?256|[0-9a-f]{8,}/iu;
1711
1711
  function Lr(e) {
1712
1712
  if (e === null) return null;
1713
1713
  try {
1714
- let t = ae(e, "device_display_name");
1714
+ let t = l(e, "device_display_name");
1715
1715
  return Ir.test(t) ? null : t;
1716
1716
  } catch {
1717
1717
  return null;
1718
1718
  }
1719
1719
  }
1720
1720
  function Rr(e, t) {
1721
- return `<dt>${ye(t)}</dt><dd><code>${ye(e)}</code></dd>`;
1721
+ return `<dt>${xe(t)}</dt><dd><code>${xe(e)}</code></dd>`;
1722
1722
  }
1723
1723
  async function zr(e) {
1724
1724
  if (![
@@ -1726,18 +1726,18 @@ async function zr(e) {
1726
1726
  e.groupId,
1727
1727
  e.deviceId,
1728
1728
  e.attemptId
1729
- ].every(w) || !r(e.csrfToken)) throw Error("auth_browser_view_invalid_input");
1730
- let t = jr(e.fingerprint), n = Lr(e.deviceName) ?? "Device", i = Rr(e.identityId, "Identity") + Rr(e.groupId, "Group") + `<dt>Device</dt><dd><bdi>${ye(n)}</bdi><br><code>${ye(e.deviceId)}</code></dd>`, a = `<section aria-label="Device key"><h2>Device key fingerprint</h2><p><code>${ye(t)}</code></p></section>`, o = { attemptId: e.attemptId }, s = ge(Mr.confirm, e.csrfToken, "Approve", o) + ge(Oe.cancelLink, e.csrfToken, "Cancel", {
1731
- ...o,
1729
+ ].every(T) || !He(e.csrfToken)) throw Error("auth_browser_view_invalid_input");
1730
+ let t = jr(e.fingerprint), n = Lr(e.deviceName) ?? "Device", r = Rr(e.identityId, "Identity") + Rr(e.groupId, "Group") + `<dt>Device</dt><dd><bdi>${xe(n)}</bdi><br><code>${xe(e.deviceId)}</code></dd>`, i = `<section aria-label="Device key"><h2>Device key fingerprint</h2><p><code>${xe(t)}</code></p></section>`, a = { attemptId: e.attemptId }, o = fe(Mr.confirm, e.csrfToken, "Approve", a) + fe(De.cancelLink, e.csrfToken, "Cancel", {
1731
+ ...a,
1732
1732
  secondary: !0
1733
1733
  });
1734
- return Te("Link account to a device", `<h1>Link account to a device</h1>${pe(Ie(e.profile, e.issuer))}<section aria-label="Link details"><h2>Link details</h2><dl>${i}</dl></section>${a}<p role="alert"><strong>Only continue if you ran <code class="command">codemem coordinator link-account --headless</code> on this device yourself in the last 10 minutes and the key fingerprint matches its terminal.</strong></p><div class="actions">${s}</div>`, e.issuer, { referrerPolicy: "same-origin" });
1734
+ return Me("Link account to a device", `<h1>Link account to a device</h1>${ke(Pe(e.profile, e.issuer))}<section aria-label="Link details"><h2>Link details</h2><dl>${r}</dl></section>${i}<p role="alert"><strong>Only continue if you ran <code class="command">codemem coordinator account link --headless</code> on this device yourself in the last 10 minutes and the key fingerprint matches its terminal.</strong></p><div class="actions">${o}</div>`, e.issuer, { referrerPolicy: "same-origin" });
1735
1735
  }
1736
1736
  async function Br() {
1737
- return Te("Return to your device", "<h1>Account link approved</h1><p>Return to your device's terminal to finish.</p>");
1737
+ return Me("Return to your device", "<h1>Account link approved</h1><p>Return to your device's terminal to finish.</p>");
1738
1738
  }
1739
1739
  async function Vr() {
1740
- return Te("Approve on the device page", "<h1>Approve on the device page</h1><p>This account link was started with a code from a device. Approve it on the page that shows the device's key fingerprint.</p>");
1740
+ return Me("Approve on the device page", "<h1>Approve on the device page</h1><p>This account link was started with a code from a device. Approve it on the page that shows the device's key fingerprint.</p>");
1741
1741
  }
1742
1742
  //#endregion
1743
1743
  //#region src/coordinator-device-headless-link.ts
@@ -1772,10 +1772,10 @@ function Jr(e) {
1772
1772
  return e.json({ error: "auth_link_invalid_input" }, 400);
1773
1773
  }
1774
1774
  function Yr(e) {
1775
- return cr(e, Gr.create) && w(e.group_id) && w(e.identity_id) && w(e.attempt_id) && (e.authority === "device_claim" || e.authority === "controller_attestation") && lr(e.runtime_verifier_hash) && lr(e.user_code_hash);
1775
+ return cr(e, Gr.create) && T(e.group_id) && T(e.identity_id) && T(e.attempt_id) && (e.authority === "device_claim" || e.authority === "controller_attestation") && lr(e.runtime_verifier_hash) && lr(e.user_code_hash);
1776
1776
  }
1777
1777
  function Xr(e, t, n) {
1778
- return cr(e, Gr.finalize) && w(e.group_id) && dr(e, t, n) && e.approved_issuer === n.issuer && e.approved_subject.length > 0 && e.approved_subject.length <= Wr;
1778
+ return cr(e, Gr.finalize) && T(e.group_id) && dr(e, t, n) && e.approved_issuer === n.issuer && e.approved_subject.length > 0 && e.approved_subject.length <= Wr;
1779
1779
  }
1780
1780
  async function Zr(e, t, n) {
1781
1781
  let r = await t.readRequestBytes(e, Ur);
@@ -1788,7 +1788,7 @@ async function Zr(e, t, n) {
1788
1788
  attemptId: String(i.attempt_id)
1789
1789
  } : Jr(e);
1790
1790
  let a = e.req.param("attemptId") ?? "";
1791
- return !w(a) || !Xr(i, a, t.config) ? Jr(e) : {
1791
+ return !T(a) || !Xr(i, a, t.config) ? Jr(e) : {
1792
1792
  raw: r,
1793
1793
  data: i,
1794
1794
  attemptId: a
@@ -1796,7 +1796,7 @@ async function Zr(e, t, n) {
1796
1796
  }
1797
1797
  function Qr(e) {
1798
1798
  let t = [...new URL(e.req.url).searchParams.entries()], n = t[0], r = e.req.param("attemptId") ?? "";
1799
- return t.length !== 1 || !n || n[0] !== "group_id" || !w(n[1]) || !w(r) ? Jr(e) : {
1799
+ return t.length !== 1 || !n || n[0] !== "group_id" || !T(n[1]) || !T(r) ? Jr(e) : {
1800
1800
  raw: /* @__PURE__ */ new Uint8Array(),
1801
1801
  data: { group_id: n[1] },
1802
1802
  attemptId: r
@@ -1815,7 +1815,7 @@ async function $r(e, t, n, r) {
1815
1815
  runtimeVerifierHash: s.runtime_verifier_hash,
1816
1816
  userCodeHash: s.user_code_hash
1817
1817
  }, a.config);
1818
- return l.kind === "rejected" ? l.error === "attempt_conflict" && await ke(e.backend, {
1818
+ return l.kind === "rejected" ? l.error === "attempt_conflict" && await Oe(e.backend, {
1819
1819
  coordinatorId: a.config.coordinatorId,
1820
1820
  userCodeHash: s.user_code_hash,
1821
1821
  attemptId: r.attemptId
@@ -2001,10 +2001,10 @@ function yi(e, t) {
2001
2001
  }) : O;
2002
2002
  }
2003
2003
  let i = n.attempt_id;
2004
- if (!w(i)) return O;
2004
+ if (!T(i)) return O;
2005
2005
  if (t === "link_start") {
2006
2006
  let e = n.start_code;
2007
- return typeof e != "string" || !d(e) ? O : Object.freeze({
2007
+ return typeof e != "string" || !w(e) ? O : Object.freeze({
2008
2008
  ok: !0,
2009
2009
  action: t,
2010
2010
  csrf: r,
@@ -2100,7 +2100,7 @@ function Oi(e) {
2100
2100
  let t = j(e, "publicOrigin"), n = j(e, "store"), r = j(n, "coordinatorId"), i = j(n, "revision");
2101
2101
  if (typeof t != "string" || /[\\\p{Cc}\p{Cf}\p{Cs}]/u.test(t)) throw k;
2102
2102
  let a = new URL(t);
2103
- if (a.protocol !== "https:" || a.origin !== t || a.username || a.password || !w(r) || typeof i != "string" || i.length !== 64 || !/^[a-f0-9]{64}$/.test(i)) throw k;
2103
+ if (a.protocol !== "https:" || a.origin !== t || a.username || a.password || !T(r) || typeof i != "string" || i.length !== 64 || !/^[a-f0-9]{64}$/.test(i)) throw k;
2104
2104
  return Object.freeze({
2105
2105
  publicOrigin: t,
2106
2106
  store: Object.freeze({
@@ -2158,7 +2158,7 @@ function ji(e, t) {
2158
2158
  }
2159
2159
  function Mi(e, t = {}) {
2160
2160
  let { clientKey: n, limit: r } = e;
2161
- if (!w(n) || n.length > 128) return A("client_unidentified");
2161
+ if (!T(n) || n.length > 128) return A("client_unidentified");
2162
2162
  if (typeof r != "number" || !Number.isSafeInteger(r) || r < 1 || r > 1e3 || !ji(e, r)) return k;
2163
2163
  let i = Ci(e.request, e.limiter, JSON.stringify([
2164
2164
  "browser-form",
@@ -2193,7 +2193,7 @@ function Fi(e) {
2193
2193
  async function Ii(e) {
2194
2194
  let t;
2195
2195
  try {
2196
- t = await v(e.cookie, e.kind);
2196
+ t = await g(e.cookie, e.kind);
2197
2197
  } catch {
2198
2198
  return A("cookie_invalid");
2199
2199
  }
@@ -2204,28 +2204,28 @@ async function Ii(e) {
2204
2204
  contentLength: e.contentLength
2205
2205
  });
2206
2206
  if (!n.ok) return A(n.error);
2207
- let i = yi(n.bytes, e.action);
2208
- return i.ok ? !r(i.csrf) || !await b(e.csrfKey, t.secret, e.kind, e.scope, i.csrf) ? A("csrf_invalid") : i.action === "session_logout" || i.action === "signin_start" ? Object.freeze({
2207
+ let r = yi(n.bytes, e.action);
2208
+ return r.ok ? !He(r.csrf) || !await Be(e.csrfKey, t.secret, e.kind, e.scope, r.csrf) ? A("csrf_invalid") : r.action === "session_logout" || r.action === "signin_start" ? Object.freeze({
2209
2209
  ok: !0,
2210
- action: i.action,
2210
+ action: r.action,
2211
2211
  cookieHash: t.cookieHash
2212
- }) : i.action === "headless_code" ? Object.freeze({
2212
+ }) : r.action === "headless_code" ? Object.freeze({
2213
2213
  ok: !0,
2214
- action: i.action,
2214
+ action: r.action,
2215
2215
  cookieHash: t.cookieHash,
2216
- userCode: i.userCode
2217
- }) : i.action === "link_start" ? Object.freeze({
2216
+ userCode: r.userCode
2217
+ }) : r.action === "link_start" ? Object.freeze({
2218
2218
  ok: !0,
2219
- action: i.action,
2219
+ action: r.action,
2220
2220
  cookieHash: t.cookieHash,
2221
- attemptId: i.attemptId,
2222
- startCode: i.startCode
2221
+ attemptId: r.attemptId,
2222
+ startCode: r.startCode
2223
2223
  }) : Object.freeze({
2224
2224
  ok: !0,
2225
- action: i.action,
2225
+ action: r.action,
2226
2226
  cookieHash: t.cookieHash,
2227
- attemptId: i.attemptId
2228
- }) : A(i.error);
2227
+ attemptId: r.attemptId
2228
+ }) : A(r.error);
2229
2229
  }
2230
2230
  async function Li(e) {
2231
2231
  try {
@@ -2268,7 +2268,7 @@ function Hi(e) {
2268
2268
  //#endregion
2269
2269
  //#region src/coordinator-browser-start-transaction.ts
2270
2270
  async function Ui(e, t, n) {
2271
- let r = await v(e, "transaction");
2271
+ let r = await g(e, "transaction");
2272
2272
  if (r.kind !== "present") return r.kind;
2273
2273
  let i = await t.readAuthBrowserTransactionActivity({ binderHash: r.cookieHash }, n);
2274
2274
  return i.kind === "rejected" ? "invalid" : i.kind;
@@ -2318,26 +2318,26 @@ async function Ji(e) {
2318
2318
  ]), r = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(n));
2319
2319
  return Array.from(new Uint8Array(r), (e) => e.toString(16).padStart(2, "0")).join("");
2320
2320
  }
2321
- async function Yi(e, t, n) {
2322
- let r = d(t);
2323
- if (!r || await he(e.public_key) !== e.key_id) return null;
2324
- let i = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e.public_key));
2325
- if (Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("") !== e.fingerprint) return null;
2326
- let a = await T(r), o = qi(e, t);
2327
- if (!await Xi(e.public_key, o, n)) return null;
2328
- let s = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(n));
2321
+ async function Yi(t, n, r) {
2322
+ let i = w(n);
2323
+ if (!i || await e(t.public_key) !== t.key_id) return null;
2324
+ let a = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t.public_key));
2325
+ if (Array.from(new Uint8Array(a), (e) => e.toString(16).padStart(2, "0")).join("") !== t.fingerprint) return null;
2326
+ let o = await b(i), s = qi(t, n);
2327
+ if (!await Xi(t.public_key, s, r)) return null;
2328
+ let c = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(r));
2329
2329
  return {
2330
- completionHash: a,
2331
- keyProofHash: Array.from(new Uint8Array(s), (e) => e.toString(16).padStart(2, "0")).join("")
2330
+ completionHash: o,
2331
+ keyProofHash: Array.from(new Uint8Array(c), (e) => e.toString(16).padStart(2, "0")).join("")
2332
2332
  };
2333
2333
  }
2334
2334
  async function Xi(e, t, n) {
2335
2335
  try {
2336
2336
  if (typeof n != "string" || !/^[A-Za-z0-9_-]{85}[AQgw]$/.test(n)) return !1;
2337
- let r = atob(`${n.replaceAll("-", "+").replaceAll("_", "/")}==`), i = Uint8Array.from(r, (e) => e.charCodeAt(0)), a = we(e);
2338
- if (a.kind !== "ed25519" || i.length !== 64) return !1;
2339
- let o = await globalThis.crypto.subtle.importKey("raw", new Uint8Array(a.blob.slice(19)), { name: "Ed25519" }, !1, ["verify"]);
2340
- return await globalThis.crypto.subtle.verify("Ed25519", o, i, new TextEncoder().encode(t));
2337
+ let r = atob(`${n.replaceAll("-", "+").replaceAll("_", "/")}==`), i = Uint8Array.from(r, (e) => e.charCodeAt(0)), o = a(e);
2338
+ if (o.kind !== "ed25519" || i.length !== 64) return !1;
2339
+ let s = await globalThis.crypto.subtle.importKey("raw", new Uint8Array(o.blob.slice(19)), { name: "Ed25519" }, !1, ["verify"]);
2340
+ return await globalThis.crypto.subtle.verify("Ed25519", s, i, new TextEncoder().encode(t));
2341
2341
  } catch {
2342
2342
  return !1;
2343
2343
  }
@@ -2432,12 +2432,12 @@ function sa(e, t, n) {
2432
2432
  e.confirmation_hash
2433
2433
  ].every((e) => typeof e == "string" && e.length > 0) && Number.isSafeInteger(n) && n >= e.created_at_ms && n < e.expires_at_ms && t === e.auth_config_revision;
2434
2434
  }
2435
- async function ca(e, t) {
2436
- if (!sa(e, t.revision, t.now) || await aa(e) !== e.confirmation_hash) return null;
2437
- let n = d(t.completionSecret);
2438
- if (!n || await T(n) !== e.completion_secret_hash || await he(e.public_key) !== e.key_id || await ia(e.public_key) !== e.fingerprint) return null;
2439
- let r = oa(e, t.completionSecret);
2440
- return await Xi(e.public_key, r, t.signature) ? { keyProofHash: await ia(t.signature) } : null;
2435
+ async function ca(t, n) {
2436
+ if (!sa(t, n.revision, n.now) || await aa(t) !== t.confirmation_hash) return null;
2437
+ let r = w(n.completionSecret);
2438
+ if (!r || await b(r) !== t.completion_secret_hash || await e(t.public_key) !== t.key_id || await ia(t.public_key) !== t.fingerprint) return null;
2439
+ let i = oa(t, n.completionSecret);
2440
+ return await Xi(t.public_key, i, n.signature) ? { keyProofHash: await ia(n.signature) } : null;
2441
2441
  }
2442
2442
  var la = 864e5, ua = "coordinator_device_rebind_attempts", da = 500;
2443
2443
  async function fa(e, t) {
@@ -2469,8 +2469,8 @@ async function ma(e, t) {
2469
2469
  }
2470
2470
  return !0;
2471
2471
  }
2472
- async function ha(e, t) {
2473
- return Ne(e).kind === "malformed_ed25519" ? null : await Ee(e) === t;
2472
+ async function ha(e, r) {
2473
+ return t(e).kind === "malformed_ed25519" ? null : await n(e) === r;
2474
2474
  }
2475
2475
  var ga = "NOT EXISTS (SELECT 1 FROM coordinator_auth_device_claims d\n WHERE d.coordinator_id = a.coordinator_id AND d.identity_id = a.current_identity_id\n AND d.device_id = a.device_id AND d.key_id = a.key_id\n AND EXISTS (SELECT 1 FROM groups g WHERE g.group_id = d.group_id AND g.archived_at IS NULL))\n AND NOT EXISTS (SELECT 1 FROM coordinator_auth_controller_attestations t\n JOIN enrolled_devices e ON e.group_id = t.group_id AND e.device_id = t.device_id\n AND e.public_key = t.public_key AND e.fingerprint = t.fingerprint AND e.enabled = 1\n AND (e.identity_id IS NULL OR e.identity_id = t.identity_id)\n JOIN groups g ON g.group_id = t.group_id AND g.archived_at IS NULL\n WHERE t.coordinator_id = a.coordinator_id AND t.identity_id = a.current_identity_id\n AND t.device_id = a.device_id AND t.public_key = a.public_key AND t.fingerprint = a.fingerprint\n AND t.revoked_at IS NULL)";
2476
2476
  function _a(e, t, n, r) {
@@ -2539,7 +2539,7 @@ async function ya(e, t) {
2539
2539
  async function ba(e, t, n) {
2540
2540
  let r = [...n];
2541
2541
  return await ya(e, "coordinator_legacy_owner_resolutions") && r.push(va), await ya(e, "coordinator_headless_link_provenance") && r.push({
2542
- sql: de,
2542
+ sql: c,
2543
2543
  values: []
2544
2544
  }), {
2545
2545
  sql: `WITH rebind_guards AS MATERIALIZED (SELECT ${r.map((e, t) => `(${e.sql}) AS g${t}`).join(",\n ")}
@@ -2674,8 +2674,8 @@ async function Ea(e) {
2674
2674
  } : { kind: "refused" };
2675
2675
  }
2676
2676
  async function Da(e, t, n) {
2677
- let r = d(n.completionSecret);
2678
- if (!r || await T(r) !== t.completion_secret_hash) return { kind: "refused" };
2677
+ let r = w(n.completionSecret);
2678
+ if (!r || await b(r) !== t.completion_secret_hash) return { kind: "refused" };
2679
2679
  let i = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(n.signature));
2680
2680
  if (Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("") !== t.final_key_proof_hash) return { kind: "refused" };
2681
2681
  let a = await Ta(e, t.coordinator_id, t.attempt_id);
@@ -2698,8 +2698,8 @@ async function ja(e) {
2698
2698
  return Array.from(new Uint8Array(t), (e) => e.toString(16).padStart(2, "0")).join("");
2699
2699
  }
2700
2700
  async function Ma(e) {
2701
- let t = d(e);
2702
- return t ? T(t) : null;
2701
+ let t = w(e);
2702
+ return t ? b(t) : null;
2703
2703
  }
2704
2704
  function Na() {
2705
2705
  let e = globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32));
@@ -2803,19 +2803,19 @@ async function Xa(e, t, n) {
2803
2803
  });
2804
2804
  return r?.enrolled === 1 ? r.bound === 1 ? "device_already_bound" : r.linked === 1 && r.proof === 1 ? "current_identity_linked" : null : "unavailable";
2805
2805
  }
2806
- async function Za(e, t, n) {
2807
- if (!e.deps.limiter.check(JSON.stringify([
2806
+ async function Za(t, n, r) {
2807
+ if (!t.deps.limiter.check(JSON.stringify([
2808
2808
  "device-rebind-start",
2809
- e.c.coordinatorId,
2810
- n
2809
+ t.c.coordinatorId,
2810
+ r
2811
2811
  ]), Aa).allowed) return N("retry");
2812
- if (!w(t.attemptId) || !w(t.currentIdentityId) || !/^[0-9a-f]{64}$/.test(t.reviewDigest) || !/^[0-9a-f]{64}$/.test(t.browserStartHash) || !h(t.loopbackRedirect).ok) return N("unavailable");
2813
- let r = t.browserStartHash, i = await he(t.signer.publicKey);
2814
- if (!i) return N("unavailable");
2815
- let a = await Xa(e, t, i);
2816
- if (a) return N(a);
2817
- let o = e.deps.now(), s = t.signer;
2818
- return await e.deps.backend.run({
2812
+ if (!T(n.attemptId) || !T(n.currentIdentityId) || !/^[0-9a-f]{64}$/.test(n.reviewDigest) || !/^[0-9a-f]{64}$/.test(n.browserStartHash) || !S(n.loopbackRedirect).ok) return N("unavailable");
2813
+ let i = n.browserStartHash, a = await e(n.signer.publicKey);
2814
+ if (!a) return N("unavailable");
2815
+ let o = await Xa(t, n, a);
2816
+ if (o) return N(o);
2817
+ let s = t.deps.now(), c = n.signer;
2818
+ return await t.deps.backend.run({
2819
2819
  sql: `INSERT INTO ${M} (coordinator_id, attempt_id, origin, device_id, public_key, key_id,
2820
2820
  fingerprint, current_identity_id, issuer, auth_config_revision, loopback_redirect, browser_start_hash,
2821
2821
  review_digest, state, created_at_ms, expires_at_ms)
@@ -2839,35 +2839,35 @@ async function Za(e, t, n) {
2839
2839
  AND (SELECT count(*) FROM ${M} o WHERE o.coordinator_id = a.coordinator_id AND o.device_id = a.device_id
2840
2840
  AND o.created_at_ms > ?) < ?`,
2841
2841
  values: [
2842
- e.c.coordinatorId,
2843
- t.attemptId,
2844
- e.deps.publicOrigin,
2845
- s.deviceId,
2846
- s.publicKey,
2842
+ t.c.coordinatorId,
2843
+ n.attemptId,
2844
+ t.deps.publicOrigin,
2845
+ c.deviceId,
2846
+ c.publicKey,
2847
+ a,
2848
+ c.fingerprint,
2849
+ n.currentIdentityId,
2850
+ t.c.issuer,
2851
+ t.c.revision,
2852
+ n.loopbackRedirect,
2847
2853
  i,
2848
- s.fingerprint,
2849
- t.currentIdentityId,
2850
- e.c.issuer,
2851
- e.c.revision,
2852
- t.loopbackRedirect,
2853
- r,
2854
- t.reviewDigest,
2855
- o,
2856
- o + ka,
2857
- s.groupId,
2858
- o,
2854
+ n.reviewDigest,
2855
+ s,
2856
+ s + ka,
2857
+ c.groupId,
2858
+ s,
2859
2859
  2,
2860
- o - 36e5,
2860
+ s - 36e5,
2861
2861
  6
2862
2862
  ]
2863
2863
  }) === 1 ? {
2864
2864
  kind: "started",
2865
- attemptId: t.attemptId,
2866
- expiresAtMs: o + ka
2865
+ attemptId: n.attemptId,
2866
+ expiresAtMs: s + ka
2867
2867
  } : N("unavailable");
2868
2868
  }
2869
2869
  async function Qa(e, t, n) {
2870
- let r = Hi(t), i = await Ui(r.cookie, new Fe(e.deps.backend, e.deps.now), e.c);
2870
+ let r = Hi(t), i = await Ui(r.cookie, new o(e.deps.backend, e.deps.now), e.c);
2871
2871
  if (i === "active" || i === "invalid") return N("unavailable");
2872
2872
  let a = await Li({
2873
2873
  request: t,
@@ -2878,25 +2878,25 @@ async function Qa(e, t, n) {
2878
2878
  limiter: e.deps.limiter
2879
2879
  });
2880
2880
  if (!a.ok || a.action !== "link_start") return N("unavailable");
2881
- let o = await v(r.cookie, "start");
2882
- if (o.kind !== "present" || o.cookieHash !== a.cookieHash) return N("unavailable");
2883
- let s = await P(e, a.attemptId);
2884
- if (s?.state !== "pending" || s.expires_at_ms <= e.deps.now() || s.browser_start_hash !== await Ma(a.startCode)) return N("unavailable");
2881
+ let s = await g(r.cookie, "start");
2882
+ if (s.kind !== "present" || s.cookieHash !== a.cookieHash) return N("unavailable");
2883
+ let c = await P(e, a.attemptId);
2884
+ if (c?.state !== "pending" || c.expires_at_ms <= e.deps.now() || c.browser_start_hash !== await Ma(a.startCode)) return N("unavailable");
2885
2885
  let l = await e.deps.client.createAuthorizationRequest(), u = new URL(l.authorizationUrl);
2886
2886
  u.searchParams.set("prompt", "select_account");
2887
- let d = e.deps.now(), f = await T(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))), p = await ja(l.material.state);
2888
- await e.deps.backend.batch($a(e, s, l.material, {
2887
+ let d = e.deps.now(), p = await b(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))), m = await ja(l.material.state);
2888
+ await e.deps.backend.batch($a(e, c, l.material, {
2889
2889
  time: d,
2890
- transactionHash: f,
2891
- stateHash: p,
2890
+ transactionHash: p,
2891
+ stateHash: m,
2892
2892
  binderHash: a.cookieHash
2893
2893
  }));
2894
- let m = await P(e, s.attempt_id);
2895
- if (m?.state !== "browser_claimed" || m.browser_transaction_hash !== f) throw Error("device_rebind_claim_unconfirmed");
2894
+ let h = await P(e, c.attempt_id);
2895
+ if (h?.state !== "browser_claimed" || h.browser_transaction_hash !== p) throw Error("device_rebind_claim_unconfirmed");
2896
2896
  return {
2897
2897
  kind: "browser_claimed",
2898
2898
  authorizationUrl: u.href,
2899
- setCookies: [re(o.secret), c("start")]
2899
+ setCookies: [f(s.secret), ze("start")]
2900
2900
  };
2901
2901
  }
2902
2902
  function $a(e, t, n, r) {
@@ -2960,7 +2960,7 @@ async function to(e, t) {
2960
2960
  async function no(e, t) {
2961
2961
  let n = Hi(t), r = eo(e, n);
2962
2962
  if (!r) return null;
2963
- let i = await v(n.cookie, "transaction");
2963
+ let i = await g(n.cookie, "transaction");
2964
2964
  if (i.kind !== "present") return null;
2965
2965
  let a = e.deps.now(), o = await e.deps.backend.first({
2966
2966
  sql: `SELECT b.* FROM coordinator_auth_browser_transactions b JOIN ${M} a
@@ -3011,7 +3011,7 @@ async function ro(e, { snapshot: t, state: n, cookie: r, txn: i, time: a }) {
3011
3011
  let c = await ao(e, i.attempt_id, s.account, o);
3012
3012
  if (c.kind === "refused") return io(e, i.attempt_id, c.reason);
3013
3013
  if (c.kind !== "verified") return c;
3014
- let l = await xe(e.deps.csrfKey, r.secret, "transaction", e.scope);
3014
+ let l = await he(e.deps.csrfKey, r.secret, "transaction", e.scope);
3015
3015
  return {
3016
3016
  kind: "verified",
3017
3017
  confirmation: c.confirmation,
@@ -3030,20 +3030,20 @@ async function io(e, t, n) {
3030
3030
  ...i ? { returnTo: i } : {}
3031
3031
  };
3032
3032
  }
3033
- async function ao(t, n, r, i) {
3034
- let a = await P(t, n), o = await t.deps.backend.first({
3035
- sql: `SELECT link_id, identity_id, authority_kind, ${le} AS headless_capable
3033
+ async function ao(e, t, n, r) {
3034
+ let i = await P(e, t), a = await e.deps.backend.first({
3035
+ sql: `SELECT link_id, identity_id, authority_kind, ${Ue} AS headless_capable
3036
3036
  FROM coordinator_auth_account_links
3037
3037
  WHERE coordinator_id = ? AND issuer = ? AND subject = ? AND revoked_at_ms IS NULL`,
3038
3038
  values: [
3039
- t.c.coordinatorId,
3040
- r.issuer,
3041
- r.subject
3039
+ e.c.coordinatorId,
3040
+ n.issuer,
3041
+ n.subject
3042
3042
  ]
3043
3043
  });
3044
- if (!a) return N("unavailable");
3045
- if (!o) return N("account_not_linked");
3046
- let s = o.headless_capable === 1, c = t.deps.now(), l = await t.deps.backend.run({
3044
+ if (!i) return N("unavailable");
3045
+ if (!a) return N("account_not_linked");
3046
+ let o = a.headless_capable === 1, s = e.deps.now(), c = await e.deps.backend.run({
3047
3047
  sql: `UPDATE ${M} AS a SET state = 'oidc_verified', account_subject = ?, target_identity_id = ?,
3048
3048
  link_id = ?, link_authority_kind = ?,
3049
3049
  enrollment_count = (SELECT count(*) FROM enrolled_devices e WHERE e.device_id = a.device_id),
@@ -3054,29 +3054,29 @@ async function ao(t, n, r, i) {
3054
3054
  AND l.link_id = ? AND l.identity_id = ? AND l.issuer = a.issuer AND l.subject = ? AND l.revoked_at_ms IS NULL)
3055
3055
  AND EXISTS (SELECT 1 FROM coordinator_auth_browser_transactions b WHERE b.coordinator_id = a.coordinator_id
3056
3056
  AND b.browser_transaction_hash = a.browser_transaction_hash AND b.state = 'consumed' AND b.claim_token = ?)
3057
- AND (? = a.current_identity_id OR ${Ia})${s ? ` AND NOT ${te("a.coordinator_id")}` : ""}`,
3057
+ AND (? = a.current_identity_id OR ${Ia})${o ? ` AND NOT ${le("a.coordinator_id")}` : ""}`,
3058
3058
  values: [
3059
- r.subject,
3060
- o.identity_id,
3061
- o.link_id,
3062
- o.authority_kind,
3063
- o.identity_id,
3064
- ...Wa(t, c, n),
3065
- o.link_id,
3066
- o.identity_id,
3067
- r.subject,
3068
- i,
3069
- o.identity_id,
3070
- ...s ? [o.link_id] : []
3059
+ n.subject,
3060
+ a.identity_id,
3061
+ a.link_id,
3062
+ a.authority_kind,
3063
+ a.identity_id,
3064
+ ...Wa(e, s, t),
3065
+ a.link_id,
3066
+ a.identity_id,
3067
+ n.subject,
3068
+ r,
3069
+ a.identity_id,
3070
+ ...o ? [a.link_id] : []
3071
3071
  ]
3072
3072
  });
3073
- if (l !== 1 && s && await e(t.deps.backend, t.c.coordinatorId, o.link_id)) return N("target_headless_linked");
3074
- if (l !== 1) return N(await oo(t, a, o.identity_id));
3075
- let u = await P(t, n);
3076
- if (u?.state !== "oidc_verified" || u.link_id !== o.link_id) throw Error("device_rebind_verify_unconfirmed");
3073
+ if (c !== 1 && o && await y(e.deps.backend, e.c.coordinatorId, a.link_id)) return N("target_headless_linked");
3074
+ if (c !== 1) return N(await oo(e, i, a.identity_id));
3075
+ let l = await P(e, t);
3076
+ if (l?.state !== "oidc_verified" || l.link_id !== a.link_id) throw Error("device_rebind_verify_unconfirmed");
3077
3077
  return {
3078
3078
  kind: "verified",
3079
- confirmation: await so(u),
3079
+ confirmation: await so(l),
3080
3080
  csrf: ""
3081
3081
  };
3082
3082
  }
@@ -3118,7 +3118,7 @@ async function co(e, t, n, r) {
3118
3118
  limiter: e.deps.limiter
3119
3119
  });
3120
3120
  if (!a.ok || a.action !== "transaction_attempt") return N("unavailable");
3121
- let o = await v(i.cookie, "transaction");
3121
+ let o = await g(i.cookie, "transaction");
3122
3122
  if (o.kind !== "present" || o.cookieHash !== a.cookieHash) return N("unavailable");
3123
3123
  let s = await P(e, a.attemptId);
3124
3124
  if (s?.state !== "oidc_verified" || s.browser_binder_hash !== o.cookieHash) return N("unavailable");
@@ -3170,26 +3170,26 @@ async function lo(e, t) {
3170
3170
  receipt: r.receipt
3171
3171
  } : N(await uo(e, t, n));
3172
3172
  }
3173
- async function uo(t, n, r) {
3174
- let i = await P(t, n.attemptId), a = t.deps.now();
3175
- if (i?.state !== "confirmed" || i.expires_at_ms <= a) return oo(t, r);
3176
- if (!await ca(i, {
3177
- revision: t.c.revision,
3178
- now: a,
3179
- completionSecret: n.completionSecret,
3180
- signature: n.signature
3173
+ async function uo(e, t, n) {
3174
+ let r = await P(e, t.attemptId), i = e.deps.now();
3175
+ if (r?.state !== "confirmed" || r.expires_at_ms <= i) return oo(e, n);
3176
+ if (!await ca(r, {
3177
+ revision: e.c.revision,
3178
+ now: i,
3179
+ completionSecret: t.completionSecret,
3180
+ signature: t.signature
3181
3181
  })) return "unavailable";
3182
- if (i.link_id && await e(t.deps.backend, t.c.coordinatorId, i.link_id)) return "target_headless_linked";
3183
- if (((await t.deps.backend.first({
3182
+ if (r.link_id && await y(e.deps.backend, e.c.coordinatorId, r.link_id)) return "target_headless_linked";
3183
+ if (((await e.deps.backend.first({
3184
3184
  sql: "SELECT count(*) AS n FROM coordinator_device_rebind_audit_log\n WHERE coordinator_id = ? AND target_identity_id = ? AND created_at_ms > ?",
3185
3185
  values: [
3186
- t.c.coordinatorId,
3187
- i.target_identity_id,
3188
- a - 864e5
3186
+ e.c.coordinatorId,
3187
+ r.target_identity_id,
3188
+ i - 864e5
3189
3189
  ]
3190
3190
  }))?.n ?? 0) >= 3) return "daily_limit";
3191
- let o = await oo(t, r);
3192
- return o === "unavailable" ? fo(t, i) : o;
3191
+ let a = await oo(e, n);
3192
+ return a === "unavailable" ? fo(e, r) : a;
3193
3193
  }
3194
3194
  async function fo(e, t) {
3195
3195
  let n = await e.deps.backend.first({
@@ -3398,7 +3398,7 @@ async function Do(e, t, n) {
3398
3398
  } : Eo(e);
3399
3399
  }
3400
3400
  function Oo(e, t, n) {
3401
- return !w(n) || !w(e.group_id) ? !1 : t === "finalize" ? d(e.completion) !== null && e.signature.length <= 512 : t === "status" || w(e.identity_id) && Co(e.browser_start_hash) && Co(e.review_digest);
3401
+ return !T(n) || !T(e.group_id) ? !1 : t === "finalize" ? w(e.completion) !== null && e.signature.length <= 512 : t === "status" || T(e.identity_id) && Co(e.browser_start_hash) && Co(e.review_digest);
3402
3402
  }
3403
3403
  function ko(e) {
3404
3404
  return {
@@ -3582,7 +3582,7 @@ function Go(e, t) {
3582
3582
  "device_id",
3583
3583
  "expected_digest"
3584
3584
  ] : ["group_id", "device_id"], i = Object.keys(n);
3585
- if (i.length !== r.length || i.some((e) => !r.includes(e)) || !("group_id" in n) || !("device_id" in n) || !w(n.group_id) || !w(n.device_id)) return null;
3585
+ if (i.length !== r.length || i.some((e) => !r.includes(e)) || !("group_id" in n) || !("device_id" in n) || !T(n.group_id) || !T(n.device_id)) return null;
3586
3586
  let a = {
3587
3587
  group_id: n.group_id,
3588
3588
  device_id: n.device_id
@@ -3645,39 +3645,39 @@ function Yo(e, t, n) {
3645
3645
  }
3646
3646
  return r;
3647
3647
  }
3648
- async function Xo(e, t, n, r) {
3649
- let i = await t.getEnrollment(r.group_id, r.device_id, !0);
3650
- if (!i) return F("revocation_target_unavailable", 409);
3651
- let a = Object.freeze({
3652
- groupId: i.group_id,
3653
- deviceId: i.device_id,
3654
- publicKey: i.public_key,
3655
- fingerprint: i.fingerprint
3648
+ async function Xo(t, n, r, i) {
3649
+ let a = await n.getEnrollment(i.group_id, i.device_id, !0);
3650
+ if (!a) return F("revocation_target_unavailable", 409);
3651
+ let o = Object.freeze({
3652
+ groupId: a.group_id,
3653
+ deviceId: a.device_id,
3654
+ publicKey: a.public_key,
3655
+ fingerprint: a.fingerprint
3656
3656
  });
3657
- if (a.groupId !== r.group_id || a.deviceId !== r.device_id || typeof a.publicKey != "string" || !Ko(a.publicKey) || typeof a.fingerprint != "string" || !a.fingerprint || a.fingerprint.includes("\0")) return F("revocation_target_unavailable", 409);
3658
- let o = await he(a.publicKey);
3659
- if (!o) return F("revocation_target_unavailable", 409);
3660
- let s = await qo(n, a, o), c = {
3657
+ if (o.groupId !== i.group_id || o.deviceId !== i.device_id || typeof o.publicKey != "string" || !Ko(o.publicKey) || typeof o.fingerprint != "string" || !o.fingerprint || o.fingerprint.includes("\0")) return F("revocation_target_unavailable", 409);
3658
+ let s = await e(o.publicKey);
3659
+ if (!s) return F("revocation_target_unavailable", 409);
3660
+ let c = await qo(r, o, s), l = {
3661
3661
  version: 1,
3662
- coordinator_id: n,
3663
- group_id: a.groupId,
3664
- device_id: a.deviceId,
3665
- key_id: o,
3662
+ coordinator_id: r,
3663
+ group_id: o.groupId,
3664
+ device_id: o.deviceId,
3665
+ key_id: s,
3666
3666
  scope: Ro
3667
3667
  };
3668
- if (e === "preview") return zo({
3668
+ if (t === "preview") return zo({
3669
3669
  state: "ready",
3670
- ...c,
3671
- expected_digest: s
3670
+ ...l,
3671
+ expected_digest: c
3672
3672
  });
3673
- if (r.expected_digest !== s) return F("revocation_preview_stale", 409);
3674
- let l = await t.createDeviceRevocation(a);
3675
- if (l?.kind === "rejected" && l.error === "enrollment_mismatch") return F("revocation_preview_stale", 409);
3676
- let u = Yo(l, a.deviceId, o);
3677
- return u ? zo({
3673
+ if (i.expected_digest !== c) return F("revocation_preview_stale", 409);
3674
+ let u = await n.createDeviceRevocation(o);
3675
+ if (u?.kind === "rejected" && u.error === "enrollment_mismatch") return F("revocation_preview_stale", 409);
3676
+ let d = Yo(u, o.deviceId, s);
3677
+ return d ? zo({
3678
3678
  state: "revoked",
3679
- ...c,
3680
- revocations: u
3679
+ ...l,
3680
+ revocations: d
3681
3681
  }) : F("device_revocation_incomplete", 503);
3682
3682
  }
3683
3683
  function Zo(e) {
@@ -3691,7 +3691,7 @@ function Zo(e) {
3691
3691
  let { store: r, trustedCoordinatorId: i, adminSecret: a } = t;
3692
3692
  try {
3693
3693
  if (!await Ho(n.headers.get("X-Codemem-Coordinator-Admin"), a)) return F("unauthorized", 401);
3694
- if (!w(i) || !r) return F("revocation_unavailable", 503);
3694
+ if (!T(i) || !r) return F("revocation_unavailable", 503);
3695
3695
  if (!Io(e)) return F("revocation_invalid_input", 400);
3696
3696
  let o = t.beforeBody?.(n);
3697
3697
  if (o) return o;
@@ -3729,7 +3729,7 @@ function $o(e) {
3729
3729
  return null;
3730
3730
  }
3731
3731
  function es(e, t) {
3732
- let n = t.context?.coordinatorId, r = w(n) && t.configuredCoordinatorIds.every((e) => e === n) ? n : null, i = t.storeFactory, a = t.adminSecret, o = t.rateLimitedResponse;
3732
+ let n = t.context?.coordinatorId, r = T(n) && t.configuredCoordinatorIds.every((e) => e === n) ? n : null, i = t.storeFactory, a = t.adminSecret, o = t.rateLimitedResponse;
3733
3733
  for (let [t, n] of [["/v1/admin/devices/revoke-preview", "preview"], ["/v1/admin/devices/revoke", "commit"]]) e.all(t, async (e) => {
3734
3734
  let t;
3735
3735
  try {
@@ -4120,7 +4120,7 @@ function Bs(e) {
4120
4120
  function Vs(e) {
4121
4121
  if (!Rs(e)) return null;
4122
4122
  let { group_id: t, device_id: n, public_key: r, fingerprint: i, identity_id: a, enabled: o } = e;
4123
- return !Bs(t) || !zs(n) || typeof r != "string" || typeof i != "string" || a !== null && typeof a != "string" || o !== 1 ? null : (Ue(r), Object.freeze({
4123
+ return !Bs(t) || !zs(n) || typeof r != "string" || typeof i != "string" || a !== null && typeof a != "string" || o !== 1 ? null : (We(r), Object.freeze({
4124
4124
  group_id: t,
4125
4125
  device_id: n,
4126
4126
  public_key: r,
@@ -4148,11 +4148,11 @@ async function Us(e, t) {
4148
4148
  if (!n) return null;
4149
4149
  let r = Object.freeze({
4150
4150
  ...n.source,
4151
- keyId: await We(n.source.public_key)
4151
+ keyId: await Ge(n.source.public_key)
4152
4152
  }), i = null;
4153
4153
  return n.target && (i = Object.freeze({
4154
4154
  ...n.target,
4155
- keyId: await We(n.target.public_key)
4155
+ keyId: await Ge(n.target.public_key)
4156
4156
  })), Object.freeze({
4157
4157
  source: r,
4158
4158
  target: i
@@ -4175,10 +4175,10 @@ function Gs(e) {
4175
4175
  let { kind: t, value: n, bodyBytes: r, timestamp: i, nonce: a, signatureBytes: o } = e;
4176
4176
  if (!(r instanceof Uint8Array) || !(o instanceof Uint8Array)) return null;
4177
4177
  let s = new Uint8Array(r), c = new Uint8Array(o), l;
4178
- if (t === "admission") l = Je({ ...n });
4179
- else if (t === "registration") l = Qe({ ...n });
4178
+ if (t === "admission") l = Ye({ ...n });
4179
+ else if (t === "registration") l = $e({ ...n });
4180
4180
  else return null;
4181
- return l.length !== s.length || !l.every((e, t) => e === s[t]) ? null : Ye(qe({
4181
+ return l.length !== s.length || !l.every((e, t) => e === s[t]) ? null : Xe(Je({
4182
4182
  bodyBytes: s,
4183
4183
  timestamp: i,
4184
4184
  nonce: a,
@@ -4296,7 +4296,7 @@ function nc(e, t) {
4296
4296
  attemptId: t.attemptId,
4297
4297
  decidedAtMs: t.decidedAtMs,
4298
4298
  createdAt: t.createdAt
4299
- }, d = Ke({
4299
+ }, d = qe({
4300
4300
  deviceId: n,
4301
4301
  nonce: r,
4302
4302
  attemptId: i,
@@ -4385,14 +4385,14 @@ function uc(e, t) {
4385
4385
  authorityId: o.authorityId,
4386
4386
  groupId: o.groupId,
4387
4387
  relayAudienceId: o.relayAudienceId
4388
- }), u = Ye(n);
4388
+ }), u = Xe(n);
4389
4389
  if (!lc(u, l, c)) return null;
4390
4390
  let d, f;
4391
4391
  if (u.kind === "admission" ? (d = u.value.sourceDeviceId, f = u.value.targetDeviceId) : d = u.value.deviceId, i !== d || !sc(a) || typeof s != "string" || s.length === 0) return null;
4392
4392
  let p = cc(t);
4393
4393
  return p ? {
4394
4394
  check: u,
4395
- packet: Object.freeze(qe(u)),
4395
+ packet: Object.freeze(Je(u)),
4396
4396
  expected: c,
4397
4397
  namespace: l,
4398
4398
  deviceHeader: i,
@@ -4444,7 +4444,7 @@ function pc(e) {
4444
4444
  }
4445
4445
  function mc(e, t, n, r, i) {
4446
4446
  if (!n || n.policyRevision !== i) return null;
4447
- let a = Ke(n, r);
4447
+ let a = qe(n, r);
4448
4448
  if (!a || !dc(e.check, a.decidedAtMs)) return null;
4449
4449
  let o = nc(n, a);
4450
4450
  if (!o) return null;
@@ -4461,7 +4461,7 @@ function mc(e, t, n, r, i) {
4461
4461
  kind: "registration",
4462
4462
  socketExpiresInMs: 9e5
4463
4463
  });
4464
- let c = $e(t.value, a.decidedAtMs);
4464
+ let c = et(t.value, a.decidedAtMs);
4465
4465
  return Object.freeze({
4466
4466
  ...s,
4467
4467
  kind: "admission",
@@ -4484,7 +4484,7 @@ async function hc(e, t) {
4484
4484
  targetDeviceId: n.targetDeviceId
4485
4485
  });
4486
4486
  if (!i) return null;
4487
- let a = await et({
4487
+ let a = await Ee({
4488
4488
  packet: n.packet,
4489
4489
  expected: n.expected,
4490
4490
  signer: {
@@ -4550,7 +4550,7 @@ function vc(e, t) {
4550
4550
  }
4551
4551
  function yc(e) {
4552
4552
  try {
4553
- let t = Ye(e), n = t.value.groupId;
4553
+ let t = Xe(e), n = t.value.groupId;
4554
4554
  return t.kind === "registration" ? {
4555
4555
  expected: { kind: "registration" },
4556
4556
  groupId: n
@@ -4608,7 +4608,7 @@ function Cc(e, t) {
4608
4608
  relayAudienceId: a
4609
4609
  };
4610
4610
  }
4611
- function wc(e = Ze(null), t = 200) {
4611
+ function wc(e = Qe(null), t = 200) {
4612
4612
  return new Response(new Uint8Array(e), {
4613
4613
  status: t,
4614
4614
  headers: {
@@ -4657,7 +4657,7 @@ async function Ec(e, t) {
4657
4657
  reserveIngress: async () => c
4658
4658
  }
4659
4659
  });
4660
- return wc(Ze(u));
4660
+ return wc(Qe(u));
4661
4661
  } finally {
4662
4662
  await o.close();
4663
4663
  }
@@ -4679,7 +4679,7 @@ function Oc(e, t) {
4679
4679
  function kc(e) {
4680
4680
  if (e === void 0) return null;
4681
4681
  try {
4682
- let { wireKey: t } = Ue(e);
4682
+ let { wireKey: t } = We(e);
4683
4683
  return `ssh-ed25519 ${btoa(String.fromCharCode(...t))}`;
4684
4684
  } catch {
4685
4685
  return null;
@@ -4700,7 +4700,7 @@ function jc(e) {
4700
4700
  return new Map([...n.values()].map(({ authorityId: n, groupId: r }) => [r, Object.freeze({
4701
4701
  group_id: r,
4702
4702
  service_public_key: t,
4703
- relay_path: `/v1/relay/${Xe(n, r)}`,
4703
+ relay_path: `/v1/relay/${Ze(n, r)}`,
4704
4704
  admission_path: e.externalPathname
4705
4705
  })]));
4706
4706
  } catch {
@@ -4781,11 +4781,11 @@ function Hc(e) {
4781
4781
  if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
4782
4782
  let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
4783
4783
  try {
4784
- a = S(i, "project_name");
4784
+ a = m(i, "project_name");
4785
4785
  } catch {
4786
4786
  throw Error("operation_intent_invalid");
4787
4787
  }
4788
- let o = t.existing_memory_count, s = Ge({ gitRemote: r }).value;
4788
+ let o = t.existing_memory_count, s = Ke({ gitRemote: r }).value;
4789
4789
  if (!r || r !== n || r.length > 2048 || r.startsWith("unmapped:") || s !== r || a !== i || !Number.isSafeInteger(o) || Number(o) < 0 || /[\p{Cc}\p{Cf}]/u.test(r) || /[\p{Cc}\p{Cf}]/u.test(a)) throw Error("operation_intent_invalid");
4790
4790
  return {
4791
4791
  canonical_identity: r,
@@ -4798,7 +4798,7 @@ function Hc(e) {
4798
4798
  }
4799
4799
  //#endregion
4800
4800
  //#region src/coordinator-api.ts
4801
- var Uc = 65536, Wc = n + 1024, I = "X-Codemem-Coordinator-Admin", Gc = "X-Codemem-Coordinator-Admin-Actor", Kc = 120, qc = 30;
4801
+ var Uc = 65536, Wc = Ie + 1024, I = "X-Codemem-Coordinator-Admin", Gc = "X-Codemem-Coordinator-Admin-Actor", Kc = 120, qc = 30;
4802
4802
  function Jc(e) {
4803
4803
  return e === "device_revoked" ? 403 : e === "invite_expired" ? 410 : e === "invite_invalid" ? 404 : 409;
4804
4804
  }
@@ -4816,7 +4816,7 @@ function Yc() {
4816
4816
  function Xc(e, t) {
4817
4817
  let n = e.browserAuth?.kind === "ready" ? e.browserAuth : void 0, r = n?.auth.storeConfig ?? e.authLink?.config, i = e.recipientInviteCoordinatorId;
4818
4818
  if (i !== void 0) {
4819
- if (!w(i) || [n?.auth.storeConfig, e.authLink?.config].some((e) => e && e.coordinatorId !== i)) throw Error("device_ownership_authorization_unavailable");
4819
+ if (!T(i) || [n?.auth.storeConfig, e.authLink?.config].some((e) => e && e.coordinatorId !== i)) throw Error("device_ownership_authorization_unavailable");
4820
4820
  return {
4821
4821
  token: t,
4822
4822
  coordinatorId: i
@@ -4840,13 +4840,13 @@ function Zc(e) {
4840
4840
  if (t?.auth.resolveAccountChanges) return {
4841
4841
  config: t.auth.storeConfig,
4842
4842
  storeFactory: t.storeFactory,
4843
- assertReady: _e,
4843
+ assertReady: pe,
4844
4844
  operationsFactory: t.auth.resolveAccountChanges
4845
4845
  };
4846
4846
  }
4847
4847
  function Qc(e, t, n) {
4848
4848
  if (t.authLink && t.browserAuth) throw Error("coordinator_auth_configuration_conflict");
4849
- let r = Zc(t), i = t.browserAuth?.kind === "unavailable" && t.browserAuth.error === "coordinator_auth_schema_upgrade_required" ? Le : Yc;
4849
+ let r = Zc(t), i = t.browserAuth?.kind === "unavailable" && t.browserAuth.error === "coordinator_auth_schema_upgrade_required" ? Fe : Yc;
4850
4850
  if (t.browserAuth?.kind !== "ready" && (e.all("/v1/auth/account-link-status", i), e.all("/v1/auth/resolved-account-owner-status", i), e.all("/v1/auth/resolved-account-owner-receipt-status", i)), t.browserAuth?.kind === "unavailable") {
4851
4851
  for (let t of [
4852
4852
  "/auth/*",
@@ -5199,39 +5199,39 @@ function xl(e, t, n) {
5199
5199
  }
5200
5200
  function Sl(e) {
5201
5201
  if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
5202
- let n = e.runtime, r = e.storeFactory, a = e.requestVerifier, o = e.requestRateLimit ?? {}, s = o.limiter ?? bo(), c = Math.max(1, Math.trunc(o.readLimit ?? Kc)), l = Math.max(1, Math.trunc(o.mutationLimit ?? qc)), u = Math.max(1, Math.trunc(o.unauthenticatedReadLimit ?? Math.min(20, c))), d = Math.max(1, Math.trunc(o.unauthenticatedMutationLimit ?? Math.min(10, l))), p = hl(e.relayAdmission);
5203
- e.relayHealth?.install(p);
5204
- let m = new TextDecoder();
5205
- function h(e, t, n) {
5206
- let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = s.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? c : l : r ? u : d);
5202
+ let t = e.runtime, n = e.storeFactory, a = e.requestVerifier, o = e.requestRateLimit ?? {}, c = o.limiter ?? bo(), f = Math.max(1, Math.trunc(o.readLimit ?? Kc)), p = Math.max(1, Math.trunc(o.mutationLimit ?? qc)), m = Math.max(1, Math.trunc(o.unauthenticatedReadLimit ?? Math.min(20, f))), g = Math.max(1, Math.trunc(o.unauthenticatedMutationLimit ?? Math.min(10, p))), _ = hl(e.relayAdmission);
5203
+ e.relayHealth?.install(_);
5204
+ let v = new TextDecoder();
5205
+ function y(e, t, n) {
5206
+ let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = c.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? f : p : r ? m : g);
5207
5207
  return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
5208
5208
  error: "rate_limited",
5209
5209
  retry_after_s: i.retryAfterS
5210
5210
  }, 429));
5211
5211
  }
5212
- function g(e) {
5212
+ function b(e) {
5213
5213
  try {
5214
- let t = JSON.parse(m.decode(e));
5214
+ let t = JSON.parse(v.decode(e));
5215
5215
  return typeof t != "object" || !t || Array.isArray(t) ? null : t;
5216
5216
  } catch {
5217
5217
  return null;
5218
5218
  }
5219
5219
  }
5220
- el(p, e, {
5221
- authorizeRequest: (e, t) => rl(e, n, a, t),
5220
+ el(_, e, {
5221
+ authorizeRequest: (e, n) => rl(e, t, a, n),
5222
5222
  authErrorStatus: il,
5223
5223
  readRequestBytes: R,
5224
- parseJsonObject: g,
5225
- rateLimitedResponse: (e, t, n) => h(e, t, n.authenticated)
5224
+ parseJsonObject: b,
5225
+ rateLimitedResponse: (e, t, n) => y(e, t, n.authenticated)
5226
5226
  });
5227
- function v(e, t) {
5227
+ function x(e, t) {
5228
5228
  let n = e[t];
5229
5229
  return n == null ? null : String(n).trim() || null;
5230
5230
  }
5231
- function y(e) {
5231
+ function ee(e) {
5232
5232
  return e?.trim() || null;
5233
5233
  }
5234
- function b(e, t) {
5234
+ function S(e, t) {
5235
5235
  let n = e[t];
5236
5236
  if (n == null || n === "") return null;
5237
5237
  if (typeof n != "number" && typeof n != "string") return NaN;
@@ -5244,24 +5244,24 @@ function Sl(e) {
5244
5244
  let r = n;
5245
5245
  return Number.isFinite(r) ? Math.trunc(r) : NaN;
5246
5246
  }
5247
- function x(e) {
5247
+ function te(e) {
5248
5248
  return [
5249
5249
  "1",
5250
5250
  "true",
5251
5251
  "yes"
5252
5252
  ].includes(String(e ?? "").trim().toLowerCase());
5253
5253
  }
5254
- function S(e) {
5254
+ function ne(e) {
5255
5255
  try {
5256
5256
  return Hc(JSON.parse(e ?? ""));
5257
5257
  } catch {
5258
5258
  throw Error("operation_intent_invalid");
5259
5259
  }
5260
5260
  }
5261
- function te(e) {
5261
+ function C(e) {
5262
5262
  let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
5263
5263
  if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
5264
- let r = S(e.project_intent_json);
5264
+ let r = ne(e.project_intent_json);
5265
5265
  if (Vc(r) !== n) throw Error("operation_intent_invalid");
5266
5266
  return {
5267
5267
  operation_id: t,
@@ -5269,20 +5269,20 @@ function Sl(e) {
5269
5269
  projects: r
5270
5270
  };
5271
5271
  }
5272
- function re(e) {
5272
+ function ie(e) {
5273
5273
  try {
5274
- return Se(JSON.parse(e ?? ""));
5274
+ return u(JSON.parse(e ?? ""));
5275
5275
  } catch {
5276
5276
  throw Error("operation_intent_invalid");
5277
5277
  }
5278
5278
  }
5279
- async function C(e, t, n) {
5279
+ async function ae(e, t, n) {
5280
5280
  if (!t) return n.json({ error: "group_id_required" }, 400);
5281
5281
  let r = await e.getGroup(t);
5282
5282
  return r ? r.archived_at ? n.json({ error: "group_archived" }, 409) : null : n.json({ error: "group_not_found" }, 404);
5283
5283
  }
5284
- async function oe(e, t, n, r) {
5285
- let i = await C(e, t, r);
5284
+ async function w(e, t, n, r) {
5285
+ let i = await ae(e, t, r);
5286
5286
  if (i) return {
5287
5287
  scope: null,
5288
5288
  response: i
@@ -5303,29 +5303,29 @@ function Sl(e) {
5303
5303
  response: r.json({ error: "scope_not_found" }, 404)
5304
5304
  };
5305
5305
  }
5306
- return p.post("/v1/presence", async (e) => {
5307
- let t = await R(e);
5308
- if (t == null) return e.json({ error: "body_too_large" }, 413);
5309
- let i = g(t);
5306
+ return _.post("/v1/presence", async (e) => {
5307
+ let r = await R(e);
5308
+ if (r == null) return e.json({ error: "body_too_large" }, 413);
5309
+ let i = b(r);
5310
5310
  if (!i) return e.json({ error: "invalid_json" }, 400);
5311
5311
  let o = String(i.group_id ?? "").trim();
5312
5312
  if (!o) return e.json({ error: "group_id_required" }, 400);
5313
- let s = r();
5313
+ let s = n();
5314
5314
  try {
5315
- let r = await rl(s, n, a, {
5315
+ let n = await rl(s, t, a, {
5316
5316
  method: e.req.method,
5317
5317
  url: e.req.url,
5318
5318
  groupId: o,
5319
- body: t,
5319
+ body: r,
5320
5320
  deviceId: e.req.header("X-Opencode-Device") ?? null,
5321
5321
  signature: e.req.header("X-Opencode-Signature") ?? null,
5322
5322
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
5323
5323
  nonce: e.req.header("X-Opencode-Nonce") ?? null
5324
5324
  });
5325
- if (!r.ok || !r.enrollment) return h(e, e.req.path, !1) || e.json({ error: r.error }, il(r.error));
5326
- let c = h(e, String(r.enrollment.device_id), !0);
5325
+ if (!n.ok || !n.enrollment) return y(e, e.req.path, !1) || e.json({ error: n.error }, il(n.error));
5326
+ let c = y(e, String(n.enrollment.device_id), !0);
5327
5327
  if (c) return c;
5328
- if (i.fingerprint && String(i.fingerprint) !== String(r.enrollment.fingerprint)) return e.json({ error: "fingerprint_mismatch" }, 401);
5328
+ if (i.fingerprint && String(i.fingerprint) !== String(n.enrollment.fingerprint)) return e.json({ error: "fingerprint_mismatch" }, 401);
5329
5329
  let l = i.addresses ?? [];
5330
5330
  if (!Array.isArray(l) || !l.every((e) => typeof e == "string")) return e.json({ error: "addresses_must_be_list_of_strings" }, 400);
5331
5331
  let u;
@@ -5336,7 +5336,7 @@ function Sl(e) {
5336
5336
  }
5337
5337
  let d = await s.upsertPresence({
5338
5338
  groupId: o,
5339
- deviceId: String(r.enrollment.device_id),
5339
+ deviceId: String(n.enrollment.device_id),
5340
5340
  addresses: l,
5341
5341
  ttlS: u,
5342
5342
  capabilities: typeof i.capabilities == "object" && i.capabilities !== null && !Array.isArray(i.capabilities) ? i.capabilities : void 0
@@ -5348,47 +5348,47 @@ function Sl(e) {
5348
5348
  } finally {
5349
5349
  await s.close();
5350
5350
  }
5351
- }), p.get("/v1/peers", async (e) => {
5352
- let t = (e.req.query("group_id") ?? "").trim();
5353
- if (!t) return e.json({ error: "group_id_required" }, 400);
5354
- let i = r();
5351
+ }), _.get("/v1/peers", async (e) => {
5352
+ let r = (e.req.query("group_id") ?? "").trim();
5353
+ if (!r) return e.json({ error: "group_id_required" }, 400);
5354
+ let i = n();
5355
5355
  try {
5356
- let r = await rl(i, n, a, {
5356
+ let n = await rl(i, t, a, {
5357
5357
  method: e.req.method,
5358
5358
  url: e.req.url,
5359
- groupId: t,
5359
+ groupId: r,
5360
5360
  body: /* @__PURE__ */ new Uint8Array(),
5361
5361
  deviceId: e.req.header("X-Opencode-Device") ?? null,
5362
5362
  signature: e.req.header("X-Opencode-Signature") ?? null,
5363
5363
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
5364
5364
  nonce: e.req.header("X-Opencode-Nonce") ?? null
5365
5365
  });
5366
- return !r.ok || !r.enrollment ? h(e, e.req.path, !1) || e.json({ error: r.error }, il(r.error)) : h(e, String(r.enrollment.device_id), !0) || await ml(e, i, t, String(r.enrollment.device_id));
5366
+ return !n.ok || !n.enrollment ? y(e, e.req.path, !1) || e.json({ error: n.error }, il(n.error)) : y(e, String(n.enrollment.device_id), !0) || await ml(e, i, r, String(n.enrollment.device_id));
5367
5367
  } finally {
5368
5368
  await i.close();
5369
5369
  }
5370
- }), p.get("/v1/scopes", (t) => vl(t, e, h)), xl(p, e, h), p.get("/v1/reciprocal-approvals", async (e) => {
5371
- let t = (e.req.query("group_id") ?? "").trim(), i = (e.req.query("direction") ?? "incoming").trim(), o = (e.req.query("status") ?? "pending").trim() || "pending";
5372
- if (!t) return e.json({ error: "group_id_required" }, 400);
5370
+ }), _.get("/v1/scopes", (t) => vl(t, e, y)), xl(_, e, y), _.get("/v1/reciprocal-approvals", async (e) => {
5371
+ let r = (e.req.query("group_id") ?? "").trim(), i = (e.req.query("direction") ?? "incoming").trim(), o = (e.req.query("status") ?? "pending").trim() || "pending";
5372
+ if (!r) return e.json({ error: "group_id_required" }, 400);
5373
5373
  if (!["incoming", "outgoing"].includes(i)) return e.json({ error: "direction_must_be_incoming_or_outgoing" }, 400);
5374
- let s = r();
5374
+ let s = n();
5375
5375
  try {
5376
- let r = await rl(s, n, a, {
5376
+ let n = await rl(s, t, a, {
5377
5377
  method: e.req.method,
5378
5378
  url: e.req.url,
5379
- groupId: t,
5379
+ groupId: r,
5380
5380
  body: /* @__PURE__ */ new Uint8Array(),
5381
5381
  deviceId: e.req.header("X-Opencode-Device") ?? null,
5382
5382
  signature: e.req.header("X-Opencode-Signature") ?? null,
5383
5383
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
5384
5384
  nonce: e.req.header("X-Opencode-Nonce") ?? null
5385
5385
  });
5386
- if (!r.ok || !r.enrollment) return h(e, e.req.path, !1) ?? e.json({ error: r.error }, il(r.error));
5387
- let c = h(e, String(r.enrollment.device_id), !0);
5386
+ if (!n.ok || !n.enrollment) return y(e, e.req.path, !1) ?? e.json({ error: n.error }, il(n.error));
5387
+ let c = y(e, String(n.enrollment.device_id), !0);
5388
5388
  if (c) return c;
5389
5389
  let l = await s.listReciprocalApprovals({
5390
- groupId: t,
5391
- deviceId: String(r.enrollment.device_id),
5390
+ groupId: r,
5391
+ deviceId: String(n.enrollment.device_id),
5392
5392
  direction: i,
5393
5393
  status: o
5394
5394
  });
@@ -5396,52 +5396,52 @@ function Sl(e) {
5396
5396
  } finally {
5397
5397
  await s.close();
5398
5398
  }
5399
- }), p.post("/v1/reciprocal-approvals", async (e) => {
5400
- let i = await R(e);
5401
- if (i == null) return e.json({ error: "body_too_large" }, 413);
5402
- let o = g(i);
5403
- if (!o) return e.json({ error: "invalid_json" }, 400);
5404
- let s = String(o.group_id ?? "").trim(), c = String(o.requested_device_id ?? "").trim(), l = Object.hasOwn(o, "expected_incoming_request_id") ? String(o.expected_incoming_request_id ?? "").trim() : void 0;
5405
- if (!s || !c) return e.json({ error: "group_id_and_requested_device_id_required" }, 400);
5406
- let u = r();
5399
+ }), _.post("/v1/reciprocal-approvals", async (e) => {
5400
+ let r = await R(e);
5401
+ if (r == null) return e.json({ error: "body_too_large" }, 413);
5402
+ let i = b(r);
5403
+ if (!i) return e.json({ error: "invalid_json" }, 400);
5404
+ let o = String(i.group_id ?? "").trim(), s = String(i.requested_device_id ?? "").trim(), c = Object.hasOwn(i, "expected_incoming_request_id") ? String(i.expected_incoming_request_id ?? "").trim() : void 0;
5405
+ if (!o || !s) return e.json({ error: "group_id_and_requested_device_id_required" }, 400);
5406
+ let l = n();
5407
5407
  try {
5408
- let r = await rl(u, n, a, {
5408
+ let n = await rl(l, t, a, {
5409
5409
  method: e.req.method,
5410
5410
  url: e.req.url,
5411
- groupId: s,
5412
- body: i,
5411
+ groupId: o,
5412
+ body: r,
5413
5413
  deviceId: e.req.header("X-Opencode-Device") ?? null,
5414
5414
  signature: e.req.header("X-Opencode-Signature") ?? null,
5415
5415
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
5416
5416
  nonce: e.req.header("X-Opencode-Nonce") ?? null
5417
5417
  });
5418
- if (!r.ok || !r.enrollment) return h(e, e.req.path, !1) ?? e.json({ error: r.error }, il(r.error));
5419
- let o = h(e, String(r.enrollment.device_id), !0);
5420
- if (o) return o;
5421
- if (c === String(r.enrollment.device_id)) return e.json({ error: "requested_device_must_differ" }, 400);
5422
- if (!await u.getEnrollment(s, c)) return e.json({ error: "requested_device_not_found" }, 404);
5418
+ if (!n.ok || !n.enrollment) return y(e, e.req.path, !1) ?? e.json({ error: n.error }, il(n.error));
5419
+ let i = y(e, String(n.enrollment.device_id), !0);
5420
+ if (i) return i;
5421
+ if (s === String(n.enrollment.device_id)) return e.json({ error: "requested_device_must_differ" }, 400);
5422
+ if (!await l.getEnrollment(o, s)) return e.json({ error: "requested_device_not_found" }, 404);
5423
5423
  try {
5424
- let t = await u.createReciprocalApproval({
5425
- groupId: s,
5426
- requestingDeviceId: String(r.enrollment.device_id),
5427
- requestedDeviceId: c,
5428
- ...l === void 0 ? {} : { expectedIncomingRequestId: l }
5424
+ let t = await l.createReciprocalApproval({
5425
+ groupId: o,
5426
+ requestingDeviceId: String(n.enrollment.device_id),
5427
+ requestedDeviceId: s,
5428
+ ...c === void 0 ? {} : { expectedIncomingRequestId: c }
5429
5429
  });
5430
5430
  return e.json({
5431
5431
  ok: !0,
5432
5432
  request: t
5433
5433
  });
5434
- } catch (n) {
5435
- if (n instanceof t) return e.json({ error: n.code }, 409);
5436
- throw n;
5434
+ } catch (t) {
5435
+ if (t instanceof re) return e.json({ error: t.code }, 409);
5436
+ throw t;
5437
5437
  }
5438
5438
  } finally {
5439
- await u.close();
5439
+ await l.close();
5440
5440
  }
5441
- }), p.post("/v1/invites/add-device", async (e) => {
5442
- let t = await R(e);
5443
- if (t == null) return e.json({ error: "body_too_large" }, 413);
5444
- let i = g(t);
5441
+ }), _.post("/v1/invites/add-device", async (e) => {
5442
+ let r = await R(e);
5443
+ if (r == null) return e.json({ error: "body_too_large" }, 413);
5444
+ let i = b(r);
5445
5445
  if (!i) return e.json({ error: "invalid_json" }, 400);
5446
5446
  let o = /* @__PURE__ */ new Set([
5447
5447
  "group_id",
@@ -5455,26 +5455,26 @@ function Sl(e) {
5455
5455
  if (Number.isNaN(new Date(c).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
5456
5456
  if (!/^[a-f0-9]{64}$/u.test(l)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
5457
5457
  if (i.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
5458
- let u = r();
5458
+ let u = n();
5459
5459
  try {
5460
- let r = await rl(u, n, a, {
5460
+ let n = await rl(u, t, a, {
5461
5461
  method: e.req.method,
5462
5462
  url: e.req.url,
5463
5463
  groupId: s,
5464
- body: t,
5464
+ body: r,
5465
5465
  deviceId: e.req.header("X-Opencode-Device") ?? null,
5466
5466
  signature: e.req.header("X-Opencode-Signature") ?? null,
5467
5467
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
5468
5468
  nonce: e.req.header("X-Opencode-Nonce") ?? null
5469
5469
  });
5470
- if (!r.ok || !r.enrollment) return h(e, e.req.path, !1) ?? e.json({ error: r.error }, il(r.error));
5471
- let o = h(e, String(r.enrollment.device_id), !0);
5470
+ if (!n.ok || !n.enrollment) return y(e, e.req.path, !1) ?? e.json({ error: n.error }, il(n.error));
5471
+ let o = y(e, String(n.enrollment.device_id), !0);
5472
5472
  if (o) return o;
5473
- let d = r.enrollment.identity_id;
5473
+ let d = n.enrollment.identity_id;
5474
5474
  if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
5475
5475
  let f;
5476
5476
  try {
5477
- f = await ie(i.reviewed_intent, {
5477
+ f = await me(i.reviewed_intent, {
5478
5478
  target: {
5479
5479
  kind: "add_device",
5480
5480
  targetIdentityId: d
@@ -5482,14 +5482,14 @@ function Sl(e) {
5482
5482
  digest: l
5483
5483
  });
5484
5484
  } catch (t) {
5485
- return t instanceof fe && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
5485
+ return t instanceof ye && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
5486
5486
  }
5487
5487
  let p = await u.createInvite({
5488
5488
  groupId: s,
5489
5489
  policy: "auto_admit",
5490
5490
  expiresAt: c,
5491
5491
  createdBy: d,
5492
- inviterDeviceId: String(r.enrollment.device_id),
5492
+ inviterDeviceId: String(n.enrollment.device_id),
5493
5493
  inviteKind: "add_device",
5494
5494
  targetIdentityId: d,
5495
5495
  reviewedPreviewDigest: l,
@@ -5506,60 +5506,60 @@ function Sl(e) {
5506
5506
  target_identity_id: p.target_identity_id ?? void 0,
5507
5507
  inviter_device_id: p.inviter_device_id ?? void 0,
5508
5508
  reviewed_preview_digest: p.reviewed_preview_digest ?? void 0
5509
- }, g = as(m), { token: _, ...v } = p;
5509
+ }, h = as(m), { token: g, ..._ } = p;
5510
5510
  return e.json({
5511
5511
  ok: !0,
5512
- invite: v,
5512
+ invite: _,
5513
5513
  payload: m,
5514
- encoded: g,
5515
- link: ss(g)
5514
+ encoded: h,
5515
+ link: ss(h)
5516
5516
  });
5517
5517
  } finally {
5518
5518
  await u.close();
5519
5519
  }
5520
- }), p.post("/v1/admin/devices", async (e) => {
5521
- let t = L(e.req.header(I), n);
5522
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5523
- let i = h(e, "admin", !0);
5524
- if (i) return i;
5525
- let a = await R(e);
5526
- if (a == null) return e.json({ error: "body_too_large" }, 413);
5527
- let o = g(a);
5528
- if (!o) return e.json({ error: "invalid_json" }, 400);
5529
- let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.fingerprint ?? "").trim(), u = String(o.public_key ?? "").trim(), d = String(o.display_name ?? "").trim() || null;
5530
- return !s || !c || !l || !u ? e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400) : ue(u) === l ? dl(e, r(), s, {
5531
- deviceId: c,
5532
- fingerprint: l,
5533
- publicKey: u,
5534
- displayName: d
5520
+ }), _.post("/v1/admin/devices", async (e) => {
5521
+ let r = L(e.req.header(I), t);
5522
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5523
+ let a = y(e, "admin", !0);
5524
+ if (a) return a;
5525
+ let o = await R(e);
5526
+ if (o == null) return e.json({ error: "body_too_large" }, 413);
5527
+ let s = b(o);
5528
+ if (!s) return e.json({ error: "invalid_json" }, 400);
5529
+ let c = String(s.group_id ?? "").trim(), l = String(s.device_id ?? "").trim(), u = String(s.fingerprint ?? "").trim(), d = String(s.public_key ?? "").trim(), f = String(s.display_name ?? "").trim() || null;
5530
+ return !c || !l || !u || !d ? e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400) : i(d) === u ? dl(e, n(), c, {
5531
+ deviceId: l,
5532
+ fingerprint: u,
5533
+ publicKey: d,
5534
+ displayName: f
5535
5535
  }) : e.json({ error: "fingerprint_mismatch" }, 400);
5536
- }), p.get("/v1/admin/groups", async (e) => {
5537
- let t = L(e.req.header(I), n);
5538
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5539
- let i = h(e, "admin", !0);
5536
+ }), _.get("/v1/admin/groups", async (e) => {
5537
+ let r = L(e.req.header(I), t);
5538
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5539
+ let i = y(e, "admin", !0);
5540
5540
  if (i) return i;
5541
5541
  let a = [
5542
5542
  "1",
5543
5543
  "true",
5544
5544
  "yes"
5545
- ].includes((e.req.query("include_archived") ?? "0").trim().toLowerCase()), o = r();
5545
+ ].includes((e.req.query("include_archived") ?? "0").trim().toLowerCase()), o = n();
5546
5546
  try {
5547
5547
  return e.json({ items: await o.listGroups(a) });
5548
5548
  } finally {
5549
5549
  await o.close();
5550
5550
  }
5551
- }), p.post("/v1/admin/groups", async (e) => {
5552
- let t = L(e.req.header(I), n);
5553
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5554
- let i = h(e, "admin", !0);
5551
+ }), _.post("/v1/admin/groups", async (e) => {
5552
+ let r = L(e.req.header(I), t);
5553
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5554
+ let i = y(e, "admin", !0);
5555
5555
  if (i) return i;
5556
5556
  let a = await R(e);
5557
5557
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5558
- let o = g(a);
5558
+ let o = b(a);
5559
5559
  if (!o) return e.json({ error: "invalid_json" }, 400);
5560
5560
  let s = String(o.group_id ?? "").trim(), c = String(o.display_name ?? "").trim() || null;
5561
5561
  if (!s) return e.json({ error: "group_id_required" }, 400);
5562
- let l = r();
5562
+ let l = n();
5563
5563
  try {
5564
5564
  return await l.createGroup(s, c), e.json({
5565
5565
  ok: !0,
@@ -5568,18 +5568,18 @@ function Sl(e) {
5568
5568
  } finally {
5569
5569
  await l.close();
5570
5570
  }
5571
- }), p.post("/v1/admin/groups/rename", async (e) => {
5572
- let t = L(e.req.header(I), n);
5573
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5574
- let i = h(e, "admin", !0);
5571
+ }), _.post("/v1/admin/groups/rename", async (e) => {
5572
+ let r = L(e.req.header(I), t);
5573
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5574
+ let i = y(e, "admin", !0);
5575
5575
  if (i) return i;
5576
5576
  let a = await R(e);
5577
5577
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5578
- let o = g(a);
5578
+ let o = b(a);
5579
5579
  if (!o) return e.json({ error: "invalid_json" }, 400);
5580
5580
  let s = String(o.group_id ?? "").trim(), c = String(o.display_name ?? "").trim();
5581
5581
  if (!s || !c) return e.json({ error: "group_id_and_display_name_required" }, 400);
5582
- let l = r();
5582
+ let l = n();
5583
5583
  try {
5584
5584
  return await l.renameGroup(s, c) ? e.json({
5585
5585
  ok: !0,
@@ -5588,38 +5588,38 @@ function Sl(e) {
5588
5588
  } finally {
5589
5589
  await l.close();
5590
5590
  }
5591
- }), p.post("/v1/admin/groups/archive", async (e) => {
5592
- let t = L(e.req.header(I), n);
5593
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5594
- let i = h(e, "admin", !0);
5591
+ }), _.post("/v1/admin/groups/archive", async (e) => {
5592
+ let r = L(e.req.header(I), t);
5593
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5594
+ let i = y(e, "admin", !0);
5595
5595
  if (i) return i;
5596
5596
  let a = await R(e);
5597
5597
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5598
- let o = g(a);
5598
+ let o = b(a);
5599
5599
  if (!o) return e.json({ error: "invalid_json" }, 400);
5600
5600
  let s = String(o.group_id ?? "").trim();
5601
5601
  if (!s) return e.json({ error: "group_id_required" }, 400);
5602
- let c = r();
5602
+ let c = n();
5603
5603
  try {
5604
- return await c.archiveGroup(s, n.now()) ? e.json({
5604
+ return await c.archiveGroup(s, t.now()) ? e.json({
5605
5605
  ok: !0,
5606
5606
  group: await c.getGroup(s)
5607
5607
  }) : e.json({ error: "group_not_found_or_already_archived" }, 404);
5608
5608
  } finally {
5609
5609
  await c.close();
5610
5610
  }
5611
- }), p.post("/v1/admin/groups/unarchive", async (e) => {
5612
- let t = L(e.req.header(I), n);
5613
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5614
- let i = h(e, "admin", !0);
5611
+ }), _.post("/v1/admin/groups/unarchive", async (e) => {
5612
+ let r = L(e.req.header(I), t);
5613
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5614
+ let i = y(e, "admin", !0);
5615
5615
  if (i) return i;
5616
5616
  let a = await R(e);
5617
5617
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5618
- let o = g(a);
5618
+ let o = b(a);
5619
5619
  if (!o) return e.json({ error: "invalid_json" }, 400);
5620
5620
  let s = String(o.group_id ?? "").trim();
5621
5621
  if (!s) return e.json({ error: "group_id_required" }, 400);
5622
- let c = r();
5622
+ let c = n();
5623
5623
  try {
5624
5624
  return await c.unarchiveGroup(s) ? e.json({
5625
5625
  ok: !0,
@@ -5628,16 +5628,16 @@ function Sl(e) {
5628
5628
  } finally {
5629
5629
  await c.close();
5630
5630
  }
5631
- }), p.get("/v1/admin/groups/:group_id/scopes", async (e) => {
5632
- let t = L(e.req.header(I), n);
5633
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5634
- let i = h(e, "admin", !0);
5631
+ }), _.get("/v1/admin/groups/:group_id/scopes", async (e) => {
5632
+ let r = L(e.req.header(I), t);
5633
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5634
+ let i = y(e, "admin", !0);
5635
5635
  if (i) return i;
5636
- let a = String(e.req.param("group_id") ?? "").trim(), o = r();
5636
+ let a = String(e.req.param("group_id") ?? "").trim(), o = n();
5637
5637
  try {
5638
- let t = await C(o, a, e);
5638
+ let t = await ae(o, a, e);
5639
5639
  if (t) return t;
5640
- let n = x(e.req.query("include_inactive"));
5640
+ let n = te(e.req.query("include_inactive"));
5641
5641
  return e.json({ items: await o.listScopes({
5642
5642
  groupId: a,
5643
5643
  includeInactive: n
@@ -5645,33 +5645,33 @@ function Sl(e) {
5645
5645
  } finally {
5646
5646
  await o.close();
5647
5647
  }
5648
- }), p.post("/v1/admin/groups/:group_id/scopes", async (e) => {
5649
- let t = L(e.req.header(I), n);
5650
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5651
- let i = h(e, "admin", !0);
5648
+ }), _.post("/v1/admin/groups/:group_id/scopes", async (e) => {
5649
+ let r = L(e.req.header(I), t);
5650
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5651
+ let i = y(e, "admin", !0);
5652
5652
  if (i) return i;
5653
5653
  let a = await R(e);
5654
5654
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5655
- let o = g(a);
5655
+ let o = b(a);
5656
5656
  if (!o) return e.json({ error: "invalid_json" }, 400);
5657
- let s = String(e.req.param("group_id") ?? "").trim(), c = v(o, "scope_id"), l = v(o, "label"), u = b(o, "membership_epoch");
5657
+ let s = String(e.req.param("group_id") ?? "").trim(), c = x(o, "scope_id"), l = x(o, "label"), u = S(o, "membership_epoch");
5658
5658
  if (!c || !l) return e.json({ error: "scope_id_and_label_required" }, 400);
5659
5659
  if (Number.isNaN(u)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
5660
- let d = r();
5660
+ let d = n();
5661
5661
  try {
5662
- let t = await C(d, s, e);
5662
+ let t = await ae(d, s, e);
5663
5663
  if (t) return t;
5664
5664
  let n = await d.createScope({
5665
5665
  scopeId: c,
5666
5666
  label: l,
5667
- kind: v(o, "kind"),
5668
- authorityType: v(o, "authority_type"),
5669
- coordinatorId: v(o, "coordinator_id"),
5667
+ kind: x(o, "kind"),
5668
+ authorityType: x(o, "authority_type"),
5669
+ coordinatorId: x(o, "coordinator_id"),
5670
5670
  groupId: s,
5671
- manifestIssuerDeviceId: v(o, "manifest_issuer_device_id"),
5671
+ manifestIssuerDeviceId: x(o, "manifest_issuer_device_id"),
5672
5672
  membershipEpoch: u,
5673
- manifestHash: v(o, "manifest_hash"),
5674
- status: v(o, "status")
5673
+ manifestHash: x(o, "manifest_hash"),
5674
+ status: x(o, "status")
5675
5675
  });
5676
5676
  return e.json({
5677
5677
  ok: !0,
@@ -5682,33 +5682,33 @@ function Sl(e) {
5682
5682
  } finally {
5683
5683
  await d.close();
5684
5684
  }
5685
- }), p.patch("/v1/admin/groups/:group_id/scopes/:scope_id", async (e) => {
5686
- let t = L(e.req.header(I), n);
5687
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5688
- let i = h(e, "admin", !0);
5685
+ }), _.patch("/v1/admin/groups/:group_id/scopes/:scope_id", async (e) => {
5686
+ let r = L(e.req.header(I), t);
5687
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5688
+ let i = y(e, "admin", !0);
5689
5689
  if (i) return i;
5690
5690
  let a = await R(e);
5691
5691
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5692
- let o = g(a);
5692
+ let o = b(a);
5693
5693
  if (!o) return e.json({ error: "invalid_json" }, 400);
5694
- let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = b(o, "membership_epoch");
5694
+ let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = S(o, "membership_epoch");
5695
5695
  if (!c) return e.json({ error: "scope_id_required" }, 400);
5696
5696
  if (Number.isNaN(l)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
5697
- let u = r();
5697
+ let u = n();
5698
5698
  try {
5699
- let t = await oe(u, s, c, e);
5699
+ let t = await w(u, s, c, e);
5700
5700
  if (t.response) return t.response;
5701
5701
  let n = await u.updateScope({
5702
5702
  scopeId: c,
5703
- label: o.label === void 0 ? void 0 : v(o, "label"),
5704
- kind: o.kind === void 0 ? void 0 : v(o, "kind"),
5705
- authorityType: o.authority_type === void 0 ? void 0 : v(o, "authority_type"),
5706
- coordinatorId: o.coordinator_id === void 0 ? void 0 : v(o, "coordinator_id"),
5703
+ label: o.label === void 0 ? void 0 : x(o, "label"),
5704
+ kind: o.kind === void 0 ? void 0 : x(o, "kind"),
5705
+ authorityType: o.authority_type === void 0 ? void 0 : x(o, "authority_type"),
5706
+ coordinatorId: o.coordinator_id === void 0 ? void 0 : x(o, "coordinator_id"),
5707
5707
  groupId: s,
5708
- manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 : v(o, "manifest_issuer_device_id"),
5708
+ manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 : x(o, "manifest_issuer_device_id"),
5709
5709
  membershipEpoch: l,
5710
- manifestHash: o.manifest_hash === void 0 ? void 0 : v(o, "manifest_hash"),
5711
- status: o.status === void 0 ? void 0 : v(o, "status")
5710
+ manifestHash: o.manifest_hash === void 0 ? void 0 : x(o, "manifest_hash"),
5711
+ status: o.status === void 0 ? void 0 : x(o, "status")
5712
5712
  });
5713
5713
  return n ? e.json({
5714
5714
  ok: !0,
@@ -5719,48 +5719,48 @@ function Sl(e) {
5719
5719
  } finally {
5720
5720
  await u.close();
5721
5721
  }
5722
- }), p.get("/v1/admin/groups/:group_id/scopes/:scope_id/members", async (e) => {
5723
- let t = L(e.req.header(I), n);
5724
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5725
- let i = h(e, "admin", !0);
5722
+ }), _.get("/v1/admin/groups/:group_id/scopes/:scope_id/members", async (e) => {
5723
+ let r = L(e.req.header(I), t);
5724
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5725
+ let i = y(e, "admin", !0);
5726
5726
  if (i) return i;
5727
- let a = String(e.req.param("group_id") ?? "").trim(), o = String(e.req.param("scope_id") ?? "").trim(), s = r();
5727
+ let a = String(e.req.param("group_id") ?? "").trim(), o = String(e.req.param("scope_id") ?? "").trim(), s = n();
5728
5728
  try {
5729
- let t = await oe(s, a, o, e);
5730
- return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o, x(e.req.query("include_revoked"))) });
5729
+ let t = await w(s, a, o, e);
5730
+ return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o, te(e.req.query("include_revoked"))) });
5731
5731
  } finally {
5732
5732
  await s.close();
5733
5733
  }
5734
- }), p.post("/v1/admin/groups/:group_id/scopes/:scope_id/members", async (e) => {
5735
- let t = L(e.req.header(I), n);
5736
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5737
- let i = h(e, "admin", !0);
5734
+ }), _.post("/v1/admin/groups/:group_id/scopes/:scope_id/members", async (e) => {
5735
+ let r = L(e.req.header(I), t);
5736
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5737
+ let i = y(e, "admin", !0);
5738
5738
  if (i) return i;
5739
5739
  let a = await R(e);
5740
5740
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5741
- let o = g(a);
5741
+ let o = b(a);
5742
5742
  if (!o) return e.json({ error: "invalid_json" }, 400);
5743
- let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = v(o, "effect_id"), u = v(o, "device_id"), d = b(o, "membership_epoch");
5743
+ let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = x(o, "effect_id"), u = x(o, "device_id"), d = S(o, "membership_epoch");
5744
5744
  if (!l) return e.json({ error: "effect_id_required" }, 400);
5745
5745
  if (!u) return e.json({ error: "device_id_required" }, 400);
5746
5746
  if (Number.isNaN(d)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
5747
- let f = r();
5747
+ let f = n();
5748
5748
  try {
5749
- let t = await oe(f, s, c, e);
5749
+ let t = await w(f, s, c, e);
5750
5750
  if (t.response) return t.response;
5751
5751
  let n = await f.grantScopeMembership({
5752
5752
  effectId: l,
5753
5753
  scopeId: c,
5754
5754
  deviceId: u,
5755
- role: v(o, "role"),
5755
+ role: x(o, "role"),
5756
5756
  membershipEpoch: d,
5757
- coordinatorId: v(o, "coordinator_id"),
5757
+ coordinatorId: x(o, "coordinator_id"),
5758
5758
  groupId: s,
5759
- manifestIssuerDeviceId: v(o, "manifest_issuer_device_id"),
5760
- manifestHash: v(o, "manifest_hash"),
5761
- signedManifestJson: v(o, "signed_manifest_json"),
5759
+ manifestIssuerDeviceId: x(o, "manifest_issuer_device_id"),
5760
+ manifestHash: x(o, "manifest_hash"),
5761
+ signedManifestJson: x(o, "signed_manifest_json"),
5762
5762
  actorType: "admin",
5763
- actorId: y(e.req.header(Gc))
5763
+ actorId: ee(e.req.header(Gc))
5764
5764
  });
5765
5765
  return e.json({
5766
5766
  ok: !0,
@@ -5768,67 +5768,67 @@ function Sl(e) {
5768
5768
  }, 201);
5769
5769
  } catch (t) {
5770
5770
  let n = t instanceof Error ? t.message : String(t);
5771
- if (t instanceof be && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
5772
- if (t instanceof be && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
5773
- let r = t instanceof be && t.code === "scope_inactive";
5771
+ if (t instanceof Ae && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
5772
+ if (t instanceof Ae && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
5773
+ let r = t instanceof Ae && t.code === "scope_inactive";
5774
5774
  return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
5775
5775
  } finally {
5776
5776
  await f.close();
5777
5777
  }
5778
- }), p.post("/v1/admin/groups/:group_id/scopes/:scope_id/members/:device_id/revoke", async (e) => {
5779
- let t = L(e.req.header(I), n);
5780
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5781
- let i = h(e, "admin", !0);
5782
- if (i) return i;
5783
- let a = await R(e);
5784
- if (a == null) return e.json({ error: "body_too_large" }, 413);
5785
- let o = a.byteLength > 0 ? g(a) : {};
5786
- if (!o) return e.json({ error: "invalid_json" }, 400);
5787
- let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = String(e.req.param("device_id") ?? "").trim(), u = v(o, "effect_id"), d = b(o, "membership_epoch");
5788
- if (!u) return e.json({ error: "effect_id_required" }, 400);
5789
- if (!l) return e.json({ error: "device_id_required" }, 400);
5790
- if (Number.isNaN(d)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
5791
- let f = r();
5778
+ }), _.post("/v1/admin/groups/:group_id/scopes/:scope_id/members/:device_id/revoke", async (e) => {
5779
+ let i = L(e.req.header(I), t);
5780
+ if (!i.ok) return y(e, e.req.path, !1) ?? e.json({ error: i.error }, 401);
5781
+ let a = y(e, "admin", !0);
5782
+ if (a) return a;
5783
+ let o = await R(e);
5784
+ if (o == null) return e.json({ error: "body_too_large" }, 413);
5785
+ let s = o.byteLength > 0 ? b(o) : {};
5786
+ if (!s) return e.json({ error: "invalid_json" }, 400);
5787
+ let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = String(e.req.param("device_id") ?? "").trim(), d = x(s, "effect_id"), f = S(s, "membership_epoch");
5788
+ if (!d) return e.json({ error: "effect_id_required" }, 400);
5789
+ if (!u) return e.json({ error: "device_id_required" }, 400);
5790
+ if (Number.isNaN(f)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
5791
+ let p = n();
5792
5792
  try {
5793
- let t = await oe(f, s, c, e);
5793
+ let t = await w(p, c, l, e);
5794
5794
  if (t.response) return t.response;
5795
- if (!await f.revokeScopeMembership({
5796
- effectId: u,
5797
- scopeId: c,
5798
- deviceId: l,
5799
- groupId: s,
5800
- membershipEpoch: d,
5801
- manifestHash: v(o, "manifest_hash"),
5802
- signedManifestJson: v(o, "signed_manifest_json"),
5795
+ if (!await p.revokeScopeMembership({
5796
+ effectId: d,
5797
+ scopeId: l,
5798
+ deviceId: u,
5799
+ groupId: c,
5800
+ membershipEpoch: f,
5801
+ manifestHash: x(s, "manifest_hash"),
5802
+ signedManifestJson: x(s, "signed_manifest_json"),
5803
5803
  actorType: "admin",
5804
- actorId: y(e.req.header(Gc))
5804
+ actorId: ee(e.req.header(Gc))
5805
5805
  })) return e.json({ error: "membership_not_found" }, 404);
5806
5806
  let n;
5807
5807
  try {
5808
- n = (await f.listScopeMemberships(c, !0)).find((e) => e.device_id === l);
5808
+ n = (await p.listScopeMemberships(l, !0)).find((e) => e.device_id === u);
5809
5809
  } catch {
5810
5810
  n = void 0;
5811
5811
  }
5812
5812
  return e.json({
5813
5813
  ok: !0,
5814
- scope_id: c,
5815
- device_id: l,
5816
- revocation: Ae({
5817
- scopeId: c,
5818
- deviceId: l,
5819
- membershipEpoch: n?.membership_epoch ?? d
5814
+ scope_id: l,
5815
+ device_id: u,
5816
+ revocation: r({
5817
+ scopeId: l,
5818
+ deviceId: u,
5819
+ membershipEpoch: n?.membership_epoch ?? f
5820
5820
  })
5821
5821
  });
5822
5822
  } catch (t) {
5823
5823
  let n = t instanceof Error ? t.message : String(t);
5824
- return t instanceof be && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
5824
+ return t instanceof Ae && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
5825
5825
  } finally {
5826
- await f.close();
5826
+ await p.close();
5827
5827
  }
5828
- }), p.get("/v1/admin/devices", async (e) => {
5829
- let t = L(e.req.header(I), n);
5830
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5831
- let i = h(e, "admin", !0);
5828
+ }), _.get("/v1/admin/devices", async (e) => {
5829
+ let r = L(e.req.header(I), t);
5830
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5831
+ let i = y(e, "admin", !0);
5832
5832
  if (i) return i;
5833
5833
  let a = (e.req.query("group_id") ?? "").trim();
5834
5834
  if (!a) return e.json({ error: "group_id_required" }, 400);
@@ -5836,156 +5836,156 @@ function Sl(e) {
5836
5836
  "1",
5837
5837
  "true",
5838
5838
  "yes"
5839
- ].includes((e.req.query("include_disabled") ?? "0").trim().toLowerCase()), s = r();
5839
+ ].includes((e.req.query("include_disabled") ?? "0").trim().toLowerCase()), s = n();
5840
5840
  try {
5841
5841
  return e.json({ items: await s.listEnrolledDevices(a, o) });
5842
5842
  } finally {
5843
5843
  await s.close();
5844
5844
  }
5845
- }), p.post("/v1/admin/devices/rename", async (e) => {
5846
- let t = L(e.req.header(I), n);
5847
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5848
- let a = h(e, "admin", !0);
5849
- if (a) return a;
5850
- let o = await R(e);
5851
- if (o == null) return e.json({ error: "body_too_large" }, 413);
5852
- let s = g(o);
5853
- if (!s) return e.json({ error: "invalid_json" }, 400);
5854
- let c = String(s.group_id ?? "").trim(), l = String(s.device_id ?? "").trim(), u = String(s.display_name ?? "").trim();
5855
- if (!c || !l) return e.json({ error: "group_id_and_device_id_required" }, 400);
5856
- if (!u) return e.json({ error: "display_name_required" }, 400);
5857
- let d;
5845
+ }), _.post("/v1/admin/devices/rename", async (e) => {
5846
+ let r = L(e.req.header(I), t);
5847
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5848
+ let i = y(e, "admin", !0);
5849
+ if (i) return i;
5850
+ let a = await R(e);
5851
+ if (a == null) return e.json({ error: "body_too_large" }, 413);
5852
+ let o = b(a);
5853
+ if (!o) return e.json({ error: "invalid_json" }, 400);
5854
+ let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.display_name ?? "").trim();
5855
+ if (!s || !c) return e.json({ error: "group_id_and_device_id_required" }, 400);
5856
+ if (!l) return e.json({ error: "display_name_required" }, 400);
5857
+ let u;
5858
5858
  try {
5859
- d = i(u, "display_name");
5859
+ u = se(l, "display_name");
5860
5860
  } catch (t) {
5861
5861
  return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
5862
5862
  }
5863
- let f = r();
5863
+ let d = n();
5864
5864
  try {
5865
- if (!await f.renameDevice(c, l, d)) return e.json({ error: "device_not_found" }, 404);
5866
- let t = await f.getEnrollment(c, l);
5865
+ if (!await d.renameDevice(s, c, u)) return e.json({ error: "device_not_found" }, 404);
5866
+ let t = await d.getEnrollment(s, c);
5867
5867
  return e.json({
5868
5868
  ok: !0,
5869
5869
  device: t
5870
5870
  });
5871
5871
  } finally {
5872
- await f.close();
5872
+ await d.close();
5873
5873
  }
5874
- }), p.post("/v1/admin/devices/disable", async (e) => {
5875
- let t = L(e.req.header(I), n);
5876
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5877
- let i = h(e, "admin", !0);
5874
+ }), _.post("/v1/admin/devices/disable", async (e) => {
5875
+ let r = L(e.req.header(I), t);
5876
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5877
+ let i = y(e, "admin", !0);
5878
5878
  if (i) return i;
5879
5879
  let a = await R(e);
5880
5880
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5881
- let o = g(a);
5881
+ let o = b(a);
5882
5882
  if (!o) return e.json({ error: "invalid_json" }, 400);
5883
5883
  let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim();
5884
5884
  if (!s || !c) return e.json({ error: "group_id_and_device_id_required" }, 400);
5885
- let l = r();
5885
+ let l = n();
5886
5886
  try {
5887
5887
  return await l.setDeviceEnabled(s, c, !1) ? e.json({ ok: !0 }) : e.json({ error: "device_not_found" }, 404);
5888
5888
  } finally {
5889
5889
  await l.close();
5890
5890
  }
5891
- }), p.post("/v1/admin/devices/enable", async (e) => {
5892
- let t = L(e.req.header(I), n);
5893
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5894
- let i = h(e, "admin", !0);
5891
+ }), _.post("/v1/admin/devices/enable", async (e) => {
5892
+ let r = L(e.req.header(I), t);
5893
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5894
+ let i = y(e, "admin", !0);
5895
5895
  if (i) return i;
5896
5896
  let a = await R(e);
5897
5897
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5898
- let o = g(a);
5898
+ let o = b(a);
5899
5899
  if (!o) return e.json({ error: "invalid_json" }, 400);
5900
5900
  let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim();
5901
- return !s || !c ? e.json({ error: "group_id_and_device_id_required" }, 400) : pl(e, r(), s, c);
5902
- }), p.post("/v1/admin/devices/remove", async (e) => {
5903
- let t = L(e.req.header(I), n);
5904
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5905
- let i = h(e, "admin", !0);
5901
+ return !s || !c ? e.json({ error: "group_id_and_device_id_required" }, 400) : pl(e, n(), s, c);
5902
+ }), _.post("/v1/admin/devices/remove", async (e) => {
5903
+ let r = L(e.req.header(I), t);
5904
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5905
+ let i = y(e, "admin", !0);
5906
5906
  if (i) return i;
5907
5907
  let a = await R(e);
5908
5908
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5909
- let o = g(a);
5909
+ let o = b(a);
5910
5910
  if (!o) return e.json({ error: "invalid_json" }, 400);
5911
5911
  let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim();
5912
5912
  if (!s || !c) return e.json({ error: "group_id_and_device_id_required" }, 400);
5913
- let l = r();
5913
+ let l = n();
5914
5914
  try {
5915
5915
  return await l.removeDevice(s, c) ? e.json({ ok: !0 }) : e.json({ error: "device_not_found" }, 404);
5916
5916
  } finally {
5917
5917
  await l.close();
5918
5918
  }
5919
- }), p.post("/v1/admin/legacy-team-completions", async (e) => {
5920
- let t = L(e.req.header(I), n);
5921
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5922
- let i = h(e, "admin", !0);
5919
+ }), _.post("/v1/admin/legacy-team-completions", async (e) => {
5920
+ let r = L(e.req.header(I), t);
5921
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5922
+ let i = y(e, "admin", !0);
5923
5923
  if (i) return i;
5924
5924
  let a = await R(e, Wc);
5925
5925
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5926
- let o = g(a);
5926
+ let o = b(a);
5927
5927
  if (!o) return e.json({ error: "invalid_json" }, 400);
5928
5928
  if (Object.keys(o).some((e) => e !== "group_id" && e !== "manifest")) return e.json({ error: "completion_manifest_invalid" }, 400);
5929
- let s, c;
5929
+ let c, l;
5930
5930
  try {
5931
- let e = ne([o.group_id])[0];
5931
+ let e = h([o.group_id])[0];
5932
5932
  if (!e) throw Error("completion_manifest_invalid");
5933
- s = e, c = Ve(o.manifest), f(c);
5933
+ c = e, l = d(o.manifest), s(l);
5934
5934
  } catch {
5935
5935
  return e.json({ error: "completion_manifest_invalid" }, 400);
5936
5936
  }
5937
- let l = r();
5937
+ let u = n();
5938
5938
  try {
5939
- let t = await l.createLegacyTeamCompletion(s, c);
5939
+ let t = await u.createLegacyTeamCompletion(c, l);
5940
5940
  return e.json({
5941
5941
  ok: !0,
5942
5942
  ...t
5943
5943
  }, t.status === "created" ? 201 : 200);
5944
5944
  } catch (t) {
5945
- if (t instanceof ee) return e.json({ error: t.code }, 409);
5945
+ if (t instanceof oe) return e.json({ error: t.code }, 409);
5946
5946
  let n = t instanceof Error ? t.message : "completion_manifest_invalid";
5947
5947
  if (n === "group_not_found") return e.json({ error: n }, 404);
5948
5948
  if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
5949
5949
  if (n === "completion_manifest_invalid") return e.json({ error: n }, 400);
5950
5950
  throw t;
5951
5951
  } finally {
5952
- await l.close();
5952
+ await u.close();
5953
5953
  }
5954
- }), p.get("/v1/admin/legacy-team-completions", async (e) => {
5955
- let t = L(e.req.header(I), n);
5956
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5957
- let i = h(e, "admin", !0);
5954
+ }), _.get("/v1/admin/legacy-team-completions", async (e) => {
5955
+ let r = L(e.req.header(I), t);
5956
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5957
+ let i = y(e, "admin", !0);
5958
5958
  if (i) return i;
5959
5959
  let a = String(e.req.query("group_id") ?? "").trim(), o;
5960
5960
  try {
5961
- if (ne([a]).length !== 1) throw Error("completion_manifest_invalid");
5962
- o = _(e.req.query("candidate_ref"));
5961
+ if (h([a]).length !== 1) throw Error("completion_manifest_invalid");
5962
+ o = ce(e.req.query("candidate_ref"));
5963
5963
  } catch {
5964
5964
  return e.json({ error: "group_id_and_candidate_ref_required" }, 400);
5965
5965
  }
5966
- let s = r();
5966
+ let s = n();
5967
5967
  try {
5968
5968
  let t = await s.getLegacyTeamCompletion(a, o);
5969
5969
  return t ? e.json({ manifest: t }) : e.json({ error: "completion_not_found" }, 404);
5970
5970
  } finally {
5971
5971
  await s.close();
5972
5972
  }
5973
- }), p.post("/v1/admin/legacy-team-completions/query", async (e) => {
5974
- let t = L(e.req.header(I), n);
5975
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
5976
- let i = h(e, "admin", !0);
5973
+ }), _.post("/v1/admin/legacy-team-completions/query", async (e) => {
5974
+ let r = L(e.req.header(I), t);
5975
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
5976
+ let i = y(e, "admin", !0);
5977
5977
  if (i) return i;
5978
5978
  let a = await R(e);
5979
5979
  if (a == null) return e.json({ error: "body_too_large" }, 413);
5980
- let o = g(a);
5980
+ let o = b(a);
5981
5981
  if (!o || Object.keys(o).some((e) => e !== "group_ids")) return e.json({ error: "completion_query_invalid" }, 400);
5982
5982
  let s;
5983
5983
  try {
5984
- if (s = ne(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
5984
+ if (s = h(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
5985
5985
  } catch {
5986
5986
  return e.json({ error: "completion_query_invalid" }, 400);
5987
5987
  }
5988
- let c = r();
5988
+ let c = n();
5989
5989
  try {
5990
5990
  return e.json({ items: await c.listLegacyTeamCompletions(s) });
5991
5991
  } catch (t) {
@@ -5994,21 +5994,21 @@ function Sl(e) {
5994
5994
  } finally {
5995
5995
  await c.close();
5996
5996
  }
5997
- }), p.post("/v1/admin/invites", async (e) => {
5998
- let t = L(e.req.header(I), n);
5999
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6000
- let a = h(e, "admin", !0);
6001
- if (a) return a;
6002
- let o = await R(e);
6003
- if (o == null) return e.json({ error: "body_too_large" }, 413);
6004
- let s = g(o);
6005
- if (!s) return e.json({ error: "invalid_json" }, 400);
6006
- let c = String(s.group_id ?? "").trim(), l = String(s.policy ?? "auto_admit").trim(), u = String(s.expires_at ?? "").trim(), d = String(s.created_by ?? "").trim() || null, f = String(s.operation_id ?? "").trim() || null, p = String(s.reviewed_project_set_digest ?? "").trim() || null, m = String(s.inviter_actor_id ?? "").trim() || null, _ = String(s.inviter_display_name ?? "").trim() || null, v = String(s.inviter_device_id ?? "").trim() || null, y = String(s.pending_person_id ?? "").trim() || null, b = String(s.invite_kind ?? s.kind ?? "").trim(), x = String(s.policy_team_id ?? "").trim() || null, S = String(s.target_identity_id ?? "").trim() || null, ee = String(s.reviewed_preview_digest ?? "").trim() || null, te, ne = null, re = null;
6007
- if (!c || !["auto_admit", "approval_required"].includes(l) || !u) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
6008
- if (Object.hasOwn(s, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
6009
- if (Number.isNaN(new Date(u).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
5997
+ }), _.post("/v1/admin/invites", async (e) => {
5998
+ let r = L(e.req.header(I), t);
5999
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6000
+ let i = y(e, "admin", !0);
6001
+ if (i) return i;
6002
+ let a = await R(e);
6003
+ if (a == null) return e.json({ error: "body_too_large" }, 413);
6004
+ let o = b(a);
6005
+ if (!o) return e.json({ error: "invalid_json" }, 400);
6006
+ let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), d = String(o.created_by ?? "").trim() || null, f = String(o.operation_id ?? "").trim() || null, p = String(o.reviewed_project_set_digest ?? "").trim() || null, m = String(o.inviter_actor_id ?? "").trim() || null, h = String(o.inviter_display_name ?? "").trim() || null, g = String(o.inviter_device_id ?? "").trim() || null, _ = String(o.pending_person_id ?? "").trim() || null, v = String(o.invite_kind ?? o.kind ?? "").trim(), x = String(o.policy_team_id ?? "").trim() || null, ee = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, te, ne = null, re = null;
6007
+ if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
6008
+ if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
6009
+ if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
6010
6010
  if (!!f != !!p) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
6011
- let C = b || (f ? "project_share" : "legacy_enrollment");
6011
+ let C = v || (f ? "project_share" : "legacy_enrollment");
6012
6012
  if (![
6013
6013
  "legacy_enrollment",
6014
6014
  "project_share",
@@ -6016,36 +6016,36 @@ function Sl(e) {
6016
6016
  "add_device"
6017
6017
  ].includes(C)) return e.json({ error: "invite_kind_invalid" }, 400);
6018
6018
  if (C === "project_share" ? !f : f) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
6019
- if (ee && !/^[a-f0-9]{64}$/u.test(ee)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
6020
- if (C === "team_member" && (!x || !ee || S) || C === "add_device" && (!S || !ee || x) || !["team_member", "add_device"].includes(C) && (x || S || ee)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
6021
- if ([x, S].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
6019
+ if (S && !/^[a-f0-9]{64}$/u.test(S)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
6020
+ if (C === "team_member" && (!x || !S || ee) || C === "add_device" && (!ee || !S || x) || !["team_member", "add_device"].includes(C) && (x || ee || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
6021
+ if ([x, ee].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
6022
6022
  if (C === "team_member" || C === "add_device") {
6023
- if (s.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
6023
+ if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
6024
6024
  try {
6025
- te = await ie(s.reviewed_intent, {
6025
+ te = await me(o.reviewed_intent, {
6026
6026
  target: C === "team_member" ? {
6027
6027
  kind: "team_member",
6028
6028
  policyTeamId: String(x)
6029
6029
  } : {
6030
6030
  kind: "add_device",
6031
- targetIdentityId: String(S)
6031
+ targetIdentityId: String(ee)
6032
6032
  },
6033
- digest: String(ee)
6033
+ digest: String(S)
6034
6034
  });
6035
6035
  } catch (t) {
6036
- return t instanceof fe && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
6036
+ return t instanceof ye && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
6037
6037
  }
6038
- } else if (s.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
6038
+ } else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
6039
6039
  if (f && !/^share_[a-f0-9]{40}$/u.test(f) || p && !/^[a-f0-9]{64}$/u.test(p)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
6040
6040
  if (f) {
6041
- if (!m || !_ || !v || !y) return e.json({ error: "project_invite_identity_context_required" }, 400);
6041
+ if (!m || !h || !g || !_) return e.json({ error: "project_invite_identity_context_required" }, 400);
6042
6042
  if ([
6043
6043
  m,
6044
- v,
6045
- y
6044
+ g,
6045
+ _
6046
6046
  ].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
6047
6047
  try {
6048
- if (i(_, "inviter_display_name"), ne = Se(s.project_summaries), !Array.isArray(s.project_intent) || s.project_intent.length !== ne.length || (re = s.project_intent.map((e, t) => {
6048
+ if (se(h, "inviter_display_name"), ne = u(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== ne.length || (re = o.project_intent.map((e, t) => {
6049
6049
  let n;
6050
6050
  try {
6051
6051
  n = Hc([e])[0];
@@ -6060,34 +6060,34 @@ function Sl(e) {
6060
6060
  return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
6061
6061
  }
6062
6062
  }
6063
- let ae = r();
6063
+ let ie = n();
6064
6064
  try {
6065
- let t = await ae.getGroup(c);
6065
+ let t = await ie.getGroup(s);
6066
6066
  if (!t) return e.json({ error: "group_not_found" }, 404);
6067
6067
  if (t.archived_at) return e.json({ error: "group_archived" }, 409);
6068
- let n = await ae.createInvite({
6069
- groupId: c,
6070
- policy: l,
6071
- expiresAt: u,
6068
+ let n = await ie.createInvite({
6069
+ groupId: s,
6070
+ policy: c,
6071
+ expiresAt: l,
6072
6072
  createdBy: d,
6073
6073
  operationId: f,
6074
6074
  reviewedProjectSetDigest: p,
6075
6075
  inviterActorId: m,
6076
- inviterDisplayName: _,
6077
- inviterDeviceId: v,
6078
- pendingPersonId: y,
6076
+ inviterDisplayName: h,
6077
+ inviterDeviceId: g,
6078
+ pendingPersonId: _,
6079
6079
  projectSummaries: ne,
6080
6080
  projectIntent: re,
6081
6081
  inviteKind: C,
6082
6082
  policyTeamId: x,
6083
- targetIdentityId: S,
6084
- reviewedPreviewDigest: ee,
6083
+ targetIdentityId: ee,
6084
+ reviewedPreviewDigest: S,
6085
6085
  reviewedIntent: te
6086
6086
  }), r = {
6087
6087
  v: 1,
6088
6088
  kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
6089
- coordinator_url: String(s.coordinator_url ?? "").trim(),
6090
- group_id: c,
6089
+ coordinator_url: String(o.coordinator_url ?? "").trim(),
6090
+ group_id: s,
6091
6091
  policy: n.policy,
6092
6092
  token: String(n.token ?? ""),
6093
6093
  expires_at: n.expires_at,
@@ -6107,10 +6107,10 @@ function Sl(e) {
6107
6107
  inviter_device_id: n.inviter_device_id ?? void 0,
6108
6108
  reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
6109
6109
  } : {}
6110
- }, i = as(r), { token: a, ...o } = n;
6110
+ }, i = as(r), { token: a, ...u } = n;
6111
6111
  return e.json({
6112
6112
  ok: !0,
6113
- invite: o,
6113
+ invite: u,
6114
6114
  payload: r,
6115
6115
  encoded: i,
6116
6116
  link: ss(i)
@@ -6120,98 +6120,98 @@ function Sl(e) {
6120
6120
  if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
6121
6121
  throw t;
6122
6122
  } finally {
6123
- await ae.close();
6123
+ await ie.close();
6124
6124
  }
6125
- }), p.post("/v1/invites/inspect", async (e) => {
6126
- let t = await R(e);
6127
- if (t == null) return e.json({ error: "body_too_large" }, 413);
6128
- let i = g(t);
6125
+ }), _.post("/v1/invites/inspect", async (e) => {
6126
+ let r = await R(e);
6127
+ if (r == null) return e.json({ error: "body_too_large" }, 413);
6128
+ let i = b(r);
6129
6129
  if (!i) return e.json({ error: "invalid_json" }, 400);
6130
6130
  let a = String(i.token ?? "").trim();
6131
6131
  if (!a) return e.json({ error: "invite_invalid" }, 404);
6132
- let o = r();
6132
+ let o = n();
6133
6133
  try {
6134
- let t = await o.getInviteByTokenForInspection(a);
6135
- if (!t || t.revoked_at) return e.json({ error: "invite_invalid" }, 404);
6136
- if (t.invite_kind === "team_member" || t.invite_kind === "add_device") try {
6137
- let t = await o.inspectRecipientInvite({
6134
+ let n = await o.getInviteByTokenForInspection(a);
6135
+ if (!n || n.revoked_at) return e.json({ error: "invite_invalid" }, 404);
6136
+ if (n.invite_kind === "team_member" || n.invite_kind === "add_device") try {
6137
+ let n = await o.inspectRecipientInvite({
6138
6138
  token: a,
6139
- now: n.now()
6139
+ now: t.now()
6140
6140
  });
6141
- return t ? e.json(t.kind === "team_member" ? {
6142
- kind: t.kind,
6143
- policy_team_id: t.policy_team_id,
6144
- assigned_identity_id: t.assigned_identity_id,
6145
- reviewed_preview_digest: t.reviewed_preview_digest,
6146
- reviewed_intent: t.reviewed_intent,
6147
- bound: t.bound
6141
+ return n ? e.json(n.kind === "team_member" ? {
6142
+ kind: n.kind,
6143
+ policy_team_id: n.policy_team_id,
6144
+ assigned_identity_id: n.assigned_identity_id,
6145
+ reviewed_preview_digest: n.reviewed_preview_digest,
6146
+ reviewed_intent: n.reviewed_intent,
6147
+ bound: n.bound
6148
6148
  } : {
6149
- kind: t.kind,
6150
- target_identity_id: t.target_identity_id,
6151
- reviewed_preview_digest: t.reviewed_preview_digest,
6152
- reviewed_intent: t.reviewed_intent,
6153
- bound: t.bound
6149
+ kind: n.kind,
6150
+ target_identity_id: n.target_identity_id,
6151
+ reviewed_preview_digest: n.reviewed_preview_digest,
6152
+ reviewed_intent: n.reviewed_intent,
6153
+ bound: n.bound
6154
6154
  }) : e.json({ error: "invite_invalid" }, 404);
6155
6155
  } catch (t) {
6156
6156
  let n = t instanceof Error ? t.message : "invite_invalid", r = n === "invite_expired" ? 410 : n === "invite_invalid" ? 404 : 409;
6157
6157
  return e.json({ error: n }, r);
6158
6158
  }
6159
- let r = !!(t.operation_id || t.reviewed_project_set_digest);
6160
- if (new Date(t.expires_at) <= new Date(n.now()) && (!r || !t.consumed_at)) return e.json({ error: "invite_expired" }, 410);
6161
- if (!t.operation_id) return e.json({
6159
+ let r = !!(n.operation_id || n.reviewed_project_set_digest);
6160
+ if (new Date(n.expires_at) <= new Date(t.now()) && (!r || !n.consumed_at)) return e.json({ error: "invite_expired" }, 410);
6161
+ if (!n.operation_id) return e.json({
6162
6162
  kind: "legacy_team_invite",
6163
- team_name: t.team_name_snapshot
6163
+ team_name: n.team_name_snapshot
6164
6164
  });
6165
- if (!t.project_intent_json || !t.project_summaries_json) return e.json({ error: "invite_invalid" }, 404);
6165
+ if (!n.project_intent_json || !n.project_summaries_json) return e.json({ error: "invite_invalid" }, 404);
6166
6166
  let i;
6167
6167
  try {
6168
- i = re(t.project_summaries_json);
6168
+ i = ie(n.project_summaries_json);
6169
6169
  } catch {
6170
6170
  return e.json({ error: "invite_invalid" }, 409);
6171
6171
  }
6172
6172
  return e.json({
6173
6173
  kind: "project_share_invite",
6174
- operation_id: t.operation_id,
6175
- inviter_name: t.inviter_display_name,
6176
- team_name: t.team_name_snapshot,
6174
+ operation_id: n.operation_id,
6175
+ inviter_name: n.inviter_display_name,
6176
+ team_name: n.team_name_snapshot,
6177
6177
  projects: i,
6178
- bound: !!t.consumed_at
6178
+ bound: !!n.consumed_at
6179
6179
  });
6180
6180
  } finally {
6181
6181
  await o.close();
6182
6182
  }
6183
- }), p.get("/v1/admin/invites", async (e) => {
6184
- let t = L(e.req.header(I), n);
6185
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6186
- let i = h(e, "admin", !0);
6183
+ }), _.get("/v1/admin/invites", async (e) => {
6184
+ let r = L(e.req.header(I), t);
6185
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6186
+ let i = y(e, "admin", !0);
6187
6187
  if (i) return i;
6188
6188
  let a = (e.req.query("group_id") ?? "").trim();
6189
6189
  if (!a) return e.json({ error: "group_id_required" }, 400);
6190
- let o = r();
6190
+ let o = n();
6191
6191
  try {
6192
6192
  let t = (await o.listInvites(a)).map(({ token: e, ...t }) => t);
6193
6193
  return e.json({ items: t });
6194
6194
  } finally {
6195
6195
  await o.close();
6196
6196
  }
6197
- }), p.get("/v1/admin/project-invites/:operationId", async (e) => {
6198
- let t = L(e.req.header(I), n);
6199
- if (!t.ok) return e.json({ error: t.error }, 401);
6197
+ }), _.get("/v1/admin/project-invites/:operationId", async (e) => {
6198
+ let r = L(e.req.header(I), t);
6199
+ if (!r.ok) return e.json({ error: r.error }, 401);
6200
6200
  let i = String(e.req.param("operationId") ?? "").trim(), a = String(e.req.query("group_id") ?? "").trim();
6201
6201
  if (!i || !a) return e.json({ error: "operation_id_and_group_id_required" }, 400);
6202
- let o = r();
6202
+ let o = n();
6203
6203
  try {
6204
- let t = await o.getInviteByOperationId(a, i);
6205
- if (!t) return e.json({ error: "operation_not_found" }, 404);
6204
+ let n = await o.getInviteByOperationId(a, i);
6205
+ if (!n) return e.json({ error: "operation_not_found" }, 404);
6206
6206
  let r;
6207
6207
  try {
6208
- r = S(t.project_intent_json);
6208
+ r = ne(n.project_intent_json);
6209
6209
  } catch {
6210
6210
  return e.json({ error: "operation_intent_invalid" }, 409);
6211
6211
  }
6212
6212
  let s = null;
6213
- if (!t.consumed_at && !t.revoked_at && new Date(t.expires_at) > new Date(n.now()) && t.token && !t.token.startsWith("consumed:")) {
6214
- let n = r.map((e) => ({
6213
+ if (!n.consumed_at && !n.revoked_at && new Date(n.expires_at) > new Date(t.now()) && n.token && !n.token.startsWith("consumed:")) {
6214
+ let t = r.map((e) => ({
6215
6215
  display_name: String(e.display_name ?? ""),
6216
6216
  existing_memory_count: Number(e.existing_memory_count ?? 0)
6217
6217
  }));
@@ -6219,59 +6219,59 @@ function Sl(e) {
6219
6219
  v: 1,
6220
6220
  kind: "coordinator_team_invite",
6221
6221
  coordinator_url: new URL(e.req.url).origin,
6222
- group_id: t.group_id,
6223
- policy: t.policy,
6224
- token: t.token,
6225
- expires_at: t.expires_at,
6226
- team_name: t.team_name_snapshot,
6222
+ group_id: n.group_id,
6223
+ policy: n.policy,
6224
+ token: n.token,
6225
+ expires_at: n.expires_at,
6226
+ team_name: n.team_name_snapshot,
6227
6227
  operation_id: i,
6228
- inviter_name: t.inviter_display_name ?? null,
6229
- project_summaries: n
6228
+ inviter_name: n.inviter_display_name ?? null,
6229
+ project_summaries: t
6230
6230
  }));
6231
6231
  }
6232
6232
  return e.json({
6233
- operation_id: t.operation_id,
6234
- group_id: t.group_id,
6235
- reviewed_project_set_digest: t.reviewed_project_set_digest,
6236
- state: t.consumed_at ? "accepted" : "waiting_for_acceptance",
6237
- pending_person_id: t.pending_person_id,
6238
- recipient_actor_id: t.recipient_actor_id,
6239
- recipient_display_name: t.recipient_display_name,
6240
- recipient_device_id: t.bound_device_id,
6241
- recipient_device_display_name: t.recipient_device_display_name,
6242
- recipient_public_key: t.bound_public_key,
6243
- recipient_fingerprint: t.bound_fingerprint,
6244
- consumed_at: t.consumed_at,
6245
- bootstrap_grant_id: t.bootstrap_grant_id,
6246
- trust_state: t.trust_state,
6233
+ operation_id: n.operation_id,
6234
+ group_id: n.group_id,
6235
+ reviewed_project_set_digest: n.reviewed_project_set_digest,
6236
+ state: n.consumed_at ? "accepted" : "waiting_for_acceptance",
6237
+ pending_person_id: n.pending_person_id,
6238
+ recipient_actor_id: n.recipient_actor_id,
6239
+ recipient_display_name: n.recipient_display_name,
6240
+ recipient_device_id: n.bound_device_id,
6241
+ recipient_device_display_name: n.recipient_device_display_name,
6242
+ recipient_public_key: n.bound_public_key,
6243
+ recipient_fingerprint: n.bound_fingerprint,
6244
+ consumed_at: n.consumed_at,
6245
+ bootstrap_grant_id: n.bootstrap_grant_id,
6246
+ trust_state: n.trust_state,
6247
6247
  projects: r,
6248
6248
  invite_link: s
6249
6249
  });
6250
6250
  } finally {
6251
6251
  await o.close();
6252
6252
  }
6253
- }), p.get("/v1/admin/bootstrap-grants/:grantId", async (e) => {
6254
- let t = L(e.req.header(I), n);
6255
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6256
- let i = h(e, "admin", !0);
6253
+ }), _.get("/v1/admin/bootstrap-grants/:grantId", async (e) => {
6254
+ let r = L(e.req.header(I), t);
6255
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6256
+ let i = y(e, "admin", !0);
6257
6257
  if (i) return i;
6258
6258
  let a = String(e.req.param("grantId") ?? "").trim();
6259
6259
  if (!a) return e.json({ error: "grant_id_required" }, 400);
6260
- let o = r();
6260
+ let o = n();
6261
6261
  try {
6262
6262
  return await ol(e, o, {
6263
6263
  grantId: a,
6264
- nowMs: Date.parse(n.now())
6264
+ nowMs: Date.parse(t.now())
6265
6265
  });
6266
6266
  } finally {
6267
6267
  await o.close();
6268
6268
  }
6269
- }), p.get("/v1/bootstrap-grants/:grantId", async (e) => {
6270
- let t = String(e.req.param("grantId") ?? "").trim(), i = String(e.req.query("group_id") ?? "").trim();
6271
- if (!t || !i) return e.json({ error: "grant_id_and_group_id_required" }, 400);
6272
- let o = r();
6269
+ }), _.get("/v1/bootstrap-grants/:grantId", async (e) => {
6270
+ let r = String(e.req.param("grantId") ?? "").trim(), i = String(e.req.query("group_id") ?? "").trim();
6271
+ if (!r || !i) return e.json({ error: "grant_id_and_group_id_required" }, 400);
6272
+ let o = n();
6273
6273
  try {
6274
- let r = await rl(o, n, a, {
6274
+ let n = await rl(o, t, a, {
6275
6275
  method: e.req.method,
6276
6276
  url: e.req.url,
6277
6277
  groupId: i,
@@ -6281,90 +6281,90 @@ function Sl(e) {
6281
6281
  timestamp: e.req.header("X-Opencode-Timestamp") ?? null,
6282
6282
  nonce: e.req.header("X-Opencode-Nonce") ?? null
6283
6283
  });
6284
- return !r.ok || !r.enrollment ? h(e, e.req.path, !1) ?? e.json({ error: r.error }, il(r.error)) : h(e, String(r.enrollment.device_id), !0) || await ol(e, o, {
6285
- grantId: t,
6286
- nowMs: Date.parse(n.now()),
6284
+ return !n.ok || !n.enrollment ? y(e, e.req.path, !1) ?? e.json({ error: n.error }, il(n.error)) : y(e, String(n.enrollment.device_id), !0) || await ol(e, o, {
6285
+ grantId: r,
6286
+ nowMs: Date.parse(t.now()),
6287
6287
  expectedSeed: {
6288
- groupId: r.enrollment.group_id,
6289
- deviceId: r.enrollment.device_id,
6290
- publicKey: r.enrollment.public_key,
6291
- fingerprint: r.enrollment.fingerprint
6288
+ groupId: n.enrollment.group_id,
6289
+ deviceId: n.enrollment.device_id,
6290
+ publicKey: n.enrollment.public_key,
6291
+ fingerprint: n.enrollment.fingerprint
6292
6292
  }
6293
6293
  });
6294
6294
  } finally {
6295
6295
  await o.close();
6296
6296
  }
6297
- }), p.get("/v1/admin/bootstrap-grants", async (e) => {
6298
- let t = L(e.req.header(I), n);
6299
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6300
- let i = h(e, "admin", !0);
6297
+ }), _.get("/v1/admin/bootstrap-grants", async (e) => {
6298
+ let r = L(e.req.header(I), t);
6299
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6300
+ let i = y(e, "admin", !0);
6301
6301
  if (i) return i;
6302
6302
  let a = (e.req.query("group_id") ?? "").trim();
6303
6303
  if (!a) return e.json({ error: "group_id_required" }, 400);
6304
- let o = r();
6304
+ let o = n();
6305
6305
  try {
6306
6306
  return e.json({ items: await o.listBootstrapGrants(a) });
6307
6307
  } finally {
6308
6308
  await o.close();
6309
6309
  }
6310
- }), p.post("/v1/admin/bootstrap-grants/revoke", async (e) => {
6311
- let t = L(e.req.header(I), n);
6312
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6313
- let i = h(e, "admin", !0);
6310
+ }), _.post("/v1/admin/bootstrap-grants/revoke", async (e) => {
6311
+ let r = L(e.req.header(I), t);
6312
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6313
+ let i = y(e, "admin", !0);
6314
6314
  if (i) return i;
6315
6315
  let a = await R(e);
6316
6316
  if (a == null) return e.json({ error: "body_too_large" }, 413);
6317
- let o = g(a);
6317
+ let o = b(a);
6318
6318
  if (!o) return e.json({ error: "invalid_json" }, 400);
6319
6319
  let s = String(o.grant_id ?? "").trim();
6320
6320
  if (!s) return e.json({ error: "grant_id_required" }, 400);
6321
- let c = r();
6321
+ let c = n();
6322
6322
  try {
6323
- return await c.revokeBootstrapGrant(s, n.now()) ? e.json({
6323
+ return await c.revokeBootstrapGrant(s, t.now()) ? e.json({
6324
6324
  ok: !0,
6325
6325
  grant_id: s
6326
6326
  }) : e.json({ error: "grant_not_found" }, 404);
6327
6327
  } finally {
6328
6328
  await c.close();
6329
6329
  }
6330
- }), p.post("/v1/admin/join-requests/approve", async (e) => fl(e, !0, {
6331
- createStore: r,
6332
- runtime: n,
6333
- rateLimitedResponse: h
6334
- })), p.post("/v1/admin/join-requests/deny", async (e) => fl(e, !1, {
6335
- createStore: r,
6336
- runtime: n,
6337
- rateLimitedResponse: h
6338
- })), p.get("/v1/admin/join-requests", async (e) => {
6339
- let t = L(e.req.header(I), n);
6340
- if (!t.ok) return h(e, e.req.path, !1) ?? e.json({ error: t.error }, 401);
6341
- let i = h(e, "admin", !0);
6330
+ }), _.post("/v1/admin/join-requests/approve", async (e) => fl(e, !0, {
6331
+ createStore: n,
6332
+ runtime: t,
6333
+ rateLimitedResponse: y
6334
+ })), _.post("/v1/admin/join-requests/deny", async (e) => fl(e, !1, {
6335
+ createStore: n,
6336
+ runtime: t,
6337
+ rateLimitedResponse: y
6338
+ })), _.get("/v1/admin/join-requests", async (e) => {
6339
+ let r = L(e.req.header(I), t);
6340
+ if (!r.ok) return y(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
6341
+ let i = y(e, "admin", !0);
6342
6342
  if (i) return i;
6343
6343
  let a = (e.req.query("group_id") ?? "").trim();
6344
6344
  if (!a) return e.json({ error: "group_id_required" }, 400);
6345
- let o = r();
6345
+ let o = n();
6346
6346
  try {
6347
6347
  return e.json({ items: await o.listJoinRequests(a) });
6348
6348
  } finally {
6349
6349
  await o.close();
6350
6350
  }
6351
- }), p.post("/v1/join", async (t) => {
6352
- let a = await R(t);
6353
- if (a == null) return t.json({ error: "body_too_large" }, 413);
6354
- let o = g(a);
6355
- if (!o) return t.json({ error: "invalid_json" }, 400);
6356
- let s = String(o.token ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.fingerprint ?? "").trim(), u = String(o.public_key ?? "").trim(), d = String(o.display_name ?? "").trim() || null, f = String(o.operation_id ?? "").trim(), p = String(o.recipient_actor_id ?? "").trim(), m = String(o.recipient_display_name ?? "").trim(), h = String(o.device_display_name ?? "").trim();
6357
- if (!s || !c || !l || !u) return t.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
6358
- if (ue(u) !== l) return t.json({ error: "fingerprint_mismatch" }, 400);
6359
- let _ = r();
6351
+ }), _.post("/v1/join", async (r) => {
6352
+ let a = await R(r);
6353
+ if (a == null) return r.json({ error: "body_too_large" }, 413);
6354
+ let o = b(a);
6355
+ if (!o) return r.json({ error: "invalid_json" }, 400);
6356
+ let s = String(o.token ?? "").trim(), c = String(o.device_id ?? "").trim(), u = String(o.fingerprint ?? "").trim(), d = String(o.public_key ?? "").trim(), f = String(o.display_name ?? "").trim() || null, p = String(o.operation_id ?? "").trim(), m = String(o.recipient_actor_id ?? "").trim(), h = String(o.recipient_display_name ?? "").trim(), g = String(o.device_display_name ?? "").trim();
6357
+ if (!s || !c || !u || !d) return r.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
6358
+ if (i(d) !== u) return r.json({ error: "fingerprint_mismatch" }, 400);
6359
+ let _ = n();
6360
6360
  try {
6361
- let r = await _.getInviteByTokenForInspection(s);
6362
- if (!r) return t.json({ error: "invite_invalid" }, 404);
6363
- let a = !!(r.operation_id || r.reviewed_project_set_digest), g = r.invite_kind === "team_member" || r.invite_kind === "add_device";
6364
- if (r.revoked_at) return t.json({ error: a || g ? "invite_invalid" : "revoked_token" }, 400);
6365
- if (!r.consumed_at && new Date(r.expires_at) <= new Date(n.now())) return t.json({ error: a || g ? "invite_expired" : "expired_token" }, 410);
6366
- if (g) {
6367
- let a = /* @__PURE__ */ new Set([
6361
+ let n = await _.getInviteByTokenForInspection(s);
6362
+ if (!n) return r.json({ error: "invite_invalid" }, 404);
6363
+ let i = !!(n.operation_id || n.reviewed_project_set_digest), a = n.invite_kind === "team_member" || n.invite_kind === "add_device";
6364
+ if (n.revoked_at) return r.json({ error: i || a ? "invite_invalid" : "revoked_token" }, 400);
6365
+ if (!n.consumed_at && new Date(n.expires_at) <= new Date(t.now())) return r.json({ error: i || a ? "invite_expired" : "expired_token" }, 410);
6366
+ if (a) {
6367
+ let i = /* @__PURE__ */ new Set([
6368
6368
  "token",
6369
6369
  "invite_kind",
6370
6370
  "kind",
@@ -6375,37 +6375,37 @@ function Sl(e) {
6375
6375
  "recipient_display_name",
6376
6376
  "device_display_name"
6377
6377
  ]);
6378
- if (Object.keys(o).some((e) => !a.has(e))) return t.json({ error: "unexpected_recipient_invite_fields" }, 400);
6379
- let d = String(o.invite_kind ?? o.kind ?? "").trim(), f = String(o.identity_id ?? "").trim();
6380
- if (!f || d !== r.invite_kind) return t.json({ error: "recipient_invite_binding_required" }, 400);
6381
- if (f.length > 256 || /[\p{Cc}\p{Cf}]/u.test(f)) return t.json({ error: "identity_id_invalid" }, 400);
6378
+ if (Object.keys(o).some((e) => !i.has(e))) return r.json({ error: "unexpected_recipient_invite_fields" }, 400);
6379
+ let a = String(o.invite_kind ?? o.kind ?? "").trim(), f = String(o.identity_id ?? "").trim();
6380
+ if (!f || a !== n.invite_kind) return r.json({ error: "recipient_invite_binding_required" }, 400);
6381
+ if (f.length > 256 || /[\p{Cc}\p{Cf}]/u.test(f)) return r.json({ error: "identity_id_invalid" }, 400);
6382
6382
  let p = null, m = null;
6383
6383
  try {
6384
6384
  if (o.recipient_display_name != null) {
6385
6385
  if (typeof o.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
6386
- p = i(o.recipient_display_name, "recipient_display_name");
6386
+ p = se(o.recipient_display_name, "recipient_display_name");
6387
6387
  }
6388
6388
  if (o.device_display_name != null) {
6389
6389
  if (typeof o.device_display_name != "string") throw Error("device_display_name_invalid");
6390
- m = ae(o.device_display_name, "device_display_name");
6390
+ m = l(o.device_display_name, "device_display_name");
6391
6391
  }
6392
6392
  } catch (e) {
6393
- return t.json({ error: e instanceof Error ? e.message : "recipient_invite_identity_invalid" }, 400);
6393
+ return r.json({ error: e instanceof Error ? e.message : "recipient_invite_identity_invalid" }, 400);
6394
6394
  }
6395
- if (r.invite_kind === "add_device" && String(r.inviter_device_id ?? "").trim() === c) return t.json({ error: "add_device_invite_self_acceptance_forbidden" }, 409);
6395
+ if (n.invite_kind === "add_device" && String(n.inviter_device_id ?? "").trim() === c) return r.json({ error: "add_device_invite_self_acceptance_forbidden" }, 409);
6396
6396
  try {
6397
6397
  let i = await _.consumeRecipientInvite({
6398
6398
  ...Xc(e, s),
6399
- inviteKind: r.invite_kind,
6399
+ inviteKind: n.invite_kind,
6400
6400
  identityId: f,
6401
6401
  deviceId: c,
6402
- publicKey: u,
6403
- fingerprint: l,
6402
+ publicKey: d,
6403
+ fingerprint: u,
6404
6404
  recipientDisplayName: p,
6405
6405
  deviceDisplayName: m,
6406
- now: n.now()
6406
+ now: t.now()
6407
6407
  });
6408
- return t.json({
6408
+ return r.json({
6409
6409
  ok: !0,
6410
6410
  status: i.status,
6411
6411
  kind: i.invite.invite_kind,
@@ -6420,10 +6420,10 @@ function Sl(e) {
6420
6420
  reviewed_intent: i.reviewed_intent
6421
6421
  });
6422
6422
  } catch (e) {
6423
- return ll(t, e);
6423
+ return ll(r, e);
6424
6424
  }
6425
6425
  }
6426
- if (r.operation_id || r.reviewed_project_set_digest) {
6426
+ if (n.operation_id || n.reviewed_project_set_digest) {
6427
6427
  let e = /* @__PURE__ */ new Set([
6428
6428
  "token",
6429
6429
  "operation_id",
@@ -6435,35 +6435,35 @@ function Sl(e) {
6435
6435
  "recipient_display_name",
6436
6436
  "device_display_name"
6437
6437
  ]);
6438
- if (Object.keys(o).some((t) => !e.has(t))) return t.json({ error: "unexpected_project_invite_fields" }, 400);
6439
- if (!f || !p || !m || !h) return t.json({ error: "project_invite_identity_required" }, 400);
6440
- if (String(r.inviter_device_id ?? "").trim() === c) return t.json({ error: "project_invite_self_acceptance_forbidden" }, 409);
6441
- if (p.length > 256 || /[\p{Cc}\p{Cf}]/u.test(p)) return t.json({ error: "recipient_actor_id_invalid" }, 400);
6442
- let a, d;
6438
+ if (Object.keys(o).some((t) => !e.has(t))) return r.json({ error: "unexpected_project_invite_fields" }, 400);
6439
+ if (!p || !m || !h || !g) return r.json({ error: "project_invite_identity_required" }, 400);
6440
+ if (String(n.inviter_device_id ?? "").trim() === c) return r.json({ error: "project_invite_self_acceptance_forbidden" }, 409);
6441
+ if (m.length > 256 || /[\p{Cc}\p{Cf}]/u.test(m)) return r.json({ error: "recipient_actor_id_invalid" }, 400);
6442
+ let i, a;
6443
6443
  try {
6444
- a = i(m, "recipient_display_name"), d = ae(h, "device_display_name");
6444
+ i = se(h, "recipient_display_name"), a = l(g, "device_display_name");
6445
6445
  } catch (e) {
6446
- return t.json({ error: e instanceof Error ? e.message : "project_invite_identity_invalid" }, 400);
6446
+ return r.json({ error: e instanceof Error ? e.message : "project_invite_identity_invalid" }, 400);
6447
6447
  }
6448
- let g;
6448
+ let f;
6449
6449
  try {
6450
- g = te(r);
6450
+ f = C(n);
6451
6451
  } catch {
6452
- return t.json({ error: "operation_intent_invalid" }, 409);
6452
+ return r.json({ error: "operation_intent_invalid" }, 409);
6453
6453
  }
6454
6454
  try {
6455
6455
  let e = await _.consumeProjectInvite({
6456
6456
  token: s,
6457
- operationId: f,
6457
+ operationId: p,
6458
6458
  deviceId: c,
6459
- publicKey: u,
6460
- fingerprint: l,
6461
- recipientActorId: p,
6462
- recipientDisplayName: a,
6463
- deviceDisplayName: d,
6464
- now: n.now()
6459
+ publicKey: d,
6460
+ fingerprint: u,
6461
+ recipientActorId: m,
6462
+ recipientDisplayName: i,
6463
+ deviceDisplayName: a,
6464
+ now: t.now()
6465
6465
  });
6466
- return t.json({
6466
+ return r.json({
6467
6467
  ok: !0,
6468
6468
  status: Nc,
6469
6469
  group_id: e.invite.group_id,
@@ -6476,10 +6476,10 @@ function Sl(e) {
6476
6476
  fingerprint: e.seed_enrollment.fingerprint,
6477
6477
  display_name: e.seed_enrollment.display_name
6478
6478
  } : null,
6479
- accepted_project_intent: g
6479
+ accepted_project_intent: f
6480
6480
  });
6481
6481
  } catch (e) {
6482
- return ul(t, e);
6482
+ return ul(r, e);
6483
6483
  }
6484
6484
  }
6485
6485
  if ([
@@ -6487,53 +6487,53 @@ function Sl(e) {
6487
6487
  "recipient_actor_id",
6488
6488
  "recipient_display_name",
6489
6489
  "device_display_name"
6490
- ].some((e) => Object.hasOwn(o, e))) return t.json({ error: "unexpected_project_invite_fields" }, 400);
6491
- let v = await _.getGroup(String(r.group_id));
6492
- if (!v) return t.json({ error: "group_not_found" }, 404);
6493
- if (v.archived_at) return t.json({ error: "group_archived" }, 409);
6494
- let y = String(r.group_id);
6495
- if (await _.getEnrollment(y, c)) return t.json({
6490
+ ].some((e) => Object.hasOwn(o, e))) return r.json({ error: "unexpected_project_invite_fields" }, 400);
6491
+ let v = await _.getGroup(String(n.group_id));
6492
+ if (!v) return r.json({ error: "group_not_found" }, 404);
6493
+ if (v.archived_at) return r.json({ error: "group_archived" }, 409);
6494
+ let y = String(n.group_id);
6495
+ if (await _.getEnrollment(y, c)) return r.json({
6496
6496
  ok: !0,
6497
6497
  status: "already_enrolled",
6498
- group_id: r.group_id,
6499
- policy: r.policy
6498
+ group_id: n.group_id,
6499
+ policy: n.policy
6500
6500
  });
6501
- let b = String(r.policy);
6502
- if (!["auto_admit", "approval_required"].includes(b)) return t.json({ error: `unknown invite policy: ${b}` }, 400);
6501
+ let b = String(n.policy);
6502
+ if (!["auto_admit", "approval_required"].includes(b)) return r.json({ error: `unknown invite policy: ${b}` }, 400);
6503
6503
  if (b === "approval_required") {
6504
6504
  let e = await _.createJoinRequest({
6505
6505
  groupId: y,
6506
6506
  deviceId: c,
6507
- publicKey: u,
6508
- fingerprint: l,
6509
- displayName: d,
6507
+ publicKey: d,
6508
+ fingerprint: u,
6509
+ displayName: f,
6510
6510
  token: s
6511
6511
  });
6512
- return t.json({
6512
+ return r.json({
6513
6513
  ok: !0,
6514
6514
  status: "pending",
6515
- group_id: r.group_id,
6516
- policy: r.policy,
6515
+ group_id: n.group_id,
6516
+ policy: n.policy,
6517
6517
  request_id: e.request_id
6518
6518
  });
6519
6519
  }
6520
6520
  return await _.enrollDevice(y, {
6521
6521
  deviceId: c,
6522
- fingerprint: l,
6523
- publicKey: u,
6524
- displayName: d
6525
- }), t.json({
6522
+ fingerprint: u,
6523
+ publicKey: d,
6524
+ displayName: f
6525
+ }), r.json({
6526
6526
  ok: !0,
6527
6527
  status: "enrolled",
6528
- group_id: r.group_id,
6529
- policy: r.policy
6528
+ group_id: n.group_id,
6529
+ policy: n.policy
6530
6530
  });
6531
6531
  } catch (e) {
6532
- return sl(t, e);
6532
+ return sl(r, e);
6533
6533
  } finally {
6534
6534
  await _.close();
6535
6535
  }
6536
- }), p;
6536
+ }), _;
6537
6537
  }
6538
6538
  async function Cl(e, t, n) {
6539
6539
  let r = L(e.req.header(I), n.runtime);
@@ -6689,7 +6689,7 @@ function Ll(e) {
6689
6689
  let t = e?.grant;
6690
6690
  if (!t || typeof t != "object" || Array.isArray(t)) throw Error("identity_group_grant_response_invalid");
6691
6691
  let n = t;
6692
- if (e?.kind !== "created" && e?.kind !== "existing" || !w(n.coordinator_id) || !w(n.identity_id) || !w(n.group_id) || !w(n.source_receipt_id) || n.status !== "active" || n.source_kind !== "controller_attestation" || typeof n.revision != "number" || !Number.isSafeInteger(n.revision) || n.revision < 1 || !w(n.created_at) || !Number.isFinite(Date.parse(n.created_at)) || n.revoked_at !== null) throw Error("identity_group_grant_response_invalid");
6692
+ if (e?.kind !== "created" && e?.kind !== "existing" || !T(n.coordinator_id) || !T(n.identity_id) || !T(n.group_id) || !T(n.source_receipt_id) || n.status !== "active" || n.source_kind !== "controller_attestation" || typeof n.revision != "number" || !Number.isSafeInteger(n.revision) || n.revision < 1 || !T(n.created_at) || !Number.isFinite(Date.parse(n.created_at)) || n.revoked_at !== null) throw Error("identity_group_grant_response_invalid");
6693
6693
  return {
6694
6694
  kind: e.kind,
6695
6695
  grant: {
@@ -6739,7 +6739,7 @@ function Vl(e) {
6739
6739
  function Hl(e) {
6740
6740
  if (Reflect.ownKeys(e).some((e) => typeof e != "string" || !Rl.some((t) => t === e))) return z("unknown_field");
6741
6741
  let t = zl(e, "coordinatorId"), n = zl(e, "issuer"), r = zl(e, "clientId"), i = zl(e, "clientSecret"), a = zl(e, "redirectUri"), o = zl(e, "revision");
6742
- if (!w(t)) return z("coordinatorId");
6742
+ if (!T(t)) return z("coordinatorId");
6743
6743
  if (n !== "https://accounts.google.com") return z("issuer");
6744
6744
  if (!Bl(r, 256)) return z("clientId");
6745
6745
  if (!Bl(i, 4096)) return z("clientSecret");
@@ -8052,7 +8052,7 @@ function op(e, t) {
8052
8052
  "clientSecret",
8053
8053
  "redirectUri"
8054
8054
  ]), r = rp(t === void 0 ? {} : t, ["fetch", "timeoutSeconds"]), i = ip(n.redirectUri, { allowQuery: !1 });
8055
- if (!oe(n.issuer) || !ip(n.issuer, { allowQuery: !1 }) || !ap(n.clientId, 256) || !ap(n.clientSecret, 4096) || typeof n.redirectUri != "string" || !i || i.href !== n.redirectUri || r.fetch !== void 0 && typeof r.fetch != "function") throw Error();
8055
+ if (!Te(n.issuer) || !ip(n.issuer, { allowQuery: !1 }) || !ap(n.clientId, 256) || !ap(n.clientSecret, 4096) || typeof n.redirectUri != "string" || !i || i.href !== n.redirectUri || r.fetch !== void 0 && typeof r.fetch != "function") throw Error();
8056
8056
  let a = r.timeoutSeconds === void 0 ? 10 : r.timeoutSeconds;
8057
8057
  if (typeof a != "number" || !Number.isFinite(a) || a < 1 || a > 30) throw Error();
8058
8058
  return {
@@ -8156,7 +8156,7 @@ function pp(e, t, n) {
8156
8156
  idTokenExpected: !0
8157
8157
  }), r = n.claims();
8158
8158
  if (!r || r.iss !== t) throw Error();
8159
- let i = s({
8159
+ let i = be({
8160
8160
  issuer: r.iss,
8161
8161
  subject: r.sub
8162
8162
  }, { issuer: t });
@@ -8245,8 +8245,8 @@ var gp = [
8245
8245
  gp.join("\n");
8246
8246
  //#endregion
8247
8247
  //#region src/owner-enrollment-link-authority.ts
8248
- var _p = (Me.match(/CREATE (?:TABLE|TRIGGER|INDEX)[\s\S]*?;(?=\s*(?:--|CREATE|$))/gu) ?? []).filter((e) => /^CREATE TABLE/u.test(e) || /CREATE TRIGGER IF NOT EXISTS owner_enrollment_authority_/u.test(e)), vp = [..._p, ...gp].map((e) => {
8249
- let t = ce(e).matches;
8248
+ var _p = (x.match(/CREATE (?:TABLE|TRIGGER|INDEX)[\s\S]*?;(?=\s*(?:--|CREATE|$))/gu) ?? []).filter((e) => /^CREATE TABLE/u.test(e) || /CREATE TRIGGER IF NOT EXISTS owner_enrollment_authority_/u.test(e)), vp = [..._p, ...gp].map((e) => {
8249
+ let t = ne(e).matches;
8250
8250
  return e.startsWith("CREATE TABLE IF NOT EXISTS coordinator_owner_enrollment_attempts") ? t.replace("FROM sqlite_master WHERE", "FROM (SELECT type,name,CASE WHEN substr(sql,1,52) = 'CREATE TABLE \"coordinator_owner_enrollment_attempts\"'\n THEN 'CREATE TABLE coordinator_owner_enrollment_attempts' || substr(sql,53)\n ELSE sql END AS sql FROM sqlite_master) WHERE") : t;
8251
8251
  }).join(" AND "), yp = `SELECT l.coordinator_id,l.link_id,q.qualification_id
8252
8252
  FROM owner_claim_proven_links l
@@ -8280,13 +8280,13 @@ async function bp(e, t = Date.now(), n = {
8280
8280
  let i = (await e.first({
8281
8281
  sql: "SELECT EXISTS (SELECT 1 FROM pragma_table_info('coordinator_owner_enrollment_attempts') WHERE name='owner_qualification_id') AS present",
8282
8282
  values: []
8283
- }))?.present === 1, o = !1;
8284
- return i && await a(e) && (o = (await e.first({
8283
+ }))?.present === 1, a = !1;
8284
+ return i && await ve(e) && (a = (await e.first({
8285
8285
  sql: `SELECT (${vp}) AS ready`,
8286
8286
  values: []
8287
8287
  }))?.ready === 1 && _p.length === 3), Sp({
8288
8288
  hasPin: i,
8289
- qualified: o,
8289
+ qualified: a,
8290
8290
  time: t,
8291
8291
  scope: r
8292
8292
  });
@@ -8307,7 +8307,7 @@ function Sp({ hasPin: e, qualified: t, time: n, scope: r }) {
8307
8307
  return (t || r.sql !== "0") && (s = `WITH owner_scope_links AS MATERIALIZED (
8308
8308
  SELECT l.* FROM coordinator_auth_account_links l WHERE ${r.sql})${t ? `, owner_claim_proven_links AS MATERIALIZED (
8309
8309
  SELECT l.* FROM owner_scope_links l
8310
- WHERE ${me({
8310
+ WHERE ${ge({
8311
8311
  link: "l",
8312
8312
  connections: !0
8313
8313
  })}),
@@ -8346,8 +8346,8 @@ function Dp(e, t) {
8346
8346
  return typeof e == "string" && e.length > 0 && e.length <= t && !/[\p{Cc}\p{Cf}\p{Cs}]/u.test(e);
8347
8347
  }
8348
8348
  function Op(e, t) {
8349
- let n = we(t.publicKey), r = new URL(e.origin);
8350
- if (!w(e.coordinatorId) || !Dp(e.revision, 64) || !/^[a-f0-9]{64}$/.test(e.revision) || r.protocol !== "https:" || r.origin !== e.origin || !Dp(e.issuer, 4096) || !w(t.attemptId) || !w(t.deviceId) || !Dp(t.publicKey, 80) || n.kind !== "ed25519" || t.publicKey !== `ssh-ed25519 ${btoa(String.fromCharCode(...n.blob))}` || !Dp(t.loopbackRedirect, 4096) || !h(t.loopbackRedirect).ok || !d(t.browserStartCode) || !Dp(t.signature, 86)) throw Error("owner_admission_invalid_start");
8349
+ let n = a(t.publicKey), r = new URL(e.origin);
8350
+ if (!T(e.coordinatorId) || !Dp(e.revision, 64) || !/^[a-f0-9]{64}$/.test(e.revision) || r.protocol !== "https:" || r.origin !== e.origin || !Dp(e.issuer, 4096) || !T(t.attemptId) || !T(t.deviceId) || !Dp(t.publicKey, 80) || n.kind !== "ed25519" || t.publicKey !== `ssh-ed25519 ${btoa(String.fromCharCode(...n.blob))}` || !Dp(t.loopbackRedirect, 4096) || !S(t.loopbackRedirect).ok || !w(t.browserStartCode) || !Dp(t.signature, 86)) throw Error("owner_admission_invalid_start");
8351
8351
  return JSON.stringify([
8352
8352
  "codemem-owner-enrollment-start-v1",
8353
8353
  "owner_enroll",
@@ -8382,7 +8382,7 @@ async function jp(e, t, n, r) {
8382
8382
  let i = Cp.get(e), a = Op(t, n), o = r.nowMs, s = o + r.ttlMs, c = n.signature;
8383
8383
  if (!i || !kp(o, s, o) || !await Xi(n.publicKey, a, c)) throw Error("owner_admission_invalid_start");
8384
8384
  let l = await globalThis.crypto.subtle.sign("HMAC", i, Ap(a, c, o, s));
8385
- return `v1.${o}.${s}.${g(new Uint8Array(l))}`;
8385
+ return `v1.${o}.${s}.${v(new Uint8Array(l))}`;
8386
8386
  }
8387
8387
  async function Mp(e, t, n, r, i) {
8388
8388
  try {
@@ -8390,7 +8390,7 @@ async function Mp(e, t, n, r, i) {
8390
8390
  if (!a || typeof t != "string" || t.length > 81) return !1;
8391
8391
  let o = /^v1\.(0|[1-9][0-9]{0,15})\.(0|[1-9][0-9]{0,15})\.([A-Za-z0-9_-]{43})$/.exec(t);
8392
8392
  if (!o) return !1;
8393
- let s = Number(o[1]), c = Number(o[2]), l = d(o[3]);
8393
+ let s = Number(o[1]), c = Number(o[2]), l = w(o[3]);
8394
8394
  return !l || !kp(s, c, i) ? !1 : await globalThis.crypto.subtle.verify("HMAC", a, l, Ap(Op(n, r), r.signature, s, c));
8395
8395
  } catch {
8396
8396
  return !1;
@@ -8398,10 +8398,10 @@ async function Mp(e, t, n, r, i) {
8398
8398
  }
8399
8399
  function Np(e) {
8400
8400
  let { coordinatorId: t, issuer: n, subject: r, identityId: i, linkId: a } = e;
8401
- if (!w(t) || !Dp(n, 4096) || !s({
8401
+ if (!T(t) || !Dp(n, 4096) || !be({
8402
8402
  issuer: n,
8403
8403
  subject: r
8404
- }, { issuer: n }).ok || !w(i) || !w(a)) throw Error("owner_admission_invalid_owner");
8404
+ }, { issuer: n }).ok || !T(i) || !T(a)) throw Error("owner_admission_invalid_owner");
8405
8405
  return JSON.stringify([
8406
8406
  "codemem-owner-enrollment-owner-commitment-v1",
8407
8407
  t,
@@ -8460,7 +8460,7 @@ async function Rp(e, t, n, r) {
8460
8460
  let i = Cp.get(e), a = Ip(t, n, r.resolvedOwner), o = r.nowMs, s = r.ttlMs, c = o + s;
8461
8461
  if (!i || !Number.isSafeInteger(s) || !kp(o, c, o) || !await Xi(a.publicKey, a.tuple, a.signature)) throw Error("owner_admission_invalid_start");
8462
8462
  let l = await Pp(a.ownerMessage), u = await globalThis.crypto.subtle.sign("HMAC", i, Lp(a.tuple, a.signature, o, c, l));
8463
- return `v2.${o}.${c}.${l}.${g(new Uint8Array(u))}`;
8463
+ return `v2.${o}.${c}.${l}.${v(new Uint8Array(u))}`;
8464
8464
  }
8465
8465
  async function zp(e, t, n, r, i) {
8466
8466
  try {
@@ -8468,10 +8468,10 @@ async function zp(e, t, n, r, i) {
8468
8468
  if (!a || typeof t != "string" || t.length > 146) return !1;
8469
8469
  let o = /^v2\.(0|[1-9][0-9]{0,15})\.(0|[1-9][0-9]{0,15})\.([a-f0-9]{64})\.([A-Za-z0-9_-]{43})$/.exec(t);
8470
8470
  if (!o) return !1;
8471
- let s = Number(o[1]), c = Number(o[2]), l = o[3], u = d(o[4]), f = i.nowMs;
8472
- if (!u || !l || !kp(s, c, f)) return !1;
8473
- let p = Ip(n, r, i.resolvedOwner);
8474
- return await Pp(p.ownerMessage) === l && await globalThis.crypto.subtle.verify("HMAC", a, u, Lp(p.tuple, p.signature, s, c, l));
8471
+ let s = Number(o[1]), c = Number(o[2]), l = o[3], u = w(o[4]), d = i.nowMs;
8472
+ if (!u || !l || !kp(s, c, d)) return !1;
8473
+ let f = Ip(n, r, i.resolvedOwner);
8474
+ return await Pp(f.ownerMessage) === l && await globalThis.crypto.subtle.verify("HMAC", a, u, Lp(f.tuple, f.signature, s, c, l));
8475
8475
  } catch {
8476
8476
  return !1;
8477
8477
  }
@@ -8515,16 +8515,16 @@ var Wp = `json_array_length(a.grant_revisions_json) BETWEEN 1 AND 50
8515
8515
  AND r.group_id = json_extract(p.value,'$.groupId') AND r.revision = json_extract(p.value,'$.revision')
8516
8516
  AND r.status = 'active' AND r.revoked_at IS NULL AND g.archived_at IS NULL)
8517
8517
  OR ${Up("json_extract(p.value,'$.groupId')")})`, Gp = "NOT EXISTS (SELECT 1 FROM coordinator_device_revocations\n WHERE (subject_kind = 'device_id' AND subject_value = a.device_id)\n OR (subject_kind = 'ed25519_key' AND subject_value = a.key_id))";
8518
- async function Kp(e, t) {
8519
- let n = await e.first({
8518
+ async function Kp(e, r) {
8519
+ let i = await e.first({
8520
8520
  sql: "SELECT json_group_array(json_object('groupId',group_id,'deviceId',device_id,'publicKey',public_key)) AS rows FROM\n (SELECT group_id,device_id,public_key FROM enrolled_devices LIMIT ?)",
8521
8521
  values: [501]
8522
8522
  });
8523
- if (!n) return null;
8524
- let r = JSON.parse(n.rows);
8525
- if (r.length > 500) return null;
8526
- for (let e of r) if (e.deviceId === t.device_id || Ne(e.publicKey).kind === "malformed_ed25519" || await Ee(e.publicKey) === t.key_id) return null;
8527
- return n.rows;
8523
+ if (!i) return null;
8524
+ let a = JSON.parse(i.rows);
8525
+ if (a.length > 500) return null;
8526
+ for (let e of a) if (e.deviceId === r.device_id || t(e.publicKey).kind === "malformed_ed25519" || await n(e.publicKey) === r.key_id) return null;
8527
+ return i.rows;
8528
8528
  }
8529
8529
  var qp = "(SELECT count(*) FROM enrolled_devices) = json_array_length(?)\n AND NOT EXISTS (SELECT 1 FROM enrolled_devices e WHERE NOT EXISTS (SELECT 1 FROM json_each(?) k\n WHERE e.group_id = json_extract(k.value,'$.groupId') AND e.device_id = json_extract(k.value,'$.deviceId')\n AND e.public_key = json_extract(k.value,'$.publicKey')))", Jp = "coordinator_id = ? AND attempt_id = ? AND state = 'finalized' AND binding_id = ?";
8530
8530
  function Yp(e, t) {
@@ -8567,10 +8567,10 @@ async function Xp(e) {
8567
8567
  WHERE a.coordinator_id=? AND a.attempt_id=? AND ${h.active}${_}) ${g.sql.replace("loopback_redirect = NULL", "loopback_redirect = NULL FROM owner_commit_links p").replace(Hp, "p.coordinator_id=a.coordinator_id AND p.attempt_id=a.attempt_id")}`, g.values.unshift(...h.values, o.coordinator_id, o.attempt_id), h.hasPin && (g.sql += " AND a.owner_qualification_id IS ?", g.values.push(o.owner_qualification_id ?? null)), await t.batch([Qp(g, u), ...im(m, r, c.length, u)]), $p(t, m);
8568
8568
  }
8569
8569
  async function Zp(e) {
8570
- return await je(e) ? ` AND ${de}` : "";
8570
+ return await ee(e) ? ` AND ${c}` : "";
8571
8571
  }
8572
8572
  function Qp(e, t) {
8573
- let n = u(e, t), r = "FROM owner_commit_links p", i = "AND (SELECT matches FROM negative_owner_consistency)";
8573
+ let n = ae(e, t), r = "FROM owner_commit_links p", i = "AND (SELECT matches FROM negative_owner_consistency)";
8574
8574
  if (!n.sql.includes(r) || !n.sql.includes(i)) throw Error("owner_enrollment_statement_invalid");
8575
8575
  return {
8576
8576
  sql: n.sql.replace(r, `${r} CROSS JOIN negative_owner_consistency negative`).replace(i, "AND negative.matches"),
@@ -8584,7 +8584,7 @@ async function $p(e, t) {
8584
8584
  }) !== null;
8585
8585
  }
8586
8586
  function em(e, t) {
8587
- return se(e, {
8587
+ return te(e, {
8588
8588
  coordinatorId: t.coordinator_id,
8589
8589
  ownerIdentityId: t.identity_id ?? "",
8590
8590
  deviceId: t.device_id,
@@ -8673,7 +8673,7 @@ function im(e, t, n, r) {
8673
8673
  values: e
8674
8674
  };
8675
8675
  return [
8676
- u(i, r),
8676
+ ae(i, r),
8677
8677
  Yp(e, 1),
8678
8678
  a,
8679
8679
  Yp(e, n),
@@ -8761,19 +8761,19 @@ async function um(e, t, n, r) {
8761
8761
  n,
8762
8762
  r
8763
8763
  ]
8764
- }, o = await a(e), s = await bp(e, t, i);
8764
+ }, a = await ve(e), o = await bp(e, t, i);
8765
8765
  return {
8766
- values: s.values,
8767
- with: `${s.with ? `${s.with},` : "WITH"} owner_admission_proven_links AS MATERIALIZED (
8768
- SELECT l.* FROM owner_scope_links l WHERE ${Be("l", { connections: o })}),
8766
+ values: o.values,
8767
+ with: `${o.with ? `${o.with},` : "WITH"} owner_admission_proven_links AS MATERIALIZED (
8768
+ SELECT l.* FROM owner_scope_links l WHERE ${Ne("l", { connections: a })}),
8769
8769
  owner_admission_links AS MATERIALIZED (
8770
- SELECT l.* FROM owner_admission_proven_links l WHERE ${s.link}
8771
- ${o ? `AND (${ze})` : ""}),
8770
+ SELECT l.* FROM owner_admission_proven_links l WHERE ${o.link}
8771
+ ${a ? `AND (${Ce})` : ""}),
8772
8772
  owner_admission_sessions AS MATERIALIZED (
8773
8773
  SELECT s.coordinator_id,s.identity_id,s.link_id,s.issuer,s.subject,l.authority_kind,l.controller_attestation_id
8774
8774
  FROM coordinator_auth_sessions s JOIN owner_admission_links l
8775
8775
  ON l.coordinator_id=s.coordinator_id AND l.link_id=s.link_id AND l.identity_id=s.identity_id
8776
- AND l.issuer=s.issuer AND l.subject=s.subject WHERE (${De}))`,
8776
+ AND l.issuer=s.issuer AND l.subject=s.subject WHERE (${de}))`,
8777
8777
  from: `FROM (SELECT ? AS coordinator_id,? AS device_id,? AS fingerprint) a
8778
8778
  JOIN owner_admission_sessions s ON s.coordinator_id = a.coordinator_id
8779
8779
  WHERE EXISTS (SELECT 1 FROM coordinator_identity_group_grants r JOIN groups g ON g.group_id = r.group_id
@@ -8850,7 +8850,7 @@ function _m(e, t) {
8850
8850
  return e;
8851
8851
  }
8852
8852
  function vm(e) {
8853
- if (!w(e)) throw Error();
8853
+ if (!T(e)) throw Error();
8854
8854
  return e;
8855
8855
  }
8856
8856
  function ym(e) {
@@ -8877,9 +8877,9 @@ async function xm(e) {
8877
8877
  return Array.from(new Uint8Array(t), (e) => e.toString(16).padStart(2, "0")).join("");
8878
8878
  }
8879
8879
  async function Sm(e) {
8880
- let t = d(e);
8880
+ let t = w(e);
8881
8881
  if (!t) throw Error();
8882
- return T(t);
8882
+ return b(t);
8883
8883
  }
8884
8884
  function Cm(e, t) {
8885
8885
  return JSON.stringify([
@@ -8914,7 +8914,7 @@ function Tm(e) {
8914
8914
  let r = Em(t, $(e, "oidcOptions")), i = t === "production" ? $(e, "admissionKey") : void 0;
8915
8915
  if (t === "production" && !Tp(i)) throw Error();
8916
8916
  let a = $(e, "csrfKey"), o = $(e, "limiter");
8917
- if (!Ce(a) || typeof o?.check != "function") throw Error();
8917
+ if (!Le(a) || typeof o?.check != "function") throw Error();
8918
8918
  let s = $(e, "backend");
8919
8919
  if (!s || ![
8920
8920
  s.first,
@@ -8953,7 +8953,7 @@ async function Dm(e) {
8953
8953
  c: l,
8954
8954
  client: c,
8955
8955
  admissionKey: s,
8956
- now: () => p(u),
8956
+ now: () => Se(u),
8957
8957
  pin: Object.freeze({
8958
8958
  coordinatorId: l.coordinatorId,
8959
8959
  origin: n.publicOrigin,
@@ -9012,7 +9012,7 @@ async function Am(e, t) {
9012
9012
  if (n.method !== "GET" || n.url.length > 8192 || n.url.includes("#")) return Q;
9013
9013
  let r = new URL(n.url), i = new URL(e.c.redirectUri), a = r.searchParams.getAll("state");
9014
9014
  if (r.origin !== i.origin || r.pathname !== i.pathname || r.username || r.password || a.length !== 1 || !/^[A-Za-z0-9._~-]{43,128}$/.test(a[0] ?? "")) return Q;
9015
- let o = a[0], s = await v(n.cookie, "transaction");
9015
+ let o = a[0], s = await g(n.cookie, "transaction");
9016
9016
  if (s.kind !== "present") return Q;
9017
9017
  let c = await Fm(e, o, s.cookieHash);
9018
9018
  if (!c) return Q;
@@ -9029,7 +9029,7 @@ async function Am(e, t) {
9029
9029
  return u === "target_headless_linked" ? mm : u ? {
9030
9030
  kind: "verified",
9031
9031
  confirmation: await Bm(u),
9032
- csrf: await xe(e.csrfKey, s.secret, "transaction", e.scope)
9032
+ csrf: await he(e.csrfKey, s.secret, "transaction", e.scope)
9033
9033
  } : Q;
9034
9034
  }
9035
9035
  function jm(e) {
@@ -9125,7 +9125,7 @@ var Im = `SELECT json_group_array(json_object('groupId',groupId,'revision',revis
9125
9125
  AND NOT ${Up("r.group_id")} ORDER BY r.group_id LIMIT 51)`;
9126
9126
  async function Lm(e, t, n) {
9127
9127
  let r = await e.backend.first({
9128
- sql: `SELECT l.*,NULL AS owner_qualification_id,${le} AS headless_capable FROM coordinator_auth_account_links l WHERE l.coordinator_id = ? AND l.issuer = ? AND l.subject = ? AND l.revoked_at_ms IS NULL`,
9128
+ sql: `SELECT l.*,NULL AS owner_qualification_id,${Ue} AS headless_capable FROM coordinator_auth_account_links l WHERE l.coordinator_id = ? AND l.issuer = ? AND l.subject = ? AND l.revoked_at_ms IS NULL`,
9129
9129
  values: [
9130
9130
  e.c.coordinatorId,
9131
9131
  n.issuer,
@@ -9144,7 +9144,7 @@ async function Lm(e, t, n) {
9144
9144
  link_id: s.link_id
9145
9145
  })) return null;
9146
9146
  let l = i === 1, u = await e.backend.first({
9147
- sql: `SELECT (${Im}) AS rows${l ? `,${te("a.coordinator_id")} AS headless` : ""}
9147
+ sql: `SELECT (${Im}) AS rows${l ? `,${le("a.coordinator_id")} AS headless` : ""}
9148
9148
  FROM coordinator_owner_enrollment_attempts a WHERE ${jm("browser_claimed")}`,
9149
9149
  values: [
9150
9150
  s.identity_id,
@@ -9165,11 +9165,11 @@ async function Rm(e, t, n) {
9165
9165
  sql: "l.coordinator_id=? AND l.link_id=?",
9166
9166
  values: [e.c.coordinatorId, n.link_id]
9167
9167
  };
9168
- if (n.authority_kind === "controller_attestation" && w(n.controller_attestation_id) && n.device_claim_id === null) return {
9168
+ if (n.authority_kind === "controller_attestation" && T(n.controller_attestation_id) && n.device_claim_id === null) return {
9169
9169
  authority: xp(t, r),
9170
9170
  link: n
9171
9171
  };
9172
- if (n.authority_kind !== "device_claim" || n.controller_attestation_id !== null || !w(n.device_claim_id)) return null;
9172
+ if (n.authority_kind !== "device_claim" || n.controller_attestation_id !== null || !T(n.device_claim_id)) return null;
9173
9173
  let i = await bp(e.backend, e.now(), r), a = await e.backend.first({
9174
9174
  sql: `${i.with}SELECT ${i.qualification} AS owner_qualification_id
9175
9175
  FROM owner_scope_links l WHERE l.coordinator_id=? AND l.link_id=?
@@ -9293,7 +9293,7 @@ async function Gm(e, t, n) {
9293
9293
  sql: "l.coordinator_id=? AND l.link_id=?",
9294
9294
  values: [t.coordinator_id, t.link_id]
9295
9295
  }, i = Object.hasOwn(t, "owner_qualification_id");
9296
- if (w(t.link_controller_attestation_id)) {
9296
+ if (T(t.link_controller_attestation_id)) {
9297
9297
  if (i && t.owner_qualification_id !== null) throw Error();
9298
9298
  let e = xp(t, r);
9299
9299
  return i ? e : {
@@ -9317,7 +9317,7 @@ async function Km(e, t, n) {
9317
9317
  n
9318
9318
  ]
9319
9319
  }), i = e.now();
9320
- if (!uh(e, r, i) || !r.browser_transaction_hash || !r.loopback_redirect || !h(r.loopback_redirect).ok) return null;
9320
+ if (!uh(e, r, i) || !r.browser_transaction_hash || !r.loopback_redirect || !S(r.loopback_redirect).ok) return null;
9321
9321
  let a = await Gm(e, r, i);
9322
9322
  return await e.backend.first({
9323
9323
  sql: `${Um(a)}SELECT 1 FROM coordinator_owner_enrollment_attempts a
@@ -9340,7 +9340,7 @@ async function qm(e, t, n, r) {
9340
9340
  limiter: e.limiter
9341
9341
  });
9342
9342
  if (!a.ok || a.action !== "transaction_attempt") return Q;
9343
- let o = await v(i.cookie, "transaction");
9343
+ let o = await g(i.cookie, "transaction");
9344
9344
  if (o.kind !== "present" || o.cookieHash !== a.cookieHash) return Q;
9345
9345
  let s = await Km(e, a.attemptId, o.cookieHash);
9346
9346
  if (!s?.loopback_redirect) return Q;
@@ -9403,29 +9403,29 @@ function Xm(e) {
9403
9403
  function Zm(e, t) {
9404
9404
  return !!t && t.purpose === "owner_enroll" && t.coordinator_id === e.c.coordinatorId && t.origin === e.pin.origin && t.issuer === e.c.issuer && Bp(t.admission_owner_hash) && (t.state === "finalized" || t.auth_config_revision === e.c.revision) && !!t.confirmation_hash;
9405
9405
  }
9406
- async function Qm(t, n) {
9407
- let r;
9406
+ async function Qm(e, t) {
9407
+ let n;
9408
9408
  try {
9409
- r = Xm(n);
9409
+ n = Xm(t);
9410
9410
  } catch {
9411
9411
  return Q;
9412
9412
  }
9413
- let i = await lh(t, r.attemptId);
9414
- if (!Zm(t, i)) return Q;
9415
- let a = await Yi(i, r.completionSecret, r.signature);
9416
- if (!a || a.completionHash !== i.completion_secret_hash) return Q;
9417
- if (i.state === "finalized") return th(t, i, a);
9418
- let o = t.now();
9419
- if (!uh(t, i, o) || i.state !== "confirmed" || (await Bm(i)).confirmationHash !== i.confirmation_hash) return Q;
9420
- let s = await Xp({
9421
- backend: t.backend,
9422
- row: i,
9423
- revision: t.c.revision,
9424
- now: o,
9425
- completionSecret: r.completionSecret,
9426
- signature: r.signature
9427
- }), c = await $m(t, r, { committed: s });
9428
- return c.kind === "rejected" && i.link_id && await e(t.backend, t.c.coordinatorId, i.link_id) ? mm : c;
9413
+ let r = await lh(e, n.attemptId);
9414
+ if (!Zm(e, r)) return Q;
9415
+ let i = await Yi(r, n.completionSecret, n.signature);
9416
+ if (!i || i.completionHash !== r.completion_secret_hash) return Q;
9417
+ if (r.state === "finalized") return th(e, r, i);
9418
+ let a = e.now();
9419
+ if (!uh(e, r, a) || r.state !== "confirmed" || (await Bm(r)).confirmationHash !== r.confirmation_hash) return Q;
9420
+ let o = await Xp({
9421
+ backend: e.backend,
9422
+ row: r,
9423
+ revision: e.c.revision,
9424
+ now: a,
9425
+ completionSecret: n.completionSecret,
9426
+ signature: n.signature
9427
+ }), s = await $m(e, n, { committed: o });
9428
+ return s.kind === "rejected" && r.link_id && await y(e.backend, e.c.coordinatorId, r.link_id) ? mm : s;
9429
9429
  }
9430
9430
  async function $m(e, t, n) {
9431
9431
  let r = await lh(e, t.attemptId);
@@ -9446,7 +9446,7 @@ async function th(e, t, n) {
9446
9446
  }
9447
9447
  function nh(e, t) {
9448
9448
  let n = Wi(e.grant_revisions_json);
9449
- if (!n || !e.binding_id || !w(e.identity_id)) throw Error();
9449
+ if (!n || !e.binding_id || !T(e.identity_id)) throw Error();
9450
9450
  return {
9451
9451
  kind: t,
9452
9452
  bindingId: e.binding_id,
@@ -9455,49 +9455,49 @@ function nh(e, t) {
9455
9455
  };
9456
9456
  }
9457
9457
  var rh = "NOT EXISTS (SELECT 1 FROM coordinator_device_ownership_bindings WHERE device_id = ? OR key_id = ?)\n AND NOT EXISTS (SELECT 1 FROM coordinator_device_revocations WHERE (subject_kind = 'device_id' AND subject_value = ?)\n OR (subject_kind = 'ed25519_key' AND subject_value = ?))";
9458
- async function ih(e, t, n, r) {
9459
- let i = ah(t, r);
9460
- if (!w(n) || n.length > 128 || $(e.limiter.check(JSON.stringify([
9458
+ async function ih(t, n, r, i) {
9459
+ let a = ah(n, i);
9460
+ if (!T(r) || r.length > 128 || $(t.limiter.check(JSON.stringify([
9461
9461
  "owner-enrollment-start",
9462
- e.c.coordinatorId,
9463
- n
9464
- ]), hm), "allowed") !== !0 || !i) return Q;
9465
- let { i: a } = i, o;
9462
+ t.c.coordinatorId,
9463
+ r
9464
+ ]), hm), "allowed") !== !0 || !a) return Q;
9465
+ let { i: o } = a, s;
9466
9466
  try {
9467
- o = await Sm(a.browserStartCode);
9467
+ s = await Sm(o.browserStartCode);
9468
9468
  } catch {
9469
9469
  return Q;
9470
9470
  }
9471
- let s = await sh(e, i);
9472
- if (!s) return Q;
9473
- let { admissionOwnerHash: c } = s;
9474
- if (!h(a.loopbackRedirect).ok) return Q;
9475
- let l = await he(a.publicKey);
9476
- if (!l || !await Xi(a.publicKey, Cm(a, e.pin), a.signature)) return Q;
9477
- let u = await xm(a.publicKey), d = e.now(), f = ch(e, a, {
9478
- keyId: l,
9479
- fingerprint: u,
9480
- browserStartHash: o,
9481
- time: d,
9482
- admissionOwnerHash: c
9471
+ let c = await sh(t, a);
9472
+ if (!c) return Q;
9473
+ let { admissionOwnerHash: l } = c;
9474
+ if (!S(o.loopbackRedirect).ok) return Q;
9475
+ let u = await e(o.publicKey);
9476
+ if (!u || !await Xi(o.publicKey, Cm(o, t.pin), o.signature)) return Q;
9477
+ let d = await xm(o.publicKey), f = t.now(), p = ch(t, o, {
9478
+ keyId: u,
9479
+ fingerprint: d,
9480
+ browserStartHash: s,
9481
+ time: f,
9482
+ admissionOwnerHash: l
9483
9483
  });
9484
- if (i.owner && i.sessionCookieHash !== void 0) {
9485
- let t = await pm({
9486
- backend: e.backend,
9487
- config: e.c,
9488
- sessionCookieHash: i.sessionCookieHash,
9489
- owner: i.owner,
9490
- deviceId: a.deviceId,
9491
- fingerprint: u,
9492
- time: d
9484
+ if (a.owner && a.sessionCookieHash !== void 0) {
9485
+ let e = await pm({
9486
+ backend: t.backend,
9487
+ config: t.c,
9488
+ sessionCookieHash: a.sessionCookieHash,
9489
+ owner: a.owner,
9490
+ deviceId: o.deviceId,
9491
+ fingerprint: d,
9492
+ time: f
9493
9493
  });
9494
- f.sql = `WITH owner_admission_authority AS MATERIALIZED (${t.sql})
9495
- ${f.sql} AND EXISTS (SELECT 1 FROM owner_admission_authority)`, f.values.unshift(...t.values);
9494
+ p.sql = `WITH owner_admission_authority AS MATERIALIZED (${e.sql})
9495
+ ${p.sql} AND EXISTS (SELECT 1 FROM owner_admission_authority)`, p.values.unshift(...e.values);
9496
9496
  }
9497
- return await e.backend.run(f) === 1 ? {
9497
+ return await t.backend.run(p) === 1 ? {
9498
9498
  kind: "started",
9499
- attemptId: a.attemptId,
9500
- expiresAtMs: d + 6e5
9499
+ attemptId: o.attemptId,
9500
+ expiresAtMs: f + 6e5
9501
9501
  } : Q;
9502
9502
  }
9503
9503
  function ah(e, t) {
@@ -9578,15 +9578,15 @@ function ch(e, t, n) {
9578
9578
  2,
9579
9579
  r.coordinatorId,
9580
9580
  t.deviceId,
9581
- n.time - y,
9581
+ n.time - _,
9582
9582
  6,
9583
9583
  r.coordinatorId,
9584
9584
  n.time,
9585
9585
  gm,
9586
9586
  gm,
9587
9587
  r.coordinatorId,
9588
- C,
9589
- C
9588
+ p,
9589
+ p
9590
9590
  ]
9591
9591
  };
9592
9592
  }
@@ -9601,7 +9601,7 @@ function uh(e, t, n) {
9601
9601
  return !!t && t.coordinator_id === e.c.coordinatorId && t.purpose === "owner_enroll" && t.origin === e.pin.origin && t.issuer === e.c.issuer && t.auth_config_revision === e.c.revision && Bp(t.admission_owner_hash) && Gi(t) && t.created_at_ms <= n && t.expires_at_ms > n;
9602
9602
  }
9603
9603
  async function dh(e, t, n) {
9604
- let r = Hi(t), i = await Ui(r.cookie, new Fe(e.backend, e.now), e.c);
9604
+ let r = Hi(t), i = await Ui(r.cookie, new o(e.backend, e.now), e.c);
9605
9605
  if (i === "active" || i === "invalid") return Q;
9606
9606
  let a = await Li({
9607
9607
  request: t,
@@ -9612,27 +9612,27 @@ async function dh(e, t, n) {
9612
9612
  limiter: e.limiter
9613
9613
  });
9614
9614
  if (!a.ok || a.action !== "link_start") return Q;
9615
- let o = await v(r.cookie, "start");
9616
- if (o.kind !== "present" || o.cookieHash !== a.cookieHash) return Q;
9617
- let s = await lh(e, a.attemptId), l = await Sm(a.startCode);
9618
- if (!uh(e, s, e.now()) || s.state !== "pending" || s.browser_start_hash !== l) return Q;
9615
+ let s = await g(r.cookie, "start");
9616
+ if (s.kind !== "present" || s.cookieHash !== a.cookieHash) return Q;
9617
+ let c = await lh(e, a.attemptId), l = await Sm(a.startCode);
9618
+ if (!uh(e, c, e.now()) || c.state !== "pending" || c.browser_start_hash !== l) return Q;
9619
9619
  let u = await e.client.createAuthorizationRequest(), d = new URL(u.authorizationUrl);
9620
9620
  d.searchParams.set("prompt", "select_account");
9621
- let f = e.now();
9622
- if (!uh(e, s, f)) return Q;
9623
- let p = await T(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))), m = await xm(u.material.state), h = [re(o.secret), c("start")];
9624
- await e.backend.batch(ph(e, s, u, {
9625
- time: f,
9626
- hash: p,
9627
- stateHash: m,
9621
+ let p = e.now();
9622
+ if (!uh(e, c, p)) return Q;
9623
+ let m = await b(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))), h = await xm(u.material.state), _ = [f(s.secret), ze("start")];
9624
+ await e.backend.batch(ph(e, c, u, {
9625
+ time: p,
9626
+ hash: m,
9627
+ stateHash: h,
9628
9628
  binder: a.cookieHash
9629
9629
  }));
9630
- let g = await lh(e, s.attempt_id);
9631
- if (g?.state !== "browser_claimed" || g.browser_transaction_hash !== p || g.browser_binder_hash !== a.cookieHash) throw Error();
9630
+ let v = await lh(e, c.attempt_id);
9631
+ if (v?.state !== "browser_claimed" || v.browser_transaction_hash !== m || v.browser_binder_hash !== a.cookieHash) throw Error();
9632
9632
  return {
9633
9633
  kind: "browser_claimed",
9634
9634
  authorizationUrl: d.href,
9635
- setCookies: h
9635
+ setCookies: _
9636
9636
  };
9637
9637
  }
9638
9638
  function fh() {
@@ -9723,4 +9723,4 @@ function _h(e, t, n, r) {
9723
9723
  //#endregion
9724
9724
  export { Fr as $, Fc as A, Oa as B, Sl as C, Bc as D, Hc as E, as as F, Hi as G, qi as H, cs as I, Ci as J, Vi as K, ss as L, Lc as M, Dc as N, Nc as O, os as P, Mr as Q, bo as R, Ol as S, Vc as T, Xi as U, oa as V, Ui as W, yi as X, Li as Y, gi as Z, Il as _, fm as a, Hn as at, Ml as b, jp as c, Mp as d, Pr as et, zp as f, Ul as g, mp as h, lm as i, jr as it, Ic as j, Pc as k, Rp as l, hp as m, xm as n, zr as nt, Ep as o, Vn as ot, gp as p, wi as q, Cm as r, Br as rt, Tp as s, fn as st, Dm as t, Vr as tt, Fp as u, Ll as v, Rc as w, Fl as x, jl as y, Ka as z };
9725
9725
 
9726
- //# sourceMappingURL=owner-enrollment-start-DFVkODlJ.js.map
9726
+ //# sourceMappingURL=owner-enrollment-start-DgToUaFZ.js.map