@fedify/vocab-runtime 2.4.0-dev.2247 → 2.4.0-dev.2256
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/internal/jsonld-cache.cjs +19 -0
- package/dist/internal/jsonld-cache.d.cts +8 -1
- package/dist/internal/jsonld-cache.d.ts +8 -1
- package/dist/internal/jsonld-cache.js +20 -2
- package/dist/mod.cjs +1 -1
- package/dist/mod.js +1 -1
- package/dist/tests/{body-EkRcWtjc.cjs → body-ILOzDJe-.cjs} +1 -1
- package/dist/tests/{body-CVAgeOnY.mjs → body-NALc-7u_.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +2 -2
- package/dist/tests/decimal.test.mjs +2 -2
- package/dist/tests/{docloader-Dqn63h7z.cjs → docloader-CZ-W5dIM.cjs} +2 -2
- package/dist/tests/{docloader-Dh5FI5cc.mjs → docloader-PCF1uReU.mjs} +2 -2
- package/dist/tests/docloader.test.cjs +2 -2
- package/dist/tests/docloader.test.mjs +2 -2
- package/dist/tests/internal/portable-dereference.test.cjs +2 -2
- package/dist/tests/internal/portable-dereference.test.mjs +2 -2
- package/dist/tests/{jsonld-cache-ChlXnADf.cjs → jsonld-cache-CMzevnnN.cjs} +24 -0
- package/dist/tests/{jsonld-cache-Clt08GtO.mjs → jsonld-cache-DCh2kTs6.mjs} +20 -2
- package/dist/tests/jsonld-cache.test.cjs +80 -1
- package/dist/tests/jsonld-cache.test.mjs +80 -1
- package/dist/tests/{portable-dereference-CmEBkIwk.cjs → portable-dereference-BCfSQoXP.cjs} +1 -1
- package/dist/tests/{portable-dereference-BPUyWeZd.mjs → portable-dereference-EAbEhAJ4.mjs} +1 -1
- package/dist/tests/{portable-media-CJz3xZPL.cjs → portable-media-HeXeBuyd.cjs} +2 -2
- package/dist/tests/{portable-media-Ch4q22fg.mjs → portable-media-SWj7DacP.mjs} +2 -2
- package/dist/tests/portable-media.test.cjs +1 -1
- package/dist/tests/portable-media.test.mjs +1 -1
- package/dist/tests/portable-workers.test.cjs +1 -1
- package/dist/tests/portable-workers.test.mjs +1 -1
- package/dist/tests/{request-Cemb1TON.cjs → request-BE3wHjK4.cjs} +1 -1
- package/dist/tests/{request-D9hlYelF.mjs → request-DkiHcgVt.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +1 -1
- package/src/internal/jsonld-cache.ts +37 -1
- package/src/jsonld-cache.test.ts +89 -0
package/deno.json
CHANGED
|
@@ -3,6 +3,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_url = require("../url-DKA6dTWV.cjs");
|
|
4
4
|
const require_jsonld = require("../jsonld.cjs");
|
|
5
5
|
//#region src/internal/jsonld-cache.ts
|
|
6
|
+
/**
|
|
7
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
8
|
+
* The original values and their order are preserved for URL validation by
|
|
9
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
10
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
11
|
+
*/
|
|
12
|
+
function getPortableActorGateways(node, allowUnmapped = true) {
|
|
13
|
+
const property = "https://w3id.org/fep/ef61/gateways";
|
|
14
|
+
if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
|
|
15
|
+
if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
|
|
16
|
+
try {
|
|
17
|
+
if (!require_url.getFe34Origin(require_url.parseIri(require_url.fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error instanceof TypeError) return void 0;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
|
|
23
|
+
}
|
|
6
24
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
7
25
|
const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
|
|
8
26
|
/**
|
|
@@ -323,6 +341,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
323
341
|
exports.compactJsonLdCache = compactJsonLdCache;
|
|
324
342
|
exports.createScopedContextLoader = createScopedContextLoader;
|
|
325
343
|
exports.getJsonLdContext = getJsonLdContext;
|
|
344
|
+
exports.getPortableActorGateways = getPortableActorGateways;
|
|
326
345
|
exports.isTrustedIriOrigin = isTrustedIriOrigin;
|
|
327
346
|
exports.normalizeJsonLdIris = normalizeJsonLdIris;
|
|
328
347
|
exports.registerDocumentLoaderWrapper = registerDocumentLoaderWrapper;
|
|
@@ -3,6 +3,13 @@ import { n as DocumentLoader } from "../docloader-C63enuyr.cjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/internal/jsonld-cache.d.ts
|
|
5
5
|
/**
|
|
6
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
7
|
+
* The original values and their order are preserved for URL validation by
|
|
8
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
9
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
10
|
+
*/
|
|
11
|
+
declare function getPortableActorGateways(node: Record<string, unknown>, allowUnmapped?: boolean): unknown[] | undefined;
|
|
12
|
+
/**
|
|
6
13
|
* Registers a loader wrapper with the shared released-wrapper registry.
|
|
7
14
|
* Both suppression and snapshot wrappers must use this registry so mixed
|
|
8
15
|
* chains can be unwrapped. The caller updates the state on release.
|
|
@@ -71,4 +78,4 @@ declare function getJsonLdContext(value: unknown, depth?: number): unknown;
|
|
|
71
78
|
*/
|
|
72
79
|
declare function compactJsonLdCache(normalized: unknown, original: unknown, documentLoader?: DocumentLoader, depth?: number, inheritedContext?: unknown): Promise<unknown>;
|
|
73
80
|
//#endregion
|
|
74
|
-
export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
|
81
|
+
export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
|
@@ -3,6 +3,13 @@ import { n as DocumentLoader } from "../docloader-C63enuyr.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/internal/jsonld-cache.d.ts
|
|
5
5
|
/**
|
|
6
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
7
|
+
* The original values and their order are preserved for URL validation by
|
|
8
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
9
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
10
|
+
*/
|
|
11
|
+
declare function getPortableActorGateways(node: Record<string, unknown>, allowUnmapped?: boolean): unknown[] | undefined;
|
|
12
|
+
/**
|
|
6
13
|
* Registers a loader wrapper with the shared released-wrapper registry.
|
|
7
14
|
* Both suppression and snapshot wrappers must use this registry so mixed
|
|
8
15
|
* chains can be unwrapped. The caller updates the state on release.
|
|
@@ -71,4 +78,4 @@ declare function getJsonLdContext(value: unknown, depth?: number): unknown;
|
|
|
71
78
|
*/
|
|
72
79
|
declare function compactJsonLdCache(normalized: unknown, original: unknown, documentLoader?: DocumentLoader, depth?: number, inheritedContext?: unknown): Promise<unknown>;
|
|
73
80
|
//#endregion
|
|
74
|
-
export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
|
81
|
+
export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
|
|
2
|
-
import { d as haveSameIriOrigin, o as formatIri, u as haveSameFe34Origin } from "../url-Cr9lJ6cD.js";
|
|
2
|
+
import { _ as parseIri, c as getFe34Origin, d as haveSameIriOrigin, o as formatIri, s as fromCompatibleEf61Id, u as haveSameFe34Origin } from "../url-Cr9lJ6cD.js";
|
|
3
3
|
import jsonld_default from "../jsonld.js";
|
|
4
4
|
//#region src/internal/jsonld-cache.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
7
|
+
* The original values and their order are preserved for URL validation by
|
|
8
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
9
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
10
|
+
*/
|
|
11
|
+
function getPortableActorGateways(node, allowUnmapped = true) {
|
|
12
|
+
const property = "https://w3id.org/fep/ef61/gateways";
|
|
13
|
+
if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
|
|
14
|
+
if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
|
|
15
|
+
try {
|
|
16
|
+
if (!getFe34Origin(parseIri(fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (error instanceof TypeError) return void 0;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
|
|
22
|
+
}
|
|
5
23
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
6
24
|
const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
|
|
7
25
|
/**
|
|
@@ -319,4 +337,4 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
319
337
|
return [...inherited, ...own];
|
|
320
338
|
}
|
|
321
339
|
//#endregion
|
|
322
|
-
export { compactJsonLdCache, createScopedContextLoader, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
|
340
|
+
export { compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
|
package/dist/mod.cjs
CHANGED
|
@@ -16,7 +16,7 @@ let _multiformats_base_x = require("@multiformats/base-x");
|
|
|
16
16
|
_multiformats_base_x = require_rolldown_runtime.__toESM(_multiformats_base_x, 1);
|
|
17
17
|
//#region deno.json
|
|
18
18
|
var name = "@fedify/vocab-runtime";
|
|
19
|
-
var version = "2.4.0-dev.
|
|
19
|
+
var version = "2.4.0-dev.2256+683c50ba";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/request.ts
|
|
22
22
|
/**
|
package/dist/mod.js
CHANGED
|
@@ -12,7 +12,7 @@ import { PublicKeyInfo } from "pkijs";
|
|
|
12
12
|
import baseX from "@multiformats/base-x";
|
|
13
13
|
//#region deno.json
|
|
14
14
|
var name = "@fedify/vocab-runtime";
|
|
15
|
-
var version = "2.4.0-dev.
|
|
15
|
+
var version = "2.4.0-dev.2256+683c50ba";
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/request.ts
|
|
18
18
|
/**
|
package/dist/tests/body.test.cjs
CHANGED
package/dist/tests/body.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as readBoundedText, t as BodyTooLargeError } from "./body-
|
|
1
|
+
import { i as readBoundedText, t as BodyTooLargeError } from "./body-NALc-7u_.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require("./url-Ddeuv0sE.cjs");
|
|
2
|
-
require("./docloader-
|
|
2
|
+
require("./docloader-CZ-W5dIM.cjs");
|
|
3
3
|
require("./key-C-AYkdJJ.cjs");
|
|
4
4
|
require("./multibase-B5Mea7Ip.cjs");
|
|
5
5
|
require("./digest-3FeH2Y-Q.cjs");
|
|
6
6
|
require("./langstr-C4Fl80ae.cjs");
|
|
7
|
-
require("./portable-media-
|
|
7
|
+
require("./portable-media-HeXeBuyd.cjs");
|
|
8
8
|
let node_test = require("node:test");
|
|
9
9
|
let node_assert = require("node:assert");
|
|
10
10
|
//#region src/decimal.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./url-ClVBNQup.mjs";
|
|
2
|
-
import "./docloader-
|
|
2
|
+
import "./docloader-PCF1uReU.mjs";
|
|
3
3
|
import "./key-C2Db_TAJ.mjs";
|
|
4
4
|
import "./multibase-BPnF_L4e.mjs";
|
|
5
5
|
import "./digest-COC7xDiQ.mjs";
|
|
6
6
|
import "./langstr-CQ26J_L7.mjs";
|
|
7
|
-
import "./portable-media-
|
|
7
|
+
import "./portable-media-SWj7DacP.mjs";
|
|
8
8
|
import { test } from "node:test";
|
|
9
9
|
import { deepStrictEqual, throws } from "node:assert";
|
|
10
10
|
//#region src/decimal.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_request = require("./request-
|
|
2
|
-
const require_body = require("./body-
|
|
1
|
+
const require_request = require("./request-BE3wHjK4.cjs");
|
|
2
|
+
const require_body = require("./body-ILOzDJe-.cjs");
|
|
3
3
|
const require_contexts = require("./contexts-DizzBjz4.cjs");
|
|
4
4
|
const require_link = require("./link-DlKm8bEr.cjs");
|
|
5
5
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
2
|
-
import { i as readBoundedText, n as MAX_BODY_SIZE, r as readBoundedBytes, t as BodyTooLargeError } from "./body-
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-DkiHcgVt.mjs";
|
|
2
|
+
import { i as readBoundedText, n as MAX_BODY_SIZE, r as readBoundedBytes, t as BodyTooLargeError } from "./body-NALc-7u_.mjs";
|
|
3
3
|
import { t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
|
|
4
4
|
import { t as HttpHeaderLink } from "./link-Cevmc87v.mjs";
|
|
5
5
|
import { n as UrlError, x as validatePublicUrl } from "./url-ClVBNQup.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BE3wHjK4.cjs");
|
|
3
3
|
const require_contexts = require("./contexts-DizzBjz4.cjs");
|
|
4
4
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
5
|
-
const require_docloader = require("./docloader-
|
|
5
|
+
const require_docloader = require("./docloader-CZ-W5dIM.cjs");
|
|
6
6
|
let node_zlib = require("node:zlib");
|
|
7
7
|
let _logtape_logtape = require("@logtape/logtape");
|
|
8
8
|
let node_assert = require("node:assert");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as FetchError } from "./request-
|
|
1
|
+
import { t as FetchError } from "./request-DkiHcgVt.mjs";
|
|
2
2
|
import { n as cid_v1_default, t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
|
|
3
3
|
import { n as UrlError } from "./url-ClVBNQup.mjs";
|
|
4
|
-
import { i as withDocumentLoaderTimeout, n as getRemoteDocument, r as resolveDocumentLoaderTimeout, t as getDocumentLoader } from "./docloader-
|
|
4
|
+
import { i as withDocumentLoaderTimeout, n as getRemoteDocument, r as resolveDocumentLoaderTimeout, t as getDocumentLoader } from "./docloader-PCF1uReU.mjs";
|
|
5
5
|
import { gzipSync } from "node:zlib";
|
|
6
6
|
import { configure, reset } from "@logtape/logtape";
|
|
7
7
|
import { deepStrictEqual, ok, rejects, throws } from "node:assert";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_url = require("../url-Ddeuv0sE.cjs");
|
|
2
|
-
const require_jsonld_cache = require("../jsonld-cache-
|
|
3
|
-
const require_portable_dereference = require("../portable-dereference-
|
|
2
|
+
const require_jsonld_cache = require("../jsonld-cache-CMzevnnN.cjs");
|
|
3
|
+
const require_portable_dereference = require("../portable-dereference-BCfSQoXP.cjs");
|
|
4
4
|
let node_assert_strict = require("node:assert/strict");
|
|
5
5
|
let node_test = require("node:test");
|
|
6
6
|
//#region src/internal/portable-dereference.test.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as withGatewayHints, _ as parseIri } from "../url-ClVBNQup.mjs";
|
|
2
|
-
import { n as createScopedContextLoader } from "../jsonld-cache-
|
|
3
|
-
import { n as getPortableGatewayCandidates, r as isPortableIri, t as createSnapshotContextLoader } from "../portable-dereference-
|
|
2
|
+
import { n as createScopedContextLoader } from "../jsonld-cache-DCh2kTs6.mjs";
|
|
3
|
+
import { n as getPortableGatewayCandidates, r as isPortableIri, t as createSnapshotContextLoader } from "../portable-dereference-EAbEhAJ4.mjs";
|
|
4
4
|
import { deepStrictEqual, ok, throws } from "node:assert/strict";
|
|
5
5
|
import { test } from "node:test";
|
|
6
6
|
//#region src/internal/portable-dereference.test.ts
|
|
@@ -6,6 +6,24 @@ jsonld_dist_jsonld_esm_js = require_rolldown_runtime.__toESM(jsonld_dist_jsonld_
|
|
|
6
6
|
var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/internal/jsonld-cache.ts
|
|
9
|
+
/**
|
|
10
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
11
|
+
* The original values and their order are preserved for URL validation by
|
|
12
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
13
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
14
|
+
*/
|
|
15
|
+
function getPortableActorGateways(node, allowUnmapped = true) {
|
|
16
|
+
const property = "https://w3id.org/fep/ef61/gateways";
|
|
17
|
+
if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
|
|
18
|
+
if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
|
|
19
|
+
try {
|
|
20
|
+
if (!require_url.getFe34Origin(require_url.parseIri(require_url.fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error instanceof TypeError) return void 0;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
|
|
26
|
+
}
|
|
9
27
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
10
28
|
const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
|
|
11
29
|
/**
|
|
@@ -341,6 +359,12 @@ Object.defineProperty(exports, "getJsonLdContext", {
|
|
|
341
359
|
return getJsonLdContext;
|
|
342
360
|
}
|
|
343
361
|
});
|
|
362
|
+
Object.defineProperty(exports, "getPortableActorGateways", {
|
|
363
|
+
enumerable: true,
|
|
364
|
+
get: function() {
|
|
365
|
+
return getPortableActorGateways;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
344
368
|
Object.defineProperty(exports, "isTrustedIriOrigin", {
|
|
345
369
|
enumerable: true,
|
|
346
370
|
get: function() {
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { d as haveSameIriOrigin, o as formatIri, u as haveSameFe34Origin } from "./url-ClVBNQup.mjs";
|
|
1
|
+
import { _ as parseIri, c as getFe34Origin, d as haveSameIriOrigin, o as formatIri, s as fromCompatibleEf61Id, u as haveSameFe34Origin } from "./url-ClVBNQup.mjs";
|
|
2
2
|
import jsonld from "jsonld/dist/jsonld.esm.js";
|
|
3
3
|
//#region src/jsonld.ts
|
|
4
4
|
var jsonld_default = jsonld;
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/internal/jsonld-cache.ts
|
|
7
|
+
/**
|
|
8
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
9
|
+
* The original values and their order are preserved for URL validation by
|
|
10
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
11
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
12
|
+
*/
|
|
13
|
+
function getPortableActorGateways(node, allowUnmapped = true) {
|
|
14
|
+
const property = "https://w3id.org/fep/ef61/gateways";
|
|
15
|
+
if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
|
|
16
|
+
if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
|
|
17
|
+
try {
|
|
18
|
+
if (!getFe34Origin(parseIri(fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (error instanceof TypeError) return void 0;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
|
|
24
|
+
}
|
|
7
25
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
8
26
|
const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
|
|
9
27
|
/**
|
|
@@ -321,4 +339,4 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
321
339
|
return [...inherited, ...own];
|
|
322
340
|
}
|
|
323
341
|
//#endregion
|
|
324
|
-
export {
|
|
342
|
+
export { isTrustedIriOrigin as a, unwrapReleasedDocumentLoader as c, getPortableActorGateways as i, jsonld_default as l, createScopedContextLoader as n, normalizeJsonLdIris as o, getJsonLdContext as r, registerDocumentLoaderWrapper as s, compactJsonLdCache as t };
|
|
@@ -1,8 +1,87 @@
|
|
|
1
1
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
2
|
-
const require_jsonld_cache = require("./jsonld-cache-
|
|
2
|
+
const require_jsonld_cache = require("./jsonld-cache-CMzevnnN.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_assert = require("node:assert");
|
|
5
5
|
//#region src/jsonld-cache.test.ts
|
|
6
|
+
(0, node_test.test)("getPortableActorGateways() preserves unmapped portable actor gateways", () => {
|
|
7
|
+
const gateways = [
|
|
8
|
+
{ "@value": "https://second.example" },
|
|
9
|
+
{ "@value": "https://first.example" },
|
|
10
|
+
{ "@value": "not a valid gateway" }
|
|
11
|
+
];
|
|
12
|
+
for (const id of [
|
|
13
|
+
"ap://did:key:z6Mkabc/actor",
|
|
14
|
+
"ap+ef61://did:key:z6Mkabc/actor",
|
|
15
|
+
"https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
|
|
16
|
+
]) {
|
|
17
|
+
const node = {
|
|
18
|
+
"@id": id,
|
|
19
|
+
"http://www.w3.org/ns/ldp#inbox": [{ "@id": `${id}/inbox` }],
|
|
20
|
+
"https://www.w3.org/ns/activitystreams#outbox": [{ "@id": `${id}/outbox` }],
|
|
21
|
+
"_:gateways": gateways
|
|
22
|
+
};
|
|
23
|
+
const original = structuredClone(node);
|
|
24
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(node), gateways, id);
|
|
25
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(node, false), void 0, id);
|
|
26
|
+
(0, node_assert.deepStrictEqual)(node, original);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
(0, node_test.test)("getPortableActorGateways() gives mapped gateways precedence", () => {
|
|
30
|
+
const canonical = "https://w3id.org/fep/ef61/gateways";
|
|
31
|
+
const gateways = [{ "@list": [{ "@id": "https://gateway.example" }] }];
|
|
32
|
+
const node = {
|
|
33
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
34
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
35
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
36
|
+
"_:gateways": [{ "@value": "https://other.example" }],
|
|
37
|
+
[canonical]: gateways
|
|
38
|
+
};
|
|
39
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(node), gateways);
|
|
40
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(node, false), gateways);
|
|
41
|
+
for (const value of [
|
|
42
|
+
void 0,
|
|
43
|
+
null,
|
|
44
|
+
{},
|
|
45
|
+
"https://gateway.example",
|
|
46
|
+
[]
|
|
47
|
+
]) {
|
|
48
|
+
node[canonical] = value;
|
|
49
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(node), Array.isArray(value) ? value : void 0);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
(0, node_test.test)("getPortableActorGateways() limits unmapped terms to portable actors", () => {
|
|
53
|
+
const node = {
|
|
54
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
55
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
56
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
57
|
+
"_:gateways": [{ "@value": "https://gateway.example" }]
|
|
58
|
+
};
|
|
59
|
+
for (const id of [
|
|
60
|
+
void 0,
|
|
61
|
+
1,
|
|
62
|
+
"not an IRI",
|
|
63
|
+
"https://ordinary.example/actor",
|
|
64
|
+
"https://gateway.example/.well-known/apgateway/not-a-did/actor",
|
|
65
|
+
"https://user@gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
|
|
66
|
+
]) (0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways({
|
|
67
|
+
...node,
|
|
68
|
+
"@id": id
|
|
69
|
+
}), void 0);
|
|
70
|
+
for (const property of ["http://www.w3.org/ns/ldp#inbox", "https://www.w3.org/ns/activitystreams#outbox"]) {
|
|
71
|
+
const nonActor = { ...node };
|
|
72
|
+
delete nonActor[property];
|
|
73
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways(nonActor), void 0);
|
|
74
|
+
}
|
|
75
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways({
|
|
76
|
+
...node,
|
|
77
|
+
"_:gateways": null
|
|
78
|
+
}), void 0);
|
|
79
|
+
const empty = [];
|
|
80
|
+
(0, node_assert.strictEqual)(require_jsonld_cache.getPortableActorGateways({
|
|
81
|
+
...node,
|
|
82
|
+
"_:gateways": empty
|
|
83
|
+
}), empty);
|
|
84
|
+
});
|
|
6
85
|
(0, node_test.test)("isTrustedIriOrigin() trusts same portable IRI origins", () => {
|
|
7
86
|
(0, node_assert.ok)(require_jsonld_cache.isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap+ef61://did:key:z6Mkabc/outbox")));
|
|
8
87
|
(0, node_assert.ok)(!require_jsonld_cache.isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
@@ -1,8 +1,87 @@
|
|
|
1
1
|
import { _ as parseIri } from "./url-ClVBNQup.mjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as isTrustedIriOrigin, i as getPortableActorGateways, l as jsonld_default, o as normalizeJsonLdIris, r as getJsonLdContext, t as compactJsonLdCache } from "./jsonld-cache-DCh2kTs6.mjs";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import { deepStrictEqual, ok, strictEqual } from "node:assert";
|
|
5
5
|
//#region src/jsonld-cache.test.ts
|
|
6
|
+
test("getPortableActorGateways() preserves unmapped portable actor gateways", () => {
|
|
7
|
+
const gateways = [
|
|
8
|
+
{ "@value": "https://second.example" },
|
|
9
|
+
{ "@value": "https://first.example" },
|
|
10
|
+
{ "@value": "not a valid gateway" }
|
|
11
|
+
];
|
|
12
|
+
for (const id of [
|
|
13
|
+
"ap://did:key:z6Mkabc/actor",
|
|
14
|
+
"ap+ef61://did:key:z6Mkabc/actor",
|
|
15
|
+
"https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
|
|
16
|
+
]) {
|
|
17
|
+
const node = {
|
|
18
|
+
"@id": id,
|
|
19
|
+
"http://www.w3.org/ns/ldp#inbox": [{ "@id": `${id}/inbox` }],
|
|
20
|
+
"https://www.w3.org/ns/activitystreams#outbox": [{ "@id": `${id}/outbox` }],
|
|
21
|
+
"_:gateways": gateways
|
|
22
|
+
};
|
|
23
|
+
const original = structuredClone(node);
|
|
24
|
+
strictEqual(getPortableActorGateways(node), gateways, id);
|
|
25
|
+
strictEqual(getPortableActorGateways(node, false), void 0, id);
|
|
26
|
+
deepStrictEqual(node, original);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
test("getPortableActorGateways() gives mapped gateways precedence", () => {
|
|
30
|
+
const canonical = "https://w3id.org/fep/ef61/gateways";
|
|
31
|
+
const gateways = [{ "@list": [{ "@id": "https://gateway.example" }] }];
|
|
32
|
+
const node = {
|
|
33
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
34
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
35
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
36
|
+
"_:gateways": [{ "@value": "https://other.example" }],
|
|
37
|
+
[canonical]: gateways
|
|
38
|
+
};
|
|
39
|
+
strictEqual(getPortableActorGateways(node), gateways);
|
|
40
|
+
strictEqual(getPortableActorGateways(node, false), gateways);
|
|
41
|
+
for (const value of [
|
|
42
|
+
void 0,
|
|
43
|
+
null,
|
|
44
|
+
{},
|
|
45
|
+
"https://gateway.example",
|
|
46
|
+
[]
|
|
47
|
+
]) {
|
|
48
|
+
node[canonical] = value;
|
|
49
|
+
strictEqual(getPortableActorGateways(node), Array.isArray(value) ? value : void 0);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
test("getPortableActorGateways() limits unmapped terms to portable actors", () => {
|
|
53
|
+
const node = {
|
|
54
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
55
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
56
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
57
|
+
"_:gateways": [{ "@value": "https://gateway.example" }]
|
|
58
|
+
};
|
|
59
|
+
for (const id of [
|
|
60
|
+
void 0,
|
|
61
|
+
1,
|
|
62
|
+
"not an IRI",
|
|
63
|
+
"https://ordinary.example/actor",
|
|
64
|
+
"https://gateway.example/.well-known/apgateway/not-a-did/actor",
|
|
65
|
+
"https://user@gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
|
|
66
|
+
]) strictEqual(getPortableActorGateways({
|
|
67
|
+
...node,
|
|
68
|
+
"@id": id
|
|
69
|
+
}), void 0);
|
|
70
|
+
for (const property of ["http://www.w3.org/ns/ldp#inbox", "https://www.w3.org/ns/activitystreams#outbox"]) {
|
|
71
|
+
const nonActor = { ...node };
|
|
72
|
+
delete nonActor[property];
|
|
73
|
+
strictEqual(getPortableActorGateways(nonActor), void 0);
|
|
74
|
+
}
|
|
75
|
+
strictEqual(getPortableActorGateways({
|
|
76
|
+
...node,
|
|
77
|
+
"_:gateways": null
|
|
78
|
+
}), void 0);
|
|
79
|
+
const empty = [];
|
|
80
|
+
strictEqual(getPortableActorGateways({
|
|
81
|
+
...node,
|
|
82
|
+
"_:gateways": empty
|
|
83
|
+
}), empty);
|
|
84
|
+
});
|
|
6
85
|
test("isTrustedIriOrigin() trusts same portable IRI origins", () => {
|
|
7
86
|
ok(isTrustedIriOrigin({}, parseIri("ap://did:key:z6Mkabc/actor"), parseIri("ap+ef61://did:key:z6Mkabc/outbox")));
|
|
8
87
|
ok(!isTrustedIriOrigin({}, parseIri("ap://did:key:z6Mkabc/actor"), parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_contexts = require("./contexts-DizzBjz4.cjs");
|
|
2
2
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
3
|
-
const require_jsonld_cache = require("./jsonld-cache-
|
|
3
|
+
const require_jsonld_cache = require("./jsonld-cache-CMzevnnN.cjs");
|
|
4
4
|
let _logtape_logtape = require("@logtape/logtape");
|
|
5
5
|
require("@opentelemetry/api");
|
|
6
6
|
//#region src/internal/portable-dereference.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
|
|
2
2
|
import { h as parseGatewayOrigin, o as formatIri, t as GATEWAY_HINT_PARAMETER } from "./url-ClVBNQup.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { c as unwrapReleasedDocumentLoader, s as registerDocumentLoaderWrapper } from "./jsonld-cache-DCh2kTs6.mjs";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import "@opentelemetry/api";
|
|
6
6
|
//#region src/internal/portable-dereference.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_request = require("./request-
|
|
2
|
-
const require_body = require("./body-
|
|
1
|
+
const require_request = require("./request-BE3wHjK4.cjs");
|
|
2
|
+
const require_body = require("./body-ILOzDJe-.cjs");
|
|
3
3
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
4
4
|
const require_digest = require("./digest-3FeH2Y-Q.cjs");
|
|
5
5
|
//#region src/portable-media.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as getUserAgent } from "./request-
|
|
2
|
-
import { r as readBoundedBytes } from "./body-
|
|
1
|
+
import { r as getUserAgent } from "./request-DkiHcgVt.mjs";
|
|
2
|
+
import { r as readBoundedBytes } from "./body-NALc-7u_.mjs";
|
|
3
3
|
import { g as parseGatewayUrl, x as validatePublicUrl } from "./url-ClVBNQup.mjs";
|
|
4
4
|
import { a as verifyDigestMultibase, i as parseHashlink, r as parseDigestMultibase } from "./digest-COC7xDiQ.mjs";
|
|
5
5
|
//#region src/portable-media.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_digest = require("./digest-3FeH2Y-Q.cjs");
|
|
2
|
-
const require_portable_media = require("./portable-media-
|
|
2
|
+
const require_portable_media = require("./portable-media-HeXeBuyd.cjs");
|
|
3
3
|
let node_assert_strict = require("node:assert/strict");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let node_http = require("node:http");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as createHashlink, t as computeDigestMultibase } from "./digest-COC7xDiQ.mjs";
|
|
2
|
-
import { t as fetchPortableMedia } from "./portable-media-
|
|
2
|
+
import { t as fetchPortableMedia } from "./portable-media-SWj7DacP.mjs";
|
|
3
3
|
import { deepStrictEqual, equal, rejects } from "node:assert/strict";
|
|
4
4
|
import { test } from "node:test";
|
|
5
5
|
import { createServer } from "node:http";
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_url = require("./url-Ddeuv0sE.cjs");
|
|
3
3
|
const require_key = require("./key-C-AYkdJJ.cjs");
|
|
4
4
|
const require_digest = require("./digest-3FeH2Y-Q.cjs");
|
|
5
|
-
const require_portable_dereference = require("./portable-dereference-
|
|
5
|
+
const require_portable_dereference = require("./portable-dereference-BCfSQoXP.cjs");
|
|
6
6
|
let node_assert_strict = require("node:assert/strict");
|
|
7
7
|
let _fedify_fixture = require("@fedify/fixture");
|
|
8
8
|
//#region src/portable-workers.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as parseIri, i as canonicalizePortableUri, o as formatIri, s as fromCompatibleEf61Id, y as toCompatibleEf61Id } from "./url-ClVBNQup.mjs";
|
|
2
2
|
import { i as importDidKey, t as exportDidKey } from "./key-C2Db_TAJ.mjs";
|
|
3
3
|
import { n as createHashlink, o as verifyHashlink, t as computeDigestMultibase } from "./digest-COC7xDiQ.mjs";
|
|
4
|
-
import { n as getPortableGatewayCandidates } from "./portable-dereference-
|
|
4
|
+
import { n as getPortableGatewayCandidates } from "./portable-dereference-EAbEhAJ4.mjs";
|
|
5
5
|
import { deepStrictEqual, equal } from "node:assert/strict";
|
|
6
6
|
import { test, testDefinitions } from "@fedify/fixture";
|
|
7
7
|
//#region src/portable-workers.test.ts
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.4.0-dev.
|
|
6
|
+
var version = "2.4.0-dev.2256+683c50ba";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BE3wHjK4.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createActivityPubRequest, o as version, r as getUserAgent } from "./request-
|
|
1
|
+
import { n as createActivityPubRequest, o as version, r as getUserAgent } from "./request-DkiHcgVt.mjs";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { deepStrictEqual } from "node:assert";
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import type { DocumentLoader } from "../docloader.ts";
|
|
2
2
|
import jsonld from "../jsonld.ts";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
formatIri,
|
|
5
|
+
fromCompatibleEf61Id,
|
|
6
|
+
getFe34Origin,
|
|
7
|
+
haveSameFe34Origin,
|
|
8
|
+
haveSameIriOrigin,
|
|
9
|
+
parseIri,
|
|
10
|
+
} from "../url.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Reads expanded gateways, including an unmapped term on portable actors.
|
|
14
|
+
* The original values and their order are preserved for URL validation by
|
|
15
|
+
* the caller. An explicitly mapped FEP-ef61 property always takes precedence.
|
|
16
|
+
* @internal Used by generated vocabulary classes and portable proof checks.
|
|
17
|
+
*/
|
|
18
|
+
export function getPortableActorGateways(
|
|
19
|
+
node: Record<string, unknown>,
|
|
20
|
+
allowUnmapped = true,
|
|
21
|
+
): unknown[] | undefined {
|
|
22
|
+
const property = "https://w3id.org/fep/ef61/gateways";
|
|
23
|
+
if (globalThis.Object.hasOwn(node, property)) {
|
|
24
|
+
return Array.isArray(node[property]) ? node[property] : undefined;
|
|
25
|
+
}
|
|
26
|
+
if (
|
|
27
|
+
!allowUnmapped || typeof node["@id"] !== "string" ||
|
|
28
|
+
!("http://www.w3.org/ns/ldp#inbox" in node) ||
|
|
29
|
+
!("https://www.w3.org/ns/activitystreams#outbox" in node)
|
|
30
|
+
) return undefined;
|
|
31
|
+
try {
|
|
32
|
+
const id = fromCompatibleEf61Id(node["@id"]) ?? node["@id"];
|
|
33
|
+
if (!getFe34Origin(parseIri(id)).startsWith("did:")) return undefined;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof TypeError) return undefined;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : undefined;
|
|
39
|
+
}
|
|
4
40
|
|
|
5
41
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
6
42
|
|
package/src/jsonld-cache.test.ts
CHANGED
|
@@ -3,12 +3,101 @@ import { test } from "node:test";
|
|
|
3
3
|
import {
|
|
4
4
|
compactJsonLdCache,
|
|
5
5
|
getJsonLdContext,
|
|
6
|
+
getPortableActorGateways,
|
|
6
7
|
isTrustedIriOrigin,
|
|
7
8
|
normalizeJsonLdIris,
|
|
8
9
|
} from "./internal/jsonld-cache.ts";
|
|
9
10
|
import jsonld from "./jsonld.ts";
|
|
10
11
|
import { parseIri } from "./url.ts";
|
|
11
12
|
|
|
13
|
+
test("getPortableActorGateways() preserves unmapped portable actor gateways", () => {
|
|
14
|
+
const gateways = [
|
|
15
|
+
{ "@value": "https://second.example" },
|
|
16
|
+
{ "@value": "https://first.example" },
|
|
17
|
+
{ "@value": "not a valid gateway" },
|
|
18
|
+
];
|
|
19
|
+
const ids = [
|
|
20
|
+
"ap://did:key:z6Mkabc/actor",
|
|
21
|
+
"ap+ef61://did:key:z6Mkabc/actor",
|
|
22
|
+
"https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor",
|
|
23
|
+
];
|
|
24
|
+
for (const id of ids) {
|
|
25
|
+
const node = {
|
|
26
|
+
"@id": id,
|
|
27
|
+
"http://www.w3.org/ns/ldp#inbox": [{ "@id": `${id}/inbox` }],
|
|
28
|
+
"https://www.w3.org/ns/activitystreams#outbox": [
|
|
29
|
+
{ "@id": `${id}/outbox` },
|
|
30
|
+
],
|
|
31
|
+
"_:gateways": gateways,
|
|
32
|
+
};
|
|
33
|
+
const original = structuredClone(node);
|
|
34
|
+
strictEqual(getPortableActorGateways(node), gateways, id);
|
|
35
|
+
strictEqual(getPortableActorGateways(node, false), undefined, id);
|
|
36
|
+
deepStrictEqual(node, original);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("getPortableActorGateways() gives mapped gateways precedence", () => {
|
|
41
|
+
const canonical = "https://w3id.org/fep/ef61/gateways";
|
|
42
|
+
const gateways = [{ "@list": [{ "@id": "https://gateway.example" }] }];
|
|
43
|
+
const node: Record<string, unknown> = {
|
|
44
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
45
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
46
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
47
|
+
"_:gateways": [{ "@value": "https://other.example" }],
|
|
48
|
+
[canonical]: gateways,
|
|
49
|
+
};
|
|
50
|
+
strictEqual(getPortableActorGateways(node), gateways);
|
|
51
|
+
strictEqual(getPortableActorGateways(node, false), gateways);
|
|
52
|
+
for (const value of [undefined, null, {}, "https://gateway.example", []]) {
|
|
53
|
+
node[canonical] = value;
|
|
54
|
+
strictEqual(
|
|
55
|
+
getPortableActorGateways(node),
|
|
56
|
+
Array.isArray(value) ? value : undefined,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("getPortableActorGateways() limits unmapped terms to portable actors", () => {
|
|
62
|
+
const node: Record<string, unknown> = {
|
|
63
|
+
"@id": "ap://did:key:z6Mkabc/actor",
|
|
64
|
+
"http://www.w3.org/ns/ldp#inbox": [],
|
|
65
|
+
"https://www.w3.org/ns/activitystreams#outbox": [],
|
|
66
|
+
"_:gateways": [{ "@value": "https://gateway.example" }],
|
|
67
|
+
};
|
|
68
|
+
for (
|
|
69
|
+
const id of [
|
|
70
|
+
undefined,
|
|
71
|
+
1,
|
|
72
|
+
"not an IRI",
|
|
73
|
+
"https://ordinary.example/actor",
|
|
74
|
+
"https://gateway.example/.well-known/apgateway/not-a-did/actor",
|
|
75
|
+
"https://user@gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor",
|
|
76
|
+
]
|
|
77
|
+
) {
|
|
78
|
+
strictEqual(getPortableActorGateways({ ...node, "@id": id }), undefined);
|
|
79
|
+
}
|
|
80
|
+
for (
|
|
81
|
+
const property of [
|
|
82
|
+
"http://www.w3.org/ns/ldp#inbox",
|
|
83
|
+
"https://www.w3.org/ns/activitystreams#outbox",
|
|
84
|
+
]
|
|
85
|
+
) {
|
|
86
|
+
const nonActor = { ...node };
|
|
87
|
+
delete nonActor[property];
|
|
88
|
+
strictEqual(getPortableActorGateways(nonActor), undefined);
|
|
89
|
+
}
|
|
90
|
+
strictEqual(
|
|
91
|
+
getPortableActorGateways({ ...node, "_:gateways": null }),
|
|
92
|
+
undefined,
|
|
93
|
+
);
|
|
94
|
+
const empty: unknown[] = [];
|
|
95
|
+
strictEqual(
|
|
96
|
+
getPortableActorGateways({ ...node, "_:gateways": empty }),
|
|
97
|
+
empty,
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
12
101
|
test("isTrustedIriOrigin() trusts same portable IRI origins", () => {
|
|
13
102
|
ok(isTrustedIriOrigin(
|
|
14
103
|
{},
|