@fedify/fedify 2.2.0-dev.613 → 2.2.0-dev.622

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 (207) hide show
  1. package/dist/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
  2. package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
  3. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  4. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  5. package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  6. package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
  7. package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
  8. package/dist/{builder-OscY92PK.js → builder-DcSpny3g.mjs} +32 -41
  9. package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
  10. package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
  11. package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
  12. package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
  13. package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
  14. package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
  15. package/dist/compat/mod.cjs +5 -8
  16. package/dist/compat/mod.d.cts +78 -6
  17. package/dist/compat/mod.d.ts +78 -6
  18. package/dist/compat/mod.js +4 -8
  19. package/dist/compat/transformers.test.mjs +62 -0
  20. package/dist/{context-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
  21. package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
  22. package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
  23. package/dist/deno-D682wzlW.mjs +8 -0
  24. package/dist/{docloader-JiZmL7BP.js → docloader-CCWf4tNV.mjs} +8 -14
  25. package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
  26. package/dist/federation/builder.test.d.mts +2 -0
  27. package/dist/federation/{builder.test.js → builder.test.mjs} +21 -44
  28. package/dist/federation/collection.test.d.mts +2 -0
  29. package/dist/federation/collection.test.mjs +21 -0
  30. package/dist/federation/handler.test.d.mts +2 -0
  31. package/dist/federation/{handler.test.js → handler.test.mjs} +69 -131
  32. package/dist/federation/idempotency.test.d.mts +2 -0
  33. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
  34. package/dist/federation/inbox.test.d.mts +2 -0
  35. package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
  36. package/dist/federation/keycache.test.d.mts +2 -0
  37. package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -19
  38. package/dist/federation/kv.test.d.mts +2 -0
  39. package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
  40. package/dist/federation/middleware.test.d.mts +2 -0
  41. package/dist/federation/{middleware.test.js → middleware.test.mjs} +173 -262
  42. package/dist/federation/mod.cjs +327 -16
  43. package/dist/federation/mod.d.cts +3 -6
  44. package/dist/federation/mod.d.ts +3 -6
  45. package/dist/federation/mod.js +322 -13
  46. package/dist/federation/mq.test.d.mts +2 -0
  47. package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
  48. package/dist/federation/negotiation.test.d.mts +2 -0
  49. package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
  50. package/dist/federation/retry.test.d.mts +2 -0
  51. package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
  52. package/dist/federation/router.test.d.mts +2 -0
  53. package/dist/federation/{router.test.js → router.test.mjs} +11 -16
  54. package/dist/federation/send.test.d.mts +2 -0
  55. package/dist/federation/{send.test.js → send.test.mjs} +22 -30
  56. package/dist/federation/webfinger.test.d.mts +2 -0
  57. package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
  58. package/dist/{http-BnsR906R.cjs → http-BQccxQlj.cjs} +177 -302
  59. package/dist/{http-CKaqhjvP.js → http-CNsnyqrO.mjs} +23 -43
  60. package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
  61. package/dist/{http-IFqEftoZ.js → http-DhwEMhtv.js} +53 -184
  62. package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
  63. package/dist/{inbox-Bd91CVJP.js → inbox-DegXbbbS.mjs} +18 -26
  64. package/dist/{key-DFLFXKER.js → key-vL60OvqM.mjs} +29 -37
  65. package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
  66. package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
  67. package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
  68. package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
  69. package/dist/{kv-cache-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
  70. package/dist/{kv-cache-Drlz6O_Y.js → kv-cache-CTj3iCix.js} +6 -13
  71. package/dist/{kv-cache-BLXcQvyb.cjs → kv-cache-DxdXJNbj.cjs} +27 -34
  72. package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
  73. package/dist/{ld-CGGXZJK0.js → ld-C3CO00YY.mjs} +17 -31
  74. package/dist/{middleware-DcpBikad.js → middleware-BmsVSOeS.js} +335 -382
  75. package/dist/middleware-C7shNcsp.cjs +4 -0
  76. package/dist/{middleware-B51dB75z.cjs → middleware-Cx0Ny6_7.cjs} +532 -587
  77. package/dist/middleware-DqVGYk56.mjs +5 -0
  78. package/dist/{middleware-B53r4pdM.js → middleware-Du-vh7I_.mjs} +282 -317
  79. package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
  80. package/dist/{mod-DCbh1JQ5.d.ts → mod-CLgIXe9w.d.ts} +3 -3
  81. package/dist/{mod-jfnweK2w.d.cts → mod-CMEbIaNh.d.cts} +3 -3
  82. package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
  83. package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
  84. package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
  85. package/dist/mod.cjs +29 -74
  86. package/dist/mod.d.cts +11 -14
  87. package/dist/mod.d.ts +11 -15
  88. package/dist/mod.js +17 -71
  89. package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.mjs} +7 -11
  90. package/dist/nodeinfo/client.test.d.mts +2 -0
  91. package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
  92. package/dist/nodeinfo/handler.test.d.mts +2 -0
  93. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -43
  94. package/dist/nodeinfo/mod.cjs +5 -8
  95. package/dist/nodeinfo/mod.d.cts +2 -3
  96. package/dist/nodeinfo/mod.d.ts +2 -3
  97. package/dist/nodeinfo/mod.js +4 -8
  98. package/dist/nodeinfo/types.test.d.mts +2 -0
  99. package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
  100. package/dist/otel/exporter.test.d.mts +2 -0
  101. package/dist/otel/{exporter.test.js → exporter.test.mjs} +124 -178
  102. package/dist/otel/mod.cjs +15 -20
  103. package/dist/otel/mod.d.cts +2 -2
  104. package/dist/otel/mod.d.ts +2 -2
  105. package/dist/otel/mod.js +8 -14
  106. package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
  107. package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
  108. package/dist/{owner-Cye0yQB_.js → owner-DF320w6K.mjs} +11 -16
  109. package/dist/{proof-DdGGXVWM.js → proof-BCWk5oas.js} +32 -58
  110. package/dist/{proof-DV5lC_Bw.js → proof-IyDwwmzL.mjs} +21 -33
  111. package/dist/{proof-CN5iR1tW.cjs → proof-WhNxSv_N.cjs} +133 -157
  112. package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.mjs} +4 -7
  113. package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
  114. package/dist/runtime/mod.cjs +11 -13
  115. package/dist/runtime/mod.d.cts +6 -2
  116. package/dist/runtime/mod.d.ts +0 -1
  117. package/dist/runtime/mod.js +4 -7
  118. package/dist/{send-C2a_3YAF.js → send-CJQubr5t.mjs} +8 -13
  119. package/dist/sig/accept.test.d.mts +2 -0
  120. package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
  121. package/dist/sig/http.test.d.mts +2 -0
  122. package/dist/sig/{http.test.js → http.test.mjs} +166 -280
  123. package/dist/sig/key.test.d.mts +2 -0
  124. package/dist/sig/{key.test.js → key.test.mjs} +11 -18
  125. package/dist/sig/ld.test.d.mts +2 -0
  126. package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
  127. package/dist/sig/mod.cjs +6 -9
  128. package/dist/sig/mod.d.cts +3 -3
  129. package/dist/sig/mod.d.ts +3 -3
  130. package/dist/sig/mod.js +5 -9
  131. package/dist/sig/owner.test.d.mts +2 -0
  132. package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
  133. package/dist/sig/proof.test.d.mts +2 -0
  134. package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
  135. package/dist/{std__assert-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
  136. package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
  137. package/dist/testing/mod.mjs +6 -0
  138. package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
  139. package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
  140. package/dist/{types-CPz01LGH.js → types-DCP0WLdt.mjs} +4 -7
  141. package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
  142. package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
  143. package/dist/utils/docloader.test.d.mts +2 -0
  144. package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -25
  145. package/dist/utils/kv-cache.test.d.mts +2 -0
  146. package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
  147. package/dist/utils/mod.cjs +5 -9
  148. package/dist/utils/mod.d.cts +1 -3
  149. package/dist/utils/mod.d.ts +1 -3
  150. package/dist/utils/mod.js +4 -9
  151. package/dist/vocab/cjs.test.d.mts +2 -0
  152. package/dist/vocab/cjs.test.mjs +14 -0
  153. package/dist/vocab/mod.cjs +10 -12
  154. package/dist/vocab/mod.js +3 -5
  155. package/package.json +8 -8
  156. package/dist/compat/transformers.test.d.ts +0 -3
  157. package/dist/compat/transformers.test.js +0 -88
  158. package/dist/compat-Bb4NuTUO.js +0 -4
  159. package/dist/compat-DmDDELst.cjs +0 -4
  160. package/dist/deno-CnMqla6T.js +0 -121
  161. package/dist/federation/builder.test.d.ts +0 -3
  162. package/dist/federation/collection.test.d.ts +0 -3
  163. package/dist/federation/collection.test.js +0 -32
  164. package/dist/federation/handler.test.d.ts +0 -3
  165. package/dist/federation/idempotency.test.d.ts +0 -3
  166. package/dist/federation/inbox.test.d.ts +0 -3
  167. package/dist/federation/keycache.test.d.ts +0 -3
  168. package/dist/federation/kv.test.d.ts +0 -3
  169. package/dist/federation/middleware.test.d.ts +0 -3
  170. package/dist/federation/mq.test.d.ts +0 -3
  171. package/dist/federation/negotiation.test.d.ts +0 -3
  172. package/dist/federation/retry.test.d.ts +0 -3
  173. package/dist/federation/router.test.d.ts +0 -3
  174. package/dist/federation/send.test.d.ts +0 -3
  175. package/dist/federation/webfinger.test.d.ts +0 -3
  176. package/dist/federation-Bp3HI26G.cjs +0 -350
  177. package/dist/federation-DaMfqRm4.js +0 -332
  178. package/dist/middleware-B0kNQMO0.js +0 -27
  179. package/dist/middleware-BYQL9cdV.js +0 -12
  180. package/dist/middleware-DfNqksSs.cjs +0 -12
  181. package/dist/mod-B7QkWzrL.d.cts +0 -80
  182. package/dist/mod-Bh8mqlYw.d.cts +0 -9
  183. package/dist/mod-D6HodEq7.d.ts +0 -7
  184. package/dist/mod-SMHOMNpZ.d.ts +0 -82
  185. package/dist/mod-gq_Xfdz8.d.cts +0 -1
  186. package/dist/nodeinfo/client.test.d.ts +0 -3
  187. package/dist/nodeinfo/handler.test.d.ts +0 -3
  188. package/dist/nodeinfo/types.test.d.ts +0 -3
  189. package/dist/nodeinfo-DoESQxq5.js +0 -4
  190. package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
  191. package/dist/otel/exporter.test.d.ts +0 -3
  192. package/dist/runtime-c2Njxsry.cjs +0 -17
  193. package/dist/runtime-poamPCMb.js +0 -13
  194. package/dist/sig/accept.test.d.ts +0 -3
  195. package/dist/sig/http.test.d.ts +0 -3
  196. package/dist/sig/key.test.d.ts +0 -3
  197. package/dist/sig/ld.test.d.ts +0 -3
  198. package/dist/sig/owner.test.d.ts +0 -3
  199. package/dist/sig/proof.test.d.ts +0 -3
  200. package/dist/sig-BNhspNOf.js +0 -4
  201. package/dist/sig-vX39WyWI.cjs +0 -4
  202. package/dist/testing/mod.js +0 -10
  203. package/dist/utils/docloader.test.d.ts +0 -3
  204. package/dist/utils/kv-cache.test.d.ts +0 -3
  205. package/dist/utils-BQ9KqEK9.cjs +0 -4
  206. package/dist/utils-Dn5OPdSW.js +0 -4
  207. /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
package/dist/otel/mod.js CHANGED
@@ -1,10 +1,7 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
5
3
  import { getLogger } from "@logtape/logtape";
6
4
  import { ExportResultCode } from "@opentelemetry/core";
7
-
8
5
  //#region src/otel/exporter.ts
9
6
  /**
10
7
  * A SpanExporter that persists ActivityPub activity traces to a
@@ -89,8 +86,7 @@ var FedifySpanExporter = class {
89
86
  const records = this.#extractRecords(span);
90
87
  for (const record of records) storeOperations.push(this.#storeRecord(record));
91
88
  }
92
- const results = await Promise.allSettled(storeOperations);
93
- const rejected = results.filter((r) => r.status === "rejected");
89
+ const rejected = (await Promise.allSettled(storeOperations)).filter((r) => r.status === "rejected");
94
90
  if (rejected.length > 0) throw new AggregateError(rejected.map((r) => r.reason), "Failed to store one or more trace activity records.");
95
91
  }
96
92
  #extractRecords(span) {
@@ -195,12 +191,11 @@ var FedifySpanExporter = class {
195
191
  }
196
192
  async #setWithCasRetry(key, transform, options) {
197
193
  if (this.#kv.cas != null) for (let attempt = 0; attempt < 3; attempt++) {
198
- const existing$1 = await this.#kv.get(key);
199
- const newValue$1 = transform(existing$1);
200
- if (await this.#kv.cas(key, existing$1, newValue$1, options)) return;
194
+ const existing = await this.#kv.get(key);
195
+ const newValue = transform(existing);
196
+ if (await this.#kv.cas(key, existing, newValue, options)) return;
201
197
  }
202
- const existing = await this.#kv.get(key);
203
- const newValue = transform(existing);
198
+ const newValue = transform(await this.#kv.get(key));
204
199
  await this.#kv.set(key, newValue, options);
205
200
  }
206
201
  async #updateTraceSummary(record, options) {
@@ -256,6 +251,5 @@ var FedifySpanExporter = class {
256
251
  */
257
252
  async shutdown() {}
258
253
  };
259
-
260
254
  //#endregion
261
- export { FedifySpanExporter };
255
+ export { FedifySpanExporter };
@@ -65,4 +65,4 @@ interface GetKeyOwnerOptions {
65
65
  */
66
66
  declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
67
67
  //#endregion
68
- export { DoesActorOwnKeyOptions, GetKeyOwnerOptions, doesActorOwnKey, getKeyOwner };
68
+ export { getKeyOwner as i, GetKeyOwnerOptions as n, doesActorOwnKey as r, DoesActorOwnKeyOptions as t };
@@ -63,4 +63,4 @@ interface GetKeyOwnerOptions {
63
63
  */
64
64
  declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
65
65
  //#endregion
66
- export { DoesActorOwnKeyOptions, GetKeyOwnerOptions, doesActorOwnKey, getKeyOwner };
66
+ export { getKeyOwner as i, GetKeyOwnerOptions as n, doesActorOwnKey as r, DoesActorOwnKeyOptions as t };
@@ -1,13 +1,11 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { deno_default } from "./deno-CnMqla6T.js";
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { n as version, t as name } from "./deno-D682wzlW.mjs";
5
+ import "./key-vL60OvqM.mjs";
7
6
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
8
- import { getDocumentLoader } from "@fedify/vocab-runtime";
9
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
10
-
8
+ import { getDocumentLoader } from "@fedify/vocab-runtime";
11
9
  //#region src/sig/owner.ts
12
10
  /**
13
11
  * Checks if the actor of the given activity owns the specified key.
@@ -17,9 +15,7 @@ import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
17
15
  * @returns Whether the actor is the owner of the key.
18
16
  */
19
17
  async function doesActorOwnKey(activity, key, options) {
20
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
21
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
22
- return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
18
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
23
19
  kind: SpanKind.INTERNAL,
24
20
  attributes: {
25
21
  "activitypub.actor.id": activity.actorId?.href ?? "",
@@ -100,9 +96,9 @@ async function getKeyOwner(keyId, options) {
100
96
  contextLoader,
101
97
  tracerProvider
102
98
  });
103
- } catch (e$1) {
104
- if (e$1 instanceof TypeError) return null;
105
- throw e$1;
99
+ } catch (e) {
100
+ if (e instanceof TypeError) return null;
101
+ throw e;
106
102
  }
107
103
  }
108
104
  }
@@ -120,6 +116,5 @@ async function getKeyOwner(keyId, options) {
120
116
  for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
121
117
  return null;
122
118
  }
123
-
124
119
  //#endregion
125
- export { doesActorOwnKey, getKeyOwner };
120
+ export { getKeyOwner as n, doesActorOwnKey as t };
@@ -1,8 +1,6 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { deno_default, fetchKey, validateCryptoKey } from "./http-IFqEftoZ.js";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ import { _ as version, d as validateCryptoKey, g as name, s as fetchKey } from "./http-DhwEMhtv.js";
6
4
  import { getLogger } from "@logtape/logtape";
7
5
  import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "@fedify/vocab";
8
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -11,7 +9,6 @@ import { getDocumentLoader } from "@fedify/vocab-runtime";
11
9
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
12
10
  import jsonld from "@fedify/vocab-runtime/jsonld";
13
11
  import serialize from "json-canon";
14
-
15
12
  //#region src/sig/ld.ts
16
13
  const logger$1 = getLogger([
17
14
  "fedify",
@@ -53,11 +50,8 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
53
50
  creator: keyId.href,
54
51
  created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
55
52
  };
56
- const optionsHash = await hashJsonLd(options, contextLoader);
57
- const docHash = await hashJsonLd(jsonLd, contextLoader);
58
- const message = optionsHash + docHash;
59
- const encoder = new TextEncoder();
60
- const messageBytes = encoder.encode(message);
53
+ const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
54
+ const messageBytes = new TextEncoder().encode(message);
61
55
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
62
56
  return {
63
57
  ...options,
@@ -79,9 +73,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
79
73
  * @since 1.0.0
80
74
  */
81
75
  async function signJsonLd(jsonLd, privateKey, keyId, options) {
82
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
83
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
84
- return await tracer.startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
76
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
85
77
  try {
86
78
  const signature = await createSignature(jsonLd, privateKey, keyId, options);
87
79
  if (span.isRecording()) {
@@ -183,23 +175,21 @@ async function verifySignature(jsonLd, options = {}) {
183
175
  const encoder = new TextEncoder();
184
176
  const message = sigOptsHash + docHash;
185
177
  const messageBytes = encoder.encode(message);
186
- const verified = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes);
187
- if (verified) return key;
178
+ if (await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes)) return key;
188
179
  if (cached) {
189
180
  logger$1.debug("Failed to verify with the cached key {keyId}; signature {signatureValue} is invalid. Retrying with the freshly fetched key...", {
190
181
  keyId: sig.creator,
191
182
  ...sig
192
183
  });
193
- const { key: key$1 } = await fetchKey(new URL(sig.creator), CryptographicKey, {
184
+ const { key } = await fetchKey(new URL(sig.creator), CryptographicKey, {
194
185
  ...options,
195
186
  keyCache: {
196
187
  get: () => Promise.resolve(void 0),
197
- set: async (keyId, key$2) => await options.keyCache?.set(keyId, key$2)
188
+ set: async (keyId, key) => await options.keyCache?.set(keyId, key)
198
189
  }
199
190
  });
200
- if (key$1 == null) return null;
201
- const verified$1 = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key$1.publicKey, signature.slice(), messageBytes);
202
- return verified$1 ? key$1 : null;
191
+ if (key == null) return null;
192
+ return await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes) ? key : null;
203
193
  }
204
194
  logger$1.debug("Failed to verify with the fetched key {keyId}; signature {signatureValue} is invalid. Check if the key is correct or if the signed message is correct. The message to sign is:\n{message}", {
205
195
  keyId: sig.creator,
@@ -218,9 +208,7 @@ async function verifySignature(jsonLd, options = {}) {
218
208
  * @returns `true` if the document is authentic; `false` otherwise.
219
209
  */
220
210
  async function verifyJsonLd(jsonLd, options = {}) {
221
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
222
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
223
- return await tracer.startActiveSpan("ld_signatures.verify", async (span) => {
211
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
224
212
  try {
225
213
  const object = await Object$1.fromJsonLd(jsonLd, options);
226
214
  if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
@@ -261,10 +249,8 @@ async function hashJsonLd(jsonLd, contextLoader) {
261
249
  documentLoader: contextLoader ?? getDocumentLoader()
262
250
  });
263
251
  const encoder = new TextEncoder();
264
- const hash = await crypto.subtle.digest("SHA-256", encoder.encode(canon));
265
- return encodeHex(hash);
252
+ return encodeHex(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
266
253
  }
267
-
268
254
  //#endregion
269
255
  //#region src/sig/owner.ts
270
256
  /**
@@ -275,9 +261,7 @@ async function hashJsonLd(jsonLd, contextLoader) {
275
261
  * @returns Whether the actor is the owner of the key.
276
262
  */
277
263
  async function doesActorOwnKey(activity, key, options) {
278
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
279
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
280
- return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
264
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
281
265
  kind: SpanKind.INTERNAL,
282
266
  attributes: {
283
267
  "activitypub.actor.id": activity.actorId?.href ?? "",
@@ -358,9 +342,9 @@ async function getKeyOwner(keyId, options) {
358
342
  contextLoader,
359
343
  tracerProvider
360
344
  });
361
- } catch (e$1) {
362
- if (e$1 instanceof TypeError) return null;
363
- throw e$1;
345
+ } catch (e) {
346
+ if (e instanceof TypeError) return null;
347
+ throw e;
364
348
  }
365
349
  }
366
350
  }
@@ -378,7 +362,6 @@ async function getKeyOwner(keyId, options) {
378
362
  for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
379
363
  return null;
380
364
  }
381
-
382
365
  //#endregion
383
366
  //#region src/sig/proof.ts
384
367
  const logger = getLogger([
@@ -396,29 +379,27 @@ const logger = getLogger([
396
379
  * @throws {TypeError} If the private key is invalid or unsupported.
397
380
  * @since 0.10.0
398
381
  */
399
- async function createProof(object, privateKey, keyId, { contextLoader, context: context$1, created } = {}) {
382
+ async function createProof(object, privateKey, keyId, { contextLoader, context, created } = {}) {
400
383
  validateCryptoKey(privateKey, "private");
401
384
  if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
402
- const objectWithoutProofs = object.clone({ proofs: [] });
403
- const compactMsg = await objectWithoutProofs.toJsonLd({
385
+ const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
404
386
  format: "compact",
405
387
  contextLoader,
406
- context: context$1
388
+ context
407
389
  });
408
390
  const msgCanon = serialize(compactMsg);
409
391
  const encoder = new TextEncoder();
410
392
  const msgBytes = encoder.encode(msgCanon);
411
393
  const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
412
394
  created ??= Temporal.Now.instant();
413
- const proofConfig = {
395
+ const proofCanon = serialize({
414
396
  "@context": compactMsg["@context"],
415
397
  type: "DataIntegrityProof",
416
398
  cryptosuite: "eddsa-jcs-2022",
417
399
  verificationMethod: keyId.href,
418
400
  proofPurpose: "assertionMethod",
419
401
  created: created.toString()
420
- };
421
- const proofCanon = serialize(proofConfig);
402
+ });
422
403
  const proofBytes = encoder.encode(proofCanon);
423
404
  const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
424
405
  const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
@@ -444,13 +425,11 @@ async function createProof(object, privateKey, keyId, { contextLoader, context:
444
425
  * @since 0.10.0
445
426
  */
446
427
  async function signObject(object, privateKey, keyId, options = {}) {
447
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
448
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
449
- return await tracer.startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
428
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
450
429
  try {
451
430
  if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
452
431
  const existingProofs = [];
453
- for await (const proof$1 of object.getProofs(options)) existingProofs.push(proof$1);
432
+ for await (const proof of object.getProofs(options)) existingProofs.push(proof);
454
433
  const proof = await createProof(object, privateKey, keyId, options);
455
434
  if (span.isRecording()) {
456
435
  if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
@@ -480,9 +459,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
480
459
  * @since 0.10.0
481
460
  */
482
461
  async function verifyProof(jsonLd, proof, options = {}) {
483
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
484
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
485
- return await tracer.startActiveSpan("object_integrity_proofs.verify", async (span) => {
462
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
486
463
  if (span.isRecording()) {
487
464
  if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
488
465
  if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
@@ -506,15 +483,14 @@ async function verifyProof(jsonLd, proof, options = {}) {
506
483
  async function verifyProofInternal(jsonLd, proof, options) {
507
484
  if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
508
485
  const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
509
- const proofConfig = {
486
+ const proofCanon = serialize({
510
487
  "@context": jsonLd["@context"],
511
488
  type: "DataIntegrityProof",
512
489
  cryptosuite: proof.cryptosuite,
513
490
  verificationMethod: proof.verificationMethodId.href,
514
491
  proofPurpose: proof.proofPurpose,
515
492
  created: proof.created.toString()
516
- };
517
- const proofCanon = serialize(proofConfig);
493
+ });
518
494
  const encoder = new TextEncoder();
519
495
  const proofBytes = encoder.encode(proofCanon);
520
496
  const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
@@ -565,8 +541,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
565
541
  });
566
542
  return null;
567
543
  }
568
- const verified = await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest);
569
- if (!verified) {
544
+ if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
570
545
  if (fetchedKey.cached) {
571
546
  logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
572
547
  keyId: proof.verificationMethodId.href,
@@ -603,7 +578,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
603
578
  * @since 0.10.0
604
579
  */
605
580
  async function verifyObject(cls, jsonLd, options = {}) {
606
- const logger$2 = getLogger([
581
+ const logger = getLogger([
607
582
  "fedify",
608
583
  "sig",
609
584
  "proof"
@@ -615,17 +590,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
615
590
  const key = await verifyProof(jsonLd, proof, options);
616
591
  if (key === null) return null;
617
592
  if (key.controllerId == null) {
618
- logger$2.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
593
+ logger.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
619
594
  continue;
620
595
  }
621
596
  attributions.delete(key.controllerId.href);
622
597
  }
623
598
  if (attributions.size > 0) {
624
- logger$2.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
599
+ logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
625
600
  return null;
626
601
  }
627
602
  return object;
628
603
  }
629
-
630
604
  //#endregion
631
- export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature };
605
+ export { doesActorOwnKey as a, createSignature as c, signJsonLd as d, verifyJsonLd as f, verifyProof as i, detachSignature as l, signObject as n, getKeyOwner as o, verifySignature as p, verifyObject as r, attachSignature as s, createProof as t, hasSignature as u };
@@ -1,16 +1,13 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { deno_default } from "./deno-CnMqla6T.js";
7
- import { fetchKey, validateCryptoKey } from "./key-DFLFXKER.js";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { n as version, t as name } from "./deno-D682wzlW.mjs";
5
+ import { n as fetchKey, o as validateCryptoKey } from "./key-vL60OvqM.mjs";
8
6
  import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
9
- import { getLogger } from "@logtape/logtape";
10
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
+ import { getLogger } from "@logtape/logtape";
11
9
  import { encodeHex } from "byte-encodings/hex";
12
10
  import serialize from "json-canon";
13
-
14
11
  //#region src/sig/proof.ts
15
12
  const logger = getLogger([
16
13
  "fedify",
@@ -27,29 +24,27 @@ const logger = getLogger([
27
24
  * @throws {TypeError} If the private key is invalid or unsupported.
28
25
  * @since 0.10.0
29
26
  */
30
- async function createProof(object, privateKey, keyId, { contextLoader, context: context$1, created } = {}) {
27
+ async function createProof(object, privateKey, keyId, { contextLoader, context, created } = {}) {
31
28
  validateCryptoKey(privateKey, "private");
32
29
  if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
33
- const objectWithoutProofs = object.clone({ proofs: [] });
34
- const compactMsg = await objectWithoutProofs.toJsonLd({
30
+ const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
35
31
  format: "compact",
36
32
  contextLoader,
37
- context: context$1
33
+ context
38
34
  });
39
35
  const msgCanon = serialize(compactMsg);
40
36
  const encoder = new TextEncoder();
41
37
  const msgBytes = encoder.encode(msgCanon);
42
38
  const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
43
39
  created ??= Temporal.Now.instant();
44
- const proofConfig = {
40
+ const proofCanon = serialize({
45
41
  "@context": compactMsg["@context"],
46
42
  type: "DataIntegrityProof",
47
43
  cryptosuite: "eddsa-jcs-2022",
48
44
  verificationMethod: keyId.href,
49
45
  proofPurpose: "assertionMethod",
50
46
  created: created.toString()
51
- };
52
- const proofCanon = serialize(proofConfig);
47
+ });
53
48
  const proofBytes = encoder.encode(proofCanon);
54
49
  const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
55
50
  const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
@@ -75,13 +70,11 @@ async function createProof(object, privateKey, keyId, { contextLoader, context:
75
70
  * @since 0.10.0
76
71
  */
77
72
  async function signObject(object, privateKey, keyId, options = {}) {
78
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
79
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
80
- return await tracer.startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
73
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
81
74
  try {
82
75
  if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
83
76
  const existingProofs = [];
84
- for await (const proof$1 of object.getProofs(options)) existingProofs.push(proof$1);
77
+ for await (const proof of object.getProofs(options)) existingProofs.push(proof);
85
78
  const proof = await createProof(object, privateKey, keyId, options);
86
79
  if (span.isRecording()) {
87
80
  if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
@@ -111,9 +104,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
111
104
  * @since 0.10.0
112
105
  */
113
106
  async function verifyProof(jsonLd, proof, options = {}) {
114
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
115
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
116
- return await tracer.startActiveSpan("object_integrity_proofs.verify", async (span) => {
107
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
117
108
  if (span.isRecording()) {
118
109
  if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
119
110
  if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
@@ -137,15 +128,14 @@ async function verifyProof(jsonLd, proof, options = {}) {
137
128
  async function verifyProofInternal(jsonLd, proof, options) {
138
129
  if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
139
130
  const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
140
- const proofConfig = {
131
+ const proofCanon = serialize({
141
132
  "@context": jsonLd["@context"],
142
133
  type: "DataIntegrityProof",
143
134
  cryptosuite: proof.cryptosuite,
144
135
  verificationMethod: proof.verificationMethodId.href,
145
136
  proofPurpose: proof.proofPurpose,
146
137
  created: proof.created.toString()
147
- };
148
- const proofCanon = serialize(proofConfig);
138
+ });
149
139
  const encoder = new TextEncoder();
150
140
  const proofBytes = encoder.encode(proofCanon);
151
141
  const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
@@ -196,8 +186,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
196
186
  });
197
187
  return null;
198
188
  }
199
- const verified = await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest);
200
- if (!verified) {
189
+ if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
201
190
  if (fetchedKey.cached) {
202
191
  logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
203
192
  keyId: proof.verificationMethodId.href,
@@ -234,7 +223,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
234
223
  * @since 0.10.0
235
224
  */
236
225
  async function verifyObject(cls, jsonLd, options = {}) {
237
- const logger$1 = getLogger([
226
+ const logger = getLogger([
238
227
  "fedify",
239
228
  "sig",
240
229
  "proof"
@@ -246,17 +235,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
246
235
  const key = await verifyProof(jsonLd, proof, options);
247
236
  if (key === null) return null;
248
237
  if (key.controllerId == null) {
249
- logger$1.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
238
+ logger.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
250
239
  continue;
251
240
  }
252
241
  attributions.delete(key.controllerId.href);
253
242
  }
254
243
  if (attributions.size > 0) {
255
- logger$1.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
244
+ logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
256
245
  return null;
257
246
  }
258
247
  return object;
259
248
  }
260
-
261
249
  //#endregion
262
- export { createProof, signObject, verifyObject, verifyProof };
250
+ export { verifyProof as i, signObject as n, verifyObject as r, createProof as t };