@fedify/fedify 1.7.10 → 1.7.12

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/{actor-m_MgQ1Da.js → actor-GZRoTRqg.js} +1059 -2276
  2. package/dist/{actor-C9RnX-Fl.js → actor-TYqJGdVq.js} +6 -9
  3. package/dist/{assert-DmFG7ppO.js → assert-LOEeCUK5.js} +1 -1
  4. package/dist/{assert_equals-CTYbeopb.js → assert_equals-B44MxcIj.js} +2 -4
  5. package/dist/{assert_instance_of-CF09JHYM.js → assert_instance_of-XtuFevV_.js} +1 -1
  6. package/dist/{assert_is_error-nrwA1GeT.js → assert_is_error-BTlryvT0.js} +1 -1
  7. package/dist/{assert_not_equals-Dc7y-V5Q.js → assert_not_equals-C685gKx6.js} +1 -1
  8. package/dist/{assert_rejects-C-sxEMM5.js → assert_rejects-DWQ4jaf9.js} +2 -2
  9. package/dist/{assert_throws-Cn9C6Jur.js → assert_throws-YetpVSc-.js} +2 -2
  10. package/dist/{authdocloader-cdK4XSRT.js → authdocloader-BopfyipD.js} +3 -3
  11. package/dist/{authdocloader-7OXAs5XI.js → authdocloader-hiFSyM7V.js} +4 -4
  12. package/dist/{builder-C7nJE1zO.js → builder-mi6RdzNE.js} +7 -10
  13. package/dist/{chunk-HsBuZ-b2.js → chunk-Cx8LTkjm.js} +3 -1
  14. package/dist/{client-DXIsEekV.js → client-DuUKk4pk.js} +6 -6
  15. package/dist/compat/transformers.test.js +27 -28
  16. package/dist/{context-Bts52fbz.js → context-RMU32mk4.js} +2 -2
  17. package/dist/{docloader-BK2Fp3AJ.js → docloader-DJxET2fN.js} +5 -9
  18. package/dist/{docloader-CgkbWVNz.js → docloader-bgBm1Hd1.js} +4 -6
  19. package/dist/{esm-Db4De7AS.js → esm-DO9PrujO.js} +23 -34
  20. package/dist/federation/builder.test.js +23 -29
  21. package/dist/federation/collection.test.js +9 -9
  22. package/dist/federation/handler.test.js +33 -33
  23. package/dist/federation/inbox.test.js +10 -10
  24. package/dist/federation/keycache.test.js +9 -9
  25. package/dist/federation/kv.test.js +10 -9
  26. package/dist/federation/middleware.test.js +76 -99
  27. package/dist/federation/mod.js +11 -11
  28. package/dist/federation/mq.test.js +10 -11
  29. package/dist/federation/retry.test.js +3 -3
  30. package/dist/federation/router.test.js +9 -9
  31. package/dist/federation/send.test.js +22 -22
  32. package/dist/{federation-BRIQn-GV.js → federation-B0aljx0V.js} +1 -2
  33. package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +24 -0
  34. package/dist/{http-D1IBucdD.js → http-D2DkwsjA.js} +56 -17
  35. package/dist/{http-CwQqD0nE.js → http-vqMAvOVs.js} +56 -17
  36. package/dist/{inbox-BrMkm2b5.js → inbox-DAAZZl2k.js} +5 -7
  37. package/dist/key-5ssHQ67E.js +16 -0
  38. package/dist/{key-Do-Pud3s.js → key-DSJGnD10.js} +4 -4
  39. package/dist/{key-C6phFgFq.js → key-DmqJj57e.js} +5 -8
  40. package/dist/{key-DtQ4rLnr.js → key-KVhaUM92.js} +6 -9
  41. package/dist/{keycache-B_99o7Nj.js → keycache-C1pEuRyQ.js} +2 -2
  42. package/dist/{keys-BgLpfFXK.js → keys-C4XQHW5_.js} +1 -1
  43. package/dist/{ld-AzOj4-js.js → ld-DzlJ_IpT.js} +9 -16
  44. package/dist/{lookup-DJgGrigh.js → lookup-CSngxuWm.js} +2 -4
  45. package/dist/{lookup-CBbanOdu.js → lookup-D0je8AqR.js} +7 -11
  46. package/dist/{lookup-ChtUDlB-.js → lookup-DL62q3Xh.js} +3 -5
  47. package/dist/{middleware-BS_et69x.js → middleware-3wVT6S9E.js} +34 -52
  48. package/dist/middleware-CxFoFBD8.js +33 -0
  49. package/dist/{middleware-R0UobiAQ.js → middleware-DlDXugwZ.js} +34 -58
  50. package/dist/middleware-w7_U3fFi.js +17 -0
  51. package/dist/mod.js +11 -11
  52. package/dist/{multibase-DeCHcK8L.js → multibase-CnLHszip.js} +1 -2
  53. package/dist/nodeinfo/client.test.js +20 -23
  54. package/dist/nodeinfo/handler.test.js +32 -32
  55. package/dist/nodeinfo/mod.js +2 -2
  56. package/dist/nodeinfo/semver.test.js +23 -30
  57. package/dist/nodeinfo/types.test.js +11 -11
  58. package/dist/{owner-Ces3Cs3s.js → owner-81ey_76X.js} +3 -3
  59. package/dist/{proof-BOQF8Trx.js → proof-BlULDH4H.js} +8 -14
  60. package/dist/{proof-BKV4HiE8.js → proof-DlI7QNdn.js} +12 -25
  61. package/dist/runtime/authdocloader.test.js +21 -21
  62. package/dist/runtime/docloader.test.js +16 -18
  63. package/dist/runtime/key.test.js +17 -17
  64. package/dist/runtime/langstr.test.js +9 -9
  65. package/dist/runtime/mod.js +6 -6
  66. package/dist/runtime/multibase/multibase.test.js +11 -12
  67. package/dist/runtime/url.test.js +6 -6
  68. package/dist/{semver-DWClQt_5.js → semver-BNrOOAs9.js} +1 -3
  69. package/dist/{send-aAmnTqe8.js → send-DdxfTHo6.js} +3 -4
  70. package/dist/sig/http.test.js +56 -54
  71. package/dist/sig/key.test.js +18 -18
  72. package/dist/sig/ld.test.js +20 -22
  73. package/dist/sig/mod.js +6 -6
  74. package/dist/sig/owner.test.js +20 -20
  75. package/dist/sig/proof.test.js +19 -19
  76. package/dist/{std__assert-vp0TKMS1.js → std__assert-o_r9vqm1.js} +1 -1
  77. package/dist/testing/docloader.test.js +9 -9
  78. package/dist/testing/mod.js +1 -1
  79. package/dist/{testing-BZ0dJ4qn.js → testing-DLyvtiiW.js} +3 -5
  80. package/dist/{type-D2s5lmbZ.js → type-CFuiGLz9.js} +1 -2
  81. package/dist/{types-C7C_l-jz.js → types-CJHS5pXl.js} +1 -1
  82. package/dist/{types-DBIKpLqH.js → types-CmVV9LT1.js} +6 -8
  83. package/dist/{url-kTAI6_KP.js → url-C2xuoQD1.js} +2 -4
  84. package/dist/vocab/actor.test.js +104 -156
  85. package/dist/vocab/lookup.test.js +17 -17
  86. package/dist/vocab/mod.js +4 -4
  87. package/dist/vocab/type.test.js +11 -15
  88. package/dist/vocab/vocab.test.js +45 -49
  89. package/dist/{vocab-F6vbRsQh.js → vocab-BebR0kAy.js} +6 -10
  90. package/dist/{vocab-BOerhowX.js → vocab-DFlq4Wa6.js} +1057 -2270
  91. package/dist/webfinger/handler.test.js +33 -34
  92. package/dist/webfinger/lookup.test.js +13 -13
  93. package/dist/webfinger/mod.js +2 -2
  94. package/dist/x/cfworkers.test.js +9 -9
  95. package/package.json +1 -1
  96. package/dist/key-ZtjFeVO8.js +0 -16
  97. package/dist/middleware-BVMzYv1x.js +0 -33
  98. package/dist/middleware-CnpuCK_K.js +0 -17
@@ -3,15 +3,15 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
5
  import { getDefaultActivityTransformers } from "./transformers-ghwJuzGY.js";
6
- import { deno_default, getDocumentLoader, kvCache } from "./docloader-BK2Fp3AJ.js";
7
- import { Activity, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-m_MgQ1Da.js";
8
- import { lookupWebFinger } from "./lookup-DJgGrigh.js";
9
- import { exportJwk, importJwk, validateCryptoKey } from "./key-C6phFgFq.js";
10
- import { doubleKnock, verifyRequest } from "./http-CwQqD0nE.js";
11
- import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-BKV4HiE8.js";
12
- import { getNodeInfo, nodeInfoToJson } from "./types-DBIKpLqH.js";
13
- import { getAuthenticatedDocumentLoader } from "./authdocloader-cdK4XSRT.js";
14
- import { lookupObject, traverseCollection } from "./vocab-F6vbRsQh.js";
6
+ import { deno_default, getDocumentLoader, kvCache } from "./docloader-DJxET2fN.js";
7
+ import { Activity, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-GZRoTRqg.js";
8
+ import { lookupWebFinger } from "./lookup-CSngxuWm.js";
9
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-DmqJj57e.js";
10
+ import { doubleKnock, verifyRequest } from "./http-vqMAvOVs.js";
11
+ import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-DlI7QNdn.js";
12
+ import { getNodeInfo, nodeInfoToJson } from "./types-CmVV9LT1.js";
13
+ import { getAuthenticatedDocumentLoader } from "./authdocloader-BopfyipD.js";
14
+ import { lookupObject, traverseCollection } from "./vocab-BebR0kAy.js";
15
15
  import { getLogger, withContext } from "@logtape/logtape";
16
16
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
17
17
  import { encodeHex } from "byte-encodings/hex";
@@ -67,8 +67,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
67
67
  activity.id.href
68
68
  ];
69
69
  if (cacheKey != null) {
70
- const cached = await kv.get(cacheKey);
71
- if (cached === true) {
70
+ if (await kv.get(cacheKey) === true) {
72
71
  logger$1.debug("Activity {activityId} has already been processed.", {
73
72
  activityId: activity.id?.href,
74
73
  activity: json,
@@ -125,8 +124,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
125
124
  return "enqueued";
126
125
  }
127
126
  tracerProvider = tracerProvider ?? trace.getTracerProvider();
128
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
129
- return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
127
+ return await tracerProvider.getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
130
128
  const dispatched = inboxListeners?.dispatchWithClass(activity);
131
129
  if (dispatched == null) {
132
130
  logger$1.error("Unsupported activity type:\n{activity}", {
@@ -312,7 +310,7 @@ var FederationBuilderImpl = class {
312
310
  this.objectTypeIds = {};
313
311
  }
314
312
  async build(options) {
315
- const { FederationImpl: FederationImpl$1 } = await import("./middleware-CnpuCK_K.js");
313
+ const { FederationImpl: FederationImpl$1 } = await import("./middleware-w7_U3fFi.js");
316
314
  const f = new FederationImpl$1(options);
317
315
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
318
316
  f.router = this.router.clone();
@@ -453,8 +451,7 @@ var FederationBuilderImpl = class {
453
451
  }
454
452
  setNodeInfoDispatcher(path, dispatcher) {
455
453
  if (this.router.has("nodeInfo")) throw new RouterError("NodeInfo dispatcher already set.");
456
- const variables = this.router.add(path, "nodeInfo");
457
- if (variables.size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
454
+ if (this.router.add(path, "nodeInfo").size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
458
455
  this.nodeInfoDispatcher = dispatcher;
459
456
  }
460
457
  setObjectDispatcher(cls, path, dispatcher) {
@@ -464,8 +461,7 @@ var FederationBuilderImpl = class {
464
461
  if (variables.size < 1) throw new RouterError("Path for object dispatcher must have at least one variable.");
465
462
  const callbacks = {
466
463
  dispatcher: (ctx, values) => {
467
- const tracer = this._getTracer();
468
- return tracer.startActiveSpan("activitypub.dispatch_object", {
464
+ return this._getTracer().startActiveSpan("activitypub.dispatch_object", {
469
465
  kind: SpanKind.SERVER,
470
466
  attributes: {
471
467
  "fedify.object.type": cls.typeId.href,
@@ -736,8 +732,7 @@ var FederationBuilderImpl = class {
736
732
  ]).warn("The {{handle}} variable in the inbox path is deprecated. Use {{identifier}} instead.");
737
733
  }
738
734
  if (sharedInboxPath != null) {
739
- const siVars = this.router.add(sharedInboxPath, "sharedInbox");
740
- if (siVars.size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
735
+ if (this.router.add(sharedInboxPath, "sharedInbox").size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
741
736
  }
742
737
  const listeners = this.inboxListeners = new InboxListenerSet();
743
738
  const setters = {
@@ -831,7 +826,7 @@ var KvKeyCache = class {
831
826
  return await Multikey.fromJsonLd(serialized, this.options);
832
827
  } catch {
833
828
  await this.kv.delete([...this.prefix, keyId.href]);
834
- return void 0;
829
+ return;
835
830
  }
836
831
  }
837
832
  }
@@ -901,8 +896,7 @@ function getFullType(spec) {
901
896
  return `${spec.type}/${spec.subtype}`;
902
897
  }
903
898
  function preferredMediaTypes(accept) {
904
- const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
905
- return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
899
+ return parseAccept(accept === void 0 ? "*/*" : accept ?? "").filter(isQuality).sort(compareSpecs).map(getFullType);
906
900
  }
907
901
 
908
902
  //#endregion
@@ -993,8 +987,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
993
987
  const spanName = name.trim().replace(/\s+/g, "_");
994
988
  tracerProvider = tracerProvider ?? trace.getTracerProvider();
995
989
  const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
996
- const url = new URL(request.url);
997
- const cursor = url.searchParams.get("cursor");
990
+ const cursor = new URL(request.url).searchParams.get("cursor");
998
991
  if (collectionCallbacks == null) return await onNotFound(request);
999
992
  let collection;
1000
993
  const baseUri = uriGetter(identifier);
@@ -1154,9 +1147,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
1154
1147
  return result;
1155
1148
  }
1156
1149
  async function handleInbox(request, options) {
1157
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
1158
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
1159
- return await tracer.startActiveSpan("activitypub.inbox", {
1150
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.inbox", {
1160
1151
  kind: options.queue == null ? SpanKind.SERVER : SpanKind.PRODUCER,
1161
1152
  attributes: { "activitypub.shared_inbox": options.recipient == null }
1162
1153
  }, async (span) => {
@@ -1188,8 +1179,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1188
1179
  });
1189
1180
  return await onNotFound(request);
1190
1181
  } else if (recipient != null) {
1191
- const actor = await actorDispatcher(ctx, recipient);
1192
- if (actor == null) {
1182
+ if (await actorDispatcher(ctx, recipient) == null) {
1193
1183
  logger$1.error("Actor {recipient} not found.", { recipient });
1194
1184
  span.setStatus({
1195
1185
  code: SpanStatusCode.ERROR,
@@ -1336,11 +1326,10 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1336
1326
  code: SpanStatusCode.ERROR,
1337
1327
  message: `Failed to verify the request's HTTP Signatures.`
1338
1328
  });
1339
- const response = new Response("Failed to verify the request signature.", {
1329
+ return new Response("Failed to verify the request signature.", {
1340
1330
  status: 401,
1341
1331
  headers: { "Content-Type": "text/plain; charset=utf-8" }
1342
1332
  });
1343
- return response;
1344
1333
  } else logger$1.debug("HTTP Signatures are verified.", { recipient });
1345
1334
  httpSigKey = key;
1346
1335
  }
@@ -1666,8 +1655,7 @@ function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
1666
1655
  */
1667
1656
  function sendActivity(options) {
1668
1657
  const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
1669
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
1670
- return tracer.startActiveSpan("activitypub.send_activity", {
1658
+ return tracerProvider.getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.send_activity", {
1671
1659
  kind: SpanKind.CLIENT,
1672
1660
  attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
1673
1661
  }, async (span) => {
@@ -1964,12 +1952,11 @@ var FederationImpl = class extends FederationBuilderImpl {
1964
1952
  });
1965
1953
  }
1966
1954
  async #listenFanoutMessage(data, message) {
1967
- const logger$1 = getLogger([
1955
+ getLogger([
1968
1956
  "fedify",
1969
1957
  "federation",
1970
1958
  "fanout"
1971
- ]);
1972
- logger$1.debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
1959
+ ]).debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
1973
1960
  activityId: message.activityId,
1974
1961
  inboxes: globalThis.Object.keys(message.inboxes).length
1975
1962
  });
@@ -2102,8 +2089,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2102
2089
  activity.id.href
2103
2090
  ];
2104
2091
  if (cacheKey != null) {
2105
- const cached = await this.kv.get(cacheKey);
2106
- if (cached === true) {
2092
+ if (await this.kv.get(cacheKey) === true) {
2107
2093
  logger$1.debug("Activity {activityId} has already been processed.", {
2108
2094
  activityId: activity.id?.href,
2109
2095
  activity: message.activity,
@@ -2350,8 +2336,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2350
2336
  const { outboxQueue } = this;
2351
2337
  if (outboxQueue.enqueueMany == null) {
2352
2338
  const promises = messages.map((m) => outboxQueue.enqueue(m));
2353
- const results = await Promise.allSettled(promises);
2354
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
2339
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
2355
2340
  if (errors.length > 0) {
2356
2341
  logger$1.error("Failed to enqueue activity {activityId} to send later: {errors}", {
2357
2342
  activityId: activity.id.href,
@@ -2750,7 +2735,6 @@ var ContextImpl = class ContextImpl {
2750
2735
  identifier: void 0,
2751
2736
  get handle() {
2752
2737
  logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
2753
- return void 0;
2754
2738
  }
2755
2739
  };
2756
2740
  const identifier = "identifier" in route.values ? route.values.identifier : route.values.handle;
@@ -2933,8 +2917,7 @@ var ContextImpl = class ContextImpl {
2933
2917
  } else identifierPromise = Promise.resolve(identity.identifier);
2934
2918
  return identifierPromise.then((identifier) => {
2935
2919
  if (identifier == null) return this.documentLoader;
2936
- const keyPair = this.getRsaKeyPairFromIdentifier(identifier);
2937
- return keyPair.then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
2920
+ return this.getRsaKeyPairFromIdentifier(identifier).then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
2938
2921
  });
2939
2922
  }
2940
2923
  return this.federation.authenticatedDocumentLoaderFactory(identity);
@@ -2976,8 +2959,7 @@ var ContextImpl = class ContextImpl {
2976
2959
  });
2977
2960
  }
2978
2961
  sendActivity(sender, recipients, activity, options = {}) {
2979
- const tracer = this.tracerProvider.getTracer(deno_default.name, deno_default.version);
2980
- return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
2962
+ return this.tracerProvider.getTracer(deno_default.name, deno_default.version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
2981
2963
  kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
2982
2964
  attributes: {
2983
2965
  "activitypub.activity.type": getTypeId(activity).href,
@@ -3122,9 +3104,7 @@ var ContextImpl = class ContextImpl {
3122
3104
  }
3123
3105
  }
3124
3106
  routeActivity(recipient, activity, options = {}) {
3125
- const tracerProvider = this.tracerProvider ?? this.tracerProvider;
3126
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
3127
- return tracer.startActiveSpan("activitypub.inbox", {
3107
+ return (this.tracerProvider ?? this.tracerProvider).getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.inbox", {
3128
3108
  kind: this.federation.inboxQueue == null || options.immediate ? SpanKind.INTERNAL : SpanKind.PRODUCER,
3129
3109
  attributes: { "activitypub.activity.type": getTypeId(activity).href }
3130
3110
  }, async (span) => {
@@ -3160,13 +3140,12 @@ var ContextImpl = class ContextImpl {
3160
3140
  const contextLoader = options.contextLoader ?? this.contextLoader;
3161
3141
  const json = await activity.toJsonLd({ contextLoader });
3162
3142
  const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
3163
- const verified = await verifyObject(Activity, json, {
3143
+ if (await verifyObject(Activity, json, {
3164
3144
  contextLoader,
3165
3145
  documentLoader: options.documentLoader ?? this.documentLoader,
3166
3146
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
3167
3147
  keyCache
3168
- });
3169
- if (verified == null) {
3148
+ }) == null) {
3170
3149
  logger$1.debug("Object Integrity Proofs are not verified.", {
3171
3150
  recipient,
3172
3151
  activity: json
@@ -3340,8 +3319,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
3340
3319
  });
3341
3320
  }
3342
3321
  forwardActivity(forwarder, recipients, options) {
3343
- const tracer = this.tracerProvider.getTracer(deno_default.name, deno_default.version);
3344
- return tracer.startActiveSpan("activitypub.outbox", {
3322
+ return this.tracerProvider.getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.outbox", {
3345
3323
  kind: this.federation.outboxQueue == null || options?.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
3346
3324
  attributes: { "activitypub.activity.type": this.activityType }
3347
3325
  }, async (span) => {
@@ -3392,8 +3370,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
3392
3370
  if (!hasSignature(this.activity)) {
3393
3371
  let hasProof;
3394
3372
  try {
3395
- const activity = await Activity.fromJsonLd(this.activity, this);
3396
- hasProof = await activity.getProof() != null;
3373
+ hasProof = await (await Activity.fromJsonLd(this.activity, this)).getProof() != null;
3397
3374
  } catch {
3398
3375
  hasProof = false;
3399
3376
  }
@@ -3471,8 +3448,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
3471
3448
  const { outboxQueue } = this.federation;
3472
3449
  if (outboxQueue.enqueueMany == null) {
3473
3450
  const promises = messages.map((m) => outboxQueue.enqueue(m));
3474
- const results = await Promise.allSettled(promises);
3475
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
3451
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
3476
3452
  if (errors.length > 0) {
3477
3453
  logger$1.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
3478
3454
  activityId: this.activityId,
@@ -0,0 +1,17 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "./transformers-ghwJuzGY.js";
6
+ import "./docloader-DJxET2fN.js";
7
+ import "./actor-GZRoTRqg.js";
8
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DlDXugwZ.js";
9
+ import "./lookup-CSngxuWm.js";
10
+ import "./key-DmqJj57e.js";
11
+ import "./http-vqMAvOVs.js";
12
+ import "./proof-DlI7QNdn.js";
13
+ import "./types-CmVV9LT1.js";
14
+ import "./authdocloader-BopfyipD.js";
15
+ import "./vocab-BebR0kAy.js";
16
+
17
+ export { FederationImpl };
package/dist/mod.js CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./transformers-ghwJuzGY.js";
6
6
  import "./compat-Bb5myD13.js";
7
- import { FetchError, fetchDocumentLoader, getDocumentLoader, getUserAgent, kvCache } from "./docloader-BK2Fp3AJ.js";
8
- import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, LanguageString, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, exportMultibaseKey, exportSpki, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, importMultibaseKey, importPem, importPkcs1, importSpki, isActor, normalizeActorHandle } from "./actor-m_MgQ1Da.js";
9
- import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "./middleware-R0UobiAQ.js";
10
- import { lookupWebFinger } from "./lookup-DJgGrigh.js";
11
- import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk } from "./key-C6phFgFq.js";
12
- import { signRequest, verifyRequest } from "./http-CwQqD0nE.js";
13
- import { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, getKeyOwner, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature } from "./proof-BKV4HiE8.js";
14
- import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation-BRIQn-GV.js";
15
- import { formatSemVer, getNodeInfo, nodeInfoToJson, parseNodeInfo, parseSemVer } from "./types-DBIKpLqH.js";
16
- import { getAuthenticatedDocumentLoader } from "./authdocloader-cdK4XSRT.js";
17
- import { PUBLIC_COLLECTION, lookupObject, traverseCollection } from "./vocab-F6vbRsQh.js";
7
+ import { FetchError, fetchDocumentLoader, getDocumentLoader, getUserAgent, kvCache } from "./docloader-DJxET2fN.js";
8
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, LanguageString, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, exportMultibaseKey, exportSpki, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, importMultibaseKey, importPem, importPkcs1, importSpki, isActor, normalizeActorHandle } from "./actor-GZRoTRqg.js";
9
+ import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "./middleware-DlDXugwZ.js";
10
+ import { lookupWebFinger } from "./lookup-CSngxuWm.js";
11
+ import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk } from "./key-DmqJj57e.js";
12
+ import { signRequest, verifyRequest } from "./http-vqMAvOVs.js";
13
+ import { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, getKeyOwner, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature } from "./proof-DlI7QNdn.js";
14
+ import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation-B0aljx0V.js";
15
+ import { formatSemVer, getNodeInfo, nodeInfoToJson, parseNodeInfo, parseSemVer } from "./types-CmVV9LT1.js";
16
+ import { getAuthenticatedDocumentLoader } from "./authdocloader-BopfyipD.js";
17
+ import { PUBLIC_COLLECTION, lookupObject, traverseCollection } from "./vocab-BebR0kAy.js";
18
18
  import "./nodeinfo-CyEbLjHs.js";
19
19
  import "./runtime-BSkOVUWM.js";
20
20
  import "./sig-BXJO--F9.js";
@@ -299,8 +299,7 @@ function decode(data) {
299
299
  "k",
300
300
  "K"
301
301
  ].includes(prefix)) data = data.toLowerCase();
302
- const enc = encoding(data[0]);
303
- return enc.decode(data.substring(1));
302
+ return encoding(data[0]).decode(data.substring(1));
304
303
  }
305
304
  /**
306
305
  * Get the encoding by name or code
@@ -3,20 +3,20 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { assertEquals } from "../assert_equals-CTYbeopb.js";
7
- import "../assert-DmFG7ppO.js";
8
- import "../assert_instance_of-CF09JHYM.js";
9
- import "../docloader-CgkbWVNz.js";
10
- import "../url-kTAI6_KP.js";
11
- import "../semver-DWClQt_5.js";
12
- import { getNodeInfo, parseInboundService, parseNodeInfo, parseOutboundService, parseProtocol, parseServices, parseSoftware, parseUsage } from "../client-DXIsEekV.js";
13
- import { test } from "../testing-BZ0dJ4qn.js";
14
- import "../std__assert-vp0TKMS1.js";
15
- import "../assert_rejects-C-sxEMM5.js";
16
- import "../assert_is_error-nrwA1GeT.js";
17
- import "../assert_not_equals-Dc7y-V5Q.js";
18
- import "../assert_throws-Cn9C6Jur.js";
19
- import { esm_default } from "../esm-Db4De7AS.js";
6
+ import { assertEquals } from "../assert_equals-B44MxcIj.js";
7
+ import "../assert-LOEeCUK5.js";
8
+ import "../assert_instance_of-XtuFevV_.js";
9
+ import "../docloader-bgBm1Hd1.js";
10
+ import "../url-C2xuoQD1.js";
11
+ import "../semver-BNrOOAs9.js";
12
+ import { getNodeInfo, parseInboundService, parseNodeInfo, parseOutboundService, parseProtocol, parseServices, parseSoftware, parseUsage } from "../client-DuUKk4pk.js";
13
+ import { test } from "../testing-DLyvtiiW.js";
14
+ import "../std__assert-o_r9vqm1.js";
15
+ import "../assert_rejects-DWQ4jaf9.js";
16
+ import "../assert_is_error-BTlryvT0.js";
17
+ import "../assert_not_equals-C685gKx6.js";
18
+ import "../assert_throws-YetpVSc-.js";
19
+ import { esm_default } from "../esm-DO9PrujO.js";
20
20
 
21
21
  //#region nodeinfo/client.test.ts
22
22
  test("getNodeInfo()", async (t) => {
@@ -446,7 +446,7 @@ test("parseSoftware()", () => {
446
446
  });
447
447
  });
448
448
  test("parseProtocol()", () => {
449
- const protocols = [
449
+ for (const protocol of [
450
450
  "activitypub",
451
451
  "buddycloud",
452
452
  "dfrn",
@@ -457,8 +457,7 @@ test("parseProtocol()", () => {
457
457
  "tent",
458
458
  "xmpp",
459
459
  "zot"
460
- ];
461
- for (const protocol of protocols) assertEquals(parseProtocol(protocol), protocol);
460
+ ]) assertEquals(parseProtocol(protocol), protocol);
462
461
  assertEquals(parseProtocol("foo"), null);
463
462
  });
464
463
  test("parseServices()", () => {
@@ -559,7 +558,7 @@ test("parseServices()", () => {
559
558
  });
560
559
  });
561
560
  test("parseInboundService()", () => {
562
- const services = [
561
+ for (const service of [
563
562
  "atom1.0",
564
563
  "gnusocial",
565
564
  "imap",
@@ -568,12 +567,11 @@ test("parseInboundService()", () => {
568
567
  "pumpio",
569
568
  "rss2.0",
570
569
  "twitter"
571
- ];
572
- for (const service of services) assertEquals(parseInboundService(service), service);
570
+ ]) assertEquals(parseInboundService(service), service);
573
571
  assertEquals(parseInboundService("foo"), null);
574
572
  });
575
573
  test("parseOutboundService()", () => {
576
- const services = [
574
+ for (const service of [
577
575
  "atom1.0",
578
576
  "blogger",
579
577
  "buddycloud",
@@ -602,8 +600,7 @@ test("parseOutboundService()", () => {
602
600
  "twitter",
603
601
  "wordpress",
604
602
  "xmpp"
605
- ];
606
- for (const service of services) assertEquals(parseOutboundService(service), service);
603
+ ]) assertEquals(parseOutboundService(service), service);
607
604
  assertEquals(parseOutboundService("foo"), null);
608
605
  });
609
606
  test("parseUsage()", () => {
@@ -3,44 +3,44 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { assertEquals } from "../assert_equals-CTYbeopb.js";
7
- import "../assert-DmFG7ppO.js";
8
- import "../assert_instance_of-CF09JHYM.js";
6
+ import { assertEquals } from "../assert_equals-B44MxcIj.js";
7
+ import "../assert-LOEeCUK5.js";
8
+ import "../assert_instance_of-XtuFevV_.js";
9
9
  import { MemoryKvStore } from "../kv-BMY6Qf_A.js";
10
- import { createFederation, handleNodeInfo, handleNodeInfoJrd } from "../middleware-BS_et69x.js";
11
- import "../docloader-CgkbWVNz.js";
12
- import "../url-kTAI6_KP.js";
13
- import { parseSemVer } from "../semver-DWClQt_5.js";
14
- import "../client-DXIsEekV.js";
10
+ import { createFederation, handleNodeInfo, handleNodeInfoJrd } from "../middleware-3wVT6S9E.js";
11
+ import "../docloader-bgBm1Hd1.js";
12
+ import "../url-C2xuoQD1.js";
13
+ import { parseSemVer } from "../semver-BNrOOAs9.js";
14
+ import "../client-DuUKk4pk.js";
15
15
  import "../router-D_aVZZUc.js";
16
- import "../types-C7C_l-jz.js";
17
- import "../multibase-DeCHcK8L.js";
18
- import "../vocab-BOerhowX.js";
16
+ import "../types-CJHS5pXl.js";
17
+ import "../multibase-CnLHszip.js";
18
+ import "../vocab-DFlq4Wa6.js";
19
19
  import "../langstr-DbWheeIS.js";
20
- import "../lookup-ChtUDlB-.js";
21
- import "../type-D2s5lmbZ.js";
22
- import "../actor-C9RnX-Fl.js";
23
- import "../key-DtQ4rLnr.js";
24
- import "../http-D1IBucdD.js";
25
- import "../authdocloader-7OXAs5XI.js";
26
- import "../ld-AzOj4-js.js";
27
- import "../owner-Ces3Cs3s.js";
28
- import "../proof-BOQF8Trx.js";
29
- import "../lookup-CBbanOdu.js";
30
- import "../inbox-BrMkm2b5.js";
31
- import "../builder-C7nJE1zO.js";
20
+ import "../lookup-DL62q3Xh.js";
21
+ import "../type-CFuiGLz9.js";
22
+ import "../actor-TYqJGdVq.js";
23
+ import "../key-KVhaUM92.js";
24
+ import "../http-D2DkwsjA.js";
25
+ import "../authdocloader-hiFSyM7V.js";
26
+ import "../ld-DzlJ_IpT.js";
27
+ import "../owner-81ey_76X.js";
28
+ import "../proof-BlULDH4H.js";
29
+ import "../lookup-D0je8AqR.js";
30
+ import "../inbox-DAAZZl2k.js";
31
+ import "../builder-mi6RdzNE.js";
32
32
  import "../collection-Dfb0TPno.js";
33
- import "../keycache-B_99o7Nj.js";
33
+ import "../keycache-C1pEuRyQ.js";
34
34
  import "../retry-BiIhZWgD.js";
35
- import "../send-aAmnTqe8.js";
36
- import { test } from "../testing-BZ0dJ4qn.js";
37
- import "../std__assert-vp0TKMS1.js";
38
- import "../assert_rejects-C-sxEMM5.js";
39
- import "../assert_is_error-nrwA1GeT.js";
40
- import "../assert_not_equals-Dc7y-V5Q.js";
41
- import "../assert_throws-Cn9C6Jur.js";
35
+ import "../send-DdxfTHo6.js";
36
+ import { test } from "../testing-DLyvtiiW.js";
37
+ import "../std__assert-o_r9vqm1.js";
38
+ import "../assert_rejects-DWQ4jaf9.js";
39
+ import "../assert_is_error-BTlryvT0.js";
40
+ import "../assert_not_equals-C685gKx6.js";
41
+ import "../assert_throws-YetpVSc-.js";
42
42
  import "../docloader-09nVWLAZ.js";
43
- import { createRequestContext } from "../context-Bts52fbz.js";
43
+ import { createRequestContext } from "../context-RMU32mk4.js";
44
44
 
45
45
  //#region nodeinfo/handler.test.ts
46
46
  test("handleNodeInfo()", async () => {
@@ -2,8 +2,8 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import "../docloader-BK2Fp3AJ.js";
6
- import { formatSemVer, getNodeInfo, nodeInfoToJson, parseNodeInfo, parseSemVer } from "../types-DBIKpLqH.js";
5
+ import "../docloader-DJxET2fN.js";
6
+ import { formatSemVer, getNodeInfo, nodeInfoToJson, parseNodeInfo, parseSemVer } from "../types-CmVV9LT1.js";
7
7
  import "../nodeinfo-CyEbLjHs.js";
8
8
 
9
9
  export { formatSemVer, getNodeInfo, nodeInfoToJson, parseNodeInfo, parseSemVer };
@@ -3,20 +3,20 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { assertEquals } from "../assert_equals-CTYbeopb.js";
7
- import "../assert-DmFG7ppO.js";
8
- import "../assert_instance_of-CF09JHYM.js";
9
- import { formatSemVer, parseSemVer } from "../semver-DWClQt_5.js";
10
- import { test } from "../testing-BZ0dJ4qn.js";
11
- import "../std__assert-vp0TKMS1.js";
12
- import "../assert_rejects-C-sxEMM5.js";
13
- import "../assert_is_error-nrwA1GeT.js";
14
- import "../assert_not_equals-Dc7y-V5Q.js";
15
- import { assertThrows } from "../assert_throws-Cn9C6Jur.js";
6
+ import { assertEquals } from "../assert_equals-B44MxcIj.js";
7
+ import "../assert-LOEeCUK5.js";
8
+ import "../assert_instance_of-XtuFevV_.js";
9
+ import { formatSemVer, parseSemVer } from "../semver-BNrOOAs9.js";
10
+ import { test } from "../testing-DLyvtiiW.js";
11
+ import "../std__assert-o_r9vqm1.js";
12
+ import "../assert_rejects-DWQ4jaf9.js";
13
+ import "../assert_is_error-BTlryvT0.js";
14
+ import "../assert_not_equals-C685gKx6.js";
15
+ import { assertThrows } from "../assert_throws-YetpVSc-.js";
16
16
 
17
17
  //#region nodeinfo/semver.test.ts
18
18
  test("parseSemVer() handles major", async (t) => {
19
- const versions = [
19
+ for (const [v, expected] of [
20
20
  ["1.2.3", 1],
21
21
  [" 1.2.3 ", 1],
22
22
  [" 2.2.3-4 ", 2],
@@ -24,14 +24,13 @@ test("parseSemVer() handles major", async (t) => {
24
24
  ["v5.2.3", 5],
25
25
  [" v8.2.3 ", 8],
26
26
  [" 13.2.3", 13]
27
- ];
28
- for (const [v, expected] of versions) await t.step(v, () => {
27
+ ]) await t.step(v, () => {
29
28
  const version = parseSemVer(v);
30
29
  assertEquals(version.major, expected);
31
30
  });
32
31
  });
33
32
  test("parseSemVer() handles minor", async (t) => {
34
- const versions = [
33
+ for (const [v, expected] of [
35
34
  ["1.1.3", 1],
36
35
  [" 1.1.3 ", 1],
37
36
  [" 1.2.3-4 ", 2],
@@ -39,14 +38,13 @@ test("parseSemVer() handles minor", async (t) => {
39
38
  ["v1.5.3", 5],
40
39
  [" v1.8.3 ", 8],
41
40
  [" 1.13.3", 13]
42
- ];
43
- for (const [v, expected] of versions) await t.step(v, () => {
41
+ ]) await t.step(v, () => {
44
42
  const version = parseSemVer(v);
45
43
  assertEquals(version.minor, expected);
46
44
  });
47
45
  });
48
46
  test("parseSemVer() handles patch", async (t) => {
49
- const versions = [
47
+ for (const [v, expected] of [
50
48
  ["1.2.1", 1],
51
49
  [" 1.2.1 ", 1],
52
50
  [" 1.2.2-4 ", 2],
@@ -54,15 +52,13 @@ test("parseSemVer() handles patch", async (t) => {
54
52
  ["v1.2.5", 5],
55
53
  [" v1.2.8 ", 8],
56
54
  [" 1.2.13", 13]
57
- ];
58
- for (const [v, expected] of versions) await t.step(v, () => {
59
- const semver = parseSemVer(v);
60
- const actual = semver.patch;
55
+ ]) await t.step(v, () => {
56
+ const actual = parseSemVer(v).patch;
61
57
  assertEquals(actual, expected);
62
58
  });
63
59
  });
64
60
  test("parseSemVer() handles prerelease", async (t) => {
65
- const versions = [
61
+ for (const [v, expected] of [
66
62
  ["1.2.2-alpha.1", ["alpha", 1]],
67
63
  ["0.6.1-1", [1]],
68
64
  ["1.0.0-beta.2", ["beta", 2]],
@@ -71,8 +67,7 @@ test("parseSemVer() handles prerelease", async (t) => {
71
67
  ["1.2.0-1b3-4", ["1b3-4"]],
72
68
  ["1.2.0-3.6-pre2", [3, "6-pre2"]],
73
69
  ["2.0.0", []]
74
- ];
75
- for (const [v, expected] of versions) await t.step(`${v} : ${JSON.stringify(expected)}`, () => {
70
+ ]) await t.step(`${v} : ${JSON.stringify(expected)}`, () => {
76
71
  const semver = parseSemVer(v);
77
72
  assertEquals(semver.prerelease, expected);
78
73
  });
@@ -101,14 +96,13 @@ test({
101
96
  }
102
97
  });
103
98
  test("parseSemVer() throws on invalid versions", async (t) => {
104
- const versions = [
99
+ for (const v of [
105
100
  "1.2.3.4",
106
101
  "NOT VALID",
107
102
  1.2,
108
103
  null,
109
104
  "Infinity.NaN.Infinity"
110
- ];
111
- for (const v of versions) await t.step(`invalid ${v}`, () => {
105
+ ]) await t.step(`invalid ${v}`, () => {
112
106
  assertThrows(function() {
113
107
  parseSemVer(v);
114
108
  }, TypeError);
@@ -119,7 +113,7 @@ test("parseSemVer() handles big numeric prerelease", function() {
119
113
  assertEquals(r.prerelease, ["beta", "90071992547409910"]);
120
114
  });
121
115
  test("formatSemVer()", async (t) => {
122
- const versions = [
116
+ for (const [version, expected] of [
123
117
  ["0.0.0", "0.0.0"],
124
118
  ["1.2.3", "1.2.3"],
125
119
  ["1.2.3-pre", "1.2.3-pre"],
@@ -127,8 +121,7 @@ test("formatSemVer()", async (t) => {
127
121
  ["1.2.3+b", "1.2.3+b"],
128
122
  ["1.2.3+b.0", "1.2.3+b.0"],
129
123
  ["1.2.3-pre.0+b.0", "1.2.3-pre.0+b.0"]
130
- ];
131
- for (const [version, expected] of versions) await t.step({
124
+ ]) await t.step({
132
125
  name: version,
133
126
  fn: () => {
134
127
  const v = parseSemVer(version);