@fedify/fedify 1.9.6-dev.2118 → 1.9.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-CCg-pZae.js → actor-B3mkavdq.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-C71CIMfC.cjs → actor-CsvteFj1.cjs} +3112 -4674
- package/dist/{actor-CNWkxCrC.js → actor-DeUOMMMQ.mjs} +8 -15
- 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-DEGiIEaL.js → authdocloader-BKq994CV.mjs} +9 -14
- package/dist/{authdocloader-wQk3e7Ag.js → authdocloader-C3_-i4Zk.js} +8 -15
- package/dist/{authdocloader-CT1cPj97.cjs → authdocloader-tagnJZ6u.cjs} +14 -22
- package/dist/{builder-D0mOpo0N.js → builder-CnVAhip1.mjs} +31 -40
- package/dist/{client-BSRRCCF9.js → client-Bza9SeZS.mjs} +11 -15
- package/dist/{client-DF8anIB5.d.ts → client-D8OSiPBT.d.ts} +2 -2
- 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-OWdVzt6R.cjs → docloader-Co-tW1B6.cjs} +112 -212
- package/dist/{docloader-CxWcuWqQ.d.ts → docloader-DSaLRXEA.d.ts} +2 -7
- package/dist/{docloader-ENN4YgIF.js → docloader-Dlo9EMTn.js} +17 -151
- package/dist/{docloader-D-MrRyHl.d.cts → docloader-DpGRDZrn.d.cts} +2 -7
- package/dist/{esm-rU2ogNNz.js → esm-BLERAZrI.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} +128 -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-B1_DzfAU.d.cts → http-C7WoprmE.d.cts} +5 -9
- package/dist/{http-Bmn4CXIM.cjs → http-cvQMgiFd.cjs} +51 -68
- package/dist/{http-DAz2fpwK.js → http-hFXuPP4j.mjs} +16 -32
- package/dist/{http-LDjZxhgJ.js → http-z-J6i29D.js} +17 -33
- package/dist/{inbox-CLgNEczc.js → inbox-B0NdZv6Q.mjs} +17 -25
- package/dist/{key-C45K8q1u.cjs → key-B2ZqbGDP.cjs} +42 -50
- package/dist/key-BfH9JUMQ.cjs +4 -0
- package/dist/{key-VDAxfcre.js → key-ByblW_7f.mjs} +12 -18
- package/dist/{key-kD68vuX_.js → key-DPg0mibt.js} +19 -19
- package/dist/key-USCeSjWo.mjs +5 -0
- package/dist/{keycache-DtWOiAMc.js → keycache-qGjtNwWK.mjs} +6 -10
- package/dist/{keys-CJezjcJ9.js → keys-D48z4zQE.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-DSD_uqio.js → ld-Bk-CiTUe.mjs} +17 -31
- package/dist/{lookup-B0Qds1Mq.js → lookup-B-LJhUtc.mjs} +8 -17
- package/dist/{lookup-Brpn8XFF.cjs → lookup-C6EHvNN7.cjs} +16 -23
- package/dist/{lookup-Dkw6PUQT.js → lookup-CuDOZqcB.js} +5 -11
- package/dist/{middleware-Cfia6iC-.js → middleware-Cns1QUI8.js} +348 -392
- package/dist/middleware-DYNDkDz7.mjs +5 -0
- package/dist/middleware-SP7rhp6I.cjs +4 -0
- package/dist/{middleware-DQ1ijTAg.cjs → middleware-UNqaTRBe.cjs} +493 -546
- package/dist/{middleware-Bn5wceGF.js → middleware-xIvAtsQ9.mjs} +275 -320
- 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-CD3PoJME.js → owner-CkmuWs8s.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-Qv3fs4TE.js → proof-BBEQdN7B.js} +33 -57
- package/dist/{proof-fJIJMt-0.js → proof-DVFzuYOq.mjs} +20 -32
- package/dist/{proof-CKkQu1BL.cjs → proof-DiFRNymC.cjs} +112 -135
- 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-KX74JBzu.js → send-BsKuGBh0.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-DlM9L2qY.js → testing-8TvaN83G.mjs} +27 -35
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{transformers-CoBS-oFG.cjs → transformers-C2P5eKUT.cjs} +20 -25
- package/dist/{types-CfuEksTX.js → types-BK9bojU0.js} +18 -36
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-Bq8MUNvK.cjs → types-D4VM3B7I.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-kdsaa4c5.js → vocab-DuJO9k13.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-Bsm-uoaE.js +0 -10
- package/dist/key-Bv9soVGW.cjs +0 -10
- package/dist/key-C6dA6KgH.js +0 -10
- package/dist/middleware-BJbqjuUV.js +0 -17
- package/dist/middleware-BVltQrGG.cjs +0 -17
- package/dist/middleware-NDh5Vgwn.js +0 -26
- 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-DBzzAvtf.cjs +0 -289
- package/dist/vocab-cxfw8FFj.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,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { CryptographicKey } from "./actor-CCg-pZae.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-VDAxfcre.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { G as FetchError, ot as name, s as CryptographicKey, st as version } from "./vocab-DuJO9k13.mjs";
|
|
5
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key-ByblW_7f.mjs";
|
|
8
6
|
import { getLogger } from "@logtape/logtape";
|
|
9
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
8
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
9
|
import { encodeHex } from "byte-encodings/hex";
|
|
12
10
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
13
11
|
import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
14
|
-
|
|
15
12
|
//#region src/sig/http.ts
|
|
16
13
|
const DEFAULT_MAX_REDIRECTION = 20;
|
|
17
14
|
/**
|
|
@@ -25,9 +22,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
25
22
|
*/
|
|
26
23
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
27
24
|
validateCryptoKey(privateKey, "private");
|
|
28
|
-
|
|
29
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
30
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
25
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
31
26
|
try {
|
|
32
27
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
33
28
|
let signed;
|
|
@@ -122,9 +117,7 @@ function createRfc9421SignatureBase(request, components, parameters) {
|
|
|
122
117
|
* @returns The formatted signature string.
|
|
123
118
|
*/
|
|
124
119
|
function formatRfc9421Signature(signature, components, parameters) {
|
|
125
|
-
|
|
126
|
-
const signatureValue = `sig1=:${encodeBase64(signature)}:`;
|
|
127
|
-
return [signatureInputValue, signatureValue];
|
|
120
|
+
return [`sig1=("${components.join("\" \"")}");${parameters}`, `sig1=:${encodeBase64(signature)}:`];
|
|
128
121
|
}
|
|
129
122
|
/**
|
|
130
123
|
* Parse RFC 9421 Signature-Input header.
|
|
@@ -254,9 +247,7 @@ const supportedHashAlgorithms = {
|
|
|
254
247
|
* could not be verified.
|
|
255
248
|
*/
|
|
256
249
|
async function verifyRequest(request, options = {}) {
|
|
257
|
-
|
|
258
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
259
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
250
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
260
251
|
if (span.isRecording()) {
|
|
261
252
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
262
253
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
@@ -446,8 +437,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
446
437
|
const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
|
|
447
438
|
const sig = decodeBase64(signature);
|
|
448
439
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
449
|
-
|
|
450
|
-
if (!verified) {
|
|
440
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
451
441
|
if (cached) {
|
|
452
442
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
453
443
|
keyId,
|
|
@@ -461,7 +451,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
461
451
|
currentTime,
|
|
462
452
|
keyCache: {
|
|
463
453
|
get: () => Promise.resolve(void 0),
|
|
464
|
-
set: async (keyId
|
|
454
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
465
455
|
}
|
|
466
456
|
});
|
|
467
457
|
}
|
|
@@ -611,9 +601,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
611
601
|
logger.debug("Failed to verify; Content-Digest header required but not found.", { components: sigInput.components });
|
|
612
602
|
continue;
|
|
613
603
|
}
|
|
614
|
-
|
|
615
|
-
const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
|
|
616
|
-
if (!digestValid) {
|
|
604
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
|
|
617
605
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
618
606
|
continue;
|
|
619
607
|
}
|
|
@@ -659,8 +647,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
659
647
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
660
648
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
661
649
|
try {
|
|
662
|
-
|
|
663
|
-
if (verified) {
|
|
650
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
|
|
664
651
|
validKey = key;
|
|
665
652
|
break;
|
|
666
653
|
} else if (cached) {
|
|
@@ -672,7 +659,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
672
659
|
currentTime,
|
|
673
660
|
keyCache: {
|
|
674
661
|
get: () => Promise.resolve(void 0),
|
|
675
|
-
set: async (keyId, key
|
|
662
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
676
663
|
},
|
|
677
664
|
spec: "rfc9421"
|
|
678
665
|
});
|
|
@@ -745,8 +732,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
745
732
|
});
|
|
746
733
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
747
734
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
748
|
-
const
|
|
749
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
735
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
750
736
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
751
737
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
752
738
|
...options,
|
|
@@ -776,8 +762,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
776
762
|
});
|
|
777
763
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
778
764
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
779
|
-
const
|
|
780
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
765
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
781
766
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
782
767
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
783
768
|
...options,
|
|
@@ -814,6 +799,5 @@ function timingSafeEqual(a, b) {
|
|
|
814
799
|
result |= lenA ^ lenB;
|
|
815
800
|
return result === 0;
|
|
816
801
|
}
|
|
817
|
-
|
|
818
802
|
//#endregion
|
|
819
|
-
export { doubleKnock, signRequest,
|
|
803
|
+
export { parseRfc9421Signature as a, timingSafeEqual as c, formatRfc9421SignatureParameters as i, verifyRequest as l, doubleKnock as n, parseRfc9421SignatureInput as o, formatRfc9421Signature as r, signRequest as s, createRfc9421SignatureBase as t };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { CryptographicKey, FetchError, deno_default } from "./type-kdsaa4c5.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-kD68vuX_.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
import { d as name, f as version, t as FetchError } from "./docloader-Dlo9EMTn.js";
|
|
4
|
+
import { y as CryptographicKey } from "./actor-B3mkavdq.js";
|
|
5
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-DPg0mibt.js";
|
|
8
6
|
import { getLogger } from "@logtape/logtape";
|
|
9
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
|
-
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
11
8
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
12
9
|
import { encodeHex } from "byte-encodings/hex";
|
|
10
|
+
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
13
11
|
import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
14
|
-
|
|
15
12
|
//#region src/sig/http.ts
|
|
16
13
|
const DEFAULT_MAX_REDIRECTION = 20;
|
|
17
14
|
/**
|
|
@@ -25,9 +22,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
25
22
|
*/
|
|
26
23
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
27
24
|
validateCryptoKey(privateKey, "private");
|
|
28
|
-
|
|
29
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
30
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
25
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
31
26
|
try {
|
|
32
27
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
33
28
|
let signed;
|
|
@@ -122,9 +117,7 @@ function createRfc9421SignatureBase(request, components, parameters) {
|
|
|
122
117
|
* @returns The formatted signature string.
|
|
123
118
|
*/
|
|
124
119
|
function formatRfc9421Signature(signature, components, parameters) {
|
|
125
|
-
|
|
126
|
-
const signatureValue = `sig1=:${encodeBase64(signature)}:`;
|
|
127
|
-
return [signatureInputValue, signatureValue];
|
|
120
|
+
return [`sig1=("${components.join("\" \"")}");${parameters}`, `sig1=:${encodeBase64(signature)}:`];
|
|
128
121
|
}
|
|
129
122
|
/**
|
|
130
123
|
* Parse RFC 9421 Signature-Input header.
|
|
@@ -254,9 +247,7 @@ const supportedHashAlgorithms = {
|
|
|
254
247
|
* could not be verified.
|
|
255
248
|
*/
|
|
256
249
|
async function verifyRequest(request, options = {}) {
|
|
257
|
-
|
|
258
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
259
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
250
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
260
251
|
if (span.isRecording()) {
|
|
261
252
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
262
253
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
@@ -446,8 +437,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
446
437
|
const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
|
|
447
438
|
const sig = decodeBase64(signature);
|
|
448
439
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
449
|
-
|
|
450
|
-
if (!verified) {
|
|
440
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
451
441
|
if (cached) {
|
|
452
442
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
453
443
|
keyId,
|
|
@@ -461,7 +451,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
461
451
|
currentTime,
|
|
462
452
|
keyCache: {
|
|
463
453
|
get: () => Promise.resolve(void 0),
|
|
464
|
-
set: async (keyId
|
|
454
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
465
455
|
}
|
|
466
456
|
});
|
|
467
457
|
}
|
|
@@ -611,9 +601,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
611
601
|
logger.debug("Failed to verify; Content-Digest header required but not found.", { components: sigInput.components });
|
|
612
602
|
continue;
|
|
613
603
|
}
|
|
614
|
-
|
|
615
|
-
const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
|
|
616
|
-
if (!digestValid) {
|
|
604
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
|
|
617
605
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
618
606
|
continue;
|
|
619
607
|
}
|
|
@@ -659,8 +647,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
659
647
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
660
648
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
661
649
|
try {
|
|
662
|
-
|
|
663
|
-
if (verified) {
|
|
650
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
|
|
664
651
|
validKey = key;
|
|
665
652
|
break;
|
|
666
653
|
} else if (cached) {
|
|
@@ -672,7 +659,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
672
659
|
currentTime,
|
|
673
660
|
keyCache: {
|
|
674
661
|
get: () => Promise.resolve(void 0),
|
|
675
|
-
set: async (keyId, key
|
|
662
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
676
663
|
},
|
|
677
664
|
spec: "rfc9421"
|
|
678
665
|
});
|
|
@@ -745,8 +732,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
745
732
|
});
|
|
746
733
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
747
734
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
748
|
-
const
|
|
749
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
735
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
750
736
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
751
737
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
752
738
|
...options,
|
|
@@ -776,8 +762,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
776
762
|
});
|
|
777
763
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
778
764
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
779
|
-
const
|
|
780
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
765
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
781
766
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
782
767
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
783
768
|
...options,
|
|
@@ -814,6 +799,5 @@ function timingSafeEqual(a, b) {
|
|
|
814
799
|
result |= lenA ^ lenB;
|
|
815
800
|
return result === 0;
|
|
816
801
|
}
|
|
817
|
-
|
|
818
802
|
//#endregion
|
|
819
|
-
export {
|
|
803
|
+
export { signRequest as n, verifyRequest as r, doubleKnock as t };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { Activity, deno_default, getTypeId } from "./type-kdsaa4c5.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { U as getTypeId, ot as name, st as version, t as Activity } from "./vocab-DuJO9k13.mjs";
|
|
7
5
|
import { getLogger } from "@logtape/logtape";
|
|
8
6
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
9
|
-
|
|
10
7
|
//#region src/federation/inbox.ts
|
|
11
8
|
var InboxListenerSet = class InboxListenerSet {
|
|
12
9
|
#listeners;
|
|
@@ -57,10 +54,8 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
57
54
|
warnedAboutDefaultIdempotency = true;
|
|
58
55
|
}
|
|
59
56
|
let keyString;
|
|
60
|
-
if (typeof strategy === "function")
|
|
61
|
-
|
|
62
|
-
keyString = result;
|
|
63
|
-
} else switch (strategy) {
|
|
57
|
+
if (typeof strategy === "function") keyString = await strategy(inboxContext, activity);
|
|
58
|
+
else switch (strategy) {
|
|
64
59
|
case "global":
|
|
65
60
|
keyString = activity.id.href;
|
|
66
61
|
break;
|
|
@@ -75,8 +70,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
75
70
|
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
76
71
|
}
|
|
77
72
|
if (cacheKey != null) {
|
|
78
|
-
|
|
79
|
-
if (cached === true) {
|
|
73
|
+
if (await kv.get(cacheKey) === true) {
|
|
80
74
|
logger.debug("Activity {activityId} has already been processed.", {
|
|
81
75
|
activityId: activity.id?.href,
|
|
82
76
|
activity: json,
|
|
@@ -133,31 +127,30 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
133
127
|
return "enqueued";
|
|
134
128
|
}
|
|
135
129
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
136
|
-
|
|
137
|
-
return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
|
|
130
|
+
return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
138
131
|
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
139
132
|
if (dispatched == null) {
|
|
140
133
|
logger.error("Unsupported activity type:\n{activity}", {
|
|
141
134
|
activity: json,
|
|
142
135
|
recipient
|
|
143
136
|
});
|
|
144
|
-
span
|
|
137
|
+
span.setStatus({
|
|
145
138
|
code: SpanStatusCode.UNSET,
|
|
146
139
|
message: `Unsupported activity type: ${getTypeId(activity).href}`
|
|
147
140
|
});
|
|
148
|
-
span
|
|
141
|
+
span.end();
|
|
149
142
|
return "unsupportedActivity";
|
|
150
143
|
}
|
|
151
144
|
const { class: cls, listener } = dispatched;
|
|
152
|
-
span
|
|
145
|
+
span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
153
146
|
try {
|
|
154
147
|
await listener(inboxContextFactory(recipient, json, activity?.id?.href, getTypeId(activity).href), activity);
|
|
155
148
|
} catch (error) {
|
|
156
149
|
try {
|
|
157
150
|
await inboxErrorHandler?.(ctx, error);
|
|
158
|
-
} catch (error
|
|
151
|
+
} catch (error) {
|
|
159
152
|
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
160
|
-
error
|
|
153
|
+
error,
|
|
161
154
|
activityId: activity.id?.href,
|
|
162
155
|
activity: json,
|
|
163
156
|
recipient
|
|
@@ -169,11 +162,11 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
169
162
|
activity: json,
|
|
170
163
|
recipient
|
|
171
164
|
});
|
|
172
|
-
span
|
|
165
|
+
span.setStatus({
|
|
173
166
|
code: SpanStatusCode.ERROR,
|
|
174
167
|
message: String(error)
|
|
175
168
|
});
|
|
176
|
-
span
|
|
169
|
+
span.end();
|
|
177
170
|
return "error";
|
|
178
171
|
}
|
|
179
172
|
if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
@@ -182,10 +175,9 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
182
175
|
activity: json,
|
|
183
176
|
recipient
|
|
184
177
|
});
|
|
185
|
-
span
|
|
178
|
+
span.end();
|
|
186
179
|
return "success";
|
|
187
180
|
});
|
|
188
181
|
}
|
|
189
|
-
|
|
190
182
|
//#endregion
|
|
191
|
-
export {
|
|
183
|
+
export { routeActivity as n, InboxListenerSet as t };
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const require_actor = require('./actor-C71CIMfC.cjs');
|
|
8
|
-
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
9
|
-
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
10
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
+
const require_docloader = require("./docloader-Co-tW1B6.cjs");
|
|
4
|
+
const require_actor = require("./actor-CsvteFj1.cjs");
|
|
5
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
11
7
|
//#region src/sig/key.ts
|
|
12
8
|
/**
|
|
13
9
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
|
@@ -22,8 +18,7 @@ function validateCryptoKey(key, type) {
|
|
|
22
18
|
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
|
23
19
|
if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
|
|
24
20
|
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
25
|
-
|
|
26
|
-
if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
21
|
+
if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
@@ -34,7 +29,7 @@ function validateCryptoKey(key, type) {
|
|
|
34
29
|
* @throws {TypeError} If the algorithm is unsupported.
|
|
35
30
|
*/
|
|
36
31
|
function generateCryptoKeyPair(algorithm) {
|
|
37
|
-
if (algorithm == null) (0,
|
|
32
|
+
if (algorithm == null) (0, _logtape_logtape.getLogger)([
|
|
38
33
|
"fedify",
|
|
39
34
|
"sig",
|
|
40
35
|
"key"
|
|
@@ -102,11 +97,10 @@ async function importJwk(jwk, type) {
|
|
|
102
97
|
* @since 1.3.0
|
|
103
98
|
*/
|
|
104
99
|
function fetchKey(keyId, cls, options = {}) {
|
|
105
|
-
const
|
|
106
|
-
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
|
100
|
+
const tracer = (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version);
|
|
107
101
|
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
108
102
|
return tracer.startActiveSpan("activitypub.fetch_key", {
|
|
109
|
-
kind:
|
|
103
|
+
kind: _opentelemetry_api.SpanKind.CLIENT,
|
|
110
104
|
attributes: {
|
|
111
105
|
"http.method": "GET",
|
|
112
106
|
"url.full": keyId.href,
|
|
@@ -123,7 +117,7 @@ function fetchKey(keyId, cls, options = {}) {
|
|
|
123
117
|
return result;
|
|
124
118
|
} catch (e) {
|
|
125
119
|
span.setStatus({
|
|
126
|
-
code:
|
|
120
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
127
121
|
message: String(e)
|
|
128
122
|
});
|
|
129
123
|
throw e;
|
|
@@ -133,7 +127,7 @@ function fetchKey(keyId, cls, options = {}) {
|
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
129
|
async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, keyCache, tracerProvider } = {}) {
|
|
136
|
-
const logger = (0,
|
|
130
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
137
131
|
"fedify",
|
|
138
132
|
"sig",
|
|
139
133
|
"key"
|
|
@@ -159,8 +153,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
159
153
|
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
160
154
|
let document;
|
|
161
155
|
try {
|
|
162
|
-
|
|
163
|
-
document = remoteDocument.document;
|
|
156
|
+
document = (await (documentLoader ?? require_docloader.getDocumentLoader())(keyId)).document;
|
|
164
157
|
} catch (_) {
|
|
165
158
|
logger.debug("Failed to fetch key {keyId}.", { keyId });
|
|
166
159
|
await keyCache?.set(cacheKey, null);
|
|
@@ -184,8 +177,8 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
184
177
|
contextLoader,
|
|
185
178
|
tracerProvider
|
|
186
179
|
});
|
|
187
|
-
} catch (e
|
|
188
|
-
if (e
|
|
180
|
+
} catch (e) {
|
|
181
|
+
if (e instanceof TypeError) {
|
|
189
182
|
logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
|
|
190
183
|
await keyCache?.set(cacheKey, null);
|
|
191
184
|
return {
|
|
@@ -193,7 +186,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
193
186
|
cached: false
|
|
194
187
|
};
|
|
195
188
|
}
|
|
196
|
-
throw e
|
|
189
|
+
throw e;
|
|
197
190
|
}
|
|
198
191
|
}
|
|
199
192
|
let key = null;
|
|
@@ -256,35 +249,34 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
256
249
|
cached: false
|
|
257
250
|
};
|
|
258
251
|
}
|
|
259
|
-
|
|
260
252
|
//#endregion
|
|
261
|
-
Object.defineProperty(exports,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
Object.defineProperty(exports, "exportJwk", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function() {
|
|
256
|
+
return exportJwk;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
Object.defineProperty(exports, "fetchKey", {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function() {
|
|
262
|
+
return fetchKey;
|
|
263
|
+
}
|
|
266
264
|
});
|
|
267
|
-
Object.defineProperty(exports,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
265
|
+
Object.defineProperty(exports, "generateCryptoKeyPair", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
get: function() {
|
|
268
|
+
return generateCryptoKeyPair;
|
|
269
|
+
}
|
|
272
270
|
});
|
|
273
|
-
Object.defineProperty(exports,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
271
|
+
Object.defineProperty(exports, "importJwk", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
get: function() {
|
|
274
|
+
return importJwk;
|
|
275
|
+
}
|
|
278
276
|
});
|
|
279
|
-
Object.defineProperty(exports,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
277
|
+
Object.defineProperty(exports, "validateCryptoKey", {
|
|
278
|
+
enumerable: true,
|
|
279
|
+
get: function() {
|
|
280
|
+
return validateCryptoKey;
|
|
281
|
+
}
|
|
284
282
|
});
|
|
285
|
-
Object.defineProperty(exports, 'validateCryptoKey', {
|
|
286
|
-
enumerable: true,
|
|
287
|
-
get: function () {
|
|
288
|
-
return validateCryptoKey;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { CryptographicKey, Object as Object$1, isActor } from "./actor-CCg-pZae.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-DuJO9k13.mjs";
|
|
5
|
+
import { i as isActor } from "./actor-DeUOMMMQ.mjs";
|
|
7
6
|
import { getLogger } from "@logtape/logtape";
|
|
8
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
|
-
|
|
10
8
|
//#region src/sig/key.ts
|
|
11
9
|
/**
|
|
12
10
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
|
@@ -21,8 +19,7 @@ function validateCryptoKey(key, type) {
|
|
|
21
19
|
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
|
22
20
|
if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
|
|
23
21
|
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
24
|
-
|
|
25
|
-
if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
22
|
+
if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
@@ -101,8 +98,7 @@ async function importJwk(jwk, type) {
|
|
|
101
98
|
* @since 1.3.0
|
|
102
99
|
*/
|
|
103
100
|
function fetchKey(keyId, cls, options = {}) {
|
|
104
|
-
const
|
|
105
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
101
|
+
const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version);
|
|
106
102
|
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
107
103
|
return tracer.startActiveSpan("activitypub.fetch_key", {
|
|
108
104
|
kind: SpanKind.CLIENT,
|
|
@@ -158,8 +154,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
158
154
|
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
159
155
|
let document;
|
|
160
156
|
try {
|
|
161
|
-
|
|
162
|
-
document = remoteDocument.document;
|
|
157
|
+
document = (await (documentLoader ?? getDocumentLoader())(keyId)).document;
|
|
163
158
|
} catch (_) {
|
|
164
159
|
logger.debug("Failed to fetch key {keyId}.", { keyId });
|
|
165
160
|
await keyCache?.set(cacheKey, null);
|
|
@@ -183,8 +178,8 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
183
178
|
contextLoader,
|
|
184
179
|
tracerProvider
|
|
185
180
|
});
|
|
186
|
-
} catch (e
|
|
187
|
-
if (e
|
|
181
|
+
} catch (e) {
|
|
182
|
+
if (e instanceof TypeError) {
|
|
188
183
|
logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
|
|
189
184
|
await keyCache?.set(cacheKey, null);
|
|
190
185
|
return {
|
|
@@ -192,7 +187,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
192
187
|
cached: false
|
|
193
188
|
};
|
|
194
189
|
}
|
|
195
|
-
throw e
|
|
190
|
+
throw e;
|
|
196
191
|
}
|
|
197
192
|
}
|
|
198
193
|
let key = null;
|
|
@@ -255,6 +250,5 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
255
250
|
cached: false
|
|
256
251
|
};
|
|
257
252
|
}
|
|
258
|
-
|
|
259
253
|
//#endregion
|
|
260
|
-
export {
|
|
254
|
+
export { validateCryptoKey as a, importJwk as i, fetchKey as n, generateCryptoKeyPair as r, exportJwk as t };
|