@codemem/core 0.44.0-alpha.1 → 0.44.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/automatic-recall.d.ts +45 -0
- package/dist/automatic-recall.d.ts.map +1 -0
- package/dist/coordinator-actions.d.ts +5 -0
- package/dist/coordinator-actions.d.ts.map +1 -1
- package/dist/{coordinator-api-Dlr65yhR.js → coordinator-api-C2ckGC2b.js} +680 -651
- package/dist/coordinator-api-C2ckGC2b.js.map +1 -0
- package/dist/coordinator-api.d.ts.map +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/export-import.d.ts.map +1 -1
- package/dist/extraction-benchmark-scoring.d.ts +1 -0
- package/dist/extraction-benchmark-scoring.d.ts.map +1 -1
- package/dist/extraction-replay.d.ts +29 -0
- package/dist/extraction-replay.d.ts.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9995 -8606
- package/dist/index.js.map +1 -1
- package/dist/ingest-pipeline.d.ts.map +1 -1
- package/dist/ingest-prompts.d.ts +3 -1
- package/dist/ingest-prompts.d.ts.map +1 -1
- package/dist/ingest-xml-parser.d.ts.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +220 -220
- package/dist/internal/cloudflare-coordinator.js.map +1 -1
- package/dist/legacy-team-setup-completion-manifest.d.ts +4 -0
- package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
- package/dist/legacy-team-setup-errors.d.ts +2 -0
- package/dist/legacy-team-setup-errors.d.ts.map +1 -1
- package/dist/legacy-team-setup-limits.d.ts +3 -1
- package/dist/legacy-team-setup-limits.d.ts.map +1 -1
- package/dist/maintenance/ai-structured.d.ts.map +1 -1
- package/dist/native-runtime.d.ts +12 -0
- package/dist/native-runtime.d.ts.map +1 -0
- package/dist/observer-client.d.ts +10 -0
- package/dist/observer-client.d.ts.map +1 -1
- package/dist/observer-concepts.d.ts +5 -0
- package/dist/observer-concepts.d.ts.map +1 -0
- package/dist/observer-config.d.ts.map +1 -1
- package/dist/observer-forced-tool.d.ts +34 -0
- package/dist/observer-forced-tool.d.ts.map +1 -0
- package/dist/observer-output-schema.d.ts +57 -0
- package/dist/observer-output-schema.d.ts.map +1 -0
- package/dist/observer-output.d.ts +59 -0
- package/dist/observer-output.d.ts.map +1 -0
- package/dist/pack.d.ts +7 -7
- package/dist/pack.d.ts.map +1 -1
- package/dist/project-identity.d.ts +4 -0
- package/dist/project-identity.d.ts.map +1 -0
- package/dist/project-invite-identity.d.ts +1 -0
- package/dist/project-invite-identity.d.ts.map +1 -1
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/dist/raw-event-flush.d.ts.map +1 -1
- package/dist/raw-event-ingest.d.ts.map +1 -1
- package/dist/raw-event-sweeper.d.ts +2 -3
- package/dist/raw-event-sweeper.d.ts.map +1 -1
- package/dist/recipient-policy-review.d.ts +6 -0
- package/dist/recipient-policy-review.d.ts.map +1 -1
- package/dist/ref-queries.d.ts +2 -0
- package/dist/ref-queries.d.ts.map +1 -1
- package/dist/release-discovery.d.ts +4 -0
- package/dist/release-discovery.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/schema.d.ts +76 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/scope-resolution.d.ts.map +1 -1
- package/dist/search.d.ts +4 -4
- package/dist/search.d.ts.map +1 -1
- package/dist/store.d.ts +16 -11
- package/dist/store.d.ts.map +1 -1
- package/dist/summary-memory.d.ts +6 -0
- package/dist/summary-memory.d.ts.map +1 -1
- package/dist/sync-daemon.d.ts.map +1 -1
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-migration.d.ts.map +1 -1
- package/dist/vectors.d.ts +7 -1
- package/dist/vectors.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/coordinator-api-Dlr65yhR.js.map +0 -1
|
@@ -1,17 +1,176 @@
|
|
|
1
1
|
import { resolve as e } from "node:path";
|
|
2
2
|
import { createHash as t } from "node:crypto";
|
|
3
|
-
|
|
3
|
+
//#region src/project-identity.ts
|
|
4
|
+
var n = /^(?:command failed(?:\s|:)|error:\s|fatal:\s|git:\s)/iu, r = /^(?:giterror|git error|git command failed):[^\r\n]*(?:not a git repository|unknown revision or path|no such remote)\b/iu;
|
|
5
|
+
function i(e) {
|
|
6
|
+
if (typeof e != "string") return !1;
|
|
7
|
+
let t = e.trim();
|
|
8
|
+
return t ? t.includes("\n") || t.includes("\r") ? !0 : n.test(t) || r.test(t) : !1;
|
|
9
|
+
}
|
|
10
|
+
function a(e) {
|
|
11
|
+
let t = e?.trim();
|
|
12
|
+
return !t || i(t) ? null : t;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/scope-resolution.ts
|
|
16
|
+
var o = "local-default", s = "legacy-shared-review";
|
|
17
|
+
function c(e) {
|
|
18
|
+
return e?.trim() || null;
|
|
19
|
+
}
|
|
20
|
+
function l(e) {
|
|
21
|
+
return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
|
|
22
|
+
}
|
|
23
|
+
function u(t) {
|
|
24
|
+
return l(e(t));
|
|
25
|
+
}
|
|
26
|
+
function d(e) {
|
|
27
|
+
let t = c(e);
|
|
28
|
+
return t ? l(t) : null;
|
|
29
|
+
}
|
|
30
|
+
function f(e) {
|
|
31
|
+
let n = [
|
|
32
|
+
e.cwd,
|
|
33
|
+
e.project,
|
|
34
|
+
e.workspaceId
|
|
35
|
+
].map((e) => a(e)).find((e) => e !== null), r = [
|
|
36
|
+
e.gitRemote,
|
|
37
|
+
e.gitBranch,
|
|
38
|
+
e.cwd,
|
|
39
|
+
e.project,
|
|
40
|
+
e.workspaceId
|
|
41
|
+
].map((e) => typeof e == "string" ? e.trim() : null), o = n ?? "unknown";
|
|
42
|
+
return !n && r.some(i) && (o = JSON.stringify(r)), `unmapped:${t("sha256").update(o, "utf8").digest("hex")}`;
|
|
43
|
+
}
|
|
44
|
+
function p(e) {
|
|
45
|
+
let t = a(e.gitRemote), n = a(e.gitBranch), r = a(e.cwd), i = a(e.workspaceId), o = a(e.project);
|
|
46
|
+
if (t) {
|
|
47
|
+
let r = l(t);
|
|
48
|
+
return e.branchScoped && n ? {
|
|
49
|
+
value: `${r}:${n}`,
|
|
50
|
+
source: "git_remote_branch",
|
|
51
|
+
displayProject: o
|
|
52
|
+
} : {
|
|
53
|
+
value: r,
|
|
54
|
+
source: "git_remote",
|
|
55
|
+
displayProject: o
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return r ? {
|
|
59
|
+
value: u(r),
|
|
60
|
+
source: "cwd",
|
|
61
|
+
displayProject: o
|
|
62
|
+
} : i ? {
|
|
63
|
+
value: l(i),
|
|
64
|
+
source: "workspace_id",
|
|
65
|
+
displayProject: o
|
|
66
|
+
} : {
|
|
67
|
+
value: f(e),
|
|
68
|
+
source: "unmapped",
|
|
69
|
+
displayProject: o
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function m(e) {
|
|
73
|
+
return !/[\\/:]/.test(e);
|
|
74
|
+
}
|
|
75
|
+
function h(e) {
|
|
76
|
+
return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
77
|
+
}
|
|
78
|
+
function g(e) {
|
|
79
|
+
return e.replace(/[*?]/g, "").length;
|
|
80
|
+
}
|
|
81
|
+
function _(e, t) {
|
|
82
|
+
let n = l(t);
|
|
83
|
+
return !n || m(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${h(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
|
|
84
|
+
}
|
|
85
|
+
function v(e) {
|
|
86
|
+
return e.mapping.priority ?? 0;
|
|
87
|
+
}
|
|
88
|
+
function y(e) {
|
|
89
|
+
let t = c(e.mapping.updated_at);
|
|
90
|
+
if (!t) return 0;
|
|
91
|
+
let n = Date.parse(t);
|
|
92
|
+
return Number.isFinite(n) ? n : 0;
|
|
93
|
+
}
|
|
94
|
+
function ee(e, t) {
|
|
95
|
+
return v(t) - v(e) || t.specificity - e.specificity || y(t) - y(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
|
|
96
|
+
}
|
|
97
|
+
function b(e) {
|
|
98
|
+
return e.toSorted(ee)[0] ?? null;
|
|
99
|
+
}
|
|
100
|
+
function x(e) {
|
|
101
|
+
let t = p(e), n = c(e.explicitScopeId);
|
|
102
|
+
if (n) return {
|
|
103
|
+
scopeId: n,
|
|
104
|
+
reason: "explicit_override",
|
|
105
|
+
workspaceIdentity: t,
|
|
106
|
+
mapping: null,
|
|
107
|
+
matchedPattern: null
|
|
108
|
+
};
|
|
109
|
+
if (t.source === "unmapped") return {
|
|
110
|
+
scopeId: e.localDefaultScopeId ?? "local-default",
|
|
111
|
+
reason: "local_default",
|
|
112
|
+
workspaceIdentity: t,
|
|
113
|
+
mapping: null,
|
|
114
|
+
matchedPattern: null
|
|
115
|
+
};
|
|
116
|
+
let r = e.mappings ?? [], i = b(r.filter((e) => d(e.workspace_identity) === t.value).map((e) => ({
|
|
117
|
+
mapping: e,
|
|
118
|
+
matchedPattern: null,
|
|
119
|
+
specificity: t.value.length
|
|
120
|
+
})));
|
|
121
|
+
if (i) return {
|
|
122
|
+
scopeId: i.mapping.scope_id,
|
|
123
|
+
reason: "exact_mapping",
|
|
124
|
+
workspaceIdentity: t,
|
|
125
|
+
mapping: i.mapping,
|
|
126
|
+
matchedPattern: null
|
|
127
|
+
};
|
|
128
|
+
let a = b(r.flatMap((e) => {
|
|
129
|
+
if (c(e.workspace_identity)) return [];
|
|
130
|
+
let n = c(e.project_pattern);
|
|
131
|
+
return !n || !_(t.value, n) ? [] : [{
|
|
132
|
+
mapping: e,
|
|
133
|
+
matchedPattern: l(n),
|
|
134
|
+
specificity: g(n)
|
|
135
|
+
}];
|
|
136
|
+
}));
|
|
137
|
+
return a ? {
|
|
138
|
+
scopeId: a.mapping.scope_id,
|
|
139
|
+
reason: "pattern_mapping",
|
|
140
|
+
workspaceIdentity: t,
|
|
141
|
+
mapping: a.mapping,
|
|
142
|
+
matchedPattern: a.matchedPattern
|
|
143
|
+
} : {
|
|
144
|
+
scopeId: e.localDefaultScopeId ?? "local-default",
|
|
145
|
+
reason: "local_default",
|
|
146
|
+
workspaceIdentity: t,
|
|
147
|
+
mapping: null,
|
|
148
|
+
matchedPattern: null
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function S(e, t) {
|
|
152
|
+
let n = /* @__PURE__ */ new Set([
|
|
153
|
+
"",
|
|
154
|
+
o,
|
|
155
|
+
s
|
|
156
|
+
]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
|
|
157
|
+
for (let e of r) e.scope_id != null && n.add(e.scope_id);
|
|
158
|
+
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);
|
|
159
|
+
for (let e of i) e.scope_id != null && n.add(e.scope_id);
|
|
160
|
+
return [...n];
|
|
161
|
+
}
|
|
162
|
+
function C(e) {
|
|
4
163
|
if (e.devices.length > 500 || e.projects.length > 500 || e.devices.length * e.projects.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
5
164
|
}
|
|
6
|
-
function
|
|
165
|
+
function w(e) {
|
|
7
166
|
if (e.projectIdentities.size * e.deviceCount > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
8
167
|
}
|
|
9
|
-
function
|
|
168
|
+
function T(e, t, n) {
|
|
10
169
|
if (n.length === 0) return;
|
|
11
|
-
let r = Number(e.prepare(
|
|
12
|
-
if ((
|
|
170
|
+
let r = [...new Set(t.map((e) => e.deviceId))], i = r.length > 0 ? `WHERE device_id NOT IN (${r.map(() => "?").join(", ")})` : "", a = Number(e.prepare(`SELECT COUNT(*) FROM identity_devices ${i}`).pluck().get(...r) ?? 0);
|
|
171
|
+
if ((r.length + a) * n.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
|
|
13
172
|
}
|
|
14
|
-
function
|
|
173
|
+
function E(e, t, n, r) {
|
|
15
174
|
if (!r) return;
|
|
16
175
|
let i = [...new Set(t.map((e) => e.deviceId))], a = i.map(() => "?").join(", "), o = a ? `AND device_id NOT IN (${a})` : "", s = Number(e.prepare(`SELECT COUNT(*) FROM legacy_team_setup_draft_devices
|
|
17
176
|
WHERE attempt_id = ? ${o}`).pluck().get(r, ...i) ?? 0), c = t.length + s;
|
|
@@ -19,146 +178,146 @@ function a(e, t, n, r) {
|
|
|
19
178
|
}
|
|
20
179
|
//#endregion
|
|
21
180
|
//#region src/recipient-policy-identifiers.ts
|
|
22
|
-
function
|
|
181
|
+
function D(e, t) {
|
|
23
182
|
return e < t ? -1 : +(e > t);
|
|
24
183
|
}
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !
|
|
184
|
+
var te = /[\p{Cc}\p{Cf}]/u;
|
|
185
|
+
function ne(e, t) {
|
|
186
|
+
return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !te.test(e);
|
|
28
187
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
188
|
+
function re(e) {
|
|
189
|
+
return ne(e, 256);
|
|
31
190
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
191
|
+
function ie(e) {
|
|
192
|
+
return ne(e, 2048);
|
|
34
193
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
37
|
-
throw TypeError(
|
|
194
|
+
var ae = "Recipient policy value must be strict JSON data";
|
|
195
|
+
function O() {
|
|
196
|
+
throw TypeError(ae);
|
|
38
197
|
}
|
|
39
|
-
function
|
|
198
|
+
function oe(e) {
|
|
40
199
|
let t = JSON.stringify(e);
|
|
41
|
-
return t === void 0 ?
|
|
200
|
+
return t === void 0 ? O() : t;
|
|
42
201
|
}
|
|
43
|
-
function
|
|
202
|
+
function se(e, t) {
|
|
44
203
|
if (e === null) return "null";
|
|
45
204
|
if (typeof e == "boolean") return e ? "true" : "false";
|
|
46
|
-
if (typeof e == "string") return
|
|
47
|
-
if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ?
|
|
48
|
-
if (typeof e != "object" || t.has(e)) return
|
|
205
|
+
if (typeof e == "string") return oe(e);
|
|
206
|
+
if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ? O() : String(e);
|
|
207
|
+
if (typeof e != "object" || t.has(e)) return O();
|
|
49
208
|
t.add(e);
|
|
50
209
|
try {
|
|
51
210
|
if (Array.isArray(e)) {
|
|
52
|
-
if (Object.getPrototypeOf(e) !== Array.prototype) return
|
|
211
|
+
if (Object.getPrototypeOf(e) !== Array.prototype) return O();
|
|
53
212
|
let n = Reflect.ownKeys(e);
|
|
54
|
-
if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return
|
|
213
|
+
if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return O();
|
|
55
214
|
let r = [];
|
|
56
215
|
for (let n = 0; n < e.length; n += 1) {
|
|
57
216
|
let i = Object.getOwnPropertyDescriptor(e, String(n));
|
|
58
|
-
if (!i?.enumerable || !("value" in i)) return
|
|
59
|
-
r.push(
|
|
217
|
+
if (!i?.enumerable || !("value" in i)) return O();
|
|
218
|
+
r.push(se(i.value, t));
|
|
60
219
|
}
|
|
61
220
|
return `[${r.join(",")}]`;
|
|
62
221
|
}
|
|
63
222
|
let n = Object.getPrototypeOf(e);
|
|
64
|
-
return n !== Object.prototype && n !== null ?
|
|
65
|
-
if (typeof t != "string") return
|
|
223
|
+
return n !== Object.prototype && n !== null ? O() : `{${Reflect.ownKeys(e).map((t) => {
|
|
224
|
+
if (typeof t != "string") return O();
|
|
66
225
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
67
|
-
return !n?.enumerable || !("value" in n) ?
|
|
68
|
-
}).toSorted(([e], [t]) =>
|
|
226
|
+
return !n?.enumerable || !("value" in n) ? O() : [t, n.value];
|
|
227
|
+
}).toSorted(([e], [t]) => D(e, t)).map(([e, n]) => `${oe(e)}:${se(n, t)}`).join(",")}}`;
|
|
69
228
|
} finally {
|
|
70
229
|
t.delete(e);
|
|
71
230
|
}
|
|
72
231
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
232
|
+
function ce(e) {
|
|
233
|
+
return se(e, /* @__PURE__ */ new WeakSet());
|
|
75
234
|
}
|
|
76
|
-
function
|
|
235
|
+
function le(e, n) {
|
|
77
236
|
if (e.includes("\0") || !e.isWellFormed()) throw TypeError("Recipient policy digest prefix must be well-formed without NUL");
|
|
78
|
-
return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(
|
|
237
|
+
return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(ce(n), "utf8").digest("hex")}`;
|
|
79
238
|
}
|
|
80
|
-
function
|
|
81
|
-
return `${e}:${t("sha256").update(
|
|
239
|
+
function ue(e, n) {
|
|
240
|
+
return `${e}:${t("sha256").update(ce(n), "utf8").digest("hex")}`;
|
|
82
241
|
}
|
|
83
|
-
var
|
|
84
|
-
function
|
|
242
|
+
var de = ["team_invite", "coordinator_invite"];
|
|
243
|
+
function fe(e, n) {
|
|
85
244
|
return `legacy-team-candidate:${t("sha256").update(JSON.stringify([e, n])).digest("hex").slice(0, 32)}`;
|
|
86
245
|
}
|
|
87
|
-
function
|
|
88
|
-
return
|
|
246
|
+
function pe(e, t) {
|
|
247
|
+
return le("legacy-team-project-ref-v1", [e, t]);
|
|
89
248
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
249
|
+
function me(e, t) {
|
|
250
|
+
return le("legacy-team-canonical-project-ref-v1", [e, t]);
|
|
92
251
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
252
|
+
function he(e, t) {
|
|
253
|
+
return le("legacy-team-device-ref-v1", [e, t]);
|
|
95
254
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
255
|
+
function ge(e) {
|
|
256
|
+
return ue("policy-team-v1", e);
|
|
98
257
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
258
|
+
function _e(e) {
|
|
259
|
+
return le("legacy-team-roster-v1", e.map((e) => ({
|
|
101
260
|
deviceId: e.deviceId,
|
|
102
261
|
fingerprint: e.fingerprint,
|
|
103
262
|
enabled: e.enabled,
|
|
104
263
|
identityId: e.identityId
|
|
105
|
-
})).toSorted((e, t) =>
|
|
264
|
+
})).toSorted((e, t) => D(e.deviceId, t.deviceId)));
|
|
106
265
|
}
|
|
107
266
|
//#endregion
|
|
108
267
|
//#region src/coordinator-legacy-team-completion.ts
|
|
109
|
-
var
|
|
110
|
-
code =
|
|
268
|
+
var ve = 1, ye = 50, be = 500, xe = 15e5, Se = 25 * xe, Ce = 256, we = 37661024, Te = "completion_conflict", Ee = class extends Error {
|
|
269
|
+
code = Te;
|
|
111
270
|
constructor() {
|
|
112
|
-
super(
|
|
271
|
+
super(Te), this.name = "CoordinatorLegacyTeamCompletionConflictError";
|
|
113
272
|
}
|
|
114
273
|
};
|
|
115
|
-
function
|
|
274
|
+
function k() {
|
|
116
275
|
throw Error("completion_manifest_invalid");
|
|
117
276
|
}
|
|
118
|
-
function
|
|
119
|
-
return (!e || typeof e != "object" || Array.isArray(e)) &&
|
|
277
|
+
function A(e) {
|
|
278
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && k(), e;
|
|
120
279
|
}
|
|
121
|
-
function
|
|
280
|
+
function j(e, t) {
|
|
122
281
|
let n = new Set(t);
|
|
123
|
-
Object.keys(e).some((e) => !n.has(e)) &&
|
|
282
|
+
Object.keys(e).some((e) => !n.has(e)) && k();
|
|
124
283
|
}
|
|
125
|
-
function
|
|
284
|
+
function De(e) {
|
|
126
285
|
return /^(?:[\\/]{2}|\.{1,2}[\\/]|\/|~[\\/]|[a-z]:[\\/]|file:)/iu.test(e);
|
|
127
286
|
}
|
|
128
|
-
function j(e) {
|
|
129
|
-
return (typeof e != "string" || !e || e !== e.trim() || e.length > ne || /[\p{Cc}\p{Cf}]/u.test(e) || oe(e)) && O(), e;
|
|
130
|
-
}
|
|
131
287
|
function M(e) {
|
|
132
|
-
|
|
133
|
-
return /^[a-f0-9]{64}$/u.test(t) || O(), t;
|
|
288
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > Ce || /[\p{Cc}\p{Cf}]/u.test(e) || De(e)) && k(), e;
|
|
134
289
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
290
|
+
function N(e) {
|
|
291
|
+
let t = M(e);
|
|
292
|
+
return /^[a-f0-9]{64}$/u.test(t) || k(), t;
|
|
293
|
+
}
|
|
294
|
+
function Oe(e) {
|
|
295
|
+
typeof e != "string" && k();
|
|
137
296
|
let t = e.normalize("NFC").trim();
|
|
138
|
-
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) ||
|
|
297
|
+
return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || De(t)) && k(), t;
|
|
139
298
|
}
|
|
140
|
-
function
|
|
141
|
-
(typeof e != "string" || !e) &&
|
|
299
|
+
function ke(e) {
|
|
300
|
+
(typeof e != "string" || !e) && k();
|
|
142
301
|
let t = new Date(e);
|
|
143
|
-
return (Number.isNaN(t.getTime()) || t.toISOString() !== e) &&
|
|
302
|
+
return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && k(), e;
|
|
144
303
|
}
|
|
145
|
-
function
|
|
146
|
-
return (!Array.isArray(e) || e.length > t) &&
|
|
304
|
+
function Ae(e, t) {
|
|
305
|
+
return (!Array.isArray(e) || e.length > t) && k(), e;
|
|
147
306
|
}
|
|
148
|
-
function
|
|
149
|
-
let n = e.toSorted((e, n) =>
|
|
150
|
-
return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) &&
|
|
307
|
+
function je(e, t) {
|
|
308
|
+
let n = e.toSorted((e, n) => D(t(e), t(n)));
|
|
309
|
+
return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && k(), n;
|
|
151
310
|
}
|
|
152
|
-
function
|
|
153
|
-
return
|
|
311
|
+
function Me(e) {
|
|
312
|
+
return je(Ae(e, 50).map(M), (e) => e);
|
|
154
313
|
}
|
|
155
|
-
function
|
|
156
|
-
let t =
|
|
157
|
-
return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) ||
|
|
314
|
+
function Ne(e) {
|
|
315
|
+
let t = M(e);
|
|
316
|
+
return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || k(), t;
|
|
158
317
|
}
|
|
159
|
-
function
|
|
160
|
-
let t =
|
|
161
|
-
|
|
318
|
+
function Pe(e) {
|
|
319
|
+
let t = A(e);
|
|
320
|
+
j(t, [
|
|
162
321
|
"version",
|
|
163
322
|
"coordinator_id",
|
|
164
323
|
"candidate_ref",
|
|
@@ -174,165 +333,165 @@ function pe(e) {
|
|
|
174
333
|
"project_mappings",
|
|
175
334
|
"project_recipients",
|
|
176
335
|
"completed_at"
|
|
177
|
-
]), t.version !== 1 &&
|
|
178
|
-
let n =
|
|
179
|
-
|
|
336
|
+
]), t.version !== 1 && k();
|
|
337
|
+
let n = A(t.team);
|
|
338
|
+
j(n, [
|
|
180
339
|
"display_name",
|
|
181
340
|
"policy_revision",
|
|
182
341
|
"device_eligibility_mode"
|
|
183
|
-
]), n.device_eligibility_mode !== "reviewed_allowlist" &&
|
|
184
|
-
let r =
|
|
185
|
-
let t =
|
|
186
|
-
return
|
|
187
|
-
identity_id:
|
|
342
|
+
]), n.device_eligibility_mode !== "reviewed_allowlist" && k();
|
|
343
|
+
let r = M(t.team_id), i = je(Ae(t.memberships, 500).map((e) => {
|
|
344
|
+
let t = A(e);
|
|
345
|
+
return j(t, ["identity_id", "role"]), t.role !== "member" && k(), {
|
|
346
|
+
identity_id: M(t.identity_id),
|
|
188
347
|
role: "member"
|
|
189
348
|
};
|
|
190
|
-
}), (e) => e.identity_id), a =
|
|
191
|
-
let t =
|
|
192
|
-
|
|
349
|
+
}), (e) => e.identity_id), a = je(Ae(t.device_decisions, 500).map((e) => {
|
|
350
|
+
let t = A(e);
|
|
351
|
+
j(t, [
|
|
193
352
|
"device_id",
|
|
194
353
|
"key_fingerprint",
|
|
195
354
|
"enabled",
|
|
196
355
|
"identity_id",
|
|
197
356
|
"decision"
|
|
198
|
-
]), t.decision !== "included" && t.decision !== "excluded" &&
|
|
199
|
-
let n = t.identity_id == null ? null :
|
|
200
|
-
t.decision === "included" != !!n &&
|
|
357
|
+
]), t.decision !== "included" && t.decision !== "excluded" && k(), typeof t.enabled != "boolean" && k();
|
|
358
|
+
let n = t.identity_id == null ? null : M(t.identity_id);
|
|
359
|
+
t.decision === "included" != !!n && k(), t.decision === "included" && !t.enabled && k();
|
|
201
360
|
let r = t.decision;
|
|
202
361
|
return {
|
|
203
|
-
device_id:
|
|
204
|
-
key_fingerprint:
|
|
362
|
+
device_id: M(t.device_id),
|
|
363
|
+
key_fingerprint: N(t.key_fingerprint),
|
|
205
364
|
enabled: t.enabled,
|
|
206
365
|
identity_id: n,
|
|
207
366
|
decision: r
|
|
208
367
|
};
|
|
209
368
|
}), (e) => e.device_id);
|
|
210
|
-
a.length === 0 &&
|
|
211
|
-
let
|
|
212
|
-
(
|
|
213
|
-
let
|
|
214
|
-
let t =
|
|
215
|
-
|
|
369
|
+
a.length === 0 && k();
|
|
370
|
+
let o = new Set(i.map((e) => e.identity_id)), s = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
|
|
371
|
+
(o.size !== s.size || [...s].some((e) => !o.has(e))) && k();
|
|
372
|
+
let c = je(Ae(t.project_mappings, 500).map((e) => {
|
|
373
|
+
let t = A(e);
|
|
374
|
+
j(t, [
|
|
216
375
|
"project_ref",
|
|
217
376
|
"resolved_project_ref",
|
|
218
377
|
"scope_id"
|
|
219
378
|
]);
|
|
220
|
-
let n =
|
|
221
|
-
return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) ||
|
|
379
|
+
let n = M(t.project_ref), r = M(t.resolved_project_ref);
|
|
380
|
+
return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) || k(), /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(r) || k(), {
|
|
222
381
|
project_ref: n,
|
|
223
382
|
resolved_project_ref: r,
|
|
224
|
-
scope_id:
|
|
383
|
+
scope_id: M(t.scope_id)
|
|
225
384
|
};
|
|
226
|
-
}), (e) => e.project_ref),
|
|
227
|
-
for (let e of
|
|
228
|
-
let t =
|
|
229
|
-
t && t !== e.scope_id &&
|
|
230
|
-
}
|
|
231
|
-
let
|
|
232
|
-
let t =
|
|
233
|
-
|
|
234
|
-
let n =
|
|
235
|
-
n !== r &&
|
|
236
|
-
let i =
|
|
237
|
-
return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) ||
|
|
385
|
+
}), (e) => e.project_ref), l = /* @__PURE__ */ new Map();
|
|
386
|
+
for (let e of c) {
|
|
387
|
+
let t = l.get(e.resolved_project_ref);
|
|
388
|
+
t && t !== e.scope_id && k(), l.set(e.resolved_project_ref, e.scope_id);
|
|
389
|
+
}
|
|
390
|
+
let u = je(Ae(t.project_recipients, 500).map((e) => {
|
|
391
|
+
let t = A(e);
|
|
392
|
+
j(t, ["resolved_project_ref", "team_id"]);
|
|
393
|
+
let n = M(t.team_id);
|
|
394
|
+
n !== r && k();
|
|
395
|
+
let i = M(t.resolved_project_ref);
|
|
396
|
+
return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) || k(), {
|
|
238
397
|
resolved_project_ref: i,
|
|
239
398
|
team_id: n
|
|
240
399
|
};
|
|
241
|
-
}), (e) => e.resolved_project_ref),
|
|
242
|
-
JSON.stringify(
|
|
243
|
-
let
|
|
400
|
+
}), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(D), f = u.map((e) => e.resolved_project_ref);
|
|
401
|
+
JSON.stringify(f) !== JSON.stringify(d) && k();
|
|
402
|
+
let p = {
|
|
244
403
|
version: 1,
|
|
245
|
-
coordinator_id:
|
|
246
|
-
candidate_ref:
|
|
247
|
-
candidate_digest:
|
|
404
|
+
coordinator_id: M(t.coordinator_id),
|
|
405
|
+
candidate_ref: Ne(t.candidate_ref),
|
|
406
|
+
candidate_digest: N(t.candidate_digest),
|
|
248
407
|
team_id: r,
|
|
249
|
-
team_digest:
|
|
250
|
-
source_digest:
|
|
251
|
-
finish_digest:
|
|
252
|
-
access_delta_digest:
|
|
408
|
+
team_digest: N(t.team_digest),
|
|
409
|
+
source_digest: N(t.source_digest),
|
|
410
|
+
finish_digest: N(t.finish_digest),
|
|
411
|
+
access_delta_digest: N(t.access_delta_digest),
|
|
253
412
|
team: {
|
|
254
|
-
display_name:
|
|
255
|
-
policy_revision:
|
|
413
|
+
display_name: Oe(n.display_name),
|
|
414
|
+
policy_revision: N(n.policy_revision),
|
|
256
415
|
device_eligibility_mode: "reviewed_allowlist"
|
|
257
416
|
},
|
|
258
417
|
memberships: i,
|
|
259
418
|
device_decisions: a,
|
|
260
|
-
project_mappings:
|
|
261
|
-
project_recipients:
|
|
262
|
-
completed_at:
|
|
419
|
+
project_mappings: c,
|
|
420
|
+
project_recipients: u,
|
|
421
|
+
completed_at: ke(t.completed_at)
|
|
263
422
|
};
|
|
264
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
423
|
+
return new TextEncoder().encode(JSON.stringify(p)).byteLength > 15e5 && k(), p;
|
|
265
424
|
}
|
|
266
|
-
function
|
|
267
|
-
return JSON.stringify(
|
|
425
|
+
function Fe(e) {
|
|
426
|
+
return JSON.stringify(Pe(e));
|
|
268
427
|
}
|
|
269
|
-
function
|
|
270
|
-
e.team_id !==
|
|
428
|
+
function Ie(e) {
|
|
429
|
+
e.team_id !== ge(e.candidate_ref) && k();
|
|
271
430
|
}
|
|
272
|
-
function
|
|
273
|
-
|
|
431
|
+
function Le(e, t) {
|
|
432
|
+
fe(e.coordinator_id, t) !== e.candidate_ref && k();
|
|
274
433
|
}
|
|
275
|
-
function
|
|
276
|
-
|
|
434
|
+
function Re(e, t, n) {
|
|
435
|
+
Le(e, t);
|
|
277
436
|
let r = new Set(e.project_mappings.map((e) => e.scope_id));
|
|
278
|
-
n.length !== r.size &&
|
|
437
|
+
n.length !== r.size && k();
|
|
279
438
|
let i = e.coordinator_id;
|
|
280
|
-
for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) &&
|
|
439
|
+
for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) && k();
|
|
281
440
|
return i;
|
|
282
441
|
}
|
|
283
442
|
//#endregion
|
|
284
443
|
//#region src/coordinator-membership-effects.ts
|
|
285
|
-
var
|
|
444
|
+
var ze = "scope_membership_effect_conflict", Be = {
|
|
286
445
|
device_not_enrolled: "device must be enrolled and enabled in the scope group.",
|
|
287
446
|
scope_group_mismatch: "membership groupId must match the scope groupId.",
|
|
288
447
|
scope_inactive: "scope is not active.",
|
|
289
448
|
scope_not_found: "scopeId must reference an existing scope."
|
|
290
|
-
},
|
|
449
|
+
}, P = class extends Error {
|
|
291
450
|
code;
|
|
292
451
|
constructor(e) {
|
|
293
|
-
super(
|
|
452
|
+
super(Be[e]), this.name = "CoordinatorMembershipError", this.code = e;
|
|
294
453
|
}
|
|
295
454
|
};
|
|
296
|
-
function
|
|
455
|
+
function F(e) {
|
|
297
456
|
return e?.trim() || null;
|
|
298
457
|
}
|
|
299
|
-
function
|
|
300
|
-
let t =
|
|
458
|
+
function Ve(e) {
|
|
459
|
+
let t = F(e);
|
|
301
460
|
if (!t) throw Error("effectId is required.");
|
|
302
461
|
if (t.length > 512 || /[\p{Cc}\p{Cf}]/u.test(t)) throw Error("effectId is invalid.");
|
|
303
462
|
return t;
|
|
304
463
|
}
|
|
305
|
-
function
|
|
464
|
+
function He(e) {
|
|
306
465
|
return JSON.stringify({
|
|
307
|
-
scopeId:
|
|
308
|
-
deviceId:
|
|
309
|
-
role:
|
|
466
|
+
scopeId: F(e.scopeId),
|
|
467
|
+
deviceId: F(e.deviceId),
|
|
468
|
+
role: F(e.role),
|
|
310
469
|
membershipEpoch: e.membershipEpoch ?? null,
|
|
311
|
-
coordinatorId:
|
|
312
|
-
groupId:
|
|
313
|
-
manifestIssuerDeviceId:
|
|
314
|
-
manifestHash:
|
|
315
|
-
signedManifestJson:
|
|
316
|
-
actorType:
|
|
317
|
-
actorId:
|
|
470
|
+
coordinatorId: F(e.coordinatorId),
|
|
471
|
+
groupId: F(e.groupId),
|
|
472
|
+
manifestIssuerDeviceId: F(e.manifestIssuerDeviceId),
|
|
473
|
+
manifestHash: F(e.manifestHash),
|
|
474
|
+
signedManifestJson: F(e.signedManifestJson),
|
|
475
|
+
actorType: F(e.actorType),
|
|
476
|
+
actorId: F(e.actorId)
|
|
318
477
|
});
|
|
319
478
|
}
|
|
320
|
-
function
|
|
479
|
+
function Ue(e) {
|
|
321
480
|
return JSON.stringify({
|
|
322
|
-
scopeId:
|
|
323
|
-
deviceId:
|
|
324
|
-
groupId:
|
|
481
|
+
scopeId: F(e.scopeId),
|
|
482
|
+
deviceId: F(e.deviceId),
|
|
483
|
+
groupId: F(e.groupId),
|
|
325
484
|
membershipEpoch: e.membershipEpoch ?? null,
|
|
326
|
-
manifestHash:
|
|
327
|
-
signedManifestJson:
|
|
328
|
-
actorType:
|
|
329
|
-
actorId:
|
|
485
|
+
manifestHash: F(e.manifestHash),
|
|
486
|
+
signedManifestJson: F(e.signedManifestJson),
|
|
487
|
+
actorType: F(e.actorType),
|
|
488
|
+
actorId: F(e.actorId)
|
|
330
489
|
});
|
|
331
490
|
}
|
|
332
|
-
function
|
|
333
|
-
if (e.action !== t || e.request_json !== n) throw Error(
|
|
491
|
+
function We(e, t, n) {
|
|
492
|
+
if (e.action !== t || e.request_json !== n) throw Error(ze);
|
|
334
493
|
}
|
|
335
|
-
function
|
|
494
|
+
function Ge(e) {
|
|
336
495
|
if (e.action !== "grant" || e.outcome_applied !== 1 || e.role == null || e.status == null || e.membership_epoch == null || e.updated_at == null) throw Error("scope_membership_effect_receipt_invalid");
|
|
337
496
|
return {
|
|
338
497
|
scope_id: e.scope_id,
|
|
@@ -350,242 +509,254 @@ function we(e) {
|
|
|
350
509
|
}
|
|
351
510
|
//#endregion
|
|
352
511
|
//#region src/coordinator-store-contract.ts
|
|
353
|
-
function
|
|
512
|
+
function Ke(e) {
|
|
354
513
|
let t = e.trim(), n = new Date(t);
|
|
355
514
|
if (!t || Number.isNaN(n.getTime())) throw Error("expiresAt must be a valid date.");
|
|
356
515
|
return n.toISOString();
|
|
357
516
|
}
|
|
358
|
-
var
|
|
359
|
-
function
|
|
360
|
-
return typeof e == "string" && e === e.trim() &&
|
|
517
|
+
var qe = /^identity:[A-Za-z0-9_-]{18,24}$/u;
|
|
518
|
+
function Je(e) {
|
|
519
|
+
return typeof e == "string" && e === e.trim() && qe.test(e);
|
|
361
520
|
}
|
|
362
|
-
function
|
|
521
|
+
function Ye(e) {
|
|
363
522
|
return String(e.kind === "team_member" ? e.assigned_identity_id ?? "" : e.target_identity_id ?? "").trim();
|
|
364
523
|
}
|
|
365
|
-
var
|
|
366
|
-
code =
|
|
524
|
+
var Xe = "reciprocal_approval_request_changed", Ze = class extends Error {
|
|
525
|
+
code = Xe;
|
|
367
526
|
constructor() {
|
|
368
|
-
super(
|
|
527
|
+
super(Xe), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
|
|
369
528
|
}
|
|
370
|
-
},
|
|
371
|
-
function
|
|
529
|
+
}, Qe = 120, $e = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, et = /^(?:actor|device|identity|local):\S+$/iu, tt = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, nt = /^pending[_-]\S+$/iu, rt = /^[a-f0-9]{12,64}$/iu, it = /^(?=.{1,253}$)(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.local)$/iu;
|
|
530
|
+
function I(e, t) {
|
|
372
531
|
if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
|
|
373
532
|
let n = e.replace(/\s+/gu, " ").trim();
|
|
374
533
|
if (!n) throw Error(`${t}_required`);
|
|
375
|
-
if ([...n].length >
|
|
534
|
+
if ([...n].length > Qe) throw Error(`${t}_too_long`);
|
|
376
535
|
return n;
|
|
377
536
|
}
|
|
378
|
-
function
|
|
537
|
+
function L(e) {
|
|
379
538
|
if (typeof e != "string") return !1;
|
|
380
539
|
let t;
|
|
381
540
|
try {
|
|
382
|
-
t =
|
|
541
|
+
t = I(e, "display_name");
|
|
383
542
|
} catch {
|
|
384
543
|
return !1;
|
|
385
544
|
}
|
|
386
545
|
return ![
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
546
|
+
$e,
|
|
547
|
+
et,
|
|
548
|
+
tt,
|
|
549
|
+
nt,
|
|
550
|
+
rt
|
|
392
551
|
].some((e) => e.test(t));
|
|
393
552
|
}
|
|
394
|
-
function
|
|
395
|
-
let n =
|
|
396
|
-
if (!
|
|
553
|
+
function R(e, t) {
|
|
554
|
+
let n = I(e, t);
|
|
555
|
+
if (!L(n)) throw Error(`${t}_invalid`);
|
|
556
|
+
return n;
|
|
557
|
+
}
|
|
558
|
+
function at(e, t) {
|
|
559
|
+
let n = I(e, t);
|
|
560
|
+
if (!it.test(n) && !L(n)) throw Error(`${t}_invalid`);
|
|
397
561
|
return n;
|
|
398
562
|
}
|
|
399
|
-
function
|
|
400
|
-
let t = String(e ?? "").replace(/\.local$/iu, "");
|
|
401
|
-
return
|
|
563
|
+
function ot(e) {
|
|
564
|
+
let t = String(e ?? "").trim(), n = t.replace(/\.local$/iu, "");
|
|
565
|
+
return n ? at(it.test(t) ? n : n.replace(/[-_]+/gu, " "), "device_display_name") : null;
|
|
402
566
|
}
|
|
403
|
-
function
|
|
567
|
+
function st(e) {
|
|
404
568
|
for (let t of [
|
|
405
569
|
e.explicitName,
|
|
406
570
|
e.osName,
|
|
407
571
|
e.coordinatorName
|
|
408
572
|
]) {
|
|
409
|
-
let e = String(t ?? "").replace(/\.local$/iu, "")
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
|
|
573
|
+
let e = String(t ?? "").trim(), n = e.replace(/\.local$/iu, "");
|
|
574
|
+
if (it.test(e)) {
|
|
575
|
+
try {
|
|
576
|
+
let t = ot(e);
|
|
577
|
+
if (t) return t;
|
|
578
|
+
} catch {}
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
if (!(!n || !L(n))) try {
|
|
582
|
+
let e = ot(t);
|
|
583
|
+
if (e && L(e)) return e;
|
|
413
584
|
} catch {}
|
|
414
585
|
}
|
|
415
586
|
let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
|
|
416
587
|
return t ? `Codemem device ${t}` : "Codemem device";
|
|
417
588
|
}
|
|
418
|
-
function
|
|
589
|
+
function ct(e) {
|
|
419
590
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("project_summaries_invalid");
|
|
420
591
|
return e.map((e) => {
|
|
421
592
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("project_summaries_invalid");
|
|
422
593
|
let t = e;
|
|
423
594
|
if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
|
|
424
595
|
return {
|
|
425
|
-
display_name:
|
|
596
|
+
display_name: I(String(t.display_name ?? ""), "project_name"),
|
|
426
597
|
existing_memory_count: Number(t.existing_memory_count)
|
|
427
598
|
};
|
|
428
599
|
});
|
|
429
600
|
}
|
|
430
601
|
//#endregion
|
|
431
602
|
//#region src/recipient-reviewed-intent.ts
|
|
432
|
-
var
|
|
603
|
+
var lt = 1, z = class extends Error {
|
|
433
604
|
code;
|
|
434
605
|
constructor(e) {
|
|
435
606
|
super(e), this.name = "RecipientReviewedIntentError", this.code = e;
|
|
436
607
|
}
|
|
437
|
-
},
|
|
438
|
-
function
|
|
439
|
-
throw new
|
|
608
|
+
}, ut = /[\p{Cc}\p{Cf}]/u, dt = 100, ft = 65536;
|
|
609
|
+
function B() {
|
|
610
|
+
throw new z("recipient_reviewed_intent_invalid");
|
|
440
611
|
}
|
|
441
|
-
function
|
|
442
|
-
return (!e || typeof e != "object" || Array.isArray(e)) &&
|
|
612
|
+
function V(e) {
|
|
613
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && B(), e;
|
|
443
614
|
}
|
|
444
|
-
function
|
|
445
|
-
Object.keys(e).some((e) => !t.includes(e)) &&
|
|
615
|
+
function H(e, t) {
|
|
616
|
+
Object.keys(e).some((e) => !t.includes(e)) && B();
|
|
446
617
|
}
|
|
447
|
-
function
|
|
448
|
-
return (typeof e != "string" || !e || e !== e.trim() || e.length > t ||
|
|
618
|
+
function U(e, t) {
|
|
619
|
+
return (typeof e != "string" || !e || e !== e.trim() || e.length > t || ut.test(e)) && B(), e;
|
|
449
620
|
}
|
|
450
|
-
function
|
|
451
|
-
(typeof e != "string" ||
|
|
621
|
+
function pt(e) {
|
|
622
|
+
(typeof e != "string" || ut.test(e)) && B();
|
|
452
623
|
let t = e.trim().replace(/\s+/gu, " ");
|
|
453
|
-
return (!t || t.length > 256) &&
|
|
624
|
+
return (!t || t.length > 256) && B(), t;
|
|
454
625
|
}
|
|
455
|
-
function
|
|
456
|
-
typeof e != "string" &&
|
|
626
|
+
function mt(e) {
|
|
627
|
+
typeof e != "string" && B();
|
|
457
628
|
try {
|
|
458
|
-
return
|
|
629
|
+
return I(e, "identity_display_name");
|
|
459
630
|
} catch {
|
|
460
|
-
return
|
|
631
|
+
return B();
|
|
461
632
|
}
|
|
462
633
|
}
|
|
463
|
-
function
|
|
464
|
-
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) &&
|
|
634
|
+
function ht(e) {
|
|
635
|
+
return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && B(), e;
|
|
465
636
|
}
|
|
466
|
-
function
|
|
637
|
+
function gt(e, t) {
|
|
467
638
|
return e < t ? -1 : +(e > t);
|
|
468
639
|
}
|
|
469
|
-
function
|
|
640
|
+
function _t(e) {
|
|
470
641
|
return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
|
|
471
642
|
}
|
|
472
|
-
function
|
|
473
|
-
let t =
|
|
474
|
-
return t.kind === "direct" ? (
|
|
643
|
+
function vt(e) {
|
|
644
|
+
let t = V(e);
|
|
645
|
+
return t.kind === "direct" ? (H(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && B(), H(t, [
|
|
475
646
|
"kind",
|
|
476
647
|
"teamId",
|
|
477
648
|
"displayName"
|
|
478
649
|
]), {
|
|
479
650
|
kind: "team",
|
|
480
|
-
teamId:
|
|
481
|
-
displayName:
|
|
651
|
+
teamId: U(t.teamId, 256),
|
|
652
|
+
displayName: pt(t.displayName)
|
|
482
653
|
});
|
|
483
654
|
}
|
|
484
|
-
function
|
|
485
|
-
let t =
|
|
486
|
-
|
|
655
|
+
function yt(e) {
|
|
656
|
+
let t = V(e);
|
|
657
|
+
H(t, [
|
|
487
658
|
"canonicalProjectIdentity",
|
|
488
659
|
"displayName",
|
|
489
660
|
"existingMemoryCount",
|
|
490
661
|
"futureMemoriesShared",
|
|
491
662
|
"sources"
|
|
492
|
-
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) &&
|
|
493
|
-
let n = t.sources.map(
|
|
494
|
-
return new Set(n.map(
|
|
495
|
-
canonicalProjectIdentity:
|
|
496
|
-
displayName:
|
|
497
|
-
existingMemoryCount:
|
|
663
|
+
]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && B();
|
|
664
|
+
let n = t.sources.map(vt).toSorted((e, t) => gt(_t(e), _t(t)));
|
|
665
|
+
return new Set(n.map(_t)).size !== n.length && B(), {
|
|
666
|
+
canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
|
|
667
|
+
displayName: pt(t.displayName),
|
|
668
|
+
existingMemoryCount: ht(t.existingMemoryCount),
|
|
498
669
|
futureMemoriesShared: !0,
|
|
499
670
|
sources: n
|
|
500
671
|
};
|
|
501
672
|
}
|
|
502
|
-
function
|
|
503
|
-
let t =
|
|
504
|
-
return
|
|
673
|
+
function bt(e) {
|
|
674
|
+
let t = V(e);
|
|
675
|
+
return H(t, [
|
|
505
676
|
"canonicalProjectIdentity",
|
|
506
677
|
"displayName",
|
|
507
678
|
"existingMemoryCount"
|
|
508
679
|
]), {
|
|
509
|
-
canonicalProjectIdentity:
|
|
510
|
-
displayName:
|
|
511
|
-
existingMemoryCount:
|
|
680
|
+
canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
|
|
681
|
+
displayName: pt(t.displayName),
|
|
682
|
+
existingMemoryCount: ht(t.existingMemoryCount)
|
|
512
683
|
};
|
|
513
684
|
}
|
|
514
|
-
function
|
|
515
|
-
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length >
|
|
516
|
-
let t = e.projects.map(
|
|
517
|
-
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) &&
|
|
685
|
+
function xt(e) {
|
|
686
|
+
(!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > dt) && B();
|
|
687
|
+
let t = e.projects.map(yt).toSorted((e, t) => gt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(bt).toSorted((e, t) => gt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
|
|
688
|
+
return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && B(), {
|
|
518
689
|
projects: t,
|
|
519
690
|
excludedProjects: n
|
|
520
691
|
};
|
|
521
692
|
}
|
|
522
|
-
function
|
|
523
|
-
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
|
|
693
|
+
function St(e, t) {
|
|
694
|
+
if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new z("recipient_invite_intent_mismatch");
|
|
524
695
|
}
|
|
525
|
-
function
|
|
526
|
-
let n =
|
|
527
|
-
n.version !== 1 &&
|
|
528
|
-
let r =
|
|
696
|
+
function Ct(e, t) {
|
|
697
|
+
let n = V(e);
|
|
698
|
+
n.version !== 1 && B();
|
|
699
|
+
let r = xt(n), i;
|
|
529
700
|
if (n.journey === "team") {
|
|
530
|
-
|
|
701
|
+
H(n, [
|
|
531
702
|
"version",
|
|
532
703
|
"journey",
|
|
533
704
|
"team",
|
|
534
705
|
"projects",
|
|
535
706
|
"excludedProjects"
|
|
536
707
|
]);
|
|
537
|
-
let e =
|
|
538
|
-
|
|
708
|
+
let e = V(n.team);
|
|
709
|
+
H(e, [
|
|
539
710
|
"teamId",
|
|
540
711
|
"displayName",
|
|
541
712
|
"futureProjectsInherit"
|
|
542
|
-
]), e.futureProjectsInherit !== !0 &&
|
|
713
|
+
]), e.futureProjectsInherit !== !0 && B(), i = {
|
|
543
714
|
version: 1,
|
|
544
715
|
journey: "team",
|
|
545
716
|
team: {
|
|
546
|
-
teamId:
|
|
547
|
-
displayName:
|
|
717
|
+
teamId: U(e.teamId, 256),
|
|
718
|
+
displayName: pt(e.displayName),
|
|
548
719
|
futureProjectsInherit: !0
|
|
549
720
|
},
|
|
550
721
|
...r
|
|
551
722
|
};
|
|
552
723
|
} else if (n.journey === "add_device") {
|
|
553
|
-
|
|
724
|
+
H(n, [
|
|
554
725
|
"version",
|
|
555
726
|
"journey",
|
|
556
727
|
"targetIdentity",
|
|
557
728
|
"projects",
|
|
558
729
|
"excludedProjects"
|
|
559
730
|
]);
|
|
560
|
-
let e =
|
|
561
|
-
|
|
731
|
+
let e = V(n.targetIdentity);
|
|
732
|
+
H(e, ["identityId", "displayName"]), i = {
|
|
562
733
|
version: 1,
|
|
563
734
|
journey: "add_device",
|
|
564
735
|
targetIdentity: {
|
|
565
|
-
identityId:
|
|
566
|
-
displayName:
|
|
736
|
+
identityId: U(e.identityId, 256),
|
|
737
|
+
displayName: mt(e.displayName)
|
|
567
738
|
},
|
|
568
739
|
...r
|
|
569
740
|
};
|
|
570
|
-
} else
|
|
571
|
-
return t &&
|
|
741
|
+
} else B();
|
|
742
|
+
return t && St(i, t), new TextEncoder().encode(W(i)).byteLength > ft && B(), i;
|
|
572
743
|
}
|
|
573
|
-
function
|
|
574
|
-
return Array.isArray(e) ? `[${e.map(
|
|
744
|
+
function W(e) {
|
|
745
|
+
return Array.isArray(e) ? `[${e.map(W).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => gt(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${W(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
|
|
575
746
|
}
|
|
576
|
-
function
|
|
577
|
-
return
|
|
747
|
+
function wt(e, t) {
|
|
748
|
+
return W(Ct(e, t));
|
|
578
749
|
}
|
|
579
|
-
async function
|
|
580
|
-
let n =
|
|
750
|
+
async function Tt(e, t) {
|
|
751
|
+
let n = wt(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
|
|
581
752
|
return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
|
|
582
753
|
}
|
|
583
|
-
async function
|
|
584
|
-
let n =
|
|
585
|
-
if (await
|
|
754
|
+
async function Et(e, t) {
|
|
755
|
+
let n = Ct(e, t.target);
|
|
756
|
+
if (await Tt(n) !== t.digest) throw new z("recipient_invite_intent_mismatch");
|
|
586
757
|
return n;
|
|
587
758
|
}
|
|
588
|
-
async function
|
|
759
|
+
async function Dt(e, t) {
|
|
589
760
|
if (!e) throw Error("recipient_invite_review_unavailable");
|
|
590
761
|
let n;
|
|
591
762
|
try {
|
|
@@ -594,21 +765,21 @@ async function at(e, t) {
|
|
|
594
765
|
throw Error("recipient_invite_review_unavailable");
|
|
595
766
|
}
|
|
596
767
|
try {
|
|
597
|
-
let r =
|
|
598
|
-
if (
|
|
599
|
-
return await
|
|
768
|
+
let r = Ct(n, t.target);
|
|
769
|
+
if (W(r) !== e) throw Error("recipient_invite_review_unavailable");
|
|
770
|
+
return await Et(r, t);
|
|
600
771
|
} catch (e) {
|
|
601
|
-
throw e instanceof
|
|
772
|
+
throw e instanceof z && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
|
|
602
773
|
}
|
|
603
774
|
}
|
|
604
775
|
//#endregion
|
|
605
776
|
//#region src/sync-fingerprint.ts
|
|
606
|
-
function
|
|
777
|
+
function Ot(e) {
|
|
607
778
|
return t("sha256").update(e, "utf-8").digest("hex");
|
|
608
779
|
}
|
|
609
780
|
//#endregion
|
|
610
781
|
//#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/compose.js
|
|
611
|
-
var
|
|
782
|
+
var kt = (e, t, n) => (r, i) => {
|
|
612
783
|
let a = -1;
|
|
613
784
|
return o(0);
|
|
614
785
|
async function o(s) {
|
|
@@ -624,45 +795,45 @@ var st = (e, t, n) => (r, i) => {
|
|
|
624
795
|
else r.finalized === !1 && n && (c = await n(r));
|
|
625
796
|
return c && (r.finalized === !1 || l) && (r.res = c), r;
|
|
626
797
|
}
|
|
627
|
-
},
|
|
628
|
-
let { all: n = !1, dot: r = !1 } = t, i = (
|
|
629
|
-
return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ?
|
|
798
|
+
}, At = /* @__PURE__ */ Symbol(), jt = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), Mt = 32, Nt = 1e4, Pt = (e) => "headers" in e, Ft = async (e, t = /* @__PURE__ */ Object.create(null)) => {
|
|
799
|
+
let { all: n = !1, dot: r = !1 } = t, i = (Pt(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
800
|
+
return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? It(e, {
|
|
630
801
|
all: n,
|
|
631
802
|
dot: r
|
|
632
803
|
}) : {};
|
|
633
804
|
};
|
|
634
|
-
async function
|
|
635
|
-
if (!
|
|
636
|
-
let n =
|
|
637
|
-
|
|
805
|
+
async function It(e, t) {
|
|
806
|
+
if (!Pt(e) && e.bodyCache.formData) return Lt(await e.bodyCache.formData, t);
|
|
807
|
+
let n = Pt(e) ? e.headers : e.raw.headers, r = jt(await e.arrayBuffer(), n.get("Content-Type") || "");
|
|
808
|
+
Pt(e) || (e.bodyCache.formData = r);
|
|
638
809
|
let i = await r;
|
|
639
|
-
return i ?
|
|
810
|
+
return i ? Lt(i, t) : {};
|
|
640
811
|
}
|
|
641
|
-
function
|
|
812
|
+
function Lt(e, t) {
|
|
642
813
|
let n = /* @__PURE__ */ Object.create(null), r = { count: 0 };
|
|
643
814
|
return e.forEach((e, r) => {
|
|
644
|
-
t.all || r.endsWith("[]") ?
|
|
815
|
+
t.all || r.endsWith("[]") ? Rt(n, r, e) : n[r] = e;
|
|
645
816
|
}), t.dot && Object.entries(n).forEach(([e, t]) => {
|
|
646
|
-
e.includes(".") && (
|
|
817
|
+
e.includes(".") && (zt(n, e, t, r), delete n[e]);
|
|
647
818
|
}), n;
|
|
648
819
|
}
|
|
649
|
-
var
|
|
820
|
+
var Rt = (e, t, n) => {
|
|
650
821
|
e[t] === void 0 ? e[t] = t.endsWith("[]") ? [n] : n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
|
|
651
|
-
},
|
|
822
|
+
}, zt = (e, t, n, r) => {
|
|
652
823
|
if (/(?:^|\.)__proto__\./.test(t)) return;
|
|
653
|
-
let i = e, a = t.split(".",
|
|
654
|
-
a.length >
|
|
655
|
-
t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >=
|
|
824
|
+
let i = e, a = t.split(".", Mt + 2);
|
|
825
|
+
a.length > Mt + 1 && Bt(), a.forEach((e, t) => {
|
|
826
|
+
t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= Nt && Bt(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
|
|
656
827
|
});
|
|
657
|
-
},
|
|
828
|
+
}, Bt = () => {
|
|
658
829
|
throw Error("Nesting limit exceeded");
|
|
659
|
-
},
|
|
830
|
+
}, Vt = (e) => {
|
|
660
831
|
let t = e.split("/");
|
|
661
832
|
return t[0] === "" && t.shift(), t;
|
|
662
|
-
},
|
|
663
|
-
let { groups: t, path: n } =
|
|
664
|
-
return
|
|
665
|
-
},
|
|
833
|
+
}, Ht = (e) => {
|
|
834
|
+
let { groups: t, path: n } = Ut(e);
|
|
835
|
+
return Wt(Vt(n), t);
|
|
836
|
+
}, Ut = (e) => {
|
|
666
837
|
let t = [];
|
|
667
838
|
return e = e.replace(/\{[^}]+\}/g, (e, n) => {
|
|
668
839
|
let r = `@${n}`;
|
|
@@ -671,7 +842,7 @@ var gt = (e, t, n) => {
|
|
|
671
842
|
groups: t,
|
|
672
843
|
path: e
|
|
673
844
|
};
|
|
674
|
-
},
|
|
845
|
+
}, Wt = (e, t) => {
|
|
675
846
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
676
847
|
let [r] = t[n];
|
|
677
848
|
for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
|
|
@@ -680,12 +851,12 @@ var gt = (e, t, n) => {
|
|
|
680
851
|
}
|
|
681
852
|
}
|
|
682
853
|
return e;
|
|
683
|
-
},
|
|
854
|
+
}, Gt = {}, Kt = (e, t) => {
|
|
684
855
|
if (e === "*") return "*";
|
|
685
856
|
let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
686
857
|
if (n) {
|
|
687
858
|
let r = `${e}#${t}`;
|
|
688
|
-
return
|
|
859
|
+
return Gt[r] || (Gt[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
|
|
689
860
|
r,
|
|
690
861
|
n[1],
|
|
691
862
|
RegExp(`^${n[2]}(?=/${t})`)
|
|
@@ -697,10 +868,10 @@ var gt = (e, t, n) => {
|
|
|
697
868
|
e,
|
|
698
869
|
n[1],
|
|
699
870
|
!0
|
|
700
|
-
]),
|
|
871
|
+
]), Gt[r];
|
|
701
872
|
}
|
|
702
873
|
return null;
|
|
703
|
-
},
|
|
874
|
+
}, qt = (e, t) => {
|
|
704
875
|
try {
|
|
705
876
|
return t(e);
|
|
706
877
|
} catch {
|
|
@@ -712,21 +883,21 @@ var gt = (e, t, n) => {
|
|
|
712
883
|
}
|
|
713
884
|
});
|
|
714
885
|
}
|
|
715
|
-
},
|
|
886
|
+
}, Jt = (e) => qt(e, decodeURI), Yt = (e) => {
|
|
716
887
|
let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
|
|
717
888
|
for (; r < t.length; r++) {
|
|
718
889
|
let e = t.charCodeAt(r);
|
|
719
890
|
if (e === 37) {
|
|
720
891
|
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);
|
|
721
|
-
return
|
|
892
|
+
return Jt(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
|
|
722
893
|
}
|
|
723
894
|
if (e === 63 || e === 35) break;
|
|
724
895
|
}
|
|
725
896
|
return t.slice(n, r);
|
|
726
|
-
},
|
|
727
|
-
let t =
|
|
897
|
+
}, Xt = (e) => {
|
|
898
|
+
let t = Yt(e);
|
|
728
899
|
return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
|
|
729
|
-
},
|
|
900
|
+
}, G = (e, t, ...n) => (n.length && (t = G(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), Zt = (e) => {
|
|
730
901
|
if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
|
|
731
902
|
let t = e.split("/"), n = [], r = "";
|
|
732
903
|
return t.forEach((e) => {
|
|
@@ -739,7 +910,7 @@ var gt = (e, t, n) => {
|
|
|
739
910
|
} else r += "/" + e;
|
|
740
911
|
}
|
|
741
912
|
}), n.filter((e, t, n) => n.indexOf(e) === t);
|
|
742
|
-
},
|
|
913
|
+
}, Qt = (e) => e.indexOf("%") === -1 ? e : qt(e, rn), $t = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), Qt(e)), en = (e, t, n) => {
|
|
743
914
|
let r = e.indexOf("#", 8);
|
|
744
915
|
r !== -1 && (e = e.slice(0, r));
|
|
745
916
|
let i;
|
|
@@ -750,7 +921,7 @@ var gt = (e, t, n) => {
|
|
|
750
921
|
let r = e.charCodeAt(n + t.length + 1);
|
|
751
922
|
if (r === 61) {
|
|
752
923
|
let r = n + t.length + 2, i = e.indexOf("&", r);
|
|
753
|
-
return
|
|
924
|
+
return $t(e.slice(r, i === -1 ? void 0 : i));
|
|
754
925
|
}
|
|
755
926
|
if (r == 38 || isNaN(r)) return "";
|
|
756
927
|
n = e.indexOf(`&${t}`, n + 1);
|
|
@@ -764,12 +935,12 @@ var gt = (e, t, n) => {
|
|
|
764
935
|
let t = e.indexOf("&", o + 1), r = e.indexOf("=", o);
|
|
765
936
|
r > t && t !== -1 && (r = -1);
|
|
766
937
|
let s = e.slice(o + 1, r === -1 ? t === -1 ? void 0 : t : r);
|
|
767
|
-
if (i && (s =
|
|
938
|
+
if (i && (s = $t(s)), o = t, s === "") continue;
|
|
768
939
|
let c;
|
|
769
|
-
r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c =
|
|
940
|
+
r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = $t(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
|
|
770
941
|
}
|
|
771
942
|
return t ? a[t] : a;
|
|
772
|
-
},
|
|
943
|
+
}, tn = en, nn = (e, t) => en(e, t, !0), rn = decodeURIComponent, an = class {
|
|
773
944
|
raw;
|
|
774
945
|
#e;
|
|
775
946
|
#t;
|
|
@@ -784,13 +955,13 @@ var gt = (e, t, n) => {
|
|
|
784
955
|
}
|
|
785
956
|
#n(e) {
|
|
786
957
|
let t = this.#t[0][this.routeIndex]?.[1][e], n = this.#i(t);
|
|
787
|
-
return n &&
|
|
958
|
+
return n && Qt(n);
|
|
788
959
|
}
|
|
789
960
|
#r() {
|
|
790
961
|
let e = {}, t = Object.keys(this.#t[0][this.routeIndex]?.[1] ?? {});
|
|
791
962
|
for (let n of t) {
|
|
792
963
|
let t = this.#i(this.#t[0][this.routeIndex][1][n]);
|
|
793
|
-
t !== void 0 && (e[n] =
|
|
964
|
+
t !== void 0 && (e[n] = Qt(t));
|
|
794
965
|
}
|
|
795
966
|
return e;
|
|
796
967
|
}
|
|
@@ -798,10 +969,10 @@ var gt = (e, t, n) => {
|
|
|
798
969
|
return this.#t[1] ? this.#t[1][e] : e;
|
|
799
970
|
}
|
|
800
971
|
query(e) {
|
|
801
|
-
return
|
|
972
|
+
return tn(this.url, e);
|
|
802
973
|
}
|
|
803
974
|
queries(e) {
|
|
804
|
-
return
|
|
975
|
+
return nn(this.url, e);
|
|
805
976
|
}
|
|
806
977
|
header(e) {
|
|
807
978
|
if (e) return this.raw.headers.get(e) ?? void 0;
|
|
@@ -811,7 +982,7 @@ var gt = (e, t, n) => {
|
|
|
811
982
|
}), t;
|
|
812
983
|
}
|
|
813
984
|
async parseBody(e) {
|
|
814
|
-
return
|
|
985
|
+
return Ft(this, e);
|
|
815
986
|
}
|
|
816
987
|
#a = (e) => {
|
|
817
988
|
let { bodyCache: t, raw: n } = this, r = t[e];
|
|
@@ -849,7 +1020,7 @@ var gt = (e, t, n) => {
|
|
|
849
1020
|
get method() {
|
|
850
1021
|
return this.raw.method;
|
|
851
1022
|
}
|
|
852
|
-
get [
|
|
1023
|
+
get [At]() {
|
|
853
1024
|
return this.#t;
|
|
854
1025
|
}
|
|
855
1026
|
get matchedRoutes() {
|
|
@@ -858,14 +1029,14 @@ var gt = (e, t, n) => {
|
|
|
858
1029
|
get routePath() {
|
|
859
1030
|
return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
|
|
860
1031
|
}
|
|
861
|
-
},
|
|
1032
|
+
}, on = {
|
|
862
1033
|
Stringify: 1,
|
|
863
1034
|
BeforeStream: 2,
|
|
864
1035
|
Stream: 3
|
|
865
|
-
},
|
|
1036
|
+
}, sn = (e, t) => {
|
|
866
1037
|
let n = new String(e);
|
|
867
1038
|
return n.isEscaped = !0, n.callbacks = t, n;
|
|
868
|
-
},
|
|
1039
|
+
}, cn = async (e, t, n, r, i) => {
|
|
869
1040
|
typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
|
|
870
1041
|
let a = e.callbacks;
|
|
871
1042
|
if (!a?.length) return Promise.resolve(e);
|
|
@@ -874,12 +1045,12 @@ var gt = (e, t, n) => {
|
|
|
874
1045
|
phase: t,
|
|
875
1046
|
buffer: i,
|
|
876
1047
|
context: r
|
|
877
|
-
}))).then((e) => Promise.all(e.filter(Boolean).map((e) =>
|
|
878
|
-
return n ?
|
|
879
|
-
},
|
|
1048
|
+
}))).then((e) => Promise.all(e.filter(Boolean).map((e) => cn(e, t, !1, r, i))).then(() => i[0]));
|
|
1049
|
+
return n ? sn(await o, a) : o;
|
|
1050
|
+
}, ln = "text/plain; charset=UTF-8", un = (e, t) => ({
|
|
880
1051
|
"Content-Type": e,
|
|
881
1052
|
...t
|
|
882
|
-
}),
|
|
1053
|
+
}), K = (e, t) => new Response(e, t), dn = class {
|
|
883
1054
|
#e;
|
|
884
1055
|
#t;
|
|
885
1056
|
env = {};
|
|
@@ -899,7 +1070,7 @@ var gt = (e, t, n) => {
|
|
|
899
1070
|
this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
|
|
900
1071
|
}
|
|
901
1072
|
get req() {
|
|
902
|
-
return this.#t ??= new
|
|
1073
|
+
return this.#t ??= new an(this.#e, this.#d, this.#u), this.#t;
|
|
903
1074
|
}
|
|
904
1075
|
get event() {
|
|
905
1076
|
if (this.#i && "respondWith" in this.#i) return this.#i;
|
|
@@ -910,11 +1081,11 @@ var gt = (e, t, n) => {
|
|
|
910
1081
|
throw Error("This context has no ExecutionContext");
|
|
911
1082
|
}
|
|
912
1083
|
get res() {
|
|
913
|
-
return this.#a ||=
|
|
1084
|
+
return this.#a ||= K(null, { headers: this.#l ??= new Headers() });
|
|
914
1085
|
}
|
|
915
1086
|
set res(e) {
|
|
916
1087
|
if (this.#a && e) {
|
|
917
|
-
e =
|
|
1088
|
+
e = K(e.body, e);
|
|
918
1089
|
for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") {
|
|
919
1090
|
if (t === "set-cookie") {
|
|
920
1091
|
let t = this.#a.headers.getSetCookie();
|
|
@@ -932,7 +1103,7 @@ var gt = (e, t, n) => {
|
|
|
932
1103
|
this.#s = e;
|
|
933
1104
|
};
|
|
934
1105
|
header = (e, t, n) => {
|
|
935
|
-
this.finalized && (this.#a =
|
|
1106
|
+
this.finalized && (this.#a = K(this.#a.body, this.#a));
|
|
936
1107
|
let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
|
|
937
1108
|
t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
|
|
938
1109
|
};
|
|
@@ -969,25 +1140,25 @@ var gt = (e, t, n) => {
|
|
|
969
1140
|
}
|
|
970
1141
|
}
|
|
971
1142
|
}
|
|
972
|
-
return
|
|
1143
|
+
return K(e, {
|
|
973
1144
|
status: typeof t == "number" ? t : t?.status ?? this.#r,
|
|
974
1145
|
headers: r ?? n
|
|
975
1146
|
});
|
|
976
1147
|
}
|
|
977
1148
|
newResponse = (...e) => this.#f(...e);
|
|
978
1149
|
body = (e, t, n) => this.#f(e, t, n);
|
|
979
|
-
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t,
|
|
980
|
-
json = (e, t, n) => this.#f(JSON.stringify(e), t,
|
|
1150
|
+
text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, un(ln, n));
|
|
1151
|
+
json = (e, t, n) => this.#f(JSON.stringify(e), t, un("application/json", n));
|
|
981
1152
|
html = (e, t, n) => {
|
|
982
|
-
let r = (e) => this.#f(e, t,
|
|
983
|
-
return typeof e == "object" ?
|
|
1153
|
+
let r = (e) => this.#f(e, t, un("text/html; charset=UTF-8", n));
|
|
1154
|
+
return typeof e == "object" ? cn(e, on.Stringify, !1, {}).then(r) : r(e);
|
|
984
1155
|
};
|
|
985
1156
|
redirect = (e, t) => {
|
|
986
1157
|
let n = String(e);
|
|
987
1158
|
return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
|
|
988
1159
|
};
|
|
989
|
-
notFound = () => (this.#c ??= () =>
|
|
990
|
-
},
|
|
1160
|
+
notFound = () => (this.#c ??= () => K(), this.#c(this));
|
|
1161
|
+
}, fn = [
|
|
991
1162
|
"get",
|
|
992
1163
|
"post",
|
|
993
1164
|
"put",
|
|
@@ -995,13 +1166,13 @@ var gt = (e, t, n) => {
|
|
|
995
1166
|
"options",
|
|
996
1167
|
"patch",
|
|
997
1168
|
"query"
|
|
998
|
-
],
|
|
1169
|
+
], pn = "Can not add a route since the matcher is already built.", mn = class extends Error {}, hn = "__COMPOSED_HANDLER", gn = (e) => e.text("404 Not Found", 404), _n = (e, t) => {
|
|
999
1170
|
if ("getResponse" in e) {
|
|
1000
1171
|
let n = e.getResponse();
|
|
1001
1172
|
return t.newResponse(n.body, n);
|
|
1002
1173
|
}
|
|
1003
1174
|
return console.error(e), t.text("Internal Server Error", 500);
|
|
1004
|
-
},
|
|
1175
|
+
}, vn = class e {
|
|
1005
1176
|
get;
|
|
1006
1177
|
post;
|
|
1007
1178
|
put;
|
|
@@ -1018,7 +1189,7 @@ var gt = (e, t, n) => {
|
|
|
1018
1189
|
#e = "/";
|
|
1019
1190
|
routes = [];
|
|
1020
1191
|
constructor(e = {}) {
|
|
1021
|
-
[...
|
|
1192
|
+
[...fn, "all"].forEach((e) => {
|
|
1022
1193
|
this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
|
|
1023
1194
|
this.#r(e, this.#e, t);
|
|
1024
1195
|
}), this);
|
|
@@ -1034,7 +1205,7 @@ var gt = (e, t, n) => {
|
|
|
1034
1205
|
this.#r("ALL", this.#e, e);
|
|
1035
1206
|
}), this);
|
|
1036
1207
|
let { strict: t, ...n } = e;
|
|
1037
|
-
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ??
|
|
1208
|
+
Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? Yt : Xt;
|
|
1038
1209
|
}
|
|
1039
1210
|
#t() {
|
|
1040
1211
|
let t = new e({
|
|
@@ -1043,18 +1214,18 @@ var gt = (e, t, n) => {
|
|
|
1043
1214
|
});
|
|
1044
1215
|
return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
|
|
1045
1216
|
}
|
|
1046
|
-
#n =
|
|
1047
|
-
errorHandler =
|
|
1217
|
+
#n = gn;
|
|
1218
|
+
errorHandler = _n;
|
|
1048
1219
|
route(e, t) {
|
|
1049
1220
|
let n = this.basePath(e);
|
|
1050
1221
|
return t.routes.map((e) => {
|
|
1051
1222
|
let r;
|
|
1052
|
-
t.errorHandler ===
|
|
1223
|
+
t.errorHandler === _n ? r = e.handler : (r = async (n, r) => (await kt([], t.errorHandler)(n, () => e.handler(n, r))).res, r[hn] = e.handler), n.#r(e.method, e.path, r, e.basePath);
|
|
1053
1224
|
}), this;
|
|
1054
1225
|
}
|
|
1055
1226
|
basePath(e) {
|
|
1056
1227
|
let t = this.#t();
|
|
1057
|
-
return t._basePath =
|
|
1228
|
+
return t._basePath = G(this._basePath, e), t;
|
|
1058
1229
|
}
|
|
1059
1230
|
onError = (e) => (this.errorHandler = e, this);
|
|
1060
1231
|
notFound = (e) => (this.#n = e, this);
|
|
@@ -1072,21 +1243,21 @@ var gt = (e, t, n) => {
|
|
|
1072
1243
|
return [e.env, t];
|
|
1073
1244
|
};
|
|
1074
1245
|
return r ||= (() => {
|
|
1075
|
-
let t =
|
|
1246
|
+
let t = G(this._basePath, e), n = t === "/" ? 0 : t.length;
|
|
1076
1247
|
return (e) => {
|
|
1077
1248
|
let t = new URL(e.url);
|
|
1078
1249
|
return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
|
|
1079
1250
|
};
|
|
1080
|
-
})(), this.#r("ALL",
|
|
1251
|
+
})(), this.#r("ALL", G(e, "*"), async (e, n) => {
|
|
1081
1252
|
let i = await t(r(e.req.raw), ...a(e));
|
|
1082
1253
|
if (i) return i;
|
|
1083
1254
|
await n();
|
|
1084
1255
|
}), this;
|
|
1085
1256
|
}
|
|
1086
1257
|
#r(e, t, n, r) {
|
|
1087
|
-
e = e.toUpperCase(), t =
|
|
1258
|
+
e = e.toUpperCase(), t = G(this._basePath, t);
|
|
1088
1259
|
let i = {
|
|
1089
|
-
basePath: r === void 0 ? this._basePath :
|
|
1260
|
+
basePath: r === void 0 ? this._basePath : G(this._basePath, r),
|
|
1090
1261
|
path: t,
|
|
1091
1262
|
method: e,
|
|
1092
1263
|
handler: n
|
|
@@ -1099,7 +1270,7 @@ var gt = (e, t, n) => {
|
|
|
1099
1270
|
}
|
|
1100
1271
|
#a(e, t, n, r) {
|
|
1101
1272
|
if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
|
|
1102
|
-
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new
|
|
1273
|
+
let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new dn(e, {
|
|
1103
1274
|
path: i,
|
|
1104
1275
|
matchResult: a,
|
|
1105
1276
|
env: n,
|
|
@@ -1117,7 +1288,7 @@ var gt = (e, t, n) => {
|
|
|
1117
1288
|
}
|
|
1118
1289
|
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);
|
|
1119
1290
|
}
|
|
1120
|
-
let s =
|
|
1291
|
+
let s = kt(a[0], this.errorHandler, this.#n);
|
|
1121
1292
|
return (async () => {
|
|
1122
1293
|
try {
|
|
1123
1294
|
let e = await s(o);
|
|
@@ -1129,19 +1300,19 @@ var gt = (e, t, n) => {
|
|
|
1129
1300
|
})();
|
|
1130
1301
|
}
|
|
1131
1302
|
fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
|
|
1132
|
-
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${
|
|
1303
|
+
request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${G("/", e)}`, t), n, r));
|
|
1133
1304
|
fire = () => {
|
|
1134
1305
|
addEventListener("fetch", (e) => {
|
|
1135
1306
|
e.respondWith(this.#a(e.request, e, void 0, e.request.method));
|
|
1136
1307
|
});
|
|
1137
1308
|
};
|
|
1138
|
-
},
|
|
1139
|
-
function
|
|
1309
|
+
}, q = () => /* @__PURE__ */ Object.create(null), yn = [];
|
|
1310
|
+
function bn(e, t) {
|
|
1140
1311
|
let n = this.buildAllMatchers(), r = ((e, t) => {
|
|
1141
1312
|
let r = n[e] || n.ALL, i = r[2][t];
|
|
1142
1313
|
if (i) return i;
|
|
1143
1314
|
let a = t.match(r[0]);
|
|
1144
|
-
if (!a) return [[],
|
|
1315
|
+
if (!a) return [[], yn];
|
|
1145
1316
|
let o = a.indexOf("", 1);
|
|
1146
1317
|
return [r[1][o], a];
|
|
1147
1318
|
});
|
|
@@ -1149,14 +1320,14 @@ function Zt(e, t) {
|
|
|
1149
1320
|
}
|
|
1150
1321
|
//#endregion
|
|
1151
1322
|
//#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
1152
|
-
var
|
|
1153
|
-
function
|
|
1323
|
+
var xn = "[^/]+", Sn = "(?:|/.*)", J = /* @__PURE__ */ Symbol(), Cn = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
1324
|
+
function wn(e, t) {
|
|
1154
1325
|
return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 ? 1 : e === ".*" || e === "(?:|/.*)" ? t === "(?:|/.*)" ? -1 : 1 : t === ".*" || t === "(?:|/.*)" ? -1 : e === "[^/]+" ? 1 : t === "[^/]+" ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
|
|
1155
1326
|
}
|
|
1156
|
-
var
|
|
1327
|
+
var Tn = class e {
|
|
1157
1328
|
#e;
|
|
1158
1329
|
#t;
|
|
1159
|
-
#n =
|
|
1330
|
+
#n = q();
|
|
1160
1331
|
insert(t, n, r, i, a) {
|
|
1161
1332
|
let o = this;
|
|
1162
1333
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
@@ -1167,43 +1338,43 @@ var nn = class e {
|
|
|
1167
1338
|
] : [
|
|
1168
1339
|
"",
|
|
1169
1340
|
"",
|
|
1170
|
-
|
|
1341
|
+
xn
|
|
1171
1342
|
] : null : s === "/*" ? [
|
|
1172
1343
|
"",
|
|
1173
1344
|
"",
|
|
1174
|
-
|
|
1345
|
+
Sn
|
|
1175
1346
|
] : s.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
|
|
1176
1347
|
if (c) {
|
|
1177
1348
|
let t = c[1], n = c[2] || "[^/]+";
|
|
1178
|
-
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 &&
|
|
1349
|
+
if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && Cn.has(n))) throw J;
|
|
1179
1350
|
if (l = o.#n[n], !l) {
|
|
1180
1351
|
if (n !== ".*" && n !== "(?:|/.*)") {
|
|
1181
|
-
for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw
|
|
1352
|
+
for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw J;
|
|
1182
1353
|
}
|
|
1183
1354
|
l = o.#n[n] = new e();
|
|
1184
1355
|
}
|
|
1185
1356
|
t !== "" && (l.#t ??= i.varIndex++, r.push([t, l.#t]));
|
|
1186
1357
|
} else if (l = o.#n[s], !l) {
|
|
1187
|
-
for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw
|
|
1358
|
+
for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw J;
|
|
1188
1359
|
l = o.#n[s] = new e();
|
|
1189
1360
|
}
|
|
1190
1361
|
o = l;
|
|
1191
1362
|
}
|
|
1192
|
-
if (o.#e !== void 0) throw
|
|
1363
|
+
if (o.#e !== void 0) throw J;
|
|
1193
1364
|
o.#e = a ? -1 : n;
|
|
1194
1365
|
}
|
|
1195
1366
|
buildRegExpStr() {
|
|
1196
|
-
let e = Object.keys(this.#n).sort(
|
|
1367
|
+
let e = Object.keys(this.#n).sort(wn).map((e) => {
|
|
1197
1368
|
let t = this.#n[e], n = t.buildRegExpStr();
|
|
1198
|
-
return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` :
|
|
1369
|
+
return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : Cn.has(e) ? `\\${e}` : e) + n;
|
|
1199
1370
|
}).filter(Boolean);
|
|
1200
1371
|
return typeof this.#e == "number" && this.#e !== -1 && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
|
|
1201
1372
|
}
|
|
1202
|
-
},
|
|
1373
|
+
}, En = class {
|
|
1203
1374
|
#e = { varIndex: 0 };
|
|
1204
|
-
#t = new
|
|
1375
|
+
#t = new Tn();
|
|
1205
1376
|
#n = 0;
|
|
1206
|
-
paths =
|
|
1377
|
+
paths = q();
|
|
1207
1378
|
insert(e, t) {
|
|
1208
1379
|
if (t) {
|
|
1209
1380
|
this.#t.insert(e.split(""), 0, [], this.#e, !0);
|
|
@@ -1241,64 +1412,64 @@ var nn = class e {
|
|
|
1241
1412
|
r
|
|
1242
1413
|
];
|
|
1243
1414
|
}
|
|
1244
|
-
},
|
|
1245
|
-
function
|
|
1246
|
-
return
|
|
1415
|
+
}, Dn = q();
|
|
1416
|
+
function On(e) {
|
|
1417
|
+
return Dn[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? Sn : e === "*" ? ".*" : `/:${xn}`)}$`);
|
|
1247
1418
|
}
|
|
1248
|
-
function
|
|
1249
|
-
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (
|
|
1419
|
+
function kn(e, t) {
|
|
1420
|
+
for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (On(n).test(t)) return [...e[n]];
|
|
1250
1421
|
}
|
|
1251
|
-
var
|
|
1422
|
+
var An = class {
|
|
1252
1423
|
name = "RegExpRouter";
|
|
1253
1424
|
#e;
|
|
1254
1425
|
#t;
|
|
1255
1426
|
#n;
|
|
1256
1427
|
constructor() {
|
|
1257
|
-
this.#e = { ALL:
|
|
1428
|
+
this.#e = { ALL: q() }, this.#t = { ALL: q() }, this.#n = { ALL: new En() };
|
|
1258
1429
|
}
|
|
1259
1430
|
#r(e, t) {
|
|
1260
1431
|
try {
|
|
1261
1432
|
this.#n[e].insert(t, !/\*|\/:/.test(t));
|
|
1262
1433
|
} catch (e) {
|
|
1263
|
-
throw e ===
|
|
1434
|
+
throw e === J ? new mn(t) : e;
|
|
1264
1435
|
}
|
|
1265
1436
|
}
|
|
1266
1437
|
add(e, t, n) {
|
|
1267
1438
|
let r = this.#e, i = this.#t;
|
|
1268
|
-
if (!r) throw Error(
|
|
1439
|
+
if (!r) throw Error(pn);
|
|
1269
1440
|
if (!r[e]) {
|
|
1270
|
-
this.#n[e] = new
|
|
1441
|
+
this.#n[e] = new En();
|
|
1271
1442
|
for (let t of [r, i]) {
|
|
1272
|
-
t[e] =
|
|
1443
|
+
t[e] = q();
|
|
1273
1444
|
for (let n in t.ALL) t[e][n] = [...t.ALL[n]], this.#r(e, n);
|
|
1274
1445
|
}
|
|
1275
1446
|
}
|
|
1276
1447
|
t === "/*" && (t = "*");
|
|
1277
1448
|
let a = e === "ALL" ? Object.keys(r) : [e];
|
|
1278
1449
|
if (/\*$/.test(t)) {
|
|
1279
|
-
let e =
|
|
1280
|
-
for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] =
|
|
1450
|
+
let e = On(t);
|
|
1451
|
+
for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = kn(r[e], t) || kn(r.ALL, t) || []);
|
|
1281
1452
|
for (let o of [r, i]) for (let r of a) for (let i in o[r]) e.test(i) && o[r][i].push([n, t]);
|
|
1282
1453
|
return;
|
|
1283
1454
|
}
|
|
1284
|
-
let o =
|
|
1285
|
-
for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] =
|
|
1455
|
+
let o = Zt(t) || [t];
|
|
1456
|
+
for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = kn(r[t], e) || kn(r.ALL, e) || []), i[t][e].push([n, e]);
|
|
1286
1457
|
}
|
|
1287
|
-
match =
|
|
1458
|
+
match = bn;
|
|
1288
1459
|
buildAllMatchers() {
|
|
1289
|
-
let e =
|
|
1460
|
+
let e = q();
|
|
1290
1461
|
for (let t of Object.keys(this.#t)) e[t] = this.#i(t);
|
|
1291
|
-
return this.#e = this.#t = this.#n = void 0,
|
|
1462
|
+
return this.#e = this.#t = this.#n = void 0, Dn = q(), e;
|
|
1292
1463
|
}
|
|
1293
1464
|
#i(e) {
|
|
1294
|
-
let t = this.#e[e], n = this.#t[e], r = this.#n[e], i =
|
|
1465
|
+
let t = this.#e[e], n = this.#t[e], r = this.#n[e], i = q(), a = [], [o, s, c] = r.buildRegExp();
|
|
1295
1466
|
for (let e of [t, n]) for (let t in e) {
|
|
1296
1467
|
let n = e[t], o = r.paths[t];
|
|
1297
1468
|
if (!o) {
|
|
1298
|
-
i[t] = [n.map(([e]) => [e,
|
|
1469
|
+
i[t] = [n.map(([e]) => [e, q()]), yn];
|
|
1299
1470
|
continue;
|
|
1300
1471
|
}
|
|
1301
|
-
a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e),
|
|
1472
|
+
a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e), q())]);
|
|
1302
1473
|
}
|
|
1303
1474
|
return [
|
|
1304
1475
|
o,
|
|
@@ -1306,7 +1477,7 @@ var cn = class {
|
|
|
1306
1477
|
i
|
|
1307
1478
|
];
|
|
1308
1479
|
}
|
|
1309
|
-
},
|
|
1480
|
+
}, jn = class {
|
|
1310
1481
|
name = "SmartRouter";
|
|
1311
1482
|
#e = [];
|
|
1312
1483
|
#t = [];
|
|
@@ -1314,7 +1485,7 @@ var cn = class {
|
|
|
1314
1485
|
this.#e = e.routers;
|
|
1315
1486
|
}
|
|
1316
1487
|
add(e, t, n) {
|
|
1317
|
-
if (!this.#t) throw Error(
|
|
1488
|
+
if (!this.#t) throw Error(pn);
|
|
1318
1489
|
this.#t.push([
|
|
1319
1490
|
e,
|
|
1320
1491
|
t,
|
|
@@ -1330,7 +1501,7 @@ var cn = class {
|
|
|
1330
1501
|
for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
|
|
1331
1502
|
o = i.match(e, t);
|
|
1332
1503
|
} catch (e) {
|
|
1333
|
-
if (e instanceof
|
|
1504
|
+
if (e instanceof mn) continue;
|
|
1334
1505
|
throw e;
|
|
1335
1506
|
}
|
|
1336
1507
|
this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
|
|
@@ -1343,29 +1514,29 @@ var cn = class {
|
|
|
1343
1514
|
if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
|
|
1344
1515
|
return this.#e[0];
|
|
1345
1516
|
}
|
|
1346
|
-
},
|
|
1517
|
+
}, Mn = q(), Nn = 0, Pn = class e {
|
|
1347
1518
|
#e = [];
|
|
1348
|
-
#t =
|
|
1519
|
+
#t = q();
|
|
1349
1520
|
#n = [];
|
|
1350
1521
|
#r;
|
|
1351
|
-
#i =
|
|
1522
|
+
#i = Mn;
|
|
1352
1523
|
insert(t, n, r) {
|
|
1353
|
-
let i = this, a =
|
|
1524
|
+
let i = this, a = Ht(n), o = /* @__PURE__ */ new Set(), s = 0;
|
|
1354
1525
|
for (let t of a) {
|
|
1355
|
-
let n = a[++s], r =
|
|
1526
|
+
let n = a[++s], r = Kt(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
|
|
1356
1527
|
r && !u.#r && (u.#r = r, i.#n.push(u)), i = u, c && o.add(r[1]);
|
|
1357
1528
|
}
|
|
1358
1529
|
i.#e.push({ [t]: {
|
|
1359
1530
|
handler: r,
|
|
1360
1531
|
possibleKeys: [...o],
|
|
1361
|
-
score: ++
|
|
1532
|
+
score: ++Nn
|
|
1362
1533
|
} });
|
|
1363
1534
|
}
|
|
1364
1535
|
#a(e, t, n, r, i) {
|
|
1365
1536
|
for (let a = 0, o = t.#e.length; a < o; a++) {
|
|
1366
1537
|
let o = t.#e[a], s = o[n] || o.ALL;
|
|
1367
1538
|
if (s) {
|
|
1368
|
-
s.params =
|
|
1539
|
+
s.params = q(), e.push(s);
|
|
1369
1540
|
for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
|
|
1370
1541
|
let t = s.possibleKeys[e];
|
|
1371
1542
|
s.params[t] = i?.[t] && !e ? i[t] : r[t] ?? i?.[t];
|
|
@@ -1375,15 +1546,15 @@ var cn = class {
|
|
|
1375
1546
|
}
|
|
1376
1547
|
search(e, t) {
|
|
1377
1548
|
let n = [];
|
|
1378
|
-
this.#i =
|
|
1379
|
-
let r = [this], i =
|
|
1549
|
+
this.#i = Mn;
|
|
1550
|
+
let r = [this], i = Vt(t), a = [], o = i.length, s = null;
|
|
1380
1551
|
for (let c = 0; c < o; c++) {
|
|
1381
1552
|
let l = i[c], u = c === o - 1, d = [];
|
|
1382
1553
|
for (let f = 0, p = r.length; f < p; f++) {
|
|
1383
1554
|
let p = r[f], m = p.#t[l];
|
|
1384
1555
|
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));
|
|
1385
1556
|
for (let r of p.#n) {
|
|
1386
|
-
let f = r.#r, m = p.#i ===
|
|
1557
|
+
let f = r.#r, m = p.#i === Mn ? {} : { ...p.#i };
|
|
1387
1558
|
if (typeof f == "string") {
|
|
1388
1559
|
(f === "*" || l.startsWith(f.slice(0, -1))) && (this.#a(n, r, e, p.#i), f === "*" && (r.#i = m, d.push(r)));
|
|
1389
1560
|
continue;
|
|
@@ -1417,52 +1588,52 @@ var cn = class {
|
|
|
1417
1588
|
}
|
|
1418
1589
|
return n[1] && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
|
|
1419
1590
|
}
|
|
1420
|
-
},
|
|
1591
|
+
}, Fn = class {
|
|
1421
1592
|
name = "TrieRouter";
|
|
1422
|
-
#e = new
|
|
1593
|
+
#e = new Pn();
|
|
1423
1594
|
add(e, t, n) {
|
|
1424
|
-
for (let r of
|
|
1595
|
+
for (let r of Zt(t) || [t]) this.#e.insert(e, r, n);
|
|
1425
1596
|
}
|
|
1426
1597
|
match(e, t) {
|
|
1427
1598
|
return this.#e.search(e, t);
|
|
1428
1599
|
}
|
|
1429
|
-
},
|
|
1600
|
+
}, In = class extends vn {
|
|
1430
1601
|
constructor(e = {}) {
|
|
1431
|
-
super(e), this.router = e.router ?? new
|
|
1602
|
+
super(e), this.router = e.router ?? new jn({ routers: [new An(), new Fn()] });
|
|
1432
1603
|
}
|
|
1433
1604
|
};
|
|
1434
1605
|
//#endregion
|
|
1435
1606
|
//#region src/coordinator-invites.ts
|
|
1436
|
-
function
|
|
1607
|
+
function Ln(e) {
|
|
1437
1608
|
let t = "";
|
|
1438
1609
|
for (let n of e) t += String.fromCharCode(n);
|
|
1439
1610
|
return btoa(t);
|
|
1440
1611
|
}
|
|
1441
|
-
function
|
|
1612
|
+
function Rn(e) {
|
|
1442
1613
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
1443
1614
|
for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
|
|
1444
1615
|
return n;
|
|
1445
1616
|
}
|
|
1446
|
-
function
|
|
1617
|
+
function zn(e) {
|
|
1447
1618
|
return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1448
1619
|
}
|
|
1449
|
-
function
|
|
1620
|
+
function Bn(e) {
|
|
1450
1621
|
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
1451
1622
|
return t + "=".repeat((4 - t.length % 4) % 4);
|
|
1452
1623
|
}
|
|
1453
|
-
function
|
|
1624
|
+
function Vn(e) {
|
|
1454
1625
|
let t = JSON.stringify(e);
|
|
1455
|
-
return
|
|
1626
|
+
return zn(Ln(new TextEncoder().encode(t)));
|
|
1456
1627
|
}
|
|
1457
|
-
function
|
|
1458
|
-
let t = new TextDecoder().decode(
|
|
1628
|
+
function Hn(e) {
|
|
1629
|
+
let t = new TextDecoder().decode(Rn(Bn(e))), n = JSON.parse(t);
|
|
1459
1630
|
if (typeof n != "object" || !n) throw Error("invalid invite payload");
|
|
1460
1631
|
return n;
|
|
1461
1632
|
}
|
|
1462
|
-
function
|
|
1633
|
+
function Un(e) {
|
|
1463
1634
|
return `codemem://join?invite=${encodeURIComponent(e)}`;
|
|
1464
1635
|
}
|
|
1465
|
-
function
|
|
1636
|
+
function Wn(e) {
|
|
1466
1637
|
let t = e.trim();
|
|
1467
1638
|
if (t.startsWith("codemem://")) {
|
|
1468
1639
|
let e = new URL(t).searchParams.get("invite") ?? "";
|
|
@@ -1473,183 +1644,41 @@ function Sn(e) {
|
|
|
1473
1644
|
}
|
|
1474
1645
|
//#endregion
|
|
1475
1646
|
//#region src/project-invite-acceptance.ts
|
|
1476
|
-
var
|
|
1477
|
-
code =
|
|
1478
|
-
detail =
|
|
1647
|
+
var Gn = "pending_setup", Kn = "project_sync_enablement_failed", qn = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", Jn = class extends Error {
|
|
1648
|
+
code = Kn;
|
|
1649
|
+
detail = qn;
|
|
1479
1650
|
constructor(e) {
|
|
1480
|
-
super(
|
|
1651
|
+
super(qn, e), this.name = "ProjectSyncEnablementError";
|
|
1481
1652
|
}
|
|
1482
1653
|
};
|
|
1483
|
-
function
|
|
1654
|
+
function Yn(e) {
|
|
1484
1655
|
return typeof e == "object" && !!e && "code" in e && e.code === "project_sync_enablement_failed" && "detail" in e && e.detail === "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.";
|
|
1485
1656
|
}
|
|
1486
1657
|
//#endregion
|
|
1487
|
-
//#region src/scope-resolution.ts
|
|
1488
|
-
var On = "local-default", kn = "legacy-shared-review";
|
|
1489
|
-
function q(e) {
|
|
1490
|
-
return e?.trim() || null;
|
|
1491
|
-
}
|
|
1492
|
-
function J(e) {
|
|
1493
|
-
return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
|
|
1494
|
-
}
|
|
1495
|
-
function An(t) {
|
|
1496
|
-
return J(e(t));
|
|
1497
|
-
}
|
|
1498
|
-
function jn(e) {
|
|
1499
|
-
let t = q(e);
|
|
1500
|
-
return t ? J(t) : null;
|
|
1501
|
-
}
|
|
1502
|
-
function Mn(e) {
|
|
1503
|
-
let n = [
|
|
1504
|
-
e.cwd,
|
|
1505
|
-
e.project,
|
|
1506
|
-
e.workspaceId
|
|
1507
|
-
].map((e) => q(e)).find((e) => e != null);
|
|
1508
|
-
return `unmapped:${t("sha256").update(n ?? "unknown", "utf8").digest("hex")}`;
|
|
1509
|
-
}
|
|
1510
|
-
function Nn(e) {
|
|
1511
|
-
let t = q(e.gitRemote), n = q(e.gitBranch), r = q(e.cwd), i = q(e.workspaceId), a = q(e.project);
|
|
1512
|
-
if (t) {
|
|
1513
|
-
let r = J(t);
|
|
1514
|
-
return e.branchScoped && n ? {
|
|
1515
|
-
value: `${r}:${n}`,
|
|
1516
|
-
source: "git_remote_branch",
|
|
1517
|
-
displayProject: a
|
|
1518
|
-
} : {
|
|
1519
|
-
value: r,
|
|
1520
|
-
source: "git_remote",
|
|
1521
|
-
displayProject: a
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
return r ? {
|
|
1525
|
-
value: An(r),
|
|
1526
|
-
source: "cwd",
|
|
1527
|
-
displayProject: a
|
|
1528
|
-
} : i ? {
|
|
1529
|
-
value: J(i),
|
|
1530
|
-
source: "workspace_id",
|
|
1531
|
-
displayProject: a
|
|
1532
|
-
} : {
|
|
1533
|
-
value: Mn(e),
|
|
1534
|
-
source: "unmapped",
|
|
1535
|
-
displayProject: a
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
function Pn(e) {
|
|
1539
|
-
return !/[\\/:]/.test(e);
|
|
1540
|
-
}
|
|
1541
|
-
function Fn(e) {
|
|
1542
|
-
return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
1543
|
-
}
|
|
1544
|
-
function In(e) {
|
|
1545
|
-
return e.replace(/[*?]/g, "").length;
|
|
1546
|
-
}
|
|
1547
|
-
function Ln(e, t) {
|
|
1548
|
-
let n = J(t);
|
|
1549
|
-
return !n || Pn(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Fn(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
|
|
1550
|
-
}
|
|
1551
|
-
function Rn(e) {
|
|
1552
|
-
return e.mapping.priority ?? 0;
|
|
1553
|
-
}
|
|
1554
|
-
function zn(e) {
|
|
1555
|
-
let t = q(e.mapping.updated_at);
|
|
1556
|
-
if (!t) return 0;
|
|
1557
|
-
let n = Date.parse(t);
|
|
1558
|
-
return Number.isFinite(n) ? n : 0;
|
|
1559
|
-
}
|
|
1560
|
-
function Bn(e, t) {
|
|
1561
|
-
return Rn(t) - Rn(e) || t.specificity - e.specificity || zn(t) - zn(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
|
|
1562
|
-
}
|
|
1563
|
-
function Vn(e) {
|
|
1564
|
-
return e.toSorted(Bn)[0] ?? null;
|
|
1565
|
-
}
|
|
1566
|
-
function Hn(e) {
|
|
1567
|
-
let t = Nn(e), n = q(e.explicitScopeId);
|
|
1568
|
-
if (n) return {
|
|
1569
|
-
scopeId: n,
|
|
1570
|
-
reason: "explicit_override",
|
|
1571
|
-
workspaceIdentity: t,
|
|
1572
|
-
mapping: null,
|
|
1573
|
-
matchedPattern: null
|
|
1574
|
-
};
|
|
1575
|
-
if (t.source === "unmapped") return {
|
|
1576
|
-
scopeId: e.localDefaultScopeId ?? "local-default",
|
|
1577
|
-
reason: "local_default",
|
|
1578
|
-
workspaceIdentity: t,
|
|
1579
|
-
mapping: null,
|
|
1580
|
-
matchedPattern: null
|
|
1581
|
-
};
|
|
1582
|
-
let r = e.mappings ?? [], i = Vn(r.filter((e) => jn(e.workspace_identity) === t.value).map((e) => ({
|
|
1583
|
-
mapping: e,
|
|
1584
|
-
matchedPattern: null,
|
|
1585
|
-
specificity: t.value.length
|
|
1586
|
-
})));
|
|
1587
|
-
if (i) return {
|
|
1588
|
-
scopeId: i.mapping.scope_id,
|
|
1589
|
-
reason: "exact_mapping",
|
|
1590
|
-
workspaceIdentity: t,
|
|
1591
|
-
mapping: i.mapping,
|
|
1592
|
-
matchedPattern: null
|
|
1593
|
-
};
|
|
1594
|
-
let a = Vn(r.flatMap((e) => {
|
|
1595
|
-
if (q(e.workspace_identity)) return [];
|
|
1596
|
-
let n = q(e.project_pattern);
|
|
1597
|
-
return !n || !Ln(t.value, n) ? [] : [{
|
|
1598
|
-
mapping: e,
|
|
1599
|
-
matchedPattern: J(n),
|
|
1600
|
-
specificity: In(n)
|
|
1601
|
-
}];
|
|
1602
|
-
}));
|
|
1603
|
-
return a ? {
|
|
1604
|
-
scopeId: a.mapping.scope_id,
|
|
1605
|
-
reason: "pattern_mapping",
|
|
1606
|
-
workspaceIdentity: t,
|
|
1607
|
-
mapping: a.mapping,
|
|
1608
|
-
matchedPattern: a.matchedPattern
|
|
1609
|
-
} : {
|
|
1610
|
-
scopeId: e.localDefaultScopeId ?? "local-default",
|
|
1611
|
-
reason: "local_default",
|
|
1612
|
-
workspaceIdentity: t,
|
|
1613
|
-
mapping: null,
|
|
1614
|
-
matchedPattern: null
|
|
1615
|
-
};
|
|
1616
|
-
}
|
|
1617
|
-
function Un(e, t) {
|
|
1618
|
-
let n = /* @__PURE__ */ new Set([
|
|
1619
|
-
"",
|
|
1620
|
-
On,
|
|
1621
|
-
kn
|
|
1622
|
-
]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
|
|
1623
|
-
for (let e of r) e.scope_id != null && n.add(e.scope_id);
|
|
1624
|
-
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);
|
|
1625
|
-
for (let e of i) e.scope_id != null && n.add(e.scope_id);
|
|
1626
|
-
return [...n];
|
|
1627
|
-
}
|
|
1628
|
-
//#endregion
|
|
1629
1658
|
//#region src/project-share-intent.ts
|
|
1630
|
-
var
|
|
1631
|
-
function
|
|
1659
|
+
var Xn = "existing_and_future";
|
|
1660
|
+
function Zn(e) {
|
|
1632
1661
|
return t("sha256").update(JSON.stringify(e)).digest("hex");
|
|
1633
1662
|
}
|
|
1634
|
-
function
|
|
1635
|
-
return
|
|
1663
|
+
function Qn(e) {
|
|
1664
|
+
return Zn({
|
|
1636
1665
|
v: 1,
|
|
1637
|
-
historyPolicy:
|
|
1666
|
+
historyPolicy: Xn,
|
|
1638
1667
|
projects: e.map((e) => ({
|
|
1639
1668
|
canonicalIdentity: e.canonicalIdentity,
|
|
1640
1669
|
existingMemoryCount: e.existingMemoryCount
|
|
1641
1670
|
})).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
|
|
1642
1671
|
});
|
|
1643
1672
|
}
|
|
1644
|
-
function
|
|
1645
|
-
return
|
|
1673
|
+
function $n(e) {
|
|
1674
|
+
return Qn(e.map((e) => ({
|
|
1646
1675
|
canonicalIdentity: e.canonical_identity,
|
|
1647
1676
|
displayName: e.display_name,
|
|
1648
1677
|
identitySource: "coordinator_acceptance",
|
|
1649
1678
|
existingMemoryCount: e.existing_memory_count
|
|
1650
1679
|
})));
|
|
1651
1680
|
}
|
|
1652
|
-
function
|
|
1681
|
+
function er(e) {
|
|
1653
1682
|
if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
|
|
1654
1683
|
let t = e.map((e) => {
|
|
1655
1684
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
|
|
@@ -1657,11 +1686,11 @@ function Jn(e) {
|
|
|
1657
1686
|
if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
|
|
1658
1687
|
let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
|
|
1659
1688
|
try {
|
|
1660
|
-
a =
|
|
1689
|
+
a = I(i, "project_name");
|
|
1661
1690
|
} catch {
|
|
1662
1691
|
throw Error("operation_intent_invalid");
|
|
1663
1692
|
}
|
|
1664
|
-
let o = t.existing_memory_count, s =
|
|
1693
|
+
let o = t.existing_memory_count, s = p({ gitRemote: r }).value;
|
|
1665
1694
|
if (!r || r !== n || r.length > 2048 || r.startsWith("unmapped:") || s !== r || a !== i || !Number.isSafeInteger(o) || Number(o) < 0 || /[\p{Cc}\p{Cf}]/u.test(r) || /[\p{Cc}\p{Cf}]/u.test(a)) throw Error("operation_intent_invalid");
|
|
1666
1695
|
return {
|
|
1667
1696
|
canonical_identity: r,
|
|
@@ -1674,20 +1703,20 @@ function Jn(e) {
|
|
|
1674
1703
|
}
|
|
1675
1704
|
//#endregion
|
|
1676
1705
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
|
|
1677
|
-
function
|
|
1706
|
+
function tr(e) {
|
|
1678
1707
|
let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
|
|
1679
1708
|
return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
|
|
1680
1709
|
}
|
|
1681
1710
|
function Y() {
|
|
1682
|
-
let [e, t] =
|
|
1711
|
+
let [e, t] = tr();
|
|
1683
1712
|
return e * 1e3 + Math.floor(t / 1e6);
|
|
1684
1713
|
}
|
|
1685
|
-
function
|
|
1714
|
+
function nr(e) {
|
|
1686
1715
|
return new Promise((t) => setTimeout(t, e));
|
|
1687
1716
|
}
|
|
1688
1717
|
//#endregion
|
|
1689
1718
|
//#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
|
|
1690
|
-
var
|
|
1719
|
+
var rr = class {
|
|
1691
1720
|
bucketSize;
|
|
1692
1721
|
tokensPerInterval;
|
|
1693
1722
|
interval;
|
|
@@ -1720,7 +1749,7 @@ var Zn = class {
|
|
|
1720
1749
|
if (this.bucketSize === 0) return Infinity;
|
|
1721
1750
|
if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
|
|
1722
1751
|
this.drip();
|
|
1723
|
-
let t = async () => (await
|
|
1752
|
+
let t = async () => (await nr(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
|
|
1724
1753
|
if (e > this.content) return t();
|
|
1725
1754
|
if (this.parentBucket != null) {
|
|
1726
1755
|
let n = await this.parentBucket.removeTokens(e);
|
|
@@ -1741,13 +1770,13 @@ var Zn = class {
|
|
|
1741
1770
|
let n = t * (this.tokensPerInterval / this.interval), r = this.content;
|
|
1742
1771
|
return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
|
|
1743
1772
|
}
|
|
1744
|
-
},
|
|
1773
|
+
}, ir = class {
|
|
1745
1774
|
tokenBucket;
|
|
1746
1775
|
curIntervalStart;
|
|
1747
1776
|
tokensThisInterval;
|
|
1748
1777
|
fireImmediately;
|
|
1749
1778
|
constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
|
|
1750
|
-
this.tokenBucket = new
|
|
1779
|
+
this.tokenBucket = new rr({
|
|
1751
1780
|
bucketSize: e,
|
|
1752
1781
|
tokensPerInterval: e,
|
|
1753
1782
|
interval: t
|
|
@@ -1759,7 +1788,7 @@ var Zn = class {
|
|
|
1759
1788
|
if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
|
|
1760
1789
|
if (this.fireImmediately) return -1;
|
|
1761
1790
|
{
|
|
1762
|
-
await
|
|
1791
|
+
await nr(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
|
|
1763
1792
|
let n = await this.tokenBucket.removeTokens(e);
|
|
1764
1793
|
return this.tokensThisInterval += e, n;
|
|
1765
1794
|
}
|
|
@@ -1780,7 +1809,7 @@ var Zn = class {
|
|
|
1780
1809
|
};
|
|
1781
1810
|
//#endregion
|
|
1782
1811
|
//#region src/request-rate-limit.ts
|
|
1783
|
-
function
|
|
1812
|
+
function ar(e = {}) {
|
|
1784
1813
|
let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
|
|
1785
1814
|
function a(e) {
|
|
1786
1815
|
return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
|
|
@@ -1797,7 +1826,7 @@ function $n(e = {}) {
|
|
|
1797
1826
|
o(l);
|
|
1798
1827
|
let u = `${c}:${e}`, d = r.get(u);
|
|
1799
1828
|
return d || (d = {
|
|
1800
|
-
limiter: new
|
|
1829
|
+
limiter: new ir({
|
|
1801
1830
|
tokensPerInterval: c,
|
|
1802
1831
|
interval: t,
|
|
1803
1832
|
fireImmediately: !0
|
|
@@ -1814,8 +1843,8 @@ function $n(e = {}) {
|
|
|
1814
1843
|
}
|
|
1815
1844
|
//#endregion
|
|
1816
1845
|
//#region src/scope-membership-semantics.ts
|
|
1817
|
-
var
|
|
1818
|
-
function
|
|
1846
|
+
var or = "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.";
|
|
1847
|
+
function sr(e) {
|
|
1819
1848
|
let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
|
|
1820
1849
|
return t == null || n == null ? {
|
|
1821
1850
|
membership_epoch: t,
|
|
@@ -1829,19 +1858,19 @@ function tr(e) {
|
|
|
1829
1858
|
reason: t < n ? "stale_epoch" : "current"
|
|
1830
1859
|
};
|
|
1831
1860
|
}
|
|
1832
|
-
function
|
|
1861
|
+
function cr(e) {
|
|
1833
1862
|
return {
|
|
1834
1863
|
scope_id: e.scopeId,
|
|
1835
1864
|
device_id: e.deviceId,
|
|
1836
1865
|
membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
|
|
1837
1866
|
prevents_future_sync: !0,
|
|
1838
1867
|
deletes_already_copied_data: !1,
|
|
1839
|
-
message:
|
|
1868
|
+
message: or
|
|
1840
1869
|
};
|
|
1841
1870
|
}
|
|
1842
1871
|
//#endregion
|
|
1843
1872
|
//#region src/sync-auth-constants.ts
|
|
1844
|
-
var
|
|
1873
|
+
var lr = 300, ur = 65536, dr = xe + 1024, X = "X-Codemem-Coordinator-Admin", fr = "X-Codemem-Coordinator-Admin-Actor", pr = 120, mr = 30;
|
|
1845
1874
|
function Z(e, t) {
|
|
1846
1875
|
let n = t.adminSecret();
|
|
1847
1876
|
if (!n) return {
|
|
@@ -1860,14 +1889,14 @@ function Z(e, t) {
|
|
|
1860
1889
|
error: "missing_admin_header"
|
|
1861
1890
|
};
|
|
1862
1891
|
}
|
|
1863
|
-
function
|
|
1892
|
+
function hr(e) {
|
|
1864
1893
|
let t = new URL(e);
|
|
1865
1894
|
return t.search ? `${t.pathname}${t.search}` : t.pathname;
|
|
1866
1895
|
}
|
|
1867
|
-
async function
|
|
1896
|
+
async function gr(e, t, n, r) {
|
|
1868
1897
|
return await e.recordNonce(t, n, r);
|
|
1869
1898
|
}
|
|
1870
|
-
async function
|
|
1899
|
+
async function _r(e, t) {
|
|
1871
1900
|
await e.cleanupNonces(t);
|
|
1872
1901
|
}
|
|
1873
1902
|
async function Q(e, t, n, r) {
|
|
@@ -1903,7 +1932,7 @@ async function Q(e, t, n, r) {
|
|
|
1903
1932
|
try {
|
|
1904
1933
|
u = await n({
|
|
1905
1934
|
method: r.method,
|
|
1906
|
-
pathWithQuery:
|
|
1935
|
+
pathWithQuery: hr(r.url),
|
|
1907
1936
|
bodyBytes: r.body,
|
|
1908
1937
|
timestamp: o,
|
|
1909
1938
|
nonce: s,
|
|
@@ -1924,7 +1953,7 @@ async function Q(e, t, n, r) {
|
|
|
1924
1953
|
enrollment: null
|
|
1925
1954
|
};
|
|
1926
1955
|
let d = t.now();
|
|
1927
|
-
return await
|
|
1956
|
+
return await gr(e, i, s, d) ? (await _r(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
|
|
1928
1957
|
ok: !0,
|
|
1929
1958
|
error: "ok",
|
|
1930
1959
|
enrollment: c
|
|
@@ -1937,9 +1966,9 @@ async function Q(e, t, n, r) {
|
|
|
1937
1966
|
function $(e) {
|
|
1938
1967
|
return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
|
|
1939
1968
|
}
|
|
1940
|
-
function
|
|
1969
|
+
function vr(e) {
|
|
1941
1970
|
if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
|
|
1942
|
-
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ??
|
|
1971
|
+
let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? ar(), o = Math.max(1, Math.trunc(i.readLimit ?? pr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? mr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new In(), d = new TextDecoder();
|
|
1943
1972
|
function f(e, t, n) {
|
|
1944
1973
|
let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = a.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? o : s : r ? c : l);
|
|
1945
1974
|
return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
|
|
@@ -1947,7 +1976,7 @@ function fr(e) {
|
|
|
1947
1976
|
retry_after_s: i.retryAfterS
|
|
1948
1977
|
}, 429));
|
|
1949
1978
|
}
|
|
1950
|
-
async function p(e, t =
|
|
1979
|
+
async function p(e, t = ur) {
|
|
1951
1980
|
let n = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
1952
1981
|
if (Number.isFinite(n) && n > t) return null;
|
|
1953
1982
|
let r = e.req.raw.body;
|
|
@@ -2006,7 +2035,7 @@ function fr(e) {
|
|
|
2006
2035
|
}
|
|
2007
2036
|
function y(e) {
|
|
2008
2037
|
try {
|
|
2009
|
-
return
|
|
2038
|
+
return er(JSON.parse(e ?? ""));
|
|
2010
2039
|
} catch {
|
|
2011
2040
|
throw Error("operation_intent_invalid");
|
|
2012
2041
|
}
|
|
@@ -2015,7 +2044,7 @@ function fr(e) {
|
|
|
2015
2044
|
let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
|
|
2016
2045
|
if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
|
|
2017
2046
|
let r = y(e.project_intent_json);
|
|
2018
|
-
if (
|
|
2047
|
+
if ($n(r) !== n) throw Error("operation_intent_invalid");
|
|
2019
2048
|
return {
|
|
2020
2049
|
operation_id: t,
|
|
2021
2050
|
reviewed_project_set_digest: n,
|
|
@@ -2024,7 +2053,7 @@ function fr(e) {
|
|
|
2024
2053
|
}
|
|
2025
2054
|
function b(e) {
|
|
2026
2055
|
try {
|
|
2027
|
-
return
|
|
2056
|
+
return ct(JSON.parse(e ?? ""));
|
|
2028
2057
|
} catch {
|
|
2029
2058
|
throw Error("operation_intent_invalid");
|
|
2030
2059
|
}
|
|
@@ -2250,7 +2279,7 @@ function fr(e) {
|
|
|
2250
2279
|
request: t
|
|
2251
2280
|
});
|
|
2252
2281
|
} catch (t) {
|
|
2253
|
-
if (t instanceof
|
|
2282
|
+
if (t instanceof Ze) return e.json({ error: t.code }, 409);
|
|
2254
2283
|
throw t;
|
|
2255
2284
|
}
|
|
2256
2285
|
} finally {
|
|
@@ -2292,7 +2321,7 @@ function fr(e) {
|
|
|
2292
2321
|
if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
|
|
2293
2322
|
let p;
|
|
2294
2323
|
try {
|
|
2295
|
-
p = await
|
|
2324
|
+
p = await Et(a.reviewed_intent, {
|
|
2296
2325
|
target: {
|
|
2297
2326
|
kind: "add_device",
|
|
2298
2327
|
targetIdentityId: d
|
|
@@ -2300,7 +2329,7 @@ function fr(e) {
|
|
|
2300
2329
|
digest: l
|
|
2301
2330
|
});
|
|
2302
2331
|
} catch (t) {
|
|
2303
|
-
return t instanceof
|
|
2332
|
+
return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2304
2333
|
}
|
|
2305
2334
|
let m = await u.createInvite({
|
|
2306
2335
|
groupId: s,
|
|
@@ -2324,13 +2353,13 @@ function fr(e) {
|
|
|
2324
2353
|
target_identity_id: m.target_identity_id ?? void 0,
|
|
2325
2354
|
inviter_device_id: m.inviter_device_id ?? void 0,
|
|
2326
2355
|
reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
|
|
2327
|
-
}, g =
|
|
2356
|
+
}, g = Vn(h), { token: _, ...v } = m;
|
|
2328
2357
|
return e.json({
|
|
2329
2358
|
ok: !0,
|
|
2330
2359
|
invite: v,
|
|
2331
2360
|
payload: h,
|
|
2332
2361
|
encoded: g,
|
|
2333
|
-
link:
|
|
2362
|
+
link: Un(g)
|
|
2334
2363
|
});
|
|
2335
2364
|
} finally {
|
|
2336
2365
|
await u.close();
|
|
@@ -2346,7 +2375,7 @@ function fr(e) {
|
|
|
2346
2375
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2347
2376
|
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;
|
|
2348
2377
|
if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
|
|
2349
|
-
if (
|
|
2378
|
+
if (Ot(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
2350
2379
|
let h = n();
|
|
2351
2380
|
try {
|
|
2352
2381
|
await h.createGroup(s), await h.enrollDevice(s, {
|
|
@@ -2586,7 +2615,7 @@ function fr(e) {
|
|
|
2586
2615
|
manifestHash: h(o, "manifest_hash"),
|
|
2587
2616
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2588
2617
|
actorType: "admin",
|
|
2589
|
-
actorId: g(e.req.header(
|
|
2618
|
+
actorId: g(e.req.header(fr))
|
|
2590
2619
|
});
|
|
2591
2620
|
return e.json({
|
|
2592
2621
|
ok: !0,
|
|
@@ -2594,9 +2623,9 @@ function fr(e) {
|
|
|
2594
2623
|
}, 201);
|
|
2595
2624
|
} catch (t) {
|
|
2596
2625
|
let n = t instanceof Error ? t.message : String(t);
|
|
2597
|
-
if (t instanceof
|
|
2598
|
-
if (t instanceof
|
|
2599
|
-
let r = t instanceof
|
|
2626
|
+
if (t instanceof P && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
|
|
2627
|
+
if (t instanceof P && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
|
|
2628
|
+
let r = t instanceof P && t.code === "scope_inactive";
|
|
2600
2629
|
return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
|
|
2601
2630
|
} finally {
|
|
2602
2631
|
await v.close();
|
|
@@ -2627,7 +2656,7 @@ function fr(e) {
|
|
|
2627
2656
|
manifestHash: h(o, "manifest_hash"),
|
|
2628
2657
|
signedManifestJson: h(o, "signed_manifest_json"),
|
|
2629
2658
|
actorType: "admin",
|
|
2630
|
-
actorId: g(e.req.header(
|
|
2659
|
+
actorId: g(e.req.header(fr))
|
|
2631
2660
|
})) return e.json({ error: "membership_not_found" }, 404);
|
|
2632
2661
|
let n;
|
|
2633
2662
|
try {
|
|
@@ -2639,7 +2668,7 @@ function fr(e) {
|
|
|
2639
2668
|
ok: !0,
|
|
2640
2669
|
scope_id: c,
|
|
2641
2670
|
device_id: l,
|
|
2642
|
-
revocation:
|
|
2671
|
+
revocation: cr({
|
|
2643
2672
|
scopeId: c,
|
|
2644
2673
|
deviceId: l,
|
|
2645
2674
|
membershipEpoch: n?.membership_epoch ?? d
|
|
@@ -2647,7 +2676,7 @@ function fr(e) {
|
|
|
2647
2676
|
});
|
|
2648
2677
|
} catch (t) {
|
|
2649
2678
|
let n = t instanceof Error ? t.message : String(t);
|
|
2650
|
-
return t instanceof
|
|
2679
|
+
return t instanceof P && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
|
|
2651
2680
|
} finally {
|
|
2652
2681
|
await v.close();
|
|
2653
2682
|
}
|
|
@@ -2682,7 +2711,7 @@ function fr(e) {
|
|
|
2682
2711
|
if (!l) return e.json({ error: "display_name_required" }, 400);
|
|
2683
2712
|
let u;
|
|
2684
2713
|
try {
|
|
2685
|
-
u =
|
|
2714
|
+
u = R(l, "display_name");
|
|
2686
2715
|
} catch (t) {
|
|
2687
2716
|
return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
|
|
2688
2717
|
}
|
|
@@ -2753,16 +2782,16 @@ function fr(e) {
|
|
|
2753
2782
|
if (!r.ok) return f(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
2754
2783
|
let i = f(e, "admin", !0);
|
|
2755
2784
|
if (i) return i;
|
|
2756
|
-
let a = await p(e,
|
|
2785
|
+
let a = await p(e, dr);
|
|
2757
2786
|
if (a == null) return e.json({ error: "body_too_large" }, 413);
|
|
2758
2787
|
let o = m(a);
|
|
2759
2788
|
if (!o) return e.json({ error: "invalid_json" }, 400);
|
|
2760
2789
|
if (Object.keys(o).some((e) => e !== "group_id" && e !== "manifest")) return e.json({ error: "completion_manifest_invalid" }, 400);
|
|
2761
2790
|
let s, c;
|
|
2762
2791
|
try {
|
|
2763
|
-
let e =
|
|
2792
|
+
let e = Me([o.group_id])[0];
|
|
2764
2793
|
if (!e) throw Error("completion_manifest_invalid");
|
|
2765
|
-
s = e, c =
|
|
2794
|
+
s = e, c = Pe(o.manifest), Ie(c);
|
|
2766
2795
|
} catch {
|
|
2767
2796
|
return e.json({ error: "completion_manifest_invalid" }, 400);
|
|
2768
2797
|
}
|
|
@@ -2774,7 +2803,7 @@ function fr(e) {
|
|
|
2774
2803
|
...t
|
|
2775
2804
|
}, t.status === "created" ? 201 : 200);
|
|
2776
2805
|
} catch (t) {
|
|
2777
|
-
if (t instanceof
|
|
2806
|
+
if (t instanceof Ee) return e.json({ error: t.code }, 409);
|
|
2778
2807
|
let n = t instanceof Error ? t.message : "completion_manifest_invalid";
|
|
2779
2808
|
if (n === "group_not_found") return e.json({ error: n }, 404);
|
|
2780
2809
|
if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
|
|
@@ -2790,8 +2819,8 @@ function fr(e) {
|
|
|
2790
2819
|
if (i) return i;
|
|
2791
2820
|
let a = String(e.req.query("group_id") ?? "").trim(), o;
|
|
2792
2821
|
try {
|
|
2793
|
-
if (
|
|
2794
|
-
o =
|
|
2822
|
+
if (Me([a]).length !== 1) throw Error("completion_manifest_invalid");
|
|
2823
|
+
o = Ne(e.req.query("candidate_ref"));
|
|
2795
2824
|
} catch {
|
|
2796
2825
|
return e.json({ error: "group_id_and_candidate_ref_required" }, 400);
|
|
2797
2826
|
}
|
|
@@ -2813,7 +2842,7 @@ function fr(e) {
|
|
|
2813
2842
|
if (!o || Object.keys(o).some((e) => e !== "group_ids")) return e.json({ error: "completion_query_invalid" }, 400);
|
|
2814
2843
|
let s;
|
|
2815
2844
|
try {
|
|
2816
|
-
if (s =
|
|
2845
|
+
if (s = Me(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
|
|
2817
2846
|
} catch {
|
|
2818
2847
|
return e.json({ error: "completion_query_invalid" }, 400);
|
|
2819
2848
|
}
|
|
@@ -2854,7 +2883,7 @@ function fr(e) {
|
|
|
2854
2883
|
if (E === "team_member" || E === "add_device") {
|
|
2855
2884
|
if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2856
2885
|
try {
|
|
2857
|
-
C = await
|
|
2886
|
+
C = await Et(o.reviewed_intent, {
|
|
2858
2887
|
target: E === "team_member" ? {
|
|
2859
2888
|
kind: "team_member",
|
|
2860
2889
|
policyTeamId: String(b)
|
|
@@ -2865,7 +2894,7 @@ function fr(e) {
|
|
|
2865
2894
|
digest: String(S)
|
|
2866
2895
|
});
|
|
2867
2896
|
} catch (t) {
|
|
2868
|
-
return t instanceof
|
|
2897
|
+
return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
|
|
2869
2898
|
}
|
|
2870
2899
|
} else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
|
|
2871
2900
|
if (d && !/^share_[a-f0-9]{40}$/u.test(d) || h && !/^[a-f0-9]{64}$/u.test(h)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
|
|
@@ -2877,10 +2906,10 @@ function fr(e) {
|
|
|
2877
2906
|
y
|
|
2878
2907
|
].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
|
|
2879
2908
|
try {
|
|
2880
|
-
if (
|
|
2909
|
+
if (R(_, "inviter_display_name"), w = ct(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== w.length || (T = o.project_intent.map((e, t) => {
|
|
2881
2910
|
let n;
|
|
2882
2911
|
try {
|
|
2883
|
-
n =
|
|
2912
|
+
n = er([e])[0];
|
|
2884
2913
|
} catch {
|
|
2885
2914
|
throw Error("project_intent_invalid");
|
|
2886
2915
|
}
|
|
@@ -2939,13 +2968,13 @@ function fr(e) {
|
|
|
2939
2968
|
inviter_device_id: n.inviter_device_id ?? void 0,
|
|
2940
2969
|
reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
|
|
2941
2970
|
} : {}
|
|
2942
|
-
}, i =
|
|
2971
|
+
}, i = Vn(r), { token: a, ...f } = n;
|
|
2943
2972
|
return e.json({
|
|
2944
2973
|
ok: !0,
|
|
2945
2974
|
invite: f,
|
|
2946
2975
|
payload: r,
|
|
2947
2976
|
encoded: i,
|
|
2948
|
-
link:
|
|
2977
|
+
link: Un(i)
|
|
2949
2978
|
});
|
|
2950
2979
|
} catch (t) {
|
|
2951
2980
|
if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
|
|
@@ -3047,7 +3076,7 @@ function fr(e) {
|
|
|
3047
3076
|
display_name: String(e.display_name ?? ""),
|
|
3048
3077
|
existing_memory_count: Number(e.existing_memory_count ?? 0)
|
|
3049
3078
|
}));
|
|
3050
|
-
s =
|
|
3079
|
+
s = Un(Vn({
|
|
3051
3080
|
v: 1,
|
|
3052
3081
|
kind: "coordinator_team_invite",
|
|
3053
3082
|
coordinator_url: new URL(e.req.url).origin,
|
|
@@ -3164,11 +3193,11 @@ function fr(e) {
|
|
|
3164
3193
|
} finally {
|
|
3165
3194
|
await c.close();
|
|
3166
3195
|
}
|
|
3167
|
-
}), u.post("/v1/admin/join-requests/approve", async (e) =>
|
|
3196
|
+
}), u.post("/v1/admin/join-requests/approve", async (e) => yr(e, !0, {
|
|
3168
3197
|
createStore: n,
|
|
3169
3198
|
runtime: t,
|
|
3170
3199
|
rateLimitedResponse: f
|
|
3171
|
-
})), u.post("/v1/admin/join-requests/deny", async (e) =>
|
|
3200
|
+
})), u.post("/v1/admin/join-requests/deny", async (e) => yr(e, !1, {
|
|
3172
3201
|
createStore: n,
|
|
3173
3202
|
runtime: t,
|
|
3174
3203
|
rateLimitedResponse: f
|
|
@@ -3192,7 +3221,7 @@ function fr(e) {
|
|
|
3192
3221
|
if (!i) return e.json({ error: "invalid_json" }, 400);
|
|
3193
3222
|
let a = String(i.token ?? "").trim(), o = String(i.device_id ?? "").trim(), s = String(i.fingerprint ?? "").trim(), c = String(i.public_key ?? "").trim(), l = String(i.display_name ?? "").trim() || null, u = String(i.operation_id ?? "").trim(), d = String(i.recipient_actor_id ?? "").trim(), f = String(i.recipient_display_name ?? "").trim(), h = String(i.device_display_name ?? "").trim();
|
|
3194
3223
|
if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
|
|
3195
|
-
if (
|
|
3224
|
+
if (Ot(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
|
|
3196
3225
|
let g = n();
|
|
3197
3226
|
try {
|
|
3198
3227
|
let n = await g.getInviteByTokenForInspection(a);
|
|
@@ -3220,11 +3249,11 @@ function fr(e) {
|
|
|
3220
3249
|
try {
|
|
3221
3250
|
if (i.recipient_display_name != null) {
|
|
3222
3251
|
if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
|
|
3223
|
-
d =
|
|
3252
|
+
d = R(i.recipient_display_name, "recipient_display_name");
|
|
3224
3253
|
}
|
|
3225
3254
|
if (i.device_display_name != null) {
|
|
3226
3255
|
if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
|
|
3227
|
-
f =
|
|
3256
|
+
f = at(i.device_display_name, "device_display_name");
|
|
3228
3257
|
}
|
|
3229
3258
|
} catch (t) {
|
|
3230
3259
|
return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
|
|
@@ -3279,7 +3308,7 @@ function fr(e) {
|
|
|
3279
3308
|
if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
|
|
3280
3309
|
let l, p;
|
|
3281
3310
|
try {
|
|
3282
|
-
l =
|
|
3311
|
+
l = R(f, "recipient_display_name"), p = at(h, "device_display_name");
|
|
3283
3312
|
} catch (t) {
|
|
3284
3313
|
return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
|
|
3285
3314
|
}
|
|
@@ -3303,7 +3332,7 @@ function fr(e) {
|
|
|
3303
3332
|
});
|
|
3304
3333
|
return e.json({
|
|
3305
3334
|
ok: !0,
|
|
3306
|
-
status:
|
|
3335
|
+
status: Gn,
|
|
3307
3336
|
group_id: n.invite.group_id,
|
|
3308
3337
|
operation_id: n.invite.operation_id,
|
|
3309
3338
|
trust_state: n.invite.trust_state,
|
|
@@ -3372,14 +3401,14 @@ function fr(e) {
|
|
|
3372
3401
|
}
|
|
3373
3402
|
}), u;
|
|
3374
3403
|
}
|
|
3375
|
-
async function
|
|
3404
|
+
async function yr(e, t, n) {
|
|
3376
3405
|
let r = Z(e.req.header(X), n.runtime);
|
|
3377
3406
|
if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
|
|
3378
3407
|
let i = n.rateLimitedResponse(e, "admin", !0);
|
|
3379
3408
|
if (i) return i;
|
|
3380
3409
|
let a = await (async () => {
|
|
3381
3410
|
let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
|
|
3382
|
-
if (Number.isFinite(t) && t >
|
|
3411
|
+
if (Number.isFinite(t) && t > ur) return null;
|
|
3383
3412
|
let n = e.req.raw.body;
|
|
3384
3413
|
if (!n) return /* @__PURE__ */ new Uint8Array();
|
|
3385
3414
|
let r = n.getReader(), i = [], a = 0;
|
|
@@ -3388,7 +3417,7 @@ async function pr(e, t, n) {
|
|
|
3388
3417
|
let { done: e, value: t } = await r.read();
|
|
3389
3418
|
if (e) break;
|
|
3390
3419
|
if (t) {
|
|
3391
|
-
if (a += t.byteLength, a >
|
|
3420
|
+
if (a += t.byteLength, a > ur) return await r.cancel(), null;
|
|
3392
3421
|
i.push(t);
|
|
3393
3422
|
}
|
|
3394
3423
|
}
|
|
@@ -3436,6 +3465,6 @@ async function pr(e, t, n) {
|
|
|
3436
3465
|
}
|
|
3437
3466
|
}
|
|
3438
3467
|
//#endregion
|
|
3439
|
-
export {
|
|
3468
|
+
export { Ne as $, R as A, He as B, Ct as C, o as Ct, st as D, a as Dt, Et as E, S as Et, Je as F, Se as G, Ve as H, Ke as I, ye as J, we as K, Ye as L, ct as M, Ze as N, L as O, Xe as P, Fe as Q, P as R, wt as S, s as St, Tt as T, x as Tt, Ue as U, Ge as V, Te as W, ve as X, be as Y, Ee as Z, Wn as _, le as _t, sr as a, de as at, lt as b, T as bt, er as c, ge as ct, Kn as d, ue as dt, Me as et, qn as f, fe as ft, Vn as g, _e as gt, Hn as h, pe as ht, cr as i, Ie as it, I as j, ot as k, Qn as l, re as lt, Yn as m, he as mt, lr as n, Le as nt, Xn as o, ce as ot, Jn as p, me as pt, xe as q, or as r, Re as rt, $n as s, D as st, vr as t, Pe as tt, Gn as u, ie as ut, Un as v, w as vt, Dt as w, p as wt, z as x, C as xt, Ot as y, E as yt, We as z };
|
|
3440
3469
|
|
|
3441
|
-
//# sourceMappingURL=coordinator-api-
|
|
3470
|
+
//# sourceMappingURL=coordinator-api-C2ckGC2b.js.map
|