@fedify/vocab 2.3.14 → 2.3.15
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/deno.json +1 -1
- package/dist/mod.cjs +289 -219
- package/dist/mod.d.cts +70 -0
- package/dist/mod.d.ts +70 -0
- package/dist/mod.js +289 -219
- package/dist-tests/{actor-CdnIo4XD.mjs → actor-pD1GaHgZ.mjs} +2 -2
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/lookup.test.mjs +34 -14
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-Cyuznh-0.mjs → vocab-DHuK2moR.mjs} +288 -218
- package/dist-tests/vocab.test.mjs +11 -3
- package/package.json +5 -5
- package/src/lookup.test.ts +37 -11
- package/src/vocab.test.ts +13 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as Question, C as Offer, D as Place, E as Person, F as Source, I as Tombstone, M as QuoteRequest, N as Reject, O as PropertyValue, S as Object$1, _ as InteractionPolicy, b as Measure, c as Create, d as Document, f as Endpoints, g as Intent, h as Hashtag, i as Announce, j as QuoteAuthorization, k as Proposal, l as CryptographicKey, n as Activity, o as Collection, p as Follow, r as Agreement, s as Commitment, t as Accept, u as Delete, v as InteractionRule, w as OrderedCollectionPage, x as Note, y as Link, z as vocab_exports } from "./vocab-
|
|
3
|
+
import { A as Question, C as Offer, D as Place, E as Person, F as Source, I as Tombstone, M as QuoteRequest, N as Reject, O as PropertyValue, S as Object$1, _ as InteractionPolicy, b as Measure, c as Create, d as Document, f as Endpoints, g as Intent, h as Hashtag, i as Announce, j as QuoteAuthorization, k as Proposal, l as CryptographicKey, n as Activity, o as Collection, p as Follow, r as Agreement, s as Commitment, t as Accept, u as Delete, v as InteractionRule, w as OrderedCollectionPage, x as Note, y as Link, z as vocab_exports } from "./vocab-DHuK2moR.mjs";
|
|
4
4
|
import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
|
|
5
5
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual, notDeepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
@@ -424,7 +424,11 @@ test({
|
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
});
|
|
427
|
-
deepStrictEqual(await new Activity({ object: new URL("https://example.com/not-found") }).getObject({
|
|
427
|
+
deepStrictEqual(await new Activity({ object: new URL("https://example.com/not-found") }).getObject({
|
|
428
|
+
documentLoader: mockDocumentLoader,
|
|
429
|
+
contextLoader: mockDocumentLoader,
|
|
430
|
+
suppressError: true
|
|
431
|
+
}), null);
|
|
428
432
|
const object3 = await (await Activity.fromJsonLd({
|
|
429
433
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
430
434
|
type: "Create",
|
|
@@ -461,7 +465,11 @@ test({
|
|
|
461
465
|
assertInstanceOf(objects[1], Object$1);
|
|
462
466
|
deepStrictEqual(objects[1].name, "Second object");
|
|
463
467
|
const activity2 = new Activity({ objects: [new URL("https://example.com/not-found"), new Object$1({ name: "Second object" })] });
|
|
464
|
-
const objects2 = await Array.fromAsync(activity2.getObjects({
|
|
468
|
+
const objects2 = await Array.fromAsync(activity2.getObjects({
|
|
469
|
+
documentLoader: mockDocumentLoader,
|
|
470
|
+
contextLoader: mockDocumentLoader,
|
|
471
|
+
suppressError: true
|
|
472
|
+
}));
|
|
465
473
|
deepStrictEqual(objects2.length, 1);
|
|
466
474
|
assertInstanceOf(objects2[0], Object$1);
|
|
467
475
|
deepStrictEqual(objects2[0].name, "Second object");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.15",
|
|
4
4
|
"homepage": "https://fedify.dev/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@js-temporal/polyfill": "^0.5.1",
|
|
42
42
|
"@multiformats/base-x": "^4.0.1",
|
|
43
43
|
"@logtape/logtape": "^2.2.0",
|
|
44
|
-
"@opentelemetry/api": "
|
|
44
|
+
"@opentelemetry/api": "~1.9.1",
|
|
45
45
|
"asn1js": "^3.0.10",
|
|
46
46
|
"es-toolkit": "1.46.1",
|
|
47
47
|
"jsonld": "^9.0.0",
|
|
48
48
|
"pkijs": "^3.3.3",
|
|
49
|
-
"@fedify/vocab-
|
|
50
|
-
"@fedify/vocab-
|
|
51
|
-
"@fedify/webfinger": "2.3.
|
|
49
|
+
"@fedify/vocab-runtime": "2.3.15",
|
|
50
|
+
"@fedify/vocab-tools": "2.3.15",
|
|
51
|
+
"@fedify/webfinger": "2.3.15"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.17.0",
|
package/src/lookup.test.ts
CHANGED
|
@@ -10,10 +10,17 @@ import { lookupObject, traverseCollection } from "./lookup.ts";
|
|
|
10
10
|
import { assertInstanceOf } from "./utils.ts";
|
|
11
11
|
import { Collection, Note, Object, Person } from "./vocab.ts";
|
|
12
12
|
|
|
13
|
+
// lookupObject() accepts this option without declaring it, since Fedify's
|
|
14
|
+
// Context passes it. It makes WebFinger lookups use the global fetch()
|
|
15
|
+
// (fetch-mock here) without resolving hostnames, so that the tests do not
|
|
16
|
+
// depend on the real DNS:
|
|
17
|
+
const allowPrivateAddress = { allowPrivateAddress: true };
|
|
18
|
+
|
|
13
19
|
test("lookupObject()", {
|
|
14
20
|
sanitizeResources: false,
|
|
15
21
|
sanitizeOps: false,
|
|
16
22
|
}, async (t) => {
|
|
23
|
+
const responseTimers: ReturnType<typeof setTimeout>[] = [];
|
|
17
24
|
fetchMock.spyGlobal();
|
|
18
25
|
|
|
19
26
|
fetchMock.get(
|
|
@@ -43,6 +50,7 @@ test("lookupObject()", {
|
|
|
43
50
|
const options = {
|
|
44
51
|
documentLoader: mockDocumentLoader,
|
|
45
52
|
contextLoader: mockDocumentLoader,
|
|
53
|
+
...allowPrivateAddress,
|
|
46
54
|
};
|
|
47
55
|
|
|
48
56
|
await t.step("actor", async () => {
|
|
@@ -106,7 +114,7 @@ test("lookupObject()", {
|
|
|
106
114
|
"begin:https://example.com/.well-known/webfinger",
|
|
107
115
|
() =>
|
|
108
116
|
new Promise((resolve) => {
|
|
109
|
-
setTimeout(() => {
|
|
117
|
+
responseTimers.push(setTimeout(() => {
|
|
110
118
|
resolve({
|
|
111
119
|
subject: "acct:johndoe@example.com",
|
|
112
120
|
links: [
|
|
@@ -117,7 +125,7 @@ test("lookupObject()", {
|
|
|
117
125
|
},
|
|
118
126
|
],
|
|
119
127
|
});
|
|
120
|
-
}, 1000);
|
|
128
|
+
}, 1000));
|
|
121
129
|
}),
|
|
122
130
|
);
|
|
123
131
|
|
|
@@ -162,7 +170,7 @@ test("lookupObject()", {
|
|
|
162
170
|
"begin:https://example.com/.well-known/webfinger",
|
|
163
171
|
() =>
|
|
164
172
|
new Promise((resolve) => {
|
|
165
|
-
setTimeout(() => {
|
|
173
|
+
responseTimers.push(setTimeout(() => {
|
|
166
174
|
resolve({
|
|
167
175
|
subject: "acct:johndoe@example.com",
|
|
168
176
|
links: [
|
|
@@ -173,7 +181,7 @@ test("lookupObject()", {
|
|
|
173
181
|
},
|
|
174
182
|
],
|
|
175
183
|
});
|
|
176
|
-
}, 500);
|
|
184
|
+
}, 500));
|
|
177
185
|
}),
|
|
178
186
|
);
|
|
179
187
|
|
|
@@ -193,7 +201,7 @@ test("lookupObject()", {
|
|
|
193
201
|
"https://example.com/slow-object",
|
|
194
202
|
() =>
|
|
195
203
|
new Promise((resolve) => {
|
|
196
|
-
setTimeout(() => {
|
|
204
|
+
responseTimers.push(setTimeout(() => {
|
|
197
205
|
resolve({
|
|
198
206
|
status: 200,
|
|
199
207
|
headers: { "Content-Type": "application/activity+json" },
|
|
@@ -203,7 +211,7 @@ test("lookupObject()", {
|
|
|
203
211
|
content: "Slow response",
|
|
204
212
|
},
|
|
205
213
|
});
|
|
206
|
-
}, 1000);
|
|
214
|
+
}, 1000));
|
|
207
215
|
}),
|
|
208
216
|
);
|
|
209
217
|
|
|
@@ -218,6 +226,7 @@ test("lookupObject()", {
|
|
|
218
226
|
deepStrictEqual(await promise, null);
|
|
219
227
|
});
|
|
220
228
|
|
|
229
|
+
for (const timer of responseTimers) clearTimeout(timer);
|
|
221
230
|
fetchMock.hardReset();
|
|
222
231
|
fetchMock.removeRoutes();
|
|
223
232
|
});
|
|
@@ -480,6 +489,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
480
489
|
|
|
481
490
|
// Default behavior should return null
|
|
482
491
|
const result1 = await lookupObject("@user@example.com", {
|
|
492
|
+
...allowPrivateAddress,
|
|
483
493
|
documentLoader: webfingerDocumentLoader,
|
|
484
494
|
contextLoader: mockDocumentLoader,
|
|
485
495
|
});
|
|
@@ -489,6 +499,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
489
499
|
await rejects(
|
|
490
500
|
() =>
|
|
491
501
|
lookupObject("@user@example.com", {
|
|
502
|
+
...allowPrivateAddress,
|
|
492
503
|
documentLoader: webfingerDocumentLoader,
|
|
493
504
|
contextLoader: mockDocumentLoader,
|
|
494
505
|
crossOrigin: "throw",
|
|
@@ -499,6 +510,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
499
510
|
|
|
500
511
|
// With crossOrigin: trust, should return the object
|
|
501
512
|
const result2 = await lookupObject("@user@example.com", {
|
|
513
|
+
...allowPrivateAddress,
|
|
502
514
|
documentLoader: webfingerDocumentLoader,
|
|
503
515
|
contextLoader: mockDocumentLoader,
|
|
504
516
|
crossOrigin: "trust",
|
|
@@ -598,12 +610,22 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
598
610
|
throw new Error("Network error");
|
|
599
611
|
};
|
|
600
612
|
|
|
613
|
+
// The WebFinger fallback must not reach the network:
|
|
614
|
+
fetchMock.spyGlobal();
|
|
615
|
+
fetchMock.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
616
|
+
|
|
601
617
|
// Network errors should not be confused with cross-origin errors
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
618
|
+
let result;
|
|
619
|
+
try {
|
|
620
|
+
result = await lookupObject("https://example.com/note", {
|
|
621
|
+
...allowPrivateAddress,
|
|
622
|
+
documentLoader: errorDocumentLoader,
|
|
623
|
+
contextLoader: mockDocumentLoader,
|
|
624
|
+
crossOrigin: "throw",
|
|
625
|
+
});
|
|
626
|
+
} finally {
|
|
627
|
+
fetchMock.hardReset();
|
|
628
|
+
}
|
|
607
629
|
|
|
608
630
|
// Should return null because the document loader failed,
|
|
609
631
|
// not because of cross-origin policy
|
|
@@ -721,6 +743,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
721
743
|
await t.step("records kind=actor for an actor result", async () => {
|
|
722
744
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
723
745
|
const person = await lookupObject("@johndoe@example.com", {
|
|
746
|
+
...allowPrivateAddress,
|
|
724
747
|
documentLoader: mockDocumentLoader,
|
|
725
748
|
contextLoader: mockDocumentLoader,
|
|
726
749
|
meterProvider,
|
|
@@ -807,6 +830,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
807
830
|
});
|
|
808
831
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
809
832
|
const result = await lookupObject("janedoe@example.com", {
|
|
833
|
+
...allowPrivateAddress,
|
|
810
834
|
documentLoader: mockDocumentLoader,
|
|
811
835
|
contextLoader: mockDocumentLoader,
|
|
812
836
|
meterProvider,
|
|
@@ -858,6 +882,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
858
882
|
);
|
|
859
883
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
860
884
|
await lookupObject("@johndoe@example.com", {
|
|
885
|
+
...allowPrivateAddress,
|
|
861
886
|
documentLoader: mockDocumentLoader,
|
|
862
887
|
contextLoader: mockDocumentLoader,
|
|
863
888
|
meterProvider,
|
|
@@ -891,6 +916,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
891
916
|
});
|
|
892
917
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
893
918
|
await lookupObject(new URL("acct:johndoe@example.com"), {
|
|
919
|
+
...allowPrivateAddress,
|
|
894
920
|
documentLoader: mockDocumentLoader,
|
|
895
921
|
contextLoader: mockDocumentLoader,
|
|
896
922
|
meterProvider,
|
package/src/vocab.test.ts
CHANGED
|
@@ -631,7 +631,14 @@ test({
|
|
|
631
631
|
const activity2 = new Activity({
|
|
632
632
|
object: new URL("https://example.com/not-found"),
|
|
633
633
|
});
|
|
634
|
-
deepStrictEqual(
|
|
634
|
+
deepStrictEqual(
|
|
635
|
+
await activity2.getObject({
|
|
636
|
+
documentLoader: mockDocumentLoader,
|
|
637
|
+
contextLoader: mockDocumentLoader,
|
|
638
|
+
suppressError: true,
|
|
639
|
+
}),
|
|
640
|
+
null,
|
|
641
|
+
);
|
|
635
642
|
|
|
636
643
|
const activity3 = await Activity.fromJsonLd({
|
|
637
644
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
@@ -686,7 +693,11 @@ test({
|
|
|
686
693
|
],
|
|
687
694
|
});
|
|
688
695
|
const objects2 = await Array.fromAsync(
|
|
689
|
-
activity2.getObjects({
|
|
696
|
+
activity2.getObjects({
|
|
697
|
+
documentLoader: mockDocumentLoader,
|
|
698
|
+
contextLoader: mockDocumentLoader,
|
|
699
|
+
suppressError: true,
|
|
700
|
+
}),
|
|
690
701
|
);
|
|
691
702
|
deepStrictEqual(objects2.length, 1);
|
|
692
703
|
assertInstanceOf(objects2[0], Object);
|