@fedify/vocab-runtime 2.4.0-dev.2228 → 2.4.0-dev.2240

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 (57) hide show
  1. package/deno.json +2 -2
  2. package/dist/internal/jsonld-cache.cjs +1 -1
  3. package/dist/internal/jsonld-cache.js +1 -1
  4. package/dist/internal/portable-dereference.cjs +6 -18
  5. package/dist/internal/portable-dereference.js +4 -16
  6. package/dist/mod.cjs +5 -2
  7. package/dist/mod.d.cts +107 -4
  8. package/dist/mod.d.ts +107 -4
  9. package/dist/mod.js +3 -3
  10. package/dist/tests/{body-BmNV5g5S.mjs → body-C00dWiYW.mjs} +1 -1
  11. package/dist/tests/{body-BQZL1aJ1.cjs → body-DHk-vT0I.cjs} +1 -1
  12. package/dist/tests/body.test.cjs +1 -1
  13. package/dist/tests/body.test.mjs +1 -1
  14. package/dist/tests/decimal.test.cjs +3 -3
  15. package/dist/tests/decimal.test.mjs +3 -3
  16. package/dist/tests/{docloader-ButlYQxr.mjs → docloader-Bi982uOa.mjs} +3 -3
  17. package/dist/tests/{docloader-BnuGCXLg.cjs → docloader-gX-8knd3.cjs} +3 -3
  18. package/dist/tests/docloader.test.cjs +59 -65
  19. package/dist/tests/docloader.test.mjs +38 -44
  20. package/dist/tests/internal/portable-dereference.test.cjs +30 -157
  21. package/dist/tests/internal/portable-dereference.test.mjs +13 -140
  22. package/dist/tests/{jsonld-cache-C7mkqjiE.mjs → jsonld-cache-CKfgtxPB.mjs} +1 -1
  23. package/dist/tests/{jsonld-cache-CXA76Xi6.cjs → jsonld-cache-DzxT9IXH.cjs} +1 -1
  24. package/dist/tests/jsonld-cache.test.cjs +2 -2
  25. package/dist/tests/jsonld-cache.test.mjs +2 -2
  26. package/dist/tests/multibase/multibase.test.cjs +7 -7
  27. package/dist/tests/multibase/multibase.test.mjs +5 -5
  28. package/dist/tests/portable-dereference-C_cwGjz6.mjs +132 -0
  29. package/dist/tests/portable-dereference-CyFYTBnr.cjs +149 -0
  30. package/dist/tests/{portable-media-CFrGpz-3.cjs → portable-media-B39cvJGK.cjs} +3 -3
  31. package/dist/tests/{portable-media-xFDDMte7.mjs → portable-media-l0ET9Pq8.mjs} +3 -3
  32. package/dist/tests/portable-media.test.cjs +1 -1
  33. package/dist/tests/portable-media.test.mjs +1 -1
  34. package/dist/tests/portable-workers.test.cjs +36 -0
  35. package/dist/tests/portable-workers.test.d.cts +2 -0
  36. package/dist/tests/portable-workers.test.d.mts +2 -0
  37. package/dist/tests/portable-workers.test.mjs +35 -0
  38. package/dist/tests/{request-2GDEEJng.mjs → request-BRPiDcmG.mjs} +1 -1
  39. package/dist/tests/{request-Cme6ShRu.cjs → request-fo2l2yJS.cjs} +1 -1
  40. package/dist/tests/request.test.cjs +1 -1
  41. package/dist/tests/request.test.mjs +1 -1
  42. package/dist/tests/{url-R9TTZ67B.mjs → url-CWC-NI3a.mjs} +224 -8
  43. package/dist/tests/{url-B6WlNhra.cjs → url-DsMBGqCc.cjs} +253 -7
  44. package/dist/tests/url.test.cjs +192 -1
  45. package/dist/tests/url.test.mjs +192 -1
  46. package/dist/{url-CHAbe3hE.cjs → url-BJMXv2kE.cjs} +253 -7
  47. package/dist/{url-BfguNa6K.js → url-CZm2-7ZO.js} +224 -8
  48. package/package.json +6 -3
  49. package/scripts/test-bun.mjs +17 -0
  50. package/src/docloader.test.ts +82 -74
  51. package/src/internal/portable-dereference.test.ts +14 -1
  52. package/src/internal/portable-dereference.ts +5 -19
  53. package/src/mod.ts +3 -0
  54. package/src/multibase/multibase.test.ts +5 -5
  55. package/src/portable-workers.test.ts +81 -0
  56. package/src/url.test.ts +385 -0
  57. package/src/url.ts +347 -13
@@ -20,6 +20,26 @@ const INVALID_PERCENT_ENCODING_PATTERN = /%(?![0-9A-Fa-f]{2})/;
20
20
  const PERCENT_ENCODING_PATTERN = /%[0-9A-Fa-f]{2}/g;
21
21
  const DID_SCHEME_PATTERN = /^did:/i;
22
22
  const DID_PATTERN = /^did:[a-z0-9]+:[-A-Za-z0-9._%]+(?::[-A-Za-z0-9._%]+)*$/i;
23
+ const DOT_SEGMENT_PATTERN = /(?:^|\/)(?:\.|%2e){1,2}(?=\/|$)/i;
24
+ function prepareUrlInput(iri) {
25
+ let prepared = iri.replace(/[\t\n\r]/g, "");
26
+ while (prepared.length > 0 && prepared.charCodeAt(0) <= 32) prepared = prepared.slice(1);
27
+ while (prepared.length > 0 && prepared.charCodeAt(prepared.length - 1) <= 32) prepared = prepared.slice(0, -1);
28
+ return prepared;
29
+ }
30
+ function assertPortablePathCanBeParsed(iri) {
31
+ const match = prepareUrlInput(iri).match(PORTABLE_IRI_PATTERN);
32
+ if (match != null && DOT_SEGMENT_PATTERN.test(match[3])) throw new TypeError("Portable ActivityPub IRI paths with dot segments cannot be represented as URLs.");
33
+ }
34
+ function assertCompatiblePathCanBeParsed(raw, parsed) {
35
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
36
+ const match = prepareUrlInput(raw).match(/^https?:[\/\\]*[^/?#\\]*([^?#]*)/i);
37
+ if (match == null) return;
38
+ const rawPath = match[1].replace(/\\/g, "/");
39
+ const compatiblePath = parsed.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(parsed.pathname.slice(COMPATIBLE_ID_PATH_PREFIX.length));
40
+ const rawCompatiblePath = rawPath.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(rawPath.slice(COMPATIBLE_ID_PATH_PREFIX.length));
41
+ if ((compatiblePath || rawCompatiblePath) && DOT_SEGMENT_PATTERN.test(rawPath)) throw new TypeError("FEP-ef61 compatible identifier paths with dot segments cannot be represented as URLs.");
42
+ }
23
43
  /**
24
44
  * Parses a JSON-LD `@id` value as an IRI.
25
45
  */
@@ -33,22 +53,40 @@ function parseJsonLdId(id, base) {
33
53
  }
34
54
  /**
35
55
  * Parses an IRI as a URL, including FEP-ef61 portable ActivityPub IRIs.
56
+ * Portable URI and FEP-ef61 compatible identifier strings whose path contains
57
+ * a `.` or `..` segment, including percent-encoded spellings, throw a
58
+ * `TypeError`: JavaScript `URL` would otherwise identify a different object.
59
+ * This also applies to compatible identifier strings used as relative bases.
60
+ * A `URL` argument may already have lost such segments before this function
61
+ * receives it.
36
62
  */
37
63
  function parseIri(iri, base) {
38
64
  if (iri instanceof URL) return normalizePortableUrl(iri) ?? new URL(iri.href);
65
+ assertPortablePathCanBeParsed(iri);
39
66
  const portable = parsePortableIri(iri);
40
67
  if (portable != null) return portable;
41
68
  base = normalizeBaseIri(base);
42
69
  if (!URL.canParse(iri, base) && iri.startsWith("at://")) return parseAtUri(iri);
43
70
  const parsed = new URL(iri, base);
71
+ assertCompatiblePathCanBeParsed(iri, parsed);
44
72
  return normalizePortableUrl(parsed) ?? parsed;
45
73
  }
46
74
  /**
47
75
  * Formats a URL as an IRI, including FEP-ef61 portable ActivityPub IRIs.
76
+ * Portable URI and FEP-ef61 compatible identifier strings with dot segments
77
+ * throw a `TypeError` because their paths cannot be represented by JavaScript
78
+ * `URL` without normalization.
48
79
  */
49
80
  function formatIri(iri) {
81
+ if (typeof iri === "string") assertPortablePathCanBeParsed(iri);
50
82
  const parsed = parsePortableIri(iri instanceof URL ? iri.href : iri);
51
- if (parsed == null) return iri instanceof URL ? iri.href : URL.canParse(iri) ? new URL(iri).href : iri;
83
+ if (parsed == null) {
84
+ if (iri instanceof URL) return iri.href;
85
+ if (!URL.canParse(iri)) return iri;
86
+ const url = new URL(iri);
87
+ assertCompatiblePathCanBeParsed(iri, url);
88
+ return url.href;
89
+ }
52
90
  return `ap+ef61://${decodePortableAuthority(parsed.host)}${parsed.pathname}${parsed.search}${parsed.hash}`;
53
91
  }
54
92
  /**
@@ -168,11 +206,15 @@ function parsePortableIri(iri) {
168
206
  }
169
207
  function normalizePortableUrl(iri) {
170
208
  if (iri.protocol !== "ap:" && iri.protocol !== "ap+ef61:") return null;
171
- return parsePortableIri(`ap+ef61://${iri.host}${iri.pathname}${iri.search}${iri.hash}`);
209
+ const raw = `ap+ef61://${iri.host}${iri.pathname}${iri.search}${iri.hash}`;
210
+ assertPortablePathCanBeParsed(raw);
211
+ return parsePortableIri(raw);
172
212
  }
173
213
  function normalizeBaseIri(base) {
174
214
  if (base == null) return void 0;
175
215
  if (base instanceof URL) return normalizePortableUrl(base) ?? base;
216
+ assertPortablePathCanBeParsed(base);
217
+ if (URL.canParse(base)) assertCompatiblePathCanBeParsed(base, new URL(base));
176
218
  return parsePortableIri(base) ?? (base.startsWith("at://") && !URL.canParse(".", base) ? parseAtUri(base) : base);
177
219
  }
178
220
  function decodePortableAuthority(authority) {
@@ -239,6 +281,7 @@ function parseGatewayUrl(url) {
239
281
  }
240
282
  const COMPATIBLE_ID_PATH_PREFIX = "/.well-known/apgateway/";
241
283
  const COMPATIBLE_ID_DID_PATTERN = /^did(?::|%3A)/i;
284
+ const RAW_COMPATIBLE_ID_PREFIX_PATTERN = /^(?:[hH][tT][tT][pP][sS]?):\/\/[^/?#]*\/\.well-known\/apgateway\/(?=[dD][iI][dD](?::|%3[aA]))/;
242
285
  const LOCATION_HINT_PARAMETERS = /* @__PURE__ */ new Set(["@gateway", "gateways"]);
243
286
  /**
244
287
  * Converts an [FEP-ef61] compatible identifier into a portable ActivityPub
@@ -274,8 +317,9 @@ const LOCATION_HINT_PARAMETERS = /* @__PURE__ */ new Set(["@gateway", "gateways"
274
317
  * malformed, e.g., it has an invalid DID, no object path,
275
318
  * invalid percent-encoding, credentials, or location
276
319
  * hints (`@gateway` query parameters, or the legacy
277
- * `gateways` parameter), which FEP-ef61 forbids in
278
- * compatible identifiers.
320
+ * `gateways` parameter), or its raw string path would
321
+ * change during URL parsing. Already-parsed `URL`
322
+ * arguments cannot reveal segments lost by their parser.
279
323
  * @since 2.4.0
280
324
  */
281
325
  function fromCompatibleEf61Id(input) {
@@ -283,18 +327,29 @@ function fromCompatibleEf61Id(input) {
283
327
  }
284
328
  function convertCompatibleEf61Id(input) {
285
329
  let url;
330
+ const rawPrefix = typeof input === "string" ? input.match(RAW_COMPATIBLE_ID_PREFIX_PATTERN) : null;
286
331
  if (input instanceof URL) url = input;
287
332
  else if (typeof input === "string" && URL.canParse(input)) url = new URL(input);
288
333
  else return null;
289
334
  if (url.protocol !== "http:" && url.protocol !== "https:") return null;
290
- if (!url.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX)) return null;
335
+ if (typeof input === "string" && rawPrefix == null) {
336
+ if (url.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(url.pathname.slice(23))) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
337
+ }
338
+ if (!url.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX)) {
339
+ if (rawPrefix != null) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
340
+ return null;
341
+ }
291
342
  const tail = url.pathname.slice(23);
292
- if (!COMPATIBLE_ID_DID_PATTERN.test(tail)) return null;
343
+ if (!COMPATIBLE_ID_DID_PATTERN.test(tail)) {
344
+ if (rawPrefix != null) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
345
+ return null;
346
+ }
293
347
  if (url.username !== "" || url.password !== "") throw new TypeError("Invalid FEP-ef61 compatible identifier: credentials are not allowed.");
294
348
  const iri = "ap+ef61://" + url.href.slice(url.origin.length + 23);
295
349
  try {
296
350
  const parsed = parsePortableIri(iri);
297
351
  if (parsed == null) throw new TypeError("Not a portable IRI.");
352
+ if (typeof input === "string" && rawPrefix != null && canonicalizePortableUri("ap://" + input.slice(rawPrefix[0].length)) !== canonicalizePortableUri(iri)) throw new TypeError("URL parsing changed the portable identifier.");
298
353
  canonicalizePortableUri(iri);
299
354
  if ((url.search === "" ? [] : normalizePortableComponent(url.search.slice(1)).split("&")).some(isLocationHint)) throw new TypeError("Location hints are not allowed.");
300
355
  return {
@@ -334,7 +389,8 @@ function convertCompatibleEf61Id(input) {
334
389
  * @returns The compatible identifier.
335
390
  * @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
336
391
  * URI, if its path has `.` or `..` segments (which
337
- * HTTP(S) URLs cannot represent), or if the gateway is
392
+ * HTTP(S) URLs cannot represent without changing the
393
+ * identified object), or if the gateway is
338
394
  * not an HTTP(S) origin with no credentials, path, query,
339
395
  * or fragment.
340
396
  * @since 2.4.0
@@ -384,6 +440,166 @@ function isLocationHint(pair) {
384
440
  }
385
441
  }
386
442
  /**
443
+ * The name of the FEP-ef61 location hint query parameter.
444
+ * @internal
445
+ */
446
+ const GATEWAY_HINT_PARAMETER = "@gateway";
447
+ /**
448
+ * Parses an FEP-ef61 gateway, which has to be an HTTP(S) origin with no
449
+ * credentials, path, query, or fragment.
450
+ * @returns The gateway, or `null` if it is not a valid gateway.
451
+ * @internal
452
+ */
453
+ function parseGatewayOrigin(gateway) {
454
+ let url;
455
+ if (gateway instanceof URL) url = new URL(gateway.href);
456
+ else if (typeof gateway === "string" && URL.canParse(gateway)) url = new URL(gateway);
457
+ else return null;
458
+ return isGatewayUrl(url) ? url : null;
459
+ }
460
+ /**
461
+ * Returns a copy of an [FEP-ef61] portable ActivityPub URI with `@gateway`
462
+ * location hints for the given gateways, which tell consumers where they can
463
+ * retrieve the object. Put hints on *references* to portable actors, e.g.,
464
+ * in `actor`, `attributedTo`, `to`, or `cc`, when constructing an object, as
465
+ * FEP-ef61 recommends:
466
+ *
467
+ * ~~~~ typescript
468
+ * withGatewayHints("ap://did:key:z6Mk.../actor", [
469
+ * "https://server1.example",
470
+ * "https://server2.example",
471
+ * ]);
472
+ * // ap+ef61://did:key:z6Mk.../actor?@gateway=https%3A%2F%2Fserver1.example&@gateway=https%3A%2F%2Fserver2.example
473
+ * ~~~~
474
+ *
475
+ * Do not put hints on an object's own `id`. Hints do not change the
476
+ * identity of a portable URI, since FEP-ef61 drops the query when comparing
477
+ * portable URIs, but implementations that do not canonicalize portable URIs
478
+ * would take a hinted ID for another object. Add hints before signing the
479
+ * object, since its Object Integrity Proof covers its references too.
480
+ *
481
+ * The hints that the URI already has, including the legacy `gateways`
482
+ * parameter, are replaced. Each gateway becomes a `@gateway` query
483
+ * parameter whose value is its URI-encoded origin, e.g.,
484
+ * `@gateway=https%3A%2F%2Fserver1.example`, in the given order after the
485
+ * other query parameters. Duplicate gateways are dropped, and an empty list
486
+ * removes the hints as {@link withoutGatewayHints} does. The other query
487
+ * parameters, their order, and the fragment are kept, but percent-encoding
488
+ * is normalized the same way as {@link canonicalizePortableUri} does it.
489
+ *
490
+ * Fedify follows at most five hints when dereferencing a portable URI
491
+ * (three for the key ID of an HTTP Signature), so list the preferred
492
+ * gateways first; there is no limit on the number of hints added here.
493
+ *
494
+ * [FEP-ef61]: https://w3id.org/fep/ef61
495
+ *
496
+ * @param portableId The `ap:` or `ap+ef61:` URI. Pass the raw string rather
497
+ * than a `URL` if its path may have `.` or `..` segments,
498
+ * because the `URL` class resolves them.
499
+ * @param gateways The gateways, e.g., the `gateways` of the actor that the
500
+ * URI refers to. Each has to be an HTTP(S) origin with no
501
+ * credentials, path, query, or fragment.
502
+ * @returns The portable URI with the hints, in the same internal `URL` form
503
+ * as {@link parseIri} returns. Use {@link formatIri} to get its
504
+ * canonical string.
505
+ * @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
506
+ * URI, e.g., it is a compatible identifier, which must
507
+ * not have location hints; if its path has `.` or `..`
508
+ * segments, which the `URL` class cannot represent; or
509
+ * if a gateway is invalid.
510
+ * @since 2.4.0
511
+ */
512
+ function withGatewayHints(portableId, gateways) {
513
+ const parts = splitPortableIri(portableId);
514
+ if (typeof gateways === "string") throw new TypeError("The gateways must be an iterable of gateways, not a string.");
515
+ const hints = [];
516
+ const seen = /* @__PURE__ */ new Set();
517
+ for (const gateway of gateways) {
518
+ const url = parseGatewayOrigin(gateway);
519
+ if (url == null) throw new TypeError("FEP-ef61 gateways must be HTTP(S) origins with no credentials, path, query, or fragment: " + String(gateway));
520
+ if (seen.has(url.href)) continue;
521
+ seen.add(url.href);
522
+ hints.push(url);
523
+ }
524
+ return replaceGatewayHints(parts, hints);
525
+ }
526
+ /**
527
+ * Returns a copy of an [FEP-ef61] portable ActivityPub URI without its
528
+ * location hints, i.e., `@gateway` query parameters and the legacy
529
+ * `gateways` parameter. The other query parameters, their order, and the
530
+ * fragment are kept, but percent-encoding is normalized the same way as
531
+ * {@link canonicalizePortableUri} does it.
532
+ *
533
+ * [FEP-ef61]: https://w3id.org/fep/ef61
534
+ *
535
+ * @param portableId The `ap:` or `ap+ef61:` URI. Pass the raw string rather
536
+ * than a `URL` if its path may have `.` or `..` segments,
537
+ * because the `URL` class resolves them.
538
+ * @returns The portable URI without the hints, in the same internal `URL`
539
+ * form as {@link parseIri} returns.
540
+ * @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
541
+ * URI, or if its path has `.` or `..` segments, which
542
+ * the `URL` class cannot represent.
543
+ * @since 2.4.0
544
+ */
545
+ function withoutGatewayHints(portableId) {
546
+ return replaceGatewayHints(splitPortableIri(portableId), []);
547
+ }
548
+ /**
549
+ * Gets the gateways in the `@gateway` location hints of an [FEP-ef61]
550
+ * portable ActivityPub URI, in order. Hints that are not valid gateways,
551
+ * i.e., HTTP(S) origins with no credentials, path, query, or fragment, are
552
+ * skipped, and so are duplicates. The legacy `gateways` parameter is not
553
+ * read.
554
+ *
555
+ * Unlike Fedify's dereferencing, which follows at most five hints, this
556
+ * returns all of them.
557
+ *
558
+ * [FEP-ef61]: https://w3id.org/fep/ef61
559
+ *
560
+ * @param portableId The `ap:` or `ap+ef61:` URI.
561
+ * @returns The gateways, e.g., `https://server1.example/`.
562
+ * @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
563
+ * URI.
564
+ * @since 2.4.0
565
+ */
566
+ function getGatewayHints(portableId) {
567
+ const { query } = splitPortableIri(portableId);
568
+ return query == null ? [] : parseGatewayHints(query);
569
+ }
570
+ function splitPortableIri(portableId) {
571
+ const raw = getRawPortableIri(portableId);
572
+ const match = raw.match(PORTABLE_IRI_PATTERN);
573
+ const parsed = parsePortableIri(raw);
574
+ if (match == null || parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
575
+ return {
576
+ raw,
577
+ parsed,
578
+ path: normalizePortableComponent(match[3]),
579
+ query: match[4] == null ? null : normalizePortableComponent(match[4].slice(1)),
580
+ fragment: match[5] == null ? "" : normalizePortableComponent(match[5])
581
+ };
582
+ }
583
+ function parseGatewayHints(query) {
584
+ const hints = [];
585
+ const seen = /* @__PURE__ */ new Set();
586
+ for (const hint of new URLSearchParams(`?${query}`).getAll(GATEWAY_HINT_PARAMETER)) {
587
+ const url = parseGatewayOrigin(hint);
588
+ if (url == null || seen.has(url.href)) continue;
589
+ seen.add(url.href);
590
+ hints.push(url);
591
+ }
592
+ return hints;
593
+ }
594
+ function replaceGatewayHints(parts, hints) {
595
+ const pairs = parts.query == null ? [] : parts.query.split("&").filter((pair) => pair !== "" && !isLocationHint(pair));
596
+ for (const hint of hints) pairs.push(`${GATEWAY_HINT_PARAMETER}=${encodeURIComponent(hint.origin)}`);
597
+ const query = pairs.length < 1 ? "" : `?${pairs.join("&")}`;
598
+ const result = parsePortableIri(`ap+ef61://${parts.parsed.host}${parts.path}${query}${parts.fragment}`);
599
+ if (result == null || canonicalizePortableUri(result.href) !== canonicalizePortableUri(parts.raw) || parseGatewayHints(result.search.slice(1)).map((url) => url.href).join(" ") !== hints.map((url) => url.href).join(" ")) throw new TypeError("The portable ActivityPub IRI cannot be represented as a URL without changing the object it refers to.");
600
+ return result;
601
+ }
602
+ /**
387
603
  * Validates a URL to prevent SSRF attacks.
388
604
  */
389
605
  async function validatePublicUrl(url) {
@@ -579,4 +795,4 @@ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
579
795
  return true;
580
796
  }
581
797
  //#endregion
582
- export { validatePublicUrl as _, formatIri as a, haveSameFe34Origin as c, isValidPublicIPv4Address as d, isValidPublicIPv6Address as f, toCompatibleEf61Id as g, parseJsonLdId as h, expandIPv6Address as i, haveSameIriOrigin as l, parseIri as m, arePortableUrisEqual as n, fromCompatibleEf61Id as o, parseGatewayUrl as p, canonicalizePortableUri as r, getFe34Origin as s, UrlError as t, isGatewayUrl as u };
798
+ export { withoutGatewayHints as S, parseIri as _, expandIPv6Address as a, validatePublicUrl as b, getFe34Origin as c, haveSameIriOrigin as d, isGatewayUrl as f, parseGatewayUrl as g, parseGatewayOrigin as h, canonicalizePortableUri as i, getGatewayHints as l, isValidPublicIPv6Address as m, UrlError as n, formatIri as o, isValidPublicIPv4Address as p, arePortableUrisEqual as r, fromCompatibleEf61Id as s, GATEWAY_HINT_PARAMETER as t, haveSameFe34Origin as u, parseJsonLdId as v, withGatewayHints as x, toCompatibleEf61Id as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.4.0-dev.2228+6d017d55",
3
+ "version": "2.4.0-dev.2240+79613fa6",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -99,7 +99,8 @@
99
99
  "@types/node": "^24.12.2",
100
100
  "fetch-mock": "^12.5.4",
101
101
  "tsdown": "^0.22.0",
102
- "typescript": "^6.0.0"
102
+ "typescript": "^6.0.0",
103
+ "@fedify/fixture": "2.0.0"
103
104
  },
104
105
  "dependencies": {
105
106
  "@js-temporal/polyfill": "^0.5.1",
@@ -116,6 +117,8 @@
116
117
  "build": "pnpm --filter @fedify/vocab-runtime... run build:self",
117
118
  "prepublish": "pnpm build",
118
119
  "pretest": "pnpm build",
119
- "test": "cd dist/tests && node --test"
120
+ "test": "cd dist/tests && node --test",
121
+ "pretest:bun": "pnpm build",
122
+ "test:bun": "node scripts/test-bun.mjs"
120
123
  }
121
124
  }
@@ -0,0 +1,17 @@
1
+ import { access, glob } from "node:fs/promises";
2
+ import { spawnSync } from "node:child_process";
3
+
4
+ const sources = await Array.fromAsync(glob("src/**/*.test.ts"));
5
+ if (sources.length === 0) throw new Error("No vocab-runtime tests found.");
6
+
7
+ const tests = sources.map((source) =>
8
+ source.replaceAll("\\", "/").replace(/^src\//, "dist/tests/")
9
+ .replace(/\.ts$/, ".mjs")
10
+ ).sort();
11
+ for (const test of tests) await access(test);
12
+
13
+ const result = spawnSync("bun", ["test", "--timeout", "60000", ...tests], {
14
+ stdio: "inherit",
15
+ });
16
+ if (result.error) throw result.error;
17
+ process.exitCode = result.status ?? 1;