@fedify/fedify 1.10.5 → 1.10.7
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.
- package/dist/{actor-CjkHF7Cj.cjs → actor-BGIAXtRd.cjs} +3112 -4674
- package/dist/{actor-Ch9BTg3N.js → actor-C-_2S5Mn.mjs} +8 -15
- package/dist/{actor-CQdxP8N-.js → actor-Cujbx4Zv.js} +1205 -2768
- package/dist/{actor-eeONG_sv.d.ts → actor-DXwwgFeR.d.ts} +3 -3
- package/dist/{actor-D190nbTD.d.cts → actor-DxvGbmjm.d.cts} +3 -3
- package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
- package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
- package/dist/{authdocloader-fR-Fqcpa.js → authdocloader-1Sk2bqFx.mjs} +9 -14
- package/dist/{authdocloader-COFZT9Wh.js → authdocloader-D4Y6iyTF.js} +8 -15
- package/dist/{authdocloader-zc5ibOmU.cjs → authdocloader-DQfruCir.cjs} +14 -22
- package/dist/{builder-YD0q32nG.js → builder-CZbrDRl7.mjs} +31 -40
- package/dist/{client-B3mQJNO7.d.ts → client-D7t26_op.d.ts} +2 -2
- package/dist/{client-BgCucCG7.js → client-Dyb8MI3u.mjs} +11 -15
- package/dist/{client-n6L4GtQL.d.cts → client-yc0Z0P6Y.d.cts} +2 -2
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -12
- package/dist/compat/mod.d.ts +78 -12
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-Cr5DIxq_.d.ts → context-C6n2yrj0.d.ts} +33 -26
- package/dist/{context-WJoO0SQs.d.cts → context-PfghnHYj.d.cts} +33 -26
- package/dist/{denokv-D0nfNQ1x.js → denokv-NJPMXyK0.mjs} +22 -11
- package/dist/{docloader-BucCRHZI.d.ts → docloader-D7k5A9JP.d.ts} +2 -7
- package/dist/{docloader-ChxNLZAA.d.cts → docloader-DbM94pGY.d.cts} +2 -7
- package/dist/{docloader-BETPdM09.js → docloader-Dtaju6oI.js} +18 -156
- package/dist/{docloader-irBWMSOZ.cjs → docloader-Q3DfzuUi.cjs} +116 -220
- package/dist/{esm-iGH0sRsE.js → esm-DOJg552-.mjs} +49 -85
- package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +29 -58
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +12 -26
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +182 -197
- package/dist/federation/mod.cjs +245 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +240 -18
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +12 -19
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +24 -34
- package/dist/{http-PgdBoDIj.js → http-BRwSVBn1.mjs} +16 -32
- package/dist/{http-DS9z_HzB.d.ts → http-BYXQvoZQ.d.ts} +5 -9
- package/dist/{http-C_1RU1U_.d.cts → http-CMzg-A9P.d.cts} +5 -9
- package/dist/{http-CQAqR_vx.cjs → http-DCrun8ql.cjs} +51 -68
- package/dist/{http-CxiIW4rD.js → http-DRnRwr3i.js} +17 -33
- package/dist/{inbox-DcDIqTbR.js → inbox-pD1nbb_5.mjs} +17 -25
- package/dist/key-Cmbps6xt.cjs +4 -0
- package/dist/{key-dNFkodH5.cjs → key-DEYIxAFs.cjs} +42 -50
- package/dist/key-DMO0TgTa.mjs +5 -0
- package/dist/{key-I-ibyaZH.js → key-DdL5Oc59.mjs} +12 -18
- package/dist/{key-Cg0kO4dA.js → key-vIzWPiil.js} +19 -19
- package/dist/{keycache-hSs_XFSb.js → keycache-BVR9f06Y.mjs} +6 -10
- package/dist/{keys-CElJez9H.js → keys-Co-0pK8a.mjs} +6 -10
- package/dist/{kv-DipCBaw2.d.ts → kv-C6UC8M9S.d.ts} +1 -1
- package/dist/{kv-BqEOXcZv.d.cts → kv-ClC9WJh5.d.cts} +1 -1
- package/dist/{kv-QzKcOQgP.js → kv-OuT2IU64.mjs} +6 -10
- package/dist/{ld-b16r91YS.js → ld-BFaDk5gX.mjs} +17 -31
- package/dist/{lookup-CySNcNcC.js → lookup-CMYXdjVH.mjs} +8 -17
- package/dist/{lookup-Bfq9Jpm0.cjs → lookup-CZGJqSjm.cjs} +16 -23
- package/dist/{lookup-CiSAeWJl.js → lookup-jlmCTRsO.js} +5 -11
- package/dist/middleware-BWlZ-wms.cjs +4 -0
- package/dist/{middleware-C5emnCh-.js → middleware-BXD5WJbj.mjs} +276 -321
- package/dist/{middleware-Dxo56yae.cjs → middleware-BhMQrJXH.cjs} +494 -547
- package/dist/{middleware-Bs4xDuXR.js → middleware-CmA2E9Bu.js} +349 -393
- package/dist/middleware-H3Ce7yn3.mjs +5 -0
- package/dist/{mod-D5rfgGFE.d.cts → mod-BQ3lrlXU.d.cts} +3 -3
- package/dist/{mod-Dz5Y15Uy.d.cts → mod-C72agZIN.d.cts} +4 -4
- package/dist/{mod-CxMBb_dd.d.cts → mod-CDbqB60V.d.cts} +2 -2
- package/dist/{mod-DS4kJskR.d.ts → mod-Lj0W1nnG.d.ts} +3 -3
- package/dist/{mod-BZfdiPBo.d.ts → mod-_HNKaczF.d.ts} +4 -4
- package/dist/{mod-ChbckRnC.d.ts → mod-lHd-Zdd_.d.ts} +2 -2
- package/dist/mod.cjs +31 -33
- package/dist/mod.d.cts +15 -17
- package/dist/mod.d.ts +15 -17
- package/dist/mod.js +20 -23
- package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
- package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
- package/dist/nodeinfo/mod.cjs +5 -9
- package/dist/nodeinfo/mod.d.cts +2 -5
- package/dist/nodeinfo/mod.d.ts +2 -5
- package/dist/nodeinfo/mod.js +4 -9
- package/dist/nodeinfo/semver.test.d.mts +2 -0
- package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +122 -180
- package/dist/otel/mod.cjs +16 -22
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +9 -16
- package/dist/{otel-Chy5T2Xh.js → otel-0v4Zy01l.mjs} +5 -10
- package/dist/{owner-AcrG3Xz1.d.cts → owner-0yNTyGMb.d.cts} +4 -4
- package/dist/{owner-Bs-sPbHX.js → owner-CNdS8zxf.mjs} +11 -16
- package/dist/{owner-8NMhXwJd.d.ts → owner-CPEbNpnZ.d.ts} +4 -4
- package/dist/{proof-SgRikE_Y.js → proof-Co7YmDpv.mjs} +20 -32
- package/dist/{proof-flD2DeA-.js → proof-DHPbi_Mx.js} +34 -60
- package/dist/{proof-BvQS195q.cjs → proof-DcPdtve2.cjs} +115 -140
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
- package/dist/runtime/authdocloader.test.d.mts +2 -0
- package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
- package/dist/runtime/docloader.test.d.mts +2 -0
- package/dist/runtime/{docloader.test.js → docloader.test.mjs} +55 -77
- package/dist/runtime/key.test.d.mts +2 -0
- package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
- package/dist/runtime/langstr.test.d.mts +2 -0
- package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
- package/dist/runtime/link.test.d.mts +2 -0
- package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
- package/dist/runtime/mod.cjs +7 -13
- package/dist/runtime/mod.d.cts +103 -6
- package/dist/runtime/mod.d.ts +103 -6
- package/dist/runtime/mod.js +6 -13
- package/dist/runtime/multibase/multibase.test.d.mts +2 -0
- package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
- package/dist/runtime/url.test.d.mts +2 -0
- package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
- package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
- package/dist/{send-C0gFHa2i.js → send-BRCWNcMa.mjs} +7 -12
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +119 -203
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +13 -22
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
- package/dist/sig/mod.cjs +7 -13
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -13
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +23 -39
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
- package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
- package/dist/testing/docloader.test.d.mts +2 -0
- package/dist/testing/docloader.test.mjs +12 -0
- package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
- package/dist/testing/mod.mjs +5 -0
- package/dist/{testing-C1GIraJh.js → testing-BLIh1cXz.mjs} +27 -35
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{transformers-CoBS-oFG.cjs → transformers-CLtJ5H8o.cjs} +20 -25
- package/dist/{types-BgUCCngg.cjs → types-B34v-m2N.cjs} +45 -64
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-Bu-epI-z.js → types-CXZk86AG.js} +18 -36
- package/dist/vocab/actor.test.d.mts +2 -0
- package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/lookup.test.d.mts +2 -0
- package/dist/vocab/{lookup.test.js → lookup.test.mjs} +34 -51
- package/dist/vocab/mod.cjs +256 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +249 -10
- package/dist/vocab/type.test.d.mts +2 -0
- package/dist/vocab/type.test.mjs +16 -0
- package/dist/vocab/vocab.test.d.mts +2 -0
- package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
- package/dist/{vocab-BASuuzcJ.d.ts → vocab-DaT4UsJF.d.ts} +2 -2
- package/dist/{vocab-DPMmFPJ1.d.cts → vocab-DnlmNyXi.d.cts} +2 -2
- package/dist/{type-DUhon7qK.js → vocab-rT_94Pke.mjs} +1178 -2876
- package/dist/webfinger/handler.test.d.mts +2 -0
- package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
- package/dist/webfinger/lookup.test.d.mts +2 -0
- package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
- package/dist/webfinger/mod.cjs +5 -9
- package/dist/webfinger/mod.d.cts +1 -3
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +4 -9
- package/dist/x/cfworkers.cjs +25 -14
- package/dist/x/cfworkers.d.cts +33 -6
- package/dist/x/cfworkers.d.ts +33 -6
- package/dist/x/cfworkers.js +22 -12
- package/dist/x/cfworkers.test.d.mts +2 -0
- package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
- package/dist/x/hono.cjs +25 -14
- package/dist/x/hono.d.cts +1 -11
- package/dist/x/hono.d.ts +1 -11
- package/dist/x/hono.js +22 -12
- package/dist/x/sveltekit.cjs +23 -12
- package/dist/x/sveltekit.d.cts +1 -11
- package/dist/x/sveltekit.d.ts +1 -11
- package/dist/x/sveltekit.js +20 -10
- package/package.json +2 -2
- package/dist/chunk-DqRYRqnO.cjs +0 -34
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -86
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/compat-nxUqe4Z-.js +0 -4
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -35
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation-C15gGOh1.cjs +0 -266
- package/dist/federation-K-xsO03l.js +0 -248
- package/dist/key-Bnod5wJl.js +0 -10
- package/dist/key-C6swTX71.js +0 -10
- package/dist/key-_Uq8gkmM.cjs +0 -10
- package/dist/middleware-BWsOtDIF.cjs +0 -17
- package/dist/middleware-Bm4bJzjg.js +0 -26
- package/dist/middleware-BvODpE_U.js +0 -17
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CD7gfdq3.d.ts +0 -104
- package/dist/mod-CnULG6Aa.d.ts +0 -82
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-JUhOKMHj.d.cts +0 -102
- package/dist/mod-OQfb33eH.d.cts +0 -80
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/semver.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
- package/dist/nodeinfo-DfycQ8Wf.js +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime/authdocloader.test.d.ts +0 -3
- package/dist/runtime/docloader.test.d.ts +0 -3
- package/dist/runtime/key.test.d.ts +0 -3
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime-C58AJWSv.cjs +0 -4
- package/dist/runtime-DPYEDf-o.js +0 -4
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-ByHXzqUi.cjs +0 -4
- package/dist/sig-Cj3tk-ig.js +0 -4
- package/dist/testing/docloader.test.d.ts +0 -3
- package/dist/testing/docloader.test.js +0 -24
- package/dist/testing/mod.js +0 -10
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab-5i6DEIi6.cjs +0 -294
- package/dist/vocab-CBavAdew.js +0 -258
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.test.d.ts +0 -3
- /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
package/dist/otel/mod.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
@@ -93,8 +90,7 @@ var FedifySpanExporter = class {
|
|
|
93
90
|
const records = this.#extractRecords(span);
|
|
94
91
|
for (const record of records) storeOperations.push(this.#storeRecord(record));
|
|
95
92
|
}
|
|
96
|
-
const
|
|
97
|
-
const rejected = results.filter((r) => r.status === "rejected");
|
|
93
|
+
const rejected = (await Promise.allSettled(storeOperations)).filter((r) => r.status === "rejected");
|
|
98
94
|
if (rejected.length > 0) throw new AggregateError(rejected.map((r) => r.reason), "Failed to store one or more trace activity records.");
|
|
99
95
|
}
|
|
100
96
|
#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
|
|
199
|
-
const newValue
|
|
200
|
-
if (await this.#kv.cas(key, existing
|
|
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
|
|
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) {
|
|
@@ -245,8 +240,7 @@ var FedifySpanExporter = class {
|
|
|
245
240
|
return records;
|
|
246
241
|
} else {
|
|
247
242
|
const key = [...this.#keyPrefix, traceId];
|
|
248
|
-
|
|
249
|
-
return records ?? [];
|
|
243
|
+
return await this.#kv.get(key) ?? [];
|
|
250
244
|
}
|
|
251
245
|
}
|
|
252
246
|
/**
|
|
@@ -273,6 +267,5 @@ var FedifySpanExporter = class {
|
|
|
273
267
|
*/
|
|
274
268
|
async shutdown() {}
|
|
275
269
|
};
|
|
276
|
-
|
|
277
270
|
//#endregion
|
|
278
|
-
export { FedifySpanExporter };
|
|
271
|
+
export { FedifySpanExporter };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
6
4
|
import { BasicTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
7
5
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
8
|
-
|
|
9
6
|
//#region src/testing/otel.ts
|
|
10
7
|
/**
|
|
11
8
|
* A test spy for OpenTelemetry spans that captures all spans and events.
|
|
@@ -37,8 +34,7 @@ var TestSpanExporter = class {
|
|
|
37
34
|
* Gets all events from spans with the given name.
|
|
38
35
|
*/
|
|
39
36
|
getEvents(spanName, eventName) {
|
|
40
|
-
const
|
|
41
|
-
const events = spans.flatMap((span) => span.events);
|
|
37
|
+
const events = this.getSpans(spanName).flatMap((span) => span.events);
|
|
42
38
|
if (eventName) return events.filter((event) => event.name === eventName);
|
|
43
39
|
return events;
|
|
44
40
|
}
|
|
@@ -59,6 +55,5 @@ function createTestTracerProvider() {
|
|
|
59
55
|
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
|
|
60
56
|
return [provider, exporter];
|
|
61
57
|
}
|
|
62
|
-
|
|
63
58
|
//#endregion
|
|
64
|
-
export { createTestTracerProvider };
|
|
59
|
+
export { createTestTracerProvider as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DocumentLoader } from "./docloader-
|
|
2
|
-
import {
|
|
3
|
-
import { Actor } from "./actor-
|
|
1
|
+
import { n as DocumentLoader } from "./docloader-DbM94pGY.cjs";
|
|
2
|
+
import { m as CryptographicKey, n as Activity } from "./vocab-DnlmNyXi.cjs";
|
|
3
|
+
import { t as Actor } from "./actor-DxvGbmjm.cjs";
|
|
4
4
|
import { TracerProvider } from "@opentelemetry/api";
|
|
5
5
|
|
|
6
6
|
//#region src/sig/owner.d.ts
|
|
@@ -64,4 +64,4 @@ interface GetKeyOwnerOptions {
|
|
|
64
64
|
*/
|
|
65
65
|
declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
|
|
66
66
|
//#endregion
|
|
67
|
-
export {
|
|
67
|
+
export { getKeyOwner as i, GetKeyOwnerOptions as n, doesActorOwnKey as r, DoesActorOwnKeyOptions as t };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import { isActor } from "./actor-Ch9BTg3N.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { J as getDocumentLoader, ot as name, s as CryptographicKey, st as version, v as Object$1 } from "./vocab-rT_94Pke.mjs";
|
|
5
|
+
import { i as isActor } from "./actor-C-_2S5Mn.mjs";
|
|
6
|
+
import "./key-DdL5Oc59.mjs";
|
|
8
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
|
-
|
|
10
8
|
//#region src/sig/owner.ts
|
|
11
9
|
/**
|
|
12
10
|
* Checks if the actor of the given activity owns the specified key.
|
|
@@ -16,9 +14,7 @@ import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
|
16
14
|
* @returns Whether the actor is the owner of the key.
|
|
17
15
|
*/
|
|
18
16
|
async function doesActorOwnKey(activity, key, options) {
|
|
19
|
-
|
|
20
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
21
|
-
return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
|
|
17
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
|
|
22
18
|
kind: SpanKind.INTERNAL,
|
|
23
19
|
attributes: {
|
|
24
20
|
"activitypub.actor.id": activity.actorId?.href ?? "",
|
|
@@ -99,9 +95,9 @@ async function getKeyOwner(keyId, options) {
|
|
|
99
95
|
contextLoader,
|
|
100
96
|
tracerProvider
|
|
101
97
|
});
|
|
102
|
-
} catch (e
|
|
103
|
-
if (e
|
|
104
|
-
throw e
|
|
98
|
+
} catch (e) {
|
|
99
|
+
if (e instanceof TypeError) return null;
|
|
100
|
+
throw e;
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
103
|
}
|
|
@@ -119,6 +115,5 @@ async function getKeyOwner(keyId, options) {
|
|
|
119
115
|
for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
|
|
120
116
|
return null;
|
|
121
117
|
}
|
|
122
|
-
|
|
123
118
|
//#endregion
|
|
124
|
-
export {
|
|
119
|
+
export { getKeyOwner as n, doesActorOwnKey as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { DocumentLoader } from "./docloader-
|
|
4
|
-
import {
|
|
5
|
-
import { Actor } from "./actor-
|
|
3
|
+
import { n as DocumentLoader } from "./docloader-D7k5A9JP.js";
|
|
4
|
+
import { m as CryptographicKey, n as Activity } from "./vocab-DaT4UsJF.js";
|
|
5
|
+
import { t as Actor } from "./actor-DXwwgFeR.js";
|
|
6
6
|
import { TracerProvider } from "@opentelemetry/api";
|
|
7
7
|
|
|
8
8
|
//#region src/sig/owner.d.ts
|
|
@@ -66,4 +66,4 @@ interface GetKeyOwnerOptions {
|
|
|
66
66
|
*/
|
|
67
67
|
declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
|
|
68
68
|
//#endregion
|
|
69
|
-
export {
|
|
69
|
+
export { getKeyOwner as i, GetKeyOwnerOptions as n, doesActorOwnKey as r, DoesActorOwnKeyOptions as t };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { Activity, DataIntegrityProof, Multikey, deno_default, getTypeId } from "./type-DUhon7qK.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-Cg0kO4dA.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { U as getTypeId, c as DataIntegrityProof, g as Multikey, ot as name, st as version, t as Activity } from "./vocab-rT_94Pke.mjs";
|
|
5
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key-DdL5Oc59.mjs";
|
|
8
6
|
import { getLogger } from "@logtape/logtape";
|
|
9
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
8
|
import { encodeHex } from "byte-encodings/hex";
|
|
11
9
|
import serialize from "json-canon";
|
|
12
|
-
|
|
13
10
|
//#region src/sig/proof.ts
|
|
14
11
|
const logger = getLogger([
|
|
15
12
|
"fedify",
|
|
@@ -26,29 +23,27 @@ const logger = getLogger([
|
|
|
26
23
|
* @throws {TypeError} If the private key is invalid or unsupported.
|
|
27
24
|
* @since 0.10.0
|
|
28
25
|
*/
|
|
29
|
-
async function createProof(object, privateKey, keyId, { contextLoader, context
|
|
26
|
+
async function createProof(object, privateKey, keyId, { contextLoader, context, created } = {}) {
|
|
30
27
|
validateCryptoKey(privateKey, "private");
|
|
31
28
|
if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
|
|
32
|
-
const
|
|
33
|
-
const compactMsg = await objectWithoutProofs.toJsonLd({
|
|
29
|
+
const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
34
30
|
format: "compact",
|
|
35
31
|
contextLoader,
|
|
36
|
-
context
|
|
32
|
+
context
|
|
37
33
|
});
|
|
38
34
|
const msgCanon = serialize(compactMsg);
|
|
39
35
|
const encoder = new TextEncoder();
|
|
40
36
|
const msgBytes = encoder.encode(msgCanon);
|
|
41
37
|
const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
|
|
42
38
|
created ??= Temporal.Now.instant();
|
|
43
|
-
const
|
|
39
|
+
const proofCanon = serialize({
|
|
44
40
|
"@context": compactMsg["@context"],
|
|
45
41
|
type: "DataIntegrityProof",
|
|
46
42
|
cryptosuite: "eddsa-jcs-2022",
|
|
47
43
|
verificationMethod: keyId.href,
|
|
48
44
|
proofPurpose: "assertionMethod",
|
|
49
45
|
created: created.toString()
|
|
50
|
-
};
|
|
51
|
-
const proofCanon = serialize(proofConfig);
|
|
46
|
+
});
|
|
52
47
|
const proofBytes = encoder.encode(proofCanon);
|
|
53
48
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
54
49
|
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
@@ -74,13 +69,11 @@ async function createProof(object, privateKey, keyId, { contextLoader, context:
|
|
|
74
69
|
* @since 0.10.0
|
|
75
70
|
*/
|
|
76
71
|
async function signObject(object, privateKey, keyId, options = {}) {
|
|
77
|
-
|
|
78
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
79
|
-
return await tracer.startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
|
|
72
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
|
|
80
73
|
try {
|
|
81
74
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
82
75
|
const existingProofs = [];
|
|
83
|
-
for await (const proof
|
|
76
|
+
for await (const proof of object.getProofs(options)) existingProofs.push(proof);
|
|
84
77
|
const proof = await createProof(object, privateKey, keyId, options);
|
|
85
78
|
if (span.isRecording()) {
|
|
86
79
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
@@ -110,9 +103,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
|
|
|
110
103
|
* @since 0.10.0
|
|
111
104
|
*/
|
|
112
105
|
async function verifyProof(jsonLd, proof, options = {}) {
|
|
113
|
-
|
|
114
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
115
|
-
return await tracer.startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
106
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
116
107
|
if (span.isRecording()) {
|
|
117
108
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
118
109
|
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
@@ -136,15 +127,14 @@ async function verifyProof(jsonLd, proof, options = {}) {
|
|
|
136
127
|
async function verifyProofInternal(jsonLd, proof, options) {
|
|
137
128
|
if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
|
|
138
129
|
const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
|
|
139
|
-
const
|
|
130
|
+
const proofCanon = serialize({
|
|
140
131
|
"@context": jsonLd["@context"],
|
|
141
132
|
type: "DataIntegrityProof",
|
|
142
133
|
cryptosuite: proof.cryptosuite,
|
|
143
134
|
verificationMethod: proof.verificationMethodId.href,
|
|
144
135
|
proofPurpose: proof.proofPurpose,
|
|
145
136
|
created: proof.created.toString()
|
|
146
|
-
};
|
|
147
|
-
const proofCanon = serialize(proofConfig);
|
|
137
|
+
});
|
|
148
138
|
const encoder = new TextEncoder();
|
|
149
139
|
const proofBytes = encoder.encode(proofCanon);
|
|
150
140
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
@@ -195,8 +185,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
195
185
|
});
|
|
196
186
|
return null;
|
|
197
187
|
}
|
|
198
|
-
|
|
199
|
-
if (!verified) {
|
|
188
|
+
if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
|
|
200
189
|
if (fetchedKey.cached) {
|
|
201
190
|
logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
|
|
202
191
|
keyId: proof.verificationMethodId.href,
|
|
@@ -233,7 +222,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
233
222
|
* @since 0.10.0
|
|
234
223
|
*/
|
|
235
224
|
async function verifyObject(cls, jsonLd, options = {}) {
|
|
236
|
-
const logger
|
|
225
|
+
const logger = getLogger([
|
|
237
226
|
"fedify",
|
|
238
227
|
"sig",
|
|
239
228
|
"proof"
|
|
@@ -245,17 +234,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
245
234
|
const key = await verifyProof(jsonLd, proof, options);
|
|
246
235
|
if (key === null) return null;
|
|
247
236
|
if (key.controllerId == null) {
|
|
248
|
-
logger
|
|
237
|
+
logger.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
|
|
249
238
|
continue;
|
|
250
239
|
}
|
|
251
240
|
attributions.delete(key.controllerId.href);
|
|
252
241
|
}
|
|
253
242
|
if (attributions.size > 0) {
|
|
254
|
-
logger
|
|
243
|
+
logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
255
244
|
return null;
|
|
256
245
|
}
|
|
257
246
|
return object;
|
|
258
247
|
}
|
|
259
|
-
|
|
260
248
|
//#endregion
|
|
261
|
-
export {
|
|
249
|
+
export { verifyProof as i, signObject as n, verifyObject as r, createProof as t };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "./actor-CQdxP8N-.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-I-ibyaZH.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
import { d as name, f as version, i as getDocumentLoader } from "./docloader-Dtaju6oI.js";
|
|
4
|
+
import { G as Multikey, Tt as getTypeId, b as DataIntegrityProof, i as isActor, q as Object$1, s as Activity, y as CryptographicKey } from "./actor-Cujbx4Zv.js";
|
|
5
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-vIzWPiil.js";
|
|
8
6
|
import { getLogger } from "@logtape/logtape";
|
|
9
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
8
|
import jsonld from "jsonld";
|
|
11
9
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
12
10
|
import { encodeHex } from "byte-encodings/hex";
|
|
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
|
|
57
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
188
|
+
set: async (keyId, key) => await options.keyCache?.set(keyId, key)
|
|
198
189
|
}
|
|
199
190
|
});
|
|
200
|
-
if (key
|
|
201
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
362
|
-
if (e
|
|
363
|
-
throw e
|
|
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
|
|
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
|
|
403
|
-
const compactMsg = await objectWithoutProofs.toJsonLd({
|
|
385
|
+
const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
404
386
|
format: "compact",
|
|
405
387
|
contextLoader,
|
|
406
|
-
context
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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 };
|