@fedify/vocab-runtime 2.4.0-dev.1583 → 2.4.0-dev.1599

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.4.0-dev.1583+1a6f31cb",
3
+ "version": "2.4.0-dev.1599+7b19967f",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
@@ -1,6 +1,6 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_url = require("../url-BAdyyqAa.cjs");
3
+ const require_url = require("../url-BMDN9GnE.cjs");
4
4
  const require_jsonld = require("../jsonld.cjs");
5
5
  //#region src/internal/jsonld-cache.ts
6
6
  const noJsonLdContext = Symbol("noJsonLdContext");
@@ -1,5 +1,5 @@
1
1
 
2
- import { i as haveSameIriOrigin, r as formatIri } from "../url-BuxPHxK2.js";
2
+ import { a as formatIri, o as haveSameIriOrigin } from "../url-BlFta-Eh.js";
3
3
  import jsonld_default from "../jsonld.js";
4
4
  //#region src/internal/jsonld-cache.ts
5
5
  const noJsonLdContext = Symbol("noJsonLdContext");
package/dist/mod.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_chunk = require("./chunk-M78iaK0I.cjs");
4
- const require_url = require("./url-BAdyyqAa.cjs");
4
+ const require_url = require("./url-BMDN9GnE.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let _opentelemetry_api = require("@opentelemetry/api");
7
7
  let node_process = require("node:process");
@@ -4367,7 +4367,7 @@ const preloadedContexts = {
4367
4367
  //#endregion
4368
4368
  //#region deno.json
4369
4369
  var name = "@fedify/vocab-runtime";
4370
- var version = "2.4.0-dev.1583+1a6f31cb";
4370
+ var version = "2.4.0-dev.1599+7b19967f";
4371
4371
  //#endregion
4372
4372
  //#region src/link.ts
4373
4373
  const parametersNeedLowerCase = ["rel", "type"];
@@ -5551,7 +5551,9 @@ LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_d
5551
5551
  exports.FetchError = FetchError;
5552
5552
  exports.LanguageString = LanguageString;
5553
5553
  exports.UrlError = require_url.UrlError;
5554
+ exports.arePortableUrisEqual = require_url.arePortableUrisEqual;
5554
5555
  exports.canParseDecimal = canParseDecimal;
5556
+ exports.canonicalizePortableUri = require_url.canonicalizePortableUri;
5555
5557
  exports.createActivityPubRequest = createActivityPubRequest;
5556
5558
  exports.decodeMultibase = decodeMultibase;
5557
5559
  exports.encodeMultibase = encodeMultibase;
package/dist/mod.d.cts CHANGED
@@ -326,6 +326,33 @@ declare function parseIri(iri: string | URL, base?: string | URL): URL;
326
326
  */
327
327
  declare function formatIri(iri: string | URL): string;
328
328
  /**
329
+ * Canonicalizes a FEP-ef61 portable ActivityPub URI for comparison.
330
+ *
331
+ * This accepts both `ap:` and `ap+ef61:` URI strings with decoded or
332
+ * percent-encoded DID authorities. The returned value uses the `ap+ef61:`
333
+ * scheme, a decoded DID authority, and no query component. Pass the raw URI
334
+ * string, not a `URL` object, because JavaScript `URL` normalizes opaque path
335
+ * segments before Fedify can compare them.
336
+ *
337
+ * @param input The raw portable ActivityPub URI string to canonicalize.
338
+ * @returns The canonical portable ActivityPub URI string.
339
+ * @throws {TypeError} If the input is not a valid portable ActivityPub IRI.
340
+ * @since 2.4.0
341
+ */
342
+ declare function canonicalizePortableUri(input: string): string;
343
+ /**
344
+ * Checks whether two FEP-ef61 portable ActivityPub URIs identify the same
345
+ * portable object.
346
+ *
347
+ * Non-string inputs return `false`. Non-portable URI strings use strict string
348
+ * equality. Portable URI strings are compared through
349
+ * {@link canonicalizePortableUri}; malformed portable URI strings return
350
+ * `false` unless they are exactly equal.
351
+ *
352
+ * @since 2.4.0
353
+ */
354
+ declare function arePortableUrisEqual(left: string, right: string): boolean;
355
+ /**
329
356
  * Checks whether two IRIs have the same origin.
330
357
  */
331
358
  declare function haveSameIriOrigin(left: URL, right: URL): boolean;
@@ -337,4 +364,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
337
364
  declare function isValidPublicIPv6Address(address: string): boolean;
338
365
  declare function expandIPv6Address(address: string): string;
339
366
  //#endregion
340
- export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
367
+ export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
package/dist/mod.d.ts CHANGED
@@ -326,6 +326,33 @@ declare function parseIri(iri: string | URL, base?: string | URL): URL;
326
326
  */
327
327
  declare function formatIri(iri: string | URL): string;
328
328
  /**
329
+ * Canonicalizes a FEP-ef61 portable ActivityPub URI for comparison.
330
+ *
331
+ * This accepts both `ap:` and `ap+ef61:` URI strings with decoded or
332
+ * percent-encoded DID authorities. The returned value uses the `ap+ef61:`
333
+ * scheme, a decoded DID authority, and no query component. Pass the raw URI
334
+ * string, not a `URL` object, because JavaScript `URL` normalizes opaque path
335
+ * segments before Fedify can compare them.
336
+ *
337
+ * @param input The raw portable ActivityPub URI string to canonicalize.
338
+ * @returns The canonical portable ActivityPub URI string.
339
+ * @throws {TypeError} If the input is not a valid portable ActivityPub IRI.
340
+ * @since 2.4.0
341
+ */
342
+ declare function canonicalizePortableUri(input: string): string;
343
+ /**
344
+ * Checks whether two FEP-ef61 portable ActivityPub URIs identify the same
345
+ * portable object.
346
+ *
347
+ * Non-string inputs return `false`. Non-portable URI strings use strict string
348
+ * equality. Portable URI strings are compared through
349
+ * {@link canonicalizePortableUri}; malformed portable URI strings return
350
+ * `false` unless they are exactly equal.
351
+ *
352
+ * @since 2.4.0
353
+ */
354
+ declare function arePortableUrisEqual(left: string, right: string): boolean;
355
+ /**
329
356
  * Checks whether two IRIs have the same origin.
330
357
  */
331
358
  declare function haveSameIriOrigin(left: URL, right: URL): boolean;
@@ -337,4 +364,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
337
364
  declare function isValidPublicIPv6Address(address: string): boolean;
338
365
  declare function expandIPv6Address(address: string): string;
339
366
  //#endregion
340
- export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
367
+ export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
package/dist/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as isValidPublicIPv4Address, c as parseJsonLdId, i as haveSameIriOrigin, l as validatePublicUrl, n as expandIPv6Address, o as isValidPublicIPv6Address, r as formatIri, s as parseIri, t as UrlError } from "./url-BuxPHxK2.js";
2
+ import { a as formatIri, c as isValidPublicIPv6Address, d as validatePublicUrl, i as expandIPv6Address, l as parseIri, n as arePortableUrisEqual, o as haveSameIriOrigin, r as canonicalizePortableUri, s as isValidPublicIPv4Address, t as UrlError, u as parseJsonLdId } from "./url-BlFta-Eh.js";
3
3
  import { getLogger } from "@logtape/logtape";
4
4
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
5
5
  import process from "node:process";
@@ -4363,7 +4363,7 @@ const preloadedContexts = {
4363
4363
  //#endregion
4364
4364
  //#region deno.json
4365
4365
  var name = "@fedify/vocab-runtime";
4366
- var version = "2.4.0-dev.1583+1a6f31cb";
4366
+ var version = "2.4.0-dev.1599+7b19967f";
4367
4367
  //#endregion
4368
4368
  //#region src/link.ts
4369
4369
  const parametersNeedLowerCase = ["rel", "type"];
@@ -5544,4 +5544,4 @@ LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_d
5544
5544
  return `<${this.locale.baseName}> ${inspect(this.toString(), options)}`;
5545
5545
  };
5546
5546
  //#endregion
5547
- export { FetchError, LanguageString, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
5547
+ export { FetchError, LanguageString, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
@@ -1,6 +1,6 @@
1
1
  require("./chunk-C2EiDwsr.cjs");
2
- require("./docloader-CSsDIyQU.cjs");
3
- require("./url-2XwVbUS_.cjs");
2
+ require("./docloader-BiSxywul.cjs");
3
+ require("./url-CtKcX6ma.cjs");
4
4
  require("./key-_wXwomh_.cjs");
5
5
  require("./multibase-Bz_UUDtL.cjs");
6
6
  require("./langstr-CbAxaeEZ.cjs");
@@ -1,5 +1,5 @@
1
- import "./docloader-z8KkbO2O.mjs";
2
- import "./url-YWJbnRlf.mjs";
1
+ import "./docloader-CDde_fhH.mjs";
2
+ import "./url-D7ay_5pk.mjs";
3
3
  import "./key-CDGDH_vC.mjs";
4
4
  import "./multibase-B4bvakyA.mjs";
5
5
  import "./langstr-Di5AvKpB.mjs";
@@ -1,7 +1,7 @@
1
1
  require("./chunk-C2EiDwsr.cjs");
2
- const require_request = require("./request-DpegHvk6.cjs");
2
+ const require_request = require("./request-C9VKqYdG.cjs");
3
3
  const require_link = require("./link-FguCydMA.cjs");
4
- const require_url = require("./url-2XwVbUS_.cjs");
4
+ const require_url = require("./url-CtKcX6ma.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let _opentelemetry_api = require("@opentelemetry/api");
7
7
  //#endregion
@@ -1,6 +1,6 @@
1
- import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-CLZQgTNJ.mjs";
1
+ import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-BBw3lNNz.mjs";
2
2
  import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
3
- import { l as validatePublicUrl, t as UrlError } from "./url-YWJbnRlf.mjs";
3
+ import { d as validatePublicUrl, t as UrlError } from "./url-D7ay_5pk.mjs";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
6
6
  //#endregion
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-C2EiDwsr.cjs");
2
- const require_docloader = require("./docloader-CSsDIyQU.cjs");
3
- const require_request = require("./request-DpegHvk6.cjs");
4
- const require_url = require("./url-2XwVbUS_.cjs");
2
+ const require_docloader = require("./docloader-BiSxywul.cjs");
3
+ const require_request = require("./request-C9VKqYdG.cjs");
4
+ const require_url = require("./url-CtKcX6ma.cjs");
5
5
  let node_assert = require("node:assert");
6
6
  let node_test = require("node:test");
7
7
  //#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
@@ -1,6 +1,6 @@
1
- import { n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-z8KkbO2O.mjs";
2
- import { t as FetchError } from "./request-CLZQgTNJ.mjs";
3
- import { t as UrlError } from "./url-YWJbnRlf.mjs";
1
+ import { n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-CDde_fhH.mjs";
2
+ import { t as FetchError } from "./request-BBw3lNNz.mjs";
3
+ import { t as UrlError } from "./url-D7ay_5pk.mjs";
4
4
  import { deepStrictEqual, ok, rejects } from "node:assert";
5
5
  import { test } from "node:test";
6
6
  //#region \0rolldown/runtime.js
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-C2EiDwsr.cjs");
2
- const require_url = require("./url-2XwVbUS_.cjs");
2
+ const require_url = require("./url-CtKcX6ma.cjs");
3
3
  let node_assert = require("node:assert");
4
4
  let node_test = require("node:test");
5
5
  let jsonld_dist_jsonld_esm_js = require("jsonld/dist/jsonld.esm.js");
@@ -1,4 +1,4 @@
1
- import { i as haveSameIriOrigin, r as formatIri, s as parseIri } from "./url-YWJbnRlf.mjs";
1
+ import { a as formatIri, l as parseIri, o as haveSameIriOrigin } from "./url-D7ay_5pk.mjs";
2
2
  import { deepStrictEqual, ok, strictEqual } from "node:assert";
3
3
  import { test } from "node:test";
4
4
  import jsonld from "jsonld/dist/jsonld.esm.js";
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  //#region deno.json
3
3
  var name = "@fedify/vocab-runtime";
4
- var version = "2.4.0-dev.1583+1a6f31cb";
4
+ var version = "2.4.0-dev.1599+7b19967f";
5
5
  //#endregion
6
6
  //#region src/request.ts
7
7
  /**
@@ -3,7 +3,7 @@ let node_process = require("node:process");
3
3
  node_process = require_chunk.__toESM(node_process, 1);
4
4
  //#region deno.json
5
5
  var name = "@fedify/vocab-runtime";
6
- var version = "2.4.0-dev.1583+1a6f31cb";
6
+ var version = "2.4.0-dev.1599+7b19967f";
7
7
  //#endregion
8
8
  //#region src/request.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-C2EiDwsr.cjs");
2
- const require_request = require("./request-DpegHvk6.cjs");
2
+ const require_request = require("./request-C9VKqYdG.cjs");
3
3
  let node_assert = require("node:assert");
4
4
  let node_test = require("node:test");
5
5
  let node_process = require("node:process");
@@ -1,4 +1,4 @@
1
- import { o as version, r as getUserAgent } from "./request-CLZQgTNJ.mjs";
1
+ import { o as version, r as getUserAgent } from "./request-BBw3lNNz.mjs";
2
2
  import { deepStrictEqual } from "node:assert";
3
3
  import { test } from "node:test";
4
4
  import process from "node:process";
@@ -10,6 +10,7 @@ var UrlError = class extends Error {
10
10
  };
11
11
  const PORTABLE_IRI_PATTERN = /^(ap|ap\+ef61):\/\/([^/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/i;
12
12
  const INVALID_PERCENT_ENCODING_PATTERN = /%(?![0-9A-Fa-f]{2})/;
13
+ const PERCENT_ENCODING_PATTERN = /%[0-9A-Fa-f]{2}/g;
13
14
  const DID_SCHEME_PATTERN = /^did:/i;
14
15
  const DID_PATTERN = /^did:[a-z0-9]+:[-A-Za-z0-9._%]+(?::[-A-Za-z0-9._%]+)*$/i;
15
16
  /**
@@ -44,6 +45,49 @@ function formatIri(iri) {
44
45
  return `ap+ef61://${decodePortableAuthority(parsed.host)}${parsed.pathname}${parsed.search}${parsed.hash}`;
45
46
  }
46
47
  /**
48
+ * Canonicalizes a FEP-ef61 portable ActivityPub URI for comparison.
49
+ *
50
+ * This accepts both `ap:` and `ap+ef61:` URI strings with decoded or
51
+ * percent-encoded DID authorities. The returned value uses the `ap+ef61:`
52
+ * scheme, a decoded DID authority, and no query component. Pass the raw URI
53
+ * string, not a `URL` object, because JavaScript `URL` normalizes opaque path
54
+ * segments before Fedify can compare them.
55
+ *
56
+ * @param input The raw portable ActivityPub URI string to canonicalize.
57
+ * @returns The canonical portable ActivityPub URI string.
58
+ * @throws {TypeError} If the input is not a valid portable ActivityPub IRI.
59
+ * @since 2.4.0
60
+ */
61
+ function canonicalizePortableUri(input) {
62
+ if (typeof input !== "string") throw new TypeError("Invalid portable ActivityPub IRI.");
63
+ const parsed = parsePortableIri(input);
64
+ if (parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
65
+ const match = input.match(PORTABLE_IRI_PATTERN);
66
+ return `ap+ef61://${normalizePortableAuthority(decodePortableAuthority(parsed.host).replace(DID_SCHEME_PATTERN, "did:"))}${normalizePortableComponent(match[3])}${match[5] == null ? "" : normalizePortableComponent(match[5])}`;
67
+ }
68
+ /**
69
+ * Checks whether two FEP-ef61 portable ActivityPub URIs identify the same
70
+ * portable object.
71
+ *
72
+ * Non-string inputs return `false`. Non-portable URI strings use strict string
73
+ * equality. Portable URI strings are compared through
74
+ * {@link canonicalizePortableUri}; malformed portable URI strings return
75
+ * `false` unless they are exactly equal.
76
+ *
77
+ * @since 2.4.0
78
+ */
79
+ function arePortableUrisEqual(left, right) {
80
+ if (typeof left !== "string" || typeof right !== "string") return false;
81
+ if (left === right) return true;
82
+ if (!PORTABLE_IRI_PATTERN.test(left) || !PORTABLE_IRI_PATTERN.test(right)) return false;
83
+ try {
84
+ return canonicalizePortableUri(left) === canonicalizePortableUri(right);
85
+ } catch (error) {
86
+ if (error instanceof TypeError) return false;
87
+ throw error;
88
+ }
89
+ }
90
+ /**
47
91
  * Checks whether two IRIs have the same origin.
48
92
  */
49
93
  function haveSameIriOrigin(left, right) {
@@ -86,6 +130,31 @@ function decodePortableAuthority(authority) {
86
130
  if (INVALID_PERCENT_ENCODING_PATTERN.test(decoded)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
87
131
  return decoded;
88
132
  }
133
+ function normalizePercentEncoding(value) {
134
+ return value.replace(PERCENT_ENCODING_PATTERN, (match) => match.toUpperCase());
135
+ }
136
+ function normalizePortableAuthority(authority) {
137
+ return normalizePercentEncoding(authority).replace(PERCENT_ENCODING_PATTERN, (match) => {
138
+ const decoded = String.fromCharCode(Number.parseInt(match.slice(1), 16));
139
+ return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : match;
140
+ });
141
+ }
142
+ function normalizePortableComponent(value) {
143
+ if (INVALID_PERCENT_ENCODING_PATTERN.test(value)) throw new TypeError("Invalid portable ActivityPub IRI component.");
144
+ return value.replace(/%[0-9A-Fa-f]{2}|[^%]+/g, (match) => {
145
+ if (match.startsWith("%")) {
146
+ const upper = match.toUpperCase();
147
+ const decoded = String.fromCharCode(Number.parseInt(upper.slice(1), 16));
148
+ return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : upper;
149
+ }
150
+ try {
151
+ return encodeURI(match);
152
+ } catch (error) {
153
+ if (error instanceof URIError) throw new TypeError("Invalid portable ActivityPub IRI component.");
154
+ throw error;
155
+ }
156
+ });
157
+ }
89
158
  function parseAtUri(uri) {
90
159
  const index = uri.indexOf("/", 5);
91
160
  const authority = index >= 0 ? uri.slice(5, index) : uri.slice(5);
@@ -264,6 +333,18 @@ Object.defineProperty(exports, "UrlError", {
264
333
  return UrlError;
265
334
  }
266
335
  });
336
+ Object.defineProperty(exports, "arePortableUrisEqual", {
337
+ enumerable: true,
338
+ get: function() {
339
+ return arePortableUrisEqual;
340
+ }
341
+ });
342
+ Object.defineProperty(exports, "canonicalizePortableUri", {
343
+ enumerable: true,
344
+ get: function() {
345
+ return canonicalizePortableUri;
346
+ }
347
+ });
267
348
  Object.defineProperty(exports, "expandIPv6Address", {
268
349
  enumerable: true,
269
350
  get: function() {
@@ -9,6 +9,7 @@ var UrlError = class extends Error {
9
9
  };
10
10
  const PORTABLE_IRI_PATTERN = /^(ap|ap\+ef61):\/\/([^/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/i;
11
11
  const INVALID_PERCENT_ENCODING_PATTERN = /%(?![0-9A-Fa-f]{2})/;
12
+ const PERCENT_ENCODING_PATTERN = /%[0-9A-Fa-f]{2}/g;
12
13
  const DID_SCHEME_PATTERN = /^did:/i;
13
14
  const DID_PATTERN = /^did:[a-z0-9]+:[-A-Za-z0-9._%]+(?::[-A-Za-z0-9._%]+)*$/i;
14
15
  /**
@@ -43,6 +44,49 @@ function formatIri(iri) {
43
44
  return `ap+ef61://${decodePortableAuthority(parsed.host)}${parsed.pathname}${parsed.search}${parsed.hash}`;
44
45
  }
45
46
  /**
47
+ * Canonicalizes a FEP-ef61 portable ActivityPub URI for comparison.
48
+ *
49
+ * This accepts both `ap:` and `ap+ef61:` URI strings with decoded or
50
+ * percent-encoded DID authorities. The returned value uses the `ap+ef61:`
51
+ * scheme, a decoded DID authority, and no query component. Pass the raw URI
52
+ * string, not a `URL` object, because JavaScript `URL` normalizes opaque path
53
+ * segments before Fedify can compare them.
54
+ *
55
+ * @param input The raw portable ActivityPub URI string to canonicalize.
56
+ * @returns The canonical portable ActivityPub URI string.
57
+ * @throws {TypeError} If the input is not a valid portable ActivityPub IRI.
58
+ * @since 2.4.0
59
+ */
60
+ function canonicalizePortableUri(input) {
61
+ if (typeof input !== "string") throw new TypeError("Invalid portable ActivityPub IRI.");
62
+ const parsed = parsePortableIri(input);
63
+ if (parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
64
+ const match = input.match(PORTABLE_IRI_PATTERN);
65
+ return `ap+ef61://${normalizePortableAuthority(decodePortableAuthority(parsed.host).replace(DID_SCHEME_PATTERN, "did:"))}${normalizePortableComponent(match[3])}${match[5] == null ? "" : normalizePortableComponent(match[5])}`;
66
+ }
67
+ /**
68
+ * Checks whether two FEP-ef61 portable ActivityPub URIs identify the same
69
+ * portable object.
70
+ *
71
+ * Non-string inputs return `false`. Non-portable URI strings use strict string
72
+ * equality. Portable URI strings are compared through
73
+ * {@link canonicalizePortableUri}; malformed portable URI strings return
74
+ * `false` unless they are exactly equal.
75
+ *
76
+ * @since 2.4.0
77
+ */
78
+ function arePortableUrisEqual(left, right) {
79
+ if (typeof left !== "string" || typeof right !== "string") return false;
80
+ if (left === right) return true;
81
+ if (!PORTABLE_IRI_PATTERN.test(left) || !PORTABLE_IRI_PATTERN.test(right)) return false;
82
+ try {
83
+ return canonicalizePortableUri(left) === canonicalizePortableUri(right);
84
+ } catch (error) {
85
+ if (error instanceof TypeError) return false;
86
+ throw error;
87
+ }
88
+ }
89
+ /**
46
90
  * Checks whether two IRIs have the same origin.
47
91
  */
48
92
  function haveSameIriOrigin(left, right) {
@@ -85,6 +129,31 @@ function decodePortableAuthority(authority) {
85
129
  if (INVALID_PERCENT_ENCODING_PATTERN.test(decoded)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
86
130
  return decoded;
87
131
  }
132
+ function normalizePercentEncoding(value) {
133
+ return value.replace(PERCENT_ENCODING_PATTERN, (match) => match.toUpperCase());
134
+ }
135
+ function normalizePortableAuthority(authority) {
136
+ return normalizePercentEncoding(authority).replace(PERCENT_ENCODING_PATTERN, (match) => {
137
+ const decoded = String.fromCharCode(Number.parseInt(match.slice(1), 16));
138
+ return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : match;
139
+ });
140
+ }
141
+ function normalizePortableComponent(value) {
142
+ if (INVALID_PERCENT_ENCODING_PATTERN.test(value)) throw new TypeError("Invalid portable ActivityPub IRI component.");
143
+ return value.replace(/%[0-9A-Fa-f]{2}|[^%]+/g, (match) => {
144
+ if (match.startsWith("%")) {
145
+ const upper = match.toUpperCase();
146
+ const decoded = String.fromCharCode(Number.parseInt(upper.slice(1), 16));
147
+ return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : upper;
148
+ }
149
+ try {
150
+ return encodeURI(match);
151
+ } catch (error) {
152
+ if (error instanceof URIError) throw new TypeError("Invalid portable ActivityPub IRI component.");
153
+ throw error;
154
+ }
155
+ });
156
+ }
88
157
  function parseAtUri(uri) {
89
158
  const index = uri.indexOf("/", 5);
90
159
  const authority = index >= 0 ? uri.slice(5, index) : uri.slice(5);
@@ -257,4 +326,4 @@ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
257
326
  return true;
258
327
  }
259
328
  //#endregion
260
- export { isValidPublicIPv4Address as a, parseJsonLdId as c, haveSameIriOrigin as i, validatePublicUrl as l, expandIPv6Address as n, isValidPublicIPv6Address as o, formatIri as r, parseIri as s, UrlError as t };
329
+ export { formatIri as a, isValidPublicIPv6Address as c, validatePublicUrl as d, expandIPv6Address as i, parseIri as l, arePortableUrisEqual as n, haveSameIriOrigin as o, canonicalizePortableUri as r, isValidPublicIPv4Address as s, UrlError as t, parseJsonLdId as u };
@@ -1,5 +1,5 @@
1
1
  require("./chunk-C2EiDwsr.cjs");
2
- const require_url = require("./url-2XwVbUS_.cjs");
2
+ const require_url = require("./url-CtKcX6ma.cjs");
3
3
  let node_assert = require("node:assert");
4
4
  let node_test = require("node:test");
5
5
  //#region src/url.test.ts
@@ -76,6 +76,86 @@ let node_test = require("node:test");
76
76
  (0, node_assert.deepStrictEqual)(require_url.formatIri(new URL("https://example.com/actor")), "https://example.com/actor");
77
77
  (0, node_assert.deepStrictEqual)(require_url.formatIri("/actor"), "/actor");
78
78
  });
79
+ (0, node_test.test)("canonicalizePortableUri() emits comparison forms", () => {
80
+ for (const iri of [
81
+ "ap://did:key:z6Mkabc/actor",
82
+ "ap://did%3Akey%3Az6Mkabc/actor",
83
+ "ap://did:key:z6Mkabc/actor?gateways=https%3A%2F%2Fa.example",
84
+ "ap+ef61://did:key:z6Mkabc/actor",
85
+ "ap+ef61://did%3Akey%3Az6Mkabc/actor?gateways=https%3A%2F%2Fa.example"
86
+ ]) (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri(iri), "ap+ef61://did:key:z6Mkabc/actor");
87
+ });
88
+ (0, node_test.test)("canonicalizePortableUri() preserves paths and fragments", () => {
89
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/objects/1/attachments/2?gateways=https%3A%2F%2Fa.example#image"), "ap+ef61://did:key:z6Mkabc/objects/1/attachments/2#image");
90
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/objects/1#reply"), "ap+ef61://did:key:z6Mkabc/objects/1#reply");
91
+ });
92
+ (0, node_test.test)("canonicalizePortableUri() preserves DID-internal pct-encoded characters", () => {
93
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:example:abc%2Fdef/actor?x=1"), "ap+ef61://did:example:abc%2Fdef/actor");
94
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did%3Aweb%3Aexample.com%253A3000/u/1"), "ap+ef61://did:web:example.com%3A3000/u/1");
95
+ });
96
+ (0, node_test.test)("canonicalizePortableUri() normalizes authority pct-encoding casing", () => {
97
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:example:abc%2fdef/actor"), "ap+ef61://did:example:abc%2Fdef/actor");
98
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:example:abc%2fdef%3abar/actor"), "ap+ef61://did:example:abc%2Fdef%3Abar/actor");
99
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did%3Aexample%3Aabc%252fdef/actor"), "ap+ef61://did:example:abc%2Fdef/actor");
100
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did%3Akey%3Az6Mk%2Dabc/actor"), "ap+ef61://did:key:z6Mk-abc/actor");
101
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did:example:abc%2fdef/actor", "ap://did:example:abc%2Fdef/actor"));
102
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did%3Akey%3Az6Mk%2Dabc/actor", "ap://did:key:z6Mk-abc/actor"));
103
+ });
104
+ (0, node_test.test)("canonicalizePortableUri() normalizes path and fragment pct-encoding casing", () => {
105
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/actor%2fprofile#part%2ftwo"), "ap+ef61://did:key:z6Mkabc/actor%2Fprofile#part%2Ftwo");
106
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/actor%2fprofile%3aimage"), "ap+ef61://did:key:z6Mkabc/actor%2Fprofile%3Aimage");
107
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/actor%2Dprofile#part%7Etwo"), "ap+ef61://did:key:z6Mkabc/actor-profile#part~two");
108
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor%2fprofile#part%2ftwo", "ap://did:key:z6Mkabc/actor%2Fprofile#part%2Ftwo"));
109
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor%2Dprofile#part%7Etwo", "ap://did:key:z6Mkabc/actor-profile#part~two"));
110
+ });
111
+ (0, node_test.test)("canonicalizePortableUri() encodes raw path and fragment characters", () => {
112
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/é#é"), "ap+ef61://did:key:z6Mkabc/%C3%A9#%C3%A9");
113
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/é#é", "ap://did:key:z6Mkabc/%C3%A9#%C3%A9"));
114
+ });
115
+ (0, node_test.test)("canonicalizePortableUri() normalizes DID scheme casing", () => {
116
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://DID:key:z6Mkabc/actor"), "ap+ef61://did:key:z6Mkabc/actor");
117
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://DID%3Akey%3Az6Mkabc/actor"), "ap+ef61://did:key:z6Mkabc/actor");
118
+ });
119
+ (0, node_test.test)("canonicalizePortableUri() preserves opaque path segments", () => {
120
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/a/../b?gateways=x"), "ap+ef61://did:key:z6Mkabc/a/../b");
121
+ (0, node_assert.deepStrictEqual)(require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/a/%2e%2e/b"), "ap+ef61://did:key:z6Mkabc/a/../b");
122
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/a/../b", "ap://did:key:z6Mkabc/b"));
123
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/a/%2e%2e/b", "ap://did:key:z6Mkabc/b"));
124
+ });
125
+ (0, node_test.test)("canonicalizePortableUri() rejects non-portable URIs", () => {
126
+ for (const iri of [
127
+ "https://example.com/actor",
128
+ "at://did:plc:example/record",
129
+ "/actor",
130
+ "ap://not-a-did/actor",
131
+ "ap://did:key:z6Mkabc"
132
+ ]) (0, node_assert.throws)(() => require_url.canonicalizePortableUri(iri), TypeError);
133
+ (0, node_assert.throws)(() => require_url.canonicalizePortableUri(new URL("ap+ef61://did%3Akey%3Az6Mkabc/actor")), TypeError);
134
+ });
135
+ (0, node_test.test)("canonicalizePortableUri() rejects invalid path and fragment pct-encoding", () => {
136
+ (0, node_assert.throws)(() => require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/a%zz"), TypeError);
137
+ (0, node_assert.throws)(() => require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/actor#part%zz"), TypeError);
138
+ (0, node_assert.throws)(() => require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/\ud800"), TypeError);
139
+ (0, node_assert.throws)(() => require_url.canonicalizePortableUri("ap://did:key:z6Mkabc/actor#\ud800"), TypeError);
140
+ });
141
+ (0, node_test.test)("arePortableUrisEqual() compares canonical portable URI forms", () => {
142
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor", "ap+ef61://did%3Akey%3Az6Mkabc/actor?gateways=https%3A%2F%2Fa.example"));
143
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://DID:key:z6Mkabc/actor", "ap://did:key:z6Mkabc/actor"));
144
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor", "ap://did:key:z6Mkdef/actor"));
145
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor", "ap://did:key:z6Mkabc/outbox"));
146
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor#one", "ap://did:key:z6Mkabc/actor#two"));
147
+ });
148
+ (0, node_test.test)("arePortableUrisEqual() handles non-portable URI strings", () => {
149
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("https://example.com/actor", "https://example.com/actor"));
150
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("https://example.com/actor", "https://example.com/outbox"));
151
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor", "https://example.com/actor"));
152
+ (0, node_assert.ok)(require_url.arePortableUrisEqual("ap://not-a-did/actor", "ap://not-a-did/actor"));
153
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://not-a-did/actor", "ap://not-a-did/outbox"));
154
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://not-a-did/actor", "ap://did:key:z6Mkabc/actor"));
155
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/a%zz", "ap://did:key:z6Mkabc/a%25zz"));
156
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/\ud800", "ap://did:key:z6Mkabc/%EF%BF%BD"));
157
+ (0, node_assert.ok)(!require_url.arePortableUrisEqual("ap://did:key:z6Mkabc/actor#\ud800", "ap://did:key:z6Mkabc/actor#%EF%BF%BD"));
158
+ });
79
159
  (0, node_test.test)("formatIri() preserves DID authority pct-encoded delimiters", () => {
80
160
  const parsed = require_url.parseIri("ap://did:example:abc%2Fdef/actor");
81
161
  (0, node_assert.deepStrictEqual)(parsed, new URL("ap+ef61://did%3Aexample%3Aabc%252Fdef/actor"));