@fedify/fedify 1.6.0-dev.810 → 1.6.0-dev.812

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 (42) hide show
  1. package/CHANGES.md +2 -0
  2. package/esm/deno.js +2 -5
  3. package/esm/federation/collection.js +1 -1
  4. package/esm/runtime/docloader.js +14 -7
  5. package/esm/runtime/key.js +7 -6
  6. package/esm/sig/http.js +37 -3
  7. package/esm/sig/ld.js +2 -2
  8. package/esm/sig/proof.js +1 -1
  9. package/esm/vocab/vocab.js +176 -176
  10. package/package.json +3 -2
  11. package/types/deno.d.ts +1 -4
  12. package/types/runtime/docloader.d.ts.map +1 -1
  13. package/types/runtime/key.d.ts.map +1 -1
  14. package/types/sig/http.d.ts +15 -0
  15. package/types/sig/http.d.ts.map +1 -1
  16. package/esm/deps/jsr.io/@david/which-runtime/0.2.1/mod.js +0 -10
  17. package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -2
  18. package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -32
  19. package/esm/deps/jsr.io/@std/crypto/1.0.5/timing_safe_equal.js +0 -55
  20. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +0 -2
  21. package/esm/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +0 -26
  22. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64.js +0 -163
  23. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64url.js +0 -81
  24. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +0 -109
  25. package/types/deps/jsr.io/@david/which-runtime/0.2.1/mod.d.ts +0 -3
  26. package/types/deps/jsr.io/@david/which-runtime/0.2.1/mod.d.ts.map +0 -1
  27. package/types/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
  28. package/types/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
  29. package/types/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
  30. package/types/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
  31. package/types/deps/jsr.io/@std/crypto/1.0.5/timing_safe_equal.d.ts +0 -34
  32. package/types/deps/jsr.io/@std/crypto/1.0.5/timing_safe_equal.d.ts.map +0 -1
  33. package/types/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +0 -9
  34. package/types/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +0 -1
  35. package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts +0 -2
  36. package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts.map +0 -1
  37. package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts +0 -40
  38. package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts.map +0 -1
  39. package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts +0 -40
  40. package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts.map +0 -1
  41. package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +0 -39
  42. package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +0 -1
package/CHANGES.md CHANGED
@@ -34,6 +34,8 @@ To be released.
34
34
  - Added `HttpMessageSignaturesSpecDeterminer` interface.
35
35
  - Added `--first-knock` option to `fedify lookup` command.
36
36
 
37
+ - The minimum supported version of Node.js is now 22.0.0.
38
+
37
39
  [RFC 9421]: https://www.rfc-editor.org/rfc/rfc9421
38
40
  [#208]: https://github.com/fedify-dev/fedify/issues/208
39
41
  [#227]: https://github.com/fedify-dev/fedify/issues/227
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.6.0-dev.810+66f5c864",
3
+ "version": "1.6.0-dev.812+f522d042",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./mod.ts",
@@ -18,7 +18,6 @@ export default {
18
18
  },
19
19
  "imports": {
20
20
  "@cfworker/json-schema": "npm:@cfworker/json-schema@^2.0.1",
21
- "@david/which-runtime": "jsr:@david/which-runtime@^0.2.1",
22
21
  "@deno/dnt": "jsr:@deno/dnt@0.41.3",
23
22
  "@es-toolkit/es-toolkit": "jsr:@es-toolkit/es-toolkit@^1.38.0",
24
23
  "@hugoalh/http-header-link": "jsr:@hugoalh/http-header-link@^1.0.2",
@@ -26,14 +25,12 @@ export default {
26
25
  "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0",
27
26
  "@phensley/language-tag": "npm:@phensley/language-tag@^1.9.0",
28
27
  "@std/assert": "jsr:@std/assert@^0.226.0",
29
- "@std/bytes": "jsr:@std/bytes@^1.0.2",
30
- "@std/crypto": "jsr:@std/crypto@^1.0.4",
31
- "@std/encoding": "jsr:@std/encoding@1.0.7",
32
28
  "@std/http": "jsr:@std/http@^1.0.6",
33
29
  "@std/testing": "jsr:@std/testing@^0.224.0",
34
30
  "@std/url": "jsr:@std/url@^0.225.1",
35
31
  "@std/yaml": "jsr:@std/yaml@^0.224.3",
36
32
  "asn1js": "npm:asn1js@^3.0.5",
33
+ "byte-encodings": "npm:byte-encodings@^1.0.11",
37
34
  "fast-check": "npm:fast-check@^3.22.0",
38
35
  "json-canon": "npm:json-canon@^1.0.1",
39
36
  "jsonld": "npm:jsonld@^8.3.2",
@@ -1,5 +1,5 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
- import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
2
+ import { encodeHex } from "byte-encodings/hex";
3
3
  /**
4
4
  * Calculates the [partial follower collection digest][1].
5
5
  *
@@ -1,5 +1,4 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
- import { isDeno, isNode } from "../deps/jsr.io/@david/which-runtime/0.2.1/mod.js";
3
2
  import { HTTPHeaderLink } from "@hugoalh/http-header-link";
4
3
  import { getLogger } from "@logtape/logtape";
5
4
  import process from "node:process";
@@ -328,12 +327,20 @@ export function kvCache({ loader, kv, prefix, rules }) {
328
327
  */
329
328
  export function getUserAgent({ software, url } = {}) {
330
329
  const fedify = `Fedify/${metadata.version}`;
331
- const runtime = isDeno ? `Deno/${dntShim.Deno.version.deno}` : "Bun" in dntShim.dntGlobalThis
332
- // @ts-ignore: `Bun` is a global variable in Bun
333
- ? `Bun/${Bun.version}`
334
- : isNode
335
- ? `Node.js/${process.version}`
336
- : null;
330
+ const runtime = // dnt-shim-ignore
331
+
332
+ // deno-lint-ignore no-explicit-any
333
+ globalThis.Deno?.version?.deno != null
334
+ ? `Deno/${dntShim.Deno.version.deno}`
335
+ // dnt-shim-ignore
336
+ // deno-lint-ignore no-explicit-any
337
+ : globalThis.process?.versions?.bun != null
338
+ ? `Bun/${process.versions.bun}`
339
+ // dnt-shim-ignore
340
+ // deno-lint-ignore no-explicit-any
341
+ : globalThis.process?.versions?.node != null
342
+ ? `Node.js/${process.versions.node}`
343
+ : null;
337
344
  const userAgent = software == null ? [fedify] : [software, fedify];
338
345
  if (runtime != null)
339
346
  userAgent.push(runtime);
@@ -1,13 +1,12 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
- import { concat } from "../deps/jsr.io/@std/bytes/1.0.6/concat.js";
3
- import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
4
- import { decodeBase64Url } from "../deps/jsr.io/@std/encoding/1.0.7/base64url.js";
5
- import { decodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
6
2
  import { Integer, Sequence } from "asn1js";
7
- import { decode, encode } from "./multibase/index.js";
3
+ import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
4
+ import { decodeBase64Url } from "byte-encodings/base64url";
5
+ import { decodeHex } from "byte-encodings/hex";
8
6
  import { addPrefix, getCodeFromData, rmPrefix } from "multicodec";
9
7
  import { createPublicKey } from "node:crypto";
10
8
  import { PublicKeyInfo } from "pkijs";
9
+ import { decode, encode } from "./multibase/index.js";
11
10
  import { validateCryptoKey } from "../sig/key.js";
12
11
  const algorithms = {
13
12
  "1.2.840.113549.1.1.1": { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
@@ -124,7 +123,9 @@ export async function exportMultibaseKey(key) {
124
123
  key.algorithm.hash.name ===
125
124
  "SHA-256") {
126
125
  const jwk = await dntShim.crypto.subtle.exportKey("jwk", key);
127
- const n = concat([new Uint8Array([0]), decodeBase64Url(jwk.n)]);
126
+ const decodedN = decodeBase64Url(jwk.n);
127
+ const n = new Uint8Array(decodedN.length + 1);
128
+ n.set(decodedN, 1);
128
129
  const sequence = new Sequence({
129
130
  value: [
130
131
  new Integer({
package/esm/sig/http.js CHANGED
@@ -2,9 +2,8 @@ import * as dntShim from "../_dnt.shims.js";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  import { SpanStatusCode, trace, } from "@opentelemetry/api";
4
4
  import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL, } from "@opentelemetry/semantic-conventions";
5
- import { timingSafeEqual } from "../deps/jsr.io/@std/crypto/1.0.5/timing_safe_equal.js";
6
- import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
7
- import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
5
+ import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
6
+ import { encodeHex } from "byte-encodings/hex";
8
7
  import { decodeDict, encodeItem, Item, } from "structured-field-values";
9
8
  import metadata from "../deno.js";
10
9
  import { CryptographicKey } from "../vocab/vocab.js";
@@ -808,4 +807,39 @@ export async function doubleKnock(request, identity, options = {}) {
808
807
  }
809
808
  return response;
810
809
  }
810
+ /**
811
+ * Performs a timing-safe equality comparison between two `Uint8Array` values.
812
+ *
813
+ * This function is designed to take a constant amount of time to execute,
814
+ * dependent only on the length of the longer of the two arrays,
815
+ * regardless of where the first difference in bytes occurs. This helps
816
+ * prevent timing attacks.
817
+ *
818
+ * @param a The first bytes.
819
+ * @param b The second bytes.
820
+ * @returns `true` if the arrays are of the same length and contain the same
821
+ * bytes, `false` otherwise.
822
+ * @since 1.6.0
823
+ */
824
+ export function timingSafeEqual(a, b) {
825
+ const lenA = a.length;
826
+ const lenB = b.length;
827
+ const commonLength = Math.max(lenA, lenB);
828
+ let result = 0;
829
+ // Perform byte-wise XOR comparison for the length of the longer array.
830
+ // If one array is shorter, its out-of-bounds "bytes" are treated as 0 for the comparison.
831
+ // All byte differences are accumulated into the `result` using bitwise OR.
832
+ for (let i = 0; i < commonLength; i++) {
833
+ const byteA = i < lenA ? a[i] : 0;
834
+ const byteB = i < lenB ? b[i] : 0;
835
+ result |= byteA ^ byteB;
836
+ }
837
+ // Incorporate the length difference into the result.
838
+ // If lengths are different, (lenA ^ lenB) will be non-zero, making `result` non-zero.
839
+ // This ensures that arrays are only considered equal if both their contents
840
+ // (up to their respective lengths) and their lengths are identical.
841
+ result |= lenA ^ lenB;
842
+ // `result` will be 0 if and only if all XORed byte pairs were 0 AND lengths were equal.
843
+ return result === 0;
844
+ }
811
845
  // cSpell: ignore keyid
package/esm/sig/ld.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  import { SpanStatusCode, trace } from "@opentelemetry/api";
4
- import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
5
- import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
4
+ import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
5
+ import { encodeHex } from "byte-encodings/hex";
6
6
  // @ts-ignore TS7016
7
7
  import jsonld from "jsonld";
8
8
  import metadata from "../deno.js";
package/esm/sig/proof.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  import { SpanStatusCode, trace } from "@opentelemetry/api";
4
- import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
4
+ import { encodeHex } from "byte-encodings/hex";
5
5
  // @ts-ignore: json-canon is not typed
6
6
  import serialize from "json-canon";
7
7
  import metadata from "../deno.js";