@codemem/core 0.48.0 → 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.
- package/dist/coordinator-account-connection-schema.d.ts +1 -1
- package/dist/{coordinator-runtime-ZLZ8uDtd.js → coordinator-runtime-Bdad5KeL.js} +164 -163
- package/dist/{coordinator-runtime-ZLZ8uDtd.js.map → coordinator-runtime-Bdad5KeL.js.map} +1 -1
- package/dist/db.d.ts +2 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/export-import.d.ts.map +1 -1
- package/dist/feed-contract.d.ts +59 -0
- package/dist/feed-contract.d.ts.map +1 -0
- package/dist/feed-contract.js +187 -0
- package/dist/feed-contract.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9700 -9593
- package/dist/index.js.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +1015 -1014
- package/dist/internal/cloudflare-coordinator.js.map +1 -1
- package/dist/internal/relay-runtime.js +36 -36
- package/dist/maintenance/scan-secrets.d.ts.map +1 -1
- package/dist/memory-ownership-recovery.d.ts.map +1 -1
- package/dist/{owner-enrollment-start-DFVkODlJ.js → owner-enrollment-start-DgToUaFZ.js} +884 -884
- package/dist/{owner-enrollment-start-DFVkODlJ.js.map → owner-enrollment-start-DgToUaFZ.js.map} +1 -1
- package/dist/project-scope-settings.d.ts +2 -0
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/dist/raw-event-flush-claim.d.ts +6 -0
- package/dist/raw-event-flush-claim.d.ts.map +1 -1
- package/dist/raw-event-flush.d.ts +3 -2
- package/dist/raw-event-flush.d.ts.map +1 -1
- package/dist/raw-event-host-generation.d.ts +4 -0
- package/dist/raw-event-host-generation.d.ts.map +1 -0
- package/dist/raw-event-ingest.d.ts.map +1 -1
- package/dist/raw-event-sweeper.d.ts.map +1 -1
- package/dist/{relay-health-DhxMrW_S.js → relay-health-zrKtNQLQ.js} +16 -16
- package/dist/{relay-health-DhxMrW_S.js.map → relay-health-zrKtNQLQ.js.map} +1 -1
- package/dist/{relay-peer-client-Dkoe1TXa.js → relay-peer-client-DdhDwDFz.js} +4471 -1978
- package/dist/relay-peer-client-DdhDwDFz.js.map +1 -0
- package/dist/relay-peer-client.d.ts +8 -0
- package/dist/relay-peer-client.d.ts.map +1 -1
- package/dist/repository-mapping-aliases.d.ts +12 -1
- package/dist/repository-mapping-aliases.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/schema.d.ts +38 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/scope-backfill.d.ts.map +1 -1
- package/dist/scope-membership-cache-read-B6z47l2W.js +4114 -0
- package/dist/scope-membership-cache-read-B6z47l2W.js.map +1 -0
- package/dist/scope-membership-cache-read.d.ts +60 -0
- package/dist/scope-membership-cache-read.d.ts.map +1 -0
- package/dist/scope-membership-cache.d.ts +2 -57
- package/dist/scope-membership-cache.d.ts.map +1 -1
- package/dist/scope-membership-semantics-B8qXaMqx.js +205 -0
- package/dist/scope-membership-semantics-B8qXaMqx.js.map +1 -0
- package/dist/semantic/semantic-ranking.d.ts +2 -3
- package/dist/semantic/semantic-ranking.d.ts.map +1 -1
- package/dist/semantic/semantic-worker-test-fixtures.d.ts.map +1 -1
- package/dist/semantic-query.d.ts +10 -1
- package/dist/semantic-query.d.ts.map +1 -1
- package/dist/semantic-worker-entry.js +1 -1
- package/dist/{semantic-worker-job-CjYS3nT_.js → semantic-worker-job-CMjFE5cp.js} +3 -3
- package/dist/{semantic-worker-job-CjYS3nT_.js.map → semantic-worker-job-CMjFE5cp.js.map} +1 -1
- package/dist/{semantic-worker-ranking-BuO9lch_.js → semantic-worker-ranking-it8Zs3qb.js} +27 -27
- package/dist/{semantic-worker-ranking-BuO9lch_.js.map → semantic-worker-ranking-it8Zs3qb.js.map} +1 -1
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/{sync-auth-constants-Cb8-a8lE.js → sync-auth-constants-WKqJ9CX5.js} +2387 -2514
- package/dist/sync-auth-constants-WKqJ9CX5.js.map +1 -0
- package/dist/sync-channel-pass.d.ts.map +1 -1
- package/dist/sync-discovery.d.ts +1 -0
- package/dist/sync-discovery.d.ts.map +1 -1
- package/dist/sync-orchestration.d.ts.map +1 -1
- package/dist/sync-pass.d.ts +3 -0
- package/dist/sync-pass.d.ts.map +1 -1
- package/dist/sync-reachability-pass-CQe7nZnN.js +2 -0
- package/dist/{sync-reachability-pass-CXHfKTMy.js → sync-reachability-pass-CSg85Qmd.js} +2880 -2865
- package/dist/sync-reachability-pass-CSg85Qmd.js.map +1 -0
- package/dist/sync-reachability-pass.d.ts.map +1 -1
- package/dist/sync-status-indexes.d.ts +4 -0
- package/dist/sync-status-indexes.d.ts.map +1 -0
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/dist/{validated-vector-index-audit-BosLXii5.js → validated-vector-index-audit-B64yhEBF.js} +192 -155
- package/dist/validated-vector-index-audit-B64yhEBF.js.map +1 -0
- package/dist/vector-backfill-queue.d.ts +33 -0
- package/dist/vector-backfill-queue.d.ts.map +1 -0
- package/dist/vector-cutover-validation.d.ts +1 -0
- package/dist/vector-cutover-validation.d.ts.map +1 -1
- package/dist/vector-migration.d.ts +2 -1
- package/dist/vector-migration.d.ts.map +1 -1
- package/dist/vectors.d.ts +8 -2
- package/dist/vectors.d.ts.map +1 -1
- package/package.json +9 -4
- package/dist/relay-admission-proof-DjvC-e6G.js +0 -78
- package/dist/relay-admission-proof-DjvC-e6G.js.map +0 -1
- package/dist/relay-peer-client-Dkoe1TXa.js.map +0 -1
- package/dist/scope-membership-cache-D5caGR57.js +0 -6545
- package/dist/scope-membership-cache-D5caGR57.js.map +0 -1
- package/dist/sync-auth-constants-Cb8-a8lE.js.map +0 -1
- package/dist/sync-reachability-pass-B6ukEh3U.js +0 -2
- package/dist/sync-reachability-pass-CXHfKTMy.js.map +0 -1
- package/dist/validated-vector-index-audit-BosLXii5.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as et } from "./relay-admission-
|
|
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) =>
|
|
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 (!
|
|
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:
|
|
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) =>
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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" ?
|
|
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 =
|
|
1277
|
+
let a = w(t.runtime_verifier), o = w(t.completion);
|
|
1278
1278
|
if (!a || !o) return Yn(e);
|
|
1279
|
-
let s = await
|
|
1279
|
+
let s = await b(a);
|
|
1280
1280
|
return await r.finalize({
|
|
1281
1281
|
...n,
|
|
1282
1282
|
runtimeVerifierHash: s,
|
|
1283
|
-
completionSecretHash: await
|
|
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
|
|
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 !
|
|
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 &&
|
|
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 =
|
|
1535
|
+
let i = w(e.runtime_verifier), a = w(e.completion);
|
|
1536
1536
|
return !i || !a ? null : {
|
|
1537
|
-
purpose:
|
|
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
|
|
1545
|
-
completionSecretHash: await
|
|
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" ?
|
|
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
|
|
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
|
|
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 (!
|
|
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
|
|
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
|
|
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 =
|
|
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>${
|
|
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(
|
|
1730
|
-
let t = jr(e.fingerprint), n = Lr(e.deviceName) ?? "Device",
|
|
1731
|
-
...
|
|
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
|
|
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
|
|
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
|
|
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) &&
|
|
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) &&
|
|
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 !
|
|
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" || !
|
|
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
|
|
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 (!
|
|
2004
|
+
if (!T(i)) return O;
|
|
2005
2005
|
if (t === "link_start") {
|
|
2006
2006
|
let e = n.start_code;
|
|
2007
|
-
return typeof e != "string" || !
|
|
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 || !
|
|
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 (!
|
|
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
|
|
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
|
|
2208
|
-
return
|
|
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:
|
|
2210
|
+
action: r.action,
|
|
2211
2211
|
cookieHash: t.cookieHash
|
|
2212
|
-
}) :
|
|
2212
|
+
}) : r.action === "headless_code" ? Object.freeze({
|
|
2213
2213
|
ok: !0,
|
|
2214
|
-
action:
|
|
2214
|
+
action: r.action,
|
|
2215
2215
|
cookieHash: t.cookieHash,
|
|
2216
|
-
userCode:
|
|
2217
|
-
}) :
|
|
2216
|
+
userCode: r.userCode
|
|
2217
|
+
}) : r.action === "link_start" ? Object.freeze({
|
|
2218
2218
|
ok: !0,
|
|
2219
|
-
action:
|
|
2219
|
+
action: r.action,
|
|
2220
2220
|
cookieHash: t.cookieHash,
|
|
2221
|
-
attemptId:
|
|
2222
|
-
startCode:
|
|
2221
|
+
attemptId: r.attemptId,
|
|
2222
|
+
startCode: r.startCode
|
|
2223
2223
|
}) : Object.freeze({
|
|
2224
2224
|
ok: !0,
|
|
2225
|
-
action:
|
|
2225
|
+
action: r.action,
|
|
2226
2226
|
cookieHash: t.cookieHash,
|
|
2227
|
-
attemptId:
|
|
2228
|
-
}) : A(
|
|
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
|
|
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(
|
|
2322
|
-
let
|
|
2323
|
-
if (!
|
|
2324
|
-
let
|
|
2325
|
-
if (Array.from(new Uint8Array(
|
|
2326
|
-
let
|
|
2327
|
-
if (!await Xi(
|
|
2328
|
-
let
|
|
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:
|
|
2331
|
-
keyProofHash: Array.from(new Uint8Array(
|
|
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)),
|
|
2338
|
-
if (
|
|
2339
|
-
let
|
|
2340
|
-
return await globalThis.crypto.subtle.verify("Ed25519",
|
|
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(
|
|
2436
|
-
if (!sa(
|
|
2437
|
-
let
|
|
2438
|
-
if (!
|
|
2439
|
-
let
|
|
2440
|
-
return await Xi(
|
|
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,
|
|
2473
|
-
return
|
|
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:
|
|
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 =
|
|
2678
|
-
if (!r || await
|
|
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 =
|
|
2702
|
-
return t ?
|
|
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(
|
|
2807
|
-
if (!
|
|
2806
|
+
async function Za(t, n, r) {
|
|
2807
|
+
if (!t.deps.limiter.check(JSON.stringify([
|
|
2808
2808
|
"device-rebind-start",
|
|
2809
|
-
|
|
2810
|
-
|
|
2809
|
+
t.c.coordinatorId,
|
|
2810
|
+
r
|
|
2811
2811
|
]), Aa).allowed) return N("retry");
|
|
2812
|
-
if (!
|
|
2813
|
-
let
|
|
2814
|
-
if (!
|
|
2815
|
-
let
|
|
2816
|
-
if (
|
|
2817
|
-
let
|
|
2818
|
-
return await
|
|
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
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
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
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
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
|
-
|
|
2860
|
+
s - 36e5,
|
|
2861
2861
|
6
|
|
2862
2862
|
]
|
|
2863
2863
|
}) === 1 ? {
|
|
2864
2864
|
kind: "started",
|
|
2865
|
-
attemptId:
|
|
2866
|
-
expiresAtMs:
|
|
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
|
|
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
|
|
2882
|
-
if (
|
|
2883
|
-
let
|
|
2884
|
-
if (
|
|
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(),
|
|
2888
|
-
await e.deps.backend.batch($a(e,
|
|
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:
|
|
2891
|
-
stateHash:
|
|
2890
|
+
transactionHash: p,
|
|
2891
|
+
stateHash: m,
|
|
2892
2892
|
binderHash: a.cookieHash
|
|
2893
2893
|
}));
|
|
2894
|
-
let
|
|
2895
|
-
if (
|
|
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: [
|
|
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
|
|
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
|
|
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
|
|
3034
|
-
let
|
|
3035
|
-
sql: `SELECT link_id, identity_id, authority_kind, ${
|
|
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
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3039
|
+
e.c.coordinatorId,
|
|
3040
|
+
n.issuer,
|
|
3041
|
+
n.subject
|
|
3042
3042
|
]
|
|
3043
3043
|
});
|
|
3044
|
-
if (!
|
|
3045
|
-
if (!
|
|
3046
|
-
let
|
|
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})${
|
|
3057
|
+
AND (? = a.current_identity_id OR ${Ia})${o ? ` AND NOT ${le("a.coordinator_id")}` : ""}`,
|
|
3058
3058
|
values: [
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
...Wa(
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
...
|
|
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 (
|
|
3074
|
-
if (
|
|
3075
|
-
let
|
|
3076
|
-
if (
|
|
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(
|
|
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
|
|
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
|
|
3174
|
-
let
|
|
3175
|
-
if (
|
|
3176
|
-
if (!await ca(
|
|
3177
|
-
revision:
|
|
3178
|
-
now:
|
|
3179
|
-
completionSecret:
|
|
3180
|
-
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 (
|
|
3183
|
-
if (((await
|
|
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
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3186
|
+
e.c.coordinatorId,
|
|
3187
|
+
r.target_identity_id,
|
|
3188
|
+
i - 864e5
|
|
3189
3189
|
]
|
|
3190
3190
|
}))?.n ?? 0) >= 3) return "daily_limit";
|
|
3191
|
-
let
|
|
3192
|
-
return
|
|
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 !
|
|
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) || !
|
|
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(
|
|
3649
|
-
let
|
|
3650
|
-
if (!
|
|
3651
|
-
let
|
|
3652
|
-
groupId:
|
|
3653
|
-
deviceId:
|
|
3654
|
-
publicKey:
|
|
3655
|
-
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 (
|
|
3658
|
-
let
|
|
3659
|
-
if (!
|
|
3660
|
-
let
|
|
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:
|
|
3663
|
-
group_id:
|
|
3664
|
-
device_id:
|
|
3665
|
-
key_id:
|
|
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 (
|
|
3668
|
+
if (t === "preview") return zo({
|
|
3669
3669
|
state: "ready",
|
|
3670
|
-
...
|
|
3671
|
-
expected_digest:
|
|
3670
|
+
...l,
|
|
3671
|
+
expected_digest: c
|
|
3672
3672
|
});
|
|
3673
|
-
if (
|
|
3674
|
-
let
|
|
3675
|
-
if (
|
|
3676
|
-
let
|
|
3677
|
-
return
|
|
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
|
-
...
|
|
3680
|
-
revocations:
|
|
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 (!
|
|
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 =
|
|
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 : (
|
|
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
|
|
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
|
|
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 =
|
|
4179
|
-
else if (t === "registration") l =
|
|
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 :
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 } =
|
|
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/${
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 (!
|
|
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:
|
|
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" ?
|
|
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
|
|
5203
|
-
e.relayHealth?.install(
|
|
5204
|
-
let
|
|
5205
|
-
function
|
|
5206
|
-
let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i =
|
|
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
|
|
5212
|
+
function b(e) {
|
|
5213
5213
|
try {
|
|
5214
|
-
let t = JSON.parse(
|
|
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(
|
|
5221
|
-
authorizeRequest: (e,
|
|
5220
|
+
el(_, e, {
|
|
5221
|
+
authorizeRequest: (e, n) => rl(e, t, a, n),
|
|
5222
5222
|
authErrorStatus: il,
|
|
5223
5223
|
readRequestBytes: R,
|
|
5224
|
-
parseJsonObject:
|
|
5225
|
-
rateLimitedResponse: (e, t, n) =>
|
|
5224
|
+
parseJsonObject: b,
|
|
5225
|
+
rateLimitedResponse: (e, t, n) => y(e, t, n.authenticated)
|
|
5226
5226
|
});
|
|
5227
|
-
function
|
|
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
|
|
5231
|
+
function ee(e) {
|
|
5232
5232
|
return e?.trim() || null;
|
|
5233
5233
|
}
|
|
5234
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
5272
|
+
function ie(e) {
|
|
5273
5273
|
try {
|
|
5274
|
-
return
|
|
5274
|
+
return u(JSON.parse(e ?? ""));
|
|
5275
5275
|
} catch {
|
|
5276
5276
|
throw Error("operation_intent_invalid");
|
|
5277
5277
|
}
|
|
5278
5278
|
}
|
|
5279
|
-
async function
|
|
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
|
|
5285
|
-
let i = await
|
|
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
|
|
5307
|
-
let
|
|
5308
|
-
if (
|
|
5309
|
-
let i =
|
|
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 =
|
|
5313
|
+
let s = n();
|
|
5314
5314
|
try {
|
|
5315
|
-
let
|
|
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:
|
|
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 (!
|
|
5326
|
-
let c =
|
|
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(
|
|
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(
|
|
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
|
-
}),
|
|
5352
|
-
let
|
|
5353
|
-
if (!
|
|
5354
|
-
let i =
|
|
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
|
|
5356
|
+
let n = await rl(i, t, a, {
|
|
5357
5357
|
method: e.req.method,
|
|
5358
5358
|
url: e.req.url,
|
|
5359
|
-
groupId:
|
|
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 !
|
|
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
|
-
}),
|
|
5371
|
-
let
|
|
5372
|
-
if (!
|
|
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 =
|
|
5374
|
+
let s = n();
|
|
5375
5375
|
try {
|
|
5376
|
-
let
|
|
5376
|
+
let n = await rl(s, t, a, {
|
|
5377
5377
|
method: e.req.method,
|
|
5378
5378
|
url: e.req.url,
|
|
5379
|
-
groupId:
|
|
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 (!
|
|
5387
|
-
let c =
|
|
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:
|
|
5391
|
-
deviceId: String(
|
|
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
|
-
}),
|
|
5400
|
-
let
|
|
5401
|
-
if (
|
|
5402
|
-
let
|
|
5403
|
-
if (!
|
|
5404
|
-
let
|
|
5405
|
-
if (!
|
|
5406
|
-
let
|
|
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
|
|
5408
|
+
let n = await rl(l, t, a, {
|
|
5409
5409
|
method: e.req.method,
|
|
5410
5410
|
url: e.req.url,
|
|
5411
|
-
groupId:
|
|
5412
|
-
body:
|
|
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 (!
|
|
5419
|
-
let
|
|
5420
|
-
if (
|
|
5421
|
-
if (
|
|
5422
|
-
if (!await
|
|
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
|
|
5425
|
-
groupId:
|
|
5426
|
-
requestingDeviceId: String(
|
|
5427
|
-
requestedDeviceId:
|
|
5428
|
-
...
|
|
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 (
|
|
5435
|
-
if (
|
|
5436
|
-
throw
|
|
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
|
|
5439
|
+
await l.close();
|
|
5440
5440
|
}
|
|
5441
|
-
}),
|
|
5442
|
-
let
|
|
5443
|
-
if (
|
|
5444
|
-
let i =
|
|
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 =
|
|
5458
|
+
let u = n();
|
|
5459
5459
|
try {
|
|
5460
|
-
let
|
|
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:
|
|
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 (!
|
|
5471
|
-
let o =
|
|
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 =
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
},
|
|
5509
|
+
}, h = as(m), { token: g, ..._ } = p;
|
|
5510
5510
|
return e.json({
|
|
5511
5511
|
ok: !0,
|
|
5512
|
-
invite:
|
|
5512
|
+
invite: _,
|
|
5513
5513
|
payload: m,
|
|
5514
|
-
encoded:
|
|
5515
|
-
link: ss(
|
|
5514
|
+
encoded: h,
|
|
5515
|
+
link: ss(h)
|
|
5516
5516
|
});
|
|
5517
5517
|
} finally {
|
|
5518
5518
|
await u.close();
|
|
5519
5519
|
}
|
|
5520
|
-
}),
|
|
5521
|
-
let
|
|
5522
|
-
if (!
|
|
5523
|
-
let
|
|
5524
|
-
if (
|
|
5525
|
-
let
|
|
5526
|
-
if (
|
|
5527
|
-
let
|
|
5528
|
-
if (!
|
|
5529
|
-
let
|
|
5530
|
-
return !
|
|
5531
|
-
deviceId:
|
|
5532
|
-
fingerprint:
|
|
5533
|
-
publicKey:
|
|
5534
|
-
displayName:
|
|
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
|
-
}),
|
|
5537
|
-
let
|
|
5538
|
-
if (!
|
|
5539
|
-
let i =
|
|
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 =
|
|
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
|
-
}),
|
|
5552
|
-
let
|
|
5553
|
-
if (!
|
|
5554
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5572
|
-
let
|
|
5573
|
-
if (!
|
|
5574
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5592
|
-
let
|
|
5593
|
-
if (!
|
|
5594
|
-
let i =
|
|
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 =
|
|
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 =
|
|
5602
|
+
let c = n();
|
|
5603
5603
|
try {
|
|
5604
|
-
return await c.archiveGroup(s,
|
|
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
|
-
}),
|
|
5612
|
-
let
|
|
5613
|
-
if (!
|
|
5614
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5632
|
-
let
|
|
5633
|
-
if (!
|
|
5634
|
-
let i =
|
|
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 =
|
|
5636
|
+
let a = String(e.req.param("group_id") ?? "").trim(), o = n();
|
|
5637
5637
|
try {
|
|
5638
|
-
let t = await
|
|
5638
|
+
let t = await ae(o, a, e);
|
|
5639
5639
|
if (t) return t;
|
|
5640
|
-
let n =
|
|
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
|
-
}),
|
|
5649
|
-
let
|
|
5650
|
-
if (!
|
|
5651
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
5660
|
+
let d = n();
|
|
5661
5661
|
try {
|
|
5662
|
-
let t = await
|
|
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:
|
|
5668
|
-
authorityType:
|
|
5669
|
-
coordinatorId:
|
|
5667
|
+
kind: x(o, "kind"),
|
|
5668
|
+
authorityType: x(o, "authority_type"),
|
|
5669
|
+
coordinatorId: x(o, "coordinator_id"),
|
|
5670
5670
|
groupId: s,
|
|
5671
|
-
manifestIssuerDeviceId:
|
|
5671
|
+
manifestIssuerDeviceId: x(o, "manifest_issuer_device_id"),
|
|
5672
5672
|
membershipEpoch: u,
|
|
5673
|
-
manifestHash:
|
|
5674
|
-
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
|
-
}),
|
|
5686
|
-
let
|
|
5687
|
-
if (!
|
|
5688
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
5697
|
+
let u = n();
|
|
5698
5698
|
try {
|
|
5699
|
-
let t = await
|
|
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 :
|
|
5704
|
-
kind: o.kind === void 0 ? void 0 :
|
|
5705
|
-
authorityType: o.authority_type === void 0 ? void 0 :
|
|
5706
|
-
coordinatorId: o.coordinator_id === void 0 ? void 0 :
|
|
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 :
|
|
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 :
|
|
5711
|
-
status: o.status === void 0 ? void 0 :
|
|
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
|
-
}),
|
|
5723
|
-
let
|
|
5724
|
-
if (!
|
|
5725
|
-
let i =
|
|
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 =
|
|
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
|
|
5730
|
-
return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o,
|
|
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
|
-
}),
|
|
5735
|
-
let
|
|
5736
|
-
if (!
|
|
5737
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
5747
|
+
let f = n();
|
|
5748
5748
|
try {
|
|
5749
|
-
let t = await
|
|
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:
|
|
5755
|
+
role: x(o, "role"),
|
|
5756
5756
|
membershipEpoch: d,
|
|
5757
|
-
coordinatorId:
|
|
5757
|
+
coordinatorId: x(o, "coordinator_id"),
|
|
5758
5758
|
groupId: s,
|
|
5759
|
-
manifestIssuerDeviceId:
|
|
5760
|
-
manifestHash:
|
|
5761
|
-
signedManifestJson:
|
|
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:
|
|
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
|
|
5772
|
-
if (t instanceof
|
|
5773
|
-
let r = t instanceof
|
|
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
|
-
}),
|
|
5779
|
-
let
|
|
5780
|
-
if (!
|
|
5781
|
-
let
|
|
5782
|
-
if (
|
|
5783
|
-
let
|
|
5784
|
-
if (
|
|
5785
|
-
let
|
|
5786
|
-
if (!
|
|
5787
|
-
let
|
|
5788
|
-
if (!
|
|
5789
|
-
if (!
|
|
5790
|
-
if (Number.isNaN(
|
|
5791
|
-
let
|
|
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
|
|
5793
|
+
let t = await w(p, c, l, e);
|
|
5794
5794
|
if (t.response) return t.response;
|
|
5795
|
-
if (!await
|
|
5796
|
-
effectId:
|
|
5797
|
-
scopeId:
|
|
5798
|
-
deviceId:
|
|
5799
|
-
groupId:
|
|
5800
|
-
membershipEpoch:
|
|
5801
|
-
manifestHash:
|
|
5802
|
-
signedManifestJson:
|
|
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:
|
|
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
|
|
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:
|
|
5815
|
-
device_id:
|
|
5816
|
-
revocation:
|
|
5817
|
-
scopeId:
|
|
5818
|
-
deviceId:
|
|
5819
|
-
membershipEpoch: n?.membership_epoch ??
|
|
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
|
|
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
|
|
5826
|
+
await p.close();
|
|
5827
5827
|
}
|
|
5828
|
-
}),
|
|
5829
|
-
let
|
|
5830
|
-
if (!
|
|
5831
|
-
let i =
|
|
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 =
|
|
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
|
-
}),
|
|
5846
|
-
let
|
|
5847
|
-
if (!
|
|
5848
|
-
let
|
|
5849
|
-
if (
|
|
5850
|
-
let
|
|
5851
|
-
if (
|
|
5852
|
-
let
|
|
5853
|
-
if (!
|
|
5854
|
-
let
|
|
5855
|
-
if (!
|
|
5856
|
-
if (!
|
|
5857
|
-
let
|
|
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
|
-
|
|
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
|
|
5863
|
+
let d = n();
|
|
5864
5864
|
try {
|
|
5865
|
-
if (!await
|
|
5866
|
-
let t = await
|
|
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
|
|
5872
|
+
await d.close();
|
|
5873
5873
|
}
|
|
5874
|
-
}),
|
|
5875
|
-
let
|
|
5876
|
-
if (!
|
|
5877
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5892
|
-
let
|
|
5893
|
-
if (!
|
|
5894
|
-
let i =
|
|
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 =
|
|
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,
|
|
5902
|
-
}),
|
|
5903
|
-
let
|
|
5904
|
-
if (!
|
|
5905
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5920
|
-
let
|
|
5921
|
-
if (!
|
|
5922
|
-
let i =
|
|
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 =
|
|
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
|
|
5929
|
+
let c, l;
|
|
5930
5930
|
try {
|
|
5931
|
-
let e =
|
|
5931
|
+
let e = h([o.group_id])[0];
|
|
5932
5932
|
if (!e) throw Error("completion_manifest_invalid");
|
|
5933
|
-
|
|
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
|
|
5937
|
+
let u = n();
|
|
5938
5938
|
try {
|
|
5939
|
-
let t = await
|
|
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
|
|
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
|
|
5952
|
+
await u.close();
|
|
5953
5953
|
}
|
|
5954
|
-
}),
|
|
5955
|
-
let
|
|
5956
|
-
if (!
|
|
5957
|
-
let i =
|
|
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 (
|
|
5962
|
-
o =
|
|
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 =
|
|
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
|
-
}),
|
|
5974
|
-
let
|
|
5975
|
-
if (!
|
|
5976
|
-
let i =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
5998
|
-
let
|
|
5999
|
-
if (!
|
|
6000
|
-
let
|
|
6001
|
-
if (
|
|
6002
|
-
let
|
|
6003
|
-
if (
|
|
6004
|
-
let
|
|
6005
|
-
if (!
|
|
6006
|
-
let
|
|
6007
|
-
if (!
|
|
6008
|
-
if (Object.hasOwn(
|
|
6009
|
-
if (Number.isNaN(new Date(
|
|
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 =
|
|
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 (
|
|
6020
|
-
if (C === "team_member" && (!x || !
|
|
6021
|
-
if ([x,
|
|
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 (
|
|
6023
|
+
if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
6024
6024
|
try {
|
|
6025
|
-
te = await
|
|
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(
|
|
6031
|
+
targetIdentityId: String(ee)
|
|
6032
6032
|
},
|
|
6033
|
-
digest: String(
|
|
6033
|
+
digest: String(S)
|
|
6034
6034
|
});
|
|
6035
6035
|
} catch (t) {
|
|
6036
|
-
return t instanceof
|
|
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 (
|
|
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 || !
|
|
6041
|
+
if (!m || !h || !g || !_) return e.json({ error: "project_invite_identity_context_required" }, 400);
|
|
6042
6042
|
if ([
|
|
6043
6043
|
m,
|
|
6044
|
-
|
|
6045
|
-
|
|
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 (
|
|
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
|
|
6063
|
+
let ie = n();
|
|
6064
6064
|
try {
|
|
6065
|
-
let t = await
|
|
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
|
|
6069
|
-
groupId:
|
|
6070
|
-
policy:
|
|
6071
|
-
expiresAt:
|
|
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:
|
|
6078
|
-
pendingPersonId:
|
|
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:
|
|
6084
|
-
reviewedPreviewDigest:
|
|
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(
|
|
6090
|
-
group_id:
|
|
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, ...
|
|
6110
|
+
}, i = as(r), { token: a, ...u } = n;
|
|
6111
6111
|
return e.json({
|
|
6112
6112
|
ok: !0,
|
|
6113
|
-
invite:
|
|
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
|
|
6123
|
+
await ie.close();
|
|
6124
6124
|
}
|
|
6125
|
-
}),
|
|
6126
|
-
let
|
|
6127
|
-
if (
|
|
6128
|
-
let i =
|
|
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 =
|
|
6132
|
+
let o = n();
|
|
6133
6133
|
try {
|
|
6134
|
-
let
|
|
6135
|
-
if (!
|
|
6136
|
-
if (
|
|
6137
|
-
let
|
|
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:
|
|
6139
|
+
now: t.now()
|
|
6140
6140
|
});
|
|
6141
|
-
return
|
|
6142
|
-
kind:
|
|
6143
|
-
policy_team_id:
|
|
6144
|
-
assigned_identity_id:
|
|
6145
|
-
reviewed_preview_digest:
|
|
6146
|
-
reviewed_intent:
|
|
6147
|
-
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:
|
|
6150
|
-
target_identity_id:
|
|
6151
|
-
reviewed_preview_digest:
|
|
6152
|
-
reviewed_intent:
|
|
6153
|
-
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 = !!(
|
|
6160
|
-
if (new Date(
|
|
6161
|
-
if (!
|
|
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:
|
|
6163
|
+
team_name: n.team_name_snapshot
|
|
6164
6164
|
});
|
|
6165
|
-
if (!
|
|
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 =
|
|
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:
|
|
6175
|
-
inviter_name:
|
|
6176
|
-
team_name:
|
|
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: !!
|
|
6178
|
+
bound: !!n.consumed_at
|
|
6179
6179
|
});
|
|
6180
6180
|
} finally {
|
|
6181
6181
|
await o.close();
|
|
6182
6182
|
}
|
|
6183
|
-
}),
|
|
6184
|
-
let
|
|
6185
|
-
if (!
|
|
6186
|
-
let i =
|
|
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 =
|
|
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
|
-
}),
|
|
6198
|
-
let
|
|
6199
|
-
if (!
|
|
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 =
|
|
6202
|
+
let o = n();
|
|
6203
6203
|
try {
|
|
6204
|
-
let
|
|
6205
|
-
if (!
|
|
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 =
|
|
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 (!
|
|
6214
|
-
let
|
|
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:
|
|
6223
|
-
policy:
|
|
6224
|
-
token:
|
|
6225
|
-
expires_at:
|
|
6226
|
-
team_name:
|
|
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:
|
|
6229
|
-
project_summaries:
|
|
6228
|
+
inviter_name: n.inviter_display_name ?? null,
|
|
6229
|
+
project_summaries: t
|
|
6230
6230
|
}));
|
|
6231
6231
|
}
|
|
6232
6232
|
return e.json({
|
|
6233
|
-
operation_id:
|
|
6234
|
-
group_id:
|
|
6235
|
-
reviewed_project_set_digest:
|
|
6236
|
-
state:
|
|
6237
|
-
pending_person_id:
|
|
6238
|
-
recipient_actor_id:
|
|
6239
|
-
recipient_display_name:
|
|
6240
|
-
recipient_device_id:
|
|
6241
|
-
recipient_device_display_name:
|
|
6242
|
-
recipient_public_key:
|
|
6243
|
-
recipient_fingerprint:
|
|
6244
|
-
consumed_at:
|
|
6245
|
-
bootstrap_grant_id:
|
|
6246
|
-
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
|
-
}),
|
|
6254
|
-
let
|
|
6255
|
-
if (!
|
|
6256
|
-
let i =
|
|
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 =
|
|
6260
|
+
let o = n();
|
|
6261
6261
|
try {
|
|
6262
6262
|
return await ol(e, o, {
|
|
6263
6263
|
grantId: a,
|
|
6264
|
-
nowMs: Date.parse(
|
|
6264
|
+
nowMs: Date.parse(t.now())
|
|
6265
6265
|
});
|
|
6266
6266
|
} finally {
|
|
6267
6267
|
await o.close();
|
|
6268
6268
|
}
|
|
6269
|
-
}),
|
|
6270
|
-
let
|
|
6271
|
-
if (!
|
|
6272
|
-
let o =
|
|
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
|
|
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 !
|
|
6285
|
-
grantId:
|
|
6286
|
-
nowMs: Date.parse(
|
|
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:
|
|
6289
|
-
deviceId:
|
|
6290
|
-
publicKey:
|
|
6291
|
-
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
|
-
}),
|
|
6298
|
-
let
|
|
6299
|
-
if (!
|
|
6300
|
-
let i =
|
|
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 =
|
|
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
|
-
}),
|
|
6311
|
-
let
|
|
6312
|
-
if (!
|
|
6313
|
-
let i =
|
|
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 =
|
|
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 =
|
|
6321
|
+
let c = n();
|
|
6322
6322
|
try {
|
|
6323
|
-
return await c.revokeBootstrapGrant(s,
|
|
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
|
-
}),
|
|
6331
|
-
createStore:
|
|
6332
|
-
runtime:
|
|
6333
|
-
rateLimitedResponse:
|
|
6334
|
-
})),
|
|
6335
|
-
createStore:
|
|
6336
|
-
runtime:
|
|
6337
|
-
rateLimitedResponse:
|
|
6338
|
-
})),
|
|
6339
|
-
let
|
|
6340
|
-
if (!
|
|
6341
|
-
let i =
|
|
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 =
|
|
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
|
-
}),
|
|
6352
|
-
let a = await R(
|
|
6353
|
-
if (a == null) return
|
|
6354
|
-
let o =
|
|
6355
|
-
if (!o) return
|
|
6356
|
-
let s = String(o.token ?? "").trim(), c = String(o.device_id ?? "").trim(),
|
|
6357
|
-
if (!s || !c || !
|
|
6358
|
-
if (
|
|
6359
|
-
let _ =
|
|
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
|
|
6362
|
-
if (!
|
|
6363
|
-
let
|
|
6364
|
-
if (
|
|
6365
|
-
if (!
|
|
6366
|
-
if (
|
|
6367
|
-
let
|
|
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) => !
|
|
6379
|
-
let
|
|
6380
|
-
if (!f ||
|
|
6381
|
-
if (f.length > 256 || /[\p{Cc}\p{Cf}]/u.test(f)) return
|
|
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 =
|
|
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 =
|
|
6390
|
+
m = l(o.device_display_name, "device_display_name");
|
|
6391
6391
|
}
|
|
6392
6392
|
} catch (e) {
|
|
6393
|
-
return
|
|
6393
|
+
return r.json({ error: e instanceof Error ? e.message : "recipient_invite_identity_invalid" }, 400);
|
|
6394
6394
|
}
|
|
6395
|
-
if (
|
|
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:
|
|
6399
|
+
inviteKind: n.invite_kind,
|
|
6400
6400
|
identityId: f,
|
|
6401
6401
|
deviceId: c,
|
|
6402
|
-
publicKey:
|
|
6403
|
-
fingerprint:
|
|
6402
|
+
publicKey: d,
|
|
6403
|
+
fingerprint: u,
|
|
6404
6404
|
recipientDisplayName: p,
|
|
6405
6405
|
deviceDisplayName: m,
|
|
6406
|
-
now:
|
|
6406
|
+
now: t.now()
|
|
6407
6407
|
});
|
|
6408
|
-
return
|
|
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(
|
|
6423
|
+
return ll(r, e);
|
|
6424
6424
|
}
|
|
6425
6425
|
}
|
|
6426
|
-
if (
|
|
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
|
|
6439
|
-
if (!
|
|
6440
|
-
if (String(
|
|
6441
|
-
if (
|
|
6442
|
-
let
|
|
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
|
-
|
|
6444
|
+
i = se(h, "recipient_display_name"), a = l(g, "device_display_name");
|
|
6445
6445
|
} catch (e) {
|
|
6446
|
-
return
|
|
6446
|
+
return r.json({ error: e instanceof Error ? e.message : "project_invite_identity_invalid" }, 400);
|
|
6447
6447
|
}
|
|
6448
|
-
let
|
|
6448
|
+
let f;
|
|
6449
6449
|
try {
|
|
6450
|
-
|
|
6450
|
+
f = C(n);
|
|
6451
6451
|
} catch {
|
|
6452
|
-
return
|
|
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:
|
|
6457
|
+
operationId: p,
|
|
6458
6458
|
deviceId: c,
|
|
6459
|
-
publicKey:
|
|
6460
|
-
fingerprint:
|
|
6461
|
-
recipientActorId:
|
|
6462
|
-
recipientDisplayName:
|
|
6463
|
-
deviceDisplayName:
|
|
6464
|
-
now:
|
|
6459
|
+
publicKey: d,
|
|
6460
|
+
fingerprint: u,
|
|
6461
|
+
recipientActorId: m,
|
|
6462
|
+
recipientDisplayName: i,
|
|
6463
|
+
deviceDisplayName: a,
|
|
6464
|
+
now: t.now()
|
|
6465
6465
|
});
|
|
6466
|
-
return
|
|
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:
|
|
6479
|
+
accepted_project_intent: f
|
|
6480
6480
|
});
|
|
6481
6481
|
} catch (e) {
|
|
6482
|
-
return ul(
|
|
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
|
|
6491
|
-
let v = await _.getGroup(String(
|
|
6492
|
-
if (!v) return
|
|
6493
|
-
if (v.archived_at) return
|
|
6494
|
-
let y = String(
|
|
6495
|
-
if (await _.getEnrollment(y, c)) return
|
|
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:
|
|
6499
|
-
policy:
|
|
6498
|
+
group_id: n.group_id,
|
|
6499
|
+
policy: n.policy
|
|
6500
6500
|
});
|
|
6501
|
-
let b = String(
|
|
6502
|
-
if (!["auto_admit", "approval_required"].includes(b)) return
|
|
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:
|
|
6508
|
-
fingerprint:
|
|
6509
|
-
displayName:
|
|
6507
|
+
publicKey: d,
|
|
6508
|
+
fingerprint: u,
|
|
6509
|
+
displayName: f,
|
|
6510
6510
|
token: s
|
|
6511
6511
|
});
|
|
6512
|
-
return
|
|
6512
|
+
return r.json({
|
|
6513
6513
|
ok: !0,
|
|
6514
6514
|
status: "pending",
|
|
6515
|
-
group_id:
|
|
6516
|
-
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:
|
|
6523
|
-
publicKey:
|
|
6524
|
-
displayName:
|
|
6525
|
-
}),
|
|
6522
|
+
fingerprint: u,
|
|
6523
|
+
publicKey: d,
|
|
6524
|
+
displayName: f
|
|
6525
|
+
}), r.json({
|
|
6526
6526
|
ok: !0,
|
|
6527
6527
|
status: "enrolled",
|
|
6528
|
-
group_id:
|
|
6529
|
-
policy:
|
|
6528
|
+
group_id: n.group_id,
|
|
6529
|
+
policy: n.policy
|
|
6530
6530
|
});
|
|
6531
6531
|
} catch (e) {
|
|
6532
|
-
return sl(
|
|
6532
|
+
return sl(r, e);
|
|
6533
6533
|
} finally {
|
|
6534
6534
|
await _.close();
|
|
6535
6535
|
}
|
|
6536
|
-
}),
|
|
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" || !
|
|
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 (!
|
|
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 (!
|
|
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 =
|
|
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 = (
|
|
8249
|
-
let t =
|
|
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,
|
|
8284
|
-
return i && await
|
|
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:
|
|
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 ${
|
|
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 =
|
|
8350
|
-
if (!
|
|
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}.${
|
|
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 =
|
|
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 (!
|
|
8401
|
+
if (!T(t) || !Dp(n, 4096) || !be({
|
|
8402
8402
|
issuer: n,
|
|
8403
8403
|
subject: r
|
|
8404
|
-
}, { issuer: n }).ok || !
|
|
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}.${
|
|
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 =
|
|
8472
|
-
if (!u || !l || !kp(s, c,
|
|
8473
|
-
let
|
|
8474
|
-
return await Pp(
|
|
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,
|
|
8519
|
-
let
|
|
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 (!
|
|
8524
|
-
let
|
|
8525
|
-
if (
|
|
8526
|
-
for (let e of
|
|
8527
|
-
return
|
|
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
|
|
8570
|
+
return await ee(e) ? ` AND ${c}` : "";
|
|
8571
8571
|
}
|
|
8572
8572
|
function Qp(e, t) {
|
|
8573
|
-
let n =
|
|
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
|
|
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
|
-
|
|
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
|
-
},
|
|
8764
|
+
}, a = await ve(e), o = await bp(e, t, i);
|
|
8765
8765
|
return {
|
|
8766
|
-
values:
|
|
8767
|
-
with: `${
|
|
8768
|
-
SELECT l.* FROM owner_scope_links l WHERE ${
|
|
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 ${
|
|
8771
|
-
${
|
|
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 (${
|
|
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 (!
|
|
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 =
|
|
8880
|
+
let t = w(e);
|
|
8881
8881
|
if (!t) throw Error();
|
|
8882
|
-
return
|
|
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 (!
|
|
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: () =>
|
|
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
|
|
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
|
|
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,${
|
|
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 ? `,${
|
|
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" &&
|
|
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 || !
|
|
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 (
|
|
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 || !
|
|
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
|
|
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(
|
|
9407
|
-
let
|
|
9406
|
+
async function Qm(e, t) {
|
|
9407
|
+
let n;
|
|
9408
9408
|
try {
|
|
9409
|
-
|
|
9409
|
+
n = Xm(t);
|
|
9410
9410
|
} catch {
|
|
9411
9411
|
return Q;
|
|
9412
9412
|
}
|
|
9413
|
-
let
|
|
9414
|
-
if (!Zm(
|
|
9415
|
-
let
|
|
9416
|
-
if (!
|
|
9417
|
-
if (
|
|
9418
|
-
let
|
|
9419
|
-
if (!uh(
|
|
9420
|
-
let
|
|
9421
|
-
backend:
|
|
9422
|
-
row:
|
|
9423
|
-
revision:
|
|
9424
|
-
now:
|
|
9425
|
-
completionSecret:
|
|
9426
|
-
signature:
|
|
9427
|
-
}),
|
|
9428
|
-
return
|
|
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 || !
|
|
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(
|
|
9459
|
-
let
|
|
9460
|
-
if (!
|
|
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
|
-
|
|
9463
|
-
|
|
9464
|
-
]), hm), "allowed") !== !0 || !
|
|
9465
|
-
let { i:
|
|
9462
|
+
t.c.coordinatorId,
|
|
9463
|
+
r
|
|
9464
|
+
]), hm), "allowed") !== !0 || !a) return Q;
|
|
9465
|
+
let { i: o } = a, s;
|
|
9466
9466
|
try {
|
|
9467
|
-
|
|
9467
|
+
s = await Sm(o.browserStartCode);
|
|
9468
9468
|
} catch {
|
|
9469
9469
|
return Q;
|
|
9470
9470
|
}
|
|
9471
|
-
let
|
|
9472
|
-
if (!
|
|
9473
|
-
let { admissionOwnerHash:
|
|
9474
|
-
if (!
|
|
9475
|
-
let
|
|
9476
|
-
if (!
|
|
9477
|
-
let
|
|
9478
|
-
keyId:
|
|
9479
|
-
fingerprint:
|
|
9480
|
-
browserStartHash:
|
|
9481
|
-
time:
|
|
9482
|
-
admissionOwnerHash:
|
|
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 (
|
|
9485
|
-
let
|
|
9486
|
-
backend:
|
|
9487
|
-
config:
|
|
9488
|
-
sessionCookieHash:
|
|
9489
|
-
owner:
|
|
9490
|
-
deviceId:
|
|
9491
|
-
fingerprint:
|
|
9492
|
-
time:
|
|
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
|
-
|
|
9495
|
-
${
|
|
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
|
|
9497
|
+
return await t.backend.run(p) === 1 ? {
|
|
9498
9498
|
kind: "started",
|
|
9499
|
-
attemptId:
|
|
9500
|
-
expiresAtMs:
|
|
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 -
|
|
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
|
-
|
|
9589
|
-
|
|
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
|
|
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
|
|
9616
|
-
if (
|
|
9617
|
-
let
|
|
9618
|
-
if (!uh(e,
|
|
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
|
|
9622
|
-
if (!uh(e,
|
|
9623
|
-
let
|
|
9624
|
-
await e.backend.batch(ph(e,
|
|
9625
|
-
time:
|
|
9626
|
-
hash:
|
|
9627
|
-
stateHash:
|
|
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
|
|
9631
|
-
if (
|
|
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:
|
|
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-
|
|
9726
|
+
//# sourceMappingURL=owner-enrollment-start-DgToUaFZ.js.map
|