@codemem/core 0.45.0 → 0.46.0-alpha.2
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/api-types.d.ts +20 -2
- package/dist/api-types.d.ts.map +1 -1
- package/dist/better-sqlite-coordinator-store.d.ts.map +1 -1
- package/dist/claude-hooks.d.ts +1 -2
- package/dist/claude-hooks.d.ts.map +1 -1
- package/dist/codex-hooks.d.ts.map +1 -1
- package/dist/coordinator-actions.d.ts.map +1 -1
- package/dist/{coordinator-api-C2ckGC2b.js → coordinator-api-BToPmSNg.js} +756 -495
- package/dist/coordinator-api-BToPmSNg.js.map +1 -0
- package/dist/coordinator-runtime.d.ts +2 -32
- package/dist/coordinator-runtime.d.ts.map +1 -1
- package/dist/coordinator-store-input-rules.d.ts +53 -0
- package/dist/coordinator-store-input-rules.d.ts.map +1 -0
- package/dist/coordinator-sync-config.d.ts +33 -0
- package/dist/coordinator-sync-config.d.ts.map +1 -0
- package/dist/d1-coordinator-store.d.ts.map +1 -1
- package/dist/database-runtime-primitives.d.ts +13 -0
- package/dist/database-runtime-primitives.d.ts.map +1 -0
- package/dist/db.d.ts +1 -21
- package/dist/db.d.ts.map +1 -1
- package/dist/extraction-tier-routing.d.ts.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20673 -14965
- package/dist/index.js.map +1 -1
- package/dist/ingest-pipeline.d.ts +6 -12
- package/dist/ingest-pipeline.d.ts.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +249 -467
- package/dist/internal/cloudflare-coordinator.js.map +1 -1
- package/dist/legacy-project-identity.d.ts +3 -0
- package/dist/legacy-project-identity.d.ts.map +1 -0
- package/dist/legacy-recipient-policy-projection.d.ts +1 -1
- package/dist/legacy-recipient-policy-projection.d.ts.map +1 -1
- package/dist/legacy-team-project-policy.d.ts +1 -1
- package/dist/legacy-team-project-policy.d.ts.map +1 -1
- package/dist/maintenance/ai-structured.d.ts.map +1 -1
- package/dist/managed-project-scope.d.ts +2 -0
- package/dist/managed-project-scope.d.ts.map +1 -0
- package/dist/observer-auth.d.ts +6 -1
- package/dist/observer-auth.d.ts.map +1 -1
- package/dist/observer-client.d.ts +50 -2
- package/dist/observer-client.d.ts.map +1 -1
- package/dist/observer-config.d.ts +71 -1
- package/dist/observer-config.d.ts.map +1 -1
- package/dist/observer-forced-tool.d.ts +3 -1
- package/dist/observer-forced-tool.d.ts.map +1 -1
- package/dist/observer-output-schema.d.ts +87 -29
- package/dist/observer-output-schema.d.ts.map +1 -1
- package/dist/observer-output.d.ts +10 -4
- package/dist/observer-output.d.ts.map +1 -1
- package/dist/observer-sse.d.ts +6 -0
- package/dist/observer-sse.d.ts.map +1 -0
- package/dist/pack.d.ts.map +1 -1
- package/dist/pi-hooks.d.ts.map +1 -1
- package/dist/pi-observer-config.d.ts +63 -0
- package/dist/pi-observer-config.d.ts.map +1 -0
- package/dist/project-label.d.ts +3 -0
- package/dist/project-label.d.ts.map +1 -0
- package/dist/project.d.ts +8 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/raw-event-flush.d.ts.map +1 -1
- package/dist/raw-event-ingest.d.ts +5 -0
- package/dist/raw-event-ingest.d.ts.map +1 -1
- package/dist/recipient-policy-contract.d.ts +88 -0
- package/dist/recipient-policy-contract.d.ts.map +1 -1
- package/dist/recipient-policy-contract.js +24 -0
- package/dist/recipient-policy-contract.js.map +1 -0
- package/dist/recipient-policy-edges.d.ts +2 -72
- package/dist/recipient-policy-edges.d.ts.map +1 -1
- package/dist/recipient-policy-onboarding.d.ts.map +1 -1
- package/dist/recipient-policy-reconciler.d.ts.map +1 -1
- package/dist/recipient-policy-review.d.ts +1 -1
- package/dist/recipient-policy-review.d.ts.map +1 -1
- package/dist/recipient-policy-team-metadata.d.ts +2 -9
- package/dist/recipient-policy-team-metadata.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts +1 -1
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/scope-membership-cache.d.ts +1 -1
- package/dist/scope-membership-cache.d.ts.map +1 -1
- package/dist/scope-resolution.d.ts.map +1 -1
- package/dist/search.d.ts +13 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/share-operation.d.ts +1 -1
- package/dist/share-operation.d.ts.map +1 -1
- package/dist/store.d.ts +18 -8
- package/dist/store.d.ts.map +1 -1
- package/dist/sync-discovery.d.ts +1 -16
- package/dist/sync-discovery.d.ts.map +1 -1
- package/dist/sync-pass.d.ts.map +1 -1
- package/dist/sync-peer-addresses.d.ts +9 -0
- package/dist/sync-peer-addresses.d.ts.map +1 -0
- package/dist/types.d.ts +17 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -5
- package/dist/coordinator-api-C2ckGC2b.js.map +0 -1
|
@@ -97,7 +97,35 @@ function ee(e, t) {
|
|
|
97
97
|
function b(e) {
|
|
98
98
|
return e.toSorted(ee)[0] ?? null;
|
|
99
99
|
}
|
|
100
|
-
function x(e) {
|
|
100
|
+
function x(e, t) {
|
|
101
|
+
let n = [t.value];
|
|
102
|
+
if (t.source !== "git_remote" && t.source !== "git_remote_branch") return n;
|
|
103
|
+
let r = a(e.cwd);
|
|
104
|
+
return r && n.push(u(r)), n;
|
|
105
|
+
}
|
|
106
|
+
function S(e, t) {
|
|
107
|
+
for (let n of t) {
|
|
108
|
+
let t = b(e.filter((e) => d(e.workspace_identity) === n).map((e) => ({
|
|
109
|
+
mapping: e,
|
|
110
|
+
matchedPattern: null,
|
|
111
|
+
specificity: n.length
|
|
112
|
+
})));
|
|
113
|
+
if (t) return t;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function te(e, t) {
|
|
118
|
+
return b(t.flatMap((t) => e.flatMap((e) => {
|
|
119
|
+
if (c(e.workspace_identity)) return [];
|
|
120
|
+
let n = c(e.project_pattern);
|
|
121
|
+
return !n || !_(t, n) ? [] : [{
|
|
122
|
+
mapping: e,
|
|
123
|
+
matchedPattern: l(n),
|
|
124
|
+
specificity: g(n)
|
|
125
|
+
}];
|
|
126
|
+
})));
|
|
127
|
+
}
|
|
128
|
+
function C(e) {
|
|
101
129
|
let t = p(e), n = c(e.explicitScopeId);
|
|
102
130
|
if (n) return {
|
|
103
131
|
scopeId: n,
|
|
@@ -113,33 +141,21 @@ function x(e) {
|
|
|
113
141
|
mapping: null,
|
|
114
142
|
matchedPattern: null
|
|
115
143
|
};
|
|
116
|
-
let r = e.mappings ?? [], i =
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
specificity: t.value.length
|
|
120
|
-
})));
|
|
121
|
-
if (i) return {
|
|
122
|
-
scopeId: i.mapping.scope_id,
|
|
144
|
+
let r = e.mappings ?? [], i = x(e, t), a = S(r, i);
|
|
145
|
+
if (a) return {
|
|
146
|
+
scopeId: a.mapping.scope_id,
|
|
123
147
|
reason: "exact_mapping",
|
|
124
148
|
workspaceIdentity: t,
|
|
125
|
-
mapping:
|
|
149
|
+
mapping: a.mapping,
|
|
126
150
|
matchedPattern: null
|
|
127
151
|
};
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return !n || !_(t.value, n) ? [] : [{
|
|
132
|
-
mapping: e,
|
|
133
|
-
matchedPattern: l(n),
|
|
134
|
-
specificity: g(n)
|
|
135
|
-
}];
|
|
136
|
-
}));
|
|
137
|
-
return a ? {
|
|
138
|
-
scopeId: a.mapping.scope_id,
|
|
152
|
+
let o = te(r, i);
|
|
153
|
+
return o ? {
|
|
154
|
+
scopeId: o.mapping.scope_id,
|
|
139
155
|
reason: "pattern_mapping",
|
|
140
156
|
workspaceIdentity: t,
|
|
141
|
-
mapping:
|
|
142
|
-
matchedPattern:
|
|
157
|
+
mapping: o.mapping,
|
|
158
|
+
matchedPattern: o.matchedPattern
|
|
143
159
|
} : {
|
|
144
160
|
scopeId: e.localDefaultScopeId ?? "local-default",
|
|
145
161
|
reason: "local_default",
|
|
@@ -148,7 +164,7 @@ function x(e) {
|
|
|
148
164
|
matchedPattern: null
|
|
149
165
|
};
|
|
150
166
|
}
|
|
151
|
-
function
|
|
167
|
+
function w(e, t) {
|
|
152
168
|
let n = /* @__PURE__ */ new Set([
|
|
153
169
|
"",
|
|
154
170
|
o,
|
|
@@ -159,18 +175,18 @@ function S(e, t) {
|
|
|
159
175
|
for (let e of i) e.scope_id != null && n.add(e.scope_id);
|
|
160
176
|
return [...n];
|
|
161
177
|
}
|
|
162
|
-
function
|
|
178
|
+
function T(e) {
|
|
163
179
|
if (e.devices.length > 500 || e.projects.length > 500 || e.devices.length * e.projects.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
164
180
|
}
|
|
165
|
-
function
|
|
181
|
+
function ne(e) {
|
|
166
182
|
if (e.projectIdentities.size * e.deviceCount > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
167
183
|
}
|
|
168
|
-
function
|
|
184
|
+
function re(e, t, n) {
|
|
169
185
|
if (n.length === 0) return;
|
|
170
186
|
let r = [...new Set(t.map((e) => e.deviceId))], i = r.length > 0 ? `WHERE device_id NOT IN (${r.map(() => "?").join(", ")})` : "", a = Number(e.prepare(`SELECT COUNT(*) FROM identity_devices ${i}`).pluck().get(...r) ?? 0);
|
|
171
187
|
if ((r.length + a) * n.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
172
188
|
}
|
|
173
|
-
function
|
|
189
|
+
function ie(e, t, n, r) {
|
|
174
190
|
if (!r) return;
|
|
175
191
|
let i = [...new Set(t.map((e) => e.deviceId))], a = i.map(() => "?").join(", "), o = a ? `AND device_id NOT IN (${a})` : "", s = Number(e.prepare(`SELECT COUNT(*) FROM legacy_team_setup_draft_devices
|
|
176
192
|
WHERE attempt_id = ? ${o}`).pluck().get(r, ...i) ?? 0), c = t.length + s;
|
|
@@ -178,97 +194,97 @@ function E(e, t, n, r) {
|
|
|
178
194
|
}
|
|
179
195
|
//#endregion
|
|
180
196
|
//#region src/recipient-policy-identifiers.ts
|
|
181
|
-
function
|
|
197
|
+
function E(e, t) {
|
|
182
198
|
return e < t ? -1 : +(e > t);
|
|
183
199
|
}
|
|
184
|
-
var
|
|
185
|
-
function
|
|
186
|
-
return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !
|
|
200
|
+
var ae = /[\p{Cc}\p{Cf}]/u;
|
|
201
|
+
function oe(e, t) {
|
|
202
|
+
return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !ae.test(e);
|
|
187
203
|
}
|
|
188
|
-
function
|
|
189
|
-
return
|
|
204
|
+
function se(e) {
|
|
205
|
+
return oe(e, 256);
|
|
190
206
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
207
|
+
function ce(e) {
|
|
208
|
+
return oe(e, 2048);
|
|
193
209
|
}
|
|
194
|
-
var
|
|
195
|
-
function
|
|
196
|
-
throw TypeError(
|
|
210
|
+
var le = "Recipient policy value must be strict JSON data";
|
|
211
|
+
function D() {
|
|
212
|
+
throw TypeError(le);
|
|
197
213
|
}
|
|
198
|
-
function
|
|
214
|
+
function ue(e) {
|
|
199
215
|
let t = JSON.stringify(e);
|
|
200
|
-
return t === void 0 ?
|
|
216
|
+
return t === void 0 ? D() : t;
|
|
201
217
|
}
|
|
202
|
-
function
|
|
218
|
+
function de(e, t) {
|
|
203
219
|
if (e === null) return "null";
|
|
204
220
|
if (typeof e == "boolean") return e ? "true" : "false";
|
|
205
|
-
if (typeof e == "string") return
|
|
206
|
-
if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ?
|
|
207
|
-
if (typeof e != "object" || t.has(e)) return
|
|
221
|
+
if (typeof e == "string") return ue(e);
|
|
222
|
+
if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ? D() : String(e);
|
|
223
|
+
if (typeof e != "object" || t.has(e)) return D();
|
|
208
224
|
t.add(e);
|
|
209
225
|
try {
|
|
210
226
|
if (Array.isArray(e)) {
|
|
211
|
-
if (Object.getPrototypeOf(e) !== Array.prototype) return
|
|
227
|
+
if (Object.getPrototypeOf(e) !== Array.prototype) return D();
|
|
212
228
|
let n = Reflect.ownKeys(e);
|
|
213
|
-
if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return
|
|
229
|
+
if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return D();
|
|
214
230
|
let r = [];
|
|
215
231
|
for (let n = 0; n < e.length; n += 1) {
|
|
216
232
|
let i = Object.getOwnPropertyDescriptor(e, String(n));
|
|
217
|
-
if (!i?.enumerable || !("value" in i)) return
|
|
218
|
-
r.push(
|
|
233
|
+
if (!i?.enumerable || !("value" in i)) return D();
|
|
234
|
+
r.push(de(i.value, t));
|
|
219
235
|
}
|
|
220
236
|
return `[${r.join(",")}]`;
|
|
221
237
|
}
|
|
222
238
|
let n = Object.getPrototypeOf(e);
|
|
223
|
-
return n !== Object.prototype && n !== null ?
|
|
224
|
-
if (typeof t != "string") return
|
|
239
|
+
return n !== Object.prototype && n !== null ? D() : `{${Reflect.ownKeys(e).map((t) => {
|
|
240
|
+
if (typeof t != "string") return D();
|
|
225
241
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
226
|
-
return !n?.enumerable || !("value" in n) ?
|
|
227
|
-
}).toSorted(([e], [t]) =>
|
|
242
|
+
return !n?.enumerable || !("value" in n) ? D() : [t, n.value];
|
|
243
|
+
}).toSorted(([e], [t]) => E(e, t)).map(([e, n]) => `${ue(e)}:${de(n, t)}`).join(",")}}`;
|
|
228
244
|
} finally {
|
|
229
245
|
t.delete(e);
|
|
230
246
|
}
|
|
231
247
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
248
|
+
function fe(e) {
|
|
249
|
+
return de(e, /* @__PURE__ */ new WeakSet());
|
|
234
250
|
}
|
|
235
|
-
function
|
|
251
|
+
function O(e, n) {
|
|
236
252
|
if (e.includes("\0") || !e.isWellFormed()) throw TypeError("Recipient policy digest prefix must be well-formed without NUL");
|
|
237
|
-
return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(
|
|
253
|
+
return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(fe(n), "utf8").digest("hex")}`;
|
|
238
254
|
}
|
|
239
|
-
function
|
|
240
|
-
return `${e}:${t("sha256").update(
|
|
255
|
+
function pe(e, n) {
|
|
256
|
+
return `${e}:${t("sha256").update(fe(n), "utf8").digest("hex")}`;
|
|
241
257
|
}
|
|
242
|
-
var
|
|
243
|
-
function
|
|
258
|
+
var me = ["team_invite", "coordinator_invite"];
|
|
259
|
+
function he(e, n) {
|
|
244
260
|
return `legacy-team-candidate:${t("sha256").update(JSON.stringify([e, n])).digest("hex").slice(0, 32)}`;
|
|
245
261
|
}
|
|
246
|
-
function
|
|
247
|
-
return
|
|
262
|
+
function ge(e, t) {
|
|
263
|
+
return O("legacy-team-project-ref-v1", [e, t]);
|
|
248
264
|
}
|
|
249
|
-
function
|
|
250
|
-
return
|
|
265
|
+
function _e(e, t) {
|
|
266
|
+
return O("legacy-team-canonical-project-ref-v1", [e, t]);
|
|
251
267
|
}
|
|
252
|
-
function
|
|
253
|
-
return
|
|
268
|
+
function ve(e, t) {
|
|
269
|
+
return O("legacy-team-device-ref-v1", [e, t]);
|
|
254
270
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
271
|
+
function ye(e) {
|
|
272
|
+
return pe("policy-team-v1", e);
|
|
257
273
|
}
|
|
258
|
-
function
|
|
259
|
-
return
|
|
274
|
+
function be(e) {
|
|
275
|
+
return O("legacy-team-roster-v1", e.map((e) => ({
|
|
260
276
|
deviceId: e.deviceId,
|
|
261
277
|
fingerprint: e.fingerprint,
|
|
262
278
|
enabled: e.enabled,
|
|
263
279
|
identityId: e.identityId
|
|
264
|
-
})).toSorted((e, t) =>
|
|
280
|
+
})).toSorted((e, t) => E(e.deviceId, t.deviceId)));
|
|
265
281
|
}
|
|
266
282
|
//#endregion
|
|
267
283
|
//#region src/coordinator-legacy-team-completion.ts
|
|
268
|
-
var
|
|
269
|
-
code =
|
|
284
|
+
var xe = 1, Se = 50, Ce = 500, we = 15e5, Te = 25 * we, Ee = 256, De = 37661024, Oe = "completion_conflict", ke = class extends Error {
|
|
285
|
+
code = Oe;
|
|
270
286
|
constructor() {
|
|
271
|
-
super(
|
|
287
|
+
super(Oe), this.name = "CoordinatorLegacyTeamCompletionConflictError";
|
|
272
288
|
}
|
|
273
289
|
};
|
|
274
290
|
function k() {
|
|
@@ -281,41 +297,41 @@ function j(e, t) {
|
|
|
281
297
|
let n = new Set(t);
|
|
282
298
|
Object.keys(e).some((e) => !n.has(e)) && k();
|
|
283
299
|
}
|
|
284
|
-
function
|
|
300
|
+
function Ae(e) {
|
|
285
301
|
return /^(?:[\\/]{2}|\.{1,2}[\\/]|\/|~[\\/]|[a-z]:[\\/]|file:)/iu.test(e);
|
|
286
302
|
}
|
|
287
303
|
function M(e) {
|
|
288
|
-
return (typeof e != "string" || !e || e !== e.trim() || e.length >
|
|
304
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > Ee || /[\p{Cc}\p{Cf}]/u.test(e) || Ae(e)) && k(), e;
|
|
289
305
|
}
|
|
290
306
|
function N(e) {
|
|
291
307
|
let t = M(e);
|
|
292
308
|
return /^[a-f0-9]{64}$/u.test(t) || k(), t;
|
|
293
309
|
}
|
|
294
|
-
function
|
|
310
|
+
function je(e) {
|
|
295
311
|
typeof e != "string" && k();
|
|
296
312
|
let t = e.normalize("NFC").trim();
|
|
297
|
-
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) ||
|
|
313
|
+
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || Ae(t)) && k(), t;
|
|
298
314
|
}
|
|
299
|
-
function
|
|
315
|
+
function Me(e) {
|
|
300
316
|
(typeof e != "string" || !e) && k();
|
|
301
317
|
let t = new Date(e);
|
|
302
318
|
return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && k(), e;
|
|
303
319
|
}
|
|
304
|
-
function
|
|
320
|
+
function Ne(e, t) {
|
|
305
321
|
return (!Array.isArray(e) || e.length > t) && k(), e;
|
|
306
322
|
}
|
|
307
|
-
function
|
|
308
|
-
let n = e.toSorted((e, n) =>
|
|
323
|
+
function P(e, t) {
|
|
324
|
+
let n = e.toSorted((e, n) => E(t(e), t(n)));
|
|
309
325
|
return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && k(), n;
|
|
310
326
|
}
|
|
311
|
-
function
|
|
312
|
-
return
|
|
327
|
+
function Pe(e) {
|
|
328
|
+
return P(Ne(e, 50).map(M), (e) => e);
|
|
313
329
|
}
|
|
314
|
-
function
|
|
330
|
+
function Fe(e) {
|
|
315
331
|
let t = M(e);
|
|
316
332
|
return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || k(), t;
|
|
317
333
|
}
|
|
318
|
-
function
|
|
334
|
+
function Ie(e) {
|
|
319
335
|
let t = A(e);
|
|
320
336
|
j(t, [
|
|
321
337
|
"version",
|
|
@@ -340,13 +356,13 @@ function Pe(e) {
|
|
|
340
356
|
"policy_revision",
|
|
341
357
|
"device_eligibility_mode"
|
|
342
358
|
]), n.device_eligibility_mode !== "reviewed_allowlist" && k();
|
|
343
|
-
let r = M(t.team_id), i =
|
|
359
|
+
let r = M(t.team_id), i = P(Ne(t.memberships, 500).map((e) => {
|
|
344
360
|
let t = A(e);
|
|
345
361
|
return j(t, ["identity_id", "role"]), t.role !== "member" && k(), {
|
|
346
362
|
identity_id: M(t.identity_id),
|
|
347
363
|
role: "member"
|
|
348
364
|
};
|
|
349
|
-
}), (e) => e.identity_id), a =
|
|
365
|
+
}), (e) => e.identity_id), a = P(Ne(t.device_decisions, 500).map((e) => {
|
|
350
366
|
let t = A(e);
|
|
351
367
|
j(t, [
|
|
352
368
|
"device_id",
|
|
@@ -369,7 +385,7 @@ function Pe(e) {
|
|
|
369
385
|
a.length === 0 && k();
|
|
370
386
|
let o = new Set(i.map((e) => e.identity_id)), s = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
|
|
371
387
|
(o.size !== s.size || [...s].some((e) => !o.has(e))) && k();
|
|
372
|
-
let c =
|
|
388
|
+
let c = P(Ne(t.project_mappings, 500).map((e) => {
|
|
373
389
|
let t = A(e);
|
|
374
390
|
j(t, [
|
|
375
391
|
"project_ref",
|
|
@@ -387,7 +403,7 @@ function Pe(e) {
|
|
|
387
403
|
let t = l.get(e.resolved_project_ref);
|
|
388
404
|
t && t !== e.scope_id && k(), l.set(e.resolved_project_ref, e.scope_id);
|
|
389
405
|
}
|
|
390
|
-
let u =
|
|
406
|
+
let u = P(Ne(t.project_recipients, 500).map((e) => {
|
|
391
407
|
let t = A(e);
|
|
392
408
|
j(t, ["resolved_project_ref", "team_id"]);
|
|
393
409
|
let n = M(t.team_id);
|
|
@@ -397,12 +413,12 @@ function Pe(e) {
|
|
|
397
413
|
resolved_project_ref: i,
|
|
398
414
|
team_id: n
|
|
399
415
|
};
|
|
400
|
-
}), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(
|
|
416
|
+
}), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(E), f = u.map((e) => e.resolved_project_ref);
|
|
401
417
|
JSON.stringify(f) !== JSON.stringify(d) && k();
|
|
402
418
|
let p = {
|
|
403
419
|
version: 1,
|
|
404
420
|
coordinator_id: M(t.coordinator_id),
|
|
405
|
-
candidate_ref:
|
|
421
|
+
candidate_ref: Fe(t.candidate_ref),
|
|
406
422
|
candidate_digest: N(t.candidate_digest),
|
|
407
423
|
team_id: r,
|
|
408
424
|
team_digest: N(t.team_digest),
|
|
@@ -410,7 +426,7 @@ function Pe(e) {
|
|
|
410
426
|
finish_digest: N(t.finish_digest),
|
|
411
427
|
access_delta_digest: N(t.access_delta_digest),
|
|
412
428
|
team: {
|
|
413
|
-
display_name:
|
|
429
|
+
display_name: je(n.display_name),
|
|
414
430
|
policy_revision: N(n.policy_revision),
|
|
415
431
|
device_eligibility_mode: "reviewed_allowlist"
|
|
416
432
|
},
|
|
@@ -418,21 +434,21 @@ function Pe(e) {
|
|
|
418
434
|
device_decisions: a,
|
|
419
435
|
project_mappings: c,
|
|
420
436
|
project_recipients: u,
|
|
421
|
-
completed_at:
|
|
437
|
+
completed_at: Me(t.completed_at)
|
|
422
438
|
};
|
|
423
439
|
return new TextEncoder().encode(JSON.stringify(p)).byteLength > 15e5 && k(), p;
|
|
424
440
|
}
|
|
425
|
-
function
|
|
426
|
-
return JSON.stringify(
|
|
441
|
+
function Le(e) {
|
|
442
|
+
return JSON.stringify(Ie(e));
|
|
427
443
|
}
|
|
428
|
-
function
|
|
429
|
-
e.team_id !==
|
|
444
|
+
function Re(e) {
|
|
445
|
+
e.team_id !== ye(e.candidate_ref) && k();
|
|
430
446
|
}
|
|
431
|
-
function
|
|
432
|
-
|
|
447
|
+
function ze(e, t) {
|
|
448
|
+
he(e.coordinator_id, t) !== e.candidate_ref && k();
|
|
433
449
|
}
|
|
434
|
-
function
|
|
435
|
-
|
|
450
|
+
function Be(e, t, n) {
|
|
451
|
+
ze(e, t);
|
|
436
452
|
let r = new Set(e.project_mappings.map((e) => e.scope_id));
|
|
437
453
|
n.length !== r.size && k();
|
|
438
454
|
let i = e.coordinator_id;
|
|
@@ -441,57 +457,57 @@ function Re(e, t, n) {
|
|
|
441
457
|
}
|
|
442
458
|
//#endregion
|
|
443
459
|
//#region src/coordinator-membership-effects.ts
|
|
444
|
-
var
|
|
460
|
+
var Ve = "scope_membership_effect_conflict", He = {
|
|
445
461
|
device_not_enrolled: "device must be enrolled and enabled in the scope group.",
|
|
446
462
|
scope_group_mismatch: "membership groupId must match the scope groupId.",
|
|
447
463
|
scope_inactive: "scope is not active.",
|
|
448
464
|
scope_not_found: "scopeId must reference an existing scope."
|
|
449
|
-
},
|
|
465
|
+
}, F = class extends Error {
|
|
450
466
|
code;
|
|
451
467
|
constructor(e) {
|
|
452
|
-
super(
|
|
468
|
+
super(He[e]), this.name = "CoordinatorMembershipError", this.code = e;
|
|
453
469
|
}
|
|
454
470
|
};
|
|
455
|
-
function
|
|
471
|
+
function I(e) {
|
|
456
472
|
return e?.trim() || null;
|
|
457
473
|
}
|
|
458
|
-
function
|
|
459
|
-
let t =
|
|
474
|
+
function Ue(e) {
|
|
475
|
+
let t = I(e);
|
|
460
476
|
if (!t) throw Error("effectId is required.");
|
|
461
477
|
if (t.length > 512 || /[\p{Cc}\p{Cf}]/u.test(t)) throw Error("effectId is invalid.");
|
|
462
478
|
return t;
|
|
463
479
|
}
|
|
464
|
-
function
|
|
480
|
+
function We(e) {
|
|
465
481
|
return JSON.stringify({
|
|
466
|
-
scopeId:
|
|
467
|
-
deviceId:
|
|
468
|
-
role:
|
|
482
|
+
scopeId: I(e.scopeId),
|
|
483
|
+
deviceId: I(e.deviceId),
|
|
484
|
+
role: I(e.role),
|
|
469
485
|
membershipEpoch: e.membershipEpoch ?? null,
|
|
470
|
-
coordinatorId:
|
|
471
|
-
groupId:
|
|
472
|
-
manifestIssuerDeviceId:
|
|
473
|
-
manifestHash:
|
|
474
|
-
signedManifestJson:
|
|
475
|
-
actorType:
|
|
476
|
-
actorId:
|
|
486
|
+
coordinatorId: I(e.coordinatorId),
|
|
487
|
+
groupId: I(e.groupId),
|
|
488
|
+
manifestIssuerDeviceId: I(e.manifestIssuerDeviceId),
|
|
489
|
+
manifestHash: I(e.manifestHash),
|
|
490
|
+
signedManifestJson: I(e.signedManifestJson),
|
|
491
|
+
actorType: I(e.actorType),
|
|
492
|
+
actorId: I(e.actorId)
|
|
477
493
|
});
|
|
478
494
|
}
|
|
479
|
-
function
|
|
495
|
+
function Ge(e) {
|
|
480
496
|
return JSON.stringify({
|
|
481
|
-
scopeId:
|
|
482
|
-
deviceId:
|
|
483
|
-
groupId:
|
|
497
|
+
scopeId: I(e.scopeId),
|
|
498
|
+
deviceId: I(e.deviceId),
|
|
499
|
+
groupId: I(e.groupId),
|
|
484
500
|
membershipEpoch: e.membershipEpoch ?? null,
|
|
485
|
-
manifestHash:
|
|
486
|
-
signedManifestJson:
|
|
487
|
-
actorType:
|
|
488
|
-
actorId:
|
|
501
|
+
manifestHash: I(e.manifestHash),
|
|
502
|
+
signedManifestJson: I(e.signedManifestJson),
|
|
503
|
+
actorType: I(e.actorType),
|
|
504
|
+
actorId: I(e.actorId)
|
|
489
505
|
});
|
|
490
506
|
}
|
|
491
|
-
function
|
|
492
|
-
if (e.action !== t || e.request_json !== n) throw Error(
|
|
507
|
+
function Ke(e, t, n) {
|
|
508
|
+
if (e.action !== t || e.request_json !== n) throw Error(Ve);
|
|
493
509
|
}
|
|
494
|
-
function
|
|
510
|
+
function qe(e) {
|
|
495
511
|
if (e.action !== "grant" || e.outcome_applied !== 1 || e.role == null || e.status == null || e.membership_epoch == null || e.updated_at == null) throw Error("scope_membership_effect_receipt_invalid");
|
|
496
512
|
return {
|
|
497
513
|
scope_id: e.scope_id,
|
|
@@ -509,254 +525,254 @@ function Ge(e) {
|
|
|
509
525
|
}
|
|
510
526
|
//#endregion
|
|
511
527
|
//#region src/coordinator-store-contract.ts
|
|
512
|
-
function
|
|
528
|
+
function Je(e) {
|
|
513
529
|
let t = e.trim(), n = new Date(t);
|
|
514
530
|
if (!t || Number.isNaN(n.getTime())) throw Error("expiresAt must be a valid date.");
|
|
515
531
|
return n.toISOString();
|
|
516
532
|
}
|
|
517
|
-
var
|
|
518
|
-
function
|
|
519
|
-
return typeof e == "string" && e === e.trim() &&
|
|
533
|
+
var Ye = /^identity:[A-Za-z0-9_-]{18,24}$/u;
|
|
534
|
+
function Xe(e) {
|
|
535
|
+
return typeof e == "string" && e === e.trim() && Ye.test(e);
|
|
520
536
|
}
|
|
521
|
-
function
|
|
537
|
+
function Ze(e) {
|
|
522
538
|
return String(e.kind === "team_member" ? e.assigned_identity_id ?? "" : e.target_identity_id ?? "").trim();
|
|
523
539
|
}
|
|
524
|
-
var
|
|
525
|
-
code =
|
|
540
|
+
var Qe = "reciprocal_approval_request_changed", $e = class extends Error {
|
|
541
|
+
code = Qe;
|
|
526
542
|
constructor() {
|
|
527
|
-
super(
|
|
543
|
+
super(Qe), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
|
|
528
544
|
}
|
|
529
|
-
},
|
|
530
|
-
function
|
|
545
|
+
}, et = 120, tt = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, nt = /^(?:actor|device|identity|local):\S+$/iu, rt = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, it = /^pending[_-]\S+$/iu, at = /^[a-f0-9]{12,64}$/iu, ot = /^(?=.{1,253}$)(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.local)$/iu;
|
|
546
|
+
function L(e, t) {
|
|
531
547
|
if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
|
|
532
548
|
let n = e.replace(/\s+/gu, " ").trim();
|
|
533
549
|
if (!n) throw Error(`${t}_required`);
|
|
534
|
-
if ([...n].length >
|
|
550
|
+
if ([...n].length > et) throw Error(`${t}_too_long`);
|
|
535
551
|
return n;
|
|
536
552
|
}
|
|
537
|
-
function
|
|
553
|
+
function R(e) {
|
|
538
554
|
if (typeof e != "string") return !1;
|
|
539
555
|
let t;
|
|
540
556
|
try {
|
|
541
|
-
t =
|
|
557
|
+
t = L(e, "display_name");
|
|
542
558
|
} catch {
|
|
543
559
|
return !1;
|
|
544
560
|
}
|
|
545
561
|
return ![
|
|
546
|
-
$e,
|
|
547
|
-
et,
|
|
548
562
|
tt,
|
|
549
563
|
nt,
|
|
550
|
-
rt
|
|
564
|
+
rt,
|
|
565
|
+
it,
|
|
566
|
+
at
|
|
551
567
|
].some((e) => e.test(t));
|
|
552
568
|
}
|
|
553
|
-
function
|
|
554
|
-
let n =
|
|
555
|
-
if (!
|
|
569
|
+
function z(e, t) {
|
|
570
|
+
let n = L(e, t);
|
|
571
|
+
if (!R(n)) throw Error(`${t}_invalid`);
|
|
556
572
|
return n;
|
|
557
573
|
}
|
|
558
|
-
function
|
|
559
|
-
let n =
|
|
560
|
-
if (!
|
|
574
|
+
function st(e, t) {
|
|
575
|
+
let n = L(e, t);
|
|
576
|
+
if (!ot.test(n) && !R(n)) throw Error(`${t}_invalid`);
|
|
561
577
|
return n;
|
|
562
578
|
}
|
|
563
|
-
function
|
|
579
|
+
function ct(e) {
|
|
564
580
|
let t = String(e ?? "").trim(), n = t.replace(/\.local$/iu, "");
|
|
565
|
-
return n ?
|
|
581
|
+
return n ? st(ot.test(t) ? n : n.replace(/[-_]+/gu, " "), "device_display_name") : null;
|
|
566
582
|
}
|
|
567
|
-
function
|
|
583
|
+
function lt(e) {
|
|
568
584
|
for (let t of [
|
|
569
585
|
e.explicitName,
|
|
570
586
|
e.osName,
|
|
571
587
|
e.coordinatorName
|
|
572
588
|
]) {
|
|
573
589
|
let e = String(t ?? "").trim(), n = e.replace(/\.local$/iu, "");
|
|
574
|
-
if (
|
|
590
|
+
if (ot.test(e)) {
|
|
575
591
|
try {
|
|
576
|
-
let t =
|
|
592
|
+
let t = ct(e);
|
|
577
593
|
if (t) return t;
|
|
578
594
|
} catch {}
|
|
579
595
|
continue;
|
|
580
596
|
}
|
|
581
|
-
if (!(!n || !
|
|
582
|
-
let e =
|
|
583
|
-
if (e &&
|
|
597
|
+
if (!(!n || !R(n))) try {
|
|
598
|
+
let e = ct(t);
|
|
599
|
+
if (e && R(e)) return e;
|
|
584
600
|
} catch {}
|
|
585
601
|
}
|
|
586
602
|
let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
|
|
587
603
|
return t ? `Codemem device ${t}` : "Codemem device";
|
|
588
604
|
}
|
|
589
|
-
function
|
|
605
|
+
function ut(e) {
|
|
590
606
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("project_summaries_invalid");
|
|
591
607
|
return e.map((e) => {
|
|
592
608
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("project_summaries_invalid");
|
|
593
609
|
let t = e;
|
|
594
610
|
if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
|
|
595
611
|
return {
|
|
596
|
-
display_name:
|
|
612
|
+
display_name: L(String(t.display_name ?? ""), "project_name"),
|
|
597
613
|
existing_memory_count: Number(t.existing_memory_count)
|
|
598
614
|
};
|
|
599
615
|
});
|
|
600
616
|
}
|
|
601
617
|
//#endregion
|
|
602
618
|
//#region src/recipient-reviewed-intent.ts
|
|
603
|
-
var
|
|
619
|
+
var dt = 1, B = class extends Error {
|
|
604
620
|
code;
|
|
605
621
|
constructor(e) {
|
|
606
622
|
super(e), this.name = "RecipientReviewedIntentError", this.code = e;
|
|
607
623
|
}
|
|
608
|
-
},
|
|
609
|
-
function
|
|
610
|
-
throw new
|
|
611
|
-
}
|
|
612
|
-
function V(e) {
|
|
613
|
-
return (!e || typeof e != "object" || Array.isArray(e)) && B(), e;
|
|
624
|
+
}, ft = /[\p{Cc}\p{Cf}]/u, pt = 100, mt = 65536;
|
|
625
|
+
function V() {
|
|
626
|
+
throw new B("recipient_reviewed_intent_invalid");
|
|
614
627
|
}
|
|
615
|
-
function H(e
|
|
616
|
-
|
|
628
|
+
function H(e) {
|
|
629
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && V(), e;
|
|
617
630
|
}
|
|
618
631
|
function U(e, t) {
|
|
619
|
-
|
|
632
|
+
Object.keys(e).some((e) => !t.includes(e)) && V();
|
|
620
633
|
}
|
|
621
|
-
function
|
|
622
|
-
(typeof e != "string" ||
|
|
634
|
+
function W(e, t) {
|
|
635
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > t || ft.test(e)) && V(), e;
|
|
636
|
+
}
|
|
637
|
+
function ht(e) {
|
|
638
|
+
(typeof e != "string" || ft.test(e)) && V();
|
|
623
639
|
let t = e.trim().replace(/\s+/gu, " ");
|
|
624
|
-
return (!t || t.length > 256) &&
|
|
640
|
+
return (!t || t.length > 256) && V(), t;
|
|
625
641
|
}
|
|
626
|
-
function
|
|
627
|
-
typeof e != "string" &&
|
|
642
|
+
function gt(e) {
|
|
643
|
+
typeof e != "string" && V();
|
|
628
644
|
try {
|
|
629
|
-
return
|
|
645
|
+
return L(e, "identity_display_name");
|
|
630
646
|
} catch {
|
|
631
|
-
return
|
|
647
|
+
return V();
|
|
632
648
|
}
|
|
633
649
|
}
|
|
634
|
-
function
|
|
635
|
-
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) &&
|
|
650
|
+
function _t(e) {
|
|
651
|
+
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && V(), e;
|
|
636
652
|
}
|
|
637
|
-
function
|
|
653
|
+
function vt(e, t) {
|
|
638
654
|
return e < t ? -1 : +(e > t);
|
|
639
655
|
}
|
|
640
|
-
function
|
|
656
|
+
function yt(e) {
|
|
641
657
|
return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
|
|
642
658
|
}
|
|
643
|
-
function
|
|
644
|
-
let t =
|
|
645
|
-
return t.kind === "direct" ? (
|
|
659
|
+
function bt(e) {
|
|
660
|
+
let t = H(e);
|
|
661
|
+
return t.kind === "direct" ? (U(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && V(), U(t, [
|
|
646
662
|
"kind",
|
|
647
663
|
"teamId",
|
|
648
664
|
"displayName"
|
|
649
665
|
]), {
|
|
650
666
|
kind: "team",
|
|
651
|
-
teamId:
|
|
652
|
-
displayName:
|
|
667
|
+
teamId: W(t.teamId, 256),
|
|
668
|
+
displayName: ht(t.displayName)
|
|
653
669
|
});
|
|
654
670
|
}
|
|
655
|
-
function
|
|
656
|
-
let t =
|
|
657
|
-
|
|
671
|
+
function xt(e) {
|
|
672
|
+
let t = H(e);
|
|
673
|
+
U(t, [
|
|
658
674
|
"canonicalProjectIdentity",
|
|
659
675
|
"displayName",
|
|
660
676
|
"existingMemoryCount",
|
|
661
677
|
"futureMemoriesShared",
|
|
662
678
|
"sources"
|
|
663
|
-
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) &&
|
|
664
|
-
let n = t.sources.map(
|
|
665
|
-
return new Set(n.map(
|
|
666
|
-
canonicalProjectIdentity:
|
|
667
|
-
displayName:
|
|
668
|
-
existingMemoryCount:
|
|
679
|
+
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && V();
|
|
680
|
+
let n = t.sources.map(bt).toSorted((e, t) => vt(yt(e), yt(t)));
|
|
681
|
+
return new Set(n.map(yt)).size !== n.length && V(), {
|
|
682
|
+
canonicalProjectIdentity: W(t.canonicalProjectIdentity, 512),
|
|
683
|
+
displayName: ht(t.displayName),
|
|
684
|
+
existingMemoryCount: _t(t.existingMemoryCount),
|
|
669
685
|
futureMemoriesShared: !0,
|
|
670
686
|
sources: n
|
|
671
687
|
};
|
|
672
688
|
}
|
|
673
|
-
function
|
|
674
|
-
let t =
|
|
675
|
-
return
|
|
689
|
+
function St(e) {
|
|
690
|
+
let t = H(e);
|
|
691
|
+
return U(t, [
|
|
676
692
|
"canonicalProjectIdentity",
|
|
677
693
|
"displayName",
|
|
678
694
|
"existingMemoryCount"
|
|
679
695
|
]), {
|
|
680
|
-
canonicalProjectIdentity:
|
|
681
|
-
displayName:
|
|
682
|
-
existingMemoryCount:
|
|
696
|
+
canonicalProjectIdentity: W(t.canonicalProjectIdentity, 512),
|
|
697
|
+
displayName: ht(t.displayName),
|
|
698
|
+
existingMemoryCount: _t(t.existingMemoryCount)
|
|
683
699
|
};
|
|
684
700
|
}
|
|
685
|
-
function
|
|
686
|
-
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length >
|
|
687
|
-
let t = e.projects.map(
|
|
688
|
-
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) &&
|
|
701
|
+
function Ct(e) {
|
|
702
|
+
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > pt) && V();
|
|
703
|
+
let t = e.projects.map(xt).toSorted((e, t) => vt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(St).toSorted((e, t) => vt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
|
|
704
|
+
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && V(), {
|
|
689
705
|
projects: t,
|
|
690
706
|
excludedProjects: n
|
|
691
707
|
};
|
|
692
708
|
}
|
|
693
|
-
function
|
|
694
|
-
if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new
|
|
709
|
+
function wt(e, t) {
|
|
710
|
+
if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new B("recipient_invite_intent_mismatch");
|
|
695
711
|
}
|
|
696
|
-
function
|
|
697
|
-
let n =
|
|
698
|
-
n.version !== 1 &&
|
|
699
|
-
let r =
|
|
712
|
+
function Tt(e, t) {
|
|
713
|
+
let n = H(e);
|
|
714
|
+
n.version !== 1 && V();
|
|
715
|
+
let r = Ct(n), i;
|
|
700
716
|
if (n.journey === "team") {
|
|
701
|
-
|
|
717
|
+
U(n, [
|
|
702
718
|
"version",
|
|
703
719
|
"journey",
|
|
704
720
|
"team",
|
|
705
721
|
"projects",
|
|
706
722
|
"excludedProjects"
|
|
707
723
|
]);
|
|
708
|
-
let e =
|
|
709
|
-
|
|
724
|
+
let e = H(n.team);
|
|
725
|
+
U(e, [
|
|
710
726
|
"teamId",
|
|
711
727
|
"displayName",
|
|
712
728
|
"futureProjectsInherit"
|
|
713
|
-
]), e.futureProjectsInherit !== !0 &&
|
|
729
|
+
]), e.futureProjectsInherit !== !0 && V(), i = {
|
|
714
730
|
version: 1,
|
|
715
731
|
journey: "team",
|
|
716
732
|
team: {
|
|
717
|
-
teamId:
|
|
718
|
-
displayName:
|
|
733
|
+
teamId: W(e.teamId, 256),
|
|
734
|
+
displayName: ht(e.displayName),
|
|
719
735
|
futureProjectsInherit: !0
|
|
720
736
|
},
|
|
721
737
|
...r
|
|
722
738
|
};
|
|
723
739
|
} else if (n.journey === "add_device") {
|
|
724
|
-
|
|
740
|
+
U(n, [
|
|
725
741
|
"version",
|
|
726
742
|
"journey",
|
|
727
743
|
"targetIdentity",
|
|
728
744
|
"projects",
|
|
729
745
|
"excludedProjects"
|
|
730
746
|
]);
|
|
731
|
-
let e =
|
|
732
|
-
|
|
747
|
+
let e = H(n.targetIdentity);
|
|
748
|
+
U(e, ["identityId", "displayName"]), i = {
|
|
733
749
|
version: 1,
|
|
734
750
|
journey: "add_device",
|
|
735
751
|
targetIdentity: {
|
|
736
|
-
identityId:
|
|
737
|
-
displayName:
|
|
752
|
+
identityId: W(e.identityId, 256),
|
|
753
|
+
displayName: gt(e.displayName)
|
|
738
754
|
},
|
|
739
755
|
...r
|
|
740
756
|
};
|
|
741
|
-
} else
|
|
742
|
-
return t &&
|
|
757
|
+
} else V();
|
|
758
|
+
return t && wt(i, t), new TextEncoder().encode(G(i)).byteLength > mt && V(), i;
|
|
743
759
|
}
|
|
744
|
-
function
|
|
745
|
-
return Array.isArray(e) ? `[${e.map(
|
|
760
|
+
function G(e) {
|
|
761
|
+
return Array.isArray(e) ? `[${e.map(G).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => vt(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${G(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
|
|
746
762
|
}
|
|
747
|
-
function
|
|
748
|
-
return
|
|
763
|
+
function Et(e, t) {
|
|
764
|
+
return G(Tt(e, t));
|
|
749
765
|
}
|
|
750
|
-
async function
|
|
751
|
-
let n =
|
|
766
|
+
async function Dt(e, t) {
|
|
767
|
+
let n = Et(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
|
|
752
768
|
return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
|
|
753
769
|
}
|
|
754
|
-
async function
|
|
755
|
-
let n =
|
|
756
|
-
if (await
|
|
770
|
+
async function K(e, t) {
|
|
771
|
+
let n = Tt(e, t.target);
|
|
772
|
+
if (await Dt(n) !== t.digest) throw new B("recipient_invite_intent_mismatch");
|
|
757
773
|
return n;
|
|
758
774
|
}
|
|
759
|
-
async function
|
|
775
|
+
async function Ot(e, t) {
|
|
760
776
|
if (!e) throw Error("recipient_invite_review_unavailable");
|
|
761
777
|
let n;
|
|
762
778
|
try {
|
|
@@ -765,21 +781,266 @@ async function Dt(e, t) {
|
|
|
765
781
|
throw Error("recipient_invite_review_unavailable");
|
|
766
782
|
}
|
|
767
783
|
try {
|
|
768
|
-
let r =
|
|
769
|
-
if (
|
|
770
|
-
return await
|
|
784
|
+
let r = Tt(n, t.target);
|
|
785
|
+
if (G(r) !== e) throw Error("recipient_invite_review_unavailable");
|
|
786
|
+
return await K(r, t);
|
|
771
787
|
} catch (e) {
|
|
772
|
-
throw e instanceof
|
|
788
|
+
throw e instanceof B && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
|
|
773
789
|
}
|
|
774
790
|
}
|
|
775
791
|
//#endregion
|
|
792
|
+
//#region src/coordinator-store-input-rules.ts
|
|
793
|
+
function kt(e) {
|
|
794
|
+
let t = e.trim();
|
|
795
|
+
if (!t) return "";
|
|
796
|
+
let n = t.includes("://") ? t : `http://${t}`;
|
|
797
|
+
try {
|
|
798
|
+
let e = new URL(n);
|
|
799
|
+
return !e.hostname || e.port && (Number(e.port) <= 0 || Number(e.port) > 65535) ? "" : e.origin + e.pathname.replace(/\/+$/, "");
|
|
800
|
+
} catch {
|
|
801
|
+
return "";
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function At(e) {
|
|
805
|
+
if (!e) return "";
|
|
806
|
+
try {
|
|
807
|
+
let t = new URL(e), n = t.hostname.toLowerCase();
|
|
808
|
+
if ((t.protocol === "http:" || t.protocol === "") && n && t.port && t.pathname === "/") return `${n}:${t.port}`;
|
|
809
|
+
} catch {}
|
|
810
|
+
return e;
|
|
811
|
+
}
|
|
812
|
+
function jt(e, t) {
|
|
813
|
+
let n = [], r = /* @__PURE__ */ new Set();
|
|
814
|
+
for (let i of [...e, ...t]) {
|
|
815
|
+
let e = kt(i), t = At(e);
|
|
816
|
+
!e || r.has(t) || (r.add(t), n.push(e));
|
|
817
|
+
}
|
|
818
|
+
return n;
|
|
819
|
+
}
|
|
820
|
+
function Mt(e) {
|
|
821
|
+
if (!e) return null;
|
|
822
|
+
let t = String(e.seedDeviceId ?? "").trim(), n = String(e.expiresAt ?? "").trim(), r = String(e.createdBy ?? "").trim() || null;
|
|
823
|
+
if (!t || !n) throw Error("bootstrapGrant.seedDeviceId and expiresAt are required.");
|
|
824
|
+
return {
|
|
825
|
+
groupId: "",
|
|
826
|
+
seedDeviceId: t,
|
|
827
|
+
workerDeviceId: "",
|
|
828
|
+
expiresAt: n,
|
|
829
|
+
createdBy: r
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function Nt(e) {
|
|
833
|
+
let t = String(e.groupId ?? "").trim(), n = String(e.seedDeviceId ?? "").trim(), r = String(e.workerDeviceId ?? "").trim(), i = String(e.expiresAt ?? "").trim(), a = String(e.createdBy ?? "").trim() || null;
|
|
834
|
+
if (!t || !n || !r || !i) throw Error("groupId, seedDeviceId, workerDeviceId, and expiresAt are required.");
|
|
835
|
+
return {
|
|
836
|
+
groupId: t,
|
|
837
|
+
seedDeviceId: n,
|
|
838
|
+
workerDeviceId: r,
|
|
839
|
+
expiresAt: i,
|
|
840
|
+
createdBy: a
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function q(e) {
|
|
844
|
+
return e?.trim() || null;
|
|
845
|
+
}
|
|
846
|
+
var Pt = /* @__PURE__ */ new Set([
|
|
847
|
+
"legacy_enrollment",
|
|
848
|
+
"project_share",
|
|
849
|
+
"team_member",
|
|
850
|
+
"add_device"
|
|
851
|
+
]);
|
|
852
|
+
function Ft(e) {
|
|
853
|
+
if (!Pt.has(e.inviteKind)) throw Error("inviteKind is invalid.");
|
|
854
|
+
if ([e.policyTeamId, e.targetIdentityId].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) throw Error("recipient invite identifier is invalid.");
|
|
855
|
+
if (e.reviewedPreviewDigest && !/^[a-f0-9]{64}$/u.test(e.reviewedPreviewDigest)) throw Error("reviewedPreviewDigest must be a SHA-256 digest.");
|
|
856
|
+
}
|
|
857
|
+
var It = {
|
|
858
|
+
project_share(e, t) {
|
|
859
|
+
if (!e) throw Error("project_share invite requires operationId.");
|
|
860
|
+
if (t.policyTeamId || t.targetIdentityId || t.reviewedPreviewDigest) throw Error("recipient invite metadata requires a recipient invite kind.");
|
|
861
|
+
},
|
|
862
|
+
legacy_enrollment(e, t) {
|
|
863
|
+
if (e) throw Error("legacy_enrollment invite cannot reference an operation.");
|
|
864
|
+
if (t.policyTeamId || t.targetIdentityId || t.reviewedPreviewDigest) throw Error("recipient invite metadata requires a recipient invite kind.");
|
|
865
|
+
},
|
|
866
|
+
team_member(e, t) {
|
|
867
|
+
if (!t.policyTeamId || !t.reviewedPreviewDigest || t.targetIdentityId || e) throw Error("team_member invite metadata is invalid.");
|
|
868
|
+
},
|
|
869
|
+
add_device(e, t) {
|
|
870
|
+
if (!t.targetIdentityId || !t.reviewedPreviewDigest || t.policyTeamId || e) throw Error("add_device invite metadata is invalid.");
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
function Lt(e, t) {
|
|
874
|
+
It[t.inviteKind](q(e.operationId), t);
|
|
875
|
+
}
|
|
876
|
+
function Rt(e) {
|
|
877
|
+
if (e.inviteKind === "team_member" && e.policyTeamId && e.reviewedPreviewDigest) return {
|
|
878
|
+
target: {
|
|
879
|
+
kind: "team_member",
|
|
880
|
+
policyTeamId: e.policyTeamId
|
|
881
|
+
},
|
|
882
|
+
digest: e.reviewedPreviewDigest
|
|
883
|
+
};
|
|
884
|
+
if (e.inviteKind === "add_device" && e.targetIdentityId && e.reviewedPreviewDigest) return {
|
|
885
|
+
target: {
|
|
886
|
+
kind: "add_device",
|
|
887
|
+
targetIdentityId: e.targetIdentityId
|
|
888
|
+
},
|
|
889
|
+
digest: e.reviewedPreviewDigest
|
|
890
|
+
};
|
|
891
|
+
throw Error("recipient invite metadata requires a recipient invite kind.");
|
|
892
|
+
}
|
|
893
|
+
async function zt(e) {
|
|
894
|
+
let t = {
|
|
895
|
+
inviteKind: e.inviteKind ?? (q(e.operationId) ? "project_share" : "legacy_enrollment"),
|
|
896
|
+
policyTeamId: q(e.policyTeamId),
|
|
897
|
+
targetIdentityId: q(e.targetIdentityId),
|
|
898
|
+
reviewedPreviewDigest: q(e.reviewedPreviewDigest)
|
|
899
|
+
};
|
|
900
|
+
if (Ft(t), Lt(e, t), e.reviewedIntent === void 0 || e.reviewedIntent === null) {
|
|
901
|
+
if (t.inviteKind === "team_member" || t.inviteKind === "add_device") throw Error("recipient_invite_review_unavailable");
|
|
902
|
+
return {
|
|
903
|
+
...t,
|
|
904
|
+
reviewedIntentJson: null
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
let n = Rt(t);
|
|
908
|
+
return await K(e.reviewedIntent, {
|
|
909
|
+
target: n.target,
|
|
910
|
+
digest: n.digest
|
|
911
|
+
}), {
|
|
912
|
+
...t,
|
|
913
|
+
reviewedIntentJson: Et(e.reviewedIntent, n.target)
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
async function Bt(e) {
|
|
917
|
+
if (e.invite_kind === "team_member") {
|
|
918
|
+
if (!e.policy_team_id || !Xe(e.assigned_identity_id) || !e.reviewed_preview_digest) throw Error("invite_invalid");
|
|
919
|
+
let t = await Ot(e.reviewed_intent_json, {
|
|
920
|
+
target: {
|
|
921
|
+
kind: "team_member",
|
|
922
|
+
policyTeamId: e.policy_team_id
|
|
923
|
+
},
|
|
924
|
+
digest: e.reviewed_preview_digest
|
|
925
|
+
});
|
|
926
|
+
return {
|
|
927
|
+
kind: "team_member",
|
|
928
|
+
invite: e,
|
|
929
|
+
policy_team_id: e.policy_team_id,
|
|
930
|
+
assigned_identity_id: e.assigned_identity_id,
|
|
931
|
+
reviewed_preview_digest: e.reviewed_preview_digest,
|
|
932
|
+
reviewed_intent: t,
|
|
933
|
+
bound: !!e.consumed_at
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
if (e.invite_kind === "add_device") {
|
|
937
|
+
if (!e.target_identity_id || !e.reviewed_preview_digest) throw Error("invite_invalid");
|
|
938
|
+
let t = await Ot(e.reviewed_intent_json, {
|
|
939
|
+
target: {
|
|
940
|
+
kind: "add_device",
|
|
941
|
+
targetIdentityId: e.target_identity_id
|
|
942
|
+
},
|
|
943
|
+
digest: e.reviewed_preview_digest
|
|
944
|
+
});
|
|
945
|
+
return {
|
|
946
|
+
kind: "add_device",
|
|
947
|
+
invite: e,
|
|
948
|
+
target_identity_id: e.target_identity_id,
|
|
949
|
+
reviewed_preview_digest: e.reviewed_preview_digest,
|
|
950
|
+
reviewed_intent: t,
|
|
951
|
+
bound: !!e.consumed_at
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
function Vt(e, t = 0) {
|
|
957
|
+
if (e == null) return t;
|
|
958
|
+
if (!Number.isFinite(e) || e < 0) throw Error("membershipEpoch must be non-negative.");
|
|
959
|
+
return Math.trunc(e);
|
|
960
|
+
}
|
|
961
|
+
function Ht(e) {
|
|
962
|
+
let t = q(e.scopeId), n = q(e.label);
|
|
963
|
+
if (!t || !n) throw Error("scopeId and label are required.");
|
|
964
|
+
return {
|
|
965
|
+
scopeId: t,
|
|
966
|
+
label: n,
|
|
967
|
+
kind: q(e.kind) ?? "user",
|
|
968
|
+
authorityType: q(e.authorityType) ?? "coordinator",
|
|
969
|
+
coordinatorId: q(e.coordinatorId),
|
|
970
|
+
groupId: q(e.groupId),
|
|
971
|
+
manifestIssuerDeviceId: q(e.manifestIssuerDeviceId),
|
|
972
|
+
membershipEpoch: Vt(e.membershipEpoch),
|
|
973
|
+
manifestHash: q(e.manifestHash),
|
|
974
|
+
status: q(e.status) ?? "active"
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
function Ut(e, t, n) {
|
|
978
|
+
if (e === void 0) return t;
|
|
979
|
+
let r = q(e);
|
|
980
|
+
if (!r) throw Error(`${n} must not be empty.`);
|
|
981
|
+
return r;
|
|
982
|
+
}
|
|
983
|
+
function Wt(e, t) {
|
|
984
|
+
return e === void 0 ? t : q(e);
|
|
985
|
+
}
|
|
986
|
+
function Gt(e, t) {
|
|
987
|
+
let n = q(e.scopeId);
|
|
988
|
+
if (!n) throw Error("scopeId is required.");
|
|
989
|
+
let r = e.membershipEpoch == null ? null : Vt(e.membershipEpoch);
|
|
990
|
+
if (r != null && r < t.membership_epoch) throw Error("membershipEpoch must not move backwards.");
|
|
991
|
+
return {
|
|
992
|
+
scopeId: n,
|
|
993
|
+
label: Ut(e.label, t.label, "label"),
|
|
994
|
+
kind: Ut(e.kind, t.kind, "kind"),
|
|
995
|
+
authorityType: Ut(e.authorityType, t.authority_type, "authorityType"),
|
|
996
|
+
coordinatorId: Wt(e.coordinatorId, t.coordinator_id),
|
|
997
|
+
groupId: Wt(e.groupId, t.group_id),
|
|
998
|
+
manifestIssuerDeviceId: Wt(e.manifestIssuerDeviceId, t.manifest_issuer_device_id),
|
|
999
|
+
membershipEpoch: r ?? t.membership_epoch,
|
|
1000
|
+
manifestHash: Wt(e.manifestHash, t.manifest_hash),
|
|
1001
|
+
status: Ut(e.status, t.status, "status")
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
function Kt(e, t, n) {
|
|
1005
|
+
let r = q(e.scopeId), i = q(e.deviceId);
|
|
1006
|
+
if (!r || !i) throw Error("scopeId and deviceId are required.");
|
|
1007
|
+
qt(e, t);
|
|
1008
|
+
let a = Jt(e, t, n);
|
|
1009
|
+
return {
|
|
1010
|
+
scopeId: r,
|
|
1011
|
+
deviceId: i,
|
|
1012
|
+
role: q(e.role) ?? "member",
|
|
1013
|
+
membershipEpoch: a,
|
|
1014
|
+
coordinatorId: t?.coordinator_id ?? null,
|
|
1015
|
+
groupId: t?.group_id ?? null,
|
|
1016
|
+
manifestIssuerDeviceId: q(e.manifestIssuerDeviceId) ?? t?.manifest_issuer_device_id ?? null,
|
|
1017
|
+
manifestHash: q(e.manifestHash) ?? t?.manifest_hash ?? null,
|
|
1018
|
+
signedManifestJson: q(e.signedManifestJson),
|
|
1019
|
+
actorType: q(e.actorType),
|
|
1020
|
+
actorId: q(e.actorId)
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
function qt(e, t) {
|
|
1024
|
+
if (q(e.coordinatorId) && q(e.coordinatorId) !== t?.coordinator_id) throw Error("membership coordinatorId must match the scope coordinatorId.");
|
|
1025
|
+
if (q(e.groupId) && q(e.groupId) !== t?.group_id) throw new F("scope_group_mismatch");
|
|
1026
|
+
}
|
|
1027
|
+
function Jt(e, t, n) {
|
|
1028
|
+
let r = e.membershipEpoch == null ? null : Vt(e.membershipEpoch), i = t?.membership_epoch ?? 0;
|
|
1029
|
+
if (r != null && r < i) throw Error("membershipEpoch must not be lower than the scope membershipEpoch.");
|
|
1030
|
+
if (r != null && n && r < (n.status === "revoked" ? n.membership_epoch + 1 : n.membership_epoch)) throw Error("membershipEpoch must not move backwards.");
|
|
1031
|
+
return r ?? (n ? Math.max(i, n.membership_epoch + +(n.status === "revoked")) : i);
|
|
1032
|
+
}
|
|
1033
|
+
function Yt(e) {
|
|
1034
|
+
return e == null || !Number.isFinite(e) ? 100 : Math.max(1, Math.min(1e3, Math.trunc(e)));
|
|
1035
|
+
}
|
|
1036
|
+
//#endregion
|
|
776
1037
|
//#region src/sync-fingerprint.ts
|
|
777
|
-
function
|
|
1038
|
+
function Xt(e) {
|
|
778
1039
|
return t("sha256").update(e, "utf-8").digest("hex");
|
|
779
1040
|
}
|
|
780
1041
|
//#endregion
|
|
781
1042
|
//#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/compose.js
|
|
782
|
-
var
|
|
1043
|
+
var Zt = (e, t, n) => (r, i) => {
|
|
783
1044
|
let a = -1;
|
|
784
1045
|
return o(0);
|
|
785
1046
|
async function o(s) {
|
|
@@ -795,45 +1056,45 @@ var kt = (e, t, n) => (r, i) => {
|
|
|
795
1056
|
else r.finalized === !1 && n && (c = await n(r));
|
|
796
1057
|
return c && (r.finalized === !1 || l) && (r.res = c), r;
|
|
797
1058
|
}
|
|
798
|
-
},
|
|
799
|
-
let { all: n = !1, dot: r = !1 } = t, i = (
|
|
800
|
-
return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ?
|
|
1059
|
+
}, Qt = /* @__PURE__ */ Symbol(), $t = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), en = 32, tn = 1e4, nn = (e) => "headers" in e, rn = async (e, t = /* @__PURE__ */ Object.create(null)) => {
|
|
1060
|
+
let { all: n = !1, dot: r = !1 } = t, i = (nn(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
1061
|
+
return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? an(e, {
|
|
801
1062
|
all: n,
|
|
802
1063
|
dot: r
|
|
803
1064
|
}) : {};
|
|
804
1065
|
};
|
|
805
|
-
async function
|
|
806
|
-
if (!
|
|
807
|
-
let n =
|
|
808
|
-
|
|
1066
|
+
async function an(e, t) {
|
|
1067
|
+
if (!nn(e) && e.bodyCache.formData) return on(await e.bodyCache.formData, t);
|
|
1068
|
+
let n = nn(e) ? e.headers : e.raw.headers, r = $t(await e.arrayBuffer(), n.get("Content-Type") || "");
|
|
1069
|
+
nn(e) || (e.bodyCache.formData = r);
|
|
809
1070
|
let i = await r;
|
|
810
|
-
return i ?
|
|
1071
|
+
return i ? on(i, t) : {};
|
|
811
1072
|
}
|
|
812
|
-
function
|
|
1073
|
+
function on(e, t) {
|
|
813
1074
|
let n = /* @__PURE__ */ Object.create(null), r = { count: 0 };
|
|
814
1075
|
return e.forEach((e, r) => {
|
|
815
|
-
t.all || r.endsWith("[]") ?
|
|
1076
|
+
t.all || r.endsWith("[]") ? sn(n, r, e) : n[r] = e;
|
|
816
1077
|
}), t.dot && Object.entries(n).forEach(([e, t]) => {
|
|
817
|
-
e.includes(".") && (
|
|
1078
|
+
e.includes(".") && (cn(n, e, t, r), delete n[e]);
|
|
818
1079
|
}), n;
|
|
819
1080
|
}
|
|
820
|
-
var
|
|
1081
|
+
var sn = (e, t, n) => {
|
|
821
1082
|
e[t] === void 0 ? e[t] = t.endsWith("[]") ? [n] : n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
|
|
822
|
-
},
|
|
1083
|
+
}, cn = (e, t, n, r) => {
|
|
823
1084
|
if (/(?:^|\.)__proto__\./.test(t)) return;
|
|
824
|
-
let i = e, a = t.split(".",
|
|
825
|
-
a.length >
|
|
826
|
-
t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >=
|
|
1085
|
+
let i = e, a = t.split(".", en + 2);
|
|
1086
|
+
a.length > en + 1 && ln(), a.forEach((e, t) => {
|
|
1087
|
+
t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= tn && ln(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
|
|
827
1088
|
});
|
|
828
|
-
},
|
|
1089
|
+
}, ln = () => {
|
|
829
1090
|
throw Error("Nesting limit exceeded");
|
|
830
|
-
},
|
|
1091
|
+
}, un = (e) => {
|
|
831
1092
|
let t = e.split("/");
|
|
832
1093
|
return t[0] === "" && t.shift(), t;
|
|
833
|
-
},
|
|
834
|
-
let { groups: t, path: n } =
|
|
835
|
-
return
|
|
836
|
-
},
|
|
1094
|
+
}, dn = (e) => {
|
|
1095
|
+
let { groups: t, path: n } = fn(e);
|
|
1096
|
+
return pn(un(n), t);
|
|
1097
|
+
}, fn = (e) => {
|
|
837
1098
|
let t = [];
|
|
838
1099
|
return e = e.replace(/\{[^}]+\}/g, (e, n) => {
|
|
839
1100
|
let r = `@${n}`;
|
|
@@ -842,7 +1103,7 @@ var Rt = (e, t, n) => {
|
|
|
842
1103
|
groups: t,
|
|
843
1104
|
path: e
|
|
844
1105
|
};
|
|
845
|
-
},
|
|
1106
|
+
}, pn = (e, t) => {
|
|
846
1107
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
847
1108
|
let [r] = t[n];
|
|
848
1109
|
for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
|
|
@@ -851,12 +1112,12 @@ var Rt = (e, t, n) => {
|
|
|
851
1112
|
}
|
|
852
1113
|
}
|
|
853
1114
|
return e;
|
|
854
|
-
},
|
|
1115
|
+
}, mn = {}, hn = (e, t) => {
|
|
855
1116
|
if (e === "*") return "*";
|
|
856
1117
|
let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
857
1118
|
if (n) {
|
|
858
1119
|
let r = `${e}#${t}`;
|
|
859
|
-
return
|
|
1120
|
+
return mn[r] || (mn[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
|
|
860
1121
|
r,
|
|
861
1122
|
n[1],
|
|
862
1123
|
RegExp(`^${n[2]}(?=/${t})`)
|
|
@@ -868,10 +1129,10 @@ var Rt = (e, t, n) => {
|
|
|
868
1129
|
e,
|
|
869
1130
|
n[1],
|
|
870
1131
|
!0
|
|
871
|
-
]),
|
|
1132
|
+
]), mn[r];
|
|
872
1133
|
}
|
|
873
1134
|
return null;
|
|
874
|
-
},
|
|
1135
|
+
}, gn = (e, t) => {
|
|
875
1136
|
try {
|
|
876
1137
|
return t(e);
|
|
877
1138
|
} catch {
|
|
@@ -883,21 +1144,21 @@ var Rt = (e, t, n) => {
|
|
|
883
1144
|
}
|
|
884
1145
|
});
|
|
885
1146
|
}
|
|
886
|
-
},
|
|
1147
|
+
}, _n = (e) => gn(e, decodeURI), vn = (e) => {
|
|
887
1148
|
let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
|
|
888
1149
|
for (; r < t.length; r++) {
|
|
889
1150
|
let e = t.charCodeAt(r);
|
|
890
1151
|
if (e === 37) {
|
|
891
1152
|
let e = t.indexOf("?", r), i = t.indexOf("#", r), a = e === -1 ? i === -1 ? void 0 : i : i === -1 ? e : Math.min(e, i), o = t.slice(n, a);
|
|
892
|
-
return
|
|
1153
|
+
return _n(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
|
|
893
1154
|
}
|
|
894
1155
|
if (e === 63 || e === 35) break;
|
|
895
1156
|
}
|
|
896
1157
|
return t.slice(n, r);
|
|
897
|
-
},
|
|
898
|
-
let t =
|
|
1158
|
+
}, yn = (e) => {
|
|
1159
|
+
let t = vn(e);
|
|
899
1160
|
return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
|
|
900
|
-
},
|
|
1161
|
+
}, J = (e, t, ...n) => (n.length && (t = J(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), bn = (e) => {
|
|
901
1162
|
if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
|
|
902
1163
|
let t = e.split("/"), n = [], r = "";
|
|
903
1164
|
return t.forEach((e) => {
|
|
@@ -910,7 +1171,7 @@ var Rt = (e, t, n) => {
|
|
|
910
1171
|
} else r += "/" + e;
|
|
911
1172
|
}
|
|
912
1173
|
}), n.filter((e, t, n) => n.indexOf(e) === t);
|
|
913
|
-
},
|
|
1174
|
+
}, xn = (e) => e.indexOf("%") === -1 ? e : gn(e, En), Sn = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), xn(e)), Cn = (e, t, n) => {
|
|
914
1175
|
let r = e.indexOf("#", 8);
|
|
915
1176
|
r !== -1 && (e = e.slice(0, r));
|
|
916
1177
|
let i;
|
|
@@ -921,7 +1182,7 @@ var Rt = (e, t, n) => {
|
|
|
921
1182
|
let r = e.charCodeAt(n + t.length + 1);
|
|
922
1183
|
if (r === 61) {
|
|
923
1184
|
let r = n + t.length + 2, i = e.indexOf("&", r);
|
|
924
|
-
return
|
|
1185
|
+
return Sn(e.slice(r, i === -1 ? void 0 : i));
|
|
925
1186
|
}
|
|
926
1187
|
if (r == 38 || isNaN(r)) return "";
|
|
927
1188
|
n = e.indexOf(`&${t}`, n + 1);
|
|
@@ -935,12 +1196,12 @@ var Rt = (e, t, n) => {
|
|
|
935
1196
|
let t = e.indexOf("&", o + 1), r = e.indexOf("=", o);
|
|
936
1197
|
r > t && t !== -1 && (r = -1);
|
|
937
1198
|
let s = e.slice(o + 1, r === -1 ? t === -1 ? void 0 : t : r);
|
|
938
|
-
if (i && (s =
|
|
1199
|
+
if (i && (s = Sn(s)), o = t, s === "") continue;
|
|
939
1200
|
let c;
|
|
940
|
-
r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c =
|
|
1201
|
+
r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = Sn(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
|
|
941
1202
|
}
|
|
942
1203
|
return t ? a[t] : a;
|
|
943
|
-
},
|
|
1204
|
+
}, wn = Cn, Tn = (e, t) => Cn(e, t, !0), En = decodeURIComponent, Dn = class {
|
|
944
1205
|
raw;
|
|
945
1206
|
#e;
|
|
946
1207
|
#t;
|
|
@@ -955,13 +1216,13 @@ var Rt = (e, t, n) => {
|
|
|
955
1216
|
}
|
|
956
1217
|
#n(e) {
|
|
957
1218
|
let t = this.#t[0][this.routeIndex]?.[1][e], n = this.#i(t);
|
|
958
|
-
return n &&
|
|
1219
|
+
return n && xn(n);
|
|
959
1220
|
}
|
|
960
1221
|
#r() {
|
|
961
1222
|
let e = {}, t = Object.keys(this.#t[0][this.routeIndex]?.[1] ?? {});
|
|
962
1223
|
for (let n of t) {
|
|
963
1224
|
let t = this.#i(this.#t[0][this.routeIndex][1][n]);
|
|
964
|
-
t !== void 0 && (e[n] =
|
|
1225
|
+
t !== void 0 && (e[n] = xn(t));
|
|
965
1226
|
}
|
|
966
1227
|
return e;
|
|
967
1228
|
}
|
|
@@ -969,10 +1230,10 @@ var Rt = (e, t, n) => {
|
|
|
969
1230
|
return this.#t[1] ? this.#t[1][e] : e;
|
|
970
1231
|
}
|
|
971
1232
|
query(e) {
|
|
972
|
-
return
|
|
1233
|
+
return wn(this.url, e);
|
|
973
1234
|
}
|
|
974
1235
|
queries(e) {
|
|
975
|
-
return
|
|
1236
|
+
return Tn(this.url, e);
|
|
976
1237
|
}
|
|
977
1238
|
header(e) {
|
|
978
1239
|
if (e) return this.raw.headers.get(e) ?? void 0;
|
|
@@ -982,7 +1243,7 @@ var Rt = (e, t, n) => {
|
|
|
982
1243
|
}), t;
|
|
983
1244
|
}
|
|
984
1245
|
async parseBody(e) {
|
|
985
|
-
return
|
|
1246
|
+
return rn(this, e);
|
|
986
1247
|
}
|
|
987
1248
|
#a = (e) => {
|
|
988
1249
|
let { bodyCache: t, raw: n } = this, r = t[e];
|
|
@@ -1020,7 +1281,7 @@ var Rt = (e, t, n) => {
|
|
|
1020
1281
|
get method() {
|
|
1021
1282
|
return this.raw.method;
|
|
1022
1283
|
}
|
|
1023
|
-
get [
|
|
1284
|
+
get [Qt]() {
|
|
1024
1285
|
return this.#t;
|
|
1025
1286
|
}
|
|
1026
1287
|
get matchedRoutes() {
|
|
@@ -1029,14 +1290,14 @@ var Rt = (e, t, n) => {
|
|
|
1029
1290
|
get routePath() {
|
|
1030
1291
|
return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
|
|
1031
1292
|
}
|
|
1032
|
-
},
|
|
1293
|
+
}, On = {
|
|
1033
1294
|
Stringify: 1,
|
|
1034
1295
|
BeforeStream: 2,
|
|
1035
1296
|
Stream: 3
|
|
1036
|
-
},
|
|
1297
|
+
}, kn = (e, t) => {
|
|
1037
1298
|
let n = new String(e);
|
|
1038
1299
|
return n.isEscaped = !0, n.callbacks = t, n;
|
|
1039
|
-
},
|
|
1300
|
+
}, An = async (e, t, n, r, i) => {
|
|
1040
1301
|
typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
|
|
1041
1302
|
let a = e.callbacks;
|
|
1042
1303
|
if (!a?.length) return Promise.resolve(e);
|
|
@@ -1045,12 +1306,12 @@ var Rt = (e, t, n) => {
|
|
|
1045
1306
|
phase: t,
|
|
1046
1307
|
buffer: i,
|
|
1047
1308
|
context: r
|
|
1048
|
-
}))).then((e) => Promise.all(e.filter(Boolean).map((e) =>
|
|
1049
|
-
return n ?
|
|
1050
|
-
},
|
|
1309
|
+
}))).then((e) => Promise.all(e.filter(Boolean).map((e) => An(e, t, !1, r, i))).then(() => i[0]));
|
|
1310
|
+
return n ? kn(await o, a) : o;
|
|
1311
|
+
}, jn = "text/plain; charset=UTF-8", Mn = (e, t) => ({
|
|
1051
1312
|
"Content-Type": e,
|
|
1052
1313
|
...t
|
|
1053
|
-
}),
|
|
1314
|
+
}), Nn = (e, t) => new Response(e, t), Pn = class {
|
|
1054
1315
|
#e;
|
|
1055
1316
|
#t;
|
|
1056
1317
|
env = {};
|
|
@@ -1070,7 +1331,7 @@ var Rt = (e, t, n) => {
|
|
|
1070
1331
|
this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
|
|
1071
1332
|
}
|
|
1072
1333
|
get req() {
|
|
1073
|
-
return this.#t ??= new
|
|
1334
|
+
return this.#t ??= new Dn(this.#e, this.#d, this.#u), this.#t;
|
|
1074
1335
|
}
|
|
1075
1336
|
get event() {
|
|
1076
1337
|
if (this.#i && "respondWith" in this.#i) return this.#i;
|
|
@@ -1081,11 +1342,11 @@ var Rt = (e, t, n) => {
|
|
|
1081
1342
|
throw Error("This context has no ExecutionContext");
|
|
1082
1343
|
}
|
|
1083
1344
|
get res() {
|
|
1084
|
-
return this.#a ||=
|
|
1345
|
+
return this.#a ||= Nn(null, { headers: this.#l ??= new Headers() });
|
|
1085
1346
|
}
|
|
1086
1347
|
set res(e) {
|
|
1087
1348
|
if (this.#a && e) {
|
|
1088
|
-
e =
|
|
1349
|
+
e = Nn(e.body, e);
|
|
1089
1350
|
for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") {
|
|
1090
1351
|
if (t === "set-cookie") {
|
|
1091
1352
|
let t = this.#a.headers.getSetCookie();
|
|
@@ -1103,7 +1364,7 @@ var Rt = (e, t, n) => {
|
|
|
1103
1364
|
this.#s = e;
|
|
1104
1365
|
};
|
|
1105
1366
|
header = (e, t, n) => {
|
|
1106
|
-
this.finalized && (this.#a =
|
|
1367
|
+
this.finalized && (this.#a = Nn(this.#a.body, this.#a));
|
|
1107
1368
|
let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
|
|
1108
1369
|
t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
|
|
1109
1370
|
};
|
|
@@ -1140,25 +1401,25 @@ var Rt = (e, t, n) => {
|
|
|
1140
1401
|
}
|
|
1141
1402
|
}
|
|
1142
1403
|
}
|
|
1143
|
-
return
|
|
1404
|
+
return Nn(e, {
|
|
1144
1405
|
status: typeof t == "number" ? t : t?.status ?? this.#r,
|
|
1145
1406
|
headers: r ?? n
|
|
1146
1407
|
});
|
|
1147
1408
|
}
|
|
1148
1409
|
newResponse = (...e) => this.#f(...e);
|
|
1149
1410
|
body = (e, t, n) => this.#f(e, t, n);
|
|
1150
|
-
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t,
|
|
1151
|
-
json = (e, t, n) => this.#f(JSON.stringify(e), t,
|
|
1411
|
+
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Mn(jn, n));
|
|
1412
|
+
json = (e, t, n) => this.#f(JSON.stringify(e), t, Mn("application/json", n));
|
|
1152
1413
|
html = (e, t, n) => {
|
|
1153
|
-
let r = (e) => this.#f(e, t,
|
|
1154
|
-
return typeof e == "object" ?
|
|
1414
|
+
let r = (e) => this.#f(e, t, Mn("text/html; charset=UTF-8", n));
|
|
1415
|
+
return typeof e == "object" ? An(e, On.Stringify, !1, {}).then(r) : r(e);
|
|
1155
1416
|
};
|
|
1156
1417
|
redirect = (e, t) => {
|
|
1157
1418
|
let n = String(e);
|
|
1158
1419
|
return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
|
|
1159
1420
|
};
|
|
1160
|
-
notFound = () => (this.#c ??= () =>
|
|
1161
|
-
},
|
|
1421
|
+
notFound = () => (this.#c ??= () => Nn(), this.#c(this));
|
|
1422
|
+
}, Fn = [
|
|
1162
1423
|
"get",
|
|
1163
1424
|
"post",
|
|
1164
1425
|
"put",
|
|
@@ -1166,13 +1427,13 @@ var Rt = (e, t, n) => {
|
|
|
1166
1427
|
"options",
|
|
1167
1428
|
"patch",
|
|
1168
1429
|
"query"
|
|
1169
|
-
],
|
|
1430
|
+
], In = "Can not add a route since the matcher is already built.", Ln = class extends Error {}, Rn = "__COMPOSED_HANDLER", zn = (e) => e.text("404 Not Found", 404), Bn = (e, t) => {
|
|
1170
1431
|
if ("getResponse" in e) {
|
|
1171
1432
|
let n = e.getResponse();
|
|
1172
1433
|
return t.newResponse(n.body, n);
|
|
1173
1434
|
}
|
|
1174
1435
|
return console.error(e), t.text("Internal Server Error", 500);
|
|
1175
|
-
},
|
|
1436
|
+
}, Vn = class e {
|
|
1176
1437
|
get;
|
|
1177
1438
|
post;
|
|
1178
1439
|
put;
|
|
@@ -1189,7 +1450,7 @@ var Rt = (e, t, n) => {
|
|
|
1189
1450
|
#e = "/";
|
|
1190
1451
|
routes = [];
|
|
1191
1452
|
constructor(e = {}) {
|
|
1192
|
-
[...
|
|
1453
|
+
[...Fn, "all"].forEach((e) => {
|
|
1193
1454
|
this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
|
|
1194
1455
|
this.#r(e, this.#e, t);
|
|
1195
1456
|
}), this);
|
|
@@ -1205,7 +1466,7 @@ var Rt = (e, t, n) => {
|
|
|
1205
1466
|
this.#r("ALL", this.#e, e);
|
|
1206
1467
|
}), this);
|
|
1207
1468
|
let { strict: t, ...n } = e;
|
|
1208
|
-
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ??
|
|
1469
|
+
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? vn : yn;
|
|
1209
1470
|
}
|
|
1210
1471
|
#t() {
|
|
1211
1472
|
let t = new e({
|
|
@@ -1214,18 +1475,18 @@ var Rt = (e, t, n) => {
|
|
|
1214
1475
|
});
|
|
1215
1476
|
return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
|
|
1216
1477
|
}
|
|
1217
|
-
#n =
|
|
1218
|
-
errorHandler =
|
|
1478
|
+
#n = zn;
|
|
1479
|
+
errorHandler = Bn;
|
|
1219
1480
|
route(e, t) {
|
|
1220
1481
|
let n = this.basePath(e);
|
|
1221
1482
|
return t.routes.map((e) => {
|
|
1222
1483
|
let r;
|
|
1223
|
-
t.errorHandler ===
|
|
1484
|
+
t.errorHandler === Bn ? r = e.handler : (r = async (n, r) => (await Zt([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Rn] = e.handler), n.#r(e.method, e.path, r, e.basePath);
|
|
1224
1485
|
}), this;
|
|
1225
1486
|
}
|
|
1226
1487
|
basePath(e) {
|
|
1227
1488
|
let t = this.#t();
|
|
1228
|
-
return t._basePath =
|
|
1489
|
+
return t._basePath = J(this._basePath, e), t;
|
|
1229
1490
|
}
|
|
1230
1491
|
onError = (e) => (this.errorHandler = e, this);
|
|
1231
1492
|
notFound = (e) => (this.#n = e, this);
|
|
@@ -1243,21 +1504,21 @@ var Rt = (e, t, n) => {
|
|
|
1243
1504
|
return [e.env, t];
|
|
1244
1505
|
};
|
|
1245
1506
|
return r ||= (() => {
|
|
1246
|
-
let t =
|
|
1507
|
+
let t = J(this._basePath, e), n = t === "/" ? 0 : t.length;
|
|
1247
1508
|
return (e) => {
|
|
1248
1509
|
let t = new URL(e.url);
|
|
1249
1510
|
return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
|
|
1250
1511
|
};
|
|
1251
|
-
})(), this.#r("ALL",
|
|
1512
|
+
})(), this.#r("ALL", J(e, "*"), async (e, n) => {
|
|
1252
1513
|
let i = await t(r(e.req.raw), ...a(e));
|
|
1253
1514
|
if (i) return i;
|
|
1254
1515
|
await n();
|
|
1255
1516
|
}), this;
|
|
1256
1517
|
}
|
|
1257
1518
|
#r(e, t, n, r) {
|
|
1258
|
-
e = e.toUpperCase(), t =
|
|
1519
|
+
e = e.toUpperCase(), t = J(this._basePath, t);
|
|
1259
1520
|
let i = {
|
|
1260
|
-
basePath: r === void 0 ? this._basePath :
|
|
1521
|
+
basePath: r === void 0 ? this._basePath : J(this._basePath, r),
|
|
1261
1522
|
path: t,
|
|
1262
1523
|
method: e,
|
|
1263
1524
|
handler: n
|
|
@@ -1270,7 +1531,7 @@ var Rt = (e, t, n) => {
|
|
|
1270
1531
|
}
|
|
1271
1532
|
#a(e, t, n, r) {
|
|
1272
1533
|
if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
|
|
1273
|
-
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new
|
|
1534
|
+
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new Pn(e, {
|
|
1274
1535
|
path: i,
|
|
1275
1536
|
matchResult: a,
|
|
1276
1537
|
env: n,
|
|
@@ -1288,7 +1549,7 @@ var Rt = (e, t, n) => {
|
|
|
1288
1549
|
}
|
|
1289
1550
|
return e instanceof Promise ? e.then((e) => e || (o.finalized ? o.res : this.#n(o))).catch((e) => this.#i(e, o)) : e ?? this.#n(o);
|
|
1290
1551
|
}
|
|
1291
|
-
let s =
|
|
1552
|
+
let s = Zt(a[0], this.errorHandler, this.#n);
|
|
1292
1553
|
return (async () => {
|
|
1293
1554
|
try {
|
|
1294
1555
|
let e = await s(o);
|
|
@@ -1300,19 +1561,19 @@ var Rt = (e, t, n) => {
|
|
|
1300
1561
|
})();
|
|
1301
1562
|
}
|
|
1302
1563
|
fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
|
|
1303
|
-
request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${
|
|
1564
|
+
request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${J("/", e)}`, t), n, r));
|
|
1304
1565
|
fire = () => {
|
|
1305
1566
|
addEventListener("fetch", (e) => {
|
|
1306
1567
|
e.respondWith(this.#a(e.request, e, void 0, e.request.method));
|
|
1307
1568
|
});
|
|
1308
1569
|
};
|
|
1309
|
-
},
|
|
1310
|
-
function
|
|
1570
|
+
}, Y = () => /* @__PURE__ */ Object.create(null), Hn = [];
|
|
1571
|
+
function Un(e, t) {
|
|
1311
1572
|
let n = this.buildAllMatchers(), r = ((e, t) => {
|
|
1312
1573
|
let r = n[e] || n.ALL, i = r[2][t];
|
|
1313
1574
|
if (i) return i;
|
|
1314
1575
|
let a = t.match(r[0]);
|
|
1315
|
-
if (!a) return [[],
|
|
1576
|
+
if (!a) return [[], Hn];
|
|
1316
1577
|
let o = a.indexOf("", 1);
|
|
1317
1578
|
return [r[1][o], a];
|
|
1318
1579
|
});
|
|
@@ -1320,14 +1581,14 @@ function bn(e, t) {
|
|
|
1320
1581
|
}
|
|
1321
1582
|
//#endregion
|
|
1322
1583
|
//#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
1323
|
-
var
|
|
1324
|
-
function
|
|
1584
|
+
var Wn = "[^/]+", Gn = "(?:|/.*)", Kn = /* @__PURE__ */ Symbol(), qn = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
1585
|
+
function Jn(e, t) {
|
|
1325
1586
|
return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 ? 1 : e === ".*" || e === "(?:|/.*)" ? t === "(?:|/.*)" ? -1 : 1 : t === ".*" || t === "(?:|/.*)" ? -1 : e === "[^/]+" ? 1 : t === "[^/]+" ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
|
|
1326
1587
|
}
|
|
1327
|
-
var
|
|
1588
|
+
var Yn = class e {
|
|
1328
1589
|
#e;
|
|
1329
1590
|
#t;
|
|
1330
|
-
#n =
|
|
1591
|
+
#n = Y();
|
|
1331
1592
|
insert(t, n, r, i, a) {
|
|
1332
1593
|
let o = this;
|
|
1333
1594
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
@@ -1338,43 +1599,43 @@ var Tn = class e {
|
|
|
1338
1599
|
] : [
|
|
1339
1600
|
"",
|
|
1340
1601
|
"",
|
|
1341
|
-
|
|
1602
|
+
Wn
|
|
1342
1603
|
] : null : s === "/*" ? [
|
|
1343
1604
|
"",
|
|
1344
1605
|
"",
|
|
1345
|
-
|
|
1606
|
+
Gn
|
|
1346
1607
|
] : s.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
|
|
1347
1608
|
if (c) {
|
|
1348
1609
|
let t = c[1], n = c[2] || "[^/]+";
|
|
1349
|
-
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 &&
|
|
1610
|
+
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && qn.has(n))) throw Kn;
|
|
1350
1611
|
if (l = o.#n[n], !l) {
|
|
1351
1612
|
if (n !== ".*" && n !== "(?:|/.*)") {
|
|
1352
|
-
for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw
|
|
1613
|
+
for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw Kn;
|
|
1353
1614
|
}
|
|
1354
1615
|
l = o.#n[n] = new e();
|
|
1355
1616
|
}
|
|
1356
1617
|
t !== "" && (l.#t ??= i.varIndex++, r.push([t, l.#t]));
|
|
1357
1618
|
} else if (l = o.#n[s], !l) {
|
|
1358
|
-
for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw
|
|
1619
|
+
for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw Kn;
|
|
1359
1620
|
l = o.#n[s] = new e();
|
|
1360
1621
|
}
|
|
1361
1622
|
o = l;
|
|
1362
1623
|
}
|
|
1363
|
-
if (o.#e !== void 0) throw
|
|
1624
|
+
if (o.#e !== void 0) throw Kn;
|
|
1364
1625
|
o.#e = a ? -1 : n;
|
|
1365
1626
|
}
|
|
1366
1627
|
buildRegExpStr() {
|
|
1367
|
-
let e = Object.keys(this.#n).sort(
|
|
1628
|
+
let e = Object.keys(this.#n).sort(Jn).map((e) => {
|
|
1368
1629
|
let t = this.#n[e], n = t.buildRegExpStr();
|
|
1369
|
-
return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` :
|
|
1630
|
+
return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : qn.has(e) ? `\\${e}` : e) + n;
|
|
1370
1631
|
}).filter(Boolean);
|
|
1371
1632
|
return typeof this.#e == "number" && this.#e !== -1 && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
|
|
1372
1633
|
}
|
|
1373
|
-
},
|
|
1634
|
+
}, Xn = class {
|
|
1374
1635
|
#e = { varIndex: 0 };
|
|
1375
|
-
#t = new
|
|
1636
|
+
#t = new Yn();
|
|
1376
1637
|
#n = 0;
|
|
1377
|
-
paths =
|
|
1638
|
+
paths = Y();
|
|
1378
1639
|
insert(e, t) {
|
|
1379
1640
|
if (t) {
|
|
1380
1641
|
this.#t.insert(e.split(""), 0, [], this.#e, !0);
|
|
@@ -1412,64 +1673,64 @@ var Tn = class e {
|
|
|
1412
1673
|
r
|
|
1413
1674
|
];
|
|
1414
1675
|
}
|
|
1415
|
-
},
|
|
1416
|
-
function
|
|
1417
|
-
return
|
|
1676
|
+
}, Zn = Y();
|
|
1677
|
+
function Qn(e) {
|
|
1678
|
+
return Zn[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? Gn : e === "*" ? ".*" : `/:${Wn}`)}$`);
|
|
1418
1679
|
}
|
|
1419
|
-
function
|
|
1420
|
-
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (
|
|
1680
|
+
function $n(e, t) {
|
|
1681
|
+
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (Qn(n).test(t)) return [...e[n]];
|
|
1421
1682
|
}
|
|
1422
|
-
var
|
|
1683
|
+
var er = class {
|
|
1423
1684
|
name = "RegExpRouter";
|
|
1424
1685
|
#e;
|
|
1425
1686
|
#t;
|
|
1426
1687
|
#n;
|
|
1427
1688
|
constructor() {
|
|
1428
|
-
this.#e = { ALL:
|
|
1689
|
+
this.#e = { ALL: Y() }, this.#t = { ALL: Y() }, this.#n = { ALL: new Xn() };
|
|
1429
1690
|
}
|
|
1430
1691
|
#r(e, t) {
|
|
1431
1692
|
try {
|
|
1432
1693
|
this.#n[e].insert(t, !/\*|\/:/.test(t));
|
|
1433
1694
|
} catch (e) {
|
|
1434
|
-
throw e ===
|
|
1695
|
+
throw e === Kn ? new Ln(t) : e;
|
|
1435
1696
|
}
|
|
1436
1697
|
}
|
|
1437
1698
|
add(e, t, n) {
|
|
1438
1699
|
let r = this.#e, i = this.#t;
|
|
1439
|
-
if (!r) throw Error(
|
|
1700
|
+
if (!r) throw Error(In);
|
|
1440
1701
|
if (!r[e]) {
|
|
1441
|
-
this.#n[e] = new
|
|
1702
|
+
this.#n[e] = new Xn();
|
|
1442
1703
|
for (let t of [r, i]) {
|
|
1443
|
-
t[e] =
|
|
1704
|
+
t[e] = Y();
|
|
1444
1705
|
for (let n in t.ALL) t[e][n] = [...t.ALL[n]], this.#r(e, n);
|
|
1445
1706
|
}
|
|
1446
1707
|
}
|
|
1447
1708
|
t === "/*" && (t = "*");
|
|
1448
1709
|
let a = e === "ALL" ? Object.keys(r) : [e];
|
|
1449
1710
|
if (/\*$/.test(t)) {
|
|
1450
|
-
let e =
|
|
1451
|
-
for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] =
|
|
1711
|
+
let e = Qn(t);
|
|
1712
|
+
for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = $n(r[e], t) || $n(r.ALL, t) || []);
|
|
1452
1713
|
for (let o of [r, i]) for (let r of a) for (let i in o[r]) e.test(i) && o[r][i].push([n, t]);
|
|
1453
1714
|
return;
|
|
1454
1715
|
}
|
|
1455
|
-
let o =
|
|
1456
|
-
for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] =
|
|
1716
|
+
let o = bn(t) || [t];
|
|
1717
|
+
for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = $n(r[t], e) || $n(r.ALL, e) || []), i[t][e].push([n, e]);
|
|
1457
1718
|
}
|
|
1458
|
-
match =
|
|
1719
|
+
match = Un;
|
|
1459
1720
|
buildAllMatchers() {
|
|
1460
|
-
let e =
|
|
1721
|
+
let e = Y();
|
|
1461
1722
|
for (let t of Object.keys(this.#t)) e[t] = this.#i(t);
|
|
1462
|
-
return this.#e = this.#t = this.#n = void 0,
|
|
1723
|
+
return this.#e = this.#t = this.#n = void 0, Zn = Y(), e;
|
|
1463
1724
|
}
|
|
1464
1725
|
#i(e) {
|
|
1465
|
-
let t = this.#e[e], n = this.#t[e], r = this.#n[e], i =
|
|
1726
|
+
let t = this.#e[e], n = this.#t[e], r = this.#n[e], i = Y(), a = [], [o, s, c] = r.buildRegExp();
|
|
1466
1727
|
for (let e of [t, n]) for (let t in e) {
|
|
1467
1728
|
let n = e[t], o = r.paths[t];
|
|
1468
1729
|
if (!o) {
|
|
1469
|
-
i[t] = [n.map(([e]) => [e,
|
|
1730
|
+
i[t] = [n.map(([e]) => [e, Y()]), Hn];
|
|
1470
1731
|
continue;
|
|
1471
1732
|
}
|
|
1472
|
-
a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e),
|
|
1733
|
+
a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e), Y())]);
|
|
1473
1734
|
}
|
|
1474
1735
|
return [
|
|
1475
1736
|
o,
|
|
@@ -1477,7 +1738,7 @@ var An = class {
|
|
|
1477
1738
|
i
|
|
1478
1739
|
];
|
|
1479
1740
|
}
|
|
1480
|
-
},
|
|
1741
|
+
}, tr = class {
|
|
1481
1742
|
name = "SmartRouter";
|
|
1482
1743
|
#e = [];
|
|
1483
1744
|
#t = [];
|
|
@@ -1485,7 +1746,7 @@ var An = class {
|
|
|
1485
1746
|
this.#e = e.routers;
|
|
1486
1747
|
}
|
|
1487
1748
|
add(e, t, n) {
|
|
1488
|
-
if (!this.#t) throw Error(
|
|
1749
|
+
if (!this.#t) throw Error(In);
|
|
1489
1750
|
this.#t.push([
|
|
1490
1751
|
e,
|
|
1491
1752
|
t,
|
|
@@ -1501,7 +1762,7 @@ var An = class {
|
|
|
1501
1762
|
for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
|
|
1502
1763
|
o = i.match(e, t);
|
|
1503
1764
|
} catch (e) {
|
|
1504
|
-
if (e instanceof
|
|
1765
|
+
if (e instanceof Ln) continue;
|
|
1505
1766
|
throw e;
|
|
1506
1767
|
}
|
|
1507
1768
|
this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
|
|
@@ -1514,29 +1775,29 @@ var An = class {
|
|
|
1514
1775
|
if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
|
|
1515
1776
|
return this.#e[0];
|
|
1516
1777
|
}
|
|
1517
|
-
},
|
|
1778
|
+
}, nr = Y(), rr = 0, ir = class e {
|
|
1518
1779
|
#e = [];
|
|
1519
|
-
#t =
|
|
1780
|
+
#t = Y();
|
|
1520
1781
|
#n = [];
|
|
1521
1782
|
#r;
|
|
1522
|
-
#i =
|
|
1783
|
+
#i = nr;
|
|
1523
1784
|
insert(t, n, r) {
|
|
1524
|
-
let i = this, a =
|
|
1785
|
+
let i = this, a = dn(n), o = /* @__PURE__ */ new Set(), s = 0;
|
|
1525
1786
|
for (let t of a) {
|
|
1526
|
-
let n = a[++s], r =
|
|
1787
|
+
let n = a[++s], r = hn(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
|
|
1527
1788
|
r && !u.#r && (u.#r = r, i.#n.push(u)), i = u, c && o.add(r[1]);
|
|
1528
1789
|
}
|
|
1529
1790
|
i.#e.push({ [t]: {
|
|
1530
1791
|
handler: r,
|
|
1531
1792
|
possibleKeys: [...o],
|
|
1532
|
-
score: ++
|
|
1793
|
+
score: ++rr
|
|
1533
1794
|
} });
|
|
1534
1795
|
}
|
|
1535
1796
|
#a(e, t, n, r, i) {
|
|
1536
1797
|
for (let a = 0, o = t.#e.length; a < o; a++) {
|
|
1537
1798
|
let o = t.#e[a], s = o[n] || o.ALL;
|
|
1538
1799
|
if (s) {
|
|
1539
|
-
s.params =
|
|
1800
|
+
s.params = Y(), e.push(s);
|
|
1540
1801
|
for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
|
|
1541
1802
|
let t = s.possibleKeys[e];
|
|
1542
1803
|
s.params[t] = i?.[t] && !e ? i[t] : r[t] ?? i?.[t];
|
|
@@ -1546,15 +1807,15 @@ var An = class {
|
|
|
1546
1807
|
}
|
|
1547
1808
|
search(e, t) {
|
|
1548
1809
|
let n = [];
|
|
1549
|
-
this.#i =
|
|
1550
|
-
let r = [this], i =
|
|
1810
|
+
this.#i = nr;
|
|
1811
|
+
let r = [this], i = un(t), a = [], o = i.length, s = null;
|
|
1551
1812
|
for (let c = 0; c < o; c++) {
|
|
1552
1813
|
let l = i[c], u = c === o - 1, d = [];
|
|
1553
1814
|
for (let f = 0, p = r.length; f < p; f++) {
|
|
1554
1815
|
let p = r[f], m = p.#t[l];
|
|
1555
1816
|
m && (m.#i = p.#i, u ? (m.#t["*"] && this.#a(n, m.#t["*"], e, p.#i), this.#a(n, m, e, p.#i)) : d.push(m));
|
|
1556
1817
|
for (let r of p.#n) {
|
|
1557
|
-
let f = r.#r, m = p.#i ===
|
|
1818
|
+
let f = r.#r, m = p.#i === nr ? {} : { ...p.#i };
|
|
1558
1819
|
if (typeof f == "string") {
|
|
1559
1820
|
(f === "*" || l.startsWith(f.slice(0, -1))) && (this.#a(n, r, e, p.#i), f === "*" && (r.#i = m, d.push(r)));
|
|
1560
1821
|
continue;
|
|
@@ -1588,52 +1849,52 @@ var An = class {
|
|
|
1588
1849
|
}
|
|
1589
1850
|
return n[1] && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
|
|
1590
1851
|
}
|
|
1591
|
-
},
|
|
1852
|
+
}, ar = class {
|
|
1592
1853
|
name = "TrieRouter";
|
|
1593
|
-
#e = new
|
|
1854
|
+
#e = new ir();
|
|
1594
1855
|
add(e, t, n) {
|
|
1595
|
-
for (let r of
|
|
1856
|
+
for (let r of bn(t) || [t]) this.#e.insert(e, r, n);
|
|
1596
1857
|
}
|
|
1597
1858
|
match(e, t) {
|
|
1598
1859
|
return this.#e.search(e, t);
|
|
1599
1860
|
}
|
|
1600
|
-
},
|
|
1861
|
+
}, or = class extends Vn {
|
|
1601
1862
|
constructor(e = {}) {
|
|
1602
|
-
super(e), this.router = e.router ?? new
|
|
1863
|
+
super(e), this.router = e.router ?? new tr({ routers: [new er(), new ar()] });
|
|
1603
1864
|
}
|
|
1604
1865
|
};
|
|
1605
1866
|
//#endregion
|
|
1606
1867
|
//#region src/coordinator-invites.ts
|
|
1607
|
-
function
|
|
1868
|
+
function sr(e) {
|
|
1608
1869
|
let t = "";
|
|
1609
1870
|
for (let n of e) t += String.fromCharCode(n);
|
|
1610
1871
|
return btoa(t);
|
|
1611
1872
|
}
|
|
1612
|
-
function
|
|
1873
|
+
function cr(e) {
|
|
1613
1874
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
1614
1875
|
for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
|
|
1615
1876
|
return n;
|
|
1616
1877
|
}
|
|
1617
|
-
function
|
|
1878
|
+
function lr(e) {
|
|
1618
1879
|
return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1619
1880
|
}
|
|
1620
|
-
function
|
|
1881
|
+
function ur(e) {
|
|
1621
1882
|
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
1622
1883
|
return t + "=".repeat((4 - t.length % 4) % 4);
|
|
1623
1884
|
}
|
|
1624
|
-
function
|
|
1885
|
+
function dr(e) {
|
|
1625
1886
|
let t = JSON.stringify(e);
|
|
1626
|
-
return
|
|
1887
|
+
return lr(sr(new TextEncoder().encode(t)));
|
|
1627
1888
|
}
|
|
1628
|
-
function
|
|
1629
|
-
let t = new TextDecoder().decode(
|
|
1889
|
+
function fr(e) {
|
|
1890
|
+
let t = new TextDecoder().decode(cr(ur(e))), n = JSON.parse(t);
|
|
1630
1891
|
if (typeof n != "object" || !n) throw Error("invalid invite payload");
|
|
1631
1892
|
return n;
|
|
1632
1893
|
}
|
|
1633
|
-
function
|
|
1894
|
+
function pr(e) {
|
|
1634
1895
|
return `codemem://join?invite=${encodeURIComponent(e)}`;
|
|
1635
1896
|
}
|
|
1636
|
-
function
|
|
1897
|
+
function mr(e) {
|
|
1637
1898
|
let t = e.trim();
|
|
1638
1899
|
if (t.startsWith("codemem://")) {
|
|
1639
1900
|
let e = new URL(t).searchParams.get("invite") ?? "";
|
|
@@ -1644,41 +1905,41 @@ function Wn(e) {
|
|
|
1644
1905
|
}
|
|
1645
1906
|
//#endregion
|
|
1646
1907
|
//#region src/project-invite-acceptance.ts
|
|
1647
|
-
var
|
|
1648
|
-
code =
|
|
1649
|
-
detail =
|
|
1908
|
+
var hr = "pending_setup", gr = "project_sync_enablement_failed", _r = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", vr = class extends Error {
|
|
1909
|
+
code = gr;
|
|
1910
|
+
detail = _r;
|
|
1650
1911
|
constructor(e) {
|
|
1651
|
-
super(
|
|
1912
|
+
super(_r, e), this.name = "ProjectSyncEnablementError";
|
|
1652
1913
|
}
|
|
1653
1914
|
};
|
|
1654
|
-
function
|
|
1915
|
+
function yr(e) {
|
|
1655
1916
|
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.";
|
|
1656
1917
|
}
|
|
1657
1918
|
//#endregion
|
|
1658
1919
|
//#region src/project-share-intent.ts
|
|
1659
|
-
var
|
|
1660
|
-
function
|
|
1920
|
+
var br = "existing_and_future";
|
|
1921
|
+
function xr(e) {
|
|
1661
1922
|
return t("sha256").update(JSON.stringify(e)).digest("hex");
|
|
1662
1923
|
}
|
|
1663
|
-
function
|
|
1664
|
-
return
|
|
1924
|
+
function Sr(e) {
|
|
1925
|
+
return xr({
|
|
1665
1926
|
v: 1,
|
|
1666
|
-
historyPolicy:
|
|
1927
|
+
historyPolicy: br,
|
|
1667
1928
|
projects: e.map((e) => ({
|
|
1668
1929
|
canonicalIdentity: e.canonicalIdentity,
|
|
1669
1930
|
existingMemoryCount: e.existingMemoryCount
|
|
1670
1931
|
})).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
|
|
1671
1932
|
});
|
|
1672
1933
|
}
|
|
1673
|
-
function
|
|
1674
|
-
return
|
|
1934
|
+
function Cr(e) {
|
|
1935
|
+
return Sr(e.map((e) => ({
|
|
1675
1936
|
canonicalIdentity: e.canonical_identity,
|
|
1676
1937
|
displayName: e.display_name,
|
|
1677
1938
|
identitySource: "coordinator_acceptance",
|
|
1678
1939
|
existingMemoryCount: e.existing_memory_count
|
|
1679
1940
|
})));
|
|
1680
1941
|
}
|
|
1681
|
-
function
|
|
1942
|
+
function wr(e) {
|
|
1682
1943
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
|
|
1683
1944
|
let t = e.map((e) => {
|
|
1684
1945
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
|
|
@@ -1686,7 +1947,7 @@ function er(e) {
|
|
|
1686
1947
|
if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
|
|
1687
1948
|
let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
|
|
1688
1949
|
try {
|
|
1689
|
-
a =
|
|
1950
|
+
a = L(i, "project_name");
|
|
1690
1951
|
} catch {
|
|
1691
1952
|
throw Error("operation_intent_invalid");
|
|
1692
1953
|
}
|
|
@@ -1703,20 +1964,20 @@ function er(e) {
|
|
|
1703
1964
|
}
|
|
1704
1965
|
//#endregion
|
|
1705
1966
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
|
|
1706
|
-
function
|
|
1967
|
+
function Tr(e) {
|
|
1707
1968
|
let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
|
|
1708
1969
|
return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
|
|
1709
1970
|
}
|
|
1710
|
-
function
|
|
1711
|
-
let [e, t] =
|
|
1971
|
+
function Er() {
|
|
1972
|
+
let [e, t] = Tr();
|
|
1712
1973
|
return e * 1e3 + Math.floor(t / 1e6);
|
|
1713
1974
|
}
|
|
1714
|
-
function
|
|
1975
|
+
function Dr(e) {
|
|
1715
1976
|
return new Promise((t) => setTimeout(t, e));
|
|
1716
1977
|
}
|
|
1717
1978
|
//#endregion
|
|
1718
1979
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
|
|
1719
|
-
var
|
|
1980
|
+
var Or = class {
|
|
1720
1981
|
bucketSize;
|
|
1721
1982
|
tokensPerInterval;
|
|
1722
1983
|
interval;
|
|
@@ -1743,13 +2004,13 @@ var rr = class {
|
|
|
1743
2004
|
default: throw Error("Invalid interval " + n);
|
|
1744
2005
|
}
|
|
1745
2006
|
else this.interval = n;
|
|
1746
|
-
this.parentBucket = r, this.content = 0, this.lastDrip =
|
|
2007
|
+
this.parentBucket = r, this.content = 0, this.lastDrip = Er();
|
|
1747
2008
|
}
|
|
1748
2009
|
async removeTokens(e) {
|
|
1749
2010
|
if (this.bucketSize === 0) return Infinity;
|
|
1750
2011
|
if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
|
|
1751
2012
|
this.drip();
|
|
1752
|
-
let t = async () => (await
|
|
2013
|
+
let t = async () => (await Dr(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
|
|
1753
2014
|
if (e > this.content) return t();
|
|
1754
2015
|
if (this.parentBucket != null) {
|
|
1755
2016
|
let n = await this.parentBucket.removeTokens(e);
|
|
@@ -1765,30 +2026,30 @@ var rr = class {
|
|
|
1765
2026
|
let e = this.content;
|
|
1766
2027
|
return this.content = this.bucketSize, this.content > e;
|
|
1767
2028
|
}
|
|
1768
|
-
let e =
|
|
2029
|
+
let e = Er(), t = Math.max(e - this.lastDrip, 0);
|
|
1769
2030
|
this.lastDrip = e;
|
|
1770
2031
|
let n = t * (this.tokensPerInterval / this.interval), r = this.content;
|
|
1771
2032
|
return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
|
|
1772
2033
|
}
|
|
1773
|
-
},
|
|
2034
|
+
}, kr = class {
|
|
1774
2035
|
tokenBucket;
|
|
1775
2036
|
curIntervalStart;
|
|
1776
2037
|
tokensThisInterval;
|
|
1777
2038
|
fireImmediately;
|
|
1778
2039
|
constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
|
|
1779
|
-
this.tokenBucket = new
|
|
2040
|
+
this.tokenBucket = new Or({
|
|
1780
2041
|
bucketSize: e,
|
|
1781
2042
|
tokensPerInterval: e,
|
|
1782
2043
|
interval: t
|
|
1783
|
-
}), this.tokenBucket.content = e, this.curIntervalStart =
|
|
2044
|
+
}), this.tokenBucket.content = e, this.curIntervalStart = Er(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
|
|
1784
2045
|
}
|
|
1785
2046
|
async removeTokens(e) {
|
|
1786
2047
|
if (e > this.tokenBucket.bucketSize) throw Error(`Requested tokens ${e} exceeds maximum tokens per interval ${this.tokenBucket.bucketSize}`);
|
|
1787
|
-
let t =
|
|
2048
|
+
let t = Er();
|
|
1788
2049
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
|
|
1789
2050
|
if (this.fireImmediately) return -1;
|
|
1790
2051
|
{
|
|
1791
|
-
await
|
|
2052
|
+
await Dr(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
|
|
1792
2053
|
let n = await this.tokenBucket.removeTokens(e);
|
|
1793
2054
|
return this.tokensThisInterval += e, n;
|
|
1794
2055
|
}
|
|
@@ -1798,7 +2059,7 @@ var rr = class {
|
|
|
1798
2059
|
}
|
|
1799
2060
|
tryRemoveTokens(e) {
|
|
1800
2061
|
if (e > this.tokenBucket.bucketSize) return !1;
|
|
1801
|
-
let t =
|
|
2062
|
+
let t = Er();
|
|
1802
2063
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) return !1;
|
|
1803
2064
|
let n = this.tokenBucket.tryRemoveTokens(e);
|
|
1804
2065
|
return n && (this.tokensThisInterval += e), n;
|
|
@@ -1809,7 +2070,7 @@ var rr = class {
|
|
|
1809
2070
|
};
|
|
1810
2071
|
//#endregion
|
|
1811
2072
|
//#region src/request-rate-limit.ts
|
|
1812
|
-
function
|
|
2073
|
+
function Ar(e = {}) {
|
|
1813
2074
|
let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
|
|
1814
2075
|
function a(e) {
|
|
1815
2076
|
return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
|
|
@@ -1826,7 +2087,7 @@ function ar(e = {}) {
|
|
|
1826
2087
|
o(l);
|
|
1827
2088
|
let u = `${c}:${e}`, d = r.get(u);
|
|
1828
2089
|
return d || (d = {
|
|
1829
|
-
limiter: new
|
|
2090
|
+
limiter: new kr({
|
|
1830
2091
|
tokensPerInterval: c,
|
|
1831
2092
|
interval: t,
|
|
1832
2093
|
fireImmediately: !0
|
|
@@ -1843,8 +2104,8 @@ function ar(e = {}) {
|
|
|
1843
2104
|
}
|
|
1844
2105
|
//#endregion
|
|
1845
2106
|
//#region src/scope-membership-semantics.ts
|
|
1846
|
-
var
|
|
1847
|
-
function
|
|
2107
|
+
var jr = "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.";
|
|
2108
|
+
function Mr(e) {
|
|
1848
2109
|
let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
|
|
1849
2110
|
return t == null || n == null ? {
|
|
1850
2111
|
membership_epoch: t,
|
|
@@ -1858,19 +2119,19 @@ function sr(e) {
|
|
|
1858
2119
|
reason: t < n ? "stale_epoch" : "current"
|
|
1859
2120
|
};
|
|
1860
2121
|
}
|
|
1861
|
-
function
|
|
2122
|
+
function Nr(e) {
|
|
1862
2123
|
return {
|
|
1863
2124
|
scope_id: e.scopeId,
|
|
1864
2125
|
device_id: e.deviceId,
|
|
1865
2126
|
membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
|
|
1866
2127
|
prevents_future_sync: !0,
|
|
1867
2128
|
deletes_already_copied_data: !1,
|
|
1868
|
-
message:
|
|
2129
|
+
message: jr
|
|
1869
2130
|
};
|
|
1870
2131
|
}
|
|
1871
2132
|
//#endregion
|
|
1872
2133
|
//#region src/sync-auth-constants.ts
|
|
1873
|
-
var
|
|
2134
|
+
var Pr = 300, Fr = 65536, Ir = we + 1024, X = "X-Codemem-Coordinator-Admin", Lr = "X-Codemem-Coordinator-Admin-Actor", Rr = 120, zr = 30;
|
|
1874
2135
|
function Z(e, t) {
|
|
1875
2136
|
let n = t.adminSecret();
|
|
1876
2137
|
if (!n) return {
|
|
@@ -1889,14 +2150,14 @@ function Z(e, t) {
|
|
|
1889
2150
|
error: "missing_admin_header"
|
|
1890
2151
|
};
|
|
1891
2152
|
}
|
|
1892
|
-
function
|
|
2153
|
+
function Br(e) {
|
|
1893
2154
|
let t = new URL(e);
|
|
1894
2155
|
return t.search ? `${t.pathname}${t.search}` : t.pathname;
|
|
1895
2156
|
}
|
|
1896
|
-
async function
|
|
2157
|
+
async function Vr(e, t, n, r) {
|
|
1897
2158
|
return await e.recordNonce(t, n, r);
|
|
1898
2159
|
}
|
|
1899
|
-
async function
|
|
2160
|
+
async function Hr(e, t) {
|
|
1900
2161
|
await e.cleanupNonces(t);
|
|
1901
2162
|
}
|
|
1902
2163
|
async function Q(e, t, n, r) {
|
|
@@ -1932,7 +2193,7 @@ async function Q(e, t, n, r) {
|
|
|
1932
2193
|
try {
|
|
1933
2194
|
u = await n({
|
|
1934
2195
|
method: r.method,
|
|
1935
|
-
pathWithQuery:
|
|
2196
|
+
pathWithQuery: Br(r.url),
|
|
1936
2197
|
bodyBytes: r.body,
|
|
1937
2198
|
timestamp: o,
|
|
1938
2199
|
nonce: s,
|
|
@@ -1953,7 +2214,7 @@ async function Q(e, t, n, r) {
|
|
|
1953
2214
|
enrollment: null
|
|
1954
2215
|
};
|
|
1955
2216
|
let d = t.now();
|
|
1956
|
-
return await
|
|
2217
|
+
return await Vr(e, i, s, d) ? (await Hr(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
|
|
1957
2218
|
ok: !0,
|
|
1958
2219
|
error: "ok",
|
|
1959
2220
|
enrollment: c
|
|
@@ -1966,9 +2227,9 @@ async function Q(e, t, n, r) {
|
|
|
1966
2227
|
function $(e) {
|
|
1967
2228
|
return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
|
|
1968
2229
|
}
|
|
1969
|
-
function
|
|
2230
|
+
function Ur(e) {
|
|
1970
2231
|
if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
|
|
1971
|
-
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ??
|
|
2232
|
+
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? Ar(), o = Math.max(1, Math.trunc(i.readLimit ?? Rr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? zr)), 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 or(), d = new TextDecoder();
|
|
1972
2233
|
function f(e, t, n) {
|
|
1973
2234
|
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);
|
|
1974
2235
|
return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
|
|
@@ -1976,7 +2237,7 @@ function vr(e) {
|
|
|
1976
2237
|
retry_after_s: i.retryAfterS
|
|
1977
2238
|
}, 429));
|
|
1978
2239
|
}
|
|
1979
|
-
async function p(e, t =
|
|
2240
|
+
async function p(e, t = Fr) {
|
|
1980
2241
|
let n = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
1981
2242
|
if (Number.isFinite(n) && n > t) return null;
|
|
1982
2243
|
let r = e.req.raw.body;
|
|
@@ -2035,7 +2296,7 @@ function vr(e) {
|
|
|
2035
2296
|
}
|
|
2036
2297
|
function y(e) {
|
|
2037
2298
|
try {
|
|
2038
|
-
return
|
|
2299
|
+
return wr(JSON.parse(e ?? ""));
|
|
2039
2300
|
} catch {
|
|
2040
2301
|
throw Error("operation_intent_invalid");
|
|
2041
2302
|
}
|
|
@@ -2044,7 +2305,7 @@ function vr(e) {
|
|
|
2044
2305
|
let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
|
|
2045
2306
|
if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
|
|
2046
2307
|
let r = y(e.project_intent_json);
|
|
2047
|
-
if (
|
|
2308
|
+
if (Cr(r) !== n) throw Error("operation_intent_invalid");
|
|
2048
2309
|
return {
|
|
2049
2310
|
operation_id: t,
|
|
2050
2311
|
reviewed_project_set_digest: n,
|
|
@@ -2053,7 +2314,7 @@ function vr(e) {
|
|
|
2053
2314
|
}
|
|
2054
2315
|
function b(e) {
|
|
2055
2316
|
try {
|
|
2056
|
-
return
|
|
2317
|
+
return ut(JSON.parse(e ?? ""));
|
|
2057
2318
|
} catch {
|
|
2058
2319
|
throw Error("operation_intent_invalid");
|
|
2059
2320
|
}
|
|
@@ -2085,7 +2346,7 @@ function vr(e) {
|
|
|
2085
2346
|
response: r.json({ error: "scope_not_found" }, 404)
|
|
2086
2347
|
};
|
|
2087
2348
|
}
|
|
2088
|
-
async function
|
|
2349
|
+
async function te(e, n, i) {
|
|
2089
2350
|
let a = await Q(e, t, r, {
|
|
2090
2351
|
method: i.req.method,
|
|
2091
2352
|
url: i.req.url,
|
|
@@ -2104,7 +2365,7 @@ function vr(e) {
|
|
|
2104
2365
|
response: f(i, String(a.enrollment.device_id), !0)
|
|
2105
2366
|
};
|
|
2106
2367
|
}
|
|
2107
|
-
function
|
|
2368
|
+
function C(e, t) {
|
|
2108
2369
|
return e.status === "active" && e.membership_epoch >= t.membership_epoch;
|
|
2109
2370
|
}
|
|
2110
2371
|
return u.post("/v1/presence", async (e) => {
|
|
@@ -2180,7 +2441,7 @@ function vr(e) {
|
|
|
2180
2441
|
if (!t) return e.json({ error: "group_id_required" }, 400);
|
|
2181
2442
|
let r = n();
|
|
2182
2443
|
try {
|
|
2183
|
-
let { auth: n, response: i } = await
|
|
2444
|
+
let { auth: n, response: i } = await te(r, t, e);
|
|
2184
2445
|
if (i) return i;
|
|
2185
2446
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
2186
2447
|
let a = await r.listScopes({
|
|
@@ -2189,7 +2450,7 @@ function vr(e) {
|
|
|
2189
2450
|
}), o = await r.listDeviceScopeMemberships(String(n.enrollment.device_id), !1), s = new Map(o.map((e) => [e.scope_id, e])), c = a.filter((e) => {
|
|
2190
2451
|
if (e.status !== "active") return !1;
|
|
2191
2452
|
let t = s.get(e.scope_id);
|
|
2192
|
-
return !!(t &&
|
|
2453
|
+
return !!(t && C(t, e));
|
|
2193
2454
|
});
|
|
2194
2455
|
return e.json({ items: c });
|
|
2195
2456
|
} finally {
|
|
@@ -2201,7 +2462,7 @@ function vr(e) {
|
|
|
2201
2462
|
if (!r) return e.json({ error: "scope_id_required" }, 400);
|
|
2202
2463
|
let i = n();
|
|
2203
2464
|
try {
|
|
2204
|
-
let { auth: n, response: a } = await
|
|
2465
|
+
let { auth: n, response: a } = await te(i, t, e);
|
|
2205
2466
|
if (a) return a;
|
|
2206
2467
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
2207
2468
|
let o = (await i.listScopes({
|
|
@@ -2210,7 +2471,7 @@ function vr(e) {
|
|
|
2210
2471
|
})).find((e) => e.scope_id === r) ?? null;
|
|
2211
2472
|
if (o?.status !== "active") return e.json({ error: "scope_not_found" }, 404);
|
|
2212
2473
|
let s = await i.listScopeMemberships(r, !1);
|
|
2213
|
-
return s.some((e) => e.device_id === String(n.enrollment?.device_id) &&
|
|
2474
|
+
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);
|
|
2214
2475
|
} finally {
|
|
2215
2476
|
await i.close();
|
|
2216
2477
|
}
|
|
@@ -2279,7 +2540,7 @@ function vr(e) {
|
|
|
2279
2540
|
request: t
|
|
2280
2541
|
});
|
|
2281
2542
|
} catch (t) {
|
|
2282
|
-
if (t instanceof
|
|
2543
|
+
if (t instanceof $e) return e.json({ error: t.code }, 409);
|
|
2283
2544
|
throw t;
|
|
2284
2545
|
}
|
|
2285
2546
|
} finally {
|
|
@@ -2321,7 +2582,7 @@ function vr(e) {
|
|
|
2321
2582
|
if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
|
|
2322
2583
|
let p;
|
|
2323
2584
|
try {
|
|
2324
|
-
p = await
|
|
2585
|
+
p = await K(a.reviewed_intent, {
|
|
2325
2586
|
target: {
|
|
2326
2587
|
kind: "add_device",
|
|
2327
2588
|
targetIdentityId: d
|
|
@@ -2329,7 +2590,7 @@ function vr(e) {
|
|
|
2329
2590
|
digest: l
|
|
2330
2591
|
});
|
|
2331
2592
|
} catch (t) {
|
|
2332
|
-
return t instanceof
|
|
2593
|
+
return t instanceof B && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2333
2594
|
}
|
|
2334
2595
|
let m = await u.createInvite({
|
|
2335
2596
|
groupId: s,
|
|
@@ -2353,13 +2614,13 @@ function vr(e) {
|
|
|
2353
2614
|
target_identity_id: m.target_identity_id ?? void 0,
|
|
2354
2615
|
inviter_device_id: m.inviter_device_id ?? void 0,
|
|
2355
2616
|
reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
|
|
2356
|
-
}, g =
|
|
2617
|
+
}, g = dr(h), { token: _, ...v } = m;
|
|
2357
2618
|
return e.json({
|
|
2358
2619
|
ok: !0,
|
|
2359
2620
|
invite: v,
|
|
2360
2621
|
payload: h,
|
|
2361
2622
|
encoded: g,
|
|
2362
|
-
link:
|
|
2623
|
+
link: pr(g)
|
|
2363
2624
|
});
|
|
2364
2625
|
} finally {
|
|
2365
2626
|
await u.close();
|
|
@@ -2375,7 +2636,7 @@ function vr(e) {
|
|
|
2375
2636
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2376
2637
|
let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.fingerprint ?? "").trim(), u = String(o.public_key ?? "").trim(), d = String(o.display_name ?? "").trim() || null;
|
|
2377
2638
|
if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
|
|
2378
|
-
if (
|
|
2639
|
+
if (Xt(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
2379
2640
|
let h = n();
|
|
2380
2641
|
try {
|
|
2381
2642
|
await h.createGroup(s), await h.enrollDevice(s, {
|
|
@@ -2615,7 +2876,7 @@ function vr(e) {
|
|
|
2615
2876
|
manifestHash: h(o, "manifest_hash"),
|
|
2616
2877
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2617
2878
|
actorType: "admin",
|
|
2618
|
-
actorId: g(e.req.header(
|
|
2879
|
+
actorId: g(e.req.header(Lr))
|
|
2619
2880
|
});
|
|
2620
2881
|
return e.json({
|
|
2621
2882
|
ok: !0,
|
|
@@ -2623,9 +2884,9 @@ function vr(e) {
|
|
|
2623
2884
|
}, 201);
|
|
2624
2885
|
} catch (t) {
|
|
2625
2886
|
let n = t instanceof Error ? t.message : String(t);
|
|
2626
|
-
if (t instanceof
|
|
2627
|
-
if (t instanceof
|
|
2628
|
-
let r = t instanceof
|
|
2887
|
+
if (t instanceof F && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
|
|
2888
|
+
if (t instanceof F && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
|
|
2889
|
+
let r = t instanceof F && t.code === "scope_inactive";
|
|
2629
2890
|
return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
|
|
2630
2891
|
} finally {
|
|
2631
2892
|
await v.close();
|
|
@@ -2656,7 +2917,7 @@ function vr(e) {
|
|
|
2656
2917
|
manifestHash: h(o, "manifest_hash"),
|
|
2657
2918
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2658
2919
|
actorType: "admin",
|
|
2659
|
-
actorId: g(e.req.header(
|
|
2920
|
+
actorId: g(e.req.header(Lr))
|
|
2660
2921
|
})) return e.json({ error: "membership_not_found" }, 404);
|
|
2661
2922
|
let n;
|
|
2662
2923
|
try {
|
|
@@ -2668,7 +2929,7 @@ function vr(e) {
|
|
|
2668
2929
|
ok: !0,
|
|
2669
2930
|
scope_id: c,
|
|
2670
2931
|
device_id: l,
|
|
2671
|
-
revocation:
|
|
2932
|
+
revocation: Nr({
|
|
2672
2933
|
scopeId: c,
|
|
2673
2934
|
deviceId: l,
|
|
2674
2935
|
membershipEpoch: n?.membership_epoch ?? d
|
|
@@ -2676,7 +2937,7 @@ function vr(e) {
|
|
|
2676
2937
|
});
|
|
2677
2938
|
} catch (t) {
|
|
2678
2939
|
let n = t instanceof Error ? t.message : String(t);
|
|
2679
|
-
return t instanceof
|
|
2940
|
+
return t instanceof F && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
|
|
2680
2941
|
} finally {
|
|
2681
2942
|
await v.close();
|
|
2682
2943
|
}
|
|
@@ -2711,7 +2972,7 @@ function vr(e) {
|
|
|
2711
2972
|
if (!l) return e.json({ error: "display_name_required" }, 400);
|
|
2712
2973
|
let u;
|
|
2713
2974
|
try {
|
|
2714
|
-
u =
|
|
2975
|
+
u = z(l, "display_name");
|
|
2715
2976
|
} catch (t) {
|
|
2716
2977
|
return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
|
|
2717
2978
|
}
|
|
@@ -2782,16 +3043,16 @@ function vr(e) {
|
|
|
2782
3043
|
if (!r.ok) return f(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
2783
3044
|
let i = f(e, "admin", !0);
|
|
2784
3045
|
if (i) return i;
|
|
2785
|
-
let a = await p(e,
|
|
3046
|
+
let a = await p(e, Ir);
|
|
2786
3047
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2787
3048
|
let o = m(a);
|
|
2788
3049
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2789
3050
|
if (Object.keys(o).some((e) => e !== "group_id" && e !== "manifest")) return e.json({ error: "completion_manifest_invalid" }, 400);
|
|
2790
3051
|
let s, c;
|
|
2791
3052
|
try {
|
|
2792
|
-
let e =
|
|
3053
|
+
let e = Pe([o.group_id])[0];
|
|
2793
3054
|
if (!e) throw Error("completion_manifest_invalid");
|
|
2794
|
-
s = e, c =
|
|
3055
|
+
s = e, c = Ie(o.manifest), Re(c);
|
|
2795
3056
|
} catch {
|
|
2796
3057
|
return e.json({ error: "completion_manifest_invalid" }, 400);
|
|
2797
3058
|
}
|
|
@@ -2803,7 +3064,7 @@ function vr(e) {
|
|
|
2803
3064
|
...t
|
|
2804
3065
|
}, t.status === "created" ? 201 : 200);
|
|
2805
3066
|
} catch (t) {
|
|
2806
|
-
if (t instanceof
|
|
3067
|
+
if (t instanceof ke) return e.json({ error: t.code }, 409);
|
|
2807
3068
|
let n = t instanceof Error ? t.message : "completion_manifest_invalid";
|
|
2808
3069
|
if (n === "group_not_found") return e.json({ error: n }, 404);
|
|
2809
3070
|
if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
|
|
@@ -2819,8 +3080,8 @@ function vr(e) {
|
|
|
2819
3080
|
if (i) return i;
|
|
2820
3081
|
let a = String(e.req.query("group_id") ?? "").trim(), o;
|
|
2821
3082
|
try {
|
|
2822
|
-
if (
|
|
2823
|
-
o =
|
|
3083
|
+
if (Pe([a]).length !== 1) throw Error("completion_manifest_invalid");
|
|
3084
|
+
o = Fe(e.req.query("candidate_ref"));
|
|
2824
3085
|
} catch {
|
|
2825
3086
|
return e.json({ error: "group_id_and_candidate_ref_required" }, 400);
|
|
2826
3087
|
}
|
|
@@ -2842,7 +3103,7 @@ function vr(e) {
|
|
|
2842
3103
|
if (!o || Object.keys(o).some((e) => e !== "group_ids")) return e.json({ error: "completion_query_invalid" }, 400);
|
|
2843
3104
|
let s;
|
|
2844
3105
|
try {
|
|
2845
|
-
if (s =
|
|
3106
|
+
if (s = Pe(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
|
|
2846
3107
|
} catch {
|
|
2847
3108
|
return e.json({ error: "completion_query_invalid" }, 400);
|
|
2848
3109
|
}
|
|
@@ -2864,27 +3125,27 @@ function vr(e) {
|
|
|
2864
3125
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2865
3126
|
let o = m(a);
|
|
2866
3127
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2867
|
-
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,
|
|
3128
|
+
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;
|
|
2868
3129
|
if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
|
|
2869
3130
|
if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
|
|
2870
3131
|
if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
|
|
2871
3132
|
if (!!d != !!h) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
|
|
2872
|
-
let
|
|
3133
|
+
let T = ee || (d ? "project_share" : "legacy_enrollment");
|
|
2873
3134
|
if (![
|
|
2874
3135
|
"legacy_enrollment",
|
|
2875
3136
|
"project_share",
|
|
2876
3137
|
"team_member",
|
|
2877
3138
|
"add_device"
|
|
2878
|
-
].includes(
|
|
2879
|
-
if (
|
|
3139
|
+
].includes(T)) return e.json({ error: "invite_kind_invalid" }, 400);
|
|
3140
|
+
if (T === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
|
|
2880
3141
|
if (S && !/^[a-f0-9]{64}$/u.test(S)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
|
|
2881
|
-
if (
|
|
3142
|
+
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);
|
|
2882
3143
|
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);
|
|
2883
|
-
if (
|
|
3144
|
+
if (T === "team_member" || T === "add_device") {
|
|
2884
3145
|
if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2885
3146
|
try {
|
|
2886
|
-
|
|
2887
|
-
target:
|
|
3147
|
+
te = await K(o.reviewed_intent, {
|
|
3148
|
+
target: T === "team_member" ? {
|
|
2888
3149
|
kind: "team_member",
|
|
2889
3150
|
policyTeamId: String(b)
|
|
2890
3151
|
} : {
|
|
@@ -2894,7 +3155,7 @@ function vr(e) {
|
|
|
2894
3155
|
digest: String(S)
|
|
2895
3156
|
});
|
|
2896
3157
|
} catch (t) {
|
|
2897
|
-
return t instanceof
|
|
3158
|
+
return t instanceof B && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2898
3159
|
}
|
|
2899
3160
|
} else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
|
|
2900
3161
|
if (d && !/^share_[a-f0-9]{40}$/u.test(d) || h && !/^[a-f0-9]{64}$/u.test(h)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
|
|
@@ -2906,27 +3167,27 @@ function vr(e) {
|
|
|
2906
3167
|
y
|
|
2907
3168
|
].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
|
|
2908
3169
|
try {
|
|
2909
|
-
if (
|
|
3170
|
+
if (z(_, "inviter_display_name"), C = ut(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== C.length || (w = o.project_intent.map((e, t) => {
|
|
2910
3171
|
let n;
|
|
2911
3172
|
try {
|
|
2912
|
-
n =
|
|
3173
|
+
n = wr([e])[0];
|
|
2913
3174
|
} catch {
|
|
2914
3175
|
throw Error("project_intent_invalid");
|
|
2915
3176
|
}
|
|
2916
|
-
let r =
|
|
3177
|
+
let r = C?.[t];
|
|
2917
3178
|
if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
|
|
2918
3179
|
return n;
|
|
2919
|
-
}), new Set(
|
|
3180
|
+
}), new Set(w.map((e) => e.canonical_identity)).size !== w.length)) throw Error("project_intent_invalid");
|
|
2920
3181
|
} catch (t) {
|
|
2921
3182
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
|
|
2922
3183
|
}
|
|
2923
3184
|
}
|
|
2924
|
-
let
|
|
3185
|
+
let ne = n();
|
|
2925
3186
|
try {
|
|
2926
|
-
let t = await
|
|
3187
|
+
let t = await ne.getGroup(s);
|
|
2927
3188
|
if (!t) return e.json({ error: "group_not_found" }, 404);
|
|
2928
3189
|
if (t.archived_at) return e.json({ error: "group_archived" }, 409);
|
|
2929
|
-
let n = await
|
|
3190
|
+
let n = await ne.createInvite({
|
|
2930
3191
|
groupId: s,
|
|
2931
3192
|
policy: c,
|
|
2932
3193
|
expiresAt: l,
|
|
@@ -2937,13 +3198,13 @@ function vr(e) {
|
|
|
2937
3198
|
inviterDisplayName: _,
|
|
2938
3199
|
inviterDeviceId: v,
|
|
2939
3200
|
pendingPersonId: y,
|
|
2940
|
-
projectSummaries:
|
|
2941
|
-
projectIntent:
|
|
2942
|
-
inviteKind:
|
|
3201
|
+
projectSummaries: C,
|
|
3202
|
+
projectIntent: w,
|
|
3203
|
+
inviteKind: T,
|
|
2943
3204
|
policyTeamId: b,
|
|
2944
3205
|
targetIdentityId: x,
|
|
2945
3206
|
reviewedPreviewDigest: S,
|
|
2946
|
-
reviewedIntent:
|
|
3207
|
+
reviewedIntent: te
|
|
2947
3208
|
}), r = {
|
|
2948
3209
|
v: 1,
|
|
2949
3210
|
kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
|
|
@@ -2956,7 +3217,7 @@ function vr(e) {
|
|
|
2956
3217
|
...n.operation_id ? {
|
|
2957
3218
|
operation_id: n.operation_id,
|
|
2958
3219
|
inviter_name: n.inviter_display_name ?? null,
|
|
2959
|
-
project_summaries:
|
|
3220
|
+
project_summaries: C ?? []
|
|
2960
3221
|
} : {},
|
|
2961
3222
|
...n.invite_kind === "team_member" ? {
|
|
2962
3223
|
policy_team_id: n.policy_team_id ?? void 0,
|
|
@@ -2968,20 +3229,20 @@ function vr(e) {
|
|
|
2968
3229
|
inviter_device_id: n.inviter_device_id ?? void 0,
|
|
2969
3230
|
reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
|
|
2970
3231
|
} : {}
|
|
2971
|
-
}, i =
|
|
3232
|
+
}, i = dr(r), { token: a, ...f } = n;
|
|
2972
3233
|
return e.json({
|
|
2973
3234
|
ok: !0,
|
|
2974
3235
|
invite: f,
|
|
2975
3236
|
payload: r,
|
|
2976
3237
|
encoded: i,
|
|
2977
|
-
link:
|
|
3238
|
+
link: pr(i)
|
|
2978
3239
|
});
|
|
2979
3240
|
} catch (t) {
|
|
2980
3241
|
if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
|
|
2981
3242
|
if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
|
|
2982
3243
|
throw t;
|
|
2983
3244
|
} finally {
|
|
2984
|
-
await
|
|
3245
|
+
await ne.close();
|
|
2985
3246
|
}
|
|
2986
3247
|
}), u.post("/v1/invites/inspect", async (e) => {
|
|
2987
3248
|
let r = await p(e);
|
|
@@ -3076,7 +3337,7 @@ function vr(e) {
|
|
|
3076
3337
|
display_name: String(e.display_name ?? ""),
|
|
3077
3338
|
existing_memory_count: Number(e.existing_memory_count ?? 0)
|
|
3078
3339
|
}));
|
|
3079
|
-
s =
|
|
3340
|
+
s = pr(dr({
|
|
3080
3341
|
v: 1,
|
|
3081
3342
|
kind: "coordinator_team_invite",
|
|
3082
3343
|
coordinator_url: new URL(e.req.url).origin,
|
|
@@ -3193,11 +3454,11 @@ function vr(e) {
|
|
|
3193
3454
|
} finally {
|
|
3194
3455
|
await c.close();
|
|
3195
3456
|
}
|
|
3196
|
-
}), u.post("/v1/admin/join-requests/approve", async (e) =>
|
|
3457
|
+
}), u.post("/v1/admin/join-requests/approve", async (e) => Wr(e, !0, {
|
|
3197
3458
|
createStore: n,
|
|
3198
3459
|
runtime: t,
|
|
3199
3460
|
rateLimitedResponse: f
|
|
3200
|
-
})), u.post("/v1/admin/join-requests/deny", async (e) =>
|
|
3461
|
+
})), u.post("/v1/admin/join-requests/deny", async (e) => Wr(e, !1, {
|
|
3201
3462
|
createStore: n,
|
|
3202
3463
|
runtime: t,
|
|
3203
3464
|
rateLimitedResponse: f
|
|
@@ -3221,7 +3482,7 @@ function vr(e) {
|
|
|
3221
3482
|
if (!i) return e.json({ error: "invalid_json" }, 400);
|
|
3222
3483
|
let a = String(i.token ?? "").trim(), o = String(i.device_id ?? "").trim(), s = String(i.fingerprint ?? "").trim(), c = String(i.public_key ?? "").trim(), l = String(i.display_name ?? "").trim() || null, u = String(i.operation_id ?? "").trim(), d = String(i.recipient_actor_id ?? "").trim(), f = String(i.recipient_display_name ?? "").trim(), h = String(i.device_display_name ?? "").trim();
|
|
3223
3484
|
if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
|
|
3224
|
-
if (
|
|
3485
|
+
if (Xt(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
3225
3486
|
let g = n();
|
|
3226
3487
|
try {
|
|
3227
3488
|
let n = await g.getInviteByTokenForInspection(a);
|
|
@@ -3249,11 +3510,11 @@ function vr(e) {
|
|
|
3249
3510
|
try {
|
|
3250
3511
|
if (i.recipient_display_name != null) {
|
|
3251
3512
|
if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
|
|
3252
|
-
d =
|
|
3513
|
+
d = z(i.recipient_display_name, "recipient_display_name");
|
|
3253
3514
|
}
|
|
3254
3515
|
if (i.device_display_name != null) {
|
|
3255
3516
|
if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
|
|
3256
|
-
f =
|
|
3517
|
+
f = st(i.device_display_name, "device_display_name");
|
|
3257
3518
|
}
|
|
3258
3519
|
} catch (t) {
|
|
3259
3520
|
return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
|
|
@@ -3308,7 +3569,7 @@ function vr(e) {
|
|
|
3308
3569
|
if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
|
|
3309
3570
|
let l, p;
|
|
3310
3571
|
try {
|
|
3311
|
-
l =
|
|
3572
|
+
l = z(f, "recipient_display_name"), p = st(h, "device_display_name");
|
|
3312
3573
|
} catch (t) {
|
|
3313
3574
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
|
|
3314
3575
|
}
|
|
@@ -3332,7 +3593,7 @@ function vr(e) {
|
|
|
3332
3593
|
});
|
|
3333
3594
|
return e.json({
|
|
3334
3595
|
ok: !0,
|
|
3335
|
-
status:
|
|
3596
|
+
status: hr,
|
|
3336
3597
|
group_id: n.invite.group_id,
|
|
3337
3598
|
operation_id: n.invite.operation_id,
|
|
3338
3599
|
trust_state: n.invite.trust_state,
|
|
@@ -3401,14 +3662,14 @@ function vr(e) {
|
|
|
3401
3662
|
}
|
|
3402
3663
|
}), u;
|
|
3403
3664
|
}
|
|
3404
|
-
async function
|
|
3665
|
+
async function Wr(e, t, n) {
|
|
3405
3666
|
let r = Z(e.req.header(X), n.runtime);
|
|
3406
3667
|
if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
3407
3668
|
let i = n.rateLimitedResponse(e, "admin", !0);
|
|
3408
3669
|
if (i) return i;
|
|
3409
3670
|
let a = await (async () => {
|
|
3410
3671
|
let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
3411
|
-
if (Number.isFinite(t) && t >
|
|
3672
|
+
if (Number.isFinite(t) && t > Fr) return null;
|
|
3412
3673
|
let n = e.req.raw.body;
|
|
3413
3674
|
if (!n) return /* @__PURE__ */ new Uint8Array();
|
|
3414
3675
|
let r = n.getReader(), i = [], a = 0;
|
|
@@ -3417,7 +3678,7 @@ async function yr(e, t, n) {
|
|
|
3417
3678
|
let { done: e, value: t } = await r.read();
|
|
3418
3679
|
if (e) break;
|
|
3419
3680
|
if (t) {
|
|
3420
|
-
if (a += t.byteLength, a >
|
|
3681
|
+
if (a += t.byteLength, a > Fr) return await r.cancel(), null;
|
|
3421
3682
|
i.push(t);
|
|
3422
3683
|
}
|
|
3423
3684
|
}
|
|
@@ -3465,6 +3726,6 @@ async function yr(e, t, n) {
|
|
|
3465
3726
|
}
|
|
3466
3727
|
}
|
|
3467
3728
|
//#endregion
|
|
3468
|
-
export {
|
|
3729
|
+
export { Ue as $, Vt as A, ie as At, ct as B, Yt as C, he as Ct, Kt as D, be as Dt, Ht as E, ge as Et, Ot as F, p as Ft, Qe as G, L as H, Dt as I, C as It, Ze as J, Xe as K, K as L, w as Lt, B as M, T as Mt, Et as N, s as Nt, zt as O, O as Ot, Tt as P, o as Pt, qe as Q, lt as R, a as Rt, jt as S, pe as St, Mt as T, ve as Tt, ut as U, z as V, $e as W, Ke as X, F as Y, We as Z, mr as _, fe as _t, Mr as a, Se as at, q as b, se as bt, wr as c, ke as ct, gr as d, Pe as dt, Ge as et, _r as f, Ie as ft, dr as g, me as gt, fr as h, Re as ht, Nr as i, we as it, dt as j, re as jt, Gt as k, ne as kt, Sr as l, Le as lt, yr as m, Be as mt, Pr as n, Te as nt, br as o, Ce as ot, vr as p, ze as pt, Je as q, jr as r, De as rt, Cr as s, xe as st, Ur as t, Oe as tt, hr as u, Fe as ut, pr as v, E as vt, Nt as w, _e as wt, Bt as x, ce as xt, Xt as y, ye as yt, R as z };
|
|
3469
3730
|
|
|
3470
|
-
//# sourceMappingURL=coordinator-api-
|
|
3731
|
+
//# sourceMappingURL=coordinator-api-BToPmSNg.js.map
|