@fedify/fedify 1.8.1-pr.315.1090 → 1.8.1-pr.318.1225
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/README.md +4 -1
- package/dist/{actor-BX-pKSuT.js → actor-C5n4A944.js} +1 -4
- package/dist/{actor-1rvS-py8.d.ts → actor-CWNAGvnO.d.ts} +2 -2
- package/dist/{actor-C02Getjh.js → actor-s5mQBwHr.js} +179 -179
- package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-AjlKk-Vo.js} +1 -1
- package/dist/{assert_throws-DTDC_gwN.js → assert_throws-CqMKbTh_.js} +1 -1
- package/dist/{authdocloader-BZs3nvC8.js → authdocloader-4RSyvLgz.js} +4 -5
- package/dist/{authdocloader-BbVFhkcz.js → authdocloader-CPaXUreA.js} +4 -4
- package/dist/{builder-DuW8p2S3.js → builder-CChGxW97.js} +74 -5
- package/dist/{client-BD0mI7gk.js → client-49mgdebk.js} +2 -2
- package/dist/{client-DK4qnXK0.d.ts → client-B0IOer6B.d.ts} +1 -1
- package/dist/compat/mod.d.ts +11 -11
- package/dist/compat/mod.js +1 -1
- package/dist/compat/transformers.test.js +20 -27
- package/dist/{context-BhO5LP_t.d.ts → context-BNA3vzcr.d.ts} +273 -60
- package/dist/{docloader-DtGccyuM.d.ts → docloader-CLolPVL_.d.ts} +2 -11
- package/dist/{docloader-umQd797n.js → docloader-DfooRmPz.js} +26 -13
- package/dist/{esm-d-9EVGaP.js → esm-3l5DpT9c.js} +1 -1
- package/dist/federation/builder.test.js +30 -16
- package/dist/federation/collection.test.js +9 -7
- package/dist/federation/handler.test.js +336 -35
- package/dist/federation/inbox.test.js +6 -10
- package/dist/federation/keycache.test.js +4 -7
- package/dist/federation/kv.test.js +8 -6
- package/dist/federation/middleware.test.js +58 -35
- package/dist/federation/mod.d.ts +11 -11
- package/dist/federation/mod.js +11 -11
- package/dist/federation/mq.test.js +10 -8
- package/dist/federation/retry.test.js +5 -3
- package/dist/federation/router.test.js +8 -7
- package/dist/federation/send.test.js +15 -21
- package/dist/{http-Cp-0z2Ja.d.ts → http-COez3YdK.d.ts} +4 -4
- package/dist/{http-CkS9JLmm.js → http-CsGPBDOo.js} +5 -4
- package/dist/{http-D59x3pzl.js → http-DyZD6UXI.js} +4 -4
- package/dist/{inbox-BjyNe-HL.js → inbox-DVl0Nqfm.js} +1 -3
- package/dist/{key-Btkh3AwY.js → key-CNNi5ktf.js} +3 -3
- package/dist/{key-jxin-rRq.js → key-CvnCx-As.js} +3 -4
- package/dist/{key-Cf8lNopw.js → key-MvqIkRnS.js} +4 -4
- package/dist/key-X4-XaJF1.js +10 -0
- package/dist/{keycache-BC5bL06g.js → keycache-BZR7b67J.js} +1 -1
- package/dist/{keys-Dfntfi5m.js → keys-CFFCiRYU.js} +1 -1
- package/dist/{kv-DDdb1hMa.d.ts → kv-BqOK6zss.d.ts} +1 -1
- package/dist/{ld-DwoZFwEd.js → ld-BDA3JCwf.js} +2 -4
- package/dist/{lookup-CAXRxPZ3.js → lookup-DcB1UuZA.js} +116 -10
- package/dist/{lookup-gQIU9tXW.js → lookup-mq8Ba5Kb.js} +2 -3
- package/dist/{lookup-m3U6KA0u.d.ts → lookup-tSXYzgYs.d.ts} +1 -7
- package/dist/{middleware-BOHju0mN.js → middleware-BKoKlIe8.js} +617 -12
- package/dist/middleware-CJiChbvg.js +26 -0
- package/dist/middleware-D6H2vPkH.js +17 -0
- package/dist/{middleware-cN6r9o1m.js → middleware-XOfMDFVl.js} +556 -25
- package/dist/{mod-yPzXIjJX.d.ts → mod-Bf-mThHd.d.ts} +4 -4
- package/dist/{mod-BqCBztub.d.ts → mod-C2jQirfr.d.ts} +2 -7
- package/dist/{mod-nlVEnYuj.d.ts → mod-CxD6XXBN.d.ts} +5 -5
- package/dist/{mod-c1I-Ydch.d.ts → mod-UTC30uNC.d.ts} +2 -2
- package/dist/mod.d.ts +14 -14
- package/dist/mod.js +11 -11
- package/dist/nodeinfo/client.test.js +11 -11
- package/dist/nodeinfo/handler.test.js +25 -34
- package/dist/nodeinfo/mod.d.ts +3 -3
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/semver.test.js +9 -7
- package/dist/nodeinfo/types.test.js +10 -8
- package/dist/{owner-BK4eWKBp.d.ts → owner-BlxMNrL4.d.ts} +3 -3
- package/dist/{owner-BrSLT3By.js → owner-D_-GBbn-.js} +2 -3
- package/dist/{proof-u4rhYX_R.js → proof-BnFHVB6H.js} +3 -5
- package/dist/{proof-BDYegzwN.js → proof-C94_doNG.js} +4 -4
- package/dist/runtime/authdocloader.test.js +14 -20
- package/dist/runtime/docloader.test.js +9 -10
- package/dist/runtime/key.test.js +10 -15
- package/dist/runtime/langstr.test.js +8 -7
- package/dist/runtime/mod.d.ts +5 -5
- package/dist/runtime/mod.js +6 -6
- package/dist/runtime/multibase/multibase.test.js +8 -7
- package/dist/runtime/url.test.js +5 -4
- package/dist/{send-DRDKgORs.js → send-DcuZAIY1.js} +2 -2
- package/dist/sig/http.test.js +36 -19
- package/dist/sig/key.test.js +11 -17
- package/dist/sig/ld.test.js +10 -16
- package/dist/sig/mod.d.ts +7 -7
- package/dist/sig/mod.js +6 -6
- package/dist/sig/owner.test.js +12 -19
- package/dist/sig/proof.test.js +12 -18
- package/dist/testing/docloader.test.js +8 -7
- package/dist/testing/mod.d.ts +8599 -1
- package/dist/testing/mod.js +4 -2
- package/dist/testing-C4oxyGxC.js +302 -0
- package/dist/{transformers-ghwJuzGY.js → transformers-DJRB0yFF.js} +3 -3
- package/dist/{vocab-C4cyrUaT.js → type-CFzYOYUt.js} +5255 -183
- package/dist/{types-D1lhruqy.js → types-Cr8o5d6d.js} +1 -1
- package/dist/{types-C7C_l-jz.js → types-n7HI7VFr.js} +1 -1
- package/dist/vocab/actor.test.js +10 -16
- package/dist/vocab/lookup.test.js +11 -86
- package/dist/vocab/mod.d.ts +5 -5
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +3 -7
- package/dist/vocab/vocab.test.js +9 -13
- package/dist/{vocab-BaWeqg9y.js → vocab-BwGxoM8R.js} +6 -7
- package/dist/{vocab-B52eQhpN.d.ts → vocab-Cyrb7_co.d.ts} +1 -1
- package/dist/webfinger/handler.test.js +25 -34
- package/dist/webfinger/lookup.test.js +9 -64
- package/dist/webfinger/mod.d.ts +3 -3
- package/dist/webfinger/mod.js +2 -2
- package/dist/x/cfworkers.d.ts +1 -1
- package/dist/x/cfworkers.test.js +8 -6
- package/dist/x/hono.d.ts +14 -14
- package/dist/x/hono.js +2 -2
- package/dist/x/sveltekit.d.ts +11 -11
- package/dist/x/sveltekit.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HsBuZ-b2.js +0 -41
- package/dist/context-V7yd31ov.js +0 -108
- package/dist/docloader-Bh-sDknx.js +0 -68
- package/dist/docloader-D5BOqs-9.js +0 -4514
- package/dist/key-DqZKjPjH.js +0 -16
- package/dist/langstr-DbWheeIS.js +0 -33
- package/dist/lookup-DvfZUKur.js +0 -133
- package/dist/middleware-31SyXabg.js +0 -33
- package/dist/middleware-CGl-YyTa.js +0 -17
- package/dist/multibase-DeCHcK8L.js +0 -316
- package/dist/router-D3UybECj.js +0 -118
- package/dist/testing-BZ0dJ4qn.js +0 -143
- package/dist/type-D2s5lmbZ.js +0 -14
- package/dist/url-kTAI6_KP.js +0 -68
- /package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-CeVBLPsZ.js} +0 -0
- /package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-D2R2nl5h.js} +0 -0
- /package/dist/{collection-Dfb0TPno.js → collection-D5V3UzU3.js} +0 -0
- /package/dist/{denokv-QWKsIqML.js → denokv-DK9P5Jq7.js} +0 -0
- /package/dist/{retry-BiIhZWgD.js → retry-BnpVRGFC.js} +0 -0
- /package/dist/{semver-DWClQt_5.js → semver-DCqorrj5.js} +0 -0
- /package/dist/{std__assert-B3iAixc-.js → std__assert-BQdmxyzF.js} +0 -0
|
@@ -10,7 +10,7 @@ import { isIP } from "node:net";
|
|
|
10
10
|
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "1.8.1-pr.
|
|
13
|
+
var version = "1.8.1-pr.318.1225+27a86736";
|
|
14
14
|
var license = "MIT";
|
|
15
15
|
var exports = {
|
|
16
16
|
".": "./mod.ts",
|
|
@@ -19,6 +19,7 @@ var exports = {
|
|
|
19
19
|
"./nodeinfo": "./nodeinfo/mod.ts",
|
|
20
20
|
"./runtime": "./runtime/mod.ts",
|
|
21
21
|
"./sig": "./sig/mod.ts",
|
|
22
|
+
"./testing": "./testing/mod.ts",
|
|
22
23
|
"./vocab": "./vocab/mod.ts",
|
|
23
24
|
"./webfinger": "./webfinger/mod.ts",
|
|
24
25
|
"./x/cfworkers": "./x/cfworkers.ts",
|
|
@@ -4464,8 +4465,7 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
4464
4465
|
* @since 1.3.0
|
|
4465
4466
|
*/
|
|
4466
4467
|
function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
|
|
4467
|
-
async function load(url
|
|
4468
|
-
if (_options?.signal?.aborted) throw new DOMException("Aborted", "AbortError");
|
|
4468
|
+
async function load(url) {
|
|
4469
4469
|
if (!skipPreloadedContexts && url in contexts_default) {
|
|
4470
4470
|
logger.debug("Using preloaded context: {url}.", { url });
|
|
4471
4471
|
return {
|
|
@@ -4485,22 +4485,35 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4485
4485
|
}
|
|
4486
4486
|
const request = createRequest(url, { userAgent });
|
|
4487
4487
|
logRequest(request);
|
|
4488
|
-
const response = await fetch(request, {
|
|
4489
|
-
|
|
4490
|
-
signal: _options?.signal
|
|
4491
|
-
});
|
|
4492
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return load(response.headers.get("Location"), _options);
|
|
4488
|
+
const response = await fetch(request, { redirect: "manual" });
|
|
4489
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return load(response.headers.get("Location"));
|
|
4493
4490
|
return getRemoteDocument(url, response, load);
|
|
4494
4491
|
}
|
|
4495
4492
|
return load;
|
|
4496
4493
|
}
|
|
4497
4494
|
const _fetchDocumentLoader = getDocumentLoader();
|
|
4498
4495
|
const _fetchDocumentLoader_allowPrivateAddress = getDocumentLoader({ allowPrivateAddress: true });
|
|
4499
|
-
|
|
4500
|
-
|
|
4496
|
+
/**
|
|
4497
|
+
* A JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4498
|
+
*
|
|
4499
|
+
* This loader preloads the below frequently used contexts:
|
|
4500
|
+
*
|
|
4501
|
+
* - <https://www.w3.org/ns/activitystreams>
|
|
4502
|
+
* - <https://w3id.org/security/v1>
|
|
4503
|
+
* - <https://w3id.org/security/data-integrity/v1>
|
|
4504
|
+
* - <https://www.w3.org/ns/did/v1>
|
|
4505
|
+
* - <https://w3id.org/security/multikey/v1>
|
|
4506
|
+
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4507
|
+
* - <http://schema.org/>
|
|
4508
|
+
* @param url The URL of the document to load.
|
|
4509
|
+
* @param allowPrivateAddress Whether to allow fetching private network
|
|
4510
|
+
* addresses. Turned off by default.
|
|
4511
|
+
* @returns The remote document.
|
|
4512
|
+
* @deprecated Use {@link getDocumentLoader} instead.
|
|
4513
|
+
*/
|
|
4514
|
+
function fetchDocumentLoader(url, allowPrivateAddress = false) {
|
|
4501
4515
|
logger.warn("fetchDocumentLoader() function is deprecated. Use getDocumentLoader() function instead.");
|
|
4502
|
-
|
|
4503
|
-
return loader(url);
|
|
4516
|
+
return (allowPrivateAddress ? _fetchDocumentLoader_allowPrivateAddress : _fetchDocumentLoader)(url);
|
|
4504
4517
|
}
|
|
4505
4518
|
/**
|
|
4506
4519
|
* Decorates a {@link DocumentLoader} with a cache backed by a {@link Deno.Kv}.
|
|
@@ -4525,7 +4538,7 @@ function kvCache({ loader, kv, prefix, rules }) {
|
|
|
4525
4538
|
}
|
|
4526
4539
|
return null;
|
|
4527
4540
|
}
|
|
4528
|
-
return async (url
|
|
4541
|
+
return async (url) => {
|
|
4529
4542
|
const match = matchRule(url);
|
|
4530
4543
|
if (match == null) return await loader(url);
|
|
4531
4544
|
const key = [...keyPrefix, url];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { __commonJS, __toESM } from "./
|
|
6
|
+
import { __commonJS, __toESM } from "./type-CFzYOYUt.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-CFzYOYUt.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 "../
|
|
11
|
-
import "../
|
|
12
|
-
import
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import {
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import "../
|
|
19
|
-
import {
|
|
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-DcB1UuZA.js";
|
|
13
|
+
import "../inbox-DVl0Nqfm.js";
|
|
14
|
+
import { createFederationBuilder } from "../builder-CChGxW97.js";
|
|
15
|
+
import { test } from "../testing-C4oxyGxC.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-CFzYOYUt.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
|
|
10
|
-
import {
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
10
|
+
import "../lookup-DcB1UuZA.js";
|
|
11
|
+
import { buildCollectionSynchronizationHeader, digest } from "../collection-D5V3UzU3.js";
|
|
12
|
+
import { test } from "../testing-C4oxyGxC.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-CFzYOYUt.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-
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import
|
|
19
|
-
import "../
|
|
20
|
-
import "../
|
|
21
|
-
import "../
|
|
22
|
-
import "../
|
|
23
|
-
import "../
|
|
24
|
-
import
|
|
25
|
-
import "../
|
|
26
|
-
import "../
|
|
27
|
-
import "../
|
|
28
|
-
import "../
|
|
29
|
-
import "../
|
|
30
|
-
import "../
|
|
31
|
-
import "../
|
|
32
|
-
import "../
|
|
33
|
-
import "../
|
|
34
|
-
import "../
|
|
35
|
-
import "../send-DRDKgORs.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-V7yd31ov.js";
|
|
44
|
-
import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-Dfntfi5m.js";
|
|
11
|
+
import { acceptsJsonLd, createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-XOfMDFVl.js";
|
|
12
|
+
import "../semver-DCqorrj5.js";
|
|
13
|
+
import "../client-49mgdebk.js";
|
|
14
|
+
import "../lookup-DcB1UuZA.js";
|
|
15
|
+
import "../types-n7HI7VFr.js";
|
|
16
|
+
import "../actor-C5n4A944.js";
|
|
17
|
+
import "../key-CvnCx-As.js";
|
|
18
|
+
import { signRequest } from "../http-DyZD6UXI.js";
|
|
19
|
+
import "../authdocloader-4RSyvLgz.js";
|
|
20
|
+
import "../ld-BDA3JCwf.js";
|
|
21
|
+
import "../owner-D_-GBbn-.js";
|
|
22
|
+
import "../proof-BnFHVB6H.js";
|
|
23
|
+
import "../inbox-DVl0Nqfm.js";
|
|
24
|
+
import "../builder-CChGxW97.js";
|
|
25
|
+
import "../collection-D5V3UzU3.js";
|
|
26
|
+
import "../keycache-BZR7b67J.js";
|
|
27
|
+
import "../retry-BnpVRGFC.js";
|
|
28
|
+
import "../send-DcuZAIY1.js";
|
|
29
|
+
import { createInboxContext, createRequestContext, mockDocumentLoader, test } from "../testing-C4oxyGxC.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-CFFCiRYU.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-CFzYOYUt.js";
|
|
6
7
|
import { assertEquals } from "../assert_equals-C5gKCm6A.js";
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import
|
|
11
|
-
import "../
|
|
12
|
-
import "../type-D2s5lmbZ.js";
|
|
13
|
-
import { InboxListenerSet } from "../inbox-BjyNe-HL.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-DcB1UuZA.js";
|
|
9
|
+
import { InboxListenerSet } from "../inbox-DVl0Nqfm.js";
|
|
10
|
+
import { test } from "../testing-C4oxyGxC.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-CFzYOYUt.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 "../
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import { CryptographicKey, Multikey } from "../vocab-C4cyrUaT.js";
|
|
14
|
-
import "../langstr-DbWheeIS.js";
|
|
15
|
-
import { KvKeyCache } from "../keycache-BC5bL06g.js";
|
|
16
|
-
import { test } from "../testing-BZ0dJ4qn.js";
|
|
11
|
+
import "../lookup-DcB1UuZA.js";
|
|
12
|
+
import { KvKeyCache } from "../keycache-BZR7b67J.js";
|
|
13
|
+
import { test } from "../testing-C4oxyGxC.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-CFzYOYUt.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
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
11
|
+
import "../lookup-DcB1UuZA.js";
|
|
12
|
+
import { test } from "../testing-C4oxyGxC.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) => {
|