@fedify/vocab-runtime 2.1.1 → 2.1.3

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 (56) hide show
  1. package/deno.json +1 -1
  2. package/dist/{chunk-CUT6urMc.cjs → chunk-CKQMccvm.cjs} +7 -9
  3. package/dist/jsonld.cjs +4 -5
  4. package/dist/jsonld.d.cts +3 -4
  5. package/dist/jsonld.d.ts +2 -2
  6. package/dist/jsonld.js +1 -3
  7. package/dist/mod.cjs +80 -170
  8. package/dist/mod.d.cts +1 -2
  9. package/dist/mod.d.ts +1 -2
  10. package/dist/mod.js +56 -149
  11. package/dist/tests/{chunk-DWy1uDak.cjs → chunk-Do9eywBl.cjs} +13 -17
  12. package/dist/tests/decimal.test.cjs +12 -21
  13. package/dist/tests/{decimal.test.js → decimal.test.mjs} +10 -18
  14. package/dist/tests/{docloader-RQoMNF99.cjs → docloader-B12Akv7g.cjs} +51 -81
  15. package/dist/tests/{docloader-DIUeF-5W.js → docloader-Crw-JAOa.mjs} +35 -65
  16. package/dist/tests/docloader.test.cjs +53 -90
  17. package/dist/tests/{docloader.test.js → docloader.test.mjs} +53 -96
  18. package/dist/tests/internal/multicodec.test.cjs +5 -7
  19. package/dist/tests/internal/{multicodec.test.js → multicodec.test.mjs} +3 -4
  20. package/dist/tests/{key-ByCmSI2y.js → key-BeTHFQJK.mjs} +14 -25
  21. package/dist/tests/{key-CCPn6TEY.cjs → key-DTTIntwb.cjs} +60 -71
  22. package/dist/tests/key.test.cjs +23 -45
  23. package/dist/tests/{key.test.js → key.test.mjs} +21 -42
  24. package/dist/tests/{langstr-EPh86hXK.cjs → langstr-CbAxaeEZ.cjs} +6 -8
  25. package/dist/tests/{langstr-BsVE3s9u.js → langstr-Di5AvKpB.mjs} +1 -2
  26. package/dist/tests/langstr.test.cjs +7 -8
  27. package/dist/tests/{langstr.test.js → langstr.test.mjs} +3 -4
  28. package/dist/tests/{link-DYNFAdNu.cjs → link-FguCydMA.cjs} +6 -8
  29. package/dist/tests/{link-C3q2TC2G.js → link-NUUWCdnK.mjs} +1 -2
  30. package/dist/tests/link.test.cjs +5 -7
  31. package/dist/tests/{link.test.js → link.test.mjs} +3 -4
  32. package/dist/tests/multibase/multibase.test.cjs +10 -17
  33. package/dist/tests/multibase/{multibase.test.js → multibase.test.mjs} +10 -18
  34. package/dist/tests/{multibase-B4g8pz6F.js → multibase-BgU9XRf7.mjs} +5 -12
  35. package/dist/tests/{multibase-o_ovPHYJ.cjs → multibase-F7LtMMsK.cjs} +43 -49
  36. package/dist/tests/{multicodec--6hQ74zI.cjs → multicodec-CxGVGa91.cjs} +16 -18
  37. package/dist/tests/{multicodec-Dq3IiOV4.js → multicodec-CyFp54fI.mjs} +1 -2
  38. package/dist/tests/{request-kJU0S4zp.cjs → request-BJsYOUki.cjs} +38 -72
  39. package/dist/tests/{request-D6fgLaP4.js → request-DuFME2HF.mjs} +4 -45
  40. package/dist/tests/request.test.cjs +23 -24
  41. package/dist/tests/request.test.mjs +42 -0
  42. package/dist/tests/{url-CWEP9Zs9.js → url-BQ_kgmCk.mjs} +3 -7
  43. package/dist/tests/{url-DIjOdK8Q.cjs → url-pFuSds44.cjs} +31 -35
  44. package/dist/tests/url.test.cjs +5 -7
  45. package/dist/tests/{url.test.js → url.test.mjs} +3 -4
  46. package/package.json +3 -3
  47. package/dist/tests/request.test.js +0 -43
  48. /package/dist/tests/{decimal.test.d.ts → decimal.test.d.mts} +0 -0
  49. /package/dist/tests/{docloader.test.d.ts → docloader.test.d.mts} +0 -0
  50. /package/dist/tests/internal/{multicodec.test.d.ts → multicodec.test.d.mts} +0 -0
  51. /package/dist/tests/{key.test.d.ts → key.test.d.mts} +0 -0
  52. /package/dist/tests/{langstr.test.d.ts → langstr.test.d.mts} +0 -0
  53. /package/dist/tests/{link.test.d.ts → link.test.d.mts} +0 -0
  54. /package/dist/tests/multibase/{multibase.test.d.ts → multibase.test.d.mts} +0 -0
  55. /package/dist/tests/{request.test.d.ts → request.test.d.mts} +0 -0
  56. /package/dist/tests/{url.test.d.ts → url.test.d.mts} +0 -0
package/dist/mod.js CHANGED
@@ -9,9 +9,8 @@ import { decodeBase64Url } from "byte-encodings/base64url";
9
9
  import { createPublicKey } from "node:crypto";
10
10
  import { PublicKeyInfo } from "pkijs";
11
11
  import baseX from "@multiformats/base-x";
12
-
13
12
  //#region src/contexts/activitystreams.json
14
- var __context$11 = {
13
+ var activitystreams_default = { "@context": {
15
14
  "@vocab": "_:",
16
15
  "xsd": "http://www.w3.org/2001/XMLSchema#",
17
16
  "as": "https://www.w3.org/ns/activitystreams#",
@@ -387,12 +386,10 @@ var __context$11 = {
387
386
  "@id": "as:alsoKnownAs",
388
387
  "@type": "@id"
389
388
  }
390
- };
391
- var activitystreams_default = { "@context": __context$11 };
392
-
389
+ } };
393
390
  //#endregion
394
391
  //#region src/contexts/did-v1.json
395
- var __context$10 = {
392
+ var did_v1_default = { "@context": {
396
393
  "@protected": true,
397
394
  "id": "@id",
398
395
  "type": "@type",
@@ -446,12 +443,10 @@ var __context$10 = {
446
443
  "@id": "https://w3id.org/security#verificationMethod",
447
444
  "@type": "@id"
448
445
  }
449
- };
450
- var did_v1_default = { "@context": __context$10 };
451
-
446
+ } };
452
447
  //#endregion
453
448
  //#region src/contexts/fep-5711.json
454
- var __context$9 = {
449
+ var fep_5711_default = { "@context": {
455
450
  "likesOf": {
456
451
  "@id": "https://w3id.org/fep/5711#likesOf",
457
452
  "@type": "@id"
@@ -484,12 +479,10 @@ var __context$9 = {
484
479
  "@id": "https://w3id.org/fep/5711#likedOf",
485
480
  "@type": "@id"
486
481
  }
487
- };
488
- var fep_5711_default = { "@context": __context$9 };
489
-
482
+ } };
490
483
  //#endregion
491
484
  //#region src/contexts/gotosocial.json
492
- var __context$8 = {
485
+ var gotosocial_default = { "@context": {
493
486
  "xsd": "http://www.w3.org/2001/XMLSchema#",
494
487
  "gts": "https://gotosocial.org/ns#",
495
488
  "LikeRequest": "gts:LikeRequest",
@@ -572,12 +565,10 @@ var __context$8 = {
572
565
  "@id": "gts:approvedBy",
573
566
  "@type": "@id"
574
567
  }
575
- };
576
- var gotosocial_default = { "@context": __context$8 };
577
-
568
+ } };
578
569
  //#endregion
579
570
  //#region src/contexts/identity-v1.json
580
- var __context$7 = {
571
+ var identity_v1_default = { "@context": {
581
572
  "id": "@id",
582
573
  "type": "@type",
583
574
  "cred": "https://w3id.org/credentials#",
@@ -726,12 +717,10 @@ var __context$7 = {
726
717
  "@id": "perm:writePermission",
727
718
  "@type": "@id"
728
719
  }
729
- };
730
- var identity_v1_default = { "@context": __context$7 };
731
-
720
+ } };
732
721
  //#endregion
733
722
  //#region src/contexts/joinmastodon.json
734
- var __context$6 = {
723
+ var joinmastodon_default = { "@context": {
735
724
  "toot": "http://joinmastodon.org/ns#",
736
725
  "Emoji": "toot:Emoji",
737
726
  "featured": {
@@ -756,12 +745,10 @@ var __context$6 = {
756
745
  "@id": "toot:attributionDomains",
757
746
  "@type": "@id"
758
747
  }
759
- };
760
- var joinmastodon_default = { "@context": __context$6 };
761
-
748
+ } };
762
749
  //#endregion
763
750
  //#region src/contexts/schemaorg.json
764
- var __context$5 = {
751
+ var schemaorg_default = { "@context": {
765
752
  "type": "@type",
766
753
  "id": "@id",
767
754
  "HTML": { "@id": "rdf:HTML" },
@@ -4063,12 +4050,10 @@ var __context$5 = {
4063
4050
  "yearlyRevenue": { "@id": "schema:yearlyRevenue" },
4064
4051
  "yearsInOperation": { "@id": "schema:yearsInOperation" },
4065
4052
  "yield": { "@id": "schema:yield" }
4066
- };
4067
- var schemaorg_default = { "@context": __context$5 };
4068
-
4053
+ } };
4069
4054
  //#endregion
4070
4055
  //#region src/contexts/security-data-integrity-v1.json
4071
- var __context$4 = {
4056
+ var security_data_integrity_v1_default = { "@context": {
4072
4057
  "id": "@id",
4073
4058
  "type": "@type",
4074
4059
  "@protected": true,
@@ -4143,12 +4128,10 @@ var __context$4 = {
4143
4128
  }
4144
4129
  }
4145
4130
  }
4146
- };
4147
- var security_data_integrity_v1_default = { "@context": __context$4 };
4148
-
4131
+ } };
4149
4132
  //#endregion
4150
4133
  //#region src/contexts/security-data-integrity-v2.json
4151
- var __context$3 = {
4134
+ var security_data_integrity_v2_default = { "@context": {
4152
4135
  "id": "@id",
4153
4136
  "type": "@type",
4154
4137
  "@protected": true,
@@ -4226,12 +4209,10 @@ var __context$3 = {
4226
4209
  }
4227
4210
  }
4228
4211
  }
4229
- };
4230
- var security_data_integrity_v2_default = { "@context": __context$3 };
4231
-
4212
+ } };
4232
4213
  //#endregion
4233
4214
  //#region src/contexts/security-multikey-v1.json
4234
- var __context$2 = {
4215
+ var security_multikey_v1_default = { "@context": {
4235
4216
  "id": "@id",
4236
4217
  "type": "@type",
4237
4218
  "@protected": true,
@@ -4263,12 +4244,10 @@ var __context$2 = {
4263
4244
  }
4264
4245
  }
4265
4246
  }
4266
- };
4267
- var security_multikey_v1_default = { "@context": __context$2 };
4268
-
4247
+ } };
4269
4248
  //#endregion
4270
4249
  //#region src/contexts/security-v1.json
4271
- var __context$1 = {
4250
+ var security_v1_default = { "@context": {
4272
4251
  "id": "@id",
4273
4252
  "type": "@type",
4274
4253
  "dc": "http://purl.org/dc/terms/",
@@ -4339,21 +4318,17 @@ var __context$1 = {
4339
4318
  "signature": "sec:signature",
4340
4319
  "signatureAlgorithm": "sec:signingAlgorithm",
4341
4320
  "signatureValue": "sec:signatureValue"
4342
- };
4343
- var security_v1_default = { "@context": __context$1 };
4344
-
4321
+ } };
4345
4322
  //#endregion
4346
4323
  //#region src/contexts/webfinger.json
4347
- var __context = {
4324
+ var webfinger_default = { "@context": {
4348
4325
  "wf": "https://purl.archive.org/socialweb/webfinger#",
4349
4326
  "xsd": "http://www.w3.org/2001/XMLSchema#",
4350
4327
  "webfinger": {
4351
4328
  "@id": "wf:webfinger",
4352
4329
  "@type": "xsd:string"
4353
4330
  }
4354
- };
4355
- var webfinger_default = { "@context": __context };
4356
-
4331
+ } };
4357
4332
  //#endregion
4358
4333
  //#region src/contexts.ts
4359
4334
  const preloadedContexts = {
@@ -4370,50 +4345,10 @@ const preloadedContexts = {
4370
4345
  "https://w3id.org/fep/5711": fep_5711_default,
4371
4346
  "http://joinmastodon.org/ns": joinmastodon_default
4372
4347
  };
4373
- var contexts_default = preloadedContexts;
4374
-
4375
4348
  //#endregion
4376
4349
  //#region deno.json
4377
4350
  var name = "@fedify/vocab-runtime";
4378
- var version = "2.1.1";
4379
- var license = "MIT";
4380
- var exports = {
4381
- ".": "./src/mod.ts",
4382
- "./jsonld": "./src/jsonld.ts"
4383
- };
4384
- var description = "Runtime library for @fedify/vocab";
4385
- var author = {
4386
- "name": "Hong Minhee",
4387
- "email": "hong@minhee.org",
4388
- "url": "https://hongminhee.org/"
4389
- };
4390
- var imports = {
4391
- "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
4392
- "asn1js": "npm:asn1js@^3.0.6",
4393
- "byte-encodings": "npm:byte-encodings@^1.0.11",
4394
- "fetch-mock": "npm:fetch-mock@^12.5.4",
4395
- "jsonld": "npm:jsonld@^9.0.0",
4396
- "pkijs": "npm:pkijs@^3.2.5"
4397
- };
4398
- var exclude = ["dist", "node_modules"];
4399
- var publish = { "exclude": ["**/*.test.ts", "tsdown.config.ts"] };
4400
- var tasks = {
4401
- "check": "deno fmt --check && deno lint && deno check src/*.ts",
4402
- "test": "deno test"
4403
- };
4404
- var deno_default = {
4405
- name,
4406
- version,
4407
- license,
4408
- exports,
4409
- description,
4410
- author,
4411
- imports,
4412
- exclude,
4413
- publish,
4414
- tasks
4415
- };
4416
-
4351
+ var version = "2.1.3";
4417
4352
  //#endregion
4418
4353
  //#region src/link.ts
4419
4354
  const parametersNeedLowerCase = ["rel", "type"];
@@ -4595,7 +4530,6 @@ var HttpHeaderLink = class HttpHeaderLink {
4595
4530
  return new this(...inputs).toString();
4596
4531
  }
4597
4532
  };
4598
-
4599
4533
  //#endregion
4600
4534
  //#region src/request.ts
4601
4535
  /**
@@ -4647,27 +4581,25 @@ function createActivityPubRequest(url, options = {}) {
4647
4581
  * @since 1.3.0
4648
4582
  */
4649
4583
  function getUserAgent({ software, url } = {}) {
4650
- const fedify = `Fedify/${deno_default.version}`;
4584
+ const fedify = `Fedify/${version}`;
4651
4585
  const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null;
4652
4586
  const userAgent = software == null ? [fedify] : [software, fedify];
4653
4587
  if (runtime != null) userAgent.push(runtime);
4654
4588
  if (url != null) userAgent.push(`+${url.toString()}`);
4655
- const first = userAgent.shift();
4656
- return `${first} (${userAgent.join("; ")})`;
4589
+ return `${userAgent.shift()} (${userAgent.join("; ")})`;
4657
4590
  }
4658
4591
  /**
4659
4592
  * Logs the request.
4660
4593
  * @param request The request to log.
4661
4594
  * @internal
4662
4595
  */
4663
- function logRequest(logger$1, request) {
4664
- logger$1.debug("Fetching document: {method} {url} {headers}", {
4596
+ function logRequest(logger, request) {
4597
+ logger.debug("Fetching document: {method} {url} {headers}", {
4665
4598
  method: request.method,
4666
4599
  url: request.url,
4667
4600
  headers: Object.fromEntries(request.headers.entries())
4668
4601
  });
4669
4602
  }
4670
-
4671
4603
  //#endregion
4672
4604
  //#region src/url.ts
4673
4605
  var UrlError = class extends Error {
@@ -4686,8 +4618,7 @@ async function validatePublicUrl(url) {
4686
4618
  if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.substring(1, hostname.length - 2);
4687
4619
  if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
4688
4620
  if ("Deno" in globalThis && !isIP(hostname)) {
4689
- const netPermission = await Deno.permissions.query({ name: "net" });
4690
- if (netPermission.state !== "granted") return;
4621
+ if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
4691
4622
  }
4692
4623
  if ("Bun" in globalThis) {
4693
4624
  if (hostname === "example.com" || hostname.endsWith(".example.com")) return;
@@ -4723,10 +4654,8 @@ function expandIPv6Address(address) {
4723
4654
  if (address.startsWith("::")) address = "0000" + address;
4724
4655
  if (address.endsWith("::")) address = address + "0000";
4725
4656
  address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
4726
- const parts = address.split(":");
4727
- return parts.map((part) => part.padStart(4, "0")).join(":");
4657
+ return address.split(":").map((part) => part.padStart(4, "0")).join(":");
4728
4658
  }
4729
-
4730
4659
  //#endregion
4731
4660
  //#region src/docloader.ts
4732
4661
  const logger = getLogger([
@@ -4744,7 +4673,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
4744
4673
  * @throws {FetchError} If the response is not OK.
4745
4674
  * @internal
4746
4675
  */
4747
- async function getRemoteDocument(url, response, fetch$1) {
4676
+ async function getRemoteDocument(url, response, fetch) {
4748
4677
  const documentUrl = response.url === "" ? url : response.url;
4749
4678
  const docUrl = new URL(documentUrl);
4750
4679
  if (!response.ok) {
@@ -4782,7 +4711,7 @@ async function getRemoteDocument(url, response, fetch$1) {
4782
4711
  alternateUrl: altUri.href,
4783
4712
  url: documentUrl
4784
4713
  });
4785
- return await fetch$1(altUri.href);
4714
+ return await fetch(altUri.href);
4786
4715
  }
4787
4716
  }
4788
4717
  }
@@ -4808,15 +4737,14 @@ async function getRemoteDocument(url, response, fetch$1) {
4808
4737
  attrPattern.lastIndex = 0;
4809
4738
  while ((attrMatch = attrPattern.exec(tagContent)) !== null) {
4810
4739
  const key = attrMatch[1].toLowerCase();
4811
- const value = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "";
4812
- attribs[key] = value;
4740
+ attribs[key] = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "";
4813
4741
  }
4814
4742
  if (attribs.rel === "alternate" && "type" in attribs && (attribs.type === "application/activity+json" || attribs.type === "application/ld+json" || attribs.type.startsWith("application/ld+json;")) && "href" in attribs && new URL(attribs.href, docUrl).href !== docUrl.href) {
4815
4743
  logger.debug("Found alternate document: {alternateUrl} from {url}", {
4816
4744
  alternateUrl: attribs.href,
4817
4745
  url: documentUrl
4818
4746
  });
4819
- return await fetch$1(new URL(attribs.href, docUrl).href);
4747
+ return await fetch(new URL(attribs.href, docUrl).href);
4820
4748
  }
4821
4749
  }
4822
4750
  document = JSON.parse(html);
@@ -4851,16 +4779,15 @@ async function getRemoteDocument(url, response, fetch$1) {
4851
4779
  * @since 1.3.0
4852
4780
  */
4853
4781
  function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
4854
- const tracerProvider = trace.getTracerProvider();
4855
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
4782
+ const tracer = trace.getTracerProvider().getTracer(name, version);
4856
4783
  async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
4857
4784
  options?.signal?.throwIfAborted();
4858
4785
  const currentUrl = new URL(url).href;
4859
- if (!skipPreloadedContexts && currentUrl in contexts_default) {
4786
+ if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
4860
4787
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
4861
4788
  return {
4862
4789
  contextUrl: null,
4863
- document: contexts_default[currentUrl],
4790
+ document: preloadedContexts[currentUrl],
4864
4791
  documentUrl: currentUrl
4865
4792
  };
4866
4793
  }
@@ -4923,7 +4850,6 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
4923
4850
  }
4924
4851
  return load;
4925
4852
  }
4926
-
4927
4853
  //#endregion
4928
4854
  //#region src/internal/multicodec.ts
4929
4855
  const INVALID_MULTICODEC_PREFIX = "Invalid multicodec prefix.";
@@ -4963,7 +4889,6 @@ function addMulticodecPrefix(code, payload) {
4963
4889
  prefixed.set(payload, prefix.length);
4964
4890
  return prefixed;
4965
4891
  }
4966
-
4967
4892
  //#endregion
4968
4893
  //#region src/jwk.ts
4969
4894
  function validateCryptoKey(key, type) {
@@ -4971,11 +4896,9 @@ function validateCryptoKey(key, type) {
4971
4896
  if (!key.extractable) throw new TypeError("The key is not extractable.");
4972
4897
  if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
4973
4898
  if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
4974
- const algorithm = key.algorithm;
4975
- if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
4899
+ if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
4976
4900
  }
4977
4901
  }
4978
-
4979
4902
  //#endregion
4980
4903
  //#region src/multibase/util.ts
4981
4904
  const textDecoder = new TextDecoder();
@@ -4991,7 +4914,6 @@ function concat(arrs, length) {
4991
4914
  }
4992
4915
  return output;
4993
4916
  }
4994
-
4995
4917
  //#endregion
4996
4918
  //#region src/multibase/base.ts
4997
4919
  /**
@@ -5000,8 +4922,8 @@ function concat(arrs, length) {
5000
4922
  var Base = class {
5001
4923
  codeBuf;
5002
4924
  codec;
5003
- constructor(name$1, code, factory, alphabet) {
5004
- this.name = name$1;
4925
+ constructor(name, code, factory, alphabet) {
4926
+ this.name = name;
5005
4927
  this.code = code;
5006
4928
  this.alphabet = alphabet;
5007
4929
  this.codeBuf = encodeText(this.code);
@@ -5016,12 +4938,11 @@ var Base = class {
5016
4938
  return this.codec.decode(string);
5017
4939
  }
5018
4940
  };
5019
-
5020
4941
  //#endregion
5021
4942
  //#region src/multibase/rfc4648.ts
5022
4943
  const decode = (string, alphabet, bitsPerChar) => {
5023
- const codes$1 = {};
5024
- for (let i = 0; i < alphabet.length; ++i) codes$1[alphabet[i]] = i;
4944
+ const codes = {};
4945
+ for (let i = 0; i < alphabet.length; ++i) codes[alphabet[i]] = i;
5025
4946
  let end = string.length;
5026
4947
  while (string[end - 1] === "=") --end;
5027
4948
  const out = new Uint8Array(end * bitsPerChar / 8 | 0);
@@ -5029,7 +4950,7 @@ const decode = (string, alphabet, bitsPerChar) => {
5029
4950
  let buffer = 0;
5030
4951
  let written = 0;
5031
4952
  for (let i = 0; i < end; ++i) {
5032
- const value = codes$1[string[i]];
4953
+ const value = codes[string[i]];
5033
4954
  if (value === void 0) throw new SyntaxError("Invalid character " + string[i]);
5034
4955
  buffer = buffer << bitsPerChar | value;
5035
4956
  bits += bitsPerChar;
@@ -5072,7 +4993,6 @@ const rfc4648 = (bitsPerChar) => (alphabet) => {
5072
4993
  }
5073
4994
  };
5074
4995
  };
5075
-
5076
4996
  //#endregion
5077
4997
  //#region src/multibase/constants.ts
5078
4998
  const identity = () => {
@@ -5234,7 +5154,6 @@ const codes = constants.reduce((prev, tupple) => {
5234
5154
  prev[tupple[1]] = names[tupple[0]];
5235
5155
  return prev;
5236
5156
  }, {});
5237
-
5238
5157
  //#endregion
5239
5158
  //#region src/multibase/mod.ts
5240
5159
  /**
@@ -5271,8 +5190,7 @@ function decodeMultibase(data) {
5271
5190
  "k",
5272
5191
  "K"
5273
5192
  ].includes(prefix)) data = data.toLowerCase();
5274
- const enc = encoding(data[0]);
5275
- return enc.decode(data.substring(1));
5193
+ return encoding(data[0]).decode(data.substring(1));
5276
5194
  }
5277
5195
  /**
5278
5196
  * Get the encoding by name or code
@@ -5294,7 +5212,6 @@ function encodingFromBaseData(data) {
5294
5212
  if (data instanceof Uint8Array) data = decodeText(data);
5295
5213
  return encoding(data[0]);
5296
5214
  }
5297
-
5298
5215
  //#endregion
5299
5216
  //#region src/key.ts
5300
5217
  const algorithms = {
@@ -5319,8 +5236,7 @@ async function importSpki(pem) {
5319
5236
  } catch (_) {
5320
5237
  throw new TypeError("Invalid PEM-SPKI format.");
5321
5238
  }
5322
- const pki = PublicKeyInfo.fromBER(spki);
5323
- const oid = pki.algorithm.algorithmId;
5239
+ const oid = PublicKeyInfo.fromBER(spki).algorithm.algorithmId;
5324
5240
  const algorithm = algorithms[oid];
5325
5241
  if (algorithm == null) throw new TypeError("Unsupported algorithm: " + oid);
5326
5242
  return await crypto.subtle.importKey("spki", spki, algorithm, true, ["verify"]);
@@ -5334,8 +5250,7 @@ async function importSpki(pem) {
5334
5250
  */
5335
5251
  async function exportSpki(key) {
5336
5252
  validateCryptoKey(key);
5337
- const spki = await crypto.subtle.exportKey("spki", key);
5338
- let pem = encodeBase64(spki);
5253
+ let pem = encodeBase64(await crypto.subtle.exportKey("spki", key));
5339
5254
  pem = (pem.match(/.{1,64}/g) || []).join("\n");
5340
5255
  return `-----BEGIN PUBLIC KEY-----\n${pem}\n-----END PUBLIC KEY-----\n`;
5341
5256
  }
@@ -5347,16 +5262,14 @@ async function exportSpki(key) {
5347
5262
  * @since 1.5.0
5348
5263
  */
5349
5264
  function importPkcs1(pem) {
5350
- const key = createPublicKey({
5265
+ return importSpki(createPublicKey({
5351
5266
  key: pem,
5352
5267
  format: "pem",
5353
5268
  type: "pkcs1"
5354
- });
5355
- const spki = key.export({
5269
+ }).export({
5356
5270
  type: "spki",
5357
5271
  format: "pem"
5358
- });
5359
- return importSpki(spki);
5272
+ }));
5360
5273
  }
5361
5274
  const PKCS1_HEADER = /^\s*-----BEGIN\s+RSA\s+PUBLIC\s+KEY-----\s*\n/;
5362
5275
  /**
@@ -5383,12 +5296,11 @@ async function importMultibaseKey(key) {
5383
5296
  const { code } = getMulticodecPrefix(decoded);
5384
5297
  const content = removeMulticodecPrefix(decoded);
5385
5298
  if (code === 4613) {
5386
- const keyObject = createPublicKey({
5299
+ const exported = createPublicKey({
5387
5300
  key: content,
5388
5301
  format: "der",
5389
5302
  type: "pkcs1"
5390
- });
5391
- const exported = keyObject.export({
5303
+ }).export({
5392
5304
  type: "spki",
5393
5305
  format: "der"
5394
5306
  });
@@ -5420,21 +5332,18 @@ async function exportMultibaseKey(key) {
5420
5332
  const decodedN = decodeBase64Url(jwk.n);
5421
5333
  const n = new Uint8Array(decodedN.length + 1);
5422
5334
  n.set(decodedN, 1);
5423
- const sequence = new Sequence({ value: [new Integer({
5335
+ content = new Sequence({ value: [new Integer({
5424
5336
  isHexOnly: true,
5425
5337
  valueHex: n
5426
5338
  }), new Integer({
5427
5339
  isHexOnly: true,
5428
5340
  valueHex: decodeBase64Url(jwk.e)
5429
- })] });
5430
- content = sequence.toBER(false);
5341
+ })] }).toBER(false);
5431
5342
  code = 4613;
5432
5343
  } else throw new TypeError("Unsupported key type: " + JSON.stringify(key.algorithm));
5433
- const prefixed = addMulticodecPrefix(code, new Uint8Array(content));
5434
- const encoded = encodeMultibase("base58btc", prefixed);
5344
+ const encoded = encodeMultibase("base58btc", addMulticodecPrefix(code, new Uint8Array(content)));
5435
5345
  return new TextDecoder().decode(encoded);
5436
5346
  }
5437
-
5438
5347
  //#endregion
5439
5348
  //#region src/decimal.ts
5440
5349
  const DECIMAL_PATTERN = /^(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/;
@@ -5510,7 +5419,6 @@ function parseDecimal(value) {
5510
5419
  if (!isDecimal(normalized)) throw new TypeError(`${JSON.stringify(value)} is not a valid xsd:decimal lexical form.`);
5511
5420
  return normalized;
5512
5421
  }
5513
-
5514
5422
  //#endregion
5515
5423
  //#region src/langstr.ts
5516
5424
  /**
@@ -5539,6 +5447,5 @@ LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, o
5539
5447
  LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_depth, options, inspect) {
5540
5448
  return `<${this.locale.baseName}> ${inspect(this.toString(), options)}`;
5541
5449
  };
5542
-
5543
5450
  //#endregion
5544
- export { FetchError, LanguageString, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, contexts_default as preloadedContexts, validatePublicUrl };
5451
+ export { FetchError, LanguageString, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, preloadedContexts, validatePublicUrl };
@@ -1,13 +1,11 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
9
  var __copyProps = (to, from, except, desc) => {
12
10
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
11
  key = keys[i];
@@ -22,18 +20,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
20
  value: mod,
23
21
  enumerable: true
24
22
  }) : target, mod));
25
-
26
23
  //#endregion
27
-
28
- Object.defineProperty(exports, '__commonJS', {
29
- enumerable: true,
30
- get: function () {
31
- return __commonJS;
32
- }
24
+ Object.defineProperty(exports, "__commonJSMin", {
25
+ enumerable: true,
26
+ get: function() {
27
+ return __commonJSMin;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "__toESM", {
31
+ enumerable: true,
32
+ get: function() {
33
+ return __toESM;
34
+ }
33
35
  });
34
- Object.defineProperty(exports, '__toESM', {
35
- enumerable: true,
36
- get: function () {
37
- return __toESM;
38
- }
39
- });
@@ -1,15 +1,10 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- require('./docloader-RQoMNF99.cjs');
3
- require('./request-kJU0S4zp.cjs');
4
- require('./link-DYNFAdNu.cjs');
5
- require('./url-DIjOdK8Q.cjs');
6
- require('./multicodec--6hQ74zI.cjs');
7
- require('./key-CCPn6TEY.cjs');
8
- require('./multibase-o_ovPHYJ.cjs');
9
- require('./langstr-EPh86hXK.cjs');
10
- const node_assert = require_chunk.__toESM(require("node:assert"));
11
- const node_test = require_chunk.__toESM(require("node:test"));
12
-
1
+ require("./chunk-Do9eywBl.cjs");
2
+ require("./docloader-B12Akv7g.cjs");
3
+ require("./key-DTTIntwb.cjs");
4
+ require("./multibase-F7LtMMsK.cjs");
5
+ require("./langstr-CbAxaeEZ.cjs");
6
+ let node_assert = require("node:assert");
7
+ let node_test = require("node:test");
13
8
  //#region src/decimal.ts
14
9
  const DECIMAL_PATTERN = /^(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/;
15
10
  const XML_SCHEMA_WHITESPACE_PATTERN = /[\t\n\r ]+/g;
@@ -84,11 +79,10 @@ function parseDecimal(value) {
84
79
  if (!isDecimal(normalized)) throw new TypeError(`${JSON.stringify(value)} is not a valid xsd:decimal lexical form.`);
85
80
  return normalized;
86
81
  }
87
-
88
82
  //#endregion
89
83
  //#region src/decimal.test.ts
90
84
  (0, node_test.test)("parseDecimal() accepts valid xsd:decimal lexical forms", () => {
91
- const values = [
85
+ for (const value of [
92
86
  "-1.23",
93
87
  "12678967.543233",
94
88
  "+100000.00",
@@ -97,8 +91,7 @@ function parseDecimal(value) {
97
91
  "5.",
98
92
  "0",
99
93
  "-0.0"
100
- ];
101
- for (const value of values) (0, node_assert.deepStrictEqual)(parseDecimal(value), value);
94
+ ]) (0, node_assert.deepStrictEqual)(parseDecimal(value), value);
102
95
  });
103
96
  (0, node_test.test)("isDecimal() reports valid xsd:decimal lexical forms", () => {
104
97
  (0, node_assert.deepStrictEqual)(isDecimal("12.50"), true);
@@ -123,7 +116,7 @@ function parseDecimal(value) {
123
116
  (0, node_assert.deepStrictEqual)(parseDecimal(" .5 "), ".5");
124
117
  });
125
118
  (0, node_test.test)("parseDecimal() rejects invalid xsd:decimal lexical forms", () => {
126
- const values = [
119
+ for (const value of [
127
120
  "",
128
121
  ".",
129
122
  "+",
@@ -135,8 +128,7 @@ function parseDecimal(value) {
135
128
  "1..2",
136
129
  "1 2.3",
137
130
  "1 2.3"
138
- ];
139
- for (const value of values) (0, node_assert.throws)(() => parseDecimal(value), {
131
+ ]) (0, node_assert.throws)(() => parseDecimal(value), {
140
132
  name: "TypeError",
141
133
  message: `${JSON.stringify(value)} is not a valid xsd:decimal lexical form.`
142
134
  });
@@ -150,5 +142,4 @@ function parseDecimal(value) {
150
142
  (0, node_test.test)("isDecimal() is exported from the package root", () => {
151
143
  (0, node_assert.deepStrictEqual)(isDecimal("12.50"), true);
152
144
  });
153
-
154
- //#endregion
145
+ //#endregion