@fedify/fedify 2.2.0-dev.924 → 2.2.0-dev.938

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 (86) hide show
  1. package/dist/assert_strict_equals-Dmjbg-bA.mjs +41 -0
  2. package/dist/{builder-FoLsluZw.mjs → builder-Dq6ijpsL.mjs} +3 -3
  3. package/dist/compat/mod.d.cts +1 -1
  4. package/dist/compat/mod.d.ts +1 -1
  5. package/dist/compat/outgoing-jsonld.test.d.mts +2 -0
  6. package/dist/compat/outgoing-jsonld.test.mjs +189 -0
  7. package/dist/compat/public-audience.test.mjs +1 -1
  8. package/dist/compat/transformers.test.mjs +3 -3
  9. package/dist/{context-BGrYMSTk.d.ts → context-BzH2-ajs.d.ts} +22 -0
  10. package/dist/{context-CMUd4wy0.d.cts → context-DJGagtNd.d.cts} +22 -0
  11. package/dist/{deno-BukNyK1t.mjs → deno-sVjM503s.mjs} +1 -1
  12. package/dist/{docloader-BgBM76TI.mjs → docloader-C5hOIM67.mjs} +2 -2
  13. package/dist/federation/builder.test.mjs +3 -3
  14. package/dist/federation/collection.test.mjs +2 -2
  15. package/dist/federation/handler.test.mjs +8 -8
  16. package/dist/federation/idempotency.test.mjs +5 -5
  17. package/dist/federation/inbox.test.mjs +1 -1
  18. package/dist/federation/keycache.test.mjs +3 -3
  19. package/dist/federation/kv.test.mjs +2 -2
  20. package/dist/federation/middleware.test.mjs +150 -10
  21. package/dist/federation/mod.cjs +1 -1
  22. package/dist/federation/mod.d.cts +2 -2
  23. package/dist/federation/mod.d.ts +2 -2
  24. package/dist/federation/mod.js +1 -1
  25. package/dist/federation/mq.test.mjs +2 -2
  26. package/dist/federation/negotiation.test.mjs +3 -3
  27. package/dist/federation/retry.test.mjs +1 -1
  28. package/dist/federation/router.test.mjs +2 -2
  29. package/dist/federation/send.test.mjs +6 -6
  30. package/dist/federation/webfinger.test.mjs +3 -3
  31. package/dist/{http-DiNUVHGB.js → http-DMkdP3lE.js} +1 -1
  32. package/dist/{http-1uLerNXX.cjs → http-De4te5mA.cjs} +1 -1
  33. package/dist/{http-DSghOjS0.mjs → http-pO-cqL07.mjs} +3 -3
  34. package/dist/{key-DAfSmMg7.mjs → key-Ch1SiRyF.mjs} +1 -1
  35. package/dist/{kv-cache-ia7oECIG.cjs → kv-cache-BM50uOpt.cjs} +1 -1
  36. package/dist/{kv-cache-Dq9VS_Jn.js → kv-cache-D7IdkIte.js} +1 -1
  37. package/dist/{ld-DYpo7uUC.mjs → ld-DkpX94b7.mjs} +2 -2
  38. package/dist/{middleware-rZ0jYYM9.cjs → middleware-0gXHFt3T.cjs} +1 -1
  39. package/dist/{middleware-aawr753E.mjs → middleware-BOshhaxP.mjs} +34 -24
  40. package/dist/{middleware-CjJ_aBdD.mjs → middleware-BqT40f_u.mjs} +1 -1
  41. package/dist/{middleware-Dt0fC6dK.cjs → middleware-CSKiL4bq.cjs} +20 -10
  42. package/dist/{middleware-olp7n2S4.js → middleware-T1_RW8x2.js} +19 -9
  43. package/dist/{mod-CJXfyw7v.d.ts → mod-2d12ffz3.d.ts} +1 -1
  44. package/dist/{mod-BcJHeuv1.d.cts → mod-D35TRn09.d.cts} +1 -1
  45. package/dist/mod.cjs +4 -4
  46. package/dist/mod.d.cts +2 -2
  47. package/dist/mod.d.ts +2 -2
  48. package/dist/mod.js +4 -4
  49. package/dist/nodeinfo/client.test.mjs +2 -2
  50. package/dist/nodeinfo/handler.test.mjs +3 -3
  51. package/dist/nodeinfo/types.test.mjs +2 -2
  52. package/dist/otel/exporter.test.mjs +2 -2
  53. package/dist/outgoing-jsonld-CNmZLixq.mjs +203 -0
  54. package/dist/{owner-B0_w8O-Y.mjs → owner-uOWCZ4oR.mjs} +2 -2
  55. package/dist/{proof-DDZ2W7TX.mjs → proof-B9ynOKyy.mjs} +12 -10
  56. package/dist/{proof-DgRfG4AE.cjs → proof-Bku-2gS1.cjs} +249 -42
  57. package/dist/{proof-DdnQ5edt.js → proof-DONzhIHm.js} +248 -41
  58. package/dist/{public-audience-eovWqzOF.mjs → public-audience-DYFHzm_c.mjs} +20 -9
  59. package/dist/{send-DMLb0UwP.mjs → send-D-qKOq3i.mjs} +2 -2
  60. package/dist/sig/accept.test.mjs +1 -1
  61. package/dist/sig/http.test.mjs +5 -5
  62. package/dist/sig/key.test.mjs +3 -3
  63. package/dist/sig/ld.test.mjs +4 -4
  64. package/dist/sig/mod.cjs +2 -2
  65. package/dist/sig/mod.js +2 -2
  66. package/dist/sig/owner.test.mjs +4 -4
  67. package/dist/sig/proof.test.mjs +25 -10
  68. package/dist/{std__assert-Duiq_YC9.mjs → std__assert-CRDpx_HF.mjs} +3 -38
  69. package/dist/testing/mod.d.mts +22 -0
  70. package/dist/utils/docloader.test.mjs +4 -4
  71. package/dist/utils/kv-cache.test.mjs +1 -1
  72. package/dist/utils/mod.cjs +1 -1
  73. package/dist/utils/mod.js +1 -1
  74. package/package.json +5 -5
  75. /package/dist/{accept-Dd__NiUL.mjs → accept-CPkZzmGN.mjs} +0 -0
  76. /package/dist/{activity-listener-CFzUqoCS.mjs → activity-listener-ell7W1s9.mjs} +0 -0
  77. /package/dist/{assert-ddO5KLpe.mjs → assert-DikXweDx.mjs} +0 -0
  78. /package/dist/{client-DVu6Fmom.mjs → client-D_1QpnWt.mjs} +0 -0
  79. /package/dist/{collection-BQRKGS7L.mjs → collection-D-HqUuA2.mjs} +0 -0
  80. /package/dist/{keycache-C2t1kvP5.mjs → keycache-EGATflN-.mjs} +0 -0
  81. /package/dist/{keys-BAK-tUlf.mjs → keys-DGu1NFwu.mjs} +0 -0
  82. /package/dist/{kv-cache-B01V7s3h.mjs → kv-cache-U__xU4qR.mjs} +0 -0
  83. /package/dist/{kv-C-TG81Sv.mjs → kv-rV3vodCc.mjs} +0 -0
  84. /package/dist/{negotiation-xb0QR3u_.mjs → negotiation-SQvQgUqe.mjs} +0 -0
  85. /package/dist/{retry-CJL0poaU.mjs → retry-bMXBL97A.mjs} +0 -0
  86. /package/dist/{types-CGUnLkU3.mjs → types-J53Kw7so.mjs} +0 -0
@@ -2,10 +2,10 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  require("./chunk-DDcVe30Y.cjs");
4
4
  const require_transformers = require("./transformers-NeAONrAq.cjs");
5
- const require_http = require("./http-1uLerNXX.cjs");
6
- const require_proof = require("./proof-DgRfG4AE.cjs");
5
+ const require_http = require("./http-De4te5mA.cjs");
6
+ const require_proof = require("./proof-Bku-2gS1.cjs");
7
7
  const require_types = require("./types-KC4QAoxe.cjs");
8
- const require_kv_cache = require("./kv-cache-ia7oECIG.cjs");
8
+ const require_kv_cache = require("./kv-cache-BM50uOpt.cjs");
9
9
  let _logtape_logtape = require("@logtape/logtape");
10
10
  let _fedify_vocab = require("@fedify/vocab");
11
11
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -210,7 +210,7 @@ var FederationBuilderImpl = class {
210
210
  this.collectionTypeIds = {};
211
211
  }
212
212
  async build(options) {
213
- const { FederationImpl } = await Promise.resolve().then(() => require("./middleware-rZ0jYYM9.cjs"));
213
+ const { FederationImpl } = await Promise.resolve().then(() => require("./middleware-0gXHFt3T.cjs"));
214
214
  const f = new FederationImpl(options);
215
215
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
216
216
  f.router = this.router.clone();
@@ -2973,6 +2973,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2973
2973
  await this.sendActivity(keys, message.inboxes, activity, {
2974
2974
  collectionSync: message.collectionSync,
2975
2975
  orderingKey: message.orderingKey,
2976
+ normalizeExistingProofs: message.normalizeExistingProofs,
2976
2977
  context
2977
2978
  });
2978
2979
  }
@@ -3257,6 +3258,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3257
3258
  else if (keys.length < 1) throw new TypeError("The keys must not be empty.");
3258
3259
  const contextLoader = this.contextLoaderFactory(this.#getLoaderOptions(ctx.origin));
3259
3260
  const activityId = activity.id.href;
3261
+ let hasProof = false;
3260
3262
  let proofCreated = false;
3261
3263
  let rsaKey = null;
3262
3264
  for (const { keyId, privateKey } of keys) {
@@ -3267,15 +3269,16 @@ var FederationImpl = class extends FederationBuilderImpl {
3267
3269
  };
3268
3270
  }
3269
3271
  for await (const _ of activity.getProofs({ contextLoader })) {
3270
- proofCreated = true;
3272
+ hasProof = true;
3271
3273
  break;
3272
3274
  }
3273
- if (!proofCreated) {
3275
+ if (!hasProof) {
3274
3276
  for (const { keyId, privateKey } of keys) if (privateKey.algorithm.name === "Ed25519") {
3275
3277
  activity = await require_proof.signObject(activity, privateKey, keyId, {
3276
3278
  contextLoader,
3277
3279
  tracerProvider: this.tracerProvider
3278
3280
  });
3281
+ hasProof = true;
3279
3282
  proofCreated = true;
3280
3283
  }
3281
3284
  }
@@ -3283,7 +3286,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3283
3286
  format: "compact",
3284
3287
  contextLoader
3285
3288
  });
3286
- jsonLd = await require_proof.normalizePublicAudience(jsonLd, contextLoader);
3289
+ if (proofCreated || !hasProof || options.normalizeExistingProofs) jsonLd = await require_proof.normalizeOutgoingActivityJsonLd(jsonLd, contextLoader);
3287
3290
  if (rsaKey == null) logger.warn("No supported key found to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature. In order to create a Linked Data signature, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
3288
3291
  activityId,
3289
3292
  keys: keys.map((pair) => ({
@@ -3295,7 +3298,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3295
3298
  contextLoader,
3296
3299
  tracerProvider: this.tracerProvider
3297
3300
  });
3298
- if (!proofCreated) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3301
+ if (!hasProof) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3299
3302
  activityId,
3300
3303
  keys: keys.map((pair) => ({
3301
3304
  keyId: pair.keyId.href,
@@ -4092,7 +4095,8 @@ var ContextImpl = class ContextImpl {
4092
4095
  context: this,
4093
4096
  orderingKey: options.orderingKey,
4094
4097
  collectionSync,
4095
- immediate: options.immediate
4098
+ immediate: options.immediate,
4099
+ normalizeExistingProofs: options.normalizeExistingProofs
4096
4100
  };
4097
4101
  span.setAttribute("activitypub.inboxes", expandedRecipients.length);
4098
4102
  for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
@@ -4104,6 +4108,7 @@ var ContextImpl = class ContextImpl {
4104
4108
  });
4105
4109
  throw new TypeError("The activity to send must have at least one actor property.");
4106
4110
  }
4111
+ let proofCreated = false;
4107
4112
  if (actorKeyPairs != null) {
4108
4113
  const contextLoader = this.contextLoader;
4109
4114
  for (const kp of actorKeyPairs) {
@@ -4112,6 +4117,7 @@ var ContextImpl = class ContextImpl {
4112
4117
  contextLoader,
4113
4118
  tracerProvider: this.tracerProvider
4114
4119
  });
4120
+ proofCreated = true;
4115
4121
  }
4116
4122
  }
4117
4123
  const inboxes = extractInboxes({
@@ -4132,7 +4138,10 @@ var ContextImpl = class ContextImpl {
4132
4138
  activity
4133
4139
  });
4134
4140
  if (this.federation.fanoutQueue == null || options.immediate || options.fanout === "skip" || (options.fanout ?? "auto") === "auto" && globalThis.Object.keys(inboxes).length < FANOUT_THRESHOLD) {
4135
- await this.federation.sendActivity(keys, inboxes, activity, opts);
4141
+ await this.federation.sendActivity(keys, inboxes, activity, {
4142
+ ...opts,
4143
+ normalizeExistingProofs: proofCreated || options.normalizeExistingProofs
4144
+ });
4136
4145
  return true;
4137
4146
  }
4138
4147
  const keyJwkPairs = await Promise.all(keys.map(async ({ keyId, privateKey }) => ({
@@ -4158,6 +4167,7 @@ var ContextImpl = class ContextImpl {
4158
4167
  activityType: (0, _fedify_vocab.getTypeId)(activity).href,
4159
4168
  collectionSync: opts.collectionSync,
4160
4169
  orderingKey: options.orderingKey,
4170
+ normalizeExistingProofs: proofCreated || options.normalizeExistingProofs,
4161
4171
  traceContext: carrier
4162
4172
  };
4163
4173
  if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  import { t as __exportAll } from "./chunk-nlSIicah.js";
4
4
  import { r as getDefaultActivityTransformers } from "./transformers-ve6e2xcg.js";
5
- import { _ as version, a as verifyRequestDetailed, d as validateCryptoKey, f as formatAcceptSignature, g as name, i as verifyRequest, n as parseRfc9421SignatureInput, o as exportJwk, t as doubleKnock, u as importJwk } from "./http-DiNUVHGB.js";
6
- import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizePublicAudience, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-DdnQ5edt.js";
5
+ import { _ as version, a as verifyRequestDetailed, d as validateCryptoKey, f as formatAcceptSignature, g as name, i as verifyRequest, n as parseRfc9421SignatureInput, o as exportJwk, t as doubleKnock, u as importJwk } from "./http-DMkdP3lE.js";
6
+ import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-DONzhIHm.js";
7
7
  import { n as getNodeInfo, t as nodeInfoToJson } from "./types-hvL8ElAs.js";
8
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-Dq9VS_Jn.js";
8
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-D7IdkIte.js";
9
9
  import { getLogger, withContext } from "@logtape/logtape";
10
10
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
11
11
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -2981,6 +2981,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2981
2981
  await this.sendActivity(keys, message.inboxes, activity, {
2982
2982
  collectionSync: message.collectionSync,
2983
2983
  orderingKey: message.orderingKey,
2984
+ normalizeExistingProofs: message.normalizeExistingProofs,
2984
2985
  context
2985
2986
  });
2986
2987
  }
@@ -3265,6 +3266,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3265
3266
  else if (keys.length < 1) throw new TypeError("The keys must not be empty.");
3266
3267
  const contextLoader = this.contextLoaderFactory(this.#getLoaderOptions(ctx.origin));
3267
3268
  const activityId = activity.id.href;
3269
+ let hasProof = false;
3268
3270
  let proofCreated = false;
3269
3271
  let rsaKey = null;
3270
3272
  for (const { keyId, privateKey } of keys) {
@@ -3275,15 +3277,16 @@ var FederationImpl = class extends FederationBuilderImpl {
3275
3277
  };
3276
3278
  }
3277
3279
  for await (const _ of activity.getProofs({ contextLoader })) {
3278
- proofCreated = true;
3280
+ hasProof = true;
3279
3281
  break;
3280
3282
  }
3281
- if (!proofCreated) {
3283
+ if (!hasProof) {
3282
3284
  for (const { keyId, privateKey } of keys) if (privateKey.algorithm.name === "Ed25519") {
3283
3285
  activity = await signObject(activity, privateKey, keyId, {
3284
3286
  contextLoader,
3285
3287
  tracerProvider: this.tracerProvider
3286
3288
  });
3289
+ hasProof = true;
3287
3290
  proofCreated = true;
3288
3291
  }
3289
3292
  }
@@ -3291,7 +3294,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3291
3294
  format: "compact",
3292
3295
  contextLoader
3293
3296
  });
3294
- jsonLd = await normalizePublicAudience(jsonLd, contextLoader);
3297
+ if (proofCreated || !hasProof || options.normalizeExistingProofs) jsonLd = await normalizeOutgoingActivityJsonLd(jsonLd, contextLoader);
3295
3298
  if (rsaKey == null) logger.warn("No supported key found to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature. In order to create a Linked Data signature, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
3296
3299
  activityId,
3297
3300
  keys: keys.map((pair) => ({
@@ -3303,7 +3306,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3303
3306
  contextLoader,
3304
3307
  tracerProvider: this.tracerProvider
3305
3308
  });
3306
- if (!proofCreated) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3309
+ if (!hasProof) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3307
3310
  activityId,
3308
3311
  keys: keys.map((pair) => ({
3309
3312
  keyId: pair.keyId.href,
@@ -4100,7 +4103,8 @@ var ContextImpl = class ContextImpl {
4100
4103
  context: this,
4101
4104
  orderingKey: options.orderingKey,
4102
4105
  collectionSync,
4103
- immediate: options.immediate
4106
+ immediate: options.immediate,
4107
+ normalizeExistingProofs: options.normalizeExistingProofs
4104
4108
  };
4105
4109
  span.setAttribute("activitypub.inboxes", expandedRecipients.length);
4106
4110
  for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
@@ -4112,6 +4116,7 @@ var ContextImpl = class ContextImpl {
4112
4116
  });
4113
4117
  throw new TypeError("The activity to send must have at least one actor property.");
4114
4118
  }
4119
+ let proofCreated = false;
4115
4120
  if (actorKeyPairs != null) {
4116
4121
  const contextLoader = this.contextLoader;
4117
4122
  for (const kp of actorKeyPairs) {
@@ -4120,6 +4125,7 @@ var ContextImpl = class ContextImpl {
4120
4125
  contextLoader,
4121
4126
  tracerProvider: this.tracerProvider
4122
4127
  });
4128
+ proofCreated = true;
4123
4129
  }
4124
4130
  }
4125
4131
  const inboxes = extractInboxes({
@@ -4140,7 +4146,10 @@ var ContextImpl = class ContextImpl {
4140
4146
  activity
4141
4147
  });
4142
4148
  if (this.federation.fanoutQueue == null || options.immediate || options.fanout === "skip" || (options.fanout ?? "auto") === "auto" && globalThis.Object.keys(inboxes).length < FANOUT_THRESHOLD) {
4143
- await this.federation.sendActivity(keys, inboxes, activity, opts);
4149
+ await this.federation.sendActivity(keys, inboxes, activity, {
4150
+ ...opts,
4151
+ normalizeExistingProofs: proofCreated || options.normalizeExistingProofs
4152
+ });
4144
4153
  return true;
4145
4154
  }
4146
4155
  const keyJwkPairs = await Promise.all(keys.map(async ({ keyId, privateKey }) => ({
@@ -4166,6 +4175,7 @@ var ContextImpl = class ContextImpl {
4166
4175
  activityType: getTypeId(activity).href,
4167
4176
  collectionSync: opts.collectionSync,
4168
4177
  orderingKey: options.orderingKey,
4178
+ normalizeExistingProofs: proofCreated || options.normalizeExistingProofs,
4169
4179
  traceContext: carrier
4170
4180
  };
4171
4181
  if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { $ as ActorAliasMapper, St as WebFingerLinksDispatcher, et as ActorDispatcher, l as RequestContext, tt as ActorHandleMapper } from "./context-BGrYMSTk.js";
3
+ import { $ as ActorAliasMapper, St as WebFingerLinksDispatcher, et as ActorDispatcher, l as RequestContext, tt as ActorHandleMapper } from "./context-BzH2-ajs.js";
4
4
  import { Span, Tracer } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/federation/webfinger.d.ts
@@ -1,4 +1,4 @@
1
- import { $ as ActorAliasMapper, St as WebFingerLinksDispatcher, et as ActorDispatcher, l as RequestContext, tt as ActorHandleMapper } from "./context-CMUd4wy0.cjs";
1
+ import { $ as ActorAliasMapper, St as WebFingerLinksDispatcher, et as ActorDispatcher, l as RequestContext, tt as ActorHandleMapper } from "./context-DJGagtNd.cjs";
2
2
  import { Span, Tracer } from "@opentelemetry/api";
3
3
 
4
4
  //#region src/federation/webfinger.d.ts
package/dist/mod.cjs CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("./chunk-DDcVe30Y.cjs");
5
5
  const require_transformers = require("./transformers-NeAONrAq.cjs");
6
6
  require("./compat/mod.cjs");
7
- const require_http = require("./http-1uLerNXX.cjs");
8
- const require_middleware = require("./middleware-Dt0fC6dK.cjs");
9
- const require_proof = require("./proof-DgRfG4AE.cjs");
7
+ const require_http = require("./http-De4te5mA.cjs");
8
+ const require_middleware = require("./middleware-CSKiL4bq.cjs");
9
+ const require_proof = require("./proof-Bku-2gS1.cjs");
10
10
  const require_types = require("./types-KC4QAoxe.cjs");
11
- const require_kv_cache = require("./kv-cache-ia7oECIG.cjs");
11
+ const require_kv_cache = require("./kv-cache-BM50uOpt.cjs");
12
12
  const require_federation_mod = require("./federation/mod.cjs");
13
13
  require("./nodeinfo/mod.cjs");
14
14
  require("./runtime/mod.cjs");
package/dist/mod.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "./client-z-8dc-e1.cjs";
2
2
  import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "./http-CrGuipxe.cjs";
3
3
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-CptqhsOy.cjs";
4
- import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as ActivityTransformer, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "./context-CMUd4wy0.cjs";
4
+ import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as ActivityTransformer, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "./context-DJGagtNd.cjs";
5
5
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-CbLNp3zQ.cjs";
6
6
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.cjs";
7
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-BcJHeuv1.cjs";
7
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-D35TRn09.cjs";
8
8
  import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "./mod-Cr3f-ACa.cjs";
9
9
  import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-CMEbIaNh.cjs";
10
10
  export * from "@fedify/vocab-runtime";
package/dist/mod.d.ts CHANGED
@@ -3,10 +3,10 @@ import { URLPattern } from "urlpattern-polyfill";
3
3
  import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "./client-AtlibPOU.js";
4
4
  import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "./http-aQzN9Ayi.js";
5
5
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-74ARJ5TL.js";
6
- import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as ActivityTransformer, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "./context-BGrYMSTk.js";
6
+ import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as ActivityTransformer, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "./context-BzH2-ajs.js";
7
7
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-GFYnFoOl.js";
8
8
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.js";
9
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-CJXfyw7v.js";
9
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-2d12ffz3.js";
10
10
  import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "./mod-CR8soWa9.js";
11
11
  import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-CLgIXe9w.js";
12
12
  export * from "@fedify/vocab-runtime";
package/dist/mod.js CHANGED
@@ -3,11 +3,11 @@ import "urlpattern-polyfill";
3
3
  import "./chunk-nlSIicah.js";
4
4
  import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-ve6e2xcg.js";
5
5
  import "./compat/mod.js";
6
- import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "./http-DiNUVHGB.js";
7
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "./middleware-olp7n2S4.js";
8
- import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "./proof-DdnQ5edt.js";
6
+ import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "./http-DMkdP3lE.js";
7
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "./middleware-T1_RW8x2.js";
8
+ import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "./proof-DONzhIHm.js";
9
9
  import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-hvL8ElAs.js";
10
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-Dq9VS_Jn.js";
10
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-D7IdkIte.js";
11
11
  import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation/mod.js";
12
12
  import "./nodeinfo/mod.js";
13
13
  import "./runtime/mod.js";
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-Duiq_YC9.mjs";
7
- import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-DVu6Fmom.mjs";
6
+ import "../std__assert-CRDpx_HF.mjs";
7
+ import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-D_1QpnWt.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/client.test.ts
10
10
  test("getNodeInfo()", async (t) => {
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-Duiq_YC9.mjs";
7
- import { t as MemoryKvStore } from "../kv-C-TG81Sv.mjs";
8
- import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-aawr753E.mjs";
6
+ import "../std__assert-CRDpx_HF.mjs";
7
+ import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
8
+ import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-BOshhaxP.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -2,9 +2,9 @@ import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-Duiq_YC9.mjs";
5
+ import "../std__assert-CRDpx_HF.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
7
- import { t as nodeInfoToJson } from "../types-CGUnLkU3.mjs";
7
+ import { t as nodeInfoToJson } from "../types-J53Kw7so.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/types.test.ts
10
10
  test("nodeInfoToJson()", () => {
@@ -2,8 +2,8 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-Duiq_YC9.mjs";
6
- import { t as MemoryKvStore } from "../kv-C-TG81Sv.mjs";
5
+ import "../std__assert-CRDpx_HF.mjs";
6
+ import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
9
9
  import { getLogger } from "@logtape/logtape";
@@ -0,0 +1,203 @@
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-DYFHzm_c.mjs";
5
+ import { preloadedContexts } from "@fedify/vocab-runtime";
6
+ import { getLogger } from "@logtape/logtape";
7
+ import jsonld from "@fedify/vocab-runtime/jsonld";
8
+ //#region src/compat/outgoing-jsonld.ts
9
+ const logger = getLogger([
10
+ "fedify",
11
+ "compat",
12
+ "outgoing-jsonld"
13
+ ]);
14
+ const ATTACHMENT_FIELDS = new Set(["attachment", "https://www.w3.org/ns/activitystreams#attachment"]);
15
+ const AS_CONTEXT_URL = "https://www.w3.org/ns/activitystreams";
16
+ const KNOWN_SAFE_CONTEXT_URLS = getKnownSafeContextUrls();
17
+ const MAX_TRAVERSAL_DEPTH = 64;
18
+ function isJsonLdListObject(value) {
19
+ return typeof value === "object" && value != null && Object.hasOwn(value, "@list");
20
+ }
21
+ function isJsonLdValueObject(value) {
22
+ return typeof value === "object" && value != null && Object.hasOwn(value, "@value");
23
+ }
24
+ function* getContextObjects(value, seen = /* @__PURE__ */ new WeakSet()) {
25
+ if (Array.isArray(value)) {
26
+ if (seen.has(value)) return;
27
+ seen.add(value);
28
+ for (const item of value) yield* getContextObjects(item, seen);
29
+ return;
30
+ }
31
+ if (typeof value === "object" && value != null) {
32
+ if (seen.has(value)) return;
33
+ seen.add(value);
34
+ const record = value;
35
+ yield record;
36
+ for (const definition of Object.values(record)) {
37
+ if (typeof definition !== "object" || definition == null) continue;
38
+ const nestedContext = definition["@context"];
39
+ if (nestedContext == null) continue;
40
+ yield* getContextObjects(nestedContext, seen);
41
+ }
42
+ }
43
+ }
44
+ function isActivityStreamsAttachmentTerm(value) {
45
+ return typeof value === "object" && value != null && value["@id"] === "as:attachment" && value["@type"] === "@id";
46
+ }
47
+ /** @internal */
48
+ function isPreloadedContextAttachmentSafe(document) {
49
+ if (typeof document !== "object" || document == null) return true;
50
+ const context = document["@context"];
51
+ for (const contextObject of getContextObjects(context)) {
52
+ if (!Object.hasOwn(contextObject, "attachment")) continue;
53
+ if (isActivityStreamsAttachmentTerm(contextObject.attachment)) continue;
54
+ return false;
55
+ }
56
+ return true;
57
+ }
58
+ function getKnownSafeContextUrls() {
59
+ const urls = /* @__PURE__ */ new Set();
60
+ for (const [url, document] of Object.entries(preloadedContexts)) if (isPreloadedContextAttachmentSafe(document)) urls.add(url);
61
+ else logger.warn("Preloaded JSON-LD context {contextUrl} redefines the `attachment` term incompatibly; attachment array normalization will require canonicalization for documents using it.", { contextUrl: url });
62
+ return urls;
63
+ }
64
+ /**
65
+ * Wraps scalar ActivityStreams attachment properties in arrays.
66
+ */
67
+ function wrapScalarAttachments(jsonLd, depth = 0) {
68
+ if (depth >= MAX_TRAVERSAL_DEPTH) return jsonLd;
69
+ if (Array.isArray(jsonLd)) {
70
+ let normalized = null;
71
+ for (let i = 0; i < jsonLd.length; i++) {
72
+ const item = jsonLd[i];
73
+ const next = wrapScalarAttachments(item, depth + 1);
74
+ if (normalized == null && next !== item) normalized = jsonLd.slice(0, i);
75
+ if (normalized != null) normalized[i] = next;
76
+ }
77
+ return normalized ?? jsonLd;
78
+ }
79
+ if (typeof jsonLd !== "object" || jsonLd == null) return jsonLd;
80
+ const record = jsonLd;
81
+ const keys = Object.keys(record);
82
+ let normalized = null;
83
+ for (let i = 0; i < keys.length; i++) {
84
+ const key = keys[i];
85
+ const value = record[key];
86
+ const next = key === "@context" || key === "@value" && isJsonLdValueObject(jsonLd) ? value : wrapScalarAttachments(value, depth + 1);
87
+ const output = ATTACHMENT_FIELDS.has(key) && next != null && !Array.isArray(next) && !isJsonLdListObject(next) ? [next] : next;
88
+ if (normalized == null && output !== value) {
89
+ const cloned = Object.create(null);
90
+ for (let j = 0; j < i; j++) {
91
+ const previousKey = keys[j];
92
+ cloned[previousKey] = record[previousKey];
93
+ }
94
+ normalized = cloned;
95
+ }
96
+ if (normalized != null) normalized[key] = output;
97
+ }
98
+ return normalized ?? jsonLd;
99
+ }
100
+ function hasNestedContext(value, depth = 0) {
101
+ if (depth >= MAX_TRAVERSAL_DEPTH) return true;
102
+ if (Array.isArray(value)) return value.some((item) => hasNestedContext(item, depth + 1));
103
+ if (typeof value !== "object" || value == null) return false;
104
+ const record = value;
105
+ for (const key of Object.keys(record)) {
106
+ if (key === "@context") return true;
107
+ if (key === "@value" && isJsonLdValueObject(value)) continue;
108
+ if (hasNestedContext(record[key], depth + 1)) return true;
109
+ }
110
+ return false;
111
+ }
112
+ function exceedsTraversalDepth(value, depth = 0) {
113
+ if (depth >= MAX_TRAVERSAL_DEPTH) return true;
114
+ if (Array.isArray(value)) return value.some((item) => exceedsTraversalDepth(item, depth + 1));
115
+ if (typeof value !== "object" || value == null) return false;
116
+ const record = value;
117
+ for (const key of Object.keys(record)) {
118
+ if (key === "@context" || key === "@value" && isJsonLdValueObject(value)) continue;
119
+ if (exceedsTraversalDepth(record[key], depth + 1)) return true;
120
+ }
121
+ return false;
122
+ }
123
+ function hasKnownSafeContext(jsonLd) {
124
+ if (typeof jsonLd !== "object" || jsonLd == null) return false;
125
+ const record = jsonLd;
126
+ if (!Object.hasOwn(record, "@context")) return false;
127
+ const context = record["@context"];
128
+ const entries = typeof context === "string" ? [context] : Array.isArray(context) ? context : null;
129
+ if (entries == null || entries.length < 1) return false;
130
+ let hasActivityStreamsContext = false;
131
+ for (const entry of entries) {
132
+ if (typeof entry !== "string") return false;
133
+ if (!KNOWN_SAFE_CONTEXT_URLS.has(entry)) return false;
134
+ if (entry === AS_CONTEXT_URL) hasActivityStreamsContext = true;
135
+ }
136
+ if (!hasActivityStreamsContext) return false;
137
+ for (const key of Object.keys(record)) {
138
+ if (key === "@context") continue;
139
+ if (hasNestedContext(record[key])) return false;
140
+ }
141
+ return true;
142
+ }
143
+ function getLogSafeJsonLdMetadata(jsonLd) {
144
+ if (typeof jsonLd !== "object" || jsonLd == null) return {};
145
+ const record = jsonLd;
146
+ const context = record["@context"];
147
+ return {
148
+ id: typeof record.id === "string" ? record.id : typeof record["@id"] === "string" ? record["@id"] : void 0,
149
+ type: typeof record.type === "string" ? record.type : typeof record["@type"] === "string" ? record["@type"] : void 0,
150
+ context: typeof context === "string" ? context : Array.isArray(context) ? context.filter((entry) => typeof entry === "string").slice(0, 4) : context == null ? void 0 : "[inline context]"
151
+ };
152
+ }
153
+ /**
154
+ * Ensures ActivityStreams attachment properties are represented as arrays
155
+ * when doing so preserves the JSON-LD semantics.
156
+ *
157
+ * JSON-LD compaction collapses single-item arrays into scalar values by
158
+ * default. Some ActivityPub implementations, Pixelfed among them, parse
159
+ * `attachment` as a plain JSON array rather than a JSON-LD property and reject
160
+ * otherwise valid objects whose single attachment is emitted as a scalar.
161
+ *
162
+ * When no `contextLoader` is supplied, the helper falls back to a restricted
163
+ * loader that resolves only Fedify's preloaded JSON-LD contexts and rejects
164
+ * every other URL without network access. Documents with custom, inline, or
165
+ * otherwise uncached contexts should pass a real `contextLoader` if they need
166
+ * the semantic-preservation check to succeed; otherwise canonicalization
167
+ * failures leave the original document unchanged.
168
+ */
169
+ async function normalizeAttachmentArrays(jsonLd, contextLoader) {
170
+ const normalized = wrapScalarAttachments(jsonLd);
171
+ if (normalized === jsonLd) return jsonLd;
172
+ if (exceedsTraversalDepth(jsonLd)) {
173
+ logger.debug("Skipping attachment array normalization because the JSON-LD document exceeds the safe traversal depth; leaving it unchanged.");
174
+ return jsonLd;
175
+ }
176
+ if (hasKnownSafeContext(jsonLd)) return normalized;
177
+ const loader = contextLoader ?? preloadedOnlyDocumentLoader;
178
+ try {
179
+ const [before, after] = await Promise.all([jsonld.canonize(jsonLd, {
180
+ format: "application/n-quads",
181
+ documentLoader: loader
182
+ }), jsonld.canonize(normalized, {
183
+ format: "application/n-quads",
184
+ documentLoader: loader
185
+ })]);
186
+ if (before === after) return normalized;
187
+ logger.warn("Wrapping scalar attachment values in arrays would change the canonical form of the JSON-LD document; leaving it unchanged. This usually means the active JSON-LD context redefines the `attachment` term. Document: {id}; type: {type}; context: {context}.", getLogSafeJsonLdMetadata(jsonLd));
188
+ } catch (error) {
189
+ logger.debug("Failed to verify attachment array normalization equivalence via JSON-LD canonicalization; leaving the JSON-LD document unchanged.\n{error}", { error });
190
+ }
191
+ return jsonLd;
192
+ }
193
+ /**
194
+ * Applies Fedify's internal JSON-LD wire-format interoperability workarounds
195
+ * to locally generated outgoing activities before they are signed, enqueued,
196
+ * or sent.
197
+ */
198
+ async function normalizeOutgoingActivityJsonLd(jsonLd, contextLoader) {
199
+ jsonLd = await normalizePublicAudience(jsonLd, contextLoader);
200
+ return await normalizeAttachmentArrays(jsonLd, contextLoader);
201
+ }
202
+ //#endregion
203
+ export { normalizeAttachmentArrays as n, normalizeOutgoingActivityJsonLd as r, isPreloadedContextAttachmentSafe as t };
@@ -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-BukNyK1t.mjs";
5
- import "./key-DAfSmMg7.mjs";
4
+ import { n as version, t as name } from "./deno-sVjM503s.mjs";
5
+ import "./key-Ch1SiRyF.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";