@fedify/fedify 2.4.0-dev.1567 → 2.4.0-dev.1570

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 (113) hide show
  1. package/README.md +4 -0
  2. package/dist/{assert-OguE97r2.mjs → assert-DvVHoIZ0.mjs} +1 -1
  3. package/dist/{assert_instance_of-DBC5X09g.mjs → assert_instance_of-CxoC8bVq.mjs} +1 -1
  4. package/dist/{assert_not_equals-DkVK8oqV.mjs → assert_not_equals-C8vcTTA3.mjs} +1 -1
  5. package/dist/{assert_rejects-DN60FHPX.mjs → assert_rejects-DAdaaIWM.mjs} +2 -2
  6. package/dist/{assert_strict_equals-XEgZAlrj.mjs → assert_strict_equals-BzqyKuYL.mjs} +1 -1
  7. package/dist/{assert_throws-BOkhLGYc.mjs → assert_throws-zN79lgIC.mjs} +1 -1
  8. package/dist/{builder-DGWCUaNQ.mjs → builder-CJnWbgbj.mjs} +23 -3
  9. package/dist/codec-nfBU4Up4.mjs +124 -0
  10. package/dist/compat/mod.d.cts +1 -1
  11. package/dist/compat/mod.d.ts +1 -1
  12. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  13. package/dist/compat/public-audience.test.mjs +3 -3
  14. package/dist/compat/transformers.test.mjs +5 -5
  15. package/dist/{context-DVoTs_wM.mjs → context-BBRTgkrs.mjs} +8 -2
  16. package/dist/{context-BBVLF7lx.d.cts → context-BLe0NPtZ.d.cts} +530 -259
  17. package/dist/{context-BU6jSQdo.d.ts → context-GfQA-CqB.d.ts} +529 -259
  18. package/dist/{deno-Dho0TW0X.mjs → deno-klNxGW7W.mjs} +1 -1
  19. package/dist/{docloader-DCQSgDOg.mjs → docloader-CuFH35j1.mjs} +3 -3
  20. package/dist/federation/builder.test.mjs +5 -5
  21. package/dist/federation/circuit-breaker.test.mjs +5 -5
  22. package/dist/federation/collection.test.mjs +3 -3
  23. package/dist/federation/handler.test.mjs +13 -23
  24. package/dist/federation/idempotency.test.mjs +6 -6
  25. package/dist/federation/inbox.test.mjs +3 -3
  26. package/dist/federation/keycache.test.mjs +5 -5
  27. package/dist/federation/kv.test.mjs +3 -3
  28. package/dist/federation/metrics.test.mjs +4 -4
  29. package/dist/federation/middleware.test.mjs +204 -19
  30. package/dist/federation/mod.cjs +3 -259
  31. package/dist/federation/mod.d.cts +4 -4
  32. package/dist/federation/mod.d.ts +4 -4
  33. package/dist/federation/mod.js +1 -257
  34. package/dist/federation/mq.test.mjs +103 -261
  35. package/dist/federation/negotiation.test.mjs +4 -4
  36. package/dist/federation/retry.test.mjs +3 -3
  37. package/dist/federation/router.test.mjs +5 -5
  38. package/dist/federation/send.test.mjs +10 -10
  39. package/dist/federation/tasks/codec.test.d.mts +2 -0
  40. package/dist/federation/tasks/codec.test.mjs +302 -0
  41. package/dist/federation/tasks/enqueue.test.d.mts +2 -0
  42. package/dist/federation/tasks/enqueue.test.mjs +1057 -0
  43. package/dist/federation/tasks/tasks.test.d.mts +2 -0
  44. package/dist/federation/tasks/tasks.test.mjs +1228 -0
  45. package/dist/federation/temporal.test.mjs +4 -4
  46. package/dist/federation/webfinger.test.mjs +6 -6
  47. package/dist/{http-sngIMb9S.js → http-D0jH0kco.js} +16 -80
  48. package/dist/{http-C7Lot0it.cjs → http-DeuPW1Oh.cjs} +14 -78
  49. package/dist/{http-Bf8YhWOi.mjs → http-JdRPUYku.mjs} +4 -4
  50. package/dist/{key-3rYgSl9f.mjs → key-o0_ipvUR.mjs} +10 -76
  51. package/dist/{kv-cache-CO2IaDJu.cjs → kv-cache-C3rqzQvu.cjs} +1 -1
  52. package/dist/{kv-cache-P3scUO6t.mjs → kv-cache-CM7w20U5.mjs} +1 -1
  53. package/dist/{kv-cache-B0siRaoZ.js → kv-cache-DSWq2JHU.js} +1 -1
  54. package/dist/{ld-CCOPy-Co.mjs → ld-C__CEgQH.mjs} +3 -3
  55. package/dist/{metrics-CR4UD_gF.mjs → metrics-CLSPm4dZ.mjs} +8 -6
  56. package/dist/{mq-D-nlpY04.d.ts → metrics-CoUJLQhZ.d.cts} +69 -1
  57. package/dist/{mq-D8uSFzxe.d.cts → metrics-Dc4jR-IC.d.ts} +69 -1
  58. package/dist/{middleware-DUelXs9h.cjs → middleware-B502nwxx.cjs} +874 -134
  59. package/dist/{middleware-CIteB8IS.mjs → middleware-CdMiavoh.mjs} +1 -1
  60. package/dist/{middleware-DfBPuuvp.mjs → middleware-CjHqy-1i.mjs} +469 -150
  61. package/dist/{middleware-BoNiH9CQ.js → middleware-zuLSkPIk.js} +863 -135
  62. package/dist/{mod-C0F6kvgS.d.cts → mod-B8Efb9qp.d.cts} +1 -1
  63. package/dist/{mod-yvIXFAEi.d.cts → mod-BtEaIEcD.d.cts} +1 -31
  64. package/dist/{mod-vPYVoa5n.d.ts → mod-Cmr39iWq.d.ts} +1 -1
  65. package/dist/{mod-DFvNJcNb.d.ts → mod-UMmveiO0.d.ts} +1 -31
  66. package/dist/mod.cjs +6 -6
  67. package/dist/mod.d.cts +6 -6
  68. package/dist/mod.d.ts +6 -6
  69. package/dist/mod.js +5 -5
  70. package/dist/mq-03vS-C9P.mjs +276 -0
  71. package/dist/nodeinfo/client.test.mjs +3 -3
  72. package/dist/nodeinfo/handler.test.mjs +5 -5
  73. package/dist/nodeinfo/types.test.mjs +4 -4
  74. package/dist/otel/exporter.test.mjs +3 -3
  75. package/dist/{outgoing-jsonld-L_DbOaFe.mjs → outgoing-jsonld-BNL8AC14.mjs} +1 -1
  76. package/dist/{owner-TUz_H-M9.mjs → owner-gz4TUfKG.mjs} +2 -2
  77. package/dist/{proof-DzKUmE7R.cjs → proof-CiDzRtr0.cjs} +1 -1
  78. package/dist/{proof-CrI3UpuA.mjs → proof-CuQpZ_AT.mjs} +5 -5
  79. package/dist/{proof-C5i7MhbD.js → proof-DQWTf6oB.js} +1 -1
  80. package/dist/{send-BBs_erdP.mjs → send-B60teucv.mjs} +3 -3
  81. package/dist/sig/accept.test.mjs +1 -1
  82. package/dist/sig/http.test.mjs +8 -8
  83. package/dist/sig/key.test.mjs +7 -191
  84. package/dist/sig/ld.test.mjs +7 -7
  85. package/dist/sig/mod.cjs +2 -2
  86. package/dist/sig/mod.js +2 -2
  87. package/dist/sig/owner.test.mjs +6 -6
  88. package/dist/sig/proof.test.mjs +9 -69
  89. package/dist/{std__assert-BBjXFNOb.mjs → std__assert-Dh6uLf_q.mjs} +4 -4
  90. package/dist/{temporal-bBIy2G-F.mjs → temporal-CvVMrvJJ.mjs} +1 -1
  91. package/dist/testing/mod.d.mts +1037 -8
  92. package/dist/testing/mod.mjs +3 -2
  93. package/dist/testing-Dy-WhqpN.mjs +77 -0
  94. package/dist/utils/docloader.test.mjs +6 -6
  95. package/dist/utils/kv-cache.test.mjs +1 -1
  96. package/dist/utils/mod.cjs +1 -1
  97. package/dist/utils/mod.d.cts +1 -1
  98. package/dist/utils/mod.d.ts +1 -1
  99. package/dist/utils/mod.js +1 -1
  100. package/package.json +8 -6
  101. /package/dist/{accept-CPkZzmGN.mjs → accept-CgDcxvjV.mjs} +0 -0
  102. /package/dist/{activity-listener-tztVvlNb.mjs → activity-listener-BeTGV3wc.mjs} +0 -0
  103. /package/dist/{assert_equals-C-ZRDbaf.mjs → assert_equals-PBVKNMJd.mjs} +0 -0
  104. /package/dist/{circuit-breaker-CSWsyoef.mjs → circuit-breaker-hJBB6jwA.mjs} +0 -0
  105. /package/dist/{client-ByXmQhYD.mjs → client-B_A6mfn3.mjs} +0 -0
  106. /package/dist/{collection-Cc3DVAhE.mjs → collection-Dp5ky45w.mjs} +0 -0
  107. /package/dist/{keycache-BeU0LCII.mjs → keycache-CaOR6NYg.mjs} +0 -0
  108. /package/dist/{keys-DGu1NFwu.mjs → keys-CSYsOMFG.mjs} +0 -0
  109. /package/dist/{kv-rV3vodCc.mjs → kv-CIvR3Non.mjs} +0 -0
  110. /package/dist/{negotiation-DDstyBvc.mjs → negotiation-m_L2nyS3.mjs} +0 -0
  111. /package/dist/{public-audience-Cvbr2Gzt.mjs → public-audience-c9zmYKgA.mjs} +0 -0
  112. /package/dist/{retry-CXg_MBI-.mjs → retry-DI4O-zYl.mjs} +0 -0
  113. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
- import "../std__assert-BBjXFNOb.mjs";
6
- import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
4
+ import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
5
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
6
+ import "../std__assert-Dh6uLf_q.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { ExportResultCode } from "@opentelemetry/core";
9
9
  import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-Cvbr2Gzt.mjs";
4
+ import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-c9zmYKgA.mjs";
5
5
  import { getLogger } from "@logtape/logtape";
6
6
  import { preloadedContexts } from "@fedify/vocab-runtime";
7
7
  import jsonld from "@fedify/vocab-runtime/jsonld";
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-Dho0TW0X.mjs";
5
- import "./key-3rYgSl9f.mjs";
4
+ import { n as version, t as name } from "./deno-klNxGW7W.mjs";
5
+ import "./key-o0_ipvUR.mjs";
6
6
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  const require_chunk = require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-C7Lot0it.cjs");
4
+ const require_http = require("./http-DeuPW1Oh.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let _fedify_vocab = require("@fedify/vocab");
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,11 +1,11 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-Dho0TW0X.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-CR4UD_gF.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-3rYgSl9f.mjs";
7
- import { n as preloadedOnlyDocumentLoader } from "./public-audience-Cvbr2Gzt.mjs";
8
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
4
+ import { n as version, t as name } from "./deno-klNxGW7W.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-CLSPm4dZ.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-o0_ipvUR.mjs";
7
+ import { n as preloadedOnlyDocumentLoader } from "./public-audience-c9zmYKgA.mjs";
8
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BNL8AC14.mjs";
9
9
  import { getLogger } from "@logtape/logtape";
10
10
  import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
11
11
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-sngIMb9S.js";
3
+ import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-D0jH0kco.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-Dho0TW0X.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics } from "./metrics-CR4UD_gF.mjs";
6
- import { n as doubleKnock } from "./http-Bf8YhWOi.mjs";
4
+ import { n as version, t as name } from "./deno-klNxGW7W.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics } from "./metrics-CLSPm4dZ.mjs";
6
+ import { n as doubleKnock } from "./http-JdRPUYku.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { FetchError } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-CPkZzmGN.mjs";
4
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-CgDcxvjV.mjs";
5
5
  import { test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, strictEqual } from "node:assert/strict";
7
7
  //#region src/sig/accept.test.ts
@@ -2,14 +2,14 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-vrlUxr60.mjs";
5
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
6
- import { r as assertExists, t as assertStringIncludes } from "../std__assert-BBjXFNOb.mjs";
7
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
8
- import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
9
- import { t as assert } from "../assert-OguE97r2.mjs";
10
- import { t as exportJwk } from "../key-3rYgSl9f.mjs";
11
- import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-Bf8YhWOi.mjs";
12
- import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
5
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
6
+ import { r as assertExists, t as assertStringIncludes } from "../std__assert-Dh6uLf_q.mjs";
7
+ import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
8
+ import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
9
+ import { t as assert } from "../assert-DvVHoIZ0.mjs";
10
+ import { t as exportJwk } from "../key-o0_ipvUR.mjs";
11
+ import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-JdRPUYku.mjs";
12
+ import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
13
13
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
15
15
  import { encodeBase64 } from "byte-encodings/base64";
@@ -1,15 +1,15 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
- import "../std__assert-BBjXFNOb.mjs";
6
- import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
7
- import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
8
- import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-3rYgSl9f.mjs";
9
- import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
4
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
+ import "../std__assert-Dh6uLf_q.mjs";
6
+ import { t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
7
+ import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
8
+ import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-o0_ipvUR.mjs";
9
+ import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
10
10
  import { CryptographicKey, Multikey } from "@fedify/vocab";
11
11
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
12
- import { FetchError, exportDidKey } from "@fedify/vocab-runtime";
12
+ import { FetchError } from "@fedify/vocab-runtime";
13
13
  //#region src/sig/key.test.ts
14
14
  test("validateCryptoKey()", async () => {
15
15
  const pkcs1v15 = await crypto.subtle.generateKey({
@@ -303,190 +303,6 @@ test("fetchKeyDetailed() returns detailed fetch errors", async () => {
303
303
  if (detailedError == null || !("error" in detailedError)) throw new Error("Expected non-HTTP fetch error details.");
304
304
  assertEquals(detailedError.error, failure);
305
305
  });
306
- test("fetchKey() resolves did:key Multikeys without document loading", async () => {
307
- const did = await exportDidKey(ed25519PublicKey.publicKey);
308
- const keyId = `${did}#${did.slice(8)}`;
309
- const expectedKey = new Multikey({
310
- id: new URL(keyId),
311
- controller: new URL(did),
312
- publicKey: ed25519PublicKey.publicKey
313
- });
314
- const cache = { [keyId]: null };
315
- let documentLoaderCalls = 0;
316
- const options = {
317
- documentLoader() {
318
- documentLoaderCalls++;
319
- throw new TypeError("did:key must not use the document loader");
320
- },
321
- contextLoader: mockDocumentLoader,
322
- keyCache: {
323
- get(keyId) {
324
- return Promise.resolve(cache[keyId.href]);
325
- },
326
- set(keyId, key) {
327
- cache[keyId.href] = key;
328
- return Promise.resolve();
329
- }
330
- }
331
- };
332
- assertEquals(await fetchKey(keyId, Multikey, options), {
333
- key: expectedKey,
334
- cached: false
335
- });
336
- assertEquals(documentLoaderCalls, 0);
337
- assertEquals(cache[keyId], expectedKey);
338
- assertEquals(await fetchKey(keyId, Multikey, options), {
339
- key: expectedKey,
340
- cached: true
341
- });
342
- assertEquals(documentLoaderCalls, 0);
343
- });
344
- test("fetchKey() validates cached did:key Multikeys", async () => {
345
- const did = await exportDidKey(ed25519PublicKey.publicKey);
346
- const keyId = `${did}#${did.slice(8)}`;
347
- const wrongKeyPair = await generateCryptoKeyPair("Ed25519");
348
- const cachedKey = new Multikey({
349
- id: new URL(keyId),
350
- controller: new URL(did),
351
- publicKey: wrongKeyPair.publicKey
352
- });
353
- const expectedKey = new Multikey({
354
- id: new URL(keyId),
355
- controller: new URL(did),
356
- publicKey: ed25519PublicKey.publicKey
357
- });
358
- const cache = { [keyId]: cachedKey };
359
- let documentLoaderCalls = 0;
360
- assertEquals(await fetchKey(keyId, Multikey, {
361
- documentLoader() {
362
- documentLoaderCalls++;
363
- throw new TypeError("did:key must not use the document loader");
364
- },
365
- contextLoader: mockDocumentLoader,
366
- keyCache: {
367
- get(keyId) {
368
- return Promise.resolve(cache[keyId.href]);
369
- },
370
- set(keyId, key) {
371
- cache[keyId.href] = key;
372
- return Promise.resolve();
373
- }
374
- }
375
- }), {
376
- key: expectedKey,
377
- cached: false
378
- });
379
- assertEquals(documentLoaderCalls, 0);
380
- assertEquals(cache[keyId], expectedKey);
381
- });
382
- test("fetchKey() rejects unsupported did:key values locally", async () => {
383
- const invalidKeyId = "did:key:z6MksHj1MJnidCtDiyYW9ugNFftoX9fLK4bornTxmMZ6X7vq#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK";
384
- const cache = {};
385
- let documentLoaderCalls = 0;
386
- const [meterProvider, recorder] = createTestMeterProvider();
387
- assertEquals(await fetchKey(invalidKeyId, Multikey, {
388
- documentLoader() {
389
- documentLoaderCalls++;
390
- throw new TypeError("did:key must not use the document loader");
391
- },
392
- contextLoader: mockDocumentLoader,
393
- meterProvider,
394
- keyCache: {
395
- get(keyId) {
396
- return Promise.resolve(cache[keyId.href]);
397
- },
398
- set(keyId, key) {
399
- cache[keyId.href] = key;
400
- return Promise.resolve();
401
- }
402
- }
403
- }), {
404
- key: null,
405
- cached: false
406
- });
407
- assertEquals(documentLoaderCalls, 0);
408
- assertEquals(cache, {});
409
- assertEquals(recorder.getMeasurement("activitypub.key.lookup")?.attributes["activitypub.lookup.result"], "invalid");
410
- });
411
- test("fetchKeyDetailed() resolves did:key without fetchError", async () => {
412
- const did = await exportDidKey(ed25519PublicKey.publicKey);
413
- const result = await fetchKeyDetailed(`${did}#${did.slice(8)}`, Multikey, {
414
- documentLoader() {
415
- throw new TypeError("did:key must not use the document loader");
416
- },
417
- contextLoader: mockDocumentLoader
418
- });
419
- assertEquals(result.key instanceof Multikey, true);
420
- assertEquals(result.cached, false);
421
- assertEquals(result.fetchError, void 0);
422
- });
423
- test("fetchKeyDetailed() rejects invalid did:key without fetchError", async () => {
424
- const invalidKeyId = "did:key:z6MksHj1MJnidCtDiyYW9ugNFftoX9fLK4bornTxmMZ6X7vq#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK";
425
- const cache = {};
426
- let documentLoaderCalls = 0;
427
- const result = await fetchKeyDetailed(invalidKeyId, Multikey, {
428
- documentLoader() {
429
- documentLoaderCalls++;
430
- throw new TypeError("did:key must not use the document loader");
431
- },
432
- contextLoader: mockDocumentLoader,
433
- keyCache: {
434
- get(keyId) {
435
- return Promise.resolve(cache[keyId.href]);
436
- },
437
- set(keyId, key) {
438
- cache[keyId.href] = key;
439
- return Promise.resolve();
440
- }
441
- }
442
- });
443
- assertEquals(result.key, null);
444
- assertEquals(result.cached, false);
445
- assertEquals(result.fetchError, void 0);
446
- assertEquals(documentLoaderCalls, 0);
447
- assertEquals(cache, {});
448
- });
449
- test("fetchKey() does not resolve did:key as CryptographicKey", async () => {
450
- const did = await exportDidKey(ed25519PublicKey.publicKey);
451
- const keyId = `${did}#${did.slice(8)}`;
452
- let cacheGets = 0;
453
- let documentLoaderCalls = 0;
454
- assertEquals(await fetchKey(keyId, CryptographicKey, {
455
- documentLoader() {
456
- documentLoaderCalls++;
457
- throw new TypeError("did:key must not use the document loader");
458
- },
459
- contextLoader: mockDocumentLoader,
460
- keyCache: {
461
- get() {
462
- cacheGets++;
463
- throw new TypeError("did:key must not check the cache");
464
- },
465
- set() {
466
- throw new TypeError("did:key must not write to the cache");
467
- }
468
- }
469
- }), {
470
- key: null,
471
- cached: false
472
- });
473
- assertEquals(cacheGets, 0);
474
- assertEquals(documentLoaderCalls, 0);
475
- });
476
- test("fetchKey() records did:key lookup metrics", async () => {
477
- const did = await exportDidKey(ed25519PublicKey.publicKey);
478
- const keyId = `${did}#${did.slice(8)}`;
479
- const [meterProvider, recorder] = createTestMeterProvider();
480
- assertEquals((await fetchKey(keyId, Multikey, {
481
- documentLoader: mockDocumentLoader,
482
- contextLoader: mockDocumentLoader,
483
- meterProvider
484
- })).cached, false);
485
- const counter = recorder.getMeasurement("activitypub.key.lookup");
486
- assertEquals(counter?.attributes["activitypub.lookup.result"], "fetched");
487
- assertEquals(counter?.attributes["activitypub.cache.enabled"], false);
488
- assertEquals(counter?.attributes["activitypub.remote.host"], "");
489
- });
490
306
  test("fetchKey() records activitypub.key.lookup with hit on cached key", async () => {
491
307
  const [meterProvider, recorder] = createTestMeterProvider();
492
308
  const cache = {};
@@ -1,13 +1,13 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
6
- import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
7
- import { t as assert } from "../assert-OguE97r2.mjs";
8
- import { i as generateCryptoKeyPair } from "../key-3rYgSl9f.mjs";
9
- import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
10
- import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-CCOPy-Co.mjs";
4
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
+ import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
6
+ import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
7
+ import { t as assert } from "../assert-DvVHoIZ0.mjs";
8
+ import { i as generateCryptoKeyPair } from "../key-o0_ipvUR.mjs";
9
+ import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
10
+ import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-C__CEgQH.mjs";
11
11
  import { CryptographicKey } from "@fedify/vocab";
12
12
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
13
13
  import { encodeBase64 } from "byte-encodings/base64";
package/dist/sig/mod.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_http = require("../http-C7Lot0it.cjs");
5
- const require_proof = require("../proof-DzKUmE7R.cjs");
4
+ const require_http = require("../http-DeuPW1Oh.cjs");
5
+ const require_proof = require("../proof-CiDzRtr0.cjs");
6
6
  exports.attachSignature = require_proof.attachSignature;
7
7
  exports.createProof = require_proof.createProof;
8
8
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-sngIMb9S.js";
4
- import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-C5i7MhbD.js";
3
+ import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-D0jH0kco.js";
4
+ import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-DQWTf6oB.js";
5
5
  export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -1,12 +1,12 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
- import "../std__assert-BBjXFNOb.mjs";
6
- import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
7
- import { t as assert } from "../assert-OguE97r2.mjs";
8
- import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-TUz_H-M9.mjs";
4
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
+ import "../std__assert-Dh6uLf_q.mjs";
6
+ import { r as assertFalse } from "../assert_rejects-DAdaaIWM.mjs";
7
+ import { t as assert } from "../assert-DvVHoIZ0.mjs";
8
+ import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-gz4TUfKG.mjs";
10
10
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
11
11
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
12
12
  //#region src/sig/owner.test.ts
@@ -1,17 +1,17 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
- import "../std__assert-BBjXFNOb.mjs";
6
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
7
- import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
8
- import { t as assert } from "../assert-OguE97r2.mjs";
9
- import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
10
- import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-L_DbOaFe.mjs";
11
- import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-CrI3UpuA.mjs";
4
+ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
+ import "../std__assert-Dh6uLf_q.mjs";
6
+ import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
7
+ import { t as assertInstanceOf } from "../assert_instance_of-CxoC8bVq.mjs";
8
+ import { t as assert } from "../assert-DvVHoIZ0.mjs";
9
+ import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
10
+ import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-BNL8AC14.mjs";
11
+ import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-CuQpZ_AT.mjs";
12
12
  import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
13
13
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
- import { decodeMultibase, exportDidKey, exportMultibaseKey, importMultibaseKey, parseIri } from "@fedify/vocab-runtime";
14
+ import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
15
15
  import { decodeHex } from "byte-encodings/hex";
16
16
  //#region src/sig/proof.test.ts
17
17
  const fep8b32TestVectorPrivateKey = await crypto.subtle.importKey("jwk", {
@@ -326,66 +326,6 @@ test("verifyProof()", async () => {
326
326
  }), null);
327
327
  assertFalse(contextLoaderCalls.includes("https://attacker.example/ctx"));
328
328
  });
329
- test("verifyProof() resolves did:key verification methods locally", async () => {
330
- const multibaseKey = (await exportDidKey(ed25519PublicKey.publicKey)).slice(8);
331
- const did = `did:key:${multibaseKey}`;
332
- const keyId = new URL(`${did}#${multibaseKey}`);
333
- const created = Temporal.Instant.from("2023-02-24T23:36:38Z");
334
- const note = new Note({
335
- id: parseIri(`ap://did:key:${multibaseKey}/objects/1`),
336
- attribution: parseIri(`ap://did:key:${multibaseKey}/actor`),
337
- content: "Portable hello"
338
- });
339
- const proof = await createProof(note, ed25519PrivateKey, keyId, {
340
- created,
341
- contextLoader: mockDocumentLoader,
342
- context: ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"]
343
- });
344
- const jsonLd = await note.toJsonLd({
345
- format: "compact",
346
- contextLoader: mockDocumentLoader,
347
- context: ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"]
348
- });
349
- let documentLoaderCalls = 0;
350
- assertEquals(await verifyProof(jsonLd, proof, {
351
- contextLoader: mockDocumentLoader,
352
- documentLoader() {
353
- documentLoaderCalls++;
354
- throw new TypeError("did:key must not use the document loader");
355
- }
356
- }), new Multikey({
357
- id: keyId,
358
- controller: new URL(did),
359
- publicKey: ed25519PublicKey.publicKey
360
- }));
361
- assertEquals(documentLoaderCalls, 0);
362
- const tampered = { ...jsonLd };
363
- tampered.content = "Portable goodbye";
364
- assertEquals(await verifyProof(tampered, proof, {
365
- contextLoader: mockDocumentLoader,
366
- documentLoader() {
367
- throw new TypeError("did:key must not use the document loader");
368
- }
369
- }), null);
370
- assertEquals(await verifyProof(jsonLd, proof.clone({ verificationMethod: new URL(`${did}#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK`) }), {
371
- contextLoader: mockDocumentLoader,
372
- documentLoader() {
373
- throw new TypeError("did:key must not use the document loader");
374
- }
375
- }), null);
376
- const unsupportedMultibaseKey = await exportMultibaseKey(rsaPublicKey2.publicKey);
377
- const unsupportedDid = `did:key:${unsupportedMultibaseKey}`;
378
- const unsupportedProof = proof.clone({ verificationMethod: new URL(`${unsupportedDid}#${unsupportedMultibaseKey}`) });
379
- let unsupportedDocumentLoaderCalls = 0;
380
- assertEquals(await verifyProof(jsonLd, unsupportedProof, {
381
- contextLoader: mockDocumentLoader,
382
- documentLoader() {
383
- unsupportedDocumentLoaderCalls++;
384
- throw new TypeError("did:key must not use the document loader");
385
- }
386
- }), null);
387
- assertEquals(unsupportedDocumentLoaderCalls, 0);
388
- });
389
329
  test("verifyProof() records verification duration metric", async (t) => {
390
330
  const jsonLd = {
391
331
  "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { l as AssertionError, s as format } from "./assert_equals-C-ZRDbaf.mjs";
5
- import "./assert_rejects-DN60FHPX.mjs";
6
- import "./assert_throws-BOkhLGYc.mjs";
7
- import "./assert_strict_equals-XEgZAlrj.mjs";
4
+ import { l as AssertionError, s as format } from "./assert_equals-PBVKNMJd.mjs";
5
+ import "./assert_rejects-DAdaaIWM.mjs";
6
+ import "./assert_throws-zN79lgIC.mjs";
7
+ import "./assert_strict_equals-BzqyKuYL.mjs";
8
8
  //#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_exists.js
9
9
  /**
10
10
  * Make an assertion that actual is not null or undefined.
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { c as getNormalizationContextLoader } from "./ld-CCOPy-Co.mjs";
4
+ import { c as getNormalizationContextLoader } from "./ld-C__CEgQH.mjs";
5
5
  import jsonld from "@fedify/vocab-runtime/jsonld";
6
6
  //#region src/federation/temporal.ts
7
7
  function isPlainObject(value) {