@codemem/core 0.44.0-alpha.1 → 0.44.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-actions.d.ts +5 -0
- package/dist/coordinator-actions.d.ts.map +1 -1
- package/dist/{coordinator-api-Dlr65yhR.js → coordinator-api-BAufmPEa.js} +216 -198
- package/dist/coordinator-api-BAufmPEa.js.map +1 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/export-import.d.ts.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8113 -7709
- package/dist/index.js.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +257 -257
- package/dist/internal/cloudflare-coordinator.js.map +1 -1
- package/dist/legacy-team-setup-completion-manifest.d.ts +4 -0
- package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
- package/dist/legacy-team-setup-errors.d.ts +2 -0
- package/dist/legacy-team-setup-errors.d.ts.map +1 -1
- package/dist/native-runtime.d.ts +12 -0
- package/dist/native-runtime.d.ts.map +1 -0
- package/dist/project-identity.d.ts +4 -0
- package/dist/project-identity.d.ts.map +1 -0
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/dist/raw-event-ingest.d.ts.map +1 -1
- package/dist/raw-event-sweeper.d.ts +2 -3
- package/dist/raw-event-sweeper.d.ts.map +1 -1
- package/dist/recipient-policy-review.d.ts +6 -0
- package/dist/recipient-policy-review.d.ts.map +1 -1
- package/dist/release-discovery.d.ts +4 -0
- package/dist/release-discovery.d.ts.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/scope-resolution.d.ts.map +1 -1
- package/dist/store.d.ts +6 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/sync-daemon.d.ts.map +1 -1
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/dist/vector-migration.d.ts.map +1 -1
- package/dist/vectors.d.ts +6 -0
- package/dist/vectors.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/coordinator-api-Dlr65yhR.js.map +0 -1
|
@@ -96,7 +96,7 @@ function x(e, t) {
|
|
|
96
96
|
function S(e) {
|
|
97
97
|
return _("policy-team-v1", e);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function te(e) {
|
|
100
100
|
return g("legacy-team-roster-v1", e.map((e) => ({
|
|
101
101
|
deviceId: e.deviceId,
|
|
102
102
|
fingerprint: e.fingerprint,
|
|
@@ -106,59 +106,59 @@ function C(e) {
|
|
|
106
106
|
}
|
|
107
107
|
//#endregion
|
|
108
108
|
//#region src/coordinator-legacy-team-completion.ts
|
|
109
|
-
var
|
|
110
|
-
code =
|
|
109
|
+
var C = 1, w = 50, T = 500, E = 15e5, ne = 25 * E, re = 256, ie = 37661024, ae = "completion_conflict", oe = class extends Error {
|
|
110
|
+
code = ae;
|
|
111
111
|
constructor() {
|
|
112
|
-
super(
|
|
112
|
+
super(ae), this.name = "CoordinatorLegacyTeamCompletionConflictError";
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function D() {
|
|
116
116
|
throw Error("completion_manifest_invalid");
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
return (!e || typeof e != "object" || Array.isArray(e)) &&
|
|
118
|
+
function O(e) {
|
|
119
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && D(), e;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function k(e, t) {
|
|
122
122
|
let n = new Set(t);
|
|
123
|
-
Object.keys(e).some((e) => !n.has(e)) &&
|
|
123
|
+
Object.keys(e).some((e) => !n.has(e)) && D();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function se(e) {
|
|
126
126
|
return /^(?:[\\/]{2}|\.{1,2}[\\/]|\/|~[\\/]|[a-z]:[\\/]|file:)/iu.test(e);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
return (typeof e != "string" || !e || e !== e.trim() || e.length >
|
|
128
|
+
function A(e) {
|
|
129
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > re || /[\p{Cc}\p{Cf}]/u.test(e) || se(e)) && D(), e;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
let t =
|
|
133
|
-
return /^[a-f0-9]{64}$/u.test(t) ||
|
|
131
|
+
function j(e) {
|
|
132
|
+
let t = A(e);
|
|
133
|
+
return /^[a-f0-9]{64}$/u.test(t) || D(), t;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
typeof e != "string" &&
|
|
135
|
+
function ce(e) {
|
|
136
|
+
typeof e != "string" && D();
|
|
137
137
|
let t = e.normalize("NFC").trim();
|
|
138
|
-
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) ||
|
|
138
|
+
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || se(t)) && D(), t;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
(typeof e != "string" || !e) &&
|
|
140
|
+
function le(e) {
|
|
141
|
+
(typeof e != "string" || !e) && D();
|
|
142
142
|
let t = new Date(e);
|
|
143
|
-
return (Number.isNaN(t.getTime()) || t.toISOString() !== e) &&
|
|
144
|
-
}
|
|
145
|
-
function le(e, t) {
|
|
146
|
-
return (!Array.isArray(e) || e.length > t) && O(), e;
|
|
143
|
+
return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && D(), e;
|
|
147
144
|
}
|
|
148
145
|
function ue(e, t) {
|
|
146
|
+
return (!Array.isArray(e) || e.length > t) && D(), e;
|
|
147
|
+
}
|
|
148
|
+
function M(e, t) {
|
|
149
149
|
let n = e.toSorted((e, n) => o(t(e), t(n)));
|
|
150
|
-
return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) &&
|
|
150
|
+
return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && D(), n;
|
|
151
151
|
}
|
|
152
152
|
function de(e) {
|
|
153
|
-
return ue(
|
|
153
|
+
return M(ue(e, 50).map(A), (e) => e);
|
|
154
154
|
}
|
|
155
155
|
function fe(e) {
|
|
156
|
-
let t =
|
|
157
|
-
return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) ||
|
|
156
|
+
let t = A(e);
|
|
157
|
+
return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || D(), t;
|
|
158
158
|
}
|
|
159
159
|
function pe(e) {
|
|
160
|
-
let t =
|
|
161
|
-
|
|
160
|
+
let t = O(e);
|
|
161
|
+
k(t, [
|
|
162
162
|
"version",
|
|
163
163
|
"coordinator_id",
|
|
164
164
|
"candidate_ref",
|
|
@@ -174,110 +174,110 @@ function pe(e) {
|
|
|
174
174
|
"project_mappings",
|
|
175
175
|
"project_recipients",
|
|
176
176
|
"completed_at"
|
|
177
|
-
]), t.version !== 1 &&
|
|
178
|
-
let n =
|
|
179
|
-
|
|
177
|
+
]), t.version !== 1 && D();
|
|
178
|
+
let n = O(t.team);
|
|
179
|
+
k(n, [
|
|
180
180
|
"display_name",
|
|
181
181
|
"policy_revision",
|
|
182
182
|
"device_eligibility_mode"
|
|
183
|
-
]), n.device_eligibility_mode !== "reviewed_allowlist" &&
|
|
184
|
-
let r =
|
|
185
|
-
let t =
|
|
186
|
-
return
|
|
187
|
-
identity_id:
|
|
183
|
+
]), n.device_eligibility_mode !== "reviewed_allowlist" && D();
|
|
184
|
+
let r = A(t.team_id), i = M(ue(t.memberships, 500).map((e) => {
|
|
185
|
+
let t = O(e);
|
|
186
|
+
return k(t, ["identity_id", "role"]), t.role !== "member" && D(), {
|
|
187
|
+
identity_id: A(t.identity_id),
|
|
188
188
|
role: "member"
|
|
189
189
|
};
|
|
190
|
-
}), (e) => e.identity_id), a = ue(
|
|
191
|
-
let t =
|
|
192
|
-
|
|
190
|
+
}), (e) => e.identity_id), a = M(ue(t.device_decisions, 500).map((e) => {
|
|
191
|
+
let t = O(e);
|
|
192
|
+
k(t, [
|
|
193
193
|
"device_id",
|
|
194
194
|
"key_fingerprint",
|
|
195
195
|
"enabled",
|
|
196
196
|
"identity_id",
|
|
197
197
|
"decision"
|
|
198
|
-
]), t.decision !== "included" && t.decision !== "excluded" &&
|
|
199
|
-
let n = t.identity_id == null ? null :
|
|
200
|
-
t.decision === "included" != !!n &&
|
|
198
|
+
]), t.decision !== "included" && t.decision !== "excluded" && D(), typeof t.enabled != "boolean" && D();
|
|
199
|
+
let n = t.identity_id == null ? null : A(t.identity_id);
|
|
200
|
+
t.decision === "included" != !!n && D(), t.decision === "included" && !t.enabled && D();
|
|
201
201
|
let r = t.decision;
|
|
202
202
|
return {
|
|
203
|
-
device_id:
|
|
204
|
-
key_fingerprint:
|
|
203
|
+
device_id: A(t.device_id),
|
|
204
|
+
key_fingerprint: j(t.key_fingerprint),
|
|
205
205
|
enabled: t.enabled,
|
|
206
206
|
identity_id: n,
|
|
207
207
|
decision: r
|
|
208
208
|
};
|
|
209
209
|
}), (e) => e.device_id);
|
|
210
|
-
a.length === 0 &&
|
|
210
|
+
a.length === 0 && D();
|
|
211
211
|
let s = new Set(i.map((e) => e.identity_id)), c = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
|
|
212
|
-
(s.size !== c.size || [...c].some((e) => !s.has(e))) &&
|
|
213
|
-
let l = ue(
|
|
214
|
-
let t =
|
|
215
|
-
|
|
212
|
+
(s.size !== c.size || [...c].some((e) => !s.has(e))) && D();
|
|
213
|
+
let l = M(ue(t.project_mappings, 500).map((e) => {
|
|
214
|
+
let t = O(e);
|
|
215
|
+
k(t, [
|
|
216
216
|
"project_ref",
|
|
217
217
|
"resolved_project_ref",
|
|
218
218
|
"scope_id"
|
|
219
219
|
]);
|
|
220
|
-
let n =
|
|
221
|
-
return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) ||
|
|
220
|
+
let n = A(t.project_ref), r = A(t.resolved_project_ref);
|
|
221
|
+
return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) || D(), /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(r) || D(), {
|
|
222
222
|
project_ref: n,
|
|
223
223
|
resolved_project_ref: r,
|
|
224
|
-
scope_id:
|
|
224
|
+
scope_id: A(t.scope_id)
|
|
225
225
|
};
|
|
226
226
|
}), (e) => e.project_ref), u = /* @__PURE__ */ new Map();
|
|
227
227
|
for (let e of l) {
|
|
228
228
|
let t = u.get(e.resolved_project_ref);
|
|
229
|
-
t && t !== e.scope_id &&
|
|
230
|
-
}
|
|
231
|
-
let d = ue(
|
|
232
|
-
let t =
|
|
233
|
-
|
|
234
|
-
let n =
|
|
235
|
-
n !== r &&
|
|
236
|
-
let i =
|
|
237
|
-
return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) ||
|
|
229
|
+
t && t !== e.scope_id && D(), u.set(e.resolved_project_ref, e.scope_id);
|
|
230
|
+
}
|
|
231
|
+
let d = M(ue(t.project_recipients, 500).map((e) => {
|
|
232
|
+
let t = O(e);
|
|
233
|
+
k(t, ["resolved_project_ref", "team_id"]);
|
|
234
|
+
let n = A(t.team_id);
|
|
235
|
+
n !== r && D();
|
|
236
|
+
let i = A(t.resolved_project_ref);
|
|
237
|
+
return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) || D(), {
|
|
238
238
|
resolved_project_ref: i,
|
|
239
239
|
team_id: n
|
|
240
240
|
};
|
|
241
241
|
}), (e) => e.resolved_project_ref), f = [...new Set(l.map((e) => e.resolved_project_ref))].toSorted(o), p = d.map((e) => e.resolved_project_ref);
|
|
242
|
-
JSON.stringify(p) !== JSON.stringify(f) &&
|
|
242
|
+
JSON.stringify(p) !== JSON.stringify(f) && D();
|
|
243
243
|
let m = {
|
|
244
244
|
version: 1,
|
|
245
|
-
coordinator_id:
|
|
245
|
+
coordinator_id: A(t.coordinator_id),
|
|
246
246
|
candidate_ref: fe(t.candidate_ref),
|
|
247
|
-
candidate_digest:
|
|
247
|
+
candidate_digest: j(t.candidate_digest),
|
|
248
248
|
team_id: r,
|
|
249
|
-
team_digest:
|
|
250
|
-
source_digest:
|
|
251
|
-
finish_digest:
|
|
252
|
-
access_delta_digest:
|
|
249
|
+
team_digest: j(t.team_digest),
|
|
250
|
+
source_digest: j(t.source_digest),
|
|
251
|
+
finish_digest: j(t.finish_digest),
|
|
252
|
+
access_delta_digest: j(t.access_delta_digest),
|
|
253
253
|
team: {
|
|
254
|
-
display_name:
|
|
255
|
-
policy_revision:
|
|
254
|
+
display_name: ce(n.display_name),
|
|
255
|
+
policy_revision: j(n.policy_revision),
|
|
256
256
|
device_eligibility_mode: "reviewed_allowlist"
|
|
257
257
|
},
|
|
258
258
|
memberships: i,
|
|
259
259
|
device_decisions: a,
|
|
260
260
|
project_mappings: l,
|
|
261
261
|
project_recipients: d,
|
|
262
|
-
completed_at:
|
|
262
|
+
completed_at: le(t.completed_at)
|
|
263
263
|
};
|
|
264
|
-
return new TextEncoder().encode(JSON.stringify(m)).byteLength > 15e5 &&
|
|
264
|
+
return new TextEncoder().encode(JSON.stringify(m)).byteLength > 15e5 && D(), m;
|
|
265
265
|
}
|
|
266
266
|
function me(e) {
|
|
267
267
|
return JSON.stringify(pe(e));
|
|
268
268
|
}
|
|
269
269
|
function he(e) {
|
|
270
|
-
e.team_id !== S(e.candidate_ref) &&
|
|
270
|
+
e.team_id !== S(e.candidate_ref) && D();
|
|
271
271
|
}
|
|
272
272
|
function ge(e, t) {
|
|
273
|
-
y(e.coordinator_id, t) !== e.candidate_ref &&
|
|
273
|
+
y(e.coordinator_id, t) !== e.candidate_ref && D();
|
|
274
274
|
}
|
|
275
275
|
function _e(e, t, n) {
|
|
276
276
|
ge(e, t);
|
|
277
277
|
let r = new Set(e.project_mappings.map((e) => e.scope_id));
|
|
278
|
-
n.length !== r.size &&
|
|
278
|
+
n.length !== r.size && D();
|
|
279
279
|
let i = e.coordinator_id;
|
|
280
|
-
for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) &&
|
|
280
|
+
for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) && D();
|
|
281
281
|
return i;
|
|
282
282
|
}
|
|
283
283
|
//#endregion
|
|
@@ -1484,33 +1484,51 @@ function Dn(e) {
|
|
|
1484
1484
|
return typeof e == "object" && !!e && "code" in e && e.code === "project_sync_enablement_failed" && "detail" in e && e.detail === "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.";
|
|
1485
1485
|
}
|
|
1486
1486
|
//#endregion
|
|
1487
|
-
//#region src/
|
|
1488
|
-
var On =
|
|
1487
|
+
//#region src/project-identity.ts
|
|
1488
|
+
var On = /^(?:command failed(?:\s|:)|error:\s|fatal:\s|git:\s)/iu, kn = /^(?:giterror|git error|git command failed):[^\r\n]*(?:not a git repository|unknown revision or path|no such remote)\b/iu;
|
|
1489
|
+
function An(e) {
|
|
1490
|
+
if (typeof e != "string") return !1;
|
|
1491
|
+
let t = e.trim();
|
|
1492
|
+
return t ? t.includes("\n") || t.includes("\r") ? !0 : On.test(t) || kn.test(t) : !1;
|
|
1493
|
+
}
|
|
1489
1494
|
function q(e) {
|
|
1490
|
-
|
|
1495
|
+
let t = e?.trim();
|
|
1496
|
+
return !t || An(t) ? null : t;
|
|
1491
1497
|
}
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/scope-resolution.ts
|
|
1500
|
+
var jn = "local-default", Mn = "legacy-shared-review";
|
|
1492
1501
|
function J(e) {
|
|
1502
|
+
return e?.trim() || null;
|
|
1503
|
+
}
|
|
1504
|
+
function Y(e) {
|
|
1493
1505
|
return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
|
|
1494
1506
|
}
|
|
1495
|
-
function
|
|
1496
|
-
return
|
|
1507
|
+
function Nn(t) {
|
|
1508
|
+
return Y(e(t));
|
|
1497
1509
|
}
|
|
1498
|
-
function
|
|
1499
|
-
let t =
|
|
1500
|
-
return t ?
|
|
1510
|
+
function Pn(e) {
|
|
1511
|
+
let t = J(e);
|
|
1512
|
+
return t ? Y(t) : null;
|
|
1501
1513
|
}
|
|
1502
|
-
function
|
|
1514
|
+
function Fn(e) {
|
|
1503
1515
|
let n = [
|
|
1504
1516
|
e.cwd,
|
|
1505
1517
|
e.project,
|
|
1506
1518
|
e.workspaceId
|
|
1507
|
-
].map((e) => q(e)).find((e) => e
|
|
1508
|
-
|
|
1519
|
+
].map((e) => q(e)).find((e) => e !== null), r = [
|
|
1520
|
+
e.gitRemote,
|
|
1521
|
+
e.gitBranch,
|
|
1522
|
+
e.cwd,
|
|
1523
|
+
e.project,
|
|
1524
|
+
e.workspaceId
|
|
1525
|
+
].map((e) => typeof e == "string" ? e.trim() : null), i = n ?? "unknown";
|
|
1526
|
+
return !n && r.some(An) && (i = JSON.stringify(r)), `unmapped:${t("sha256").update(i, "utf8").digest("hex")}`;
|
|
1509
1527
|
}
|
|
1510
|
-
function
|
|
1528
|
+
function In(e) {
|
|
1511
1529
|
let t = q(e.gitRemote), n = q(e.gitBranch), r = q(e.cwd), i = q(e.workspaceId), a = q(e.project);
|
|
1512
1530
|
if (t) {
|
|
1513
|
-
let r =
|
|
1531
|
+
let r = Y(t);
|
|
1514
1532
|
return e.branchScoped && n ? {
|
|
1515
1533
|
value: `${r}:${n}`,
|
|
1516
1534
|
source: "git_remote_branch",
|
|
@@ -1522,49 +1540,49 @@ function Nn(e) {
|
|
|
1522
1540
|
};
|
|
1523
1541
|
}
|
|
1524
1542
|
return r ? {
|
|
1525
|
-
value:
|
|
1543
|
+
value: Nn(r),
|
|
1526
1544
|
source: "cwd",
|
|
1527
1545
|
displayProject: a
|
|
1528
1546
|
} : i ? {
|
|
1529
|
-
value:
|
|
1547
|
+
value: Y(i),
|
|
1530
1548
|
source: "workspace_id",
|
|
1531
1549
|
displayProject: a
|
|
1532
1550
|
} : {
|
|
1533
|
-
value:
|
|
1551
|
+
value: Fn(e),
|
|
1534
1552
|
source: "unmapped",
|
|
1535
1553
|
displayProject: a
|
|
1536
1554
|
};
|
|
1537
1555
|
}
|
|
1538
|
-
function
|
|
1556
|
+
function Ln(e) {
|
|
1539
1557
|
return !/[\\/:]/.test(e);
|
|
1540
1558
|
}
|
|
1541
|
-
function
|
|
1559
|
+
function Rn(e) {
|
|
1542
1560
|
return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
1543
1561
|
}
|
|
1544
|
-
function
|
|
1562
|
+
function zn(e) {
|
|
1545
1563
|
return e.replace(/[*?]/g, "").length;
|
|
1546
1564
|
}
|
|
1547
|
-
function
|
|
1548
|
-
let n =
|
|
1549
|
-
return !n ||
|
|
1565
|
+
function Bn(e, t) {
|
|
1566
|
+
let n = Y(t);
|
|
1567
|
+
return !n || Ln(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Rn(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
|
|
1550
1568
|
}
|
|
1551
|
-
function
|
|
1569
|
+
function Vn(e) {
|
|
1552
1570
|
return e.mapping.priority ?? 0;
|
|
1553
1571
|
}
|
|
1554
|
-
function
|
|
1555
|
-
let t =
|
|
1572
|
+
function Hn(e) {
|
|
1573
|
+
let t = J(e.mapping.updated_at);
|
|
1556
1574
|
if (!t) return 0;
|
|
1557
1575
|
let n = Date.parse(t);
|
|
1558
1576
|
return Number.isFinite(n) ? n : 0;
|
|
1559
1577
|
}
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1578
|
+
function Un(e, t) {
|
|
1579
|
+
return Vn(t) - Vn(e) || t.specificity - e.specificity || Hn(t) - Hn(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
|
|
1562
1580
|
}
|
|
1563
|
-
function
|
|
1564
|
-
return e.toSorted(
|
|
1581
|
+
function Wn(e) {
|
|
1582
|
+
return e.toSorted(Un)[0] ?? null;
|
|
1565
1583
|
}
|
|
1566
|
-
function
|
|
1567
|
-
let t =
|
|
1584
|
+
function Gn(e) {
|
|
1585
|
+
let t = In(e), n = J(e.explicitScopeId);
|
|
1568
1586
|
if (n) return {
|
|
1569
1587
|
scopeId: n,
|
|
1570
1588
|
reason: "explicit_override",
|
|
@@ -1579,7 +1597,7 @@ function Hn(e) {
|
|
|
1579
1597
|
mapping: null,
|
|
1580
1598
|
matchedPattern: null
|
|
1581
1599
|
};
|
|
1582
|
-
let r = e.mappings ?? [], i =
|
|
1600
|
+
let r = e.mappings ?? [], i = Wn(r.filter((e) => Pn(e.workspace_identity) === t.value).map((e) => ({
|
|
1583
1601
|
mapping: e,
|
|
1584
1602
|
matchedPattern: null,
|
|
1585
1603
|
specificity: t.value.length
|
|
@@ -1591,13 +1609,13 @@ function Hn(e) {
|
|
|
1591
1609
|
mapping: i.mapping,
|
|
1592
1610
|
matchedPattern: null
|
|
1593
1611
|
};
|
|
1594
|
-
let a =
|
|
1595
|
-
if (
|
|
1596
|
-
let n =
|
|
1597
|
-
return !n || !
|
|
1612
|
+
let a = Wn(r.flatMap((e) => {
|
|
1613
|
+
if (J(e.workspace_identity)) return [];
|
|
1614
|
+
let n = J(e.project_pattern);
|
|
1615
|
+
return !n || !Bn(t.value, n) ? [] : [{
|
|
1598
1616
|
mapping: e,
|
|
1599
|
-
matchedPattern:
|
|
1600
|
-
specificity:
|
|
1617
|
+
matchedPattern: Y(n),
|
|
1618
|
+
specificity: zn(n)
|
|
1601
1619
|
}];
|
|
1602
1620
|
}));
|
|
1603
1621
|
return a ? {
|
|
@@ -1614,11 +1632,11 @@ function Hn(e) {
|
|
|
1614
1632
|
matchedPattern: null
|
|
1615
1633
|
};
|
|
1616
1634
|
}
|
|
1617
|
-
function
|
|
1635
|
+
function Kn(e, t) {
|
|
1618
1636
|
let n = /* @__PURE__ */ new Set([
|
|
1619
1637
|
"",
|
|
1620
|
-
|
|
1621
|
-
|
|
1638
|
+
jn,
|
|
1639
|
+
Mn
|
|
1622
1640
|
]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
|
|
1623
1641
|
for (let e of r) e.scope_id != null && n.add(e.scope_id);
|
|
1624
1642
|
let i = e.prepare("SELECT sm.scope_id AS scope_id\n FROM scope_memberships sm\n JOIN replication_scopes rs ON rs.scope_id = sm.scope_id\n WHERE sm.device_id = ?\n AND sm.status = 'active'\n AND rs.status = 'active'\n AND sm.membership_epoch >= rs.membership_epoch").all(t);
|
|
@@ -1627,29 +1645,29 @@ function Un(e, t) {
|
|
|
1627
1645
|
}
|
|
1628
1646
|
//#endregion
|
|
1629
1647
|
//#region src/project-share-intent.ts
|
|
1630
|
-
var
|
|
1631
|
-
function
|
|
1648
|
+
var qn = "existing_and_future";
|
|
1649
|
+
function Jn(e) {
|
|
1632
1650
|
return t("sha256").update(JSON.stringify(e)).digest("hex");
|
|
1633
1651
|
}
|
|
1634
|
-
function
|
|
1635
|
-
return
|
|
1652
|
+
function Yn(e) {
|
|
1653
|
+
return Jn({
|
|
1636
1654
|
v: 1,
|
|
1637
|
-
historyPolicy:
|
|
1655
|
+
historyPolicy: qn,
|
|
1638
1656
|
projects: e.map((e) => ({
|
|
1639
1657
|
canonicalIdentity: e.canonicalIdentity,
|
|
1640
1658
|
existingMemoryCount: e.existingMemoryCount
|
|
1641
1659
|
})).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
|
|
1642
1660
|
});
|
|
1643
1661
|
}
|
|
1644
|
-
function
|
|
1645
|
-
return
|
|
1662
|
+
function Xn(e) {
|
|
1663
|
+
return Yn(e.map((e) => ({
|
|
1646
1664
|
canonicalIdentity: e.canonical_identity,
|
|
1647
1665
|
displayName: e.display_name,
|
|
1648
1666
|
identitySource: "coordinator_acceptance",
|
|
1649
1667
|
existingMemoryCount: e.existing_memory_count
|
|
1650
1668
|
})));
|
|
1651
1669
|
}
|
|
1652
|
-
function
|
|
1670
|
+
function Zn(e) {
|
|
1653
1671
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
|
|
1654
1672
|
let t = e.map((e) => {
|
|
1655
1673
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
|
|
@@ -1661,7 +1679,7 @@ function Jn(e) {
|
|
|
1661
1679
|
} catch {
|
|
1662
1680
|
throw Error("operation_intent_invalid");
|
|
1663
1681
|
}
|
|
1664
|
-
let o = t.existing_memory_count, s =
|
|
1682
|
+
let o = t.existing_memory_count, s = In({ gitRemote: r }).value;
|
|
1665
1683
|
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");
|
|
1666
1684
|
return {
|
|
1667
1685
|
canonical_identity: r,
|
|
@@ -1674,20 +1692,20 @@ function Jn(e) {
|
|
|
1674
1692
|
}
|
|
1675
1693
|
//#endregion
|
|
1676
1694
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
|
|
1677
|
-
function
|
|
1695
|
+
function Qn(e) {
|
|
1678
1696
|
let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
|
|
1679
1697
|
return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
|
|
1680
1698
|
}
|
|
1681
|
-
function
|
|
1682
|
-
let [e, t] =
|
|
1699
|
+
function $n() {
|
|
1700
|
+
let [e, t] = Qn();
|
|
1683
1701
|
return e * 1e3 + Math.floor(t / 1e6);
|
|
1684
1702
|
}
|
|
1685
|
-
function
|
|
1703
|
+
function er(e) {
|
|
1686
1704
|
return new Promise((t) => setTimeout(t, e));
|
|
1687
1705
|
}
|
|
1688
1706
|
//#endregion
|
|
1689
1707
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
|
|
1690
|
-
var
|
|
1708
|
+
var tr = class {
|
|
1691
1709
|
bucketSize;
|
|
1692
1710
|
tokensPerInterval;
|
|
1693
1711
|
interval;
|
|
@@ -1714,13 +1732,13 @@ var Zn = class {
|
|
|
1714
1732
|
default: throw Error("Invalid interval " + n);
|
|
1715
1733
|
}
|
|
1716
1734
|
else this.interval = n;
|
|
1717
|
-
this.parentBucket = r, this.content = 0, this.lastDrip =
|
|
1735
|
+
this.parentBucket = r, this.content = 0, this.lastDrip = $n();
|
|
1718
1736
|
}
|
|
1719
1737
|
async removeTokens(e) {
|
|
1720
1738
|
if (this.bucketSize === 0) return Infinity;
|
|
1721
1739
|
if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
|
|
1722
1740
|
this.drip();
|
|
1723
|
-
let t = async () => (await
|
|
1741
|
+
let t = async () => (await er(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
|
|
1724
1742
|
if (e > this.content) return t();
|
|
1725
1743
|
if (this.parentBucket != null) {
|
|
1726
1744
|
let n = await this.parentBucket.removeTokens(e);
|
|
@@ -1736,30 +1754,30 @@ var Zn = class {
|
|
|
1736
1754
|
let e = this.content;
|
|
1737
1755
|
return this.content = this.bucketSize, this.content > e;
|
|
1738
1756
|
}
|
|
1739
|
-
let e =
|
|
1757
|
+
let e = $n(), t = Math.max(e - this.lastDrip, 0);
|
|
1740
1758
|
this.lastDrip = e;
|
|
1741
1759
|
let n = t * (this.tokensPerInterval / this.interval), r = this.content;
|
|
1742
1760
|
return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
|
|
1743
1761
|
}
|
|
1744
|
-
},
|
|
1762
|
+
}, nr = class {
|
|
1745
1763
|
tokenBucket;
|
|
1746
1764
|
curIntervalStart;
|
|
1747
1765
|
tokensThisInterval;
|
|
1748
1766
|
fireImmediately;
|
|
1749
1767
|
constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
|
|
1750
|
-
this.tokenBucket = new
|
|
1768
|
+
this.tokenBucket = new tr({
|
|
1751
1769
|
bucketSize: e,
|
|
1752
1770
|
tokensPerInterval: e,
|
|
1753
1771
|
interval: t
|
|
1754
|
-
}), this.tokenBucket.content = e, this.curIntervalStart =
|
|
1772
|
+
}), this.tokenBucket.content = e, this.curIntervalStart = $n(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
|
|
1755
1773
|
}
|
|
1756
1774
|
async removeTokens(e) {
|
|
1757
1775
|
if (e > this.tokenBucket.bucketSize) throw Error(`Requested tokens ${e} exceeds maximum tokens per interval ${this.tokenBucket.bucketSize}`);
|
|
1758
|
-
let t =
|
|
1776
|
+
let t = $n();
|
|
1759
1777
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
|
|
1760
1778
|
if (this.fireImmediately) return -1;
|
|
1761
1779
|
{
|
|
1762
|
-
await
|
|
1780
|
+
await er(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
|
|
1763
1781
|
let n = await this.tokenBucket.removeTokens(e);
|
|
1764
1782
|
return this.tokensThisInterval += e, n;
|
|
1765
1783
|
}
|
|
@@ -1769,7 +1787,7 @@ var Zn = class {
|
|
|
1769
1787
|
}
|
|
1770
1788
|
tryRemoveTokens(e) {
|
|
1771
1789
|
if (e > this.tokenBucket.bucketSize) return !1;
|
|
1772
|
-
let t =
|
|
1790
|
+
let t = $n();
|
|
1773
1791
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) return !1;
|
|
1774
1792
|
let n = this.tokenBucket.tryRemoveTokens(e);
|
|
1775
1793
|
return n && (this.tokensThisInterval += e), n;
|
|
@@ -1780,7 +1798,7 @@ var Zn = class {
|
|
|
1780
1798
|
};
|
|
1781
1799
|
//#endregion
|
|
1782
1800
|
//#region src/request-rate-limit.ts
|
|
1783
|
-
function
|
|
1801
|
+
function rr(e = {}) {
|
|
1784
1802
|
let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
|
|
1785
1803
|
function a(e) {
|
|
1786
1804
|
return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
|
|
@@ -1797,7 +1815,7 @@ function $n(e = {}) {
|
|
|
1797
1815
|
o(l);
|
|
1798
1816
|
let u = `${c}:${e}`, d = r.get(u);
|
|
1799
1817
|
return d || (d = {
|
|
1800
|
-
limiter: new
|
|
1818
|
+
limiter: new nr({
|
|
1801
1819
|
tokensPerInterval: c,
|
|
1802
1820
|
interval: t,
|
|
1803
1821
|
fireImmediately: !0
|
|
@@ -1814,8 +1832,8 @@ function $n(e = {}) {
|
|
|
1814
1832
|
}
|
|
1815
1833
|
//#endregion
|
|
1816
1834
|
//#region src/scope-membership-semantics.ts
|
|
1817
|
-
var
|
|
1818
|
-
function
|
|
1835
|
+
var ir = "Revocation blocks future sync for this Space. It does not remove data already copied to the revoked device; offline devices, backups, copied databases, malicious peers, or old versions may retain data.";
|
|
1836
|
+
function ar(e) {
|
|
1819
1837
|
let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
|
|
1820
1838
|
return t == null || n == null ? {
|
|
1821
1839
|
membership_epoch: t,
|
|
@@ -1829,19 +1847,19 @@ function tr(e) {
|
|
|
1829
1847
|
reason: t < n ? "stale_epoch" : "current"
|
|
1830
1848
|
};
|
|
1831
1849
|
}
|
|
1832
|
-
function
|
|
1850
|
+
function or(e) {
|
|
1833
1851
|
return {
|
|
1834
1852
|
scope_id: e.scopeId,
|
|
1835
1853
|
device_id: e.deviceId,
|
|
1836
1854
|
membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
|
|
1837
1855
|
prevents_future_sync: !0,
|
|
1838
1856
|
deletes_already_copied_data: !1,
|
|
1839
|
-
message:
|
|
1857
|
+
message: ir
|
|
1840
1858
|
};
|
|
1841
1859
|
}
|
|
1842
1860
|
//#endregion
|
|
1843
1861
|
//#region src/sync-auth-constants.ts
|
|
1844
|
-
var
|
|
1862
|
+
var sr = 300, cr = 65536, lr = E + 1024, X = "X-Codemem-Coordinator-Admin", ur = "X-Codemem-Coordinator-Admin-Actor", dr = 120, fr = 30;
|
|
1845
1863
|
function Z(e, t) {
|
|
1846
1864
|
let n = t.adminSecret();
|
|
1847
1865
|
if (!n) return {
|
|
@@ -1860,14 +1878,14 @@ function Z(e, t) {
|
|
|
1860
1878
|
error: "missing_admin_header"
|
|
1861
1879
|
};
|
|
1862
1880
|
}
|
|
1863
|
-
function
|
|
1881
|
+
function pr(e) {
|
|
1864
1882
|
let t = new URL(e);
|
|
1865
1883
|
return t.search ? `${t.pathname}${t.search}` : t.pathname;
|
|
1866
1884
|
}
|
|
1867
|
-
async function
|
|
1885
|
+
async function mr(e, t, n, r) {
|
|
1868
1886
|
return await e.recordNonce(t, n, r);
|
|
1869
1887
|
}
|
|
1870
|
-
async function
|
|
1888
|
+
async function hr(e, t) {
|
|
1871
1889
|
await e.cleanupNonces(t);
|
|
1872
1890
|
}
|
|
1873
1891
|
async function Q(e, t, n, r) {
|
|
@@ -1903,7 +1921,7 @@ async function Q(e, t, n, r) {
|
|
|
1903
1921
|
try {
|
|
1904
1922
|
u = await n({
|
|
1905
1923
|
method: r.method,
|
|
1906
|
-
pathWithQuery:
|
|
1924
|
+
pathWithQuery: pr(r.url),
|
|
1907
1925
|
bodyBytes: r.body,
|
|
1908
1926
|
timestamp: o,
|
|
1909
1927
|
nonce: s,
|
|
@@ -1924,7 +1942,7 @@ async function Q(e, t, n, r) {
|
|
|
1924
1942
|
enrollment: null
|
|
1925
1943
|
};
|
|
1926
1944
|
let d = t.now();
|
|
1927
|
-
return await
|
|
1945
|
+
return await mr(e, i, s, d) ? (await hr(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
|
|
1928
1946
|
ok: !0,
|
|
1929
1947
|
error: "ok",
|
|
1930
1948
|
enrollment: c
|
|
@@ -1937,9 +1955,9 @@ async function Q(e, t, n, r) {
|
|
|
1937
1955
|
function $(e) {
|
|
1938
1956
|
return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
|
|
1939
1957
|
}
|
|
1940
|
-
function
|
|
1958
|
+
function gr(e) {
|
|
1941
1959
|
if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
|
|
1942
|
-
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ??
|
|
1960
|
+
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? rr(), o = Math.max(1, Math.trunc(i.readLimit ?? dr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? fr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new mn(), d = new TextDecoder();
|
|
1943
1961
|
function f(e, t, n) {
|
|
1944
1962
|
let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = a.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? o : s : r ? c : l);
|
|
1945
1963
|
return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
|
|
@@ -1947,7 +1965,7 @@ function fr(e) {
|
|
|
1947
1965
|
retry_after_s: i.retryAfterS
|
|
1948
1966
|
}, 429));
|
|
1949
1967
|
}
|
|
1950
|
-
async function p(e, t =
|
|
1968
|
+
async function p(e, t = cr) {
|
|
1951
1969
|
let n = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
1952
1970
|
if (Number.isFinite(n) && n > t) return null;
|
|
1953
1971
|
let r = e.req.raw.body;
|
|
@@ -2006,7 +2024,7 @@ function fr(e) {
|
|
|
2006
2024
|
}
|
|
2007
2025
|
function y(e) {
|
|
2008
2026
|
try {
|
|
2009
|
-
return
|
|
2027
|
+
return Zn(JSON.parse(e ?? ""));
|
|
2010
2028
|
} catch {
|
|
2011
2029
|
throw Error("operation_intent_invalid");
|
|
2012
2030
|
}
|
|
@@ -2015,7 +2033,7 @@ function fr(e) {
|
|
|
2015
2033
|
let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
|
|
2016
2034
|
if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
|
|
2017
2035
|
let r = y(e.project_intent_json);
|
|
2018
|
-
if (
|
|
2036
|
+
if (Xn(r) !== n) throw Error("operation_intent_invalid");
|
|
2019
2037
|
return {
|
|
2020
2038
|
operation_id: t,
|
|
2021
2039
|
reviewed_project_set_digest: n,
|
|
@@ -2056,7 +2074,7 @@ function fr(e) {
|
|
|
2056
2074
|
response: r.json({ error: "scope_not_found" }, 404)
|
|
2057
2075
|
};
|
|
2058
2076
|
}
|
|
2059
|
-
async function
|
|
2077
|
+
async function te(e, n, i) {
|
|
2060
2078
|
let a = await Q(e, t, r, {
|
|
2061
2079
|
method: i.req.method,
|
|
2062
2080
|
url: i.req.url,
|
|
@@ -2075,7 +2093,7 @@ function fr(e) {
|
|
|
2075
2093
|
response: f(i, String(a.enrollment.device_id), !0)
|
|
2076
2094
|
};
|
|
2077
2095
|
}
|
|
2078
|
-
function
|
|
2096
|
+
function C(e, t) {
|
|
2079
2097
|
return e.status === "active" && e.membership_epoch >= t.membership_epoch;
|
|
2080
2098
|
}
|
|
2081
2099
|
return u.post("/v1/presence", async (e) => {
|
|
@@ -2151,7 +2169,7 @@ function fr(e) {
|
|
|
2151
2169
|
if (!t) return e.json({ error: "group_id_required" }, 400);
|
|
2152
2170
|
let r = n();
|
|
2153
2171
|
try {
|
|
2154
|
-
let { auth: n, response: i } = await
|
|
2172
|
+
let { auth: n, response: i } = await te(r, t, e);
|
|
2155
2173
|
if (i) return i;
|
|
2156
2174
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
2157
2175
|
let a = await r.listScopes({
|
|
@@ -2160,7 +2178,7 @@ function fr(e) {
|
|
|
2160
2178
|
}), o = await r.listDeviceScopeMemberships(String(n.enrollment.device_id), !1), s = new Map(o.map((e) => [e.scope_id, e])), c = a.filter((e) => {
|
|
2161
2179
|
if (e.status !== "active") return !1;
|
|
2162
2180
|
let t = s.get(e.scope_id);
|
|
2163
|
-
return !!(t &&
|
|
2181
|
+
return !!(t && C(t, e));
|
|
2164
2182
|
});
|
|
2165
2183
|
return e.json({ items: c });
|
|
2166
2184
|
} finally {
|
|
@@ -2172,7 +2190,7 @@ function fr(e) {
|
|
|
2172
2190
|
if (!r) return e.json({ error: "scope_id_required" }, 400);
|
|
2173
2191
|
let i = n();
|
|
2174
2192
|
try {
|
|
2175
|
-
let { auth: n, response: a } = await
|
|
2193
|
+
let { auth: n, response: a } = await te(i, t, e);
|
|
2176
2194
|
if (a) return a;
|
|
2177
2195
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
2178
2196
|
let o = (await i.listScopes({
|
|
@@ -2181,7 +2199,7 @@ function fr(e) {
|
|
|
2181
2199
|
})).find((e) => e.scope_id === r) ?? null;
|
|
2182
2200
|
if (o?.status !== "active") return e.json({ error: "scope_not_found" }, 404);
|
|
2183
2201
|
let s = await i.listScopeMemberships(r, !1);
|
|
2184
|
-
return s.some((e) => e.device_id === String(n.enrollment?.device_id) &&
|
|
2202
|
+
return s.some((e) => e.device_id === String(n.enrollment?.device_id) && C(e, o)) ? e.json({ items: s.filter((e) => C(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
|
|
2185
2203
|
} finally {
|
|
2186
2204
|
await i.close();
|
|
2187
2205
|
}
|
|
@@ -2586,7 +2604,7 @@ function fr(e) {
|
|
|
2586
2604
|
manifestHash: h(o, "manifest_hash"),
|
|
2587
2605
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2588
2606
|
actorType: "admin",
|
|
2589
|
-
actorId: g(e.req.header(
|
|
2607
|
+
actorId: g(e.req.header(ur))
|
|
2590
2608
|
});
|
|
2591
2609
|
return e.json({
|
|
2592
2610
|
ok: !0,
|
|
@@ -2627,7 +2645,7 @@ function fr(e) {
|
|
|
2627
2645
|
manifestHash: h(o, "manifest_hash"),
|
|
2628
2646
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2629
2647
|
actorType: "admin",
|
|
2630
|
-
actorId: g(e.req.header(
|
|
2648
|
+
actorId: g(e.req.header(ur))
|
|
2631
2649
|
})) return e.json({ error: "membership_not_found" }, 404);
|
|
2632
2650
|
let n;
|
|
2633
2651
|
try {
|
|
@@ -2639,7 +2657,7 @@ function fr(e) {
|
|
|
2639
2657
|
ok: !0,
|
|
2640
2658
|
scope_id: c,
|
|
2641
2659
|
device_id: l,
|
|
2642
|
-
revocation:
|
|
2660
|
+
revocation: or({
|
|
2643
2661
|
scopeId: c,
|
|
2644
2662
|
deviceId: l,
|
|
2645
2663
|
membershipEpoch: n?.membership_epoch ?? d
|
|
@@ -2753,7 +2771,7 @@ function fr(e) {
|
|
|
2753
2771
|
if (!r.ok) return f(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
2754
2772
|
let i = f(e, "admin", !0);
|
|
2755
2773
|
if (i) return i;
|
|
2756
|
-
let a = await p(e,
|
|
2774
|
+
let a = await p(e, lr);
|
|
2757
2775
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2758
2776
|
let o = m(a);
|
|
2759
2777
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
@@ -2774,7 +2792,7 @@ function fr(e) {
|
|
|
2774
2792
|
...t
|
|
2775
2793
|
}, t.status === "created" ? 201 : 200);
|
|
2776
2794
|
} catch (t) {
|
|
2777
|
-
if (t instanceof
|
|
2795
|
+
if (t instanceof oe) return e.json({ error: t.code }, 409);
|
|
2778
2796
|
let n = t instanceof Error ? t.message : "completion_manifest_invalid";
|
|
2779
2797
|
if (n === "group_not_found") return e.json({ error: n }, 404);
|
|
2780
2798
|
if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
|
|
@@ -2835,27 +2853,27 @@ function fr(e) {
|
|
|
2835
2853
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2836
2854
|
let o = m(a);
|
|
2837
2855
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2838
|
-
let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null,
|
|
2856
|
+
let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, te, C = null, w = null;
|
|
2839
2857
|
if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
|
|
2840
2858
|
if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
|
|
2841
2859
|
if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
|
|
2842
2860
|
if (!!d != !!h) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
|
|
2843
|
-
let
|
|
2861
|
+
let T = ee || (d ? "project_share" : "legacy_enrollment");
|
|
2844
2862
|
if (![
|
|
2845
2863
|
"legacy_enrollment",
|
|
2846
2864
|
"project_share",
|
|
2847
2865
|
"team_member",
|
|
2848
2866
|
"add_device"
|
|
2849
|
-
].includes(
|
|
2850
|
-
if (
|
|
2867
|
+
].includes(T)) return e.json({ error: "invite_kind_invalid" }, 400);
|
|
2868
|
+
if (T === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
|
|
2851
2869
|
if (S && !/^[a-f0-9]{64}$/u.test(S)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
|
|
2852
|
-
if (
|
|
2870
|
+
if (T === "team_member" && (!b || !S || x) || T === "add_device" && (!x || !S || b) || !["team_member", "add_device"].includes(T) && (b || x || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
|
|
2853
2871
|
if ([b, x].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
|
|
2854
|
-
if (
|
|
2872
|
+
if (T === "team_member" || T === "add_device") {
|
|
2855
2873
|
if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2856
2874
|
try {
|
|
2857
|
-
|
|
2858
|
-
target:
|
|
2875
|
+
te = await it(o.reviewed_intent, {
|
|
2876
|
+
target: T === "team_member" ? {
|
|
2859
2877
|
kind: "team_member",
|
|
2860
2878
|
policyTeamId: String(b)
|
|
2861
2879
|
} : {
|
|
@@ -2877,27 +2895,27 @@ function fr(e) {
|
|
|
2877
2895
|
y
|
|
2878
2896
|
].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
|
|
2879
2897
|
try {
|
|
2880
|
-
if (I(_, "inviter_display_name"),
|
|
2898
|
+
if (I(_, "inviter_display_name"), C = Be(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== C.length || (w = o.project_intent.map((e, t) => {
|
|
2881
2899
|
let n;
|
|
2882
2900
|
try {
|
|
2883
|
-
n =
|
|
2901
|
+
n = Zn([e])[0];
|
|
2884
2902
|
} catch {
|
|
2885
2903
|
throw Error("project_intent_invalid");
|
|
2886
2904
|
}
|
|
2887
|
-
let r =
|
|
2905
|
+
let r = C?.[t];
|
|
2888
2906
|
if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
|
|
2889
2907
|
return n;
|
|
2890
|
-
}), new Set(
|
|
2908
|
+
}), new Set(w.map((e) => e.canonical_identity)).size !== w.length)) throw Error("project_intent_invalid");
|
|
2891
2909
|
} catch (t) {
|
|
2892
2910
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
|
|
2893
2911
|
}
|
|
2894
2912
|
}
|
|
2895
|
-
let
|
|
2913
|
+
let E = n();
|
|
2896
2914
|
try {
|
|
2897
|
-
let t = await
|
|
2915
|
+
let t = await E.getGroup(s);
|
|
2898
2916
|
if (!t) return e.json({ error: "group_not_found" }, 404);
|
|
2899
2917
|
if (t.archived_at) return e.json({ error: "group_archived" }, 409);
|
|
2900
|
-
let n = await
|
|
2918
|
+
let n = await E.createInvite({
|
|
2901
2919
|
groupId: s,
|
|
2902
2920
|
policy: c,
|
|
2903
2921
|
expiresAt: l,
|
|
@@ -2908,13 +2926,13 @@ function fr(e) {
|
|
|
2908
2926
|
inviterDisplayName: _,
|
|
2909
2927
|
inviterDeviceId: v,
|
|
2910
2928
|
pendingPersonId: y,
|
|
2911
|
-
projectSummaries:
|
|
2912
|
-
projectIntent:
|
|
2913
|
-
inviteKind:
|
|
2929
|
+
projectSummaries: C,
|
|
2930
|
+
projectIntent: w,
|
|
2931
|
+
inviteKind: T,
|
|
2914
2932
|
policyTeamId: b,
|
|
2915
2933
|
targetIdentityId: x,
|
|
2916
2934
|
reviewedPreviewDigest: S,
|
|
2917
|
-
reviewedIntent:
|
|
2935
|
+
reviewedIntent: te
|
|
2918
2936
|
}), r = {
|
|
2919
2937
|
v: 1,
|
|
2920
2938
|
kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
|
|
@@ -2927,7 +2945,7 @@ function fr(e) {
|
|
|
2927
2945
|
...n.operation_id ? {
|
|
2928
2946
|
operation_id: n.operation_id,
|
|
2929
2947
|
inviter_name: n.inviter_display_name ?? null,
|
|
2930
|
-
project_summaries:
|
|
2948
|
+
project_summaries: C ?? []
|
|
2931
2949
|
} : {},
|
|
2932
2950
|
...n.invite_kind === "team_member" ? {
|
|
2933
2951
|
policy_team_id: n.policy_team_id ?? void 0,
|
|
@@ -2952,7 +2970,7 @@ function fr(e) {
|
|
|
2952
2970
|
if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
|
|
2953
2971
|
throw t;
|
|
2954
2972
|
} finally {
|
|
2955
|
-
await
|
|
2973
|
+
await E.close();
|
|
2956
2974
|
}
|
|
2957
2975
|
}), u.post("/v1/invites/inspect", async (e) => {
|
|
2958
2976
|
let r = await p(e);
|
|
@@ -3164,11 +3182,11 @@ function fr(e) {
|
|
|
3164
3182
|
} finally {
|
|
3165
3183
|
await c.close();
|
|
3166
3184
|
}
|
|
3167
|
-
}), u.post("/v1/admin/join-requests/approve", async (e) =>
|
|
3185
|
+
}), u.post("/v1/admin/join-requests/approve", async (e) => _r(e, !0, {
|
|
3168
3186
|
createStore: n,
|
|
3169
3187
|
runtime: t,
|
|
3170
3188
|
rateLimitedResponse: f
|
|
3171
|
-
})), u.post("/v1/admin/join-requests/deny", async (e) =>
|
|
3189
|
+
})), u.post("/v1/admin/join-requests/deny", async (e) => _r(e, !1, {
|
|
3172
3190
|
createStore: n,
|
|
3173
3191
|
runtime: t,
|
|
3174
3192
|
rateLimitedResponse: f
|
|
@@ -3372,14 +3390,14 @@ function fr(e) {
|
|
|
3372
3390
|
}
|
|
3373
3391
|
}), u;
|
|
3374
3392
|
}
|
|
3375
|
-
async function
|
|
3393
|
+
async function _r(e, t, n) {
|
|
3376
3394
|
let r = Z(e.req.header(X), n.runtime);
|
|
3377
3395
|
if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
3378
3396
|
let i = n.rateLimitedResponse(e, "admin", !0);
|
|
3379
3397
|
if (i) return i;
|
|
3380
3398
|
let a = await (async () => {
|
|
3381
3399
|
let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
3382
|
-
if (Number.isFinite(t) && t >
|
|
3400
|
+
if (Number.isFinite(t) && t > cr) return null;
|
|
3383
3401
|
let n = e.req.raw.body;
|
|
3384
3402
|
if (!n) return /* @__PURE__ */ new Uint8Array();
|
|
3385
3403
|
let r = n.getReader(), i = [], a = 0;
|
|
@@ -3388,7 +3406,7 @@ async function pr(e, t, n) {
|
|
|
3388
3406
|
let { done: e, value: t } = await r.read();
|
|
3389
3407
|
if (e) break;
|
|
3390
3408
|
if (t) {
|
|
3391
|
-
if (a += t.byteLength, a >
|
|
3409
|
+
if (a += t.byteLength, a > cr) return await r.cancel(), null;
|
|
3392
3410
|
i.push(t);
|
|
3393
3411
|
}
|
|
3394
3412
|
}
|
|
@@ -3436,6 +3454,6 @@ async function pr(e, t, n) {
|
|
|
3436
3454
|
}
|
|
3437
3455
|
}
|
|
3438
3456
|
//#endregion
|
|
3439
|
-
export {
|
|
3457
|
+
export { E as $, at as A, ke as B, Sn as C, g as Ct, L as D, n as Dt, Ve as E, i as Et, Re as F, Ce as G, Te as H, I, be as J, xe as K, F as L, it as M, ze as N, nt as O, Le as P, ie as Q, Be as R, yn as S, te as St, ot as T, a as Tt, Oe as U, De as V, N as W, ae as X, Se as Y, ne as Z, wn as _, _ as _t, ar as a, fe as at, Dn as b, x as bt, Zn as c, ge as ct, jn as d, v as dt, w as et, In as f, h as ft, Cn as g, u as gt, q as h, l as ht, or as i, me as it, rt as j, tt as k, Yn as l, _e as lt, Kn as m, S as mt, sr as n, C as nt, qn as o, de as ot, Gn as p, o as pt, we as q, ir as r, oe as rt, Xn as s, pe as st, gr as t, T as tt, Mn as u, he as ut, Tn as v, y as vt, xn as w, r as wt, bn as x, ee as xt, En as y, b as yt, Ae as z };
|
|
3440
3458
|
|
|
3441
|
-
//# sourceMappingURL=coordinator-api-
|
|
3459
|
+
//# sourceMappingURL=coordinator-api-BAufmPEa.js.map
|