@fedify/fedify 2.4.0-dev.2122 → 2.4.0-dev.2129

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 (98) hide show
  1. package/dist/{builder-BCXywsZF.mjs → builder-C0bxZDL0.mjs} +3 -3
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{compound-proof-Fxd45Oy5.mjs → compound-proof-D9Kljk_7.mjs} +3 -3
  6. package/dist/{context-tOiJfBoD.d.ts → context-Cz1w5Krc.d.ts} +31 -5
  7. package/dist/{context-CoNRxGYp.mjs → context-DfSVPcJ8.mjs} +6 -3
  8. package/dist/{context-SMNOiiY6.d.cts → context-Dvec_D_h.d.cts} +31 -5
  9. package/dist/{deno-BZrnW0Qz.mjs → deno-_o3lkDlG.mjs} +1 -1
  10. package/dist/{docloader-3BHaS20Z.mjs → docloader-BbS0rO-Y.mjs} +7 -7
  11. package/dist/federation/builder.test.mjs +1 -1
  12. package/dist/federation/compound-fanout.test.mjs +3 -3
  13. package/dist/federation/handler-compound-proof.test.mjs +4 -4
  14. package/dist/federation/handler.test.mjs +6 -6
  15. package/dist/federation/hashlink-media.test.mjs +2 -2
  16. package/dist/federation/idempotency.test.mjs +2 -2
  17. package/dist/federation/metrics.test.mjs +1 -1
  18. package/dist/federation/middleware.test.mjs +8 -8
  19. package/dist/federation/mod.cjs +1 -1
  20. package/dist/federation/mod.d.cts +2 -2
  21. package/dist/federation/mod.d.ts +2 -2
  22. package/dist/federation/mod.js +1 -1
  23. package/dist/federation/outgoing-proof.test.mjs +6 -6
  24. package/dist/federation/portable-actor.test.mjs +3 -3
  25. package/dist/federation/portable-chain.test.d.mts +2 -0
  26. package/dist/federation/portable-chain.test.mjs +358 -0
  27. package/dist/federation/portable-gateway-keys.test.mjs +77 -6
  28. package/dist/federation/portable-inbox.test.mjs +9 -4
  29. package/dist/federation/portable.test.mjs +3 -3
  30. package/dist/federation/send.test.mjs +3 -3
  31. package/dist/federation/tasks/enqueue.test.mjs +2 -2
  32. package/dist/federation/tasks/tasks.test.mjs +3 -3
  33. package/dist/federation/temporal.test.mjs +1 -1
  34. package/dist/federation/webfinger.test.mjs +2 -2
  35. package/dist/{federation-Ml6NrgRV.cjs → federation-DRY8KrkB.cjs} +46 -22
  36. package/dist/{http-4bmgw-mA.cjs → http-B1J6E-bT.cjs} +384 -33
  37. package/dist/{http-B9BQDNIy.mjs → http-BpOiZE09.mjs} +18 -12
  38. package/dist/{http-D76Py0M4.d.cts → http-C-x_OLSp.d.ts} +57 -14
  39. package/dist/{http-BETASGl0.js → http-C2M6wcs8.js} +374 -35
  40. package/dist/{http-BrQgkJay.d.ts → http-CjezPjFX.d.cts} +57 -14
  41. package/dist/{key-PyYvun0F.mjs → key-DolJjJab.mjs} +103 -16
  42. package/dist/{kv-cache-CPqUxRL3.mjs → kv-cache-Bq2cah0c.mjs} +1 -1
  43. package/dist/{kv-cache-C4mv2ZFQ.js → kv-cache-D7TiyMxv.js} +6 -6
  44. package/dist/{kv-cache-D2Bz6t_c.cjs → kv-cache-D9nRbG2Q.cjs} +6 -6
  45. package/dist/{ld-u4JOD4iO.mjs → ld-Dwc176V4.mjs} +3 -3
  46. package/dist/{metrics-DCLoLvLz.mjs → metrics-CDaHfBXY.mjs} +1 -1
  47. package/dist/{middleware-B7bmtONC.mjs → middleware-CmB1FD8A.mjs} +1 -1
  48. package/dist/{middleware-DWlAGlyP.js → middleware-CylX-pvI.js} +52 -28
  49. package/dist/{middleware-CgOqRkK-.mjs → middleware-DN3MdTDg.mjs} +64 -39
  50. package/dist/{mod-CTh7ijx5.d.ts → mod-Bz9tFXI2.d.ts} +14 -3
  51. package/dist/{mod-Cwdt_CWU.d.ts → mod-CZetqT5h.d.ts} +1 -1
  52. package/dist/{mod-Cr79cQlc.d.cts → mod-D4g9ffEn.d.cts} +1 -1
  53. package/dist/{mod-DnElMslb.d.cts → mod-DGOIxEfb.d.cts} +1 -1
  54. package/dist/{mod-DMdGFMEl.d.cts → mod-S--JxYjo.d.cts} +14 -3
  55. package/dist/{mod-COWgSo2v.d.ts → mod-owwElvpw.d.ts} +1 -1
  56. package/dist/mod.cjs +8 -8
  57. package/dist/mod.d.cts +5 -5
  58. package/dist/mod.d.ts +5 -5
  59. package/dist/mod.js +5 -5
  60. package/dist/nodeinfo/handler.test.mjs +2 -2
  61. package/dist/{owner-CPFM-sqo.mjs → owner-BNHhwjNu.mjs} +37 -4
  62. package/dist/{sig-C1xOA4ml.js → portable-collection-CRpTUHCY.mjs} +5 -4
  63. package/dist/portable-collection-CgglAI9B.js +656 -0
  64. package/dist/{sig-Cb9VSeiF.cjs → portable-collection-PTGD0q70.cjs} +253 -2
  65. package/dist/portable-key-DqX2emHQ.mjs +395 -0
  66. package/dist/{portable-key-id-T7lecIbt.mjs → portable-key-id-Bg259c4Z.mjs} +69 -2
  67. package/dist/{proof-BCOg7Njv.mjs → proof-B4_0E-KU.mjs} +5 -5
  68. package/dist/{send-C8eOPat3.mjs → send-Dpu5qbP5.mjs} +3 -3
  69. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  70. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  71. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  72. package/dist/sig/compound-proof.test.mjs +2 -2
  73. package/dist/sig/http.test.mjs +2 -2
  74. package/dist/sig/key.test.mjs +1 -1
  75. package/dist/sig/ld.test.mjs +2 -2
  76. package/dist/sig/mod.cjs +5 -6
  77. package/dist/sig/mod.d.cts +2 -2
  78. package/dist/sig/mod.d.ts +2 -2
  79. package/dist/sig/mod.js +2 -3
  80. package/dist/sig/owner.test.mjs +1 -1
  81. package/dist/sig/portable-collection.test.mjs +20 -431
  82. package/dist/sig/portable-key.test.mjs +479 -5
  83. package/dist/sig/proof.test.mjs +3 -3
  84. package/dist/{temporal-vjHOhBpy.mjs → temporal-78JVR3GK.mjs} +1 -1
  85. package/dist/testing/kv.test.mjs +1 -1
  86. package/dist/testing/mod.d.mts +30 -4
  87. package/dist/testing/mod.mjs +2 -2
  88. package/dist/{testing-BWq1dCzx.mjs → testing-otQhu4aD.mjs} +1 -1
  89. package/dist/utils/docloader.test.mjs +81 -2
  90. package/dist/utils/kv-cache.test.mjs +1 -1
  91. package/dist/utils/mod.cjs +1 -1
  92. package/dist/utils/mod.d.cts +1 -1
  93. package/dist/utils/mod.d.ts +1 -1
  94. package/dist/utils/mod.js +1 -1
  95. package/package.json +7 -7
  96. package/dist/owner-DkA0Lz7v.cjs +0 -225
  97. package/dist/owner-wNinn7RK.js +0 -215
  98. package/dist/portable-key-DyylakVV.mjs +0 -214
@@ -1,10 +1,10 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-Dmm3t92W.cjs");
3
3
  const require_transformers = require("./transformers-BalCrSsr.cjs");
4
- const require_http = require("./http-4bmgw-mA.cjs");
4
+ const require_http = require("./http-B1J6E-bT.cjs");
5
5
  const require_types = require("./types-Be2zbyeG.cjs");
6
- const require_owner = require("./owner-DkA0Lz7v.cjs");
7
- const require_kv_cache = require("./kv-cache-D2Bz6t_c.cjs");
6
+ const require_portable_collection = require("./portable-collection-PTGD0q70.cjs");
7
+ const require_kv_cache = require("./kv-cache-D9nRbG2Q.cjs");
8
8
  let _logtape_logtape = require("@logtape/logtape");
9
9
  let _fedify_uri_template = require("@fedify/uri-template");
10
10
  let _fedify_vocab = require("@fedify/vocab");
@@ -4512,7 +4512,8 @@ async function handleInboxInternal(request, parameters, span) {
4512
4512
  documentLoader: ctx.documentLoader,
4513
4513
  keyCache,
4514
4514
  meterProvider,
4515
- tracerProvider
4515
+ tracerProvider,
4516
+ verifyPortableObject: ctx.verifyPortableObject
4516
4517
  });
4517
4518
  } catch (error) {
4518
4519
  if (error instanceof RangeError && await hasMalformedKnownTemporalLiteral(jsonWithoutSig, ctx.contextLoader)) return await respondInvalidActivity(error);
@@ -4670,7 +4671,7 @@ async function handleInboxInternal(request, parameters, span) {
4670
4671
  "http_signatures.verified": httpSigKey != null,
4671
4672
  "http_signatures.key_id": httpSigKey?.id?.href ?? ""
4672
4673
  });
4673
- if (!skipSignatureVerification && !proofVerified && (isPortableActivity(activity) || isPortableGatewayKey(httpSigKey))) {
4674
+ if (!skipSignatureVerification && !proofVerified && (isPortableActivity(activity) || isPortableActorKey(httpSigKey))) {
4674
4675
  if (deferredLdSignatureError != null) throw deferredLdSignatureError;
4675
4676
  logger.error("The activity {activityId} of the portable actor {actorId} is not authenticated by a valid Object Integrity Proof.", {
4676
4677
  activity: json,
@@ -4714,7 +4715,7 @@ async function handleInboxInternal(request, parameters, span) {
4714
4715
  });
4715
4716
  }
4716
4717
  }
4717
- if (httpSigKey != null && !await require_owner.doesActorOwnKey(activity, httpSigKey, ctx)) {
4718
+ if (httpSigKey != null && !await require_portable_collection.doesActorOwnKey(activity, httpSigKey, ctx)) {
4718
4719
  if (deferredLdSignatureError != null) throw deferredLdSignatureError;
4719
4720
  require_http.getFederationMetrics(parameters.meterProvider).recordSignatureVerificationFailure("actorKeyMismatch", httpSigKey.id == null ? void 0 : require_http.getRemoteHost(httpSigKey.id));
4720
4721
  logger.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
@@ -5451,13 +5452,13 @@ const MIN_COMPONENTS = [
5451
5452
  "@authority"
5452
5453
  ];
5453
5454
  /**
5454
- * Checks whether an HTTP Signature key is a gateway key of an FEP-ef61
5455
- * portable actor, i.e., its ID is a compatible identifier and it is owned by
5456
- * a portable actor, which only the portable actor's signed document can
5457
- * establish.
5455
+ * Checks whether an HTTP Signature key is a key of an FEP-ef61 portable
5456
+ * actor, i.e., its ID is a compatible identifier or an `ap:` or `ap+ef61:`
5457
+ * URI, and it is owned by a portable actor, which only the portable actor's
5458
+ * signed document can establish.
5458
5459
  */
5459
- function isPortableGatewayKey(key) {
5460
- return key?.id != null && require_http.isCompatibleKeyId(key.id) && key.ownerId != null && require_http.isPortableId(key.ownerId);
5460
+ function isPortableActorKey(key) {
5461
+ return key?.id != null && require_http.isPortableKeyId(key.id) && key.ownerId != null && require_http.isPortableId(key.ownerId);
5461
5462
  }
5462
5463
  /**
5463
5464
  * Checks whether an activity needs an Object Integrity Proof by its DID:
@@ -5894,7 +5895,7 @@ async function signOutgoingActivity(activity, candidates, options) {
5894
5895
  hasProof = true;
5895
5896
  break;
5896
5897
  }
5897
- const keys = candidates.filter((c) => c.privateKey.algorithm.name === "Ed25519" && !require_http.isCompatibleKeyId(c.verificationMethod));
5898
+ const keys = candidates.filter((c) => c.privateKey.algorithm.name === "Ed25519" && !require_http.isPortableKeyId(c.verificationMethod));
5898
5899
  if (!hasProof && activity.id != null && require_http.isPortableId(activity.id)) return await sign(selectPortableActivityKey(activity, activity.id, keys));
5899
5900
  if (keys.length < 1 || hasProof && !options.appendToExistingProofs) return {
5900
5901
  activity,
@@ -7211,11 +7212,16 @@ var FederationImpl = class extends FederationBuilderImpl {
7211
7212
  });
7212
7213
  return parsedActorIds;
7213
7214
  };
7214
- const parseActivity = () => _fedify_vocab.Activity.fromJsonLd(message.activity, {
7215
- contextLoader: this.contextLoaderFactory(loaderOptions),
7216
- documentLoader: rsaKeyPair == null ? this.documentLoaderFactory(loaderOptions) : this.authenticatedDocumentLoaderFactory(rsaKeyPair, loaderOptions),
7217
- tracerProvider: this.tracerProvider
7218
- });
7215
+ const parseActivity = () => {
7216
+ const contextLoader = this.contextLoaderFactory(loaderOptions);
7217
+ const documentLoader = rsaKeyPair == null ? this.documentLoaderFactory(loaderOptions) : this.authenticatedDocumentLoaderFactory(rsaKeyPair, loaderOptions);
7218
+ return _fedify_vocab.Activity.fromJsonLd(message.activity, {
7219
+ contextLoader,
7220
+ documentLoader,
7221
+ tracerProvider: this.tracerProvider,
7222
+ verifyPortableObject: createPortableObjectVerifier(documentLoader, contextLoader, this)
7223
+ });
7224
+ };
7219
7225
  const enqueueHeldOutboxMessage = async (delay, heldSince) => {
7220
7226
  const { outboxQueue } = this;
7221
7227
  if (outboxQueue == null) return;
@@ -7857,7 +7863,7 @@ var FederationImpl = class extends FederationBuilderImpl {
7857
7863
  const ldSignable = !require_http.hasPortableActor(activity);
7858
7864
  for (const { keyId, privateKey } of keys) {
7859
7865
  require_http.validateCryptoKey(privateKey, "private");
7860
- if (ldSignable && rsaKey == null && privateKey.algorithm.name === "RSASSA-PKCS1-v1_5" && !require_http.isCompatibleKeyId(keyId)) rsaKey = {
7866
+ if (ldSignable && rsaKey == null && privateKey.algorithm.name === "RSASSA-PKCS1-v1_5" && !require_http.isPortableKeyId(keyId)) rsaKey = {
7861
7867
  keyId,
7862
7868
  privateKey
7863
7869
  };
@@ -8691,12 +8697,28 @@ function getCollectionMetricRoute(routeName) {
8691
8697
  }
8692
8698
  }
8693
8699
  const FANOUT_THRESHOLD = 5;
8700
+ /**
8701
+ * Creates the FEP-ef61 portable object verifier that a context applies to
8702
+ * portable objects it dereferences: `verifyPortableObject()` with the given
8703
+ * loaders and the federation's tracer provider as defaults. Other options,
8704
+ * such as the document URL, gateways, and referrer, are passed through as
8705
+ * they are.
8706
+ */
8707
+ function createPortableObjectVerifier(documentLoader, contextLoader, federation) {
8708
+ return (document, options = {}) => require_portable_collection.verifyPortableObject(document, {
8709
+ ...options,
8710
+ documentLoader: options.documentLoader ?? documentLoader,
8711
+ contextLoader: options.contextLoader ?? contextLoader,
8712
+ tracerProvider: options.tracerProvider ?? federation.tracerProvider
8713
+ });
8714
+ }
8694
8715
  var ContextImpl = class ContextImpl {
8695
8716
  url;
8696
8717
  federation;
8697
8718
  data;
8698
8719
  documentLoader;
8699
8720
  contextLoader;
8721
+ verifyPortableObject;
8700
8722
  invokedFromActorKeyPairsDispatcher;
8701
8723
  #codec;
8702
8724
  constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
@@ -8705,6 +8727,7 @@ var ContextImpl = class ContextImpl {
8705
8727
  this.data = data;
8706
8728
  this.documentLoader = documentLoader;
8707
8729
  this.contextLoader = contextLoader;
8730
+ this.verifyPortableObject = createPortableObjectVerifier(documentLoader, contextLoader, federation);
8708
8731
  this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
8709
8732
  }
8710
8733
  /**
@@ -9056,7 +9079,7 @@ var ContextImpl = class ContextImpl {
9056
9079
  userAgent: options.userAgent ?? this.federation.userAgent,
9057
9080
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
9058
9081
  meterProvider: options.meterProvider ?? this.meterProvider,
9059
- verifyPortableObject: options.verifyPortableObject ?? require_http.verifyPortableObjectProof,
9082
+ verifyPortableObject: options.verifyPortableObject ?? this.verifyPortableObject,
9060
9083
  allowPrivateAddress: this.federation.allowPrivateAddress
9061
9084
  });
9062
9085
  }
@@ -9064,7 +9087,8 @@ var ContextImpl = class ContextImpl {
9064
9087
  return (0, _fedify_vocab.traverseCollection)(collection, {
9065
9088
  ...options,
9066
9089
  documentLoader: options.documentLoader ?? this.documentLoader,
9067
- contextLoader: options.contextLoader ?? this.contextLoader
9090
+ contextLoader: options.contextLoader ?? this.contextLoader,
9091
+ verifyPortableObject: options.verifyPortableObject ?? this.verifyPortableObject
9068
9092
  });
9069
9093
  }
9070
9094
  lookupNodeInfo(url, options = {}) {
@@ -9490,7 +9514,7 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
9490
9514
  const key = await this.getSignedKey(options);
9491
9515
  if (key == null) return this.#signedKeyOwner = null;
9492
9516
  try {
9493
- return this.#signedKeyOwner = await require_owner.getKeyOwner(key, {
9517
+ return this.#signedKeyOwner = await require_portable_collection.getKeyOwner(key, {
9494
9518
  contextLoader: options.contextLoader ?? this.contextLoader,
9495
9519
  documentLoader: options.documentLoader ?? this.documentLoader,
9496
9520
  tracerProvider: options.tracerProvider ?? this.tracerProvider