@fedify/fedify 1.9.6 → 1.9.8
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-CEGEmRll.js → actor-BTA45fXF.js} +1205 -2768
- package/dist/{actor-Ydzhc8dj.d.cts → actor-Be-68iJP.d.cts} +3 -3
- package/dist/{actor-C1Euqngb.d.ts → actor-C5AY0Tno.d.ts} +3 -3
- package/dist/{actor-DbpZ6pzg.js → actor-DGa1EWaV.mjs} +8 -15
- package/dist/{actor-DlS-Q8hE.cjs → actor-DxfJk4lY.cjs} +3112 -4674
- 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-DUQcOTRS.js → authdocloader-BC2rYCy1.mjs} +9 -14
- package/dist/{authdocloader-CT_V4Z7G.cjs → authdocloader-BrhFB421.cjs} +14 -22
- package/dist/{authdocloader-BLqMyboS.js → authdocloader-CqtNsX_N.js} +8 -15
- package/dist/{builder-BO61xeXE.js → builder-CIkAhIGC.mjs} +31 -40
- package/dist/{client-DF8anIB5.d.ts → client-D8OSiPBT.d.ts} +2 -2
- package/dist/{client-UG5wpNhG.js → client-MXqit6c-.mjs} +11 -15
- package/dist/{client-DjT_tegg.d.cts → client-T0VFOdMw.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-CwUAkopp.d.cts → context-CACMqDzl.d.cts} +33 -26
- package/dist/{context-CXUibY4L.d.ts → context-K4cCphQj.d.ts} +33 -26
- package/dist/{denokv-Bv33Xxea.js → denokv-CoSB_Eps.mjs} +22 -11
- package/dist/{docloader-BIFI3OS7.cjs → docloader-BVuUhBLI.cjs} +112 -212
- package/dist/{docloader-fJgJeqiX.js → docloader-BoXhusJ1.js} +17 -151
- package/dist/{docloader-CxWcuWqQ.d.ts → docloader-DSaLRXEA.d.ts} +2 -7
- package/dist/{docloader-D-MrRyHl.d.cts → docloader-DpGRDZrn.d.cts} +2 -7
- package/dist/{esm-C1EfGjSS.js → esm-BHJ7sdNg.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} +22 -49
- 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} +9 -20
- 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 +223 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +218 -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} +17 -26
- package/dist/{http-wsGR6KkT.d.ts → http-BZpls--H.d.ts} +5 -9
- package/dist/{http-CR-Eg1Uq.js → http-Bu5ZNlhZ.mjs} +16 -32
- package/dist/{http-B1_DzfAU.d.cts → http-C7WoprmE.d.cts} +5 -9
- package/dist/{http-BgopPF-8.cjs → http-DKw-O_VY.cjs} +51 -68
- package/dist/{http-05HxN-lp.js → http-VJbz6sKD.js} +17 -33
- package/dist/{inbox-DcJN1cxM.js → inbox-DkbTULXE.mjs} +17 -25
- package/dist/key-4fu6v0Jf.mjs +5 -0
- package/dist/{key-DjS1X9TG.cjs → key-B-wFdaPB.cjs} +42 -50
- package/dist/{key-ibMO03_0.js → key-BNMK_IVr.mjs} +12 -18
- package/dist/key-CancShOo.cjs +4 -0
- package/dist/{key-CPJcJjp-.js → key-DK3o0FEH.js} +19 -19
- package/dist/{keycache-CMUfqYqr.js → keycache-D-Vj8z88.mjs} +6 -10
- package/dist/{keys-IZ5050fT.js → keys-B27nVeIs.mjs} +6 -10
- package/dist/{kv-C7sopW2E.d.ts → kv-Bq9QLKm5.d.ts} +1 -1
- package/dist/{kv-CRZrzyXm.js → kv-DM1zFCtL.mjs} +6 -10
- package/dist/{kv-63Cil1MD.d.cts → kv-GIrOktyG.d.cts} +1 -1
- package/dist/{ld-DHNA2RSQ.js → ld-6jAVu3jV.mjs} +17 -31
- package/dist/{lookup-CKZfuyxA.js → lookup-BaU75j-d.js} +5 -11
- package/dist/{lookup-C4_dVYz7.cjs → lookup-BiIPmTwB.cjs} +16 -23
- package/dist/{lookup-BMAWLsP2.js → lookup-DmeJ8WUw.mjs} +8 -17
- package/dist/middleware-9ByEpBvV.cjs +4 -0
- package/dist/{middleware-CGbvIGvy.cjs → middleware-C188G4Go.cjs} +494 -547
- package/dist/{middleware-DrhEvfTo.js → middleware-Db1yZQaT.mjs} +276 -321
- package/dist/{middleware-ODfDRN3q.js → middleware-Do06X21v.js} +349 -393
- package/dist/middleware-DrfZEjyc.mjs +5 -0
- package/dist/{mod-CDObsV1d.d.ts → mod-BSwc3_rD.d.ts} +3 -3
- package/dist/{mod-DBzN0aCM.d.ts → mod-BTNpXcPj.d.ts} +2 -2
- package/dist/{mod-fjqfsrty.d.cts → mod-Chb_NKPp.d.cts} +4 -4
- package/dist/{mod-DgcYoyZK.d.ts → mod-DHoc3toL.d.ts} +4 -4
- package/dist/{mod-jQ4OODsl.d.cts → mod-DIMx6YjJ.d.cts} +2 -2
- package/dist/{mod-BUbqxBev.d.cts → mod-HElaq2UB.d.cts} +3 -3
- 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/{owner-DDHsHYQO.js → owner-CKuGt_T9.mjs} +10 -13
- package/dist/{owner-BbeUDvOu.d.ts → owner-DPAPnB0R.d.ts} +4 -4
- package/dist/{owner-6KSEp9eV.d.cts → owner-_rFs0ik_.d.cts} +4 -4
- package/dist/{proof-V1uQaB2y.js → proof-CmTtG_t-.js} +33 -57
- package/dist/{proof-CX7ujFFX.cjs → proof-DLOy7HYU.cjs} +112 -135
- package/dist/{proof-exgGRW88.js → proof-mJLL2gSA.mjs} +20 -32
- 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} +52 -72
- 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-BfMYakUE.js → send-BsQbGuw4.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.mjs +39 -0
- 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-RPOc_gVG.js → testing-DS3gcq8V.mjs} +27 -35
- package/dist/{transformers-CoBS-oFG.cjs → transformers-BM0M8hnW.cjs} +20 -25
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{types-Cptev2nt.js → types-BXfL-dsX.js} +18 -36
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-CGnM1vft.cjs → types-DpM4FhjW.cjs} +45 -64
- 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} +29 -45
- package/dist/vocab/mod.cjs +251 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +244 -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-CDHNj5zp.d.ts → vocab-BLvSEtuz.d.cts} +2 -4
- package/dist/{type-COPv6pMi.js → vocab-DuW9rL1h.mjs} +1177 -2871
- package/dist/{vocab-Cfs0937i.d.cts → vocab-lhCS9lzq.d.ts} +4 -2
- 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-D1U8YY9t.js +0 -226
- package/dist/federation-H2_En3j5.cjs +0 -244
- package/dist/key-BCUd8FWp.js +0 -10
- package/dist/key-BUardnTH.cjs +0 -10
- package/dist/key-Dr6H_e3K.js +0 -10
- package/dist/middleware-BJ83veqi.js +0 -26
- package/dist/middleware-CJ4W2ir5.cjs +0 -17
- package/dist/middleware-Ve2mHJgo.js +0 -17
- package/dist/mod-BcObK1Lz.d.ts +0 -82
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CIbqfZW0.d.ts +0 -104
- package/dist/mod-Dt-G9ZOS.d.cts +0 -102
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-mXx9V0q5.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/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/owner.test.js +0 -52
- 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-BFy1CS5L.cjs +0 -289
- package/dist/vocab-BPFiQ650.js +0 -253
- 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
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const json_canon = require_chunk.__toESM(require("json-canon"));
|
|
15
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
+
const require_docloader = require("./docloader-BVuUhBLI.cjs");
|
|
4
|
+
const require_actor = require("./actor-DxfJk4lY.cjs");
|
|
5
|
+
const require_key = require("./key-B-wFdaPB.cjs");
|
|
6
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
7
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
8
|
+
let jsonld = require("jsonld");
|
|
9
|
+
jsonld = require_docloader.__toESM(jsonld);
|
|
10
|
+
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
11
|
+
let byte_encodings_hex = require("byte-encodings/hex");
|
|
12
|
+
let json_canon = require("json-canon");
|
|
13
|
+
json_canon = require_docloader.__toESM(json_canon);
|
|
16
14
|
//#region src/sig/ld.ts
|
|
17
|
-
const logger$1 = (0,
|
|
15
|
+
const logger$1 = (0, _logtape_logtape.getLogger)([
|
|
18
16
|
"fedify",
|
|
19
17
|
"sig",
|
|
20
18
|
"ld"
|
|
@@ -54,11 +52,8 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
54
52
|
creator: keyId.href,
|
|
55
53
|
created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
56
54
|
};
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const message = optionsHash + docHash;
|
|
60
|
-
const encoder = new TextEncoder();
|
|
61
|
-
const messageBytes = encoder.encode(message);
|
|
55
|
+
const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
|
|
56
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
62
57
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
|
|
63
58
|
return {
|
|
64
59
|
...options,
|
|
@@ -80,9 +75,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
80
75
|
* @since 1.0.0
|
|
81
76
|
*/
|
|
82
77
|
async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
83
|
-
|
|
84
|
-
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
|
85
|
-
return await tracer.startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
78
|
+
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version).startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
86
79
|
try {
|
|
87
80
|
const signature = await createSignature(jsonLd, privateKey, keyId, options);
|
|
88
81
|
if (span.isRecording()) {
|
|
@@ -92,7 +85,7 @@ async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
|
92
85
|
return attachSignature(jsonLd, signature);
|
|
93
86
|
} catch (error) {
|
|
94
87
|
span.setStatus({
|
|
95
|
-
code:
|
|
88
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
96
89
|
message: String(error)
|
|
97
90
|
});
|
|
98
91
|
throw error;
|
|
@@ -184,23 +177,21 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
184
177
|
const encoder = new TextEncoder();
|
|
185
178
|
const message = sigOptsHash + docHash;
|
|
186
179
|
const messageBytes = encoder.encode(message);
|
|
187
|
-
|
|
188
|
-
if (verified) return key;
|
|
180
|
+
if (await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes)) return key;
|
|
189
181
|
if (cached) {
|
|
190
182
|
logger$1.debug("Failed to verify with the cached key {keyId}; signature {signatureValue} is invalid. Retrying with the freshly fetched key...", {
|
|
191
183
|
keyId: sig.creator,
|
|
192
184
|
...sig
|
|
193
185
|
});
|
|
194
|
-
const { key
|
|
186
|
+
const { key } = await require_key.fetchKey(new URL(sig.creator), require_actor.CryptographicKey, {
|
|
195
187
|
...options,
|
|
196
188
|
keyCache: {
|
|
197
189
|
get: () => Promise.resolve(void 0),
|
|
198
|
-
set: async (keyId, key
|
|
190
|
+
set: async (keyId, key) => await options.keyCache?.set(keyId, key)
|
|
199
191
|
}
|
|
200
192
|
});
|
|
201
|
-
if (key
|
|
202
|
-
|
|
203
|
-
return verified$1 ? key$1 : null;
|
|
193
|
+
if (key == null) return null;
|
|
194
|
+
return await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes) ? key : null;
|
|
204
195
|
}
|
|
205
196
|
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}", {
|
|
206
197
|
keyId: sig.creator,
|
|
@@ -219,9 +210,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
219
210
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
220
211
|
*/
|
|
221
212
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
222
|
-
|
|
223
|
-
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
|
224
|
-
return await tracer.startActiveSpan("ld_signatures.verify", async (span) => {
|
|
213
|
+
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
225
214
|
try {
|
|
226
215
|
const object = await require_actor.Object.fromJsonLd(jsonLd, options);
|
|
227
216
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
@@ -247,7 +236,7 @@ async function verifyJsonLd(jsonLd, options = {}) {
|
|
|
247
236
|
return true;
|
|
248
237
|
} catch (error) {
|
|
249
238
|
span.setStatus({
|
|
250
|
-
code:
|
|
239
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
251
240
|
message: String(error)
|
|
252
241
|
});
|
|
253
242
|
throw error;
|
|
@@ -262,10 +251,8 @@ async function hashJsonLd(jsonLd, contextLoader) {
|
|
|
262
251
|
documentLoader: contextLoader ?? require_docloader.getDocumentLoader()
|
|
263
252
|
});
|
|
264
253
|
const encoder = new TextEncoder();
|
|
265
|
-
|
|
266
|
-
return (0, byte_encodings_hex.encodeHex)(hash);
|
|
254
|
+
return (0, byte_encodings_hex.encodeHex)(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
|
|
267
255
|
}
|
|
268
|
-
|
|
269
256
|
//#endregion
|
|
270
257
|
//#region src/sig/owner.ts
|
|
271
258
|
/**
|
|
@@ -293,7 +280,7 @@ async function doesActorOwnKey(activity, key, options) {
|
|
|
293
280
|
* @since 0.7.0
|
|
294
281
|
*/
|
|
295
282
|
async function getKeyOwner(keyId, options) {
|
|
296
|
-
const tracerProvider = options.tracerProvider ??
|
|
283
|
+
const tracerProvider = options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
|
|
297
284
|
const documentLoader = options.documentLoader ?? require_docloader.getDocumentLoader();
|
|
298
285
|
const contextLoader = options.contextLoader ?? require_docloader.getDocumentLoader();
|
|
299
286
|
let object;
|
|
@@ -323,9 +310,9 @@ async function getKeyOwner(keyId, options) {
|
|
|
323
310
|
contextLoader,
|
|
324
311
|
tracerProvider
|
|
325
312
|
});
|
|
326
|
-
} catch (e
|
|
327
|
-
if (e
|
|
328
|
-
throw e
|
|
313
|
+
} catch (e) {
|
|
314
|
+
if (e instanceof TypeError) return null;
|
|
315
|
+
throw e;
|
|
329
316
|
}
|
|
330
317
|
}
|
|
331
318
|
}
|
|
@@ -343,10 +330,9 @@ async function getKeyOwner(keyId, options) {
|
|
|
343
330
|
for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
|
|
344
331
|
return null;
|
|
345
332
|
}
|
|
346
|
-
|
|
347
333
|
//#endregion
|
|
348
334
|
//#region src/sig/proof.ts
|
|
349
|
-
const logger = (0,
|
|
335
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
350
336
|
"fedify",
|
|
351
337
|
"sig",
|
|
352
338
|
"proof"
|
|
@@ -364,8 +350,7 @@ const logger = (0, __logtape_logtape.getLogger)([
|
|
|
364
350
|
async function createProof(object, privateKey, keyId, { contextLoader, context, created } = {}) {
|
|
365
351
|
require_key.validateCryptoKey(privateKey, "private");
|
|
366
352
|
if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
|
|
367
|
-
const
|
|
368
|
-
const compactMsg = await objectWithoutProofs.toJsonLd({
|
|
353
|
+
const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
369
354
|
format: "compact",
|
|
370
355
|
contextLoader,
|
|
371
356
|
context
|
|
@@ -375,15 +360,14 @@ async function createProof(object, privateKey, keyId, { contextLoader, context,
|
|
|
375
360
|
const msgBytes = encoder.encode(msgCanon);
|
|
376
361
|
const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
|
|
377
362
|
created ??= Temporal.Now.instant();
|
|
378
|
-
const
|
|
363
|
+
const proofCanon = (0, json_canon.default)({
|
|
379
364
|
"@context": compactMsg["@context"],
|
|
380
365
|
type: "DataIntegrityProof",
|
|
381
366
|
cryptosuite: "eddsa-jcs-2022",
|
|
382
367
|
verificationMethod: keyId.href,
|
|
383
368
|
proofPurpose: "assertionMethod",
|
|
384
369
|
created: created.toString()
|
|
385
|
-
};
|
|
386
|
-
const proofCanon = (0, json_canon.default)(proofConfig);
|
|
370
|
+
});
|
|
387
371
|
const proofBytes = encoder.encode(proofCanon);
|
|
388
372
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
389
373
|
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
@@ -409,13 +393,11 @@ async function createProof(object, privateKey, keyId, { contextLoader, context,
|
|
|
409
393
|
* @since 0.10.0
|
|
410
394
|
*/
|
|
411
395
|
async function signObject(object, privateKey, keyId, options = {}) {
|
|
412
|
-
|
|
413
|
-
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
|
414
|
-
return await tracer.startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": require_actor.getTypeId(object).href } }, async (span) => {
|
|
396
|
+
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": require_actor.getTypeId(object).href } }, async (span) => {
|
|
415
397
|
try {
|
|
416
398
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
417
399
|
const existingProofs = [];
|
|
418
|
-
for await (const proof
|
|
400
|
+
for await (const proof of object.getProofs(options)) existingProofs.push(proof);
|
|
419
401
|
const proof = await createProof(object, privateKey, keyId, options);
|
|
420
402
|
if (span.isRecording()) {
|
|
421
403
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
@@ -425,7 +407,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
|
|
|
425
407
|
return object.clone({ proofs: [...existingProofs, proof] });
|
|
426
408
|
} catch (error) {
|
|
427
409
|
span.setStatus({
|
|
428
|
-
code:
|
|
410
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
429
411
|
message: String(error)
|
|
430
412
|
});
|
|
431
413
|
throw error;
|
|
@@ -445,9 +427,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
|
|
|
445
427
|
* @since 0.10.0
|
|
446
428
|
*/
|
|
447
429
|
async function verifyProof(jsonLd, proof, options = {}) {
|
|
448
|
-
|
|
449
|
-
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
|
450
|
-
return await tracer.startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
430
|
+
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
451
431
|
if (span.isRecording()) {
|
|
452
432
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
453
433
|
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
@@ -455,11 +435,11 @@ async function verifyProof(jsonLd, proof, options = {}) {
|
|
|
455
435
|
}
|
|
456
436
|
try {
|
|
457
437
|
const key = await verifyProofInternal(jsonLd, proof, options);
|
|
458
|
-
if (key == null) span.setStatus({ code:
|
|
438
|
+
if (key == null) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
|
|
459
439
|
return key;
|
|
460
440
|
} catch (error) {
|
|
461
441
|
span.setStatus({
|
|
462
|
-
code:
|
|
442
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
463
443
|
message: String(error)
|
|
464
444
|
});
|
|
465
445
|
throw error;
|
|
@@ -471,15 +451,14 @@ async function verifyProof(jsonLd, proof, options = {}) {
|
|
|
471
451
|
async function verifyProofInternal(jsonLd, proof, options) {
|
|
472
452
|
if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
|
|
473
453
|
const publicKeyPromise = require_key.fetchKey(proof.verificationMethodId, require_actor.Multikey, options);
|
|
474
|
-
const
|
|
454
|
+
const proofCanon = (0, json_canon.default)({
|
|
475
455
|
"@context": jsonLd["@context"],
|
|
476
456
|
type: "DataIntegrityProof",
|
|
477
457
|
cryptosuite: proof.cryptosuite,
|
|
478
458
|
verificationMethod: proof.verificationMethodId.href,
|
|
479
459
|
proofPurpose: proof.proofPurpose,
|
|
480
460
|
created: proof.created.toString()
|
|
481
|
-
};
|
|
482
|
-
const proofCanon = (0, json_canon.default)(proofConfig);
|
|
461
|
+
});
|
|
483
462
|
const encoder = new TextEncoder();
|
|
484
463
|
const proofBytes = encoder.encode(proofCanon);
|
|
485
464
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
@@ -530,8 +509,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
530
509
|
});
|
|
531
510
|
return null;
|
|
532
511
|
}
|
|
533
|
-
|
|
534
|
-
if (!verified) {
|
|
512
|
+
if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
|
|
535
513
|
if (fetchedKey.cached) {
|
|
536
514
|
logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
|
|
537
515
|
keyId: proof.verificationMethodId.href,
|
|
@@ -568,7 +546,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
568
546
|
* @since 0.10.0
|
|
569
547
|
*/
|
|
570
548
|
async function verifyObject(cls, jsonLd, options = {}) {
|
|
571
|
-
const logger
|
|
549
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
572
550
|
"fedify",
|
|
573
551
|
"sig",
|
|
574
552
|
"proof"
|
|
@@ -580,94 +558,93 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
580
558
|
const key = await verifyProof(jsonLd, proof, options);
|
|
581
559
|
if (key === null) return null;
|
|
582
560
|
if (key.controllerId == null) {
|
|
583
|
-
logger
|
|
561
|
+
logger.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
|
|
584
562
|
continue;
|
|
585
563
|
}
|
|
586
564
|
attributions.delete(key.controllerId.href);
|
|
587
565
|
}
|
|
588
566
|
if (attributions.size > 0) {
|
|
589
|
-
logger
|
|
567
|
+
logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
590
568
|
return null;
|
|
591
569
|
}
|
|
592
570
|
return object;
|
|
593
571
|
}
|
|
594
|
-
|
|
595
572
|
//#endregion
|
|
596
|
-
Object.defineProperty(exports,
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
573
|
+
Object.defineProperty(exports, "attachSignature", {
|
|
574
|
+
enumerable: true,
|
|
575
|
+
get: function() {
|
|
576
|
+
return attachSignature;
|
|
577
|
+
}
|
|
601
578
|
});
|
|
602
|
-
Object.defineProperty(exports,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
579
|
+
Object.defineProperty(exports, "createProof", {
|
|
580
|
+
enumerable: true,
|
|
581
|
+
get: function() {
|
|
582
|
+
return createProof;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
Object.defineProperty(exports, "createSignature", {
|
|
586
|
+
enumerable: true,
|
|
587
|
+
get: function() {
|
|
588
|
+
return createSignature;
|
|
589
|
+
}
|
|
607
590
|
});
|
|
608
|
-
Object.defineProperty(exports,
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
591
|
+
Object.defineProperty(exports, "detachSignature", {
|
|
592
|
+
enumerable: true,
|
|
593
|
+
get: function() {
|
|
594
|
+
return detachSignature;
|
|
595
|
+
}
|
|
613
596
|
});
|
|
614
|
-
Object.defineProperty(exports,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
597
|
+
Object.defineProperty(exports, "doesActorOwnKey", {
|
|
598
|
+
enumerable: true,
|
|
599
|
+
get: function() {
|
|
600
|
+
return doesActorOwnKey;
|
|
601
|
+
}
|
|
619
602
|
});
|
|
620
|
-
Object.defineProperty(exports,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
603
|
+
Object.defineProperty(exports, "getKeyOwner", {
|
|
604
|
+
enumerable: true,
|
|
605
|
+
get: function() {
|
|
606
|
+
return getKeyOwner;
|
|
607
|
+
}
|
|
625
608
|
});
|
|
626
|
-
Object.defineProperty(exports,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
609
|
+
Object.defineProperty(exports, "hasSignature", {
|
|
610
|
+
enumerable: true,
|
|
611
|
+
get: function() {
|
|
612
|
+
return hasSignature;
|
|
613
|
+
}
|
|
631
614
|
});
|
|
632
|
-
Object.defineProperty(exports,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
615
|
+
Object.defineProperty(exports, "signJsonLd", {
|
|
616
|
+
enumerable: true,
|
|
617
|
+
get: function() {
|
|
618
|
+
return signJsonLd;
|
|
619
|
+
}
|
|
637
620
|
});
|
|
638
|
-
Object.defineProperty(exports,
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
621
|
+
Object.defineProperty(exports, "signObject", {
|
|
622
|
+
enumerable: true,
|
|
623
|
+
get: function() {
|
|
624
|
+
return signObject;
|
|
625
|
+
}
|
|
643
626
|
});
|
|
644
|
-
Object.defineProperty(exports,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
627
|
+
Object.defineProperty(exports, "verifyJsonLd", {
|
|
628
|
+
enumerable: true,
|
|
629
|
+
get: function() {
|
|
630
|
+
return verifyJsonLd;
|
|
631
|
+
}
|
|
649
632
|
});
|
|
650
|
-
Object.defineProperty(exports,
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
633
|
+
Object.defineProperty(exports, "verifyObject", {
|
|
634
|
+
enumerable: true,
|
|
635
|
+
get: function() {
|
|
636
|
+
return verifyObject;
|
|
637
|
+
}
|
|
655
638
|
});
|
|
656
|
-
Object.defineProperty(exports,
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
639
|
+
Object.defineProperty(exports, "verifyProof", {
|
|
640
|
+
enumerable: true,
|
|
641
|
+
get: function() {
|
|
642
|
+
return verifyProof;
|
|
643
|
+
}
|
|
661
644
|
});
|
|
662
|
-
Object.defineProperty(exports,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
645
|
+
Object.defineProperty(exports, "verifySignature", {
|
|
646
|
+
enumerable: true,
|
|
647
|
+
get: function() {
|
|
648
|
+
return verifySignature;
|
|
649
|
+
}
|
|
667
650
|
});
|
|
668
|
-
Object.defineProperty(exports, 'verifySignature', {
|
|
669
|
-
enumerable: true,
|
|
670
|
-
get: function () {
|
|
671
|
-
return verifySignature;
|
|
672
|
-
}
|
|
673
|
-
});
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { Activity, DataIntegrityProof, Multikey, deno_default, getTypeId } from "./type-COPv6pMi.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-CPJcJjp-.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-DuW9rL1h.mjs";
|
|
5
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key-BNMK_IVr.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,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
6
4
|
//#region src/federation/retry.ts
|
|
7
5
|
/**
|
|
8
6
|
* Creates an exponential backoff retry policy. The delay between retries
|
|
@@ -32,6 +30,5 @@ function createExponentialBackoffPolicy(options = {}) {
|
|
|
32
30
|
return Temporal.Duration.compare(delay, maxDelay) > 0 ? maxDelay : delay;
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
//#endregion
|
|
37
|
-
export { createExponentialBackoffPolicy };
|
|
34
|
+
export { createExponentialBackoffPolicy as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { __exportAll as t };
|