@fedify/fedify 1.8.1-pr.315.1091 → 1.8.1-pr.318.1226

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 (130) hide show
  1. package/README.md +7 -1
  2. package/dist/{actor-DLZ25ttS.js → actor-0LRDe92J.js} +179 -179
  3. package/dist/{actor-C_d9cZrz.js → actor-CBdxZ_5B.js} +1 -4
  4. package/dist/{actor-1rvS-py8.d.ts → actor-CWNAGvnO.d.ts} +2 -2
  5. package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-AjlKk-Vo.js} +1 -1
  6. package/dist/{assert_throws-DTDC_gwN.js → assert_throws-CqMKbTh_.js} +1 -1
  7. package/dist/{authdocloader-CLixqGPW.js → authdocloader-D44DXoqW.js} +4 -4
  8. package/dist/{authdocloader-DUnUXs5R.js → authdocloader-WRu2Kpbf.js} +4 -5
  9. package/dist/{builder-Js_TKEl1.js → builder-Dh_UMNS6.js} +74 -5
  10. package/dist/{client-DK4qnXK0.d.ts → client-B0IOer6B.d.ts} +1 -1
  11. package/dist/{client-Cu9HMcIJ.js → client-Czxpmewo.js} +2 -2
  12. package/dist/compat/mod.d.ts +11 -11
  13. package/dist/compat/mod.js +1 -1
  14. package/dist/compat/transformers.test.js +20 -27
  15. package/dist/{context-BhO5LP_t.d.ts → context-BNA3vzcr.d.ts} +273 -60
  16. package/dist/{docloader-BindvZ7y.js → docloader-BHVq3b-C.js} +26 -13
  17. package/dist/{docloader-DtGccyuM.d.ts → docloader-CLolPVL_.d.ts} +2 -11
  18. package/dist/{esm-d-9EVGaP.js → esm-B2SCYePu.js} +1 -1
  19. package/dist/federation/builder.test.js +30 -16
  20. package/dist/federation/collection.test.js +9 -7
  21. package/dist/federation/handler.test.js +336 -35
  22. package/dist/federation/inbox.test.js +6 -10
  23. package/dist/federation/keycache.test.js +4 -7
  24. package/dist/federation/kv.test.js +8 -6
  25. package/dist/federation/middleware.test.js +58 -35
  26. package/dist/federation/mod.d.ts +11 -11
  27. package/dist/federation/mod.js +11 -11
  28. package/dist/federation/mq.test.js +10 -8
  29. package/dist/federation/retry.test.js +5 -3
  30. package/dist/federation/router.test.js +8 -7
  31. package/dist/federation/send.test.js +15 -21
  32. package/dist/{http-DIyD7he1.js → http-CEG06HdI.js} +5 -4
  33. package/dist/{http-Cp-0z2Ja.d.ts → http-COez3YdK.d.ts} +4 -4
  34. package/dist/{http-BigTqmE7.js → http-y8quLgtl.js} +4 -4
  35. package/dist/{inbox-BB6ajp8P.js → inbox-C-5n8RpN.js} +1 -3
  36. package/dist/{key-DlkWX5Fp.js → key-BZv5cFOk.js} +4 -4
  37. package/dist/key-BmX3Xl8V.js +10 -0
  38. package/dist/{key-D9LuuzMv.js → key-DWoGACfw.js} +3 -4
  39. package/dist/{key-BfI9Ju0m.js → key-Onkg3OkA.js} +3 -3
  40. package/dist/{keycache-C4C7f09E.js → keycache-DSOcI0ys.js} +1 -1
  41. package/dist/{keys-BjET3ZIs.js → keys-BpduoW2T.js} +1 -1
  42. package/dist/{kv-DDdb1hMa.d.ts → kv-BqOK6zss.d.ts} +1 -1
  43. package/dist/{ld-CYqXYuyr.js → ld-Gnnbyhbn.js} +2 -4
  44. package/dist/{lookup-_XgQq_BY.js → lookup-1w_0aKHb.js} +2 -3
  45. package/dist/{lookup-BYiP0j0F.js → lookup-BrKHd_gO.js} +116 -10
  46. package/dist/{lookup-m3U6KA0u.d.ts → lookup-tSXYzgYs.d.ts} +1 -7
  47. package/dist/middleware-BRY2xSk9.js +17 -0
  48. package/dist/{middleware-VSdfWI3m.js → middleware-CC2z8n5b.js} +556 -25
  49. package/dist/middleware-CuCsdoo8.js +26 -0
  50. package/dist/{middleware-e74I4DJ9.js → middleware-Db24iHkj.js} +617 -12
  51. package/dist/{mod-yPzXIjJX.d.ts → mod-Bf-mThHd.d.ts} +4 -4
  52. package/dist/{mod-BqCBztub.d.ts → mod-C2jQirfr.d.ts} +2 -7
  53. package/dist/{mod-nlVEnYuj.d.ts → mod-CxD6XXBN.d.ts} +5 -5
  54. package/dist/{mod-c1I-Ydch.d.ts → mod-UTC30uNC.d.ts} +2 -2
  55. package/dist/mod.d.ts +14 -14
  56. package/dist/mod.js +11 -11
  57. package/dist/nodeinfo/client.test.js +11 -11
  58. package/dist/nodeinfo/handler.test.js +25 -34
  59. package/dist/nodeinfo/mod.d.ts +3 -3
  60. package/dist/nodeinfo/mod.js +2 -2
  61. package/dist/nodeinfo/semver.test.js +9 -7
  62. package/dist/nodeinfo/types.test.js +10 -8
  63. package/dist/{owner-D7RvVquY.js → owner-BlXcpuDu.js} +2 -3
  64. package/dist/{owner-BK4eWKBp.d.ts → owner-BlxMNrL4.d.ts} +3 -3
  65. package/dist/{proof-ChRSmA_D.js → proof-ab2WWb-L.js} +4 -4
  66. package/dist/{proof-D4z1cLgw.js → proof-xhXpvg1i.js} +3 -5
  67. package/dist/runtime/authdocloader.test.js +14 -20
  68. package/dist/runtime/docloader.test.js +9 -10
  69. package/dist/runtime/key.test.js +10 -15
  70. package/dist/runtime/langstr.test.js +8 -7
  71. package/dist/runtime/mod.d.ts +5 -5
  72. package/dist/runtime/mod.js +6 -6
  73. package/dist/runtime/multibase/multibase.test.js +8 -7
  74. package/dist/runtime/url.test.js +5 -4
  75. package/dist/{send-DmlRAY0X.js → send-ubsDsJMw.js} +2 -2
  76. package/dist/sig/http.test.js +36 -19
  77. package/dist/sig/key.test.js +11 -17
  78. package/dist/sig/ld.test.js +10 -16
  79. package/dist/sig/mod.d.ts +7 -7
  80. package/dist/sig/mod.js +6 -6
  81. package/dist/sig/owner.test.js +12 -19
  82. package/dist/sig/proof.test.js +12 -18
  83. package/dist/testing/docloader.test.js +8 -7
  84. package/dist/testing/mod.d.ts +8599 -1
  85. package/dist/testing/mod.js +4 -2
  86. package/dist/testing-Dv2RuzR3.js +302 -0
  87. package/dist/{transformers-ghwJuzGY.js → transformers-DJRB0yFF.js} +3 -3
  88. package/dist/{vocab-dw0HG0EQ.js → type-BLj4c5rS.js} +5255 -183
  89. package/dist/{types-DuZ6KMHu.js → types-WSGNUHOP.js} +1 -1
  90. package/dist/{types-C7C_l-jz.js → types-n7HI7VFr.js} +1 -1
  91. package/dist/vocab/actor.test.js +10 -16
  92. package/dist/vocab/lookup.test.js +11 -110
  93. package/dist/vocab/mod.d.ts +5 -5
  94. package/dist/vocab/mod.js +4 -4
  95. package/dist/vocab/type.test.js +3 -7
  96. package/dist/vocab/vocab.test.js +9 -13
  97. package/dist/{vocab-CI5oydJj.js → vocab-Cr35Ee8r.js} +6 -7
  98. package/dist/{vocab-B52eQhpN.d.ts → vocab-Cyrb7_co.d.ts} +1 -1
  99. package/dist/webfinger/handler.test.js +25 -34
  100. package/dist/webfinger/lookup.test.js +9 -64
  101. package/dist/webfinger/mod.d.ts +3 -3
  102. package/dist/webfinger/mod.js +2 -2
  103. package/dist/x/cfworkers.d.ts +1 -1
  104. package/dist/x/cfworkers.test.js +8 -6
  105. package/dist/x/hono.d.ts +14 -14
  106. package/dist/x/hono.js +2 -2
  107. package/dist/x/sveltekit.d.ts +11 -11
  108. package/dist/x/sveltekit.js +1 -1
  109. package/package.json +1 -1
  110. package/dist/chunk-HsBuZ-b2.js +0 -41
  111. package/dist/context-CXi1nrZE.js +0 -108
  112. package/dist/docloader-Bh-sDknx.js +0 -68
  113. package/dist/docloader-CJ7eOrpZ.js +0 -4514
  114. package/dist/key-DG7lKWv0.js +0 -16
  115. package/dist/langstr-DbWheeIS.js +0 -33
  116. package/dist/lookup-CEbB0_t_.js +0 -133
  117. package/dist/middleware-Dd2mc8-e.js +0 -33
  118. package/dist/middleware-DjA978L0.js +0 -17
  119. package/dist/multibase-DeCHcK8L.js +0 -316
  120. package/dist/router-D3UybECj.js +0 -118
  121. package/dist/testing-BZ0dJ4qn.js +0 -143
  122. package/dist/type-D2s5lmbZ.js +0 -14
  123. package/dist/url-kTAI6_KP.js +0 -68
  124. /package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-CeVBLPsZ.js} +0 -0
  125. /package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-D2R2nl5h.js} +0 -0
  126. /package/dist/{collection-Dfb0TPno.js → collection-D5V3UzU3.js} +0 -0
  127. /package/dist/{denokv-QWKsIqML.js → denokv-DK9P5Jq7.js} +0 -0
  128. /package/dist/{retry-BiIhZWgD.js → retry-BnpVRGFC.js} +0 -0
  129. /package/dist/{semver-DWClQt_5.js → semver-DCqorrj5.js} +0 -0
  130. /package/dist/{std__assert-B3iAixc-.js → std__assert-BQdmxyzF.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore } from "./kv-DDdb1hMa.js";
3
+ import { KvKey, KvStore } from "./kv-BqOK6zss.js";
4
4
 
5
5
  //#region runtime/docloader.d.ts
6
6
  /**
@@ -21,20 +21,12 @@ interface RemoteDocument {
21
21
  */
22
22
  documentUrl: string;
23
23
  }
24
- /**
25
- * Options for {@link DocumentLoader}.
26
- * @since 1.8.0
27
- */
28
- interface DocumentLoaderOptions {
29
- signal?: AbortSignal;
30
- }
31
24
  /**
32
25
  * A JSON-LD document loader that fetches documents from the Web.
33
26
  * @param url The URL of the document to load.
34
- * @param options The options for the document loader.
35
27
  * @returns The loaded remote document.
36
28
  */
37
- type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
29
+ type DocumentLoader = (url: string) => Promise<RemoteDocument>;
38
30
  /**
39
31
  * A factory function that creates a {@link DocumentLoader} with options.
40
32
  * @param options The options for the document loader.
@@ -148,7 +140,6 @@ declare function getDocumentLoader({
148
140
  * @deprecated Use {@link getDocumentLoader} instead.
149
141
  */
150
142
  declare function fetchDocumentLoader(url: string, allowPrivateAddress?: boolean): Promise<RemoteDocument>;
151
- declare function fetchDocumentLoader(url: string, options?: DocumentLoaderOptions): Promise<RemoteDocument>;
152
143
  /**
153
144
  * The parameters for {@link kvCache} function.
154
145
  */
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { __commonJS, __toESM } from "./chunk-HsBuZ-b2.js";
6
+ import { __commonJS, __toESM } from "./type-BLj4c5rS.js";
7
7
 
8
8
  //#region ../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
9
9
  var require_glob_to_regexp = __commonJS({ "../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
@@ -3,26 +3,21 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import { Activity, Note, Person } from "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
8
  import "../assert-DwEa6glZ.js";
8
9
  import "../assert_instance_of-C9QtN-X9.js";
9
10
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
10
- import "../docloader-CJ7eOrpZ.js";
11
- import "../url-kTAI6_KP.js";
12
- import { parseSemVer } from "../semver-DWClQt_5.js";
13
- import "../router-D3UybECj.js";
14
- import "../multibase-DeCHcK8L.js";
15
- import { Activity, Note, Person } from "../vocab-dw0HG0EQ.js";
16
- import "../langstr-DbWheeIS.js";
17
- import "../type-D2s5lmbZ.js";
18
- import "../inbox-BB6ajp8P.js";
19
- import { createFederationBuilder } from "../builder-Js_TKEl1.js";
20
- import { test } from "../testing-BZ0dJ4qn.js";
21
- import { assertExists } from "../std__assert-B3iAixc-.js";
22
- import "../assert_rejects-DceVjUlD.js";
23
- import "../assert_is_error-DQdKoRgb.js";
24
- import "../assert_not_equals-7pyUM3Ib.js";
25
- import "../assert_throws-DTDC_gwN.js";
11
+ import { parseSemVer } from "../semver-DCqorrj5.js";
12
+ import "../lookup-BrKHd_gO.js";
13
+ import "../inbox-C-5n8RpN.js";
14
+ import { createFederationBuilder } from "../builder-Dh_UMNS6.js";
15
+ import { test } from "../testing-Dv2RuzR3.js";
16
+ import { assertExists } from "../std__assert-BQdmxyzF.js";
17
+ import "../assert_rejects-AjlKk-Vo.js";
18
+ import "../assert_is_error-CeVBLPsZ.js";
19
+ import "../assert_not_equals-D2R2nl5h.js";
20
+ import { assertThrows } from "../assert_throws-CqMKbTh_.js";
26
21
 
27
22
  //#region federation/builder.test.ts
28
23
  test("FederationBuilder", async (t) => {
@@ -155,6 +150,25 @@ test("FederationBuilder", async (t) => {
155
150
  assertEquals(personRoute?.name, `object:${Person.typeId.href}`);
156
151
  assertEquals(personRoute?.values.id, "abc");
157
152
  });
153
+ await t.step("should handle symbol names uniquely in custom collection dispatchers", () => {
154
+ const builder = createFederationBuilder();
155
+ const unnamedSymbol1 = Symbol();
156
+ const unnamedSymbol2 = Symbol();
157
+ const namedSymbol1 = Symbol.for("");
158
+ const namedSymbol2 = Symbol.for("");
159
+ const strId = String(unnamedSymbol1);
160
+ const dispatcher = (_ctx, _params) => ({ items: [] });
161
+ builder.setCollectionDispatcher(unnamedSymbol1, Note, "/unnamed-symbol1/{id}", dispatcher);
162
+ assertThrows(() => {
163
+ builder.setCollectionDispatcher(unnamedSymbol1, Note, "/unnamed-symbol1-duplicate/{id}", dispatcher);
164
+ }, Error, "Collection dispatcher for Symbol() already set.");
165
+ builder.setCollectionDispatcher(unnamedSymbol2, Note, "/unnamed-symbol2/{id}", dispatcher);
166
+ builder.setCollectionDispatcher(namedSymbol1, Note, "/named-symbol/{id}", dispatcher);
167
+ assertThrows(() => {
168
+ builder.setCollectionDispatcher(namedSymbol2, Note, "/named-symbol/{id}", dispatcher);
169
+ });
170
+ builder.setCollectionDispatcher(strId, Note, "/string-id/{id}", dispatcher);
171
+ });
158
172
  });
159
173
 
160
174
  //#endregion
@@ -3,16 +3,18 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
8
  import "../assert-DwEa6glZ.js";
8
9
  import "../assert_instance_of-C9QtN-X9.js";
9
- import { buildCollectionSynchronizationHeader, digest } from "../collection-Dfb0TPno.js";
10
- import { test } from "../testing-BZ0dJ4qn.js";
11
- import "../std__assert-B3iAixc-.js";
12
- import "../assert_rejects-DceVjUlD.js";
13
- import "../assert_is_error-DQdKoRgb.js";
14
- import "../assert_not_equals-7pyUM3Ib.js";
15
- import "../assert_throws-DTDC_gwN.js";
10
+ import "../lookup-BrKHd_gO.js";
11
+ import { buildCollectionSynchronizationHeader, digest } from "../collection-D5V3UzU3.js";
12
+ import { test } from "../testing-Dv2RuzR3.js";
13
+ import "../std__assert-BQdmxyzF.js";
14
+ import "../assert_rejects-AjlKk-Vo.js";
15
+ import "../assert_is_error-CeVBLPsZ.js";
16
+ import "../assert_not_equals-D2R2nl5h.js";
17
+ import "../assert_throws-CqMKbTh_.js";
16
18
  import { decodeHex } from "byte-encodings/hex";
17
19
 
18
20
  //#region federation/collection.test.ts
@@ -3,45 +3,36 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import { Create, Note, Person } from "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
8
  import { assert } from "../assert-DwEa6glZ.js";
8
9
  import "../assert_instance_of-C9QtN-X9.js";
9
10
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
10
- import { acceptsJsonLd, createFederation, handleActor, handleCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-VSdfWI3m.js";
11
- import "../docloader-CJ7eOrpZ.js";
12
- import "../url-kTAI6_KP.js";
13
- import "../semver-DWClQt_5.js";
14
- import "../client-Cu9HMcIJ.js";
15
- import "../router-D3UybECj.js";
16
- import "../types-C7C_l-jz.js";
17
- import "../multibase-DeCHcK8L.js";
18
- import { Create, Note, Person } from "../vocab-dw0HG0EQ.js";
19
- import "../langstr-DbWheeIS.js";
20
- import "../lookup-CEbB0_t_.js";
21
- import "../type-D2s5lmbZ.js";
22
- import "../actor-C_d9cZrz.js";
23
- import "../key-D9LuuzMv.js";
24
- import { signRequest } from "../http-BigTqmE7.js";
25
- import "../authdocloader-DUnUXs5R.js";
26
- import "../ld-CYqXYuyr.js";
27
- import "../owner-D7RvVquY.js";
28
- import "../proof-D4z1cLgw.js";
29
- import "../lookup-BYiP0j0F.js";
30
- import "../inbox-BB6ajp8P.js";
31
- import "../builder-Js_TKEl1.js";
32
- import "../collection-Dfb0TPno.js";
33
- import "../keycache-C4C7f09E.js";
34
- import "../retry-BiIhZWgD.js";
35
- import "../send-DmlRAY0X.js";
36
- import { test } from "../testing-BZ0dJ4qn.js";
37
- import "../std__assert-B3iAixc-.js";
38
- import { assertFalse } from "../assert_rejects-DceVjUlD.js";
39
- import "../assert_is_error-DQdKoRgb.js";
40
- import "../assert_not_equals-7pyUM3Ib.js";
41
- import "../assert_throws-DTDC_gwN.js";
42
- import { mockDocumentLoader } from "../docloader-Bh-sDknx.js";
43
- import { createInboxContext, createRequestContext } from "../context-CXi1nrZE.js";
44
- import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-BjET3ZIs.js";
11
+ import { acceptsJsonLd, createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-CC2z8n5b.js";
12
+ import "../semver-DCqorrj5.js";
13
+ import "../client-Czxpmewo.js";
14
+ import "../lookup-BrKHd_gO.js";
15
+ import "../types-n7HI7VFr.js";
16
+ import "../actor-CBdxZ_5B.js";
17
+ import "../key-DWoGACfw.js";
18
+ import { signRequest } from "../http-y8quLgtl.js";
19
+ import "../authdocloader-WRu2Kpbf.js";
20
+ import "../ld-Gnnbyhbn.js";
21
+ import "../owner-BlXcpuDu.js";
22
+ import "../proof-xhXpvg1i.js";
23
+ import "../inbox-C-5n8RpN.js";
24
+ import "../builder-Dh_UMNS6.js";
25
+ import "../collection-D5V3UzU3.js";
26
+ import "../keycache-DSOcI0ys.js";
27
+ import "../retry-BnpVRGFC.js";
28
+ import "../send-ubsDsJMw.js";
29
+ import { createInboxContext, createRequestContext, mockDocumentLoader, test } from "../testing-Dv2RuzR3.js";
30
+ import "../std__assert-BQdmxyzF.js";
31
+ import { assertFalse } from "../assert_rejects-AjlKk-Vo.js";
32
+ import "../assert_is_error-CeVBLPsZ.js";
33
+ import "../assert_not_equals-D2R2nl5h.js";
34
+ import "../assert_throws-CqMKbTh_.js";
35
+ import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-BpduoW2T.js";
45
36
 
46
37
  //#region federation/handler.test.ts
47
38
  test("acceptsJsonLd()", () => {
@@ -1243,5 +1234,315 @@ test("respondWithObjectIfAcceptable", async () => {
1243
1234
  }), request, { contextLoader: mockDocumentLoader });
1244
1235
  assertEquals(response, null);
1245
1236
  });
1237
+ test("handleCustomCollection()", async () => {
1238
+ const federation = createFederation({ kv: new MemoryKvStore() });
1239
+ let context = createRequestContext({
1240
+ federation,
1241
+ data: void 0,
1242
+ url: new URL("https://example.com/")
1243
+ });
1244
+ const dispatcher = (_ctx, values, cursor) => {
1245
+ if (values.handle !== "someone") return null;
1246
+ const items = [
1247
+ new Create({ id: new URL("https://example.com/activities/1") }),
1248
+ new Create({ id: new URL("https://example.com/activities/2") }),
1249
+ new Create({ id: new URL("https://example.com/activities/3") })
1250
+ ];
1251
+ if (cursor != null) {
1252
+ const idx = parseInt(cursor);
1253
+ return {
1254
+ items: [items[idx]],
1255
+ nextCursor: idx < items.length - 1 ? (idx + 1).toString() : null,
1256
+ prevCursor: idx > 0 ? (idx - 1).toString() : null
1257
+ };
1258
+ }
1259
+ return { items };
1260
+ };
1261
+ const counter = (_ctx, values) => values.handle === "someone" ? 3 : null;
1262
+ const firstCursor = (_ctx, values) => values.handle === "someone" ? "0" : null;
1263
+ const lastCursor = (_ctx, values) => values.handle === "someone" ? "2" : null;
1264
+ const callbacks = {
1265
+ dispatcher,
1266
+ counter,
1267
+ firstCursor,
1268
+ lastCursor
1269
+ };
1270
+ let onNotFoundCalled = null;
1271
+ const onNotFound = (request) => {
1272
+ onNotFoundCalled = request;
1273
+ return new Response("Not found", { status: 404 });
1274
+ };
1275
+ let onNotAcceptableCalled = null;
1276
+ const onNotAcceptable = (request) => {
1277
+ onNotAcceptableCalled = request;
1278
+ return new Response("Not acceptable", { status: 406 });
1279
+ };
1280
+ let onUnauthorizedCalled = null;
1281
+ const onUnauthorized = (request) => {
1282
+ onUnauthorizedCalled = request;
1283
+ return new Response("Unauthorized", { status: 401 });
1284
+ };
1285
+ const errorHandlers = {
1286
+ onNotFound,
1287
+ onNotAcceptable,
1288
+ onUnauthorized
1289
+ };
1290
+ let response = await handleCustomCollection(context.request, {
1291
+ context,
1292
+ name: "custom collection",
1293
+ values: { handle: "someone" },
1294
+ ...errorHandlers
1295
+ });
1296
+ assertEquals(response.status, 404);
1297
+ assertEquals(onNotFoundCalled, context.request);
1298
+ assertEquals(onNotAcceptableCalled, null);
1299
+ assertEquals(onUnauthorizedCalled, null);
1300
+ onNotFoundCalled = null;
1301
+ response = await handleCustomCollection(context.request, {
1302
+ context,
1303
+ name: "custom collection",
1304
+ values: { handle: "someone" },
1305
+ collectionCallbacks: { dispatcher },
1306
+ ...errorHandlers
1307
+ });
1308
+ assertEquals(response.status, 406);
1309
+ assertEquals(onNotFoundCalled, null);
1310
+ assertEquals(onNotAcceptableCalled, context.request);
1311
+ assertEquals(onUnauthorizedCalled, null);
1312
+ onNotAcceptableCalled = null;
1313
+ context = createRequestContext({
1314
+ ...context,
1315
+ request: new Request(context.url, { headers: { Accept: "application/activity+json" } })
1316
+ });
1317
+ response = await handleCustomCollection(context.request, {
1318
+ context,
1319
+ name: "custom collection",
1320
+ values: { handle: "no-one" },
1321
+ collectionCallbacks: { dispatcher },
1322
+ ...errorHandlers
1323
+ });
1324
+ assertEquals(response.status, 404);
1325
+ assertEquals(onNotFoundCalled, context.request);
1326
+ assertEquals(onNotAcceptableCalled, null);
1327
+ assertEquals(onUnauthorizedCalled, null);
1328
+ onNotFoundCalled = null;
1329
+ response = await handleCustomCollection(context.request, {
1330
+ context,
1331
+ name: "custom collection",
1332
+ values: { handle: "someone" },
1333
+ collectionCallbacks: { dispatcher },
1334
+ ...errorHandlers
1335
+ });
1336
+ assertEquals(response.status, 200);
1337
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
1338
+ const createCtx = [
1339
+ "https://w3id.org/identity/v1",
1340
+ "https://www.w3.org/ns/activitystreams",
1341
+ "https://w3id.org/security/data-integrity/v1",
1342
+ {
1343
+ toot: "http://joinmastodon.org/ns#",
1344
+ misskey: "https://misskey-hub.net/ns#",
1345
+ fedibird: "http://fedibird.com/ns#",
1346
+ ChatMessage: "http://litepub.social/ns#ChatMessage",
1347
+ Emoji: "toot:Emoji",
1348
+ Hashtag: "as:Hashtag",
1349
+ sensitive: "as:sensitive",
1350
+ votersCount: {
1351
+ "@id": "toot:votersCount",
1352
+ "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
1353
+ },
1354
+ _misskey_quote: "misskey:_misskey_quote",
1355
+ quoteUri: "fedibird:quoteUri",
1356
+ quoteUrl: "as:quoteUrl",
1357
+ emojiReactions: {
1358
+ "@id": "fedibird:emojiReactions",
1359
+ "@type": "@id"
1360
+ }
1361
+ }
1362
+ ];
1363
+ const CONTEXT = [
1364
+ "https://www.w3.org/ns/activitystreams",
1365
+ "https://w3id.org/security/data-integrity/v1",
1366
+ {
1367
+ toot: "http://joinmastodon.org/ns#",
1368
+ misskey: "https://misskey-hub.net/ns#",
1369
+ fedibird: "http://fedibird.com/ns#",
1370
+ ChatMessage: "http://litepub.social/ns#ChatMessage",
1371
+ Emoji: "toot:Emoji",
1372
+ Hashtag: "as:Hashtag",
1373
+ sensitive: "as:sensitive",
1374
+ votersCount: "toot:votersCount",
1375
+ _misskey_quote: "misskey:_misskey_quote",
1376
+ quoteUri: "fedibird:quoteUri",
1377
+ quoteUrl: "as:quoteUrl",
1378
+ emojiReactions: {
1379
+ "@id": "fedibird:emojiReactions",
1380
+ "@type": "@id"
1381
+ }
1382
+ }
1383
+ ];
1384
+ assertEquals(await response.json(), {
1385
+ "@context": CONTEXT,
1386
+ id: "https://example.com/",
1387
+ type: "Collection",
1388
+ items: [
1389
+ {
1390
+ "@context": createCtx,
1391
+ type: "Create",
1392
+ id: "https://example.com/activities/1"
1393
+ },
1394
+ {
1395
+ "@context": createCtx,
1396
+ type: "Create",
1397
+ id: "https://example.com/activities/2"
1398
+ },
1399
+ {
1400
+ "@context": createCtx,
1401
+ type: "Create",
1402
+ id: "https://example.com/activities/3"
1403
+ }
1404
+ ]
1405
+ });
1406
+ assertEquals(onNotFoundCalled, null);
1407
+ assertEquals(onNotAcceptableCalled, null);
1408
+ assertEquals(onUnauthorizedCalled, null);
1409
+ response = await handleCustomCollection(context.request, {
1410
+ context,
1411
+ name: "custom collection",
1412
+ values: { handle: "someone" },
1413
+ collectionCallbacks: {
1414
+ dispatcher,
1415
+ authorizePredicate: (_ctx, _values, key, keyOwner) => key != null && keyOwner != null
1416
+ },
1417
+ ...errorHandlers
1418
+ });
1419
+ assertEquals(response.status, 401);
1420
+ assertEquals(onNotFoundCalled, null);
1421
+ assertEquals(onNotAcceptableCalled, null);
1422
+ assertEquals(onUnauthorizedCalled, context.request);
1423
+ onUnauthorizedCalled = null;
1424
+ context = createRequestContext({
1425
+ ...context,
1426
+ getSignedKey: () => Promise.resolve(rsaPublicKey2),
1427
+ getSignedKeyOwner: () => Promise.resolve(new Person({}))
1428
+ });
1429
+ response = await handleCustomCollection(context.request, {
1430
+ context,
1431
+ name: "custom collection",
1432
+ values: { handle: "someone" },
1433
+ collectionCallbacks: {
1434
+ dispatcher,
1435
+ authorizePredicate: (_ctx, _values, key, keyOwner) => key != null && keyOwner != null
1436
+ },
1437
+ ...errorHandlers
1438
+ });
1439
+ assertEquals(response.status, 200);
1440
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
1441
+ assertEquals(await response.json(), {
1442
+ "@context": CONTEXT,
1443
+ id: "https://example.com/",
1444
+ type: "Collection",
1445
+ items: [
1446
+ {
1447
+ "@context": createCtx,
1448
+ type: "Create",
1449
+ id: "https://example.com/activities/1"
1450
+ },
1451
+ {
1452
+ "@context": createCtx,
1453
+ type: "Create",
1454
+ id: "https://example.com/activities/2"
1455
+ },
1456
+ {
1457
+ "@context": createCtx,
1458
+ type: "Create",
1459
+ id: "https://example.com/activities/3"
1460
+ }
1461
+ ]
1462
+ });
1463
+ assertEquals(onNotFoundCalled, null);
1464
+ assertEquals(onNotAcceptableCalled, null);
1465
+ assertEquals(onUnauthorizedCalled, null);
1466
+ response = await handleCustomCollection(context.request, {
1467
+ context,
1468
+ name: "custom collection",
1469
+ values: { handle: "someone" },
1470
+ collectionCallbacks: callbacks,
1471
+ ...errorHandlers
1472
+ });
1473
+ assertEquals(response.status, 200);
1474
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
1475
+ assertEquals(await response.json(), {
1476
+ "@context": CONTEXT,
1477
+ id: "https://example.com/",
1478
+ type: "Collection",
1479
+ totalItems: 3,
1480
+ first: "https://example.com/?cursor=0",
1481
+ last: "https://example.com/?cursor=2"
1482
+ });
1483
+ assertEquals(onNotFoundCalled, null);
1484
+ assertEquals(onNotAcceptableCalled, null);
1485
+ assertEquals(onUnauthorizedCalled, null);
1486
+ let url = new URL("https://example.com/?cursor=0");
1487
+ context = createRequestContext({
1488
+ ...context,
1489
+ url,
1490
+ request: new Request(url, { headers: { Accept: "application/activity+json" } })
1491
+ });
1492
+ response = await handleCustomCollection(context.request, {
1493
+ context,
1494
+ name: "custom collection",
1495
+ values: { handle: "someone" },
1496
+ collectionCallbacks: callbacks,
1497
+ ...errorHandlers
1498
+ });
1499
+ assertEquals(response.status, 200);
1500
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
1501
+ assertEquals(await response.json(), {
1502
+ "@context": CONTEXT,
1503
+ id: "https://example.com/?cursor=0",
1504
+ type: "CollectionPage",
1505
+ partOf: "https://example.com/",
1506
+ next: "https://example.com/?cursor=1",
1507
+ items: {
1508
+ "@context": createCtx,
1509
+ id: "https://example.com/activities/1",
1510
+ type: "Create"
1511
+ }
1512
+ });
1513
+ assertEquals(onNotFoundCalled, null);
1514
+ assertEquals(onNotAcceptableCalled, null);
1515
+ assertEquals(onUnauthorizedCalled, null);
1516
+ url = new URL("https://example.com/?cursor=2");
1517
+ context = createRequestContext({
1518
+ ...context,
1519
+ url,
1520
+ request: new Request(url, { headers: { Accept: "application/activity+json" } })
1521
+ });
1522
+ response = await handleCustomCollection(context.request, {
1523
+ context,
1524
+ name: "custom collection",
1525
+ values: { handle: "someone" },
1526
+ collectionCallbacks: callbacks,
1527
+ ...errorHandlers
1528
+ });
1529
+ assertEquals(response.status, 200);
1530
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
1531
+ assertEquals(await response.json(), {
1532
+ "@context": CONTEXT,
1533
+ id: "https://example.com/?cursor=2",
1534
+ type: "CollectionPage",
1535
+ partOf: "https://example.com/",
1536
+ prev: "https://example.com/?cursor=1",
1537
+ items: {
1538
+ "@context": createCtx,
1539
+ id: "https://example.com/activities/3",
1540
+ type: "Create"
1541
+ }
1542
+ });
1543
+ assertEquals(onNotFoundCalled, null);
1544
+ assertEquals(onNotAcceptableCalled, null);
1545
+ assertEquals(onUnauthorizedCalled, null);
1546
+ });
1246
1547
 
1247
1548
  //#endregion
@@ -3,17 +3,13 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import { Activity, Create, Invite, Offer, Update } from "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
- import "../docloader-CJ7eOrpZ.js";
8
- import "../url-kTAI6_KP.js";
9
- import "../multibase-DeCHcK8L.js";
10
- import { Activity, Create, Invite, Offer, Update } from "../vocab-dw0HG0EQ.js";
11
- import "../langstr-DbWheeIS.js";
12
- import "../type-D2s5lmbZ.js";
13
- import { InboxListenerSet } from "../inbox-BB6ajp8P.js";
14
- import { test } from "../testing-BZ0dJ4qn.js";
15
- import "../assert_is_error-DQdKoRgb.js";
16
- import { assertThrows } from "../assert_throws-DTDC_gwN.js";
8
+ import "../lookup-BrKHd_gO.js";
9
+ import { InboxListenerSet } from "../inbox-C-5n8RpN.js";
10
+ import { test } from "../testing-Dv2RuzR3.js";
11
+ import "../assert_is_error-CeVBLPsZ.js";
12
+ import { assertThrows } from "../assert_throws-CqMKbTh_.js";
17
13
 
18
14
  //#region federation/inbox.test.ts
19
15
  test("InboxListenerSet", () => {
@@ -3,17 +3,14 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import { CryptographicKey, Multikey } from "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
8
  import { assert } from "../assert-DwEa6glZ.js";
8
9
  import { assertInstanceOf } from "../assert_instance_of-C9QtN-X9.js";
9
10
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
10
- import "../docloader-CJ7eOrpZ.js";
11
- import "../url-kTAI6_KP.js";
12
- import "../multibase-DeCHcK8L.js";
13
- import { CryptographicKey, Multikey } from "../vocab-dw0HG0EQ.js";
14
- import "../langstr-DbWheeIS.js";
15
- import { KvKeyCache } from "../keycache-C4C7f09E.js";
16
- import { test } from "../testing-BZ0dJ4qn.js";
11
+ import "../lookup-BrKHd_gO.js";
12
+ import { KvKeyCache } from "../keycache-DSOcI0ys.js";
13
+ import { test } from "../testing-Dv2RuzR3.js";
17
14
 
18
15
  //#region federation/keycache.test.ts
19
16
  test("KvKeyCache.set()", async () => {
@@ -3,16 +3,18 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
+ import "../type-BLj4c5rS.js";
6
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
7
8
  import "../assert-DwEa6glZ.js";
8
9
  import "../assert_instance_of-C9QtN-X9.js";
9
10
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
10
- import { test } from "../testing-BZ0dJ4qn.js";
11
- import "../std__assert-B3iAixc-.js";
12
- import "../assert_rejects-DceVjUlD.js";
13
- import "../assert_is_error-DQdKoRgb.js";
14
- import "../assert_not_equals-7pyUM3Ib.js";
15
- import "../assert_throws-DTDC_gwN.js";
11
+ import "../lookup-BrKHd_gO.js";
12
+ import { test } from "../testing-Dv2RuzR3.js";
13
+ import "../std__assert-BQdmxyzF.js";
14
+ import "../assert_rejects-AjlKk-Vo.js";
15
+ import "../assert_is_error-CeVBLPsZ.js";
16
+ import "../assert_not_equals-D2R2nl5h.js";
17
+ import "../assert_throws-CqMKbTh_.js";
16
18
 
17
19
  //#region federation/kv.test.ts
18
20
  test("MemoryKvStore", async (t) => {