@fedify/vocab-runtime 2.4.0-dev.2256 → 2.4.0-dev.2260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/deno.json +1 -1
  2. package/dist/{docloader-C63enuyr.d.cts → docloader-CYwqh5Df.d.cts} +1 -0
  3. package/dist/{docloader-C63enuyr.d.ts → docloader-CYwqh5Df.d.ts} +1 -0
  4. package/dist/internal/jsonld-cache.cjs +1 -1
  5. package/dist/internal/jsonld-cache.d.cts +1 -1
  6. package/dist/internal/jsonld-cache.d.ts +1 -1
  7. package/dist/internal/jsonld-cache.js +1 -1
  8. package/dist/internal/portable-dereference.cjs +55 -1
  9. package/dist/internal/portable-dereference.d.cts +25 -3
  10. package/dist/internal/portable-dereference.d.ts +25 -3
  11. package/dist/internal/portable-dereference.js +55 -2
  12. package/dist/mod.cjs +2 -2
  13. package/dist/mod.d.cts +55 -6
  14. package/dist/mod.d.ts +55 -6
  15. package/dist/mod.js +2 -2
  16. package/dist/{portable-Cux3IA20.d.cts → portable-DqtfLy_1.d.cts} +1 -1
  17. package/dist/{portable-DBA1FS_L.d.ts → portable-DtWsu2yU.d.ts} +1 -1
  18. package/dist/tests/{body-NALc-7u_.mjs → body-BbkIKvTI.mjs} +1 -1
  19. package/dist/tests/{body-ILOzDJe-.cjs → body-edyRdC9n.cjs} +1 -1
  20. package/dist/tests/body.test.cjs +1 -1
  21. package/dist/tests/body.test.mjs +1 -1
  22. package/dist/tests/decimal.test.cjs +3 -3
  23. package/dist/tests/decimal.test.mjs +3 -3
  24. package/dist/tests/{docloader-PCF1uReU.mjs → docloader-DS598-E-.mjs} +3 -3
  25. package/dist/tests/{docloader-CZ-W5dIM.cjs → docloader-DVikRN3s.cjs} +3 -3
  26. package/dist/tests/docloader.test.cjs +3 -3
  27. package/dist/tests/docloader.test.mjs +3 -3
  28. package/dist/tests/internal/portable-dereference.test.cjs +31 -3
  29. package/dist/tests/internal/portable-dereference.test.mjs +31 -3
  30. package/dist/tests/{jsonld-cache-DCh2kTs6.mjs → jsonld-cache-BPQmOZWD.mjs} +1 -1
  31. package/dist/tests/{jsonld-cache-CMzevnnN.cjs → jsonld-cache-C07AyNOY.cjs} +1 -1
  32. package/dist/tests/jsonld-cache.test.cjs +2 -2
  33. package/dist/tests/jsonld-cache.test.mjs +2 -2
  34. package/dist/tests/portable-dereference-BNXtgg5U.cjs +278 -0
  35. package/dist/tests/portable-dereference-DRE5bz-l.mjs +249 -0
  36. package/dist/tests/{portable-media-HeXeBuyd.cjs → portable-media-BC-QRzPd.cjs} +3 -3
  37. package/dist/tests/{portable-media-SWj7DacP.mjs → portable-media-CP6hh3ja.mjs} +3 -3
  38. package/dist/tests/portable-media.test.cjs +1 -1
  39. package/dist/tests/portable-media.test.mjs +1 -1
  40. package/dist/tests/portable-workers.test.cjs +2 -2
  41. package/dist/tests/portable-workers.test.mjs +2 -2
  42. package/dist/tests/{request-DkiHcgVt.mjs → request-D-SOvXf_.mjs} +1 -1
  43. package/dist/tests/{request-BE3wHjK4.cjs → request-kRkxuOkZ.cjs} +1 -1
  44. package/dist/tests/request.test.cjs +1 -1
  45. package/dist/tests/request.test.mjs +1 -1
  46. package/dist/tests/{url-Ddeuv0sE.cjs → url-BNakuZ8k.cjs} +53 -4
  47. package/dist/tests/{url-ClVBNQup.mjs → url-DMxmp7ZG.mjs} +53 -4
  48. package/dist/tests/url.test.cjs +1 -1
  49. package/dist/tests/url.test.mjs +1 -1
  50. package/dist/{url-DKA6dTWV.cjs → url-DrGTR8yv.cjs} +53 -4
  51. package/dist/{url-Cr9lJ6cD.js → url-Dzyp-NsC.js} +53 -4
  52. package/package.json +1 -1
  53. package/src/docloader.ts +1 -0
  54. package/src/internal/portable-dereference.test.ts +62 -0
  55. package/src/internal/portable-dereference.ts +67 -0
  56. package/src/url.ts +53 -4
  57. package/dist/tests/portable-dereference-BCfSQoXP.cjs +0 -149
  58. package/dist/tests/portable-dereference-EAbEhAJ4.mjs +0 -132
@@ -1,8 +1,8 @@
1
- const require_request = require("./request-BE3wHjK4.cjs");
2
- const require_body = require("./body-ILOzDJe-.cjs");
1
+ const require_request = require("./request-kRkxuOkZ.cjs");
2
+ const require_body = require("./body-edyRdC9n.cjs");
3
3
  const require_contexts = require("./contexts-DizzBjz4.cjs");
4
4
  const require_link = require("./link-DlKm8bEr.cjs");
5
- const require_url = require("./url-Ddeuv0sE.cjs");
5
+ const require_url = require("./url-BNakuZ8k.cjs");
6
6
  let _logtape_logtape = require("@logtape/logtape");
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
8
8
  //#region src/docloader.ts
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
- const require_request = require("./request-BE3wHjK4.cjs");
2
+ const require_request = require("./request-kRkxuOkZ.cjs");
3
3
  const require_contexts = require("./contexts-DizzBjz4.cjs");
4
- const require_url = require("./url-Ddeuv0sE.cjs");
5
- const require_docloader = require("./docloader-CZ-W5dIM.cjs");
4
+ const require_url = require("./url-BNakuZ8k.cjs");
5
+ const require_docloader = require("./docloader-DVikRN3s.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-DkiHcgVt.mjs";
1
+ import { t as FetchError } from "./request-D-SOvXf_.mjs";
2
2
  import { n as cid_v1_default, t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
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-PCF1uReU.mjs";
3
+ import { n as UrlError } from "./url-DMxmp7ZG.mjs";
4
+ import { i as withDocumentLoaderTimeout, n as getRemoteDocument, r as resolveDocumentLoaderTimeout, t as getDocumentLoader } from "./docloader-DS598-E-.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
- const require_url = require("../url-Ddeuv0sE.cjs");
2
- const require_jsonld_cache = require("../jsonld-cache-CMzevnnN.cjs");
3
- const require_portable_dereference = require("../portable-dereference-BCfSQoXP.cjs");
1
+ const require_url = require("../url-BNakuZ8k.cjs");
2
+ const require_jsonld_cache = require("../jsonld-cache-C07AyNOY.cjs");
3
+ const require_portable_dereference = require("../portable-dereference-BNXtgg5U.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
@@ -56,6 +56,34 @@ const hrefs = (urls) => urls.map((url) => url.href);
56
56
  4
57
57
  ].map((i) => `https://g${i}.example/`));
58
58
  });
59
+ (0, node_test.test)("getReferrerGateways() takes gateways from the owner", () => {
60
+ const actor = {
61
+ id: require_url.parseIri("ap://did:key:z6Mkabc/actor"),
62
+ gateways: [
63
+ new URL("https://a.example"),
64
+ new URL("https://a.example/"),
65
+ new URL("https://b.example/path"),
66
+ new URL("https://c.example")
67
+ ]
68
+ };
69
+ const outbox = { id: require_url.parseIri("ap://did:key:z6Mkabc/actor/outbox") };
70
+ require_portable_dereference.recordPortableReferrer(actor, outbox, "outbox");
71
+ const page = require_url.parseIri("ap://did:key:z6Mkabc/actor/outbox?cursor=1");
72
+ (0, node_assert_strict.deepStrictEqual)(hrefs(require_portable_dereference.getReferrerGateways(actor, outbox.id) ?? []), ["https://a.example/", "https://c.example/"]);
73
+ (0, node_assert_strict.deepStrictEqual)(hrefs(require_portable_dereference.getReferrerGateways(outbox, page) ?? []), ["https://a.example/", "https://c.example/"]);
74
+ (0, node_assert_strict.deepStrictEqual)(require_portable_dereference.getReferrerGateways(outbox, require_url.withGatewayHints(page, [new URL("https://hint.example")])), void 0);
75
+ (0, node_assert_strict.deepStrictEqual)(require_portable_dereference.getReferrerGateways(outbox, require_url.parseIri("ap://did:key:z6Mkdef/notes/1")), void 0);
76
+ const compatible = {
77
+ id: new URL("https://a.example/.well-known/apgateway/did:key:z6Mkabc/actor"),
78
+ gateways: [new URL("https://a.example")]
79
+ };
80
+ (0, node_assert_strict.deepStrictEqual)(hrefs(require_portable_dereference.getReferrerGateways(compatible, outbox.id) ?? []), ["https://a.example/"]);
81
+ (0, node_assert_strict.deepStrictEqual)(require_portable_dereference.getReferrerGateways({}, page), void 0);
82
+ (0, node_assert_strict.deepStrictEqual)(require_portable_dereference.getReferrerGateways({
83
+ id: actor.id,
84
+ gateways: []
85
+ }, page), void 0);
86
+ });
59
87
  (0, node_test.test)("createSnapshotContextLoader() does not nest released snapshots", async () => {
60
88
  const calls = [];
61
89
  const base = (url) => {
@@ -1,6 +1,6 @@
1
- import { S as withGatewayHints, _ as parseIri } from "../url-ClVBNQup.mjs";
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";
1
+ import { S as withGatewayHints, _ as parseIri } from "../url-DMxmp7ZG.mjs";
2
+ import { n as createScopedContextLoader } from "../jsonld-cache-BPQmOZWD.mjs";
3
+ import { a as recordPortableReferrer, i as isPortableIri, n as getPortableGatewayCandidates, r as getReferrerGateways, t as createSnapshotContextLoader } from "../portable-dereference-DRE5bz-l.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
@@ -56,6 +56,34 @@ test("getPortableGatewayCandidates() reads hints from withGatewayHints()", () =>
56
56
  4
57
57
  ].map((i) => `https://g${i}.example/`));
58
58
  });
59
+ test("getReferrerGateways() takes gateways from the owner", () => {
60
+ const actor = {
61
+ id: parseIri("ap://did:key:z6Mkabc/actor"),
62
+ gateways: [
63
+ new URL("https://a.example"),
64
+ new URL("https://a.example/"),
65
+ new URL("https://b.example/path"),
66
+ new URL("https://c.example")
67
+ ]
68
+ };
69
+ const outbox = { id: parseIri("ap://did:key:z6Mkabc/actor/outbox") };
70
+ recordPortableReferrer(actor, outbox, "outbox");
71
+ const page = parseIri("ap://did:key:z6Mkabc/actor/outbox?cursor=1");
72
+ deepStrictEqual(hrefs(getReferrerGateways(actor, outbox.id) ?? []), ["https://a.example/", "https://c.example/"]);
73
+ deepStrictEqual(hrefs(getReferrerGateways(outbox, page) ?? []), ["https://a.example/", "https://c.example/"]);
74
+ deepStrictEqual(getReferrerGateways(outbox, withGatewayHints(page, [new URL("https://hint.example")])), void 0);
75
+ deepStrictEqual(getReferrerGateways(outbox, parseIri("ap://did:key:z6Mkdef/notes/1")), void 0);
76
+ const compatible = {
77
+ id: new URL("https://a.example/.well-known/apgateway/did:key:z6Mkabc/actor"),
78
+ gateways: [new URL("https://a.example")]
79
+ };
80
+ deepStrictEqual(hrefs(getReferrerGateways(compatible, outbox.id) ?? []), ["https://a.example/"]);
81
+ deepStrictEqual(getReferrerGateways({}, page), void 0);
82
+ deepStrictEqual(getReferrerGateways({
83
+ id: actor.id,
84
+ gateways: []
85
+ }, page), void 0);
86
+ });
59
87
  test("createSnapshotContextLoader() does not nest released snapshots", async () => {
60
88
  const calls = [];
61
89
  const base = (url) => {
@@ -1,4 +1,4 @@
1
- import { _ as parseIri, c as getFe34Origin, d as haveSameIriOrigin, o as formatIri, s as fromCompatibleEf61Id, 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-DMxmp7ZG.mjs";
2
2
  import jsonld from "jsonld/dist/jsonld.esm.js";
3
3
  //#region src/jsonld.ts
4
4
  var jsonld_default = jsonld;
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
- const require_url = require("./url-Ddeuv0sE.cjs");
2
+ const require_url = require("./url-BNakuZ8k.cjs");
3
3
  let jsonld_dist_jsonld_esm_js = require("jsonld/dist/jsonld.esm.js");
4
4
  jsonld_dist_jsonld_esm_js = require_rolldown_runtime.__toESM(jsonld_dist_jsonld_esm_js, 1);
5
5
  //#region src/jsonld.ts
@@ -1,5 +1,5 @@
1
- const require_url = require("./url-Ddeuv0sE.cjs");
2
- const require_jsonld_cache = require("./jsonld-cache-CMzevnnN.cjs");
1
+ const require_url = require("./url-BNakuZ8k.cjs");
2
+ const require_jsonld_cache = require("./jsonld-cache-C07AyNOY.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
@@ -1,5 +1,5 @@
1
- import { _ as parseIri } from "./url-ClVBNQup.mjs";
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";
1
+ import { _ as parseIri } from "./url-DMxmp7ZG.mjs";
2
+ import { a as isTrustedIriOrigin, i as getPortableActorGateways, l as jsonld_default, o as normalizeJsonLdIris, r as getJsonLdContext, t as compactJsonLdCache } from "./jsonld-cache-BPQmOZWD.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
@@ -0,0 +1,278 @@
1
+ const require_contexts = require("./contexts-DizzBjz4.cjs");
2
+ const require_url = require("./url-BNakuZ8k.cjs");
3
+ const require_jsonld_cache = require("./jsonld-cache-C07AyNOY.cjs");
4
+ let _logtape_logtape = require("@logtape/logtape");
5
+ require("@opentelemetry/api");
6
+ //#region src/internal/portable-dereference.ts
7
+ const logger = (0, _logtape_logtape.getLogger)([
8
+ "fedify",
9
+ "vocab",
10
+ "gateway"
11
+ ]);
12
+ /**
13
+ * The maximum number of `@gateway` location hints to try for one reference.
14
+ * Hints come from possibly untrusted documents, so they are bounded to keep
15
+ * a single accessor call from fanning out to many servers.
16
+ */
17
+ const MAX_GATEWAY_HINTS = 5;
18
+ const BASELINE_CONTEXT_URLS = /* @__PURE__ */ new Set([
19
+ "https://w3id.org/identity/v1",
20
+ "https://www.w3.org/ns/activitystreams",
21
+ "https://w3id.org/security/v1",
22
+ "https://w3id.org/security/data-integrity/v1"
23
+ ]);
24
+ const provenances = /* @__PURE__ */ new WeakMap();
25
+ function getObjectId(object) {
26
+ if (object == null || typeof object !== "object" || !("id" in object)) return null;
27
+ const id = object.id;
28
+ return id instanceof URL ? id : null;
29
+ }
30
+ /**
31
+ * Checks whether a vocabulary object is part of a chain of portable objects,
32
+ * i.e., whether it has a portable ID, has an FEP-ef61 compatible identifier
33
+ * as its ID (even a malformed one, so that it fails closed), or was obtained
34
+ * from a portable object. Accessors of such objects dereference references
35
+ * as portable objects.
36
+ *
37
+ * Being part of a chain does not mean that the object itself is verified:
38
+ * an object parsed from arbitrary JSON-LD is in a chain just because of its
39
+ * ID. Only {@link dereferencePortableIri} records that an object was
40
+ * accepted by a verifier.
41
+ *
42
+ * @internal Technically exported for generated vocabulary classes, but not
43
+ * part of the public API contract. This is not considered public API for
44
+ * Semantic Versioning decisions.
45
+ */
46
+ function isInPortableChain(object) {
47
+ if (provenances.has(object)) return true;
48
+ const id = getObjectId(object);
49
+ return id != null && (isPortableIri(id) || isCompatibleEf61Iri(id));
50
+ }
51
+ /**
52
+ * Checks whether a URL is an FEP-ef61 compatible identifier, i.e., an HTTP(S)
53
+ * URL under a gateway's `/.well-known/apgateway/` path that stands for
54
+ * a portable object. Malformed compatible identifiers count as compatible
55
+ * identifiers too.
56
+ *
57
+ * @internal Technically exported for generated vocabulary classes, but not
58
+ * part of the public API contract. This is not considered public API for
59
+ * Semantic Versioning decisions.
60
+ */
61
+ function isCompatibleEf61Iri(url) {
62
+ try {
63
+ return require_url.fromCompatibleEf61Id(url) != null;
64
+ } catch (error) {
65
+ if (error instanceof TypeError) return true;
66
+ throw error;
67
+ }
68
+ }
69
+ /**
70
+ * Records that a vocabulary object returned by a property accessor was
71
+ * obtained through the given property of a portable object, so that later
72
+ * dereferences from it can tell where it came from. Nothing is recorded if
73
+ * the parent is not in a portable chain, or if the child already has its
74
+ * provenance.
75
+ *
76
+ * @internal Technically exported for generated vocabulary classes, but not
77
+ * part of the public API contract. This is not considered public API for
78
+ * Semantic Versioning decisions.
79
+ */
80
+ function recordPortableReferrer(parent, child, property) {
81
+ if (child == null || typeof child !== "object") return;
82
+ if (provenances.has(child) || !isInPortableChain(parent)) return;
83
+ provenances.set(child, { referrer: {
84
+ object: parent,
85
+ property
86
+ } });
87
+ }
88
+ /**
89
+ * Checks whether a URL is an FEP-ef61 portable ActivityPub IRI.
90
+ *
91
+ * @internal Technically exported for generated vocabulary classes, but not
92
+ * part of the public API contract. This is not considered public API for
93
+ * Semantic Versioning decisions.
94
+ */
95
+ function isPortableIri(url) {
96
+ return url.protocol === "ap+ef61:" || url.protocol === "ap:";
97
+ }
98
+ /**
99
+ * Picks the ordered list of FEP-ef61 gateways to fetch a portable IRI from.
100
+ *
101
+ * If `gateways` is given, it is used as is (even when empty), and `@gateway`
102
+ * location hints in the IRI are ignored. Otherwise, up to
103
+ * {@link MAX_GATEWAY_HINTS} valid `@gateway` hints are used. Duplicate
104
+ * gateways are dropped in both cases.
105
+ *
106
+ * @throws {TypeError} If an explicit gateway is not an HTTP(S) origin.
107
+ * @internal
108
+ */
109
+ function getPortableGatewayCandidates(url, gateways) {
110
+ const candidates = [];
111
+ const seen = /* @__PURE__ */ new Set();
112
+ const add = (gateway) => {
113
+ if (seen.has(gateway.href)) return;
114
+ seen.add(gateway.href);
115
+ candidates.push(gateway);
116
+ };
117
+ if (gateways != null) {
118
+ for (const gateway of gateways) {
119
+ const parsed = require_url.parseGatewayOrigin(gateway);
120
+ if (parsed == null) throw new TypeError("FEP-ef61 gateways must be HTTP(S) origins with no credentials, path, query, or fragment: " + String(gateway));
121
+ add(parsed);
122
+ }
123
+ return candidates;
124
+ }
125
+ for (const hint of new URLSearchParams(url.search).getAll(require_url.GATEWAY_HINT_PARAMETER)) {
126
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
127
+ const parsed = require_url.parseGatewayOrigin(hint);
128
+ if (parsed == null) {
129
+ logger.debug("Ignoring an invalid FEP-ef61 gateway hint {hint} in {url}.", {
130
+ hint,
131
+ url: require_url.formatIri(url)
132
+ });
133
+ continue;
134
+ }
135
+ add(parsed);
136
+ }
137
+ return candidates;
138
+ }
139
+ /**
140
+ * Gets the gateways through which a portable reference without location hints
141
+ * can be dereferenced, from the portable actor that the reference belongs to.
142
+ *
143
+ * The references in a portable actor's own document, such as its `outbox`,
144
+ * usually have no `@gateway` hints, as they are not needed there, since
145
+ * the actor's `gateways` already tells where to retrieve them. So this walks
146
+ * from the object whose property is being dereferenced up through the objects
147
+ * it was obtained from, e.g., from a collection page to the collection and
148
+ * then to the actor, and returns the `gateways` of the first object that has
149
+ * any, but only if that object has the same DID as the reference. The
150
+ * gateways only tell where to look; whatever they serve is still verified.
151
+ *
152
+ * @param object The object whose property is being dereferenced.
153
+ * @param url The portable IRI to dereference.
154
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
155
+ * the IRI has valid `@gateway` hints or no such object is found.
156
+ * @internal Technically exported for generated vocabulary classes, but not
157
+ * part of the public API contract. This is not considered public API for
158
+ * Semantic Versioning decisions.
159
+ */
160
+ function getReferrerGateways(object, url) {
161
+ if (getPortableGatewayCandidates(url).length > 0) return void 0;
162
+ const visited = /* @__PURE__ */ new Set();
163
+ let current = object;
164
+ while (current != null && !visited.has(current)) {
165
+ visited.add(current);
166
+ const gateways = "gateways" in current ? current.gateways : void 0;
167
+ if (Array.isArray(gateways) && gateways.length > 0) {
168
+ const id = getObjectId(current);
169
+ const portableId = id == null ? null : isPortableIri(id) ? id : getCompatibleEf61Target(id);
170
+ if (portableId == null || !require_url.haveSameFe34Origin(portableId, url)) return;
171
+ const candidates = [];
172
+ for (const gateway of gateways) {
173
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
174
+ if (typeof gateway !== "string" && !(gateway instanceof URL)) continue;
175
+ const parsed = require_url.parseGatewayOrigin(gateway);
176
+ if (parsed == null) continue;
177
+ if (candidates.some((c) => c.href === parsed.href)) continue;
178
+ candidates.push(parsed);
179
+ }
180
+ return candidates.length > 0 ? candidates : void 0;
181
+ }
182
+ current = provenances.get(current)?.referrer?.object;
183
+ }
184
+ }
185
+ function getCompatibleEf61Target(id) {
186
+ try {
187
+ return require_url.fromCompatibleEf61Id(id);
188
+ } catch {
189
+ return null;
190
+ }
191
+ }
192
+ /**
193
+ * Creates a context loader that returns the same context documents for the
194
+ * whole dereference operation, so that the identity check, the proof
195
+ * verifier, and the parser interpret the fetched document identically even
196
+ * if the underlying loader is nondeterministic. Failed loads are not
197
+ * remembered, so a transient failure does not affect the next gateway.
198
+ *
199
+ * The parsed object keeps the loader for its own later dereferences, so
200
+ * `release()` turns it into a plain pass-through to the underlying loader
201
+ * once the operation is over.
202
+ *
203
+ * @internal Technically exported for generated vocabulary classes, but not
204
+ * part of the public API contract. This is not considered public API for
205
+ * Semantic Versioning decisions.
206
+ */
207
+ function createSnapshotContextLoader(contextLoader, suppressError) {
208
+ contextLoader = require_jsonld_cache.unwrapReleasedDocumentLoader(contextLoader);
209
+ const cache = /* @__PURE__ */ new Map();
210
+ let released = false;
211
+ const release = () => {
212
+ released = true;
213
+ state.released = true;
214
+ cache.clear();
215
+ };
216
+ const loader = async (url, options) => {
217
+ if (released) return await contextLoader(url, options);
218
+ const key = URL.canParse(url) ? new URL(url).href : url;
219
+ if (BASELINE_CONTEXT_URLS.has(key)) return {
220
+ contextUrl: null,
221
+ document: structuredClone(require_contexts.preloadedContexts[key]),
222
+ documentUrl: key
223
+ };
224
+ let promise = cache.get(key);
225
+ if (promise == null) {
226
+ const loading = contextLoader(url, suppressError ? {
227
+ ...options,
228
+ suppressError: true
229
+ } : options).then((document) => structuredClone(document));
230
+ promise = loading;
231
+ cache.set(key, loading);
232
+ loading.catch(() => {
233
+ if (cache.get(key) === loading) cache.delete(key);
234
+ });
235
+ }
236
+ return structuredClone(await promise);
237
+ };
238
+ const state = {
239
+ base: contextLoader,
240
+ released: false
241
+ };
242
+ require_jsonld_cache.registerDocumentLoaderWrapper(loader, state);
243
+ return {
244
+ loader,
245
+ release
246
+ };
247
+ }
248
+ //#endregion
249
+ Object.defineProperty(exports, "createSnapshotContextLoader", {
250
+ enumerable: true,
251
+ get: function() {
252
+ return createSnapshotContextLoader;
253
+ }
254
+ });
255
+ Object.defineProperty(exports, "getPortableGatewayCandidates", {
256
+ enumerable: true,
257
+ get: function() {
258
+ return getPortableGatewayCandidates;
259
+ }
260
+ });
261
+ Object.defineProperty(exports, "getReferrerGateways", {
262
+ enumerable: true,
263
+ get: function() {
264
+ return getReferrerGateways;
265
+ }
266
+ });
267
+ Object.defineProperty(exports, "isPortableIri", {
268
+ enumerable: true,
269
+ get: function() {
270
+ return isPortableIri;
271
+ }
272
+ });
273
+ Object.defineProperty(exports, "recordPortableReferrer", {
274
+ enumerable: true,
275
+ get: function() {
276
+ return recordPortableReferrer;
277
+ }
278
+ });