@codemem/core 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-types.d.ts +14 -0
- package/dist/api-types.d.ts.map +1 -1
- package/dist/claude-hooks.d.ts +12 -4
- package/dist/claude-hooks.d.ts.map +1 -1
- package/dist/codex-hooks.d.ts +7 -3
- package/dist/codex-hooks.d.ts.map +1 -1
- package/dist/coordinator-actions.d.ts.map +1 -1
- package/dist/{coordinator-api-Bxw5Q3py.js → coordinator-api-SeLosPIq.js} +489 -459
- package/dist/coordinator-api-SeLosPIq.js.map +1 -0
- package/dist/coordinator-api.d.ts.map +1 -1
- package/dist/db.d.ts +2 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/device-identity-binding.d.ts +50 -0
- package/dist/device-identity-binding.d.ts.map +1 -0
- package/dist/device-identity-inventory.d.ts +72 -0
- package/dist/device-identity-inventory.d.ts.map +1 -0
- package/dist/hook-transcript.d.ts +25 -0
- package/dist/hook-transcript.d.ts.map +1 -0
- package/dist/identity-target.d.ts +16 -0
- package/dist/identity-target.d.ts.map +1 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8601 -7482
- package/dist/index.js.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +149 -149
- package/dist/project-invite-identity.d.ts +2 -0
- package/dist/project-invite-identity.d.ts.map +1 -1
- package/dist/prompt-transport.d.ts +36 -0
- package/dist/prompt-transport.d.ts.map +1 -0
- package/dist/raw-event-flush.d.ts +1 -0
- package/dist/raw-event-flush.d.ts.map +1 -1
- package/dist/raw-event-ingest.d.ts +19 -0
- package/dist/raw-event-ingest.d.ts.map +1 -0
- package/dist/raw-event-sweeper.d.ts +6 -1
- package/dist/raw-event-sweeper.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts +9 -0
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/schema.d.ts +817 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/share-operation.d.ts.map +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/sync-auth.d.ts +62 -2
- package/dist/sync-auth.d.ts.map +1 -1
- package/dist/sync-bootstrap.d.ts +2 -0
- package/dist/sync-bootstrap.d.ts.map +1 -1
- package/dist/sync-http-client.d.ts +1 -0
- package/dist/sync-http-client.d.ts.map +1 -1
- package/dist/sync-pass.d.ts.map +1 -1
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/coordinator-api-Bxw5Q3py.js.map +0 -1
|
@@ -83,201 +83,225 @@ function m(e) {
|
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/project-invite-identity.ts
|
|
86
|
-
var h = 120;
|
|
87
|
-
function
|
|
86
|
+
var h = 120, g = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, _ = /^(?:actor|device|identity|local):\S+$/iu, v = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, y = /^pending[_-]\S+$/iu, b = /^[a-f0-9]{12,64}$/iu;
|
|
87
|
+
function x(e, t) {
|
|
88
88
|
if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
|
|
89
89
|
let n = e.replace(/\s+/gu, " ").trim();
|
|
90
90
|
if (!n) throw Error(`${t}_required`);
|
|
91
91
|
if ([...n].length > h) throw Error(`${t}_too_long`);
|
|
92
92
|
return n;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function S(e) {
|
|
95
|
+
if (typeof e != "string") return !1;
|
|
96
|
+
let t;
|
|
97
|
+
try {
|
|
98
|
+
t = x(e, "display_name");
|
|
99
|
+
} catch {
|
|
100
|
+
return !1;
|
|
101
|
+
}
|
|
102
|
+
return ![
|
|
103
|
+
g,
|
|
104
|
+
_,
|
|
105
|
+
v,
|
|
106
|
+
y,
|
|
107
|
+
b
|
|
108
|
+
].some((e) => e.test(t));
|
|
109
|
+
}
|
|
110
|
+
function C(e, t) {
|
|
111
|
+
let n = x(e, t);
|
|
112
|
+
if (!S(n)) throw Error(`${t}_invalid`);
|
|
113
|
+
return n;
|
|
114
|
+
}
|
|
115
|
+
function w(e) {
|
|
95
116
|
let t = String(e ?? "").replace(/\.local$/iu, "");
|
|
96
|
-
return t.trim() ?
|
|
117
|
+
return t.trim() ? x(t.replace(/[-_]+/gu, " "), "device_display_name") : null;
|
|
97
118
|
}
|
|
98
|
-
function
|
|
119
|
+
function T(e) {
|
|
99
120
|
for (let t of [
|
|
100
121
|
e.explicitName,
|
|
101
122
|
e.osName,
|
|
102
123
|
e.coordinatorName
|
|
103
124
|
]) {
|
|
104
|
-
let e =
|
|
105
|
-
if (e)
|
|
125
|
+
let e = String(t ?? "").replace(/\.local$/iu, "").trim();
|
|
126
|
+
if (!(!e || !S(e))) try {
|
|
127
|
+
let e = w(t);
|
|
128
|
+
if (e && S(e)) return e;
|
|
129
|
+
} catch {}
|
|
106
130
|
}
|
|
107
131
|
let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
|
|
108
132
|
return t ? `Codemem device ${t}` : "Codemem device";
|
|
109
133
|
}
|
|
110
|
-
function
|
|
134
|
+
function ee(e) {
|
|
111
135
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("project_summaries_invalid");
|
|
112
136
|
return e.map((e) => {
|
|
113
137
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("project_summaries_invalid");
|
|
114
138
|
let t = e;
|
|
115
139
|
if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
|
|
116
140
|
return {
|
|
117
|
-
display_name:
|
|
141
|
+
display_name: x(String(t.display_name ?? ""), "project_name"),
|
|
118
142
|
existing_memory_count: Number(t.existing_memory_count)
|
|
119
143
|
};
|
|
120
144
|
});
|
|
121
145
|
}
|
|
122
146
|
//#endregion
|
|
123
147
|
//#region src/recipient-reviewed-intent.ts
|
|
124
|
-
var
|
|
148
|
+
var E = 1, D = class extends Error {
|
|
125
149
|
code;
|
|
126
150
|
constructor(e) {
|
|
127
151
|
super(e), this.name = "RecipientReviewedIntentError", this.code = e;
|
|
128
152
|
}
|
|
129
|
-
},
|
|
130
|
-
function
|
|
131
|
-
throw new
|
|
153
|
+
}, O = /[\p{Cc}\p{Cf}]/u, k = 100, A = 64 * 1024;
|
|
154
|
+
function j() {
|
|
155
|
+
throw new D("recipient_reviewed_intent_invalid");
|
|
132
156
|
}
|
|
133
|
-
function
|
|
134
|
-
return (!e || typeof e != "object" || Array.isArray(e)) &&
|
|
157
|
+
function M(e) {
|
|
158
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && j(), e;
|
|
135
159
|
}
|
|
136
|
-
function
|
|
137
|
-
Object.keys(e).some((e) => !t.includes(e)) &&
|
|
160
|
+
function N(e, t) {
|
|
161
|
+
Object.keys(e).some((e) => !t.includes(e)) && j();
|
|
138
162
|
}
|
|
139
|
-
function
|
|
140
|
-
return (typeof e != "string" || !e || e !== e.trim() || e.length > t ||
|
|
163
|
+
function P(e, t) {
|
|
164
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > t || O.test(e)) && j(), e;
|
|
141
165
|
}
|
|
142
|
-
function
|
|
143
|
-
(typeof e != "string" ||
|
|
166
|
+
function te(e) {
|
|
167
|
+
(typeof e != "string" || O.test(e)) && j();
|
|
144
168
|
let t = e.trim().replace(/\s+/gu, " ");
|
|
145
|
-
return (!t || t.length > 256) &&
|
|
169
|
+
return (!t || t.length > 256) && j(), t;
|
|
146
170
|
}
|
|
147
|
-
function
|
|
148
|
-
typeof e != "string" &&
|
|
171
|
+
function ne(e) {
|
|
172
|
+
typeof e != "string" && j();
|
|
149
173
|
try {
|
|
150
|
-
return
|
|
174
|
+
return x(e, "identity_display_name");
|
|
151
175
|
} catch {
|
|
152
|
-
return
|
|
176
|
+
return j();
|
|
153
177
|
}
|
|
154
178
|
}
|
|
155
|
-
function
|
|
156
|
-
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) &&
|
|
179
|
+
function re(e) {
|
|
180
|
+
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && j(), e;
|
|
157
181
|
}
|
|
158
|
-
function
|
|
182
|
+
function ie(e, t) {
|
|
159
183
|
return e < t ? -1 : +(e > t);
|
|
160
184
|
}
|
|
161
|
-
function
|
|
185
|
+
function ae(e) {
|
|
162
186
|
return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
|
|
163
187
|
}
|
|
164
|
-
function
|
|
165
|
-
let t =
|
|
166
|
-
return t.kind === "direct" ? (
|
|
188
|
+
function oe(e) {
|
|
189
|
+
let t = M(e);
|
|
190
|
+
return t.kind === "direct" ? (N(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && j(), N(t, [
|
|
167
191
|
"kind",
|
|
168
192
|
"teamId",
|
|
169
193
|
"displayName"
|
|
170
194
|
]), {
|
|
171
195
|
kind: "team",
|
|
172
|
-
teamId:
|
|
173
|
-
displayName:
|
|
196
|
+
teamId: P(t.teamId, 256),
|
|
197
|
+
displayName: te(t.displayName)
|
|
174
198
|
});
|
|
175
199
|
}
|
|
176
|
-
function
|
|
177
|
-
let t =
|
|
178
|
-
|
|
200
|
+
function se(e) {
|
|
201
|
+
let t = M(e);
|
|
202
|
+
N(t, [
|
|
179
203
|
"canonicalProjectIdentity",
|
|
180
204
|
"displayName",
|
|
181
205
|
"existingMemoryCount",
|
|
182
206
|
"futureMemoriesShared",
|
|
183
207
|
"sources"
|
|
184
|
-
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) &&
|
|
185
|
-
let n = t.sources.map(
|
|
186
|
-
return new Set(n.map(
|
|
187
|
-
canonicalProjectIdentity:
|
|
188
|
-
displayName:
|
|
189
|
-
existingMemoryCount:
|
|
208
|
+
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && j();
|
|
209
|
+
let n = t.sources.map(oe).toSorted((e, t) => ie(ae(e), ae(t)));
|
|
210
|
+
return new Set(n.map(ae)).size !== n.length && j(), {
|
|
211
|
+
canonicalProjectIdentity: P(t.canonicalProjectIdentity, 512),
|
|
212
|
+
displayName: te(t.displayName),
|
|
213
|
+
existingMemoryCount: re(t.existingMemoryCount),
|
|
190
214
|
futureMemoriesShared: !0,
|
|
191
215
|
sources: n
|
|
192
216
|
};
|
|
193
217
|
}
|
|
194
|
-
function
|
|
195
|
-
let t =
|
|
196
|
-
return
|
|
218
|
+
function ce(e) {
|
|
219
|
+
let t = M(e);
|
|
220
|
+
return N(t, [
|
|
197
221
|
"canonicalProjectIdentity",
|
|
198
222
|
"displayName",
|
|
199
223
|
"existingMemoryCount"
|
|
200
224
|
]), {
|
|
201
|
-
canonicalProjectIdentity:
|
|
202
|
-
displayName:
|
|
203
|
-
existingMemoryCount:
|
|
225
|
+
canonicalProjectIdentity: P(t.canonicalProjectIdentity, 512),
|
|
226
|
+
displayName: te(t.displayName),
|
|
227
|
+
existingMemoryCount: re(t.existingMemoryCount)
|
|
204
228
|
};
|
|
205
229
|
}
|
|
206
|
-
function
|
|
207
|
-
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length >
|
|
208
|
-
let t = e.projects.map(
|
|
209
|
-
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) &&
|
|
230
|
+
function le(e) {
|
|
231
|
+
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > k) && j();
|
|
232
|
+
let t = e.projects.map(se).toSorted((e, t) => ie(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(ce).toSorted((e, t) => ie(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
|
|
233
|
+
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && j(), {
|
|
210
234
|
projects: t,
|
|
211
235
|
excludedProjects: n
|
|
212
236
|
};
|
|
213
237
|
}
|
|
214
|
-
function
|
|
215
|
-
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
|
|
238
|
+
function ue(e, t) {
|
|
239
|
+
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 D("recipient_invite_intent_mismatch");
|
|
216
240
|
}
|
|
217
|
-
function
|
|
218
|
-
let n =
|
|
219
|
-
n.version !== 1 &&
|
|
220
|
-
let r =
|
|
241
|
+
function F(e, t) {
|
|
242
|
+
let n = M(e);
|
|
243
|
+
n.version !== 1 && j();
|
|
244
|
+
let r = le(n), i;
|
|
221
245
|
if (n.journey === "team") {
|
|
222
|
-
|
|
246
|
+
N(n, [
|
|
223
247
|
"version",
|
|
224
248
|
"journey",
|
|
225
249
|
"team",
|
|
226
250
|
"projects",
|
|
227
251
|
"excludedProjects"
|
|
228
252
|
]);
|
|
229
|
-
let e =
|
|
230
|
-
|
|
253
|
+
let e = M(n.team);
|
|
254
|
+
N(e, [
|
|
231
255
|
"teamId",
|
|
232
256
|
"displayName",
|
|
233
257
|
"futureProjectsInherit"
|
|
234
|
-
]), e.futureProjectsInherit !== !0 &&
|
|
258
|
+
]), e.futureProjectsInherit !== !0 && j(), i = {
|
|
235
259
|
version: 1,
|
|
236
260
|
journey: "team",
|
|
237
261
|
team: {
|
|
238
|
-
teamId:
|
|
239
|
-
displayName:
|
|
262
|
+
teamId: P(e.teamId, 256),
|
|
263
|
+
displayName: te(e.displayName),
|
|
240
264
|
futureProjectsInherit: !0
|
|
241
265
|
},
|
|
242
266
|
...r
|
|
243
267
|
};
|
|
244
268
|
} else if (n.journey === "add_device") {
|
|
245
|
-
|
|
269
|
+
N(n, [
|
|
246
270
|
"version",
|
|
247
271
|
"journey",
|
|
248
272
|
"targetIdentity",
|
|
249
273
|
"projects",
|
|
250
274
|
"excludedProjects"
|
|
251
275
|
]);
|
|
252
|
-
let e =
|
|
253
|
-
|
|
276
|
+
let e = M(n.targetIdentity);
|
|
277
|
+
N(e, ["identityId", "displayName"]), i = {
|
|
254
278
|
version: 1,
|
|
255
279
|
journey: "add_device",
|
|
256
280
|
targetIdentity: {
|
|
257
|
-
identityId:
|
|
258
|
-
displayName:
|
|
281
|
+
identityId: P(e.identityId, 256),
|
|
282
|
+
displayName: ne(e.displayName)
|
|
259
283
|
},
|
|
260
284
|
...r
|
|
261
285
|
};
|
|
262
|
-
} else
|
|
263
|
-
return t &&
|
|
286
|
+
} else j();
|
|
287
|
+
return t && ue(i, t), new TextEncoder().encode(I(i)).byteLength > A && j(), i;
|
|
264
288
|
}
|
|
265
|
-
function
|
|
266
|
-
return Array.isArray(e) ? `[${e.map(
|
|
289
|
+
function I(e) {
|
|
290
|
+
return Array.isArray(e) ? `[${e.map(I).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => ie(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${I(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
|
|
267
291
|
}
|
|
268
|
-
function
|
|
269
|
-
return
|
|
292
|
+
function de(e, t) {
|
|
293
|
+
return I(F(e, t));
|
|
270
294
|
}
|
|
271
|
-
async function
|
|
272
|
-
let n =
|
|
295
|
+
async function fe(e, t) {
|
|
296
|
+
let n = de(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
|
|
273
297
|
return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
|
|
274
298
|
}
|
|
275
|
-
async function
|
|
276
|
-
let n =
|
|
277
|
-
if (await
|
|
299
|
+
async function L(e, t) {
|
|
300
|
+
let n = F(e, t.target);
|
|
301
|
+
if (await fe(n) !== t.digest) throw new D("recipient_invite_intent_mismatch");
|
|
278
302
|
return n;
|
|
279
303
|
}
|
|
280
|
-
async function
|
|
304
|
+
async function pe(e, t) {
|
|
281
305
|
if (!e) throw Error("recipient_invite_review_unavailable");
|
|
282
306
|
let n;
|
|
283
307
|
try {
|
|
@@ -286,21 +310,21 @@ async function ce(e, t) {
|
|
|
286
310
|
throw Error("recipient_invite_review_unavailable");
|
|
287
311
|
}
|
|
288
312
|
try {
|
|
289
|
-
let r =
|
|
290
|
-
if (
|
|
291
|
-
return await
|
|
313
|
+
let r = F(n, t.target);
|
|
314
|
+
if (I(r) !== e) throw Error("recipient_invite_review_unavailable");
|
|
315
|
+
return await L(r, t);
|
|
292
316
|
} catch (e) {
|
|
293
|
-
throw e instanceof
|
|
317
|
+
throw e instanceof D && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
|
|
294
318
|
}
|
|
295
319
|
}
|
|
296
320
|
//#endregion
|
|
297
321
|
//#region src/sync-fingerprint.ts
|
|
298
|
-
function
|
|
322
|
+
function me(e) {
|
|
299
323
|
return t("sha256").update(e, "utf-8").digest("hex");
|
|
300
324
|
}
|
|
301
325
|
//#endregion
|
|
302
326
|
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/compose.js
|
|
303
|
-
var
|
|
327
|
+
var he = (e, t, n) => (r, i) => {
|
|
304
328
|
let a = -1;
|
|
305
329
|
return o(0);
|
|
306
330
|
async function o(s) {
|
|
@@ -316,40 +340,40 @@ var ue = (e, t, n) => (r, i) => {
|
|
|
316
340
|
else r.finalized === !1 && n && (c = await n(r));
|
|
317
341
|
return c && (r.finalized === !1 || l) && (r.res = c), r;
|
|
318
342
|
}
|
|
319
|
-
},
|
|
320
|
-
let { all: n = !1, dot: r = !1 } = t, i = (e instanceof
|
|
321
|
-
return i?.startsWith("multipart/form-data") || i?.startsWith("application/x-www-form-urlencoded") ?
|
|
343
|
+
}, ge = /* @__PURE__ */ Symbol(), _e = async (e, t = /* @__PURE__ */ Object.create(null)) => {
|
|
344
|
+
let { all: n = !1, dot: r = !1 } = t, i = (e instanceof Re ? e.raw.headers : e.headers).get("Content-Type");
|
|
345
|
+
return i?.startsWith("multipart/form-data") || i?.startsWith("application/x-www-form-urlencoded") ? ve(e, {
|
|
322
346
|
all: n,
|
|
323
347
|
dot: r
|
|
324
348
|
}) : {};
|
|
325
349
|
};
|
|
326
|
-
async function
|
|
350
|
+
async function ve(e, t) {
|
|
327
351
|
let n = await e.formData();
|
|
328
|
-
return n ?
|
|
352
|
+
return n ? ye(n, t) : {};
|
|
329
353
|
}
|
|
330
|
-
function
|
|
354
|
+
function ye(e, t) {
|
|
331
355
|
let n = /* @__PURE__ */ Object.create(null);
|
|
332
356
|
return e.forEach((e, r) => {
|
|
333
|
-
t.all || r.endsWith("[]") ?
|
|
357
|
+
t.all || r.endsWith("[]") ? be(n, r, e) : n[r] = e;
|
|
334
358
|
}), t.dot && Object.entries(n).forEach(([e, t]) => {
|
|
335
|
-
e.includes(".") && (
|
|
359
|
+
e.includes(".") && (xe(n, e, t), delete n[e]);
|
|
336
360
|
}), n;
|
|
337
361
|
}
|
|
338
|
-
var
|
|
362
|
+
var be = (e, t, n) => {
|
|
339
363
|
e[t] === void 0 ? t.endsWith("[]") ? e[t] = [n] : e[t] = n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
|
|
340
|
-
},
|
|
364
|
+
}, xe = (e, t, n) => {
|
|
341
365
|
if (/(?:^|\.)__proto__\./.test(t)) return;
|
|
342
366
|
let r = e, i = t.split(".");
|
|
343
367
|
i.forEach((e, t) => {
|
|
344
368
|
t === i.length - 1 ? r[e] = n : ((!r[e] || typeof r[e] != "object" || Array.isArray(r[e]) || r[e] instanceof File) && (r[e] = /* @__PURE__ */ Object.create(null)), r = r[e]);
|
|
345
369
|
});
|
|
346
|
-
},
|
|
370
|
+
}, Se = (e) => {
|
|
347
371
|
let t = e.split("/");
|
|
348
372
|
return t[0] === "" && t.shift(), t;
|
|
349
|
-
},
|
|
350
|
-
let { groups: t, path: n } =
|
|
351
|
-
return
|
|
352
|
-
},
|
|
373
|
+
}, Ce = (e) => {
|
|
374
|
+
let { groups: t, path: n } = we(e);
|
|
375
|
+
return Te(Se(n), t);
|
|
376
|
+
}, we = (e) => {
|
|
353
377
|
let t = [];
|
|
354
378
|
return e = e.replace(/\{[^}]+\}/g, (e, n) => {
|
|
355
379
|
let r = `@${n}`;
|
|
@@ -358,7 +382,7 @@ var he = (e, t, n) => {
|
|
|
358
382
|
groups: t,
|
|
359
383
|
path: e
|
|
360
384
|
};
|
|
361
|
-
},
|
|
385
|
+
}, Te = (e, t) => {
|
|
362
386
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
363
387
|
let [r] = t[n];
|
|
364
388
|
for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
|
|
@@ -367,12 +391,12 @@ var he = (e, t, n) => {
|
|
|
367
391
|
}
|
|
368
392
|
}
|
|
369
393
|
return e;
|
|
370
|
-
},
|
|
394
|
+
}, R = {}, Ee = (e, t) => {
|
|
371
395
|
if (e === "*") return "*";
|
|
372
396
|
let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
373
397
|
if (n) {
|
|
374
398
|
let r = `${e}#${t}`;
|
|
375
|
-
return
|
|
399
|
+
return R[r] || (n[2] ? R[r] = t && t[0] !== ":" && t[0] !== "*" ? [
|
|
376
400
|
r,
|
|
377
401
|
n[1],
|
|
378
402
|
RegExp(`^${n[2]}(?=/${t})`)
|
|
@@ -380,14 +404,14 @@ var he = (e, t, n) => {
|
|
|
380
404
|
e,
|
|
381
405
|
n[1],
|
|
382
406
|
RegExp(`^${n[2]}$`)
|
|
383
|
-
] :
|
|
407
|
+
] : R[r] = [
|
|
384
408
|
e,
|
|
385
409
|
n[1],
|
|
386
410
|
!0
|
|
387
|
-
]),
|
|
411
|
+
]), R[r];
|
|
388
412
|
}
|
|
389
413
|
return null;
|
|
390
|
-
},
|
|
414
|
+
}, De = (e, t) => {
|
|
391
415
|
try {
|
|
392
416
|
return t(e);
|
|
393
417
|
} catch {
|
|
@@ -399,20 +423,20 @@ var he = (e, t, n) => {
|
|
|
399
423
|
}
|
|
400
424
|
});
|
|
401
425
|
}
|
|
402
|
-
},
|
|
426
|
+
}, Oe = (e) => De(e, decodeURI), ke = (e) => {
|
|
403
427
|
let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
|
|
404
428
|
for (; r < t.length; r++) {
|
|
405
429
|
let e = t.charCodeAt(r);
|
|
406
430
|
if (e === 37) {
|
|
407
431
|
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);
|
|
408
|
-
return
|
|
432
|
+
return Oe(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
|
|
409
433
|
} else if (e === 63 || e === 35) break;
|
|
410
434
|
}
|
|
411
435
|
return t.slice(n, r);
|
|
412
|
-
},
|
|
413
|
-
let t =
|
|
436
|
+
}, Ae = (e) => {
|
|
437
|
+
let t = ke(e);
|
|
414
438
|
return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
|
|
415
|
-
},
|
|
439
|
+
}, z = (e, t, ...n) => (n.length && (t = z(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), je = (e) => {
|
|
416
440
|
if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
|
|
417
441
|
let t = e.split("/"), n = [], r = "";
|
|
418
442
|
return t.forEach((e) => {
|
|
@@ -423,7 +447,7 @@ var he = (e, t, n) => {
|
|
|
423
447
|
r += "/" + t, n.push(r);
|
|
424
448
|
} else r += "/" + e;
|
|
425
449
|
}), n.filter((e, t, n) => n.indexOf(e) === t);
|
|
426
|
-
},
|
|
450
|
+
}, Me = (e) => /[%+]/.test(e) ? (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), e.indexOf("%") === -1 ? e : De(e, Ie)) : e, Ne = (e, t, n) => {
|
|
427
451
|
let r;
|
|
428
452
|
if (!n && t && !/[%+]/.test(t)) {
|
|
429
453
|
let n = e.indexOf("?", 8);
|
|
@@ -432,7 +456,7 @@ var he = (e, t, n) => {
|
|
|
432
456
|
let r = e.charCodeAt(n + t.length + 1);
|
|
433
457
|
if (r === 61) {
|
|
434
458
|
let r = n + t.length + 2, i = e.indexOf("&", r);
|
|
435
|
-
return
|
|
459
|
+
return Me(e.slice(r, i === -1 ? void 0 : i));
|
|
436
460
|
} else if (r == 38 || isNaN(r)) return "";
|
|
437
461
|
n = e.indexOf(`&${t}`, n + 1);
|
|
438
462
|
}
|
|
@@ -445,12 +469,12 @@ var he = (e, t, n) => {
|
|
|
445
469
|
let t = e.indexOf("&", a + 1), o = e.indexOf("=", a);
|
|
446
470
|
o > t && t !== -1 && (o = -1);
|
|
447
471
|
let s = e.slice(a + 1, o === -1 ? t === -1 ? void 0 : t : o);
|
|
448
|
-
if (r && (s =
|
|
472
|
+
if (r && (s = Me(s)), a = t, s === "") continue;
|
|
449
473
|
let c;
|
|
450
|
-
o === -1 ? c = "" : (c = e.slice(o + 1, t === -1 ? void 0 : t), r && (c =
|
|
474
|
+
o === -1 ? c = "" : (c = e.slice(o + 1, t === -1 ? void 0 : t), r && (c = Me(c))), n ? (i[s] && Array.isArray(i[s]) || (i[s] = []), i[s].push(c)) : i[s] ??= c;
|
|
451
475
|
}
|
|
452
476
|
return t ? i[t] : i;
|
|
453
|
-
},
|
|
477
|
+
}, Pe = Ne, Fe = (e, t) => Ne(e, t, !0), Ie = decodeURIComponent, Le = (e) => De(e, Ie), Re = class {
|
|
454
478
|
raw;
|
|
455
479
|
#e;
|
|
456
480
|
#t;
|
|
@@ -465,13 +489,13 @@ var he = (e, t, n) => {
|
|
|
465
489
|
}
|
|
466
490
|
#n(e) {
|
|
467
491
|
let t = this.#t[0][this.routeIndex][1][e], n = this.#i(t);
|
|
468
|
-
return n && /\%/.test(n) ?
|
|
492
|
+
return n && /\%/.test(n) ? Le(n) : n;
|
|
469
493
|
}
|
|
470
494
|
#r() {
|
|
471
495
|
let e = {}, t = Object.keys(this.#t[0][this.routeIndex][1]);
|
|
472
496
|
for (let n of t) {
|
|
473
497
|
let t = this.#i(this.#t[0][this.routeIndex][1][n]);
|
|
474
|
-
t !== void 0 && (e[n] = /\%/.test(t) ?
|
|
498
|
+
t !== void 0 && (e[n] = /\%/.test(t) ? Le(t) : t);
|
|
475
499
|
}
|
|
476
500
|
return e;
|
|
477
501
|
}
|
|
@@ -479,10 +503,10 @@ var he = (e, t, n) => {
|
|
|
479
503
|
return this.#t[1] ? this.#t[1][e] : e;
|
|
480
504
|
}
|
|
481
505
|
query(e) {
|
|
482
|
-
return
|
|
506
|
+
return Pe(this.url, e);
|
|
483
507
|
}
|
|
484
508
|
queries(e) {
|
|
485
|
-
return
|
|
509
|
+
return Fe(this.url, e);
|
|
486
510
|
}
|
|
487
511
|
header(e) {
|
|
488
512
|
if (e) return this.raw.headers.get(e) ?? void 0;
|
|
@@ -492,7 +516,7 @@ var he = (e, t, n) => {
|
|
|
492
516
|
}), t;
|
|
493
517
|
}
|
|
494
518
|
async parseBody(e) {
|
|
495
|
-
return
|
|
519
|
+
return _e(this, e);
|
|
496
520
|
}
|
|
497
521
|
#a = (e) => {
|
|
498
522
|
let { bodyCache: t, raw: n } = this, r = t[e];
|
|
@@ -530,7 +554,7 @@ var he = (e, t, n) => {
|
|
|
530
554
|
get method() {
|
|
531
555
|
return this.raw.method;
|
|
532
556
|
}
|
|
533
|
-
get [
|
|
557
|
+
get [ge]() {
|
|
534
558
|
return this.#t;
|
|
535
559
|
}
|
|
536
560
|
get matchedRoutes() {
|
|
@@ -539,14 +563,14 @@ var he = (e, t, n) => {
|
|
|
539
563
|
get routePath() {
|
|
540
564
|
return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
|
|
541
565
|
}
|
|
542
|
-
},
|
|
566
|
+
}, ze = {
|
|
543
567
|
Stringify: 1,
|
|
544
568
|
BeforeStream: 2,
|
|
545
569
|
Stream: 3
|
|
546
|
-
},
|
|
570
|
+
}, Be = (e, t) => {
|
|
547
571
|
let n = new String(e);
|
|
548
572
|
return n.isEscaped = !0, n.callbacks = t, n;
|
|
549
|
-
},
|
|
573
|
+
}, Ve = async (e, t, n, r, i) => {
|
|
550
574
|
typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
|
|
551
575
|
let a = e.callbacks;
|
|
552
576
|
if (!a?.length) return Promise.resolve(e);
|
|
@@ -555,12 +579,12 @@ var he = (e, t, n) => {
|
|
|
555
579
|
phase: t,
|
|
556
580
|
buffer: i,
|
|
557
581
|
context: r
|
|
558
|
-
}))).then((e) => Promise.all(e.filter(Boolean).map((e) =>
|
|
559
|
-
return n ?
|
|
560
|
-
},
|
|
582
|
+
}))).then((e) => Promise.all(e.filter(Boolean).map((e) => Ve(e, t, !1, r, i))).then(() => i[0]));
|
|
583
|
+
return n ? Be(await o, a) : o;
|
|
584
|
+
}, He = "text/plain; charset=UTF-8", Ue = (e, t) => ({
|
|
561
585
|
"Content-Type": e,
|
|
562
586
|
...t
|
|
563
|
-
}),
|
|
587
|
+
}), B = (e, t) => new Response(e, t), We = class {
|
|
564
588
|
#e;
|
|
565
589
|
#t;
|
|
566
590
|
env = {};
|
|
@@ -580,7 +604,7 @@ var he = (e, t, n) => {
|
|
|
580
604
|
this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
|
|
581
605
|
}
|
|
582
606
|
get req() {
|
|
583
|
-
return this.#t ??= new
|
|
607
|
+
return this.#t ??= new Re(this.#e, this.#d, this.#u), this.#t;
|
|
584
608
|
}
|
|
585
609
|
get event() {
|
|
586
610
|
if (this.#i && "respondWith" in this.#i) return this.#i;
|
|
@@ -591,11 +615,11 @@ var he = (e, t, n) => {
|
|
|
591
615
|
throw Error("This context has no ExecutionContext");
|
|
592
616
|
}
|
|
593
617
|
get res() {
|
|
594
|
-
return this.#a ||=
|
|
618
|
+
return this.#a ||= B(null, { headers: this.#l ??= new Headers() });
|
|
595
619
|
}
|
|
596
620
|
set res(e) {
|
|
597
621
|
if (this.#a && e) {
|
|
598
|
-
e =
|
|
622
|
+
e = B(e.body, e);
|
|
599
623
|
for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") if (t === "set-cookie") {
|
|
600
624
|
let t = this.#a.headers.getSetCookie();
|
|
601
625
|
e.headers.delete("set-cookie");
|
|
@@ -611,7 +635,7 @@ var he = (e, t, n) => {
|
|
|
611
635
|
this.#s = e;
|
|
612
636
|
};
|
|
613
637
|
header = (e, t, n) => {
|
|
614
|
-
this.finalized && (this.#a =
|
|
638
|
+
this.finalized && (this.#a = B(this.#a.body, this.#a));
|
|
615
639
|
let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
|
|
616
640
|
t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
|
|
617
641
|
};
|
|
@@ -636,38 +660,38 @@ var he = (e, t, n) => {
|
|
|
636
660
|
r.delete(e);
|
|
637
661
|
for (let n of t) r.append(e, n);
|
|
638
662
|
}
|
|
639
|
-
return
|
|
663
|
+
return B(e, {
|
|
640
664
|
status: typeof t == "number" ? t : t?.status ?? this.#r,
|
|
641
665
|
headers: r
|
|
642
666
|
});
|
|
643
667
|
}
|
|
644
668
|
newResponse = (...e) => this.#f(...e);
|
|
645
669
|
body = (e, t, n) => this.#f(e, t, n);
|
|
646
|
-
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t,
|
|
647
|
-
json = (e, t, n) => this.#f(JSON.stringify(e), t,
|
|
670
|
+
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Ue(He, n));
|
|
671
|
+
json = (e, t, n) => this.#f(JSON.stringify(e), t, Ue("application/json", n));
|
|
648
672
|
html = (e, t, n) => {
|
|
649
|
-
let r = (e) => this.#f(e, t,
|
|
650
|
-
return typeof e == "object" ?
|
|
673
|
+
let r = (e) => this.#f(e, t, Ue("text/html; charset=UTF-8", n));
|
|
674
|
+
return typeof e == "object" ? Ve(e, ze.Stringify, !1, {}).then(r) : r(e);
|
|
651
675
|
};
|
|
652
676
|
redirect = (e, t) => {
|
|
653
677
|
let n = String(e);
|
|
654
678
|
return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
|
|
655
679
|
};
|
|
656
|
-
notFound = () => (this.#c ??= () =>
|
|
657
|
-
},
|
|
680
|
+
notFound = () => (this.#c ??= () => B(), this.#c(this));
|
|
681
|
+
}, Ge = [
|
|
658
682
|
"get",
|
|
659
683
|
"post",
|
|
660
684
|
"put",
|
|
661
685
|
"delete",
|
|
662
686
|
"options",
|
|
663
687
|
"patch"
|
|
664
|
-
],
|
|
688
|
+
], Ke = "Can not add a route since the matcher is already built.", qe = class extends Error {}, Je = "__COMPOSED_HANDLER", Ye = (e) => e.text("404 Not Found", 404), Xe = (e, t) => {
|
|
665
689
|
if ("getResponse" in e) {
|
|
666
690
|
let n = e.getResponse();
|
|
667
691
|
return t.newResponse(n.body, n);
|
|
668
692
|
}
|
|
669
693
|
return console.error(e), t.text("Internal Server Error", 500);
|
|
670
|
-
},
|
|
694
|
+
}, Ze = class e {
|
|
671
695
|
get;
|
|
672
696
|
post;
|
|
673
697
|
put;
|
|
@@ -683,7 +707,7 @@ var he = (e, t, n) => {
|
|
|
683
707
|
#e = "/";
|
|
684
708
|
routes = [];
|
|
685
709
|
constructor(e = {}) {
|
|
686
|
-
[...
|
|
710
|
+
[...Ge, "all"].forEach((e) => {
|
|
687
711
|
this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
|
|
688
712
|
this.#r(e, this.#e, t);
|
|
689
713
|
}), this);
|
|
@@ -699,7 +723,7 @@ var he = (e, t, n) => {
|
|
|
699
723
|
this.#r("ALL", this.#e, e);
|
|
700
724
|
}), this);
|
|
701
725
|
let { strict: t, ...n } = e;
|
|
702
|
-
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ??
|
|
726
|
+
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? ke : Ae;
|
|
703
727
|
}
|
|
704
728
|
#t() {
|
|
705
729
|
let t = new e({
|
|
@@ -708,18 +732,18 @@ var he = (e, t, n) => {
|
|
|
708
732
|
});
|
|
709
733
|
return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
|
|
710
734
|
}
|
|
711
|
-
#n =
|
|
712
|
-
errorHandler =
|
|
735
|
+
#n = Ye;
|
|
736
|
+
errorHandler = Xe;
|
|
713
737
|
route(e, t) {
|
|
714
738
|
let n = this.basePath(e);
|
|
715
739
|
return t.routes.map((e) => {
|
|
716
740
|
let r;
|
|
717
|
-
t.errorHandler ===
|
|
741
|
+
t.errorHandler === Xe ? r = e.handler : (r = async (n, r) => (await he([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Je] = e.handler), n.#r(e.method, e.path, r, e.basePath);
|
|
718
742
|
}), this;
|
|
719
743
|
}
|
|
720
744
|
basePath(e) {
|
|
721
745
|
let t = this.#t();
|
|
722
|
-
return t._basePath =
|
|
746
|
+
return t._basePath = z(this._basePath, e), t;
|
|
723
747
|
}
|
|
724
748
|
onError = (e) => (this.errorHandler = e, this);
|
|
725
749
|
notFound = (e) => (this.#n = e, this);
|
|
@@ -737,21 +761,21 @@ var he = (e, t, n) => {
|
|
|
737
761
|
return [e.env, t];
|
|
738
762
|
};
|
|
739
763
|
return r ||= (() => {
|
|
740
|
-
let t =
|
|
764
|
+
let t = z(this._basePath, e), n = t === "/" ? 0 : t.length;
|
|
741
765
|
return (e) => {
|
|
742
766
|
let t = new URL(e.url);
|
|
743
767
|
return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
|
|
744
768
|
};
|
|
745
|
-
})(), this.#r("ALL",
|
|
769
|
+
})(), this.#r("ALL", z(e, "*"), async (e, n) => {
|
|
746
770
|
let i = await t(r(e.req.raw), ...a(e));
|
|
747
771
|
if (i) return i;
|
|
748
772
|
await n();
|
|
749
773
|
}), this;
|
|
750
774
|
}
|
|
751
775
|
#r(e, t, n, r) {
|
|
752
|
-
e = e.toUpperCase(), t =
|
|
776
|
+
e = e.toUpperCase(), t = z(this._basePath, t);
|
|
753
777
|
let i = {
|
|
754
|
-
basePath: r === void 0 ? this._basePath :
|
|
778
|
+
basePath: r === void 0 ? this._basePath : z(this._basePath, r),
|
|
755
779
|
path: t,
|
|
756
780
|
method: e,
|
|
757
781
|
handler: n
|
|
@@ -764,7 +788,7 @@ var he = (e, t, n) => {
|
|
|
764
788
|
}
|
|
765
789
|
#a(e, t, n, r) {
|
|
766
790
|
if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
|
|
767
|
-
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new
|
|
791
|
+
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new We(e, {
|
|
768
792
|
path: i,
|
|
769
793
|
matchResult: a,
|
|
770
794
|
env: n,
|
|
@@ -782,7 +806,7 @@ var he = (e, t, n) => {
|
|
|
782
806
|
}
|
|
783
807
|
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);
|
|
784
808
|
}
|
|
785
|
-
let s =
|
|
809
|
+
let s = he(a[0], this.errorHandler, this.#n);
|
|
786
810
|
return (async () => {
|
|
787
811
|
try {
|
|
788
812
|
let e = await s(o);
|
|
@@ -794,19 +818,19 @@ var he = (e, t, n) => {
|
|
|
794
818
|
})();
|
|
795
819
|
}
|
|
796
820
|
fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
|
|
797
|
-
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${
|
|
821
|
+
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${z("/", e)}`, t), n, r));
|
|
798
822
|
fire = () => {
|
|
799
823
|
addEventListener("fetch", (e) => {
|
|
800
824
|
e.respondWith(this.#a(e.request, e, void 0, e.request.method));
|
|
801
825
|
});
|
|
802
826
|
};
|
|
803
|
-
},
|
|
804
|
-
function
|
|
827
|
+
}, Qe = [];
|
|
828
|
+
function $e(e, t) {
|
|
805
829
|
let n = this.buildAllMatchers(), r = ((e, t) => {
|
|
806
830
|
let r = n[e] || n.ALL, i = r[2][t];
|
|
807
831
|
if (i) return i;
|
|
808
832
|
let a = t.match(r[0]);
|
|
809
|
-
if (!a) return [[],
|
|
833
|
+
if (!a) return [[], Qe];
|
|
810
834
|
let o = a.indexOf("", 1);
|
|
811
835
|
return [r[1][o], a];
|
|
812
836
|
});
|
|
@@ -814,17 +838,17 @@ function Ye(e, t) {
|
|
|
814
838
|
}
|
|
815
839
|
//#endregion
|
|
816
840
|
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
817
|
-
var
|
|
818
|
-
function
|
|
819
|
-
return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 || e ===
|
|
841
|
+
var V = "[^/]+", H = ".*", U = "(?:|/.*)", W = /* @__PURE__ */ Symbol(), et = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
842
|
+
function tt(e, t) {
|
|
843
|
+
return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 || e === H || e === U ? 1 : t === H || t === U ? -1 : e === V ? 1 : t === V ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
|
|
820
844
|
}
|
|
821
|
-
var
|
|
845
|
+
var nt = class e {
|
|
822
846
|
#e;
|
|
823
847
|
#t;
|
|
824
848
|
#n = /* @__PURE__ */ Object.create(null);
|
|
825
849
|
insert(t, n, r, i, a) {
|
|
826
850
|
if (t.length === 0) {
|
|
827
|
-
if (this.#e !== void 0) throw
|
|
851
|
+
if (this.#e !== void 0) throw W;
|
|
828
852
|
if (a) return;
|
|
829
853
|
this.#e = n;
|
|
830
854
|
return;
|
|
@@ -832,42 +856,42 @@ var Qe = class e {
|
|
|
832
856
|
let [o, ...s] = t, c = o === "*" ? s.length === 0 ? [
|
|
833
857
|
"",
|
|
834
858
|
"",
|
|
835
|
-
|
|
859
|
+
H
|
|
836
860
|
] : [
|
|
837
861
|
"",
|
|
838
862
|
"",
|
|
839
|
-
|
|
863
|
+
V
|
|
840
864
|
] : o === "/*" ? [
|
|
841
865
|
"",
|
|
842
866
|
"",
|
|
843
|
-
|
|
867
|
+
U
|
|
844
868
|
] : o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
|
|
845
869
|
if (c) {
|
|
846
|
-
let t = c[1], n = c[2] ||
|
|
847
|
-
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)))) throw
|
|
870
|
+
let t = c[1], n = c[2] || V;
|
|
871
|
+
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)))) throw W;
|
|
848
872
|
if (l = this.#n[n], !l) {
|
|
849
|
-
if (Object.keys(this.#n).some((e) => e !==
|
|
873
|
+
if (Object.keys(this.#n).some((e) => e !== H && e !== U)) throw W;
|
|
850
874
|
if (a) return;
|
|
851
875
|
l = this.#n[n] = new e(), t !== "" && (l.#t = i.varIndex++);
|
|
852
876
|
}
|
|
853
877
|
!a && t !== "" && r.push([t, l.#t]);
|
|
854
878
|
} else if (l = this.#n[o], !l) {
|
|
855
|
-
if (Object.keys(this.#n).some((e) => e.length > 1 && e !==
|
|
879
|
+
if (Object.keys(this.#n).some((e) => e.length > 1 && e !== H && e !== U)) throw W;
|
|
856
880
|
if (a) return;
|
|
857
881
|
l = this.#n[o] = new e();
|
|
858
882
|
}
|
|
859
883
|
l.insert(s, n, r, i, a);
|
|
860
884
|
}
|
|
861
885
|
buildRegExpStr() {
|
|
862
|
-
let e = Object.keys(this.#n).sort(
|
|
886
|
+
let e = Object.keys(this.#n).sort(tt).map((e) => {
|
|
863
887
|
let t = this.#n[e];
|
|
864
|
-
return (typeof t.#t == "number" ? `(${e})@${t.#t}` :
|
|
888
|
+
return (typeof t.#t == "number" ? `(${e})@${t.#t}` : et.has(e) ? `\\${e}` : e) + t.buildRegExpStr();
|
|
865
889
|
});
|
|
866
890
|
return typeof this.#e == "number" && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
|
|
867
891
|
}
|
|
868
|
-
},
|
|
892
|
+
}, rt = class {
|
|
869
893
|
#e = { varIndex: 0 };
|
|
870
|
-
#t = new
|
|
894
|
+
#t = new nt();
|
|
871
895
|
insert(e, t, n) {
|
|
872
896
|
let r = [], i = [];
|
|
873
897
|
for (let t = 0;;) {
|
|
@@ -901,29 +925,29 @@ var Qe = class e {
|
|
|
901
925
|
r
|
|
902
926
|
];
|
|
903
927
|
}
|
|
904
|
-
},
|
|
928
|
+
}, it = [
|
|
905
929
|
/^$/,
|
|
906
930
|
[],
|
|
907
931
|
/* @__PURE__ */ Object.create(null)
|
|
908
|
-
],
|
|
909
|
-
function
|
|
910
|
-
return
|
|
932
|
+
], at = /* @__PURE__ */ Object.create(null);
|
|
933
|
+
function ot(e) {
|
|
934
|
+
return at[e] ??= RegExp(e === "*" ? "" : `^${e.replace(/\/\*$|([.\\+*[^\]$()])/g, (e, t) => t ? `\\${t}` : "(?:|/.*)")}$`);
|
|
911
935
|
}
|
|
912
|
-
function
|
|
913
|
-
|
|
936
|
+
function st() {
|
|
937
|
+
at = /* @__PURE__ */ Object.create(null);
|
|
914
938
|
}
|
|
915
|
-
function
|
|
916
|
-
let t = new
|
|
917
|
-
if (e.length === 0) return
|
|
939
|
+
function ct(e) {
|
|
940
|
+
let t = new rt(), n = [];
|
|
941
|
+
if (e.length === 0) return it;
|
|
918
942
|
let r = e.map((e) => [!/\*|\/:/.test(e[0]), ...e]).sort(([e, t], [n, r]) => e ? 1 : n ? -1 : t.length - r.length), i = /* @__PURE__ */ Object.create(null);
|
|
919
943
|
for (let e = 0, a = -1, o = r.length; e < o; e++) {
|
|
920
944
|
let [o, s, c] = r[e];
|
|
921
|
-
o ? i[s] = [c.map(([e]) => [e, /* @__PURE__ */ Object.create(null)]),
|
|
945
|
+
o ? i[s] = [c.map(([e]) => [e, /* @__PURE__ */ Object.create(null)]), Qe] : a++;
|
|
922
946
|
let l;
|
|
923
947
|
try {
|
|
924
948
|
l = t.insert(s, a, o);
|
|
925
949
|
} catch (e) {
|
|
926
|
-
throw e ===
|
|
950
|
+
throw e === W ? new qe(s) : e;
|
|
927
951
|
}
|
|
928
952
|
o || (n[a] = c.map(([e, t]) => {
|
|
929
953
|
let n = /* @__PURE__ */ Object.create(null);
|
|
@@ -949,12 +973,12 @@ function it(e) {
|
|
|
949
973
|
i
|
|
950
974
|
];
|
|
951
975
|
}
|
|
952
|
-
function
|
|
976
|
+
function G(e, t) {
|
|
953
977
|
if (e) {
|
|
954
|
-
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (
|
|
978
|
+
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (ot(n).test(t)) return [...e[n]];
|
|
955
979
|
}
|
|
956
980
|
}
|
|
957
|
-
var
|
|
981
|
+
var lt = class {
|
|
958
982
|
name = "RegExpRouter";
|
|
959
983
|
#e;
|
|
960
984
|
#t;
|
|
@@ -963,7 +987,7 @@ var at = class {
|
|
|
963
987
|
}
|
|
964
988
|
add(e, t, n) {
|
|
965
989
|
let r = this.#e, i = this.#t;
|
|
966
|
-
if (!r || !i) throw Error(
|
|
990
|
+
if (!r || !i) throw Error(Ke);
|
|
967
991
|
r[e] || [r, i].forEach((t) => {
|
|
968
992
|
t[e] = /* @__PURE__ */ Object.create(null), Object.keys(t.ALL).forEach((n) => {
|
|
969
993
|
t[e][n] = [...t.ALL[n]];
|
|
@@ -971,10 +995,10 @@ var at = class {
|
|
|
971
995
|
}), t === "/*" && (t = "*");
|
|
972
996
|
let a = (t.match(/\/:/g) || []).length;
|
|
973
997
|
if (/\*$/.test(t)) {
|
|
974
|
-
let o =
|
|
998
|
+
let o = ot(t);
|
|
975
999
|
e === "ALL" ? Object.keys(r).forEach((e) => {
|
|
976
|
-
r[e][t] ||=
|
|
977
|
-
}) : r[e][t] ||=
|
|
1000
|
+
r[e][t] ||= G(r[e], t) || G(r.ALL, t) || [];
|
|
1001
|
+
}) : r[e][t] ||= G(r[e], t) || G(r.ALL, t) || [], Object.keys(r).forEach((t) => {
|
|
978
1002
|
(e === "ALL" || e === t) && Object.keys(r[t]).forEach((e) => {
|
|
979
1003
|
o.test(e) && r[t][e].push([n, a]);
|
|
980
1004
|
});
|
|
@@ -983,29 +1007,29 @@ var at = class {
|
|
|
983
1007
|
});
|
|
984
1008
|
return;
|
|
985
1009
|
}
|
|
986
|
-
let o =
|
|
1010
|
+
let o = je(t) || [t];
|
|
987
1011
|
for (let t = 0, s = o.length; t < s; t++) {
|
|
988
1012
|
let c = o[t];
|
|
989
1013
|
Object.keys(i).forEach((o) => {
|
|
990
|
-
(e === "ALL" || e === o) && (i[o][c] ||= [...
|
|
1014
|
+
(e === "ALL" || e === o) && (i[o][c] ||= [...G(r[o], c) || G(r.ALL, c) || []], i[o][c].push([n, a - s + t + 1]));
|
|
991
1015
|
});
|
|
992
1016
|
}
|
|
993
1017
|
}
|
|
994
|
-
match =
|
|
1018
|
+
match = $e;
|
|
995
1019
|
buildAllMatchers() {
|
|
996
1020
|
let e = /* @__PURE__ */ Object.create(null);
|
|
997
1021
|
return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach((t) => {
|
|
998
1022
|
e[t] ||= this.#n(t);
|
|
999
|
-
}), this.#e = this.#t = void 0,
|
|
1023
|
+
}), this.#e = this.#t = void 0, st(), e;
|
|
1000
1024
|
}
|
|
1001
1025
|
#n(e) {
|
|
1002
1026
|
let t = [], n = e === "ALL";
|
|
1003
1027
|
return [this.#e, this.#t].forEach((r) => {
|
|
1004
1028
|
let i = r[e] ? Object.keys(r[e]).map((t) => [t, r[e][t]]) : [];
|
|
1005
1029
|
i.length === 0 ? e !== "ALL" && t.push(...Object.keys(r.ALL).map((e) => [e, r.ALL[e]])) : (n ||= !0, t.push(...i));
|
|
1006
|
-
}), n ?
|
|
1030
|
+
}), n ? ct(t) : null;
|
|
1007
1031
|
}
|
|
1008
|
-
},
|
|
1032
|
+
}, ut = class {
|
|
1009
1033
|
name = "SmartRouter";
|
|
1010
1034
|
#e = [];
|
|
1011
1035
|
#t = [];
|
|
@@ -1013,7 +1037,7 @@ var at = class {
|
|
|
1013
1037
|
this.#e = e.routers;
|
|
1014
1038
|
}
|
|
1015
1039
|
add(e, t, n) {
|
|
1016
|
-
if (!this.#t) throw Error(
|
|
1040
|
+
if (!this.#t) throw Error(Ke);
|
|
1017
1041
|
this.#t.push([
|
|
1018
1042
|
e,
|
|
1019
1043
|
t,
|
|
@@ -1029,7 +1053,7 @@ var at = class {
|
|
|
1029
1053
|
for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
|
|
1030
1054
|
o = i.match(e, t);
|
|
1031
1055
|
} catch (e) {
|
|
1032
|
-
if (e instanceof
|
|
1056
|
+
if (e instanceof qe) continue;
|
|
1033
1057
|
throw e;
|
|
1034
1058
|
}
|
|
1035
1059
|
this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
|
|
@@ -1042,15 +1066,15 @@ var at = class {
|
|
|
1042
1066
|
if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
|
|
1043
1067
|
return this.#e[0];
|
|
1044
1068
|
}
|
|
1045
|
-
},
|
|
1069
|
+
}, K = /* @__PURE__ */ Object.create(null), dt = (e) => {
|
|
1046
1070
|
for (let t in e) return !0;
|
|
1047
1071
|
return !1;
|
|
1048
|
-
},
|
|
1072
|
+
}, ft = class e {
|
|
1049
1073
|
#e;
|
|
1050
1074
|
#t;
|
|
1051
1075
|
#n;
|
|
1052
1076
|
#r = 0;
|
|
1053
|
-
#i =
|
|
1077
|
+
#i = K;
|
|
1054
1078
|
constructor(e, t, n) {
|
|
1055
1079
|
if (this.#t = n || /* @__PURE__ */ Object.create(null), this.#e = [], e && t) {
|
|
1056
1080
|
let n = /* @__PURE__ */ Object.create(null);
|
|
@@ -1064,9 +1088,9 @@ var at = class {
|
|
|
1064
1088
|
}
|
|
1065
1089
|
insert(t, n, r) {
|
|
1066
1090
|
this.#r = ++this.#r;
|
|
1067
|
-
let i = this, a =
|
|
1091
|
+
let i = this, a = Ce(n), o = [];
|
|
1068
1092
|
for (let t = 0, n = a.length; t < n; t++) {
|
|
1069
|
-
let n = a[t], r = a[t + 1], s =
|
|
1093
|
+
let n = a[t], r = a[t + 1], s = Ee(n, r), c = Array.isArray(s) ? s[0] : n;
|
|
1070
1094
|
if (c in i.#t) {
|
|
1071
1095
|
i = i.#t[c], s && o.push(s[1]);
|
|
1072
1096
|
continue;
|
|
@@ -1082,7 +1106,7 @@ var at = class {
|
|
|
1082
1106
|
#a(e, t, n, r, i) {
|
|
1083
1107
|
for (let a = 0, o = t.#e.length; a < o; a++) {
|
|
1084
1108
|
let o = t.#e[a], s = o[n] || o.ALL, c = {};
|
|
1085
|
-
if (s !== void 0 && (s.params = /* @__PURE__ */ Object.create(null), e.push(s), r !==
|
|
1109
|
+
if (s !== void 0 && (s.params = /* @__PURE__ */ Object.create(null), e.push(s), r !== K || i && i !== K)) for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
|
|
1086
1110
|
let t = s.possibleKeys[e], n = c[s.score];
|
|
1087
1111
|
s.params[t] = i?.[t] && !n ? i[t] : r[t] ?? i?.[t], c[s.score] = !0;
|
|
1088
1112
|
}
|
|
@@ -1090,15 +1114,15 @@ var at = class {
|
|
|
1090
1114
|
}
|
|
1091
1115
|
search(e, t) {
|
|
1092
1116
|
let n = [];
|
|
1093
|
-
this.#i =
|
|
1094
|
-
let r = [this], i =
|
|
1117
|
+
this.#i = K;
|
|
1118
|
+
let r = [this], i = Se(t), a = [], o = i.length, s = null;
|
|
1095
1119
|
for (let c = 0; c < o; c++) {
|
|
1096
1120
|
let l = i[c], u = c === o - 1, d = [];
|
|
1097
1121
|
for (let f = 0, p = r.length; f < p; f++) {
|
|
1098
1122
|
let p = r[f], m = p.#t[l];
|
|
1099
1123
|
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));
|
|
1100
1124
|
for (let r = 0, f = p.#n.length; r < f; r++) {
|
|
1101
|
-
let f = p.#n[r], m = p.#i ===
|
|
1125
|
+
let f = p.#n[r], m = p.#i === K ? {} : { ...p.#i };
|
|
1102
1126
|
if (f === "*") {
|
|
1103
1127
|
let t = p.#t["*"];
|
|
1104
1128
|
t && (this.#a(n, t, e, p.#i), t.#i = m, d.push(t));
|
|
@@ -1115,7 +1139,7 @@ var at = class {
|
|
|
1115
1139
|
}
|
|
1116
1140
|
let r = t.substring(s[c]), l = _.exec(r);
|
|
1117
1141
|
if (l) {
|
|
1118
|
-
if (m[g] = l[0], this.#a(n, v, e, p.#i, m),
|
|
1142
|
+
if (m[g] = l[0], this.#a(n, v, e, p.#i, m), dt(v.#t)) {
|
|
1119
1143
|
v.#i = m;
|
|
1120
1144
|
let e = l[0].match(/\//)?.length ?? 0;
|
|
1121
1145
|
(a[e] ||= []).push(v);
|
|
@@ -1131,14 +1155,14 @@ var at = class {
|
|
|
1131
1155
|
}
|
|
1132
1156
|
return n.length > 1 && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
|
|
1133
1157
|
}
|
|
1134
|
-
},
|
|
1158
|
+
}, pt = class {
|
|
1135
1159
|
name = "TrieRouter";
|
|
1136
1160
|
#e;
|
|
1137
1161
|
constructor() {
|
|
1138
|
-
this.#e = new
|
|
1162
|
+
this.#e = new ft();
|
|
1139
1163
|
}
|
|
1140
1164
|
add(e, t, n) {
|
|
1141
|
-
let r =
|
|
1165
|
+
let r = je(t);
|
|
1142
1166
|
if (r) {
|
|
1143
1167
|
for (let t = 0, i = r.length; t < i; t++) this.#e.insert(e, r[t], n);
|
|
1144
1168
|
return;
|
|
@@ -1148,43 +1172,43 @@ var at = class {
|
|
|
1148
1172
|
match(e, t) {
|
|
1149
1173
|
return this.#e.search(e, t);
|
|
1150
1174
|
}
|
|
1151
|
-
},
|
|
1175
|
+
}, mt = class extends Ze {
|
|
1152
1176
|
constructor(e = {}) {
|
|
1153
|
-
super(e), this.router = e.router ?? new
|
|
1177
|
+
super(e), this.router = e.router ?? new ut({ routers: [new lt(), new pt()] });
|
|
1154
1178
|
}
|
|
1155
1179
|
};
|
|
1156
1180
|
//#endregion
|
|
1157
1181
|
//#region src/coordinator-invites.ts
|
|
1158
|
-
function
|
|
1182
|
+
function ht(e) {
|
|
1159
1183
|
let t = "";
|
|
1160
1184
|
for (let n of e) t += String.fromCharCode(n);
|
|
1161
1185
|
return btoa(t);
|
|
1162
1186
|
}
|
|
1163
|
-
function
|
|
1187
|
+
function gt(e) {
|
|
1164
1188
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
1165
1189
|
for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
|
|
1166
1190
|
return n;
|
|
1167
1191
|
}
|
|
1168
|
-
function
|
|
1192
|
+
function _t(e) {
|
|
1169
1193
|
return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1170
1194
|
}
|
|
1171
|
-
function
|
|
1195
|
+
function vt(e) {
|
|
1172
1196
|
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
1173
1197
|
return t + "=".repeat((4 - t.length % 4) % 4);
|
|
1174
1198
|
}
|
|
1175
|
-
function
|
|
1199
|
+
function yt(e) {
|
|
1176
1200
|
let t = JSON.stringify(e);
|
|
1177
|
-
return
|
|
1201
|
+
return _t(ht(new TextEncoder().encode(t)));
|
|
1178
1202
|
}
|
|
1179
|
-
function
|
|
1180
|
-
let t = new TextDecoder().decode(
|
|
1203
|
+
function bt(e) {
|
|
1204
|
+
let t = new TextDecoder().decode(gt(vt(e))), n = JSON.parse(t);
|
|
1181
1205
|
if (typeof n != "object" || !n) throw Error("invalid invite payload");
|
|
1182
1206
|
return n;
|
|
1183
1207
|
}
|
|
1184
|
-
function
|
|
1208
|
+
function xt(e) {
|
|
1185
1209
|
return `codemem://join?invite=${encodeURIComponent(e)}`;
|
|
1186
1210
|
}
|
|
1187
|
-
function
|
|
1211
|
+
function St(e) {
|
|
1188
1212
|
let t = e.trim();
|
|
1189
1213
|
if (t.startsWith("codemem://")) {
|
|
1190
1214
|
let e = new URL(t).searchParams.get("invite") ?? "";
|
|
@@ -1195,44 +1219,44 @@ function gt(e) {
|
|
|
1195
1219
|
}
|
|
1196
1220
|
//#endregion
|
|
1197
1221
|
//#region src/project-invite-acceptance.ts
|
|
1198
|
-
var
|
|
1199
|
-
code =
|
|
1200
|
-
detail =
|
|
1222
|
+
var Ct = "pending_setup", wt = "project_sync_enablement_failed", Tt = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", Et = class extends Error {
|
|
1223
|
+
code = wt;
|
|
1224
|
+
detail = Tt;
|
|
1201
1225
|
constructor(e) {
|
|
1202
|
-
super(
|
|
1226
|
+
super(Tt, e), this.name = "ProjectSyncEnablementError";
|
|
1203
1227
|
}
|
|
1204
1228
|
};
|
|
1205
|
-
function
|
|
1229
|
+
function Dt(e) {
|
|
1206
1230
|
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.";
|
|
1207
1231
|
}
|
|
1208
1232
|
//#endregion
|
|
1209
1233
|
//#region src/scope-resolution.ts
|
|
1210
|
-
var
|
|
1211
|
-
function
|
|
1234
|
+
var Ot = "local-default", kt = "legacy-shared-review";
|
|
1235
|
+
function q(e) {
|
|
1212
1236
|
return e?.trim() || null;
|
|
1213
1237
|
}
|
|
1214
|
-
function
|
|
1238
|
+
function J(e) {
|
|
1215
1239
|
return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
|
|
1216
1240
|
}
|
|
1217
|
-
function
|
|
1218
|
-
return
|
|
1241
|
+
function At(t) {
|
|
1242
|
+
return J(e(t));
|
|
1219
1243
|
}
|
|
1220
|
-
function
|
|
1221
|
-
let t =
|
|
1222
|
-
return t ?
|
|
1244
|
+
function jt(e) {
|
|
1245
|
+
let t = q(e);
|
|
1246
|
+
return t ? J(t) : null;
|
|
1223
1247
|
}
|
|
1224
|
-
function
|
|
1248
|
+
function Mt(e) {
|
|
1225
1249
|
let n = [
|
|
1226
1250
|
e.cwd,
|
|
1227
1251
|
e.project,
|
|
1228
1252
|
e.workspaceId
|
|
1229
|
-
].map((e) =>
|
|
1253
|
+
].map((e) => q(e)).find((e) => e != null);
|
|
1230
1254
|
return `unmapped:${t("sha256").update(n ?? "unknown", "utf8").digest("hex")}`;
|
|
1231
1255
|
}
|
|
1232
|
-
function
|
|
1233
|
-
let t =
|
|
1256
|
+
function Nt(e) {
|
|
1257
|
+
let t = q(e.gitRemote), n = q(e.gitBranch), r = q(e.cwd), i = q(e.workspaceId), a = q(e.project);
|
|
1234
1258
|
if (t) {
|
|
1235
|
-
let r =
|
|
1259
|
+
let r = J(t);
|
|
1236
1260
|
return e.branchScoped && n ? {
|
|
1237
1261
|
value: `${r}:${n}`,
|
|
1238
1262
|
source: "git_remote_branch",
|
|
@@ -1244,49 +1268,49 @@ function Dt(e) {
|
|
|
1244
1268
|
};
|
|
1245
1269
|
}
|
|
1246
1270
|
return r ? {
|
|
1247
|
-
value:
|
|
1271
|
+
value: At(r),
|
|
1248
1272
|
source: "cwd",
|
|
1249
1273
|
displayProject: a
|
|
1250
1274
|
} : i ? {
|
|
1251
|
-
value:
|
|
1275
|
+
value: J(i),
|
|
1252
1276
|
source: "workspace_id",
|
|
1253
1277
|
displayProject: a
|
|
1254
1278
|
} : {
|
|
1255
|
-
value:
|
|
1279
|
+
value: Mt(e),
|
|
1256
1280
|
source: "unmapped",
|
|
1257
1281
|
displayProject: a
|
|
1258
1282
|
};
|
|
1259
1283
|
}
|
|
1260
|
-
function
|
|
1284
|
+
function Pt(e) {
|
|
1261
1285
|
return !/[\\/:]/.test(e);
|
|
1262
1286
|
}
|
|
1263
|
-
function
|
|
1287
|
+
function Ft(e) {
|
|
1264
1288
|
return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
1265
1289
|
}
|
|
1266
|
-
function
|
|
1290
|
+
function It(e) {
|
|
1267
1291
|
return e.replace(/[*?]/g, "").length;
|
|
1268
1292
|
}
|
|
1269
|
-
function
|
|
1270
|
-
let n =
|
|
1271
|
-
return !n ||
|
|
1293
|
+
function Lt(e, t) {
|
|
1294
|
+
let n = J(t);
|
|
1295
|
+
return !n || Pt(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Ft(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
|
|
1272
1296
|
}
|
|
1273
|
-
function
|
|
1297
|
+
function Rt(e) {
|
|
1274
1298
|
return e.mapping.priority ?? 0;
|
|
1275
1299
|
}
|
|
1276
|
-
function
|
|
1277
|
-
let t =
|
|
1300
|
+
function zt(e) {
|
|
1301
|
+
let t = q(e.mapping.updated_at);
|
|
1278
1302
|
if (!t) return 0;
|
|
1279
1303
|
let n = Date.parse(t);
|
|
1280
1304
|
return Number.isFinite(n) ? n : 0;
|
|
1281
1305
|
}
|
|
1282
|
-
function
|
|
1283
|
-
return
|
|
1306
|
+
function Bt(e, t) {
|
|
1307
|
+
return Rt(t) - Rt(e) || t.specificity - e.specificity || zt(t) - zt(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
|
|
1284
1308
|
}
|
|
1285
|
-
function
|
|
1286
|
-
return e.toSorted(
|
|
1309
|
+
function Vt(e) {
|
|
1310
|
+
return e.toSorted(Bt)[0] ?? null;
|
|
1287
1311
|
}
|
|
1288
|
-
function
|
|
1289
|
-
let t =
|
|
1312
|
+
function Ht(e) {
|
|
1313
|
+
let t = Nt(e), n = q(e.explicitScopeId);
|
|
1290
1314
|
if (n) return {
|
|
1291
1315
|
scopeId: n,
|
|
1292
1316
|
reason: "explicit_override",
|
|
@@ -1301,7 +1325,7 @@ function It(e) {
|
|
|
1301
1325
|
mapping: null,
|
|
1302
1326
|
matchedPattern: null
|
|
1303
1327
|
};
|
|
1304
|
-
let r = e.mappings ?? [], i =
|
|
1328
|
+
let r = e.mappings ?? [], i = Vt(r.filter((e) => jt(e.workspace_identity) === t.value).map((e) => ({
|
|
1305
1329
|
mapping: e,
|
|
1306
1330
|
matchedPattern: null,
|
|
1307
1331
|
specificity: t.value.length
|
|
@@ -1313,13 +1337,13 @@ function It(e) {
|
|
|
1313
1337
|
mapping: i.mapping,
|
|
1314
1338
|
matchedPattern: null
|
|
1315
1339
|
};
|
|
1316
|
-
let a =
|
|
1317
|
-
if (
|
|
1318
|
-
let n =
|
|
1319
|
-
return !n || !
|
|
1340
|
+
let a = Vt(r.flatMap((e) => {
|
|
1341
|
+
if (q(e.workspace_identity)) return [];
|
|
1342
|
+
let n = q(e.project_pattern);
|
|
1343
|
+
return !n || !Lt(t.value, n) ? [] : [{
|
|
1320
1344
|
mapping: e,
|
|
1321
|
-
matchedPattern:
|
|
1322
|
-
specificity:
|
|
1345
|
+
matchedPattern: J(n),
|
|
1346
|
+
specificity: It(n)
|
|
1323
1347
|
}];
|
|
1324
1348
|
}));
|
|
1325
1349
|
return a ? {
|
|
@@ -1336,11 +1360,11 @@ function It(e) {
|
|
|
1336
1360
|
matchedPattern: null
|
|
1337
1361
|
};
|
|
1338
1362
|
}
|
|
1339
|
-
function
|
|
1363
|
+
function Ut(e, t) {
|
|
1340
1364
|
let n = new Set([
|
|
1341
1365
|
"",
|
|
1342
|
-
|
|
1343
|
-
|
|
1366
|
+
Ot,
|
|
1367
|
+
kt
|
|
1344
1368
|
]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
|
|
1345
1369
|
for (let e of r) e.scope_id != null && n.add(e.scope_id);
|
|
1346
1370
|
let i = e.prepare("SELECT sm.scope_id AS scope_id\n FROM scope_memberships sm\n JOIN replication_scopes rs ON rs.scope_id = sm.scope_id\n WHERE sm.device_id = ?\n AND sm.status = 'active'\n AND rs.status = 'active'\n AND sm.membership_epoch >= rs.membership_epoch").all(t);
|
|
@@ -1349,29 +1373,29 @@ function Lt(e, t) {
|
|
|
1349
1373
|
}
|
|
1350
1374
|
//#endregion
|
|
1351
1375
|
//#region src/project-share-intent.ts
|
|
1352
|
-
var
|
|
1353
|
-
function
|
|
1376
|
+
var Wt = "existing_and_future";
|
|
1377
|
+
function Gt(e) {
|
|
1354
1378
|
return t("sha256").update(JSON.stringify(e)).digest("hex");
|
|
1355
1379
|
}
|
|
1356
|
-
function
|
|
1357
|
-
return
|
|
1380
|
+
function Kt(e) {
|
|
1381
|
+
return Gt({
|
|
1358
1382
|
v: 1,
|
|
1359
|
-
historyPolicy:
|
|
1383
|
+
historyPolicy: Wt,
|
|
1360
1384
|
projects: e.map((e) => ({
|
|
1361
1385
|
canonicalIdentity: e.canonicalIdentity,
|
|
1362
1386
|
existingMemoryCount: e.existingMemoryCount
|
|
1363
1387
|
})).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
|
|
1364
1388
|
});
|
|
1365
1389
|
}
|
|
1366
|
-
function
|
|
1367
|
-
return
|
|
1390
|
+
function qt(e) {
|
|
1391
|
+
return Kt(e.map((e) => ({
|
|
1368
1392
|
canonicalIdentity: e.canonical_identity,
|
|
1369
1393
|
displayName: e.display_name,
|
|
1370
1394
|
identitySource: "coordinator_acceptance",
|
|
1371
1395
|
existingMemoryCount: e.existing_memory_count
|
|
1372
1396
|
})));
|
|
1373
1397
|
}
|
|
1374
|
-
function
|
|
1398
|
+
function Jt(e) {
|
|
1375
1399
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
|
|
1376
1400
|
let t = e.map((e) => {
|
|
1377
1401
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
|
|
@@ -1379,11 +1403,11 @@ function Ht(e) {
|
|
|
1379
1403
|
if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
|
|
1380
1404
|
let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
|
|
1381
1405
|
try {
|
|
1382
|
-
a =
|
|
1406
|
+
a = x(i, "project_name");
|
|
1383
1407
|
} catch {
|
|
1384
1408
|
throw Error("operation_intent_invalid");
|
|
1385
1409
|
}
|
|
1386
|
-
let o = t.existing_memory_count, s =
|
|
1410
|
+
let o = t.existing_memory_count, s = Nt({ gitRemote: r }).value;
|
|
1387
1411
|
if (!r || r !== n || r.length > 2048 || r.startsWith("unmapped:") || s !== r || a !== i || !Number.isSafeInteger(o) || Number(o) < 0 || /[\p{Cc}\p{Cf}]/u.test(r) || /[\p{Cc}\p{Cf}]/u.test(a)) throw Error("operation_intent_invalid");
|
|
1388
1412
|
return {
|
|
1389
1413
|
canonical_identity: r,
|
|
@@ -1396,20 +1420,20 @@ function Ht(e) {
|
|
|
1396
1420
|
}
|
|
1397
1421
|
//#endregion
|
|
1398
1422
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
|
|
1399
|
-
function
|
|
1423
|
+
function Yt(e) {
|
|
1400
1424
|
let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
|
|
1401
1425
|
return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
|
|
1402
1426
|
}
|
|
1403
|
-
function
|
|
1404
|
-
let [e, t] =
|
|
1427
|
+
function Y() {
|
|
1428
|
+
let [e, t] = Yt();
|
|
1405
1429
|
return e * 1e3 + Math.floor(t / 1e6);
|
|
1406
1430
|
}
|
|
1407
|
-
function
|
|
1431
|
+
function Xt(e) {
|
|
1408
1432
|
return new Promise((t) => setTimeout(t, e));
|
|
1409
1433
|
}
|
|
1410
1434
|
//#endregion
|
|
1411
1435
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
|
|
1412
|
-
var
|
|
1436
|
+
var Zt = class {
|
|
1413
1437
|
bucketSize;
|
|
1414
1438
|
tokensPerInterval;
|
|
1415
1439
|
interval;
|
|
@@ -1436,13 +1460,13 @@ var Gt = class {
|
|
|
1436
1460
|
default: throw Error("Invalid interval " + n);
|
|
1437
1461
|
}
|
|
1438
1462
|
else this.interval = n;
|
|
1439
|
-
this.parentBucket = r, this.content = 0, this.lastDrip =
|
|
1463
|
+
this.parentBucket = r, this.content = 0, this.lastDrip = Y();
|
|
1440
1464
|
}
|
|
1441
1465
|
async removeTokens(e) {
|
|
1442
1466
|
if (this.bucketSize === 0) return Infinity;
|
|
1443
1467
|
if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
|
|
1444
1468
|
this.drip();
|
|
1445
|
-
let t = async () => (await
|
|
1469
|
+
let t = async () => (await Xt(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
|
|
1446
1470
|
if (e > this.content) return t();
|
|
1447
1471
|
if (this.parentBucket != null) {
|
|
1448
1472
|
let n = await this.parentBucket.removeTokens(e);
|
|
@@ -1457,30 +1481,30 @@ var Gt = class {
|
|
|
1457
1481
|
let e = this.content;
|
|
1458
1482
|
return this.content = this.bucketSize, this.content > e;
|
|
1459
1483
|
}
|
|
1460
|
-
let e =
|
|
1484
|
+
let e = Y(), t = Math.max(e - this.lastDrip, 0);
|
|
1461
1485
|
this.lastDrip = e;
|
|
1462
1486
|
let n = t * (this.tokensPerInterval / this.interval), r = this.content;
|
|
1463
1487
|
return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
|
|
1464
1488
|
}
|
|
1465
|
-
},
|
|
1489
|
+
}, Qt = class {
|
|
1466
1490
|
tokenBucket;
|
|
1467
1491
|
curIntervalStart;
|
|
1468
1492
|
tokensThisInterval;
|
|
1469
1493
|
fireImmediately;
|
|
1470
1494
|
constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
|
|
1471
|
-
this.tokenBucket = new
|
|
1495
|
+
this.tokenBucket = new Zt({
|
|
1472
1496
|
bucketSize: e,
|
|
1473
1497
|
tokensPerInterval: e,
|
|
1474
1498
|
interval: t
|
|
1475
|
-
}), this.tokenBucket.content = e, this.curIntervalStart =
|
|
1499
|
+
}), this.tokenBucket.content = e, this.curIntervalStart = Y(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
|
|
1476
1500
|
}
|
|
1477
1501
|
async removeTokens(e) {
|
|
1478
1502
|
if (e > this.tokenBucket.bucketSize) throw Error(`Requested tokens ${e} exceeds maximum tokens per interval ${this.tokenBucket.bucketSize}`);
|
|
1479
|
-
let t =
|
|
1503
|
+
let t = Y();
|
|
1480
1504
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
|
|
1481
1505
|
if (this.fireImmediately) return -1;
|
|
1482
1506
|
{
|
|
1483
|
-
await
|
|
1507
|
+
await Xt(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
|
|
1484
1508
|
let n = await this.tokenBucket.removeTokens(e);
|
|
1485
1509
|
return this.tokensThisInterval += e, n;
|
|
1486
1510
|
}
|
|
@@ -1490,7 +1514,7 @@ var Gt = class {
|
|
|
1490
1514
|
}
|
|
1491
1515
|
tryRemoveTokens(e) {
|
|
1492
1516
|
if (e > this.tokenBucket.bucketSize) return !1;
|
|
1493
|
-
let t =
|
|
1517
|
+
let t = Y();
|
|
1494
1518
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) return !1;
|
|
1495
1519
|
let n = this.tokenBucket.tryRemoveTokens(e);
|
|
1496
1520
|
return n && (this.tokensThisInterval += e), n;
|
|
@@ -1501,7 +1525,7 @@ var Gt = class {
|
|
|
1501
1525
|
};
|
|
1502
1526
|
//#endregion
|
|
1503
1527
|
//#region src/request-rate-limit.ts
|
|
1504
|
-
function
|
|
1528
|
+
function $t(e = {}) {
|
|
1505
1529
|
let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
|
|
1506
1530
|
function a(e) {
|
|
1507
1531
|
return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
|
|
@@ -1518,7 +1542,7 @@ function qt(e = {}) {
|
|
|
1518
1542
|
o(l);
|
|
1519
1543
|
let u = `${c}:${e}`, d = r.get(u);
|
|
1520
1544
|
return d || (d = {
|
|
1521
|
-
limiter: new
|
|
1545
|
+
limiter: new Qt({
|
|
1522
1546
|
tokensPerInterval: c,
|
|
1523
1547
|
interval: t,
|
|
1524
1548
|
fireImmediately: !0
|
|
@@ -1535,8 +1559,8 @@ function qt(e = {}) {
|
|
|
1535
1559
|
}
|
|
1536
1560
|
//#endregion
|
|
1537
1561
|
//#region src/scope-membership-semantics.ts
|
|
1538
|
-
var
|
|
1539
|
-
function
|
|
1562
|
+
var en = "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.";
|
|
1563
|
+
function tn(e) {
|
|
1540
1564
|
let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
|
|
1541
1565
|
return t == null || n == null ? {
|
|
1542
1566
|
membership_epoch: t,
|
|
@@ -1550,19 +1574,19 @@ function Yt(e) {
|
|
|
1550
1574
|
reason: t < n ? "stale_epoch" : "current"
|
|
1551
1575
|
};
|
|
1552
1576
|
}
|
|
1553
|
-
function
|
|
1577
|
+
function nn(e) {
|
|
1554
1578
|
return {
|
|
1555
1579
|
scope_id: e.scopeId,
|
|
1556
1580
|
device_id: e.deviceId,
|
|
1557
1581
|
membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
|
|
1558
1582
|
prevents_future_sync: !0,
|
|
1559
1583
|
deletes_already_copied_data: !1,
|
|
1560
|
-
message:
|
|
1584
|
+
message: en
|
|
1561
1585
|
};
|
|
1562
1586
|
}
|
|
1563
1587
|
//#endregion
|
|
1564
1588
|
//#region src/sync-auth-constants.ts
|
|
1565
|
-
var
|
|
1589
|
+
var rn = 300, an = 64 * 1024, X = "X-Codemem-Coordinator-Admin", on = "X-Codemem-Coordinator-Admin-Actor", sn = 120, cn = 30;
|
|
1566
1590
|
function Z(e, t) {
|
|
1567
1591
|
let n = t.adminSecret();
|
|
1568
1592
|
if (!n) return {
|
|
@@ -1581,14 +1605,14 @@ function Z(e, t) {
|
|
|
1581
1605
|
error: "missing_admin_header"
|
|
1582
1606
|
};
|
|
1583
1607
|
}
|
|
1584
|
-
function
|
|
1608
|
+
function ln(e) {
|
|
1585
1609
|
let t = new URL(e);
|
|
1586
1610
|
return t.search ? `${t.pathname}${t.search}` : t.pathname;
|
|
1587
1611
|
}
|
|
1588
|
-
async function
|
|
1612
|
+
async function un(e, t, n, r) {
|
|
1589
1613
|
return await e.recordNonce(t, n, r);
|
|
1590
1614
|
}
|
|
1591
|
-
async function
|
|
1615
|
+
async function dn(e, t) {
|
|
1592
1616
|
await e.cleanupNonces(t);
|
|
1593
1617
|
}
|
|
1594
1618
|
async function Q(e, t, n, r) {
|
|
@@ -1624,7 +1648,7 @@ async function Q(e, t, n, r) {
|
|
|
1624
1648
|
try {
|
|
1625
1649
|
u = await n({
|
|
1626
1650
|
method: r.method,
|
|
1627
|
-
pathWithQuery:
|
|
1651
|
+
pathWithQuery: ln(r.url),
|
|
1628
1652
|
bodyBytes: r.body,
|
|
1629
1653
|
timestamp: o,
|
|
1630
1654
|
nonce: s,
|
|
@@ -1645,7 +1669,7 @@ async function Q(e, t, n, r) {
|
|
|
1645
1669
|
enrollment: null
|
|
1646
1670
|
};
|
|
1647
1671
|
let d = t.now();
|
|
1648
|
-
return await
|
|
1672
|
+
return await un(e, i, s, d) ? (await dn(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 300 * 2 * 1e3)).toISOString()), {
|
|
1649
1673
|
ok: !0,
|
|
1650
1674
|
error: "ok",
|
|
1651
1675
|
enrollment: c
|
|
@@ -1658,9 +1682,9 @@ async function Q(e, t, n, r) {
|
|
|
1658
1682
|
function $(e) {
|
|
1659
1683
|
return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
|
|
1660
1684
|
}
|
|
1661
|
-
function
|
|
1685
|
+
function fn(e) {
|
|
1662
1686
|
if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
|
|
1663
|
-
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, a = e.requestRateLimit ?? {}, o = a.limiter ??
|
|
1687
|
+
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, a = e.requestRateLimit ?? {}, o = a.limiter ?? $t(), s = Math.max(1, Math.trunc(a.readLimit ?? sn)), c = Math.max(1, Math.trunc(a.mutationLimit ?? cn)), l = Math.max(1, Math.trunc(a.unauthenticatedReadLimit ?? Math.min(20, s))), u = Math.max(1, Math.trunc(a.unauthenticatedMutationLimit ?? Math.min(10, c))), d = new mt(), f = new TextDecoder();
|
|
1664
1688
|
function p(e, t, n) {
|
|
1665
1689
|
let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = o.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? s : c : r ? l : u);
|
|
1666
1690
|
return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
|
|
@@ -1670,7 +1694,7 @@ function an(e) {
|
|
|
1670
1694
|
}
|
|
1671
1695
|
async function m(e) {
|
|
1672
1696
|
let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
1673
|
-
if (Number.isFinite(t) && t >
|
|
1697
|
+
if (Number.isFinite(t) && t > an) return null;
|
|
1674
1698
|
let n = e.req.raw.body;
|
|
1675
1699
|
if (!n) return new Uint8Array();
|
|
1676
1700
|
let r = n.getReader(), i = [], a = 0;
|
|
@@ -1679,7 +1703,7 @@ function an(e) {
|
|
|
1679
1703
|
let { done: e, value: t } = await r.read();
|
|
1680
1704
|
if (e) break;
|
|
1681
1705
|
if (t) {
|
|
1682
|
-
if (a += t.byteLength, a >
|
|
1706
|
+
if (a += t.byteLength, a > an) return await r.cancel(), null;
|
|
1683
1707
|
i.push(t);
|
|
1684
1708
|
}
|
|
1685
1709
|
}
|
|
@@ -1698,14 +1722,14 @@ function an(e) {
|
|
|
1698
1722
|
return null;
|
|
1699
1723
|
}
|
|
1700
1724
|
}
|
|
1701
|
-
function
|
|
1725
|
+
function g(e, t) {
|
|
1702
1726
|
let n = e[t];
|
|
1703
1727
|
return n == null ? null : String(n).trim() || null;
|
|
1704
1728
|
}
|
|
1705
|
-
function
|
|
1729
|
+
function _(e) {
|
|
1706
1730
|
return e?.trim() || null;
|
|
1707
1731
|
}
|
|
1708
|
-
function
|
|
1732
|
+
function v(e, t) {
|
|
1709
1733
|
let n = e[t];
|
|
1710
1734
|
if (n == null || n === "") return null;
|
|
1711
1735
|
if (typeof n != "number" && typeof n != "string") return NaN;
|
|
@@ -1718,45 +1742,45 @@ function an(e) {
|
|
|
1718
1742
|
let r = n;
|
|
1719
1743
|
return Number.isFinite(r) ? Math.trunc(r) : NaN;
|
|
1720
1744
|
}
|
|
1721
|
-
function
|
|
1745
|
+
function y(e) {
|
|
1722
1746
|
return [
|
|
1723
1747
|
"1",
|
|
1724
1748
|
"true",
|
|
1725
1749
|
"yes"
|
|
1726
1750
|
].includes(String(e ?? "").trim().toLowerCase());
|
|
1727
1751
|
}
|
|
1728
|
-
function
|
|
1752
|
+
function b(e) {
|
|
1729
1753
|
try {
|
|
1730
|
-
return
|
|
1754
|
+
return Jt(JSON.parse(e ?? ""));
|
|
1731
1755
|
} catch {
|
|
1732
1756
|
throw Error("operation_intent_invalid");
|
|
1733
1757
|
}
|
|
1734
1758
|
}
|
|
1735
|
-
function
|
|
1759
|
+
function x(e) {
|
|
1736
1760
|
let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
|
|
1737
1761
|
if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
|
|
1738
|
-
let r =
|
|
1739
|
-
if (
|
|
1762
|
+
let r = b(e.project_intent_json);
|
|
1763
|
+
if (qt(r) !== n) throw Error("operation_intent_invalid");
|
|
1740
1764
|
return {
|
|
1741
1765
|
operation_id: t,
|
|
1742
1766
|
reviewed_project_set_digest: n,
|
|
1743
1767
|
projects: r
|
|
1744
1768
|
};
|
|
1745
1769
|
}
|
|
1746
|
-
function
|
|
1770
|
+
function S(e) {
|
|
1747
1771
|
try {
|
|
1748
|
-
return
|
|
1772
|
+
return ee(JSON.parse(e ?? ""));
|
|
1749
1773
|
} catch {
|
|
1750
1774
|
throw Error("operation_intent_invalid");
|
|
1751
1775
|
}
|
|
1752
1776
|
}
|
|
1753
|
-
async function
|
|
1777
|
+
async function w(e, t, n) {
|
|
1754
1778
|
if (!t) return n.json({ error: "group_id_required" }, 400);
|
|
1755
1779
|
let r = await e.getGroup(t);
|
|
1756
1780
|
return r ? r.archived_at ? n.json({ error: "group_archived" }, 409) : null : n.json({ error: "group_not_found" }, 404);
|
|
1757
1781
|
}
|
|
1758
|
-
async function
|
|
1759
|
-
let i = await
|
|
1782
|
+
async function T(e, t, n, r) {
|
|
1783
|
+
let i = await w(e, t, r);
|
|
1760
1784
|
if (i) return {
|
|
1761
1785
|
scope: null,
|
|
1762
1786
|
response: i
|
|
@@ -1777,7 +1801,7 @@ function an(e) {
|
|
|
1777
1801
|
response: r.json({ error: "scope_not_found" }, 404)
|
|
1778
1802
|
};
|
|
1779
1803
|
}
|
|
1780
|
-
async function
|
|
1804
|
+
async function E(e, n, i) {
|
|
1781
1805
|
let a = await Q(e, t, r, {
|
|
1782
1806
|
method: i.req.method,
|
|
1783
1807
|
url: i.req.url,
|
|
@@ -1796,11 +1820,11 @@ function an(e) {
|
|
|
1796
1820
|
response: p(i, String(a.enrollment.device_id), !0)
|
|
1797
1821
|
};
|
|
1798
1822
|
}
|
|
1799
|
-
function
|
|
1823
|
+
function O(e, t) {
|
|
1800
1824
|
return e.status === "active" && e.membership_epoch >= t.membership_epoch;
|
|
1801
1825
|
}
|
|
1802
|
-
async function
|
|
1803
|
-
return (await e.listScopeMemberships(t.scope_id, !1)).some((e) => e.device_id === n &&
|
|
1826
|
+
async function k(e, t, n) {
|
|
1827
|
+
return (await e.listScopeMemberships(t.scope_id, !1)).some((e) => e.device_id === n && O(e, t));
|
|
1804
1828
|
}
|
|
1805
1829
|
return d.post("/v1/presence", async (e) => {
|
|
1806
1830
|
let i = await m(e);
|
|
@@ -1875,14 +1899,14 @@ function an(e) {
|
|
|
1875
1899
|
if (!t) return e.json({ error: "group_id_required" }, 400);
|
|
1876
1900
|
let r = n();
|
|
1877
1901
|
try {
|
|
1878
|
-
let { auth: n, response: i } = await
|
|
1902
|
+
let { auth: n, response: i } = await E(r, t, e);
|
|
1879
1903
|
if (i) return i;
|
|
1880
1904
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
1881
1905
|
let a = await r.listScopes({
|
|
1882
1906
|
groupId: t,
|
|
1883
1907
|
includeInactive: !1
|
|
1884
1908
|
}), o = [];
|
|
1885
|
-
for (let e of a) e.status === "active" && await
|
|
1909
|
+
for (let e of a) e.status === "active" && await k(r, e, String(n.enrollment.device_id)) && o.push(e);
|
|
1886
1910
|
return e.json({ items: o });
|
|
1887
1911
|
} finally {
|
|
1888
1912
|
await r.close();
|
|
@@ -1893,7 +1917,7 @@ function an(e) {
|
|
|
1893
1917
|
if (!r) return e.json({ error: "scope_id_required" }, 400);
|
|
1894
1918
|
let i = n();
|
|
1895
1919
|
try {
|
|
1896
|
-
let { auth: n, response: a } = await
|
|
1920
|
+
let { auth: n, response: a } = await E(i, t, e);
|
|
1897
1921
|
if (a) return a;
|
|
1898
1922
|
if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
|
|
1899
1923
|
let o = (await i.listScopes({
|
|
@@ -1902,7 +1926,7 @@ function an(e) {
|
|
|
1902
1926
|
})).find((e) => e.scope_id === r) ?? null;
|
|
1903
1927
|
if (o?.status !== "active") return e.json({ error: "scope_not_found" }, 404);
|
|
1904
1928
|
let s = await i.listScopeMemberships(r, !1);
|
|
1905
|
-
return s.some((e) => e.device_id === String(n.enrollment?.device_id) &&
|
|
1929
|
+
return s.some((e) => e.device_id === String(n.enrollment?.device_id) && O(e, o)) ? e.json({ items: s.filter((e) => O(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
|
|
1906
1930
|
} finally {
|
|
1907
1931
|
await i.close();
|
|
1908
1932
|
}
|
|
@@ -2007,7 +2031,7 @@ function an(e) {
|
|
|
2007
2031
|
if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
|
|
2008
2032
|
let f;
|
|
2009
2033
|
try {
|
|
2010
|
-
f = await
|
|
2034
|
+
f = await L(a.reviewed_intent, {
|
|
2011
2035
|
target: {
|
|
2012
2036
|
kind: "add_device",
|
|
2013
2037
|
targetIdentityId: d
|
|
@@ -2015,7 +2039,7 @@ function an(e) {
|
|
|
2015
2039
|
digest: l
|
|
2016
2040
|
});
|
|
2017
2041
|
} catch (t) {
|
|
2018
|
-
return t instanceof
|
|
2042
|
+
return t instanceof D && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2019
2043
|
}
|
|
2020
2044
|
let m = await u.createInvite({
|
|
2021
2045
|
groupId: s,
|
|
@@ -2039,13 +2063,13 @@ function an(e) {
|
|
|
2039
2063
|
target_identity_id: m.target_identity_id ?? void 0,
|
|
2040
2064
|
inviter_device_id: m.inviter_device_id ?? void 0,
|
|
2041
2065
|
reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
|
|
2042
|
-
}, g =
|
|
2066
|
+
}, g = yt(h), { token: _, ...v } = m;
|
|
2043
2067
|
return e.json({
|
|
2044
2068
|
ok: !0,
|
|
2045
2069
|
invite: v,
|
|
2046
2070
|
payload: h,
|
|
2047
2071
|
encoded: g,
|
|
2048
|
-
link:
|
|
2072
|
+
link: xt(g)
|
|
2049
2073
|
});
|
|
2050
2074
|
} finally {
|
|
2051
2075
|
await u.close();
|
|
@@ -2061,7 +2085,7 @@ function an(e) {
|
|
|
2061
2085
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2062
2086
|
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;
|
|
2063
2087
|
if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
|
|
2064
|
-
if (
|
|
2088
|
+
if (me(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
2065
2089
|
let f = n();
|
|
2066
2090
|
try {
|
|
2067
2091
|
await f.createGroup(s), await f.enrollDevice(s, {
|
|
@@ -2176,9 +2200,9 @@ function an(e) {
|
|
|
2176
2200
|
if (i) return i;
|
|
2177
2201
|
let a = String(e.req.param("group_id") ?? "").trim(), o = n();
|
|
2178
2202
|
try {
|
|
2179
|
-
let t = await
|
|
2203
|
+
let t = await w(o, a, e);
|
|
2180
2204
|
if (t) return t;
|
|
2181
|
-
let n =
|
|
2205
|
+
let n = y(e.req.query("include_inactive"));
|
|
2182
2206
|
return e.json({ items: await o.listScopes({
|
|
2183
2207
|
groupId: a,
|
|
2184
2208
|
includeInactive: n
|
|
@@ -2195,24 +2219,24 @@ function an(e) {
|
|
|
2195
2219
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2196
2220
|
let o = h(a);
|
|
2197
2221
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2198
|
-
let s = String(e.req.param("group_id") ?? "").trim(), c =
|
|
2222
|
+
let s = String(e.req.param("group_id") ?? "").trim(), c = g(o, "scope_id"), l = g(o, "label"), u = v(o, "membership_epoch");
|
|
2199
2223
|
if (!c || !l) return e.json({ error: "scope_id_and_label_required" }, 400);
|
|
2200
2224
|
if (Number.isNaN(u)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
|
|
2201
2225
|
let d = n();
|
|
2202
2226
|
try {
|
|
2203
|
-
let t = await
|
|
2227
|
+
let t = await w(d, s, e);
|
|
2204
2228
|
if (t) return t;
|
|
2205
2229
|
let n = await d.createScope({
|
|
2206
2230
|
scopeId: c,
|
|
2207
2231
|
label: l,
|
|
2208
|
-
kind:
|
|
2209
|
-
authorityType:
|
|
2210
|
-
coordinatorId:
|
|
2232
|
+
kind: g(o, "kind"),
|
|
2233
|
+
authorityType: g(o, "authority_type"),
|
|
2234
|
+
coordinatorId: g(o, "coordinator_id"),
|
|
2211
2235
|
groupId: s,
|
|
2212
|
-
manifestIssuerDeviceId:
|
|
2236
|
+
manifestIssuerDeviceId: g(o, "manifest_issuer_device_id"),
|
|
2213
2237
|
membershipEpoch: u,
|
|
2214
|
-
manifestHash:
|
|
2215
|
-
status:
|
|
2238
|
+
manifestHash: g(o, "manifest_hash"),
|
|
2239
|
+
status: g(o, "status")
|
|
2216
2240
|
});
|
|
2217
2241
|
return e.json({
|
|
2218
2242
|
ok: !0,
|
|
@@ -2232,24 +2256,24 @@ function an(e) {
|
|
|
2232
2256
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2233
2257
|
let o = h(a);
|
|
2234
2258
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2235
|
-
let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l =
|
|
2259
|
+
let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = v(o, "membership_epoch");
|
|
2236
2260
|
if (!c) return e.json({ error: "scope_id_required" }, 400);
|
|
2237
2261
|
if (Number.isNaN(l)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
|
|
2238
2262
|
let u = n();
|
|
2239
2263
|
try {
|
|
2240
|
-
let t = await
|
|
2264
|
+
let t = await T(u, s, c, e);
|
|
2241
2265
|
if (t.response) return t.response;
|
|
2242
2266
|
let n = await u.updateScope({
|
|
2243
2267
|
scopeId: c,
|
|
2244
|
-
label: o.label === void 0 ? void 0 :
|
|
2245
|
-
kind: o.kind === void 0 ? void 0 :
|
|
2246
|
-
authorityType: o.authority_type === void 0 ? void 0 :
|
|
2247
|
-
coordinatorId: o.coordinator_id === void 0 ? void 0 :
|
|
2268
|
+
label: o.label === void 0 ? void 0 : g(o, "label"),
|
|
2269
|
+
kind: o.kind === void 0 ? void 0 : g(o, "kind"),
|
|
2270
|
+
authorityType: o.authority_type === void 0 ? void 0 : g(o, "authority_type"),
|
|
2271
|
+
coordinatorId: o.coordinator_id === void 0 ? void 0 : g(o, "coordinator_id"),
|
|
2248
2272
|
groupId: s,
|
|
2249
|
-
manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 :
|
|
2273
|
+
manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 : g(o, "manifest_issuer_device_id"),
|
|
2250
2274
|
membershipEpoch: l,
|
|
2251
|
-
manifestHash: o.manifest_hash === void 0 ? void 0 :
|
|
2252
|
-
status: o.status === void 0 ? void 0 :
|
|
2275
|
+
manifestHash: o.manifest_hash === void 0 ? void 0 : g(o, "manifest_hash"),
|
|
2276
|
+
status: o.status === void 0 ? void 0 : g(o, "status")
|
|
2253
2277
|
});
|
|
2254
2278
|
return n ? e.json({
|
|
2255
2279
|
ok: !0,
|
|
@@ -2267,8 +2291,8 @@ function an(e) {
|
|
|
2267
2291
|
if (i) return i;
|
|
2268
2292
|
let a = String(e.req.param("group_id") ?? "").trim(), o = String(e.req.param("scope_id") ?? "").trim(), s = n();
|
|
2269
2293
|
try {
|
|
2270
|
-
let t = await
|
|
2271
|
-
return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o,
|
|
2294
|
+
let t = await T(s, a, o, e);
|
|
2295
|
+
return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o, y(e.req.query("include_revoked"))) });
|
|
2272
2296
|
} finally {
|
|
2273
2297
|
await s.close();
|
|
2274
2298
|
}
|
|
@@ -2281,27 +2305,27 @@ function an(e) {
|
|
|
2281
2305
|
if (o == null) return e.json({ error: "body_too_large" }, 413);
|
|
2282
2306
|
let s = h(o);
|
|
2283
2307
|
if (!s) return e.json({ error: "invalid_json" }, 400);
|
|
2284
|
-
let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u =
|
|
2308
|
+
let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = g(s, "effect_id"), d = g(s, "device_id"), f = v(s, "membership_epoch");
|
|
2285
2309
|
if (!u) return e.json({ error: "effect_id_required" }, 400);
|
|
2286
2310
|
if (!d) return e.json({ error: "device_id_required" }, 400);
|
|
2287
2311
|
if (Number.isNaN(f)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
|
|
2288
|
-
let
|
|
2312
|
+
let y = n();
|
|
2289
2313
|
try {
|
|
2290
|
-
let t = await
|
|
2314
|
+
let t = await T(y, c, l, e);
|
|
2291
2315
|
if (t.response) return t.response;
|
|
2292
|
-
let n = await
|
|
2316
|
+
let n = await y.grantScopeMembership({
|
|
2293
2317
|
effectId: u,
|
|
2294
2318
|
scopeId: l,
|
|
2295
2319
|
deviceId: d,
|
|
2296
|
-
role:
|
|
2320
|
+
role: g(s, "role"),
|
|
2297
2321
|
membershipEpoch: f,
|
|
2298
|
-
coordinatorId:
|
|
2322
|
+
coordinatorId: g(s, "coordinator_id"),
|
|
2299
2323
|
groupId: c,
|
|
2300
|
-
manifestIssuerDeviceId:
|
|
2301
|
-
manifestHash:
|
|
2302
|
-
signedManifestJson:
|
|
2324
|
+
manifestIssuerDeviceId: g(s, "manifest_issuer_device_id"),
|
|
2325
|
+
manifestHash: g(s, "manifest_hash"),
|
|
2326
|
+
signedManifestJson: g(s, "signed_manifest_json"),
|
|
2303
2327
|
actorType: "admin",
|
|
2304
|
-
actorId:
|
|
2328
|
+
actorId: _(e.req.header(on))
|
|
2305
2329
|
});
|
|
2306
2330
|
return e.json({
|
|
2307
2331
|
ok: !0,
|
|
@@ -2314,7 +2338,7 @@ function an(e) {
|
|
|
2314
2338
|
let r = t instanceof i && t.code === "scope_inactive";
|
|
2315
2339
|
return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
|
|
2316
2340
|
} finally {
|
|
2317
|
-
await
|
|
2341
|
+
await y.close();
|
|
2318
2342
|
}
|
|
2319
2343
|
}), d.post("/v1/admin/groups/:group_id/scopes/:scope_id/members/:device_id/revoke", async (e) => {
|
|
2320
2344
|
let r = Z(e.req.header(X), t);
|
|
@@ -2325,28 +2349,28 @@ function an(e) {
|
|
|
2325
2349
|
if (o == null) return e.json({ error: "body_too_large" }, 413);
|
|
2326
2350
|
let s = o.byteLength > 0 ? h(o) : {};
|
|
2327
2351
|
if (!s) return e.json({ error: "invalid_json" }, 400);
|
|
2328
|
-
let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = String(e.req.param("device_id") ?? "").trim(), d =
|
|
2352
|
+
let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = String(e.req.param("device_id") ?? "").trim(), d = g(s, "effect_id"), f = v(s, "membership_epoch");
|
|
2329
2353
|
if (!d) return e.json({ error: "effect_id_required" }, 400);
|
|
2330
2354
|
if (!u) return e.json({ error: "device_id_required" }, 400);
|
|
2331
2355
|
if (Number.isNaN(f)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
|
|
2332
|
-
let
|
|
2356
|
+
let y = n();
|
|
2333
2357
|
try {
|
|
2334
|
-
let t = await
|
|
2358
|
+
let t = await T(y, c, l, e);
|
|
2335
2359
|
if (t.response) return t.response;
|
|
2336
|
-
if (!await
|
|
2360
|
+
if (!await y.revokeScopeMembership({
|
|
2337
2361
|
effectId: d,
|
|
2338
2362
|
scopeId: l,
|
|
2339
2363
|
deviceId: u,
|
|
2340
2364
|
groupId: c,
|
|
2341
2365
|
membershipEpoch: f,
|
|
2342
|
-
manifestHash:
|
|
2343
|
-
signedManifestJson:
|
|
2366
|
+
manifestHash: g(s, "manifest_hash"),
|
|
2367
|
+
signedManifestJson: g(s, "signed_manifest_json"),
|
|
2344
2368
|
actorType: "admin",
|
|
2345
|
-
actorId:
|
|
2369
|
+
actorId: _(e.req.header(on))
|
|
2346
2370
|
})) return e.json({ error: "membership_not_found" }, 404);
|
|
2347
2371
|
let n;
|
|
2348
2372
|
try {
|
|
2349
|
-
n = (await
|
|
2373
|
+
n = (await y.listScopeMemberships(l, !0)).find((e) => e.device_id === u);
|
|
2350
2374
|
} catch {
|
|
2351
2375
|
n = void 0;
|
|
2352
2376
|
}
|
|
@@ -2354,7 +2378,7 @@ function an(e) {
|
|
|
2354
2378
|
ok: !0,
|
|
2355
2379
|
scope_id: l,
|
|
2356
2380
|
device_id: u,
|
|
2357
|
-
revocation:
|
|
2381
|
+
revocation: nn({
|
|
2358
2382
|
scopeId: l,
|
|
2359
2383
|
deviceId: u,
|
|
2360
2384
|
membershipEpoch: n?.membership_epoch ?? f
|
|
@@ -2364,7 +2388,7 @@ function an(e) {
|
|
|
2364
2388
|
let n = t instanceof Error ? t.message : String(t);
|
|
2365
2389
|
return t instanceof i && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
|
|
2366
2390
|
} finally {
|
|
2367
|
-
await
|
|
2391
|
+
await y.close();
|
|
2368
2392
|
}
|
|
2369
2393
|
}), d.get("/v1/admin/devices", async (e) => {
|
|
2370
2394
|
let r = Z(e.req.header(X), t);
|
|
@@ -2395,16 +2419,22 @@ function an(e) {
|
|
|
2395
2419
|
let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.display_name ?? "").trim();
|
|
2396
2420
|
if (!s || !c) return e.json({ error: "group_id_and_device_id_required" }, 400);
|
|
2397
2421
|
if (!l) return e.json({ error: "display_name_required" }, 400);
|
|
2398
|
-
let u
|
|
2422
|
+
let u;
|
|
2399
2423
|
try {
|
|
2400
|
-
|
|
2401
|
-
|
|
2424
|
+
u = C(l, "display_name");
|
|
2425
|
+
} catch (t) {
|
|
2426
|
+
return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
|
|
2427
|
+
}
|
|
2428
|
+
let d = n();
|
|
2429
|
+
try {
|
|
2430
|
+
if (!await d.renameDevice(s, c, u)) return e.json({ error: "device_not_found" }, 404);
|
|
2431
|
+
let t = await d.getEnrollment(s, c);
|
|
2402
2432
|
return e.json({
|
|
2403
2433
|
ok: !0,
|
|
2404
2434
|
device: t
|
|
2405
2435
|
});
|
|
2406
2436
|
} finally {
|
|
2407
|
-
await
|
|
2437
|
+
await d.close();
|
|
2408
2438
|
}
|
|
2409
2439
|
}), d.post("/v1/admin/devices/disable", async (e) => {
|
|
2410
2440
|
let r = Z(e.req.header(X), t);
|
|
@@ -2466,86 +2496,86 @@ function an(e) {
|
|
|
2466
2496
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2467
2497
|
let o = h(a);
|
|
2468
2498
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2469
|
-
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, f = String(o.reviewed_project_set_digest ?? "").trim() || null,
|
|
2499
|
+
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, f = 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, b = String(o.invite_kind ?? o.kind ?? "").trim(), x = String(o.policy_team_id ?? "").trim() || null, S = String(o.target_identity_id ?? "").trim() || null, w = String(o.reviewed_preview_digest ?? "").trim() || null, T, E = null, O = null;
|
|
2470
2500
|
if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
|
|
2471
2501
|
if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
|
|
2472
2502
|
if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
|
|
2473
2503
|
if (!!d != !!f) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
|
|
2474
|
-
let
|
|
2504
|
+
let k = b || (d ? "project_share" : "legacy_enrollment");
|
|
2475
2505
|
if (![
|
|
2476
2506
|
"legacy_enrollment",
|
|
2477
2507
|
"project_share",
|
|
2478
2508
|
"team_member",
|
|
2479
2509
|
"add_device"
|
|
2480
|
-
].includes(
|
|
2481
|
-
if (
|
|
2482
|
-
if (
|
|
2483
|
-
if (
|
|
2484
|
-
if ([
|
|
2485
|
-
if (
|
|
2510
|
+
].includes(k)) return e.json({ error: "invite_kind_invalid" }, 400);
|
|
2511
|
+
if (k === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
|
|
2512
|
+
if (w && !/^[a-f0-9]{64}$/u.test(w)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
|
|
2513
|
+
if (k === "team_member" && (!x || !w || S) || k === "add_device" && (!S || !w || x) || !["team_member", "add_device"].includes(k) && (x || S || w)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
|
|
2514
|
+
if ([x, S].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
|
|
2515
|
+
if (k === "team_member" || k === "add_device") {
|
|
2486
2516
|
if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2487
2517
|
try {
|
|
2488
|
-
|
|
2489
|
-
target:
|
|
2518
|
+
T = await L(o.reviewed_intent, {
|
|
2519
|
+
target: k === "team_member" ? {
|
|
2490
2520
|
kind: "team_member",
|
|
2491
|
-
policyTeamId: String(
|
|
2521
|
+
policyTeamId: String(x)
|
|
2492
2522
|
} : {
|
|
2493
2523
|
kind: "add_device",
|
|
2494
|
-
targetIdentityId: String(
|
|
2524
|
+
targetIdentityId: String(S)
|
|
2495
2525
|
},
|
|
2496
|
-
digest: String(
|
|
2526
|
+
digest: String(w)
|
|
2497
2527
|
});
|
|
2498
2528
|
} catch (t) {
|
|
2499
|
-
return t instanceof
|
|
2529
|
+
return t instanceof D && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2500
2530
|
}
|
|
2501
2531
|
} else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
|
|
2502
2532
|
if (d && !/^share_[a-f0-9]{40}$/u.test(d) || f && !/^[a-f0-9]{64}$/u.test(f)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
|
|
2503
2533
|
if (d) {
|
|
2504
|
-
if (!
|
|
2534
|
+
if (!g || !_ || !v || !y) return e.json({ error: "project_invite_identity_context_required" }, 400);
|
|
2505
2535
|
if ([
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2536
|
+
g,
|
|
2537
|
+
v,
|
|
2538
|
+
y
|
|
2509
2539
|
].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
|
|
2510
2540
|
try {
|
|
2511
|
-
if (
|
|
2541
|
+
if (C(_, "inviter_display_name"), E = ee(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== E.length || (O = o.project_intent.map((e, t) => {
|
|
2512
2542
|
let n;
|
|
2513
2543
|
try {
|
|
2514
|
-
n =
|
|
2544
|
+
n = Jt([e])[0];
|
|
2515
2545
|
} catch {
|
|
2516
2546
|
throw Error("project_intent_invalid");
|
|
2517
2547
|
}
|
|
2518
|
-
let r =
|
|
2548
|
+
let r = E?.[t];
|
|
2519
2549
|
if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
|
|
2520
2550
|
return n;
|
|
2521
|
-
}), new Set(
|
|
2551
|
+
}), new Set(O.map((e) => e.canonical_identity)).size !== O.length)) throw Error("project_intent_invalid");
|
|
2522
2552
|
} catch (t) {
|
|
2523
2553
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
|
|
2524
2554
|
}
|
|
2525
2555
|
}
|
|
2526
|
-
let
|
|
2556
|
+
let A = n();
|
|
2527
2557
|
try {
|
|
2528
|
-
let t = await
|
|
2558
|
+
let t = await A.getGroup(s);
|
|
2529
2559
|
if (!t) return e.json({ error: "group_not_found" }, 404);
|
|
2530
2560
|
if (t.archived_at) return e.json({ error: "group_archived" }, 409);
|
|
2531
|
-
let n = await
|
|
2561
|
+
let n = await A.createInvite({
|
|
2532
2562
|
groupId: s,
|
|
2533
2563
|
policy: c,
|
|
2534
2564
|
expiresAt: l,
|
|
2535
2565
|
createdBy: u,
|
|
2536
2566
|
operationId: d,
|
|
2537
2567
|
reviewedProjectSetDigest: f,
|
|
2538
|
-
inviterActorId:
|
|
2539
|
-
inviterDisplayName:
|
|
2540
|
-
inviterDeviceId:
|
|
2541
|
-
pendingPersonId:
|
|
2542
|
-
projectSummaries:
|
|
2543
|
-
projectIntent:
|
|
2544
|
-
inviteKind:
|
|
2545
|
-
policyTeamId:
|
|
2546
|
-
targetIdentityId:
|
|
2547
|
-
reviewedPreviewDigest:
|
|
2548
|
-
reviewedIntent:
|
|
2568
|
+
inviterActorId: g,
|
|
2569
|
+
inviterDisplayName: _,
|
|
2570
|
+
inviterDeviceId: v,
|
|
2571
|
+
pendingPersonId: y,
|
|
2572
|
+
projectSummaries: E,
|
|
2573
|
+
projectIntent: O,
|
|
2574
|
+
inviteKind: k,
|
|
2575
|
+
policyTeamId: x,
|
|
2576
|
+
targetIdentityId: S,
|
|
2577
|
+
reviewedPreviewDigest: w,
|
|
2578
|
+
reviewedIntent: T
|
|
2549
2579
|
}), r = {
|
|
2550
2580
|
v: 1,
|
|
2551
2581
|
kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
|
|
@@ -2558,7 +2588,7 @@ function an(e) {
|
|
|
2558
2588
|
...n.operation_id ? {
|
|
2559
2589
|
operation_id: n.operation_id,
|
|
2560
2590
|
inviter_name: n.inviter_display_name ?? null,
|
|
2561
|
-
project_summaries:
|
|
2591
|
+
project_summaries: E ?? []
|
|
2562
2592
|
} : {},
|
|
2563
2593
|
...n.invite_kind === "team_member" ? {
|
|
2564
2594
|
policy_team_id: n.policy_team_id ?? void 0,
|
|
@@ -2570,20 +2600,20 @@ function an(e) {
|
|
|
2570
2600
|
inviter_device_id: n.inviter_device_id ?? void 0,
|
|
2571
2601
|
reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
|
|
2572
2602
|
} : {}
|
|
2573
|
-
}, i =
|
|
2603
|
+
}, i = yt(r), { token: a, ...p } = n;
|
|
2574
2604
|
return e.json({
|
|
2575
2605
|
ok: !0,
|
|
2576
2606
|
invite: p,
|
|
2577
2607
|
payload: r,
|
|
2578
2608
|
encoded: i,
|
|
2579
|
-
link:
|
|
2609
|
+
link: xt(i)
|
|
2580
2610
|
});
|
|
2581
2611
|
} catch (t) {
|
|
2582
2612
|
if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
|
|
2583
2613
|
if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
|
|
2584
2614
|
throw t;
|
|
2585
2615
|
} finally {
|
|
2586
|
-
await
|
|
2616
|
+
await A.close();
|
|
2587
2617
|
}
|
|
2588
2618
|
}), d.post("/v1/invites/inspect", async (e) => {
|
|
2589
2619
|
let r = await m(e);
|
|
@@ -2628,7 +2658,7 @@ function an(e) {
|
|
|
2628
2658
|
if (!n.project_intent_json || !n.project_summaries_json) return e.json({ error: "invite_invalid" }, 404);
|
|
2629
2659
|
let i;
|
|
2630
2660
|
try {
|
|
2631
|
-
i =
|
|
2661
|
+
i = S(n.project_summaries_json);
|
|
2632
2662
|
} catch {
|
|
2633
2663
|
return e.json({ error: "invite_invalid" }, 409);
|
|
2634
2664
|
}
|
|
@@ -2668,7 +2698,7 @@ function an(e) {
|
|
|
2668
2698
|
if (!n) return e.json({ error: "operation_not_found" }, 404);
|
|
2669
2699
|
let r;
|
|
2670
2700
|
try {
|
|
2671
|
-
r =
|
|
2701
|
+
r = b(n.project_intent_json);
|
|
2672
2702
|
} catch {
|
|
2673
2703
|
return e.json({ error: "operation_intent_invalid" }, 409);
|
|
2674
2704
|
}
|
|
@@ -2678,7 +2708,7 @@ function an(e) {
|
|
|
2678
2708
|
display_name: String(e.display_name ?? ""),
|
|
2679
2709
|
existing_memory_count: Number(e.existing_memory_count ?? 0)
|
|
2680
2710
|
}));
|
|
2681
|
-
s =
|
|
2711
|
+
s = xt(yt({
|
|
2682
2712
|
v: 1,
|
|
2683
2713
|
kind: "coordinator_team_invite",
|
|
2684
2714
|
coordinator_url: new URL(e.req.url).origin,
|
|
@@ -2795,11 +2825,11 @@ function an(e) {
|
|
|
2795
2825
|
} finally {
|
|
2796
2826
|
await c.close();
|
|
2797
2827
|
}
|
|
2798
|
-
}), d.post("/v1/admin/join-requests/approve", async (e) =>
|
|
2828
|
+
}), d.post("/v1/admin/join-requests/approve", async (e) => pn(e, !0, {
|
|
2799
2829
|
createStore: n,
|
|
2800
2830
|
runtime: t,
|
|
2801
2831
|
rateLimitedResponse: p
|
|
2802
|
-
})), d.post("/v1/admin/join-requests/deny", async (e) =>
|
|
2832
|
+
})), d.post("/v1/admin/join-requests/deny", async (e) => pn(e, !1, {
|
|
2803
2833
|
createStore: n,
|
|
2804
2834
|
runtime: t,
|
|
2805
2835
|
rateLimitedResponse: p
|
|
@@ -2823,10 +2853,10 @@ function an(e) {
|
|
|
2823
2853
|
if (!i) return e.json({ error: "invalid_json" }, 400);
|
|
2824
2854
|
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(), p = String(i.device_display_name ?? "").trim();
|
|
2825
2855
|
if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
|
|
2826
|
-
if (
|
|
2827
|
-
let
|
|
2856
|
+
if (me(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
2857
|
+
let g = n();
|
|
2828
2858
|
try {
|
|
2829
|
-
let n = await
|
|
2859
|
+
let n = await g.getInviteByTokenForInspection(a);
|
|
2830
2860
|
if (!n) return e.json({ error: "invite_invalid" }, 404);
|
|
2831
2861
|
let r = !!(n.operation_id || n.reviewed_project_set_digest), m = n.invite_kind === "team_member" || n.invite_kind === "add_device";
|
|
2832
2862
|
if (n.revoked_at) return e.json({ error: r || m ? "invite_invalid" : "revoked_token" }, 400);
|
|
@@ -2851,18 +2881,18 @@ function an(e) {
|
|
|
2851
2881
|
try {
|
|
2852
2882
|
if (i.recipient_display_name != null) {
|
|
2853
2883
|
if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
|
|
2854
|
-
d =
|
|
2884
|
+
d = C(i.recipient_display_name, "recipient_display_name");
|
|
2855
2885
|
}
|
|
2856
2886
|
if (i.device_display_name != null) {
|
|
2857
2887
|
if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
|
|
2858
|
-
f =
|
|
2888
|
+
f = C(i.device_display_name, "device_display_name");
|
|
2859
2889
|
}
|
|
2860
2890
|
} catch (t) {
|
|
2861
2891
|
return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
|
|
2862
2892
|
}
|
|
2863
2893
|
if (n.invite_kind === "add_device" && String(n.inviter_device_id ?? "").trim() === o) return e.json({ error: "add_device_invite_self_acceptance_forbidden" }, 409);
|
|
2864
2894
|
try {
|
|
2865
|
-
let r = await
|
|
2895
|
+
let r = await g.consumeRecipientInvite({
|
|
2866
2896
|
token: a,
|
|
2867
2897
|
inviteKind: n.invite_kind,
|
|
2868
2898
|
identityId: u,
|
|
@@ -2883,7 +2913,7 @@ function an(e) {
|
|
|
2883
2913
|
target_identity_id: r.invite.target_identity_id ?? null,
|
|
2884
2914
|
assigned_identity_id: r.invite.assigned_identity_id ?? null,
|
|
2885
2915
|
bootstrap_grant_id: r.bootstrap_grant?.grant_id ?? null,
|
|
2886
|
-
inviter_device: r.bootstrap_grant ? await
|
|
2916
|
+
inviter_device: r.bootstrap_grant ? await g.getEnrollment(r.invite.group_id, r.bootstrap_grant.seed_device_id) : null,
|
|
2887
2917
|
reviewed_preview_digest: r.invite.reviewed_preview_digest,
|
|
2888
2918
|
reviewed_intent: r.reviewed_intent
|
|
2889
2919
|
});
|
|
@@ -2910,18 +2940,18 @@ function an(e) {
|
|
|
2910
2940
|
if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
|
|
2911
2941
|
let l, m;
|
|
2912
2942
|
try {
|
|
2913
|
-
l =
|
|
2943
|
+
l = C(f, "recipient_display_name"), m = C(p, "device_display_name");
|
|
2914
2944
|
} catch (t) {
|
|
2915
2945
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
|
|
2916
2946
|
}
|
|
2917
2947
|
let h;
|
|
2918
2948
|
try {
|
|
2919
|
-
h =
|
|
2949
|
+
h = x(n);
|
|
2920
2950
|
} catch {
|
|
2921
2951
|
return e.json({ error: "operation_intent_invalid" }, 409);
|
|
2922
2952
|
}
|
|
2923
2953
|
try {
|
|
2924
|
-
let n = await
|
|
2954
|
+
let n = await g.consumeProjectInvite({
|
|
2925
2955
|
token: a,
|
|
2926
2956
|
operationId: u,
|
|
2927
2957
|
deviceId: o,
|
|
@@ -2934,7 +2964,7 @@ function an(e) {
|
|
|
2934
2964
|
});
|
|
2935
2965
|
return e.json({
|
|
2936
2966
|
ok: !0,
|
|
2937
|
-
status:
|
|
2967
|
+
status: Ct,
|
|
2938
2968
|
group_id: n.invite.group_id,
|
|
2939
2969
|
operation_id: n.invite.operation_id,
|
|
2940
2970
|
trust_state: n.invite.trust_state,
|
|
@@ -2958,21 +2988,21 @@ function an(e) {
|
|
|
2958
2988
|
"recipient_display_name",
|
|
2959
2989
|
"device_display_name"
|
|
2960
2990
|
].some((e) => Object.hasOwn(i, e))) return e.json({ error: "unexpected_project_invite_fields" }, 400);
|
|
2961
|
-
let h = await
|
|
2991
|
+
let h = await g.getGroup(String(n.group_id));
|
|
2962
2992
|
if (!h) return e.json({ error: "group_not_found" }, 404);
|
|
2963
2993
|
if (h.archived_at) return e.json({ error: "group_archived" }, 409);
|
|
2964
|
-
let
|
|
2965
|
-
if (await
|
|
2994
|
+
let _ = String(n.group_id);
|
|
2995
|
+
if (await g.getEnrollment(_, o)) return e.json({
|
|
2966
2996
|
ok: !0,
|
|
2967
2997
|
status: "already_enrolled",
|
|
2968
2998
|
group_id: n.group_id,
|
|
2969
2999
|
policy: n.policy
|
|
2970
3000
|
});
|
|
2971
|
-
let
|
|
2972
|
-
if (!["auto_admit", "approval_required"].includes(
|
|
2973
|
-
if (
|
|
2974
|
-
let t = await
|
|
2975
|
-
groupId:
|
|
3001
|
+
let v = String(n.policy);
|
|
3002
|
+
if (!["auto_admit", "approval_required"].includes(v)) return e.json({ error: `unknown invite policy: ${v}` }, 400);
|
|
3003
|
+
if (v === "approval_required") {
|
|
3004
|
+
let t = await g.createJoinRequest({
|
|
3005
|
+
groupId: _,
|
|
2976
3006
|
deviceId: o,
|
|
2977
3007
|
publicKey: c,
|
|
2978
3008
|
fingerprint: s,
|
|
@@ -2987,7 +3017,7 @@ function an(e) {
|
|
|
2987
3017
|
request_id: t.request_id
|
|
2988
3018
|
});
|
|
2989
3019
|
}
|
|
2990
|
-
return await
|
|
3020
|
+
return await g.enrollDevice(_, {
|
|
2991
3021
|
deviceId: o,
|
|
2992
3022
|
fingerprint: s,
|
|
2993
3023
|
publicKey: c,
|
|
@@ -2999,18 +3029,18 @@ function an(e) {
|
|
|
2999
3029
|
policy: n.policy
|
|
3000
3030
|
});
|
|
3001
3031
|
} finally {
|
|
3002
|
-
await
|
|
3032
|
+
await g.close();
|
|
3003
3033
|
}
|
|
3004
3034
|
}), d;
|
|
3005
3035
|
}
|
|
3006
|
-
async function
|
|
3036
|
+
async function pn(e, t, n) {
|
|
3007
3037
|
let r = Z(e.req.header(X), n.runtime);
|
|
3008
3038
|
if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
3009
3039
|
let i = n.rateLimitedResponse(e, "admin", !0);
|
|
3010
3040
|
if (i) return i;
|
|
3011
3041
|
let a = await (async () => {
|
|
3012
3042
|
let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
3013
|
-
if (Number.isFinite(t) && t >
|
|
3043
|
+
if (Number.isFinite(t) && t > an) return null;
|
|
3014
3044
|
let n = e.req.raw.body;
|
|
3015
3045
|
if (!n) return new Uint8Array();
|
|
3016
3046
|
let r = n.getReader(), i = [], a = 0;
|
|
@@ -3019,7 +3049,7 @@ async function on(e, t, n) {
|
|
|
3019
3049
|
let { done: e, value: t } = await r.read();
|
|
3020
3050
|
if (e) break;
|
|
3021
3051
|
if (t) {
|
|
3022
|
-
if (a += t.byteLength, a >
|
|
3052
|
+
if (a += t.byteLength, a > an) return await r.cancel(), null;
|
|
3023
3053
|
i.push(t);
|
|
3024
3054
|
}
|
|
3025
3055
|
}
|
|
@@ -3067,6 +3097,6 @@ async function on(e, t, n) {
|
|
|
3067
3097
|
}
|
|
3068
3098
|
}
|
|
3069
3099
|
//#endregion
|
|
3070
|
-
export {
|
|
3100
|
+
export { fe as A, m as B, xt as C, de as D, D as E, C as F, o as G, l as H, x as I, c as K, ee as L, T as M, S as N, F as O, w as P, p as R, St as S, E as T, s as U, i as V, u as W, Tt as _, tn as a, bt as b, Jt as c, Ot as d, Nt as f, wt as g, Ct as h, nn as i, L as j, pe as k, Kt as l, Ut as m, rn as n, Wt as o, Ht as p, en as r, qt as s, fn as t, kt as u, Et as v, me as w, yt as x, Dt as y, d as z };
|
|
3071
3101
|
|
|
3072
|
-
//# sourceMappingURL=coordinator-api-
|
|
3102
|
+
//# sourceMappingURL=coordinator-api-SeLosPIq.js.map
|