@fedify/vocab-runtime 2.2.0-dev.613 → 2.2.0-dev.622

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-DEi540Xh.js → docloader-CLla_XnE.mjs} +35 -65
  15. package/dist/tests/{docloader-txRGFv1x.cjs → docloader-WtKuh5yf.cjs} +51 -81
  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-73FIhAHw.cjs → request-B7F8mcfm.cjs} +38 -72
  39. package/dist/tests/{request-BO6hGoBJ.js → request-DeDrepIV.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.2.0-dev.613+cf8cd122";
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.2.0-dev.622+e54cb037";
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,17 +4779,16 @@ async function getRemoteDocument(url, response, fetch$1) {
4851
4779
  * @since 1.3.0
4852
4780
  */
4853
4781
  function getDocumentLoader({ allowPrivateAddress, maxRedirection, 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
  const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
4857
4784
  async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
4858
4785
  options?.signal?.throwIfAborted();
4859
4786
  const currentUrl = new URL(url).href;
4860
- if (!skipPreloadedContexts && currentUrl in contexts_default) {
4787
+ if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
4861
4788
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
4862
4789
  return {
4863
4790
  contextUrl: null,
4864
- document: contexts_default[currentUrl],
4791
+ document: preloadedContexts[currentUrl],
4865
4792
  documentUrl: currentUrl
4866
4793
  };
4867
4794
  }
@@ -4924,7 +4851,6 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
4924
4851
  }
4925
4852
  return load;
4926
4853
  }
4927
-
4928
4854
  //#endregion
4929
4855
  //#region src/internal/multicodec.ts
4930
4856
  const INVALID_MULTICODEC_PREFIX = "Invalid multicodec prefix.";
@@ -4964,7 +4890,6 @@ function addMulticodecPrefix(code, payload) {
4964
4890
  prefixed.set(payload, prefix.length);
4965
4891
  return prefixed;
4966
4892
  }
4967
-
4968
4893
  //#endregion
4969
4894
  //#region src/jwk.ts
4970
4895
  function validateCryptoKey(key, type) {
@@ -4972,11 +4897,9 @@ function validateCryptoKey(key, type) {
4972
4897
  if (!key.extractable) throw new TypeError("The key is not extractable.");
4973
4898
  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!");
4974
4899
  if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
4975
- const algorithm = key.algorithm;
4976
- 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.");
4900
+ 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.");
4977
4901
  }
4978
4902
  }
4979
-
4980
4903
  //#endregion
4981
4904
  //#region src/multibase/util.ts
4982
4905
  const textDecoder = new TextDecoder();
@@ -4992,7 +4915,6 @@ function concat(arrs, length) {
4992
4915
  }
4993
4916
  return output;
4994
4917
  }
4995
-
4996
4918
  //#endregion
4997
4919
  //#region src/multibase/base.ts
4998
4920
  /**
@@ -5001,8 +4923,8 @@ function concat(arrs, length) {
5001
4923
  var Base = class {
5002
4924
  codeBuf;
5003
4925
  codec;
5004
- constructor(name$1, code, factory, alphabet) {
5005
- this.name = name$1;
4926
+ constructor(name, code, factory, alphabet) {
4927
+ this.name = name;
5006
4928
  this.code = code;
5007
4929
  this.alphabet = alphabet;
5008
4930
  this.codeBuf = encodeText(this.code);
@@ -5017,12 +4939,11 @@ var Base = class {
5017
4939
  return this.codec.decode(string);
5018
4940
  }
5019
4941
  };
5020
-
5021
4942
  //#endregion
5022
4943
  //#region src/multibase/rfc4648.ts
5023
4944
  const decode = (string, alphabet, bitsPerChar) => {
5024
- const codes$1 = {};
5025
- for (let i = 0; i < alphabet.length; ++i) codes$1[alphabet[i]] = i;
4945
+ const codes = {};
4946
+ for (let i = 0; i < alphabet.length; ++i) codes[alphabet[i]] = i;
5026
4947
  let end = string.length;
5027
4948
  while (string[end - 1] === "=") --end;
5028
4949
  const out = new Uint8Array(end * bitsPerChar / 8 | 0);
@@ -5030,7 +4951,7 @@ const decode = (string, alphabet, bitsPerChar) => {
5030
4951
  let buffer = 0;
5031
4952
  let written = 0;
5032
4953
  for (let i = 0; i < end; ++i) {
5033
- const value = codes$1[string[i]];
4954
+ const value = codes[string[i]];
5034
4955
  if (value === void 0) throw new SyntaxError("Invalid character " + string[i]);
5035
4956
  buffer = buffer << bitsPerChar | value;
5036
4957
  bits += bitsPerChar;
@@ -5073,7 +4994,6 @@ const rfc4648 = (bitsPerChar) => (alphabet) => {
5073
4994
  }
5074
4995
  };
5075
4996
  };
5076
-
5077
4997
  //#endregion
5078
4998
  //#region src/multibase/constants.ts
5079
4999
  const identity = () => {
@@ -5235,7 +5155,6 @@ const codes = constants.reduce((prev, tupple) => {
5235
5155
  prev[tupple[1]] = names[tupple[0]];
5236
5156
  return prev;
5237
5157
  }, {});
5238
-
5239
5158
  //#endregion
5240
5159
  //#region src/multibase/mod.ts
5241
5160
  /**
@@ -5272,8 +5191,7 @@ function decodeMultibase(data) {
5272
5191
  "k",
5273
5192
  "K"
5274
5193
  ].includes(prefix)) data = data.toLowerCase();
5275
- const enc = encoding(data[0]);
5276
- return enc.decode(data.substring(1));
5194
+ return encoding(data[0]).decode(data.substring(1));
5277
5195
  }
5278
5196
  /**
5279
5197
  * Get the encoding by name or code
@@ -5295,7 +5213,6 @@ function encodingFromBaseData(data) {
5295
5213
  if (data instanceof Uint8Array) data = decodeText(data);
5296
5214
  return encoding(data[0]);
5297
5215
  }
5298
-
5299
5216
  //#endregion
5300
5217
  //#region src/key.ts
5301
5218
  const algorithms = {
@@ -5320,8 +5237,7 @@ async function importSpki(pem) {
5320
5237
  } catch (_) {
5321
5238
  throw new TypeError("Invalid PEM-SPKI format.");
5322
5239
  }
5323
- const pki = PublicKeyInfo.fromBER(spki);
5324
- const oid = pki.algorithm.algorithmId;
5240
+ const oid = PublicKeyInfo.fromBER(spki).algorithm.algorithmId;
5325
5241
  const algorithm = algorithms[oid];
5326
5242
  if (algorithm == null) throw new TypeError("Unsupported algorithm: " + oid);
5327
5243
  return await crypto.subtle.importKey("spki", spki, algorithm, true, ["verify"]);
@@ -5335,8 +5251,7 @@ async function importSpki(pem) {
5335
5251
  */
5336
5252
  async function exportSpki(key) {
5337
5253
  validateCryptoKey(key);
5338
- const spki = await crypto.subtle.exportKey("spki", key);
5339
- let pem = encodeBase64(spki);
5254
+ let pem = encodeBase64(await crypto.subtle.exportKey("spki", key));
5340
5255
  pem = (pem.match(/.{1,64}/g) || []).join("\n");
5341
5256
  return `-----BEGIN PUBLIC KEY-----\n${pem}\n-----END PUBLIC KEY-----\n`;
5342
5257
  }
@@ -5348,16 +5263,14 @@ async function exportSpki(key) {
5348
5263
  * @since 1.5.0
5349
5264
  */
5350
5265
  function importPkcs1(pem) {
5351
- const key = createPublicKey({
5266
+ return importSpki(createPublicKey({
5352
5267
  key: pem,
5353
5268
  format: "pem",
5354
5269
  type: "pkcs1"
5355
- });
5356
- const spki = key.export({
5270
+ }).export({
5357
5271
  type: "spki",
5358
5272
  format: "pem"
5359
- });
5360
- return importSpki(spki);
5273
+ }));
5361
5274
  }
5362
5275
  const PKCS1_HEADER = /^\s*-----BEGIN\s+RSA\s+PUBLIC\s+KEY-----\s*\n/;
5363
5276
  /**
@@ -5384,12 +5297,11 @@ async function importMultibaseKey(key) {
5384
5297
  const { code } = getMulticodecPrefix(decoded);
5385
5298
  const content = removeMulticodecPrefix(decoded);
5386
5299
  if (code === 4613) {
5387
- const keyObject = createPublicKey({
5300
+ const exported = createPublicKey({
5388
5301
  key: content,
5389
5302
  format: "der",
5390
5303
  type: "pkcs1"
5391
- });
5392
- const exported = keyObject.export({
5304
+ }).export({
5393
5305
  type: "spki",
5394
5306
  format: "der"
5395
5307
  });
@@ -5421,21 +5333,18 @@ async function exportMultibaseKey(key) {
5421
5333
  const decodedN = decodeBase64Url(jwk.n);
5422
5334
  const n = new Uint8Array(decodedN.length + 1);
5423
5335
  n.set(decodedN, 1);
5424
- const sequence = new Sequence({ value: [new Integer({
5336
+ content = new Sequence({ value: [new Integer({
5425
5337
  isHexOnly: true,
5426
5338
  valueHex: n
5427
5339
  }), new Integer({
5428
5340
  isHexOnly: true,
5429
5341
  valueHex: decodeBase64Url(jwk.e)
5430
- })] });
5431
- content = sequence.toBER(false);
5342
+ })] }).toBER(false);
5432
5343
  code = 4613;
5433
5344
  } else throw new TypeError("Unsupported key type: " + JSON.stringify(key.algorithm));
5434
- const prefixed = addMulticodecPrefix(code, new Uint8Array(content));
5435
- const encoded = encodeMultibase("base58btc", prefixed);
5345
+ const encoded = encodeMultibase("base58btc", addMulticodecPrefix(code, new Uint8Array(content)));
5436
5346
  return new TextDecoder().decode(encoded);
5437
5347
  }
5438
-
5439
5348
  //#endregion
5440
5349
  //#region src/decimal.ts
5441
5350
  const DECIMAL_PATTERN = /^(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/;
@@ -5511,7 +5420,6 @@ function parseDecimal(value) {
5511
5420
  if (!isDecimal(normalized)) throw new TypeError(`${JSON.stringify(value)} is not a valid xsd:decimal lexical form.`);
5512
5421
  return normalized;
5513
5422
  }
5514
-
5515
5423
  //#endregion
5516
5424
  //#region src/langstr.ts
5517
5425
  /**
@@ -5540,6 +5448,5 @@ LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, o
5540
5448
  LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_depth, options, inspect) {
5541
5449
  return `<${this.locale.baseName}> ${inspect(this.toString(), options)}`;
5542
5450
  };
5543
-
5544
5451
  //#endregion
5545
- 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 };
5452
+ 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-txRGFv1x.cjs');
3
- require('./request-73FIhAHw.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-WtKuh5yf.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