@fedify/vocab 2.4.5-dev.2462 → 2.4.5
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 +80 -3
- package/dist/mod.d.cts +75 -0
- package/dist/mod.d.ts +75 -0
- package/dist/mod.js +80 -3
- package/dist-tests/{actor-C2nY5FCY.mjs → actor-BWv7I2WQ.mjs} +6 -4
- package/dist-tests/actor.test.mjs +4 -3
- package/dist-tests/{esm-B55wgjAT.mjs → esm-BIqRhjGA.mjs} +1 -1
- package/dist-tests/gateway.test.mjs +4 -4
- package/dist-tests/{lookup-CeKwbSpe.mjs → lookup---G_JdKW.mjs} +2 -2
- package/dist-tests/lookup.test.mjs +35 -15
- package/dist-tests/portable-lookup.test.mjs +52 -13
- package/dist-tests/rolldown-runtime-BWJg4WE8.mjs +37 -0
- package/dist-tests/signed-representation.test.mjs +1 -1
- package/dist-tests/translation.test.mjs +3 -3
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/undici-D88PC0XH.mjs +22898 -0
- package/dist-tests/{vocab-mc4pgfni.mjs → vocab-S9K4rFgH.mjs} +77 -34
- package/dist-tests/vocab.test.mjs +6064 -8
- package/package.json +5 -5
- package/src/actor.ts +4 -0
- package/src/gateway.test.ts +1 -1
- package/src/lookup.test.ts +37 -11
- package/src/portable-lookup.test.ts +72 -7
- package/src/vocab.test.ts +40 -5
package/dist/mod.js
CHANGED
|
@@ -12,7 +12,7 @@ import { isTemporalDuration, isTemporalInstant } from "@fedify/vocab-runtime/tem
|
|
|
12
12
|
import { delay } from "es-toolkit";
|
|
13
13
|
//#region deno.json
|
|
14
14
|
var name = "@fedify/vocab";
|
|
15
|
-
var version = "2.4.5
|
|
15
|
+
var version = "2.4.5";
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/type.ts
|
|
18
18
|
function getTypeId(object) {
|
|
@@ -328,6 +328,11 @@ var Object$1 = class Object$1 {
|
|
|
328
328
|
get _warning() {
|
|
329
329
|
return this.#warning;
|
|
330
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
333
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
334
|
+
* accessor name and its getter/setter semantics stable.
|
|
335
|
+
*/
|
|
331
336
|
get _cachedJsonLd() {
|
|
332
337
|
return this.#cachedJsonLd;
|
|
333
338
|
}
|
|
@@ -13922,6 +13927,11 @@ var PropertyValue = class {
|
|
|
13922
13927
|
get _warning() {
|
|
13923
13928
|
return this.#warning;
|
|
13924
13929
|
}
|
|
13930
|
+
/**
|
|
13931
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
13932
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
13933
|
+
* accessor name and its getter/setter semantics stable.
|
|
13934
|
+
*/
|
|
13925
13935
|
get _cachedJsonLd() {
|
|
13926
13936
|
return this.#cachedJsonLd;
|
|
13927
13937
|
}
|
|
@@ -14294,6 +14304,11 @@ var Measure = class {
|
|
|
14294
14304
|
get _warning() {
|
|
14295
14305
|
return this.#warning;
|
|
14296
14306
|
}
|
|
14307
|
+
/**
|
|
14308
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
14309
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
14310
|
+
* accessor name and its getter/setter semantics stable.
|
|
14311
|
+
*/
|
|
14297
14312
|
get _cachedJsonLd() {
|
|
14298
14313
|
return this.#cachedJsonLd;
|
|
14299
14314
|
}
|
|
@@ -15677,6 +15692,11 @@ var InteractionPolicy = class {
|
|
|
15677
15692
|
get _warning() {
|
|
15678
15693
|
return this.#warning;
|
|
15679
15694
|
}
|
|
15695
|
+
/**
|
|
15696
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
15697
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
15698
|
+
* accessor name and its getter/setter semantics stable.
|
|
15699
|
+
*/
|
|
15680
15700
|
get _cachedJsonLd() {
|
|
15681
15701
|
return this.#cachedJsonLd;
|
|
15682
15702
|
}
|
|
@@ -16185,6 +16205,11 @@ var InteractionRule = class {
|
|
|
16185
16205
|
get _warning() {
|
|
16186
16206
|
return this.#warning;
|
|
16187
16207
|
}
|
|
16208
|
+
/**
|
|
16209
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
16210
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
16211
|
+
* accessor name and its getter/setter semantics stable.
|
|
16212
|
+
*/
|
|
16188
16213
|
get _cachedJsonLd() {
|
|
16189
16214
|
return this.#cachedJsonLd;
|
|
16190
16215
|
}
|
|
@@ -19626,6 +19651,11 @@ var Translation = class {
|
|
|
19626
19651
|
get _warning() {
|
|
19627
19652
|
return this.#warning;
|
|
19628
19653
|
}
|
|
19654
|
+
/**
|
|
19655
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
19656
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
19657
|
+
* accessor name and its getter/setter semantics stable.
|
|
19658
|
+
*/
|
|
19629
19659
|
get _cachedJsonLd() {
|
|
19630
19660
|
return this.#cachedJsonLd;
|
|
19631
19661
|
}
|
|
@@ -27276,6 +27306,11 @@ var DidService = class {
|
|
|
27276
27306
|
get _warning() {
|
|
27277
27307
|
return this.#warning;
|
|
27278
27308
|
}
|
|
27309
|
+
/**
|
|
27310
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
27311
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
27312
|
+
* accessor name and its getter/setter semantics stable.
|
|
27313
|
+
*/
|
|
27279
27314
|
get _cachedJsonLd() {
|
|
27280
27315
|
return this.#cachedJsonLd;
|
|
27281
27316
|
}
|
|
@@ -27782,6 +27817,11 @@ var DataIntegrityProof = class {
|
|
|
27782
27817
|
get _warning() {
|
|
27783
27818
|
return this.#warning;
|
|
27784
27819
|
}
|
|
27820
|
+
/**
|
|
27821
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
27822
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
27823
|
+
* accessor name and its getter/setter semantics stable.
|
|
27824
|
+
*/
|
|
27785
27825
|
get _cachedJsonLd() {
|
|
27786
27826
|
return this.#cachedJsonLd;
|
|
27787
27827
|
}
|
|
@@ -28468,6 +28508,11 @@ var CryptographicKey = class {
|
|
|
28468
28508
|
get _warning() {
|
|
28469
28509
|
return this.#warning;
|
|
28470
28510
|
}
|
|
28511
|
+
/**
|
|
28512
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
28513
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
28514
|
+
* accessor name and its getter/setter semantics stable.
|
|
28515
|
+
*/
|
|
28471
28516
|
get _cachedJsonLd() {
|
|
28472
28517
|
return this.#cachedJsonLd;
|
|
28473
28518
|
}
|
|
@@ -29135,6 +29180,11 @@ var Multikey = class {
|
|
|
29135
29180
|
get _warning() {
|
|
29136
29181
|
return this.#warning;
|
|
29137
29182
|
}
|
|
29183
|
+
/**
|
|
29184
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
29185
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
29186
|
+
* accessor name and its getter/setter semantics stable.
|
|
29187
|
+
*/
|
|
29138
29188
|
get _cachedJsonLd() {
|
|
29139
29189
|
return this.#cachedJsonLd;
|
|
29140
29190
|
}
|
|
@@ -30197,6 +30247,11 @@ var Commitment = class {
|
|
|
30197
30247
|
get _warning() {
|
|
30198
30248
|
return this.#warning;
|
|
30199
30249
|
}
|
|
30250
|
+
/**
|
|
30251
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
30252
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
30253
|
+
* accessor name and its getter/setter semantics stable.
|
|
30254
|
+
*/
|
|
30200
30255
|
get _cachedJsonLd() {
|
|
30201
30256
|
return this.#cachedJsonLd;
|
|
30202
30257
|
}
|
|
@@ -30583,6 +30638,11 @@ var Intent = class {
|
|
|
30583
30638
|
get _warning() {
|
|
30584
30639
|
return this.#warning;
|
|
30585
30640
|
}
|
|
30641
|
+
/**
|
|
30642
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
30643
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
30644
|
+
* accessor name and its getter/setter semantics stable.
|
|
30645
|
+
*/
|
|
30586
30646
|
get _cachedJsonLd() {
|
|
30587
30647
|
return this.#cachedJsonLd;
|
|
30588
30648
|
}
|
|
@@ -41868,6 +41928,11 @@ var Endpoints = class {
|
|
|
41868
41928
|
get _warning() {
|
|
41869
41929
|
return this.#warning;
|
|
41870
41930
|
}
|
|
41931
|
+
/**
|
|
41932
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
41933
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
41934
|
+
* accessor name and its getter/setter semantics stable.
|
|
41935
|
+
*/
|
|
41871
41936
|
get _cachedJsonLd() {
|
|
41872
41937
|
return this.#cachedJsonLd;
|
|
41873
41938
|
}
|
|
@@ -48570,6 +48635,11 @@ var Link = class Link {
|
|
|
48570
48635
|
get _warning() {
|
|
48571
48636
|
return this.#warning;
|
|
48572
48637
|
}
|
|
48638
|
+
/**
|
|
48639
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
48640
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
48641
|
+
* accessor name and its getter/setter semantics stable.
|
|
48642
|
+
*/
|
|
48573
48643
|
get _cachedJsonLd() {
|
|
48574
48644
|
return this.#cachedJsonLd;
|
|
48575
48645
|
}
|
|
@@ -74348,6 +74418,11 @@ var Source = class {
|
|
|
74348
74418
|
get _warning() {
|
|
74349
74419
|
return this.#warning;
|
|
74350
74420
|
}
|
|
74421
|
+
/**
|
|
74422
|
+
* Internal cross-package contract with @fedify/testing, which copies this
|
|
74423
|
+
* cache when attaching document loaders to an activity clone. Keep this
|
|
74424
|
+
* accessor name and its getter/setter semantics stable.
|
|
74425
|
+
*/
|
|
74351
74426
|
get _cachedJsonLd() {
|
|
74352
74427
|
return this.#cachedJsonLd;
|
|
74353
74428
|
}
|
|
@@ -76935,7 +77010,8 @@ async function getPortableActorHandle(actor, actorId, options) {
|
|
|
76935
77010
|
const result = await lookupWebFinger(handle, {
|
|
76936
77011
|
userAgent: options.userAgent,
|
|
76937
77012
|
tracerProvider: options.tracerProvider,
|
|
76938
|
-
meterProvider: options.meterProvider
|
|
77013
|
+
meterProvider: options.meterProvider,
|
|
77014
|
+
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true
|
|
76939
77015
|
});
|
|
76940
77016
|
if (result == null || !linksToPortableActor(result, canonicalId)) throw new ActorHandleNotFoundError();
|
|
76941
77017
|
const subject = result.subject?.match(/^acct:([^@]+)@([^@]+)$/);
|
|
@@ -76943,7 +77019,8 @@ async function getPortableActorHandle(actor, actorId, options) {
|
|
|
76943
77019
|
const subjectResult = await lookupWebFinger(result.subject, {
|
|
76944
77020
|
userAgent: options.userAgent,
|
|
76945
77021
|
tracerProvider: options.tracerProvider,
|
|
76946
|
-
meterProvider: options.meterProvider
|
|
77022
|
+
meterProvider: options.meterProvider,
|
|
77023
|
+
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true
|
|
76947
77024
|
});
|
|
76948
77025
|
if (subjectResult != null && linksToPortableActor(subjectResult, canonicalId)) return normalizeActorHandle(`@${subject[1]}@${subject[2]}`, options);
|
|
76949
77026
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-mc4pgfni.mjs";
|
|
4
3
|
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
4
|
+
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-S9K4rFgH.mjs";
|
|
5
5
|
import { canonicalizePortableUri, formatIri, fromCompatibleEf61Id, isGatewayUrl } from "@fedify/vocab-runtime";
|
|
6
6
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
7
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { domainToASCII, domainToUnicode } from "node:url";
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab";
|
|
11
|
-
var version = "2.4.5
|
|
11
|
+
var version = "2.4.5";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/actor.ts
|
|
14
14
|
const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
|
|
@@ -206,7 +206,8 @@ async function getPortableActorHandle(actor, actorId, options) {
|
|
|
206
206
|
const result = await lookupWebFinger(handle, {
|
|
207
207
|
userAgent: options.userAgent,
|
|
208
208
|
tracerProvider: options.tracerProvider,
|
|
209
|
-
meterProvider: options.meterProvider
|
|
209
|
+
meterProvider: options.meterProvider,
|
|
210
|
+
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true
|
|
210
211
|
});
|
|
211
212
|
if (result == null || !linksToPortableActor(result, canonicalId)) throw new ActorHandleNotFoundError();
|
|
212
213
|
const subject = result.subject?.match(/^acct:([^@]+)@([^@]+)$/);
|
|
@@ -214,7 +215,8 @@ async function getPortableActorHandle(actor, actorId, options) {
|
|
|
214
215
|
const subjectResult = await lookupWebFinger(result.subject, {
|
|
215
216
|
userAgent: options.userAgent,
|
|
216
217
|
tracerProvider: options.tracerProvider,
|
|
217
|
-
meterProvider: options.meterProvider
|
|
218
|
+
meterProvider: options.meterProvider,
|
|
219
|
+
allowPrivateAddress: "allowPrivateAddress" in options && options.allowPrivateAddress === true
|
|
218
220
|
});
|
|
219
221
|
if (subjectResult != null && linksToPortableActor(subjectResult, canonicalId)) return normalizeActorHandle(`@${subject[1]}@${subject[2]}`, options);
|
|
220
222
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
4
|
-
import { t as esm_default } from "./esm-
|
|
5
|
-
import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-
|
|
3
|
+
import { n as __exportAll } from "./rolldown-runtime-BWJg4WE8.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-BIqRhjGA.mjs";
|
|
5
|
+
import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-BWv7I2WQ.mjs";
|
|
6
|
+
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-S9K4rFgH.mjs";
|
|
6
7
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
7
8
|
import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
8
9
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
3
|
+
import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-BWJg4WE8.mjs";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
6
6
|
var import_glob_to_regexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as traverseCollection, t as lookupObject } from "./lookup
|
|
3
|
+
import { t as esm_default } from "./esm-BIqRhjGA.mjs";
|
|
4
|
+
import { F as Person, M as OrderedCollection, S as Image, c as CollectionPage, k as Note, s as Collection, u as Create } from "./vocab-S9K4rFgH.mjs";
|
|
5
|
+
import { n as traverseCollection, t as lookupObject } from "./lookup---G_JdKW.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "./utils-Df2odC27.mjs";
|
|
7
7
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
8
8
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
@@ -597,7 +597,7 @@ test("getObject() sends the ActivityStreams Accept header to gateways", {
|
|
|
597
597
|
});
|
|
598
598
|
try {
|
|
599
599
|
assertInstanceOf(await (await createActivity()).getObject({
|
|
600
|
-
documentLoader: getDocumentLoader(),
|
|
600
|
+
documentLoader: getDocumentLoader({ allowPrivateAddress: true }),
|
|
601
601
|
contextLoader: mockDocumentLoader,
|
|
602
602
|
gateways: ["https://example.com"],
|
|
603
603
|
verifyPortableObject: createVerifier()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
4
|
-
import { i as isActor, o as name, s as version } from "./actor-C2nY5FCY.mjs";
|
|
3
|
+
import { i as isActor, o as name, s as version } from "./actor-BWv7I2WQ.mjs";
|
|
5
4
|
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
5
|
+
import { A as Object$1 } from "./vocab-S9K4rFgH.mjs";
|
|
6
6
|
import { canonicalizePortableUri, formatIri, getDocumentLoader, haveSameFe34Origin, haveSameIriOrigin, parseIri } from "@fedify/vocab-runtime";
|
|
7
7
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
8
8
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as traverseCollection, t as lookupObject } from "./lookup
|
|
3
|
+
import { t as esm_default } from "./esm-BIqRhjGA.mjs";
|
|
4
|
+
import { A as Object$1, F as Person, k as Note, s as Collection } from "./vocab-S9K4rFgH.mjs";
|
|
5
|
+
import { n as traverseCollection, t as lookupObject } from "./lookup---G_JdKW.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "./utils-Df2odC27.mjs";
|
|
7
7
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
8
8
|
import { deepStrictEqual, equal, ok, rejects } from "node:assert/strict";
|
|
9
9
|
//#region src/lookup.test.ts
|
|
10
|
+
const allowPrivateAddress = { allowPrivateAddress: true };
|
|
10
11
|
test("lookupObject()", {
|
|
11
12
|
sanitizeResources: false,
|
|
12
13
|
sanitizeOps: false
|
|
13
14
|
}, async (t) => {
|
|
15
|
+
const responseTimers = [];
|
|
14
16
|
esm_default.spyGlobal();
|
|
15
17
|
esm_default.get("begin:https://example.com/.well-known/webfinger", {
|
|
16
18
|
subject: "acct:johndoe@example.com",
|
|
@@ -34,7 +36,8 @@ test("lookupObject()", {
|
|
|
34
36
|
});
|
|
35
37
|
const options = {
|
|
36
38
|
documentLoader: mockDocumentLoader,
|
|
37
|
-
contextLoader: mockDocumentLoader
|
|
39
|
+
contextLoader: mockDocumentLoader,
|
|
40
|
+
...allowPrivateAddress
|
|
38
41
|
};
|
|
39
42
|
await t.step("actor", async () => {
|
|
40
43
|
const person = await lookupObject("@johndoe@example.com", options);
|
|
@@ -73,7 +76,7 @@ test("lookupObject()", {
|
|
|
73
76
|
});
|
|
74
77
|
esm_default.removeRoutes({ includeFallback: false });
|
|
75
78
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
76
|
-
setTimeout(() => {
|
|
79
|
+
responseTimers.push(setTimeout(() => {
|
|
77
80
|
resolve({
|
|
78
81
|
subject: "acct:johndoe@example.com",
|
|
79
82
|
links: [{
|
|
@@ -82,7 +85,7 @@ test("lookupObject()", {
|
|
|
82
85
|
type: "application/activity+json"
|
|
83
86
|
}]
|
|
84
87
|
});
|
|
85
|
-
}, 1e3);
|
|
88
|
+
}, 1e3));
|
|
86
89
|
}));
|
|
87
90
|
await t.step("request cancellation", async () => {
|
|
88
91
|
const controller = new AbortController();
|
|
@@ -113,7 +116,7 @@ test("lookupObject()", {
|
|
|
113
116
|
});
|
|
114
117
|
esm_default.removeRoutes({ includeFallback: false });
|
|
115
118
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
116
|
-
setTimeout(() => {
|
|
119
|
+
responseTimers.push(setTimeout(() => {
|
|
117
120
|
resolve({
|
|
118
121
|
subject: "acct:johndoe@example.com",
|
|
119
122
|
links: [{
|
|
@@ -122,7 +125,7 @@ test("lookupObject()", {
|
|
|
122
125
|
type: "application/activity+json"
|
|
123
126
|
}]
|
|
124
127
|
});
|
|
125
|
-
}, 500);
|
|
128
|
+
}, 500));
|
|
126
129
|
}));
|
|
127
130
|
await t.step("cancellation with immediate abort", async () => {
|
|
128
131
|
const controller = new AbortController();
|
|
@@ -134,7 +137,7 @@ test("lookupObject()", {
|
|
|
134
137
|
});
|
|
135
138
|
esm_default.removeRoutes({ includeFallback: false });
|
|
136
139
|
esm_default.get("https://example.com/slow-object", () => new Promise((resolve) => {
|
|
137
|
-
setTimeout(() => {
|
|
140
|
+
responseTimers.push(setTimeout(() => {
|
|
138
141
|
resolve({
|
|
139
142
|
status: 200,
|
|
140
143
|
headers: { "Content-Type": "application/activity+json" },
|
|
@@ -144,7 +147,7 @@ test("lookupObject()", {
|
|
|
144
147
|
content: "Slow response"
|
|
145
148
|
}
|
|
146
149
|
});
|
|
147
|
-
}, 1e3);
|
|
150
|
+
}, 1e3));
|
|
148
151
|
}));
|
|
149
152
|
await t.step("direct object fetch cancellation", async () => {
|
|
150
153
|
const controller = new AbortController();
|
|
@@ -155,6 +158,7 @@ test("lookupObject()", {
|
|
|
155
158
|
controller.abort();
|
|
156
159
|
deepStrictEqual(await promise, null);
|
|
157
160
|
});
|
|
161
|
+
for (const timer of responseTimers) clearTimeout(timer);
|
|
158
162
|
esm_default.hardReset();
|
|
159
163
|
esm_default.removeRoutes();
|
|
160
164
|
});
|
|
@@ -392,15 +396,18 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
392
396
|
throw new Error(`Unexpected URL: ${url}`);
|
|
393
397
|
};
|
|
394
398
|
deepStrictEqual(await lookupObject("@user@example.com", {
|
|
399
|
+
...allowPrivateAddress,
|
|
395
400
|
documentLoader: webfingerDocumentLoader,
|
|
396
401
|
contextLoader: mockDocumentLoader
|
|
397
402
|
}), null);
|
|
398
403
|
await rejects(() => lookupObject("@user@example.com", {
|
|
404
|
+
...allowPrivateAddress,
|
|
399
405
|
documentLoader: webfingerDocumentLoader,
|
|
400
406
|
contextLoader: mockDocumentLoader,
|
|
401
407
|
crossOrigin: "throw"
|
|
402
408
|
}), Error, "The object's @id (https://malicious.com/fake-actor) has a different origin than the document URL (https://different-origin.com/actor)");
|
|
403
409
|
const result2 = await lookupObject("@user@example.com", {
|
|
410
|
+
...allowPrivateAddress,
|
|
404
411
|
documentLoader: webfingerDocumentLoader,
|
|
405
412
|
contextLoader: mockDocumentLoader,
|
|
406
413
|
crossOrigin: "trust"
|
|
@@ -471,11 +478,20 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
471
478
|
const errorDocumentLoader = async (_url) => {
|
|
472
479
|
throw new Error("Network error");
|
|
473
480
|
};
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
481
|
+
esm_default.spyGlobal();
|
|
482
|
+
esm_default.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
483
|
+
let result;
|
|
484
|
+
try {
|
|
485
|
+
result = await lookupObject("https://example.com/note", {
|
|
486
|
+
...allowPrivateAddress,
|
|
487
|
+
documentLoader: errorDocumentLoader,
|
|
488
|
+
contextLoader: mockDocumentLoader,
|
|
489
|
+
crossOrigin: "throw"
|
|
490
|
+
});
|
|
491
|
+
} finally {
|
|
492
|
+
esm_default.hardReset();
|
|
493
|
+
}
|
|
494
|
+
deepStrictEqual(result, null);
|
|
479
495
|
});
|
|
480
496
|
await t.step("malformed JSON handling with cross-origin policy", async () => {
|
|
481
497
|
const malformedJsonDocumentLoader = async (url) => {
|
|
@@ -540,6 +556,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
540
556
|
await t.step("records kind=actor for an actor result", async () => {
|
|
541
557
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
542
558
|
assertInstanceOf(await lookupObject("@johndoe@example.com", {
|
|
559
|
+
...allowPrivateAddress,
|
|
543
560
|
documentLoader: mockDocumentLoader,
|
|
544
561
|
contextLoader: mockDocumentLoader,
|
|
545
562
|
meterProvider
|
|
@@ -593,6 +610,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
593
610
|
});
|
|
594
611
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
595
612
|
deepStrictEqual(await lookupObject("janedoe@example.com", {
|
|
613
|
+
...allowPrivateAddress,
|
|
596
614
|
documentLoader: mockDocumentLoader,
|
|
597
615
|
contextLoader: mockDocumentLoader,
|
|
598
616
|
meterProvider
|
|
@@ -622,6 +640,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
622
640
|
});
|
|
623
641
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
624
642
|
await lookupObject("@johndoe@example.com", {
|
|
643
|
+
...allowPrivateAddress,
|
|
625
644
|
documentLoader: mockDocumentLoader,
|
|
626
645
|
contextLoader: mockDocumentLoader,
|
|
627
646
|
meterProvider
|
|
@@ -643,6 +662,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
643
662
|
});
|
|
644
663
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
645
664
|
await lookupObject(new URL("acct:johndoe@example.com"), {
|
|
665
|
+
...allowPrivateAddress,
|
|
646
666
|
documentLoader: mockDocumentLoader,
|
|
647
667
|
contextLoader: mockDocumentLoader,
|
|
648
668
|
meterProvider
|