@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
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.4.0-dev.2256+683c50ba",
3
+ "version": "2.4.0-dev.2260+42356e7d",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
@@ -104,6 +104,7 @@ interface DocumentLoaderOptions {
104
104
  * Whether to lower error-level logs for recoverable document loading
105
105
  * failures to warning-level logs. The loader still throws the error.
106
106
  * @default `false`
107
+ * @since 2.4.0
107
108
  */
108
109
  suppressError?: boolean;
109
110
  }
@@ -104,6 +104,7 @@ interface DocumentLoaderOptions {
104
104
  * Whether to lower error-level logs for recoverable document loading
105
105
  * failures to warning-level logs. The loader still throws the error.
106
106
  * @default `false`
107
+ * @since 2.4.0
107
108
  */
108
109
  suppressError?: boolean;
109
110
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_url = require("../url-DKA6dTWV.cjs");
3
+ const require_url = require("../url-DrGTR8yv.cjs");
4
4
  const require_jsonld = require("../jsonld.cjs");
5
5
  //#region src/internal/jsonld-cache.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "../docloader-C63enuyr.cjs";
2
+ import { n as DocumentLoader } from "../docloader-CYwqh5Df.cjs";
3
3
 
4
4
  //#region src/internal/jsonld-cache.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "../docloader-C63enuyr.js";
2
+ import { n as DocumentLoader } from "../docloader-CYwqh5Df.js";
3
3
 
4
4
  //#region src/internal/jsonld-cache.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
 
2
- import { _ as parseIri, c as getFe34Origin, d as haveSameIriOrigin, o as formatIri, s as fromCompatibleEf61Id, 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-Dzyp-NsC.js";
3
3
  import jsonld_default from "../jsonld.js";
4
4
  //#region src/internal/jsonld-cache.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_contexts = require("../contexts-BK1CqBR5.cjs");
4
- const require_url = require("../url-DKA6dTWV.cjs");
4
+ const require_url = require("../url-DrGTR8yv.cjs");
5
5
  const require_jsonld = require("../jsonld.cjs");
6
6
  const require_internal_jsonld_cache = require("./jsonld-cache.cjs");
7
7
  let _logtape_logtape = require("@logtape/logtape");
@@ -376,6 +376,59 @@ function getPortableGatewayCandidates(url, gateways) {
376
376
  return candidates;
377
377
  }
378
378
  /**
379
+ * Gets the gateways through which a portable reference without location hints
380
+ * can be dereferenced, from the portable actor that the reference belongs to.
381
+ *
382
+ * The references in a portable actor's own document, such as its `outbox`,
383
+ * usually have no `@gateway` hints, as they are not needed there, since
384
+ * the actor's `gateways` already tells where to retrieve them. So this walks
385
+ * from the object whose property is being dereferenced up through the objects
386
+ * it was obtained from, e.g., from a collection page to the collection and
387
+ * then to the actor, and returns the `gateways` of the first object that has
388
+ * any, but only if that object has the same DID as the reference. The
389
+ * gateways only tell where to look; whatever they serve is still verified.
390
+ *
391
+ * @param object The object whose property is being dereferenced.
392
+ * @param url The portable IRI to dereference.
393
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
394
+ * the IRI has valid `@gateway` hints or no such object is found.
395
+ * @internal Technically exported for generated vocabulary classes, but not
396
+ * part of the public API contract. This is not considered public API for
397
+ * Semantic Versioning decisions.
398
+ */
399
+ function getReferrerGateways(object, url) {
400
+ if (getPortableGatewayCandidates(url).length > 0) return void 0;
401
+ const visited = /* @__PURE__ */ new Set();
402
+ let current = object;
403
+ while (current != null && !visited.has(current)) {
404
+ visited.add(current);
405
+ const gateways = "gateways" in current ? current.gateways : void 0;
406
+ if (Array.isArray(gateways) && gateways.length > 0) {
407
+ const id = getObjectId(current);
408
+ const portableId = id == null ? null : isPortableIri(id) ? id : getCompatibleEf61Target(id);
409
+ if (portableId == null || !require_url.haveSameFe34Origin(portableId, url)) return;
410
+ const candidates = [];
411
+ for (const gateway of gateways) {
412
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
413
+ if (typeof gateway !== "string" && !(gateway instanceof URL)) continue;
414
+ const parsed = require_url.parseGatewayOrigin(gateway);
415
+ if (parsed == null) continue;
416
+ if (candidates.some((c) => c.href === parsed.href)) continue;
417
+ candidates.push(parsed);
418
+ }
419
+ return candidates.length > 0 ? candidates : void 0;
420
+ }
421
+ current = provenances.get(current)?.referrer?.object;
422
+ }
423
+ }
424
+ function getCompatibleEf61Target(id) {
425
+ try {
426
+ return require_url.fromCompatibleEf61Id(id);
427
+ } catch {
428
+ return null;
429
+ }
430
+ }
431
+ /**
379
432
  * Creates a context loader that returns the same context documents for the
380
433
  * whole dereference operation, so that the identity check, the proof
381
434
  * verifier, and the parser interpret the fetched document identically even
@@ -653,6 +706,7 @@ exports.createSnapshotContextLoader = createSnapshotContextLoader;
653
706
  exports.dereferencePortableIri = dereferencePortableIri;
654
707
  exports.getPortableGatewayCandidates = getPortableGatewayCandidates;
655
708
  exports.getPortableResponseClaim = getPortableResponseClaim;
709
+ exports.getReferrerGateways = getReferrerGateways;
656
710
  exports.isCompatibleEf61Iri = isCompatibleEf61Iri;
657
711
  exports.isInPortableChain = isInPortableChain;
658
712
  exports.isPortableIri = isPortableIri;
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader, s as RemoteDocument } from "../docloader-C63enuyr.cjs";
3
- import { r as PortableObjectVerifier } from "../portable-Cux3IA20.cjs";
2
+ import { n as DocumentLoader, s as RemoteDocument } from "../docloader-CYwqh5Df.cjs";
3
+ import { r as PortableObjectVerifier } from "../portable-DqtfLy_1.cjs";
4
4
  import { Span, TracerProvider } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/internal/portable-dereference.d.ts
@@ -230,6 +230,28 @@ declare function isPortableIri(url: URL): boolean;
230
230
  */
231
231
  declare function getPortableGatewayCandidates(url: URL, gateways?: readonly (string | URL)[]): URL[];
232
232
  /**
233
+ * Gets the gateways through which a portable reference without location hints
234
+ * can be dereferenced, from the portable actor that the reference belongs to.
235
+ *
236
+ * The references in a portable actor's own document, such as its `outbox`,
237
+ * usually have no `@gateway` hints, as they are not needed there, since
238
+ * the actor's `gateways` already tells where to retrieve them. So this walks
239
+ * from the object whose property is being dereferenced up through the objects
240
+ * it was obtained from, e.g., from a collection page to the collection and
241
+ * then to the actor, and returns the `gateways` of the first object that has
242
+ * any, but only if that object has the same DID as the reference. The
243
+ * gateways only tell where to look; whatever they serve is still verified.
244
+ *
245
+ * @param object The object whose property is being dereferenced.
246
+ * @param url The portable IRI to dereference.
247
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
248
+ * the IRI has valid `@gateway` hints or no such object is found.
249
+ * @internal Technically exported for generated vocabulary classes, but not
250
+ * part of the public API contract. This is not considered public API for
251
+ * Semantic Versioning decisions.
252
+ */
253
+ declare function getReferrerGateways(object: object, url: URL): URL[] | undefined;
254
+ /**
233
255
  * Creates a context loader that returns the same context documents for the
234
256
  * whole dereference operation, so that the identity check, the proof
235
257
  * verifier, and the parser interpret the fetched document identically even
@@ -324,4 +346,4 @@ declare function dereferencePortableIri<T extends {
324
346
  id: URL | null;
325
347
  }>(url: URL, options: DereferencePortableIriOptions<T>): Promise<T | null>;
326
348
  //#endregion
327
- export { DereferencePortableIriOptions, PortableObjectRejectedError, PortableReferrerLink, PortableResponseClaim, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
349
+ export { DereferencePortableIriOptions, PortableObjectRejectedError, PortableReferrerLink, PortableResponseClaim, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, getReferrerGateways, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader, s as RemoteDocument } from "../docloader-C63enuyr.js";
3
- import { r as PortableObjectVerifier } from "../portable-DBA1FS_L.js";
2
+ import { n as DocumentLoader, s as RemoteDocument } from "../docloader-CYwqh5Df.js";
3
+ import { r as PortableObjectVerifier } from "../portable-DtWsu2yU.js";
4
4
  import { Span, TracerProvider } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/internal/portable-dereference.d.ts
@@ -230,6 +230,28 @@ declare function isPortableIri(url: URL): boolean;
230
230
  */
231
231
  declare function getPortableGatewayCandidates(url: URL, gateways?: readonly (string | URL)[]): URL[];
232
232
  /**
233
+ * Gets the gateways through which a portable reference without location hints
234
+ * can be dereferenced, from the portable actor that the reference belongs to.
235
+ *
236
+ * The references in a portable actor's own document, such as its `outbox`,
237
+ * usually have no `@gateway` hints, as they are not needed there, since
238
+ * the actor's `gateways` already tells where to retrieve them. So this walks
239
+ * from the object whose property is being dereferenced up through the objects
240
+ * it was obtained from, e.g., from a collection page to the collection and
241
+ * then to the actor, and returns the `gateways` of the first object that has
242
+ * any, but only if that object has the same DID as the reference. The
243
+ * gateways only tell where to look; whatever they serve is still verified.
244
+ *
245
+ * @param object The object whose property is being dereferenced.
246
+ * @param url The portable IRI to dereference.
247
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
248
+ * the IRI has valid `@gateway` hints or no such object is found.
249
+ * @internal Technically exported for generated vocabulary classes, but not
250
+ * part of the public API contract. This is not considered public API for
251
+ * Semantic Versioning decisions.
252
+ */
253
+ declare function getReferrerGateways(object: object, url: URL): URL[] | undefined;
254
+ /**
233
255
  * Creates a context loader that returns the same context documents for the
234
256
  * whole dereference operation, so that the identity check, the proof
235
257
  * verifier, and the parser interpret the fetched document identically even
@@ -324,4 +346,4 @@ declare function dereferencePortableIri<T extends {
324
346
  id: URL | null;
325
347
  }>(url: URL, options: DereferencePortableIriOptions<T>): Promise<T | null>;
326
348
  //#endregion
327
- export { DereferencePortableIriOptions, PortableObjectRejectedError, PortableReferrerLink, PortableResponseClaim, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
349
+ export { DereferencePortableIriOptions, PortableObjectRejectedError, PortableReferrerLink, PortableResponseClaim, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, getReferrerGateways, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { t as preloadedContexts } from "../contexts-DPuJ4UYL.js";
3
- import { _ as parseIri, h as parseGatewayOrigin, i as canonicalizePortableUri, o as formatIri, s as fromCompatibleEf61Id, t as GATEWAY_HINT_PARAMETER, u as haveSameFe34Origin, y as toCompatibleEf61Id } from "../url-Cr9lJ6cD.js";
3
+ import { _ as parseIri, h as parseGatewayOrigin, i as canonicalizePortableUri, o as formatIri, s as fromCompatibleEf61Id, t as GATEWAY_HINT_PARAMETER, u as haveSameFe34Origin, y as toCompatibleEf61Id } from "../url-Dzyp-NsC.js";
4
4
  import jsonld_default from "../jsonld.js";
5
5
  import { createScopedContextLoader, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader } from "./jsonld-cache.js";
6
6
  import { getLogger } from "@logtape/logtape";
@@ -375,6 +375,59 @@ function getPortableGatewayCandidates(url, gateways) {
375
375
  return candidates;
376
376
  }
377
377
  /**
378
+ * Gets the gateways through which a portable reference without location hints
379
+ * can be dereferenced, from the portable actor that the reference belongs to.
380
+ *
381
+ * The references in a portable actor's own document, such as its `outbox`,
382
+ * usually have no `@gateway` hints, as they are not needed there, since
383
+ * the actor's `gateways` already tells where to retrieve them. So this walks
384
+ * from the object whose property is being dereferenced up through the objects
385
+ * it was obtained from, e.g., from a collection page to the collection and
386
+ * then to the actor, and returns the `gateways` of the first object that has
387
+ * any, but only if that object has the same DID as the reference. The
388
+ * gateways only tell where to look; whatever they serve is still verified.
389
+ *
390
+ * @param object The object whose property is being dereferenced.
391
+ * @param url The portable IRI to dereference.
392
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
393
+ * the IRI has valid `@gateway` hints or no such object is found.
394
+ * @internal Technically exported for generated vocabulary classes, but not
395
+ * part of the public API contract. This is not considered public API for
396
+ * Semantic Versioning decisions.
397
+ */
398
+ function getReferrerGateways(object, url) {
399
+ if (getPortableGatewayCandidates(url).length > 0) return void 0;
400
+ const visited = /* @__PURE__ */ new Set();
401
+ let current = object;
402
+ while (current != null && !visited.has(current)) {
403
+ visited.add(current);
404
+ const gateways = "gateways" in current ? current.gateways : void 0;
405
+ if (Array.isArray(gateways) && gateways.length > 0) {
406
+ const id = getObjectId(current);
407
+ const portableId = id == null ? null : isPortableIri(id) ? id : getCompatibleEf61Target(id);
408
+ if (portableId == null || !haveSameFe34Origin(portableId, url)) return;
409
+ const candidates = [];
410
+ for (const gateway of gateways) {
411
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
412
+ if (typeof gateway !== "string" && !(gateway instanceof URL)) continue;
413
+ const parsed = parseGatewayOrigin(gateway);
414
+ if (parsed == null) continue;
415
+ if (candidates.some((c) => c.href === parsed.href)) continue;
416
+ candidates.push(parsed);
417
+ }
418
+ return candidates.length > 0 ? candidates : void 0;
419
+ }
420
+ current = provenances.get(current)?.referrer?.object;
421
+ }
422
+ }
423
+ function getCompatibleEf61Target(id) {
424
+ try {
425
+ return fromCompatibleEf61Id(id);
426
+ } catch {
427
+ return null;
428
+ }
429
+ }
430
+ /**
378
431
  * Creates a context loader that returns the same context documents for the
379
432
  * whole dereference operation, so that the identity check, the proof
380
433
  * verifier, and the parser interpret the fetched document identically even
@@ -646,4 +699,4 @@ async function checkPortableObjectId(document, expectedId, contextLoader) {
646
699
  if (actualId !== expectedId) throw new PortableObjectRejection("its @id ({objectId}) does not match the requested portable ID", { objectId: id });
647
700
  }
648
701
  //#endregion
649
- export { PortableObjectRejectedError, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
702
+ export { PortableObjectRejectedError, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, getReferrerGateways, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
package/dist/mod.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_rolldown_runtime = require("./rolldown-runtime-B7lfambq.cjs");
4
4
  const require_contexts = require("./contexts-BK1CqBR5.cjs");
5
- const require_url = require("./url-DKA6dTWV.cjs");
5
+ const require_url = require("./url-DrGTR8yv.cjs");
6
6
  let _logtape_logtape = require("@logtape/logtape");
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
8
8
  let node_process = require("node:process");
@@ -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.2256+683c50ba";
19
+ var version = "2.4.0-dev.2260+42356e7d";
20
20
  //#endregion
21
21
  //#region src/request.ts
22
22
  /**
package/dist/mod.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { _ as logRequest, a as DocumentLoaderOptions, c as getDocumentLoader, d as withDocumentLoaderTimeout, f as CreateRequestOptions, g as getUserAgent, h as createActivityPubRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as GetUserAgentOptions, n as DocumentLoader, o as GetDocumentLoaderOptions, p as FetchError, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as resolveDocumentLoaderTimeout } from "./docloader-C63enuyr.cjs";
3
- import { i as PortableObjectVerifierOptions, n as PortableObjectVerification, r as PortableObjectVerifier, t as PortableObjectReferrer } from "./portable-Cux3IA20.cjs";
2
+ import { _ as logRequest, a as DocumentLoaderOptions, c as getDocumentLoader, d as withDocumentLoaderTimeout, f as CreateRequestOptions, g as getUserAgent, h as createActivityPubRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as GetUserAgentOptions, n as DocumentLoader, o as GetDocumentLoaderOptions, p as FetchError, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as resolveDocumentLoaderTimeout } from "./docloader-CYwqh5Df.cjs";
3
+ import { i as PortableObjectVerifierOptions, n as PortableObjectVerification, r as PortableObjectVerifier, t as PortableObjectReferrer } from "./portable-DqtfLy_1.cjs";
4
4
  import { TracerProvider } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/contexts.d.ts
@@ -462,7 +462,14 @@ declare class UrlError extends Error {
462
462
  });
463
463
  }
464
464
  /**
465
- * Parses a JSON-LD `@id` value as an IRI.
465
+ * Parses a JSON-LD `@id` value as an IRI, including FEP-ef61 portable
466
+ * ActivityPub IRIs. See {@link parseIri} for how IRIs are parsed.
467
+ * @param id The `@id` value.
468
+ * @param base The base IRI to resolve a relative `@id` against.
469
+ * @returns The parsed IRI, or `undefined` if `id` is missing or a blank node
470
+ * identifier.
471
+ * @throws {TypeError} If `id` is not a valid IRI.
472
+ * @since 2.4.0
466
473
  */
467
474
  declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL | undefined;
468
475
  /**
@@ -473,6 +480,16 @@ declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL
473
480
  * This also applies to compatible identifier strings used as relative bases.
474
481
  * A `URL` argument may already have lost such segments before this function
475
482
  * receives it.
483
+ *
484
+ * Portable IRIs, e.g., `ap://did:key:z6Mk.../actor`, cannot be represented by
485
+ * JavaScript `URL` as they are, so the returned `URL` keeps the DID authority
486
+ * percent-encoded, e.g., `ap+ef61://did%3Akey%3Az6Mk.../actor`. Use
487
+ * {@link formatIri} to get the canonical string back.
488
+ * @param iri The IRI to parse.
489
+ * @param base The base IRI to resolve a relative IRI against.
490
+ * @returns The parsed IRI.
491
+ * @throws {TypeError} If the IRI is malformed.
492
+ * @since 2.4.0
476
493
  */
477
494
  declare function parseIri(iri: string | URL, base?: string | URL): URL;
478
495
  /**
@@ -487,6 +504,12 @@ declare function parseIri(iri: string | URL, base?: string | URL): URL;
487
504
  * the scheme this function produces. Do not compare its results as strings to
488
505
  * tell whether two portable IRIs identify the same object; use
489
506
  * `arePortableUrisEqual()` instead.
507
+ * @param iri The IRI to format.
508
+ * @returns The formatted IRI. A string that cannot be parsed as a URL at all
509
+ * is returned unchanged.
510
+ * @throws {TypeError} If the IRI is a malformed portable IRI or FEP-ef61
511
+ * compatible identifier, e.g., one with dot segments.
512
+ * @since 2.4.0
490
513
  */
491
514
  declare function formatIri(iri: string | URL): string;
492
515
  /**
@@ -541,16 +564,42 @@ declare function getFe34Origin(input: string | URL): string;
541
564
  */
542
565
  declare function haveSameFe34Origin(left: string | URL, right: string | URL): boolean;
543
566
  /**
544
- * Checks whether two IRIs have the same origin.
567
+ * Checks whether two IRIs have the same origin. Unlike comparing
568
+ * `URL.origin`, which is `"null"` for URLs with non-special schemes, this
569
+ * compares FEP-ef61 portable ActivityPub IRIs by their schemes and DIDs, so
570
+ * that `ap:` and `ap+ef61:` IRIs of the same DID with decoded or
571
+ * percent-encoded authorities have the same origin. Other IRIs with
572
+ * a non-special scheme and a host are compared by their schemes and hosts.
573
+ *
574
+ * This is not an FEP-fe34 origin check: an `ap+ef61:` IRI and the `did:key`
575
+ * verification method of the same DID have different origins here. Use
576
+ * {@link haveSameFe34Origin} for that.
577
+ * @param left The first IRI.
578
+ * @param right The second IRI.
579
+ * @returns `true` if the IRIs have the same origin.
580
+ * @since 2.4.0
545
581
  */
546
582
  declare function haveSameIriOrigin(left: URL, right: URL): boolean;
547
583
  /**
548
- * Checks whether the URL is an FEP-ef61 gateway base URI.
584
+ * Checks whether the URL is an FEP-ef61 gateway base URI, i.e., an HTTP(S)
585
+ * URI with no credentials, path, query, or fragment, such as
586
+ * `https://example.com/`. FEP-ef61 requires every item of a portable actor's
587
+ * `gateways` to be such a URI. A URI with an empty query or fragment
588
+ * delimiter, such as `https://example.com/?`, is not a gateway base URI.
589
+ *
590
+ * Note that the `URL` class normalizes `https://example.com` to
591
+ * `https://example.com/`, so both are gateway base URIs.
592
+ * @param url The URL to check.
593
+ * @returns `true` if the URL is an FEP-ef61 gateway base URI.
549
594
  * @since 2.4.0
550
595
  */
551
596
  declare function isGatewayUrl(url: URL): boolean;
552
597
  /**
553
- * Parses and validates an FEP-ef61 gateway base URI.
598
+ * Parses and validates an FEP-ef61 gateway base URI, i.e., an HTTP(S) URI with
599
+ * no credentials, path, query, or fragment, such as `https://example.com`.
600
+ * See {@link isGatewayUrl} for the rules.
601
+ * @param url The gateway base URI to parse.
602
+ * @returns The parsed gateway base URI, whose path is `/`.
554
603
  * @throws {TypeError} If the URI is malformed, or is not an HTTP(S) base URI
555
604
  * with no credentials, path, query, or fragment. In the
556
605
  * latter case, the message starts with
package/dist/mod.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { _ as logRequest, a as DocumentLoaderOptions, c as getDocumentLoader, d as withDocumentLoaderTimeout, f as CreateRequestOptions, g as getUserAgent, h as createActivityPubRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as GetUserAgentOptions, n as DocumentLoader, o as GetDocumentLoaderOptions, p as FetchError, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as resolveDocumentLoaderTimeout } from "./docloader-C63enuyr.js";
3
- import { i as PortableObjectVerifierOptions, n as PortableObjectVerification, r as PortableObjectVerifier, t as PortableObjectReferrer } from "./portable-DBA1FS_L.js";
2
+ import { _ as logRequest, a as DocumentLoaderOptions, c as getDocumentLoader, d as withDocumentLoaderTimeout, f as CreateRequestOptions, g as getUserAgent, h as createActivityPubRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as GetUserAgentOptions, n as DocumentLoader, o as GetDocumentLoaderOptions, p as FetchError, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as resolveDocumentLoaderTimeout } from "./docloader-CYwqh5Df.js";
3
+ import { i as PortableObjectVerifierOptions, n as PortableObjectVerification, r as PortableObjectVerifier, t as PortableObjectReferrer } from "./portable-DtWsu2yU.js";
4
4
  import { TracerProvider } from "@opentelemetry/api";
5
5
  //#region src/contexts.d.ts
6
6
  declare const preloadedContexts: Record<string, unknown>;
@@ -461,7 +461,14 @@ declare class UrlError extends Error {
461
461
  });
462
462
  }
463
463
  /**
464
- * Parses a JSON-LD `@id` value as an IRI.
464
+ * Parses a JSON-LD `@id` value as an IRI, including FEP-ef61 portable
465
+ * ActivityPub IRIs. See {@link parseIri} for how IRIs are parsed.
466
+ * @param id The `@id` value.
467
+ * @param base The base IRI to resolve a relative `@id` against.
468
+ * @returns The parsed IRI, or `undefined` if `id` is missing or a blank node
469
+ * identifier.
470
+ * @throws {TypeError} If `id` is not a valid IRI.
471
+ * @since 2.4.0
465
472
  */
466
473
  declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL | undefined;
467
474
  /**
@@ -472,6 +479,16 @@ declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL
472
479
  * This also applies to compatible identifier strings used as relative bases.
473
480
  * A `URL` argument may already have lost such segments before this function
474
481
  * receives it.
482
+ *
483
+ * Portable IRIs, e.g., `ap://did:key:z6Mk.../actor`, cannot be represented by
484
+ * JavaScript `URL` as they are, so the returned `URL` keeps the DID authority
485
+ * percent-encoded, e.g., `ap+ef61://did%3Akey%3Az6Mk.../actor`. Use
486
+ * {@link formatIri} to get the canonical string back.
487
+ * @param iri The IRI to parse.
488
+ * @param base The base IRI to resolve a relative IRI against.
489
+ * @returns The parsed IRI.
490
+ * @throws {TypeError} If the IRI is malformed.
491
+ * @since 2.4.0
475
492
  */
476
493
  declare function parseIri(iri: string | URL, base?: string | URL): URL;
477
494
  /**
@@ -486,6 +503,12 @@ declare function parseIri(iri: string | URL, base?: string | URL): URL;
486
503
  * the scheme this function produces. Do not compare its results as strings to
487
504
  * tell whether two portable IRIs identify the same object; use
488
505
  * `arePortableUrisEqual()` instead.
506
+ * @param iri The IRI to format.
507
+ * @returns The formatted IRI. A string that cannot be parsed as a URL at all
508
+ * is returned unchanged.
509
+ * @throws {TypeError} If the IRI is a malformed portable IRI or FEP-ef61
510
+ * compatible identifier, e.g., one with dot segments.
511
+ * @since 2.4.0
489
512
  */
490
513
  declare function formatIri(iri: string | URL): string;
491
514
  /**
@@ -540,16 +563,42 @@ declare function getFe34Origin(input: string | URL): string;
540
563
  */
541
564
  declare function haveSameFe34Origin(left: string | URL, right: string | URL): boolean;
542
565
  /**
543
- * Checks whether two IRIs have the same origin.
566
+ * Checks whether two IRIs have the same origin. Unlike comparing
567
+ * `URL.origin`, which is `"null"` for URLs with non-special schemes, this
568
+ * compares FEP-ef61 portable ActivityPub IRIs by their schemes and DIDs, so
569
+ * that `ap:` and `ap+ef61:` IRIs of the same DID with decoded or
570
+ * percent-encoded authorities have the same origin. Other IRIs with
571
+ * a non-special scheme and a host are compared by their schemes and hosts.
572
+ *
573
+ * This is not an FEP-fe34 origin check: an `ap+ef61:` IRI and the `did:key`
574
+ * verification method of the same DID have different origins here. Use
575
+ * {@link haveSameFe34Origin} for that.
576
+ * @param left The first IRI.
577
+ * @param right The second IRI.
578
+ * @returns `true` if the IRIs have the same origin.
579
+ * @since 2.4.0
544
580
  */
545
581
  declare function haveSameIriOrigin(left: URL, right: URL): boolean;
546
582
  /**
547
- * Checks whether the URL is an FEP-ef61 gateway base URI.
583
+ * Checks whether the URL is an FEP-ef61 gateway base URI, i.e., an HTTP(S)
584
+ * URI with no credentials, path, query, or fragment, such as
585
+ * `https://example.com/`. FEP-ef61 requires every item of a portable actor's
586
+ * `gateways` to be such a URI. A URI with an empty query or fragment
587
+ * delimiter, such as `https://example.com/?`, is not a gateway base URI.
588
+ *
589
+ * Note that the `URL` class normalizes `https://example.com` to
590
+ * `https://example.com/`, so both are gateway base URIs.
591
+ * @param url The URL to check.
592
+ * @returns `true` if the URL is an FEP-ef61 gateway base URI.
548
593
  * @since 2.4.0
549
594
  */
550
595
  declare function isGatewayUrl(url: URL): boolean;
551
596
  /**
552
- * Parses and validates an FEP-ef61 gateway base URI.
597
+ * Parses and validates an FEP-ef61 gateway base URI, i.e., an HTTP(S) URI with
598
+ * no credentials, path, query, or fragment, such as `https://example.com`.
599
+ * See {@link isGatewayUrl} for the rules.
600
+ * @param url The gateway base URI to parse.
601
+ * @returns The parsed gateway base URI, whose path is `/`.
553
602
  * @throws {TypeError} If the URI is malformed, or is not an HTTP(S) base URI
554
603
  * with no credentials, path, query, or fragment. In the
555
604
  * latter case, the message starts with
package/dist/mod.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { t as preloadedContexts } from "./contexts-DPuJ4UYL.js";
3
- import { S as withoutGatewayHints, _ as parseIri, a as expandIPv6Address, b as validatePublicUrl, c as getFe34Origin, d as haveSameIriOrigin, f as isGatewayUrl, g as parseGatewayUrl, i as canonicalizePortableUri, l as getGatewayHints, m as isValidPublicIPv6Address, n as UrlError, o as formatIri, p as isValidPublicIPv4Address, r as arePortableUrisEqual, s as fromCompatibleEf61Id, u as haveSameFe34Origin, v as parseJsonLdId, x as withGatewayHints, y as toCompatibleEf61Id } from "./url-Cr9lJ6cD.js";
3
+ import { S as withoutGatewayHints, _ as parseIri, a as expandIPv6Address, b as validatePublicUrl, c as getFe34Origin, d as haveSameIriOrigin, f as isGatewayUrl, g as parseGatewayUrl, i as canonicalizePortableUri, l as getGatewayHints, m as isValidPublicIPv6Address, n as UrlError, o as formatIri, p as isValidPublicIPv4Address, r as arePortableUrisEqual, s as fromCompatibleEf61Id, u as haveSameFe34Origin, v as parseJsonLdId, x as withGatewayHints, y as toCompatibleEf61Id } from "./url-Dzyp-NsC.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
6
6
  import process from "node:process";
@@ -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.2256+683c50ba";
15
+ var version = "2.4.0-dev.2260+42356e7d";
16
16
  //#endregion
17
17
  //#region src/request.ts
18
18
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "./docloader-C63enuyr.cjs";
2
+ import { n as DocumentLoader } from "./docloader-CYwqh5Df.cjs";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/portable.d.ts
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "./docloader-C63enuyr.js";
2
+ import { n as DocumentLoader } from "./docloader-CYwqh5Df.js";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/portable.d.ts
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "./request-DkiHcgVt.mjs";
1
+ import { t as FetchError } from "./request-D-SOvXf_.mjs";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  //#region src/body.ts
4
4
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,4 +1,4 @@
1
- const require_request = require("./request-BE3wHjK4.cjs");
1
+ const require_request = require("./request-kRkxuOkZ.cjs");
2
2
  let _logtape_logtape = require("@logtape/logtape");
3
3
  //#region src/body.ts
4
4
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,4 +1,4 @@
1
- const require_body = require("./body-ILOzDJe-.cjs");
1
+ const require_body = require("./body-edyRdC9n.cjs");
2
2
  let node_assert_strict = require("node:assert/strict");
3
3
  let node_test = require("node:test");
4
4
  let node_zlib = require("node:zlib");
@@ -1,4 +1,4 @@
1
- import { i as readBoundedText, t as BodyTooLargeError } from "./body-NALc-7u_.mjs";
1
+ import { i as readBoundedText, t as BodyTooLargeError } from "./body-BbkIKvTI.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
- require("./url-Ddeuv0sE.cjs");
2
- require("./docloader-CZ-W5dIM.cjs");
1
+ require("./url-BNakuZ8k.cjs");
2
+ require("./docloader-DVikRN3s.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-HeXeBuyd.cjs");
7
+ require("./portable-media-BC-QRzPd.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
- import "./url-ClVBNQup.mjs";
2
- import "./docloader-PCF1uReU.mjs";
1
+ import "./url-DMxmp7ZG.mjs";
2
+ import "./docloader-DS598-E-.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-SWj7DacP.mjs";
7
+ import "./portable-media-CP6hh3ja.mjs";
8
8
  import { test } from "node:test";
9
9
  import { deepStrictEqual, throws } from "node:assert";
10
10
  //#region src/decimal.ts
@@ -1,8 +1,8 @@
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";
1
+ import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-D-SOvXf_.mjs";
2
+ import { i as readBoundedText, n as MAX_BODY_SIZE, r as readBoundedBytes, t as BodyTooLargeError } from "./body-BbkIKvTI.mjs";
3
3
  import { t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
4
4
  import { t as HttpHeaderLink } from "./link-Cevmc87v.mjs";
5
- import { n as UrlError, x as validatePublicUrl } from "./url-ClVBNQup.mjs";
5
+ import { n as UrlError, x as validatePublicUrl } from "./url-DMxmp7ZG.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  //#region src/docloader.ts