@fedify/fedify 2.4.0-dev.1988 → 2.4.0-dev.2010

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.
Files changed (62) hide show
  1. package/dist/{builder-Cts78G9N.mjs → builder-asm96yV1.mjs} +2 -2
  2. package/dist/compat/transformers.test.mjs +1 -1
  3. package/dist/compound-proof-7UIAueLV.mjs +495 -0
  4. package/dist/{deno-BgMEefEr.mjs → deno-Ckq9TwCv.mjs} +1 -1
  5. package/dist/{docloader-DEYs99FZ.mjs → docloader-DUKEPG-O.mjs} +2 -2
  6. package/dist/federation/builder.test.mjs +1 -1
  7. package/dist/federation/handler-compound-proof.test.d.mts +2 -0
  8. package/dist/federation/handler-compound-proof.test.mjs +152 -0
  9. package/dist/federation/handler.test.mjs +5 -5
  10. package/dist/federation/idempotency.test.mjs +2 -2
  11. package/dist/federation/metrics.test.mjs +1 -1
  12. package/dist/federation/middleware.test.mjs +7 -7
  13. package/dist/federation/mod.cjs +1 -1
  14. package/dist/federation/mod.js +1 -1
  15. package/dist/federation/send.test.mjs +3 -3
  16. package/dist/federation/tasks/enqueue.test.mjs +1 -1
  17. package/dist/federation/tasks/tasks.test.mjs +2 -2
  18. package/dist/federation/temporal.test.mjs +1 -1
  19. package/dist/federation/webfinger.test.mjs +1 -1
  20. package/dist/{federation-DzPUG_AP.cjs → federation-CgbvMauV.cjs} +542 -43
  21. package/dist/{http-CgwqtxAy.js → http-DQA2JOEJ.js} +2 -2
  22. package/dist/{http-Z3anvCd-.cjs → http-DQBfmkrS.cjs} +2 -2
  23. package/dist/{http-CtidZS_t.mjs → http-DZaAutqg.mjs} +3 -3
  24. package/dist/{key-Cwbg5ggV.mjs → key-zxzx01Ec.mjs} +2 -2
  25. package/dist/{kv-cache-CykuL0ya.js → kv-cache-BBoePTOJ.js} +1 -1
  26. package/dist/{kv-cache-DHiR8yTf.mjs → kv-cache-CbrUX90H.mjs} +1 -1
  27. package/dist/{kv-cache-BM2-w-Wq.cjs → kv-cache-sy8OMNT8.cjs} +1 -1
  28. package/dist/{ld-CzhdWyTt.mjs → ld-CD_TN0e8.mjs} +3 -3
  29. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +204 -0
  30. package/dist/map-local-create-note-B0SeXJms.mjs +214 -0
  31. package/dist/{metrics-CrqsHP0l.mjs → metrics-B47Cm5gK.mjs} +1 -1
  32. package/dist/{middleware-CeCj5caM.js → middleware-U0OIuqwD.js} +511 -12
  33. package/dist/{middleware-CZpYxSKD.mjs → middleware-U_Gannqi.mjs} +1 -1
  34. package/dist/{middleware-DCpiAsZi.mjs → middleware-pHwDTAnq.mjs} +52 -20
  35. package/dist/mod.cjs +19 -19
  36. package/dist/mod.js +4 -4
  37. package/dist/nodeinfo/handler.test.mjs +1 -1
  38. package/dist/{proof-DHu5zI0Z.cjs → owner--mNatWct.cjs} +1252 -1140
  39. package/dist/{proof-CUghqhAf.js → owner-BNKC3s6G.js} +1239 -1139
  40. package/dist/{owner-BqVXJLW8.mjs → owner-u3IJRhVx.mjs} +2 -2
  41. package/dist/{proof-DL8Iid3a.mjs → proof-D3te0SP-.mjs} +176 -76
  42. package/dist/{send-6jS4xFsX.mjs → send-CDr0Zivk.mjs} +3 -3
  43. package/dist/sig/compound-proof-discovery.test.d.mts +2 -0
  44. package/dist/sig/compound-proof-discovery.test.mjs +331 -0
  45. package/dist/sig/compound-proof-verification.test.d.mts +2 -0
  46. package/dist/sig/compound-proof-verification.test.mjs +465 -0
  47. package/dist/sig/compound-proof.test.d.mts +2 -0
  48. package/dist/sig/compound-proof.test.mjs +324 -0
  49. package/dist/sig/http.test.mjs +2 -2
  50. package/dist/sig/key.test.mjs +1 -1
  51. package/dist/sig/ld.test.mjs +2 -2
  52. package/dist/sig/mod.cjs +17 -17
  53. package/dist/sig/mod.js +2 -2
  54. package/dist/sig/owner.test.mjs +1 -1
  55. package/dist/sig/proof.test.mjs +1 -1
  56. package/dist/{temporal-DcyzeytP.mjs → temporal-DKhVF_Uk.mjs} +1 -1
  57. package/dist/testing/kv.test.mjs +1 -1
  58. package/dist/utils/docloader.test.mjs +2 -2
  59. package/dist/utils/kv-cache.test.mjs +1 -1
  60. package/dist/utils/mod.cjs +1 -1
  61. package/dist/utils/mod.js +1 -1
  62. package/package.json +6 -6
@@ -0,0 +1,331 @@
1
+ import "temporal-polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
5
+ import "../std__assert-CxFT0MNt.mjs";
6
+ import { n as inspectCompoundPortableObjectApplicability, t as discoverCompoundProofDocuments } from "../compound-proof-7UIAueLV.mjs";
7
+ import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
8
+ import { test } from "@fedify/fixture";
9
+ //#region src/sig/compound-proof-discovery.test.ts
10
+ const limits = {
11
+ maxDepth: 16,
12
+ maxMaps: 32,
13
+ maxProofs: 8,
14
+ maxBytes: 16384
15
+ };
16
+ test("portable applicability is bounded and ignores metadata", () => {
17
+ assertEquals(inspectCompoundPortableObjectApplicability({
18
+ "@context": { id: "ap://did:key:context/object" },
19
+ proof: { id: "ap://did:key:proof/object" },
20
+ object: { id: "https://example.com/objects/1" }
21
+ }, limits), "absent");
22
+ assertEquals(inspectCompoundPortableObjectApplicability({ object: [{ "@id": "AP+EF61://did:key:child/objects/1" }] }, limits), "present");
23
+ assertEquals(inspectCompoundPortableObjectApplicability({ values: new Array(2e4).fill(0) }, {
24
+ ...limits,
25
+ maxBytes: 1e3
26
+ }), "indeterminate");
27
+ });
28
+ test("discoverCompoundProofDocuments() returns immutable deepest-first candidates", () => {
29
+ const input = {
30
+ id: "ap://example.test/activities/1",
31
+ object: {
32
+ id: "ap://example.test/objects/1",
33
+ content: "one",
34
+ proof: {
35
+ type: "DataIntegrityProof",
36
+ proofValue: "zInner"
37
+ }
38
+ },
39
+ items: [{
40
+ id: "ap://example.test/objects/2",
41
+ content: "two",
42
+ proof: {
43
+ type: "DataIntegrityProof",
44
+ proofValue: "zArray"
45
+ }
46
+ }],
47
+ "a/b~c": {
48
+ "@id": "ap://example.test/objects/3",
49
+ proof: {
50
+ type: "DataIntegrityProof",
51
+ proofValue: "zEscaped"
52
+ }
53
+ },
54
+ proof: {
55
+ type: "DataIntegrityProof",
56
+ proofValue: "zOuter",
57
+ proof: {
58
+ type: "DataIntegrityProof",
59
+ proofValue: "zNotADocument"
60
+ }
61
+ }
62
+ };
63
+ const before = structuredClone(input);
64
+ const result = discoverCompoundProofDocuments(input, limits);
65
+ assertEquals(input, before);
66
+ assertEquals(result.status, "ok");
67
+ if (result.status !== "ok") return;
68
+ assertEquals(result.documents.map(({ path, id, depth }) => ({
69
+ path,
70
+ id,
71
+ depth
72
+ })), [
73
+ {
74
+ path: "/items/0",
75
+ id: "ap://example.test/objects/2",
76
+ depth: 2
77
+ },
78
+ {
79
+ path: "/a~1b~0c",
80
+ id: "ap://example.test/objects/3",
81
+ depth: 1
82
+ },
83
+ {
84
+ path: "/object",
85
+ id: "ap://example.test/objects/1",
86
+ depth: 1
87
+ },
88
+ {
89
+ path: "",
90
+ id: "ap://example.test/activities/1",
91
+ depth: 0
92
+ }
93
+ ]);
94
+ assertEquals(result.documents[0].securedDocument, input.items[0]);
95
+ assertEquals(result.documents[0].proof, input.items[0].proof);
96
+ assertEquals(result.statistics.proofCount, 4);
97
+ input.items[0].content = "mutated after discovery";
98
+ assertEquals(result.documents[0].securedDocument.content, "two");
99
+ assertEquals(result.snapshot.items[0].content, "two");
100
+ });
101
+ test("discoverCompoundProofDocuments() is independent of member order", () => {
102
+ const first = {
103
+ z: {
104
+ id: "z",
105
+ proof: { proofValue: "z" }
106
+ },
107
+ a: {
108
+ id: "a",
109
+ proof: { proofValue: "a" }
110
+ },
111
+ proof: { proofValue: "root" }
112
+ };
113
+ const second = {
114
+ proof: { proofValue: "root" },
115
+ a: {
116
+ proof: { proofValue: "a" },
117
+ id: "a"
118
+ },
119
+ z: {
120
+ proof: { proofValue: "z" },
121
+ id: "z"
122
+ }
123
+ };
124
+ const firstResult = discoverCompoundProofDocuments(first, limits);
125
+ const secondResult = discoverCompoundProofDocuments(second, limits);
126
+ assertEquals(firstResult.status, "ok");
127
+ assertEquals(secondResult.status, "ok");
128
+ if (firstResult.status !== "ok" || secondResult.status !== "ok") return;
129
+ assertEquals(firstResult.documents.map((candidate) => candidate.path), [
130
+ "/a",
131
+ "/z",
132
+ ""
133
+ ]);
134
+ assertEquals(secondResult.documents.map((candidate) => candidate.path), [
135
+ "/a",
136
+ "/z",
137
+ ""
138
+ ]);
139
+ });
140
+ test("discoverCompoundProofDocuments() does not inspect context definitions", () => {
141
+ const result = discoverCompoundProofDocuments({
142
+ "@context": {
143
+ proof: "https://w3id.org/security#proof",
144
+ portable: {
145
+ "@id": "ap://did:key:z6MkContext/objects/1",
146
+ "@context": { proof: "https://example.com/nested-proof" }
147
+ }
148
+ },
149
+ id: "https://social.example/objects/1",
150
+ type: "Note"
151
+ }, limits);
152
+ assertEquals(result.status, "ok");
153
+ if (result.status !== "ok") return;
154
+ assertEquals(result.documents, []);
155
+ assertEquals(result.statistics.proofCount, 0);
156
+ });
157
+ test("discoverCompoundProofDocuments() preserves the recorded compound vector", () => {
158
+ const result = discoverCompoundProofDocuments(map_local_create_note_default.documents.finalSecuredCompound, limits);
159
+ assertEquals(result.status, "ok");
160
+ if (result.status !== "ok") return;
161
+ assertEquals(result.documents.map(({ path }) => path), ["/object", ""]);
162
+ assertEquals(result.documents[0].securedDocument, map_local_create_note_default.documents.securedInner);
163
+ assertEquals(result.documents[1].securedDocument, map_local_create_note_default.documents.finalSecuredCompound);
164
+ });
165
+ test("discoverCompoundProofDocuments() rejects unsupported proof shapes atomically", () => {
166
+ for (const proof of [
167
+ null,
168
+ "remote-proof",
169
+ [{ proofValue: "z" }]
170
+ ]) assertEquals(discoverCompoundProofDocuments({
171
+ object: { proof: { proofValue: "valid candidate" } },
172
+ other: { proof }
173
+ }, limits), {
174
+ status: "unsupported",
175
+ reason: {
176
+ type: "unsupportedProofShape",
177
+ path: "/other/proof"
178
+ }
179
+ });
180
+ });
181
+ test("discoverCompoundProofDocuments() applies resource limits atomically", () => {
182
+ const cases = [
183
+ {
184
+ input: { child: { child: { proof: {} } } },
185
+ limits: {
186
+ ...limits,
187
+ maxDepth: 1
188
+ },
189
+ limit: "depth",
190
+ maximum: 1
191
+ },
192
+ {
193
+ input: {
194
+ first: {},
195
+ second: { proof: {} }
196
+ },
197
+ limits: {
198
+ ...limits,
199
+ maxMaps: 2
200
+ },
201
+ limit: "maps",
202
+ maximum: 2
203
+ },
204
+ {
205
+ input: {
206
+ first: { proof: {} },
207
+ second: { proof: {} }
208
+ },
209
+ limits: {
210
+ ...limits,
211
+ maxProofs: 1
212
+ },
213
+ limit: "proofs",
214
+ maximum: 1
215
+ },
216
+ {
217
+ input: {
218
+ content: "too large",
219
+ proof: {}
220
+ },
221
+ limits: {
222
+ ...limits,
223
+ maxBytes: 8
224
+ },
225
+ limit: "bytes",
226
+ maximum: 8
227
+ }
228
+ ];
229
+ for (const fixture of cases) {
230
+ const result = discoverCompoundProofDocuments(fixture.input, fixture.limits);
231
+ assertEquals(result.status, "unsupported");
232
+ if (result.status !== "unsupported") continue;
233
+ assertEquals(result.reason.type, "limitExceeded");
234
+ if (result.reason.type !== "limitExceeded") continue;
235
+ assertEquals(result.reason.limit, fixture.limit);
236
+ assertEquals(result.reason.maximum, fixture.maximum);
237
+ }
238
+ });
239
+ test("discoverCompoundProofDocuments() rejects values that are not JSON trees", () => {
240
+ const cyclic = { proof: {} };
241
+ cyclic.self = cyclic;
242
+ const shared = { proof: {} };
243
+ const symbolKeyed = { [Symbol("hidden")]: { proof: {} } };
244
+ for (const input of [
245
+ [],
246
+ { value: void 0 },
247
+ { value: NaN },
248
+ cyclic,
249
+ {
250
+ first: shared,
251
+ second: shared
252
+ },
253
+ symbolKeyed
254
+ ]) {
255
+ const result = discoverCompoundProofDocuments(input, limits);
256
+ assertEquals(result.status, "unsupported");
257
+ if (result.status !== "unsupported") continue;
258
+ assertEquals(result.reason.type, "invalidJsonTree");
259
+ }
260
+ });
261
+ test("discoverCompoundProofDocuments() handles wide JSON containers", () => {
262
+ const input = { values: new Array(2e5).fill(0) };
263
+ const result = discoverCompoundProofDocuments(input, {
264
+ maxDepth: 2,
265
+ maxMaps: 1,
266
+ maxProofs: 0,
267
+ maxBytes: 1048576
268
+ });
269
+ assertEquals(result.status, "ok");
270
+ if (result.status !== "ok") return;
271
+ assertEquals(result.statistics.byteLength, JSON.stringify(input).length);
272
+ });
273
+ test("discoverCompoundProofDocuments() rejects accessors without invoking them", () => {
274
+ let getterCalls = 0;
275
+ const accessorMap = {};
276
+ Object.defineProperty(accessorMap, "object", {
277
+ enumerable: true,
278
+ get() {
279
+ getterCalls++;
280
+ return { proof: {} };
281
+ }
282
+ });
283
+ const accessorArray = [{}];
284
+ Object.defineProperty(accessorArray, 0, {
285
+ enumerable: true,
286
+ get() {
287
+ getterCalls++;
288
+ return { proof: {} };
289
+ }
290
+ });
291
+ for (const input of [accessorMap, { items: accessorArray }]) {
292
+ const result = discoverCompoundProofDocuments(input, limits);
293
+ assertEquals(result.status, "unsupported");
294
+ if (result.status !== "unsupported") continue;
295
+ assertEquals(result.reason.type, "invalidJsonTree");
296
+ }
297
+ assertEquals(getterCalls, 0);
298
+ });
299
+ test("discoverCompoundProofDocuments() rejects non-enumerable map properties", () => {
300
+ const input = {};
301
+ Object.defineProperty(input, "proof", {
302
+ value: {},
303
+ enumerable: false
304
+ });
305
+ const result = discoverCompoundProofDocuments(input, limits);
306
+ assertEquals(result.status, "unsupported");
307
+ if (result.status !== "unsupported") return;
308
+ assertEquals(result.reason.type, "invalidJsonTree");
309
+ });
310
+ test("discoverCompoundProofDocuments() rejects non-JSON array properties", () => {
311
+ const namedProperty = Object.assign([], { extra: { proof: {} } });
312
+ const sparse = new Array(2);
313
+ sparse[1] = null;
314
+ const nonEnumerableIndex = [];
315
+ Object.defineProperty(nonEnumerableIndex, 0, {
316
+ value: { proof: {} },
317
+ enumerable: false
318
+ });
319
+ for (const input of [
320
+ { items: namedProperty },
321
+ { items: sparse },
322
+ { items: nonEnumerableIndex }
323
+ ]) {
324
+ const result = discoverCompoundProofDocuments(input, limits);
325
+ assertEquals(result.status, "unsupported");
326
+ if (result.status !== "unsupported") continue;
327
+ assertEquals(result.reason.type, "invalidJsonTree");
328
+ }
329
+ });
330
+ //#endregion
331
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "temporal-polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";