@fedify/fedify 2.1.1 → 2.1.3
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/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
- package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.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_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
- package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
- package/dist/{builder-DbKYZdSy.js → builder-BKo51w-F.mjs} +32 -41
- package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
- package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
- package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
- package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
- package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
- 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 -6
- package/dist/compat/mod.d.ts +78 -6
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
- package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
- package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
- package/dist/deno-D5r_9RvZ.mjs +8 -0
- package/dist/{docloader-Ck0SCLXX.js → docloader-B9CXCw8i.mjs} +8 -14
- package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
- package/dist/federation/builder.test.d.mts +2 -0
- package/dist/federation/{builder.test.js → builder.test.mjs} +21 -44
- 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} +69 -131
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -19
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +173 -262
- package/dist/federation/mod.cjs +327 -16
- package/dist/federation/mod.d.cts +3 -6
- package/dist/federation/mod.d.ts +3 -6
- package/dist/federation/mod.js +322 -13
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
- package/dist/federation/negotiation.test.d.mts +2 -0
- package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +11 -16
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +22 -30
- package/dist/federation/webfinger.test.d.mts +2 -0
- package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
- package/dist/{http-DFzT4YFG.js → http-B53alCGi.mjs} +23 -43
- package/dist/{http-ca2xny58.cjs → http-BngkmEhl.cjs} +177 -302
- package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
- package/dist/{http-EUQ6crVa.js → http-PS3wuU8D.js} +53 -184
- package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
- package/dist/{inbox-BMLz_-pL.js → inbox-CHsLu5ai.mjs} +18 -26
- package/dist/{key-CypuWa94.js → key-D9Np_ZXl.mjs} +29 -37
- package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
- package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
- package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
- package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
- package/dist/{kv-cache-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
- package/dist/{kv-cache-SKgbvvu4.js → kv-cache-B2Qi5MGv.js} +6 -13
- package/dist/{kv-cache-BBJFLMW5.cjs → kv-cache-YCtINZK4.cjs} +27 -34
- package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
- package/dist/{ld-CXLtTc0G.js → ld-BaxRFhDd.mjs} +17 -31
- package/dist/{middleware-CL6XaAFy.cjs → middleware-Bsv-7iX7.cjs} +532 -587
- package/dist/middleware-C37OmOz_.mjs +5 -0
- package/dist/middleware-CelV2xrI.cjs +4 -0
- package/dist/{middleware-CvS6hWm3.js → middleware-Dn1kk96N.js} +335 -382
- package/dist/{middleware-BHJ0xm0L.js → middleware-dFn6ozt5.mjs} +282 -317
- package/dist/{mod-Bx9jcLB8.d.cts → mod-B505FZBC.d.cts} +3 -3
- package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
- package/dist/{mod-Cs2dYEwI.d.ts → mod-D7PAuO6k.d.ts} +3 -3
- package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
- package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
- package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
- package/dist/mod.cjs +29 -74
- package/dist/mod.d.cts +11 -14
- package/dist/mod.d.ts +11 -15
- package/dist/mod.js +17 -71
- package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.mjs} +7 -11
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -43
- package/dist/nodeinfo/mod.cjs +5 -8
- package/dist/nodeinfo/mod.d.cts +2 -3
- package/dist/nodeinfo/mod.d.ts +2 -3
- package/dist/nodeinfo/mod.js +4 -8
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +124 -178
- package/dist/otel/mod.cjs +15 -20
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +8 -14
- package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
- package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
- package/dist/{owner-CwMai3jn.js → owner-dxM51u36.mjs} +11 -16
- package/dist/{proof-ZuJBOUoi.js → proof-CH5U0k7G.mjs} +21 -33
- package/dist/{proof-sCID81Ua.cjs → proof-D39qiki3.cjs} +133 -157
- package/dist/{proof-6Zw1FW7t.js → proof-Dpgqx9RS.js} +32 -58
- package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.mjs} +4 -7
- package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
- package/dist/runtime/mod.cjs +11 -13
- package/dist/runtime/mod.d.cts +6 -2
- package/dist/runtime/mod.d.ts +0 -1
- package/dist/runtime/mod.js +4 -7
- package/dist/{send-BW73dy6Q.js → send-D1-4ZnQq.mjs} +8 -13
- package/dist/sig/accept.test.d.mts +2 -0
- package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +166 -280
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +11 -18
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
- package/dist/sig/mod.cjs +6 -9
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +5 -9
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
- package/dist/{std__assert-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
- package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
- package/dist/testing/mod.mjs +6 -0
- package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
- package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
- package/dist/{types-CPz01LGH.js → types-DCP0WLdt.mjs} +4 -7
- package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
- package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
- package/dist/utils/docloader.test.d.mts +2 -0
- package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -25
- package/dist/utils/kv-cache.test.d.mts +2 -0
- package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
- package/dist/utils/mod.cjs +5 -9
- package/dist/utils/mod.d.cts +1 -3
- package/dist/utils/mod.d.ts +1 -3
- package/dist/utils/mod.js +4 -9
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/mod.cjs +10 -12
- package/dist/vocab/mod.js +3 -5
- package/package.json +8 -8
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -88
- package/dist/compat-Bb4NuTUO.js +0 -4
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/deno-DH972JvX.js +0 -121
- 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 -32
- 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/negotiation.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/webfinger.test.d.ts +0 -3
- package/dist/federation-Bp3HI26G.cjs +0 -350
- package/dist/federation-DaMfqRm4.js +0 -332
- package/dist/middleware-B8FJuMM0.js +0 -27
- package/dist/middleware-BVp930fR.js +0 -12
- package/dist/middleware-BvGP-uXy.cjs +0 -12
- package/dist/mod-B7QkWzrL.d.cts +0 -80
- package/dist/mod-Bh8mqlYw.d.cts +0 -9
- package/dist/mod-D6HodEq7.d.ts +0 -7
- package/dist/mod-SMHOMNpZ.d.ts +0 -82
- package/dist/mod-gq_Xfdz8.d.cts +0 -1
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-DoESQxq5.js +0 -4
- package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime-c2Njxsry.cjs +0 -17
- package/dist/runtime-poamPCMb.js +0 -13
- package/dist/sig/accept.test.d.ts +0 -3
- 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-BNhspNOf.js +0 -4
- package/dist/sig-vX39WyWI.cjs +0 -4
- package/dist/testing/mod.js +0 -10
- package/dist/utils/docloader.test.d.ts +0 -3
- package/dist/utils/kv-cache.test.d.ts +0 -3
- package/dist/utils-BQ9KqEK9.cjs +0 -4
- package/dist/utils-Dn5OPdSW.js +0 -4
- /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
|
@@ -3,7 +3,6 @@ import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
|
3
3
|
import { TracerProvider } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
5
|
//#region src/sig/key.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Generates a key pair which is appropriate for Fedify.
|
|
9
8
|
* @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
|
|
@@ -536,9 +535,5 @@ interface HttpMessageSignaturesSpecDeterminer {
|
|
|
536
535
|
*/
|
|
537
536
|
rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
|
|
538
537
|
}
|
|
539
|
-
/**
|
|
540
|
-
* The options for double-knock requests.
|
|
541
|
-
* @since 1.6.0
|
|
542
|
-
*/
|
|
543
538
|
//#endregion
|
|
544
|
-
export {
|
|
539
|
+
export { exportJwk as C, importJwk as D, generateCryptoKeyPair as E, KeyCache as S, fetchKeyDetailed as T, validateAcceptSignature as _, VerifyRequestDetailedResult as a, FetchKeyOptions as b, signRequest as c, AcceptSignatureMember as d, AcceptSignatureParameters as f, parseAcceptSignature as g, fulfillAcceptSignature as h, SignRequestOptions as i, verifyRequest as l, formatAcceptSignature as m, HttpMessageSignaturesSpecDeterminer as n, VerifyRequestFailureReason as o, FulfillAcceptSignatureResult as p, Rfc9421SignRequestOptions as r, VerifyRequestOptions as s, HttpMessageSignaturesSpec as t, verifyRequestDetailed as u, FetchKeyDetailedResult as v, fetchKey as w, FetchKeyResult as x, FetchKeyErrorResult as y };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
5
3
|
import { getLogger } from "@logtape/logtape";
|
|
6
4
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
5
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -10,124 +8,18 @@ import { Item, decodeDict, encodeDict, encodeItem } from "structured-field-value
|
|
|
10
8
|
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
11
9
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
12
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
13
|
-
|
|
14
11
|
//#region deno.json
|
|
15
12
|
var name = "@fedify/fedify";
|
|
16
|
-
var version = "2.1.
|
|
17
|
-
var license = "MIT";
|
|
18
|
-
var exports = {
|
|
19
|
-
".": "./src/mod.ts",
|
|
20
|
-
"./compat": "./src/compat/mod.ts",
|
|
21
|
-
"./federation": "./src/federation/mod.ts",
|
|
22
|
-
"./nodeinfo": "./src/nodeinfo/mod.ts",
|
|
23
|
-
"./otel": "./src/otel/mod.ts",
|
|
24
|
-
"./runtime": "./src/runtime/mod.ts",
|
|
25
|
-
"./sig": "./src/sig/mod.ts",
|
|
26
|
-
"./utils": "./src/utils/mod.ts",
|
|
27
|
-
"./vocab": "./src/vocab/mod.ts"
|
|
28
|
-
};
|
|
29
|
-
var imports = {
|
|
30
|
-
"@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
|
|
31
|
-
"@std/assert": "jsr:@std/assert@^0.226.0",
|
|
32
|
-
"@std/url": "jsr:@std/url@^0.225.1",
|
|
33
|
-
"asn1js": "npm:asn1js@^3.0.7",
|
|
34
|
-
"fast-check": "npm:fast-check@^3.22.0",
|
|
35
|
-
"fetch-mock": "npm:fetch-mock@^12.5.2",
|
|
36
|
-
"json-canon": "npm:json-canon@^1.0.1",
|
|
37
|
-
"jsonld": "npm:jsonld@^9.0.0",
|
|
38
|
-
"pkijs": "npm:pkijs@^3.3.3",
|
|
39
|
-
"structured-field-values": "npm:structured-field-values@^2.0.4",
|
|
40
|
-
"uri-template-router": "npm:uri-template-router@^1.0.0",
|
|
41
|
-
"url-template": "npm:url-template@^3.1.1"
|
|
42
|
-
};
|
|
43
|
-
var exclude = [
|
|
44
|
-
".test-report.xml",
|
|
45
|
-
"apidoc/",
|
|
46
|
-
"dist/",
|
|
47
|
-
"node_modules/",
|
|
48
|
-
"npm/",
|
|
49
|
-
"pnpm-lock.yaml",
|
|
50
|
-
"src/cfworkers/dist/",
|
|
51
|
-
"src/cfworkers/fixtures/",
|
|
52
|
-
"src/cfworkers/imports.ts",
|
|
53
|
-
"src/cfworkers/README.md",
|
|
54
|
-
"src/cfworkers/server.ts",
|
|
55
|
-
"src/cfworkers/server.js",
|
|
56
|
-
"src/cfworkers/server.js.map"
|
|
57
|
-
];
|
|
58
|
-
var publish = { "exclude": [
|
|
59
|
-
"**/*.test.ts",
|
|
60
|
-
"src/testing/",
|
|
61
|
-
"tsdown.config.ts",
|
|
62
|
-
"scripts/",
|
|
63
|
-
"wrangler.toml"
|
|
64
|
-
] };
|
|
65
|
-
var tasks = {
|
|
66
|
-
"codegen": "deno task -f @fedify/vocab compile",
|
|
67
|
-
"cache": {
|
|
68
|
-
"command": "deno cache src/mod.ts",
|
|
69
|
-
"dependencies": ["codegen"]
|
|
70
|
-
},
|
|
71
|
-
"check": {
|
|
72
|
-
"command": "deno fmt --check && deno lint && deno check src/**/*.ts",
|
|
73
|
-
"dependencies": ["codegen"]
|
|
74
|
-
},
|
|
75
|
-
"test": {
|
|
76
|
-
"command": "deno test --check --doc --allow-read --allow-write --allow-env --unstable-kv --trace-leaks --parallel",
|
|
77
|
-
"dependencies": ["codegen"]
|
|
78
|
-
},
|
|
79
|
-
"coverage": "deno task test --clean --coverage && deno coverage --html coverage",
|
|
80
|
-
"bench": {
|
|
81
|
-
"command": "deno bench --allow-read --allow-write --allow-net --allow-env --allow-run --unstable-kv",
|
|
82
|
-
"dependencies": ["codegen"]
|
|
83
|
-
},
|
|
84
|
-
"apidoc": {
|
|
85
|
-
"command": "deno doc --html --name=Fedify --output=apidoc/ src/mod.ts",
|
|
86
|
-
"dependencies": ["codegen"]
|
|
87
|
-
},
|
|
88
|
-
"publish": {
|
|
89
|
-
"command": "deno publish",
|
|
90
|
-
"dependencies": ["codegen"]
|
|
91
|
-
},
|
|
92
|
-
"pnpm:install": "pnpm install --silent",
|
|
93
|
-
"pnpm:build": {
|
|
94
|
-
"command": "pnpm exec tsdown",
|
|
95
|
-
"dependencies": ["pnpm:build-vocab"]
|
|
96
|
-
},
|
|
97
|
-
"test:node": {
|
|
98
|
-
"command": "cd dist/ && node --test",
|
|
99
|
-
"dependencies": ["pnpm:build"]
|
|
100
|
-
},
|
|
101
|
-
"test:bun": {
|
|
102
|
-
"command": "cd dist/ && bun test --timeout 60000",
|
|
103
|
-
"dependencies": ["pnpm:build"]
|
|
104
|
-
},
|
|
105
|
-
"test:cfworkers": {
|
|
106
|
-
"command": "pnpm exec wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx src/cfworkers/client.ts",
|
|
107
|
-
"dependencies": ["pnpm:build"]
|
|
108
|
-
},
|
|
109
|
-
"test-all": { "dependencies": [
|
|
110
|
-
"check",
|
|
111
|
-
"test",
|
|
112
|
-
"test:node",
|
|
113
|
-
"test:bun",
|
|
114
|
-
"test:cfworkers"
|
|
115
|
-
] }
|
|
116
|
-
};
|
|
117
|
-
var deno_default = {
|
|
118
|
-
name,
|
|
119
|
-
version,
|
|
120
|
-
license,
|
|
121
|
-
exports,
|
|
122
|
-
imports,
|
|
123
|
-
exclude,
|
|
124
|
-
publish,
|
|
125
|
-
tasks
|
|
126
|
-
};
|
|
127
|
-
|
|
13
|
+
var version = "2.1.3";
|
|
128
14
|
//#endregion
|
|
129
15
|
//#region src/sig/accept.ts
|
|
130
16
|
/**
|
|
17
|
+
* `Accept-Signature` header parsing, serialization, and validation utilities
|
|
18
|
+
* for RFC 9421 §5 challenge-response negotiation.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
131
23
|
* Parses an `Accept-Signature` header value (RFC 9421 §5.1) into an
|
|
132
24
|
* array of {@link AcceptSignatureMember} objects.
|
|
133
25
|
*
|
|
@@ -258,7 +150,6 @@ function fulfillAcceptSignature(entry, localKeyId, localAlg) {
|
|
|
258
150
|
expires: entry.parameters.expires
|
|
259
151
|
};
|
|
260
152
|
}
|
|
261
|
-
|
|
262
153
|
//#endregion
|
|
263
154
|
//#region src/sig/key.ts
|
|
264
155
|
/**
|
|
@@ -274,8 +165,7 @@ function validateCryptoKey(key, type) {
|
|
|
274
165
|
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
|
275
166
|
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!");
|
|
276
167
|
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
277
|
-
|
|
278
|
-
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.");
|
|
168
|
+
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.");
|
|
279
169
|
}
|
|
280
170
|
}
|
|
281
171
|
/**
|
|
@@ -342,8 +232,7 @@ async function importJwk(jwk, type) {
|
|
|
342
232
|
}
|
|
343
233
|
async function withFetchKeySpan(keyId, tracerProvider, fetcher) {
|
|
344
234
|
tracerProvider ??= trace.getTracerProvider();
|
|
345
|
-
|
|
346
|
-
return await tracer.startActiveSpan("activitypub.fetch_key", {
|
|
235
|
+
return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.fetch_key", {
|
|
347
236
|
kind: SpanKind.CLIENT,
|
|
348
237
|
attributes: {
|
|
349
238
|
"http.method": "GET",
|
|
@@ -404,41 +293,41 @@ function fetchKey(keyId, cls, options = {}) {
|
|
|
404
293
|
async function fetchKeyDetailed(keyId, cls, options = {}) {
|
|
405
294
|
const cacheKey = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
406
295
|
return await withFetchKeySpan(cacheKey, options.tracerProvider, async () => {
|
|
407
|
-
return await fetchKeyWithResult(cacheKey, cls, options, async (cacheKey
|
|
408
|
-
const fetchError = await keyCache?.getFetchError?.(cacheKey
|
|
296
|
+
return await fetchKeyWithResult(cacheKey, cls, options, async (cacheKey, keyId, keyCache, logger) => {
|
|
297
|
+
const fetchError = await keyCache?.getFetchError?.(cacheKey);
|
|
409
298
|
if (fetchError != null) {
|
|
410
|
-
logger.debug("Entry {keyId} found in cache with preserved fetch failure details.", { keyId
|
|
299
|
+
logger.debug("Entry {keyId} found in cache with preserved fetch failure details.", { keyId });
|
|
411
300
|
return {
|
|
412
301
|
key: null,
|
|
413
302
|
cached: true,
|
|
414
303
|
fetchError
|
|
415
304
|
};
|
|
416
305
|
}
|
|
417
|
-
logger.debug("Entry {keyId} found in cache, but no fetch failure details are available.", { keyId
|
|
306
|
+
logger.debug("Entry {keyId} found in cache, but no fetch failure details are available.", { keyId });
|
|
418
307
|
return {
|
|
419
308
|
key: null,
|
|
420
309
|
cached: true
|
|
421
310
|
};
|
|
422
|
-
}, async (error, cacheKey
|
|
311
|
+
}, async (error, cacheKey, keyId, keyCache, logger) => {
|
|
423
312
|
logger.debug("Failed to fetch key {keyId}.", {
|
|
424
|
-
keyId
|
|
313
|
+
keyId,
|
|
425
314
|
error
|
|
426
315
|
});
|
|
427
|
-
await keyCache?.set(cacheKey
|
|
316
|
+
await keyCache?.set(cacheKey, null);
|
|
428
317
|
if (error instanceof FetchError && error.response != null) {
|
|
429
|
-
const fetchError
|
|
318
|
+
const fetchError = {
|
|
430
319
|
status: error.response.status,
|
|
431
320
|
response: error.response.clone()
|
|
432
321
|
};
|
|
433
|
-
await keyCache?.setFetchError?.(cacheKey
|
|
322
|
+
await keyCache?.setFetchError?.(cacheKey, fetchError);
|
|
434
323
|
return {
|
|
435
324
|
key: null,
|
|
436
325
|
cached: false,
|
|
437
|
-
fetchError
|
|
326
|
+
fetchError
|
|
438
327
|
};
|
|
439
328
|
}
|
|
440
329
|
const fetchError = { error: error instanceof Error ? error : new Error(String(error)) };
|
|
441
|
-
await keyCache?.setFetchError?.(cacheKey
|
|
330
|
+
await keyCache?.setFetchError?.(cacheKey, fetchError);
|
|
442
331
|
return {
|
|
443
332
|
key: null,
|
|
444
333
|
cached: false,
|
|
@@ -484,8 +373,8 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
|
|
|
484
373
|
contextLoader,
|
|
485
374
|
tracerProvider
|
|
486
375
|
});
|
|
487
|
-
} catch (e
|
|
488
|
-
if (e
|
|
376
|
+
} catch (e) {
|
|
377
|
+
if (e instanceof TypeError) {
|
|
489
378
|
logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
|
|
490
379
|
await keyCache?.set(cacheKey, null);
|
|
491
380
|
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
@@ -494,7 +383,7 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
|
|
|
494
383
|
cached: false
|
|
495
384
|
};
|
|
496
385
|
}
|
|
497
|
-
throw e
|
|
386
|
+
throw e;
|
|
498
387
|
}
|
|
499
388
|
}
|
|
500
389
|
let key = null;
|
|
@@ -575,38 +464,35 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
|
|
|
575
464
|
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
576
465
|
let document;
|
|
577
466
|
try {
|
|
578
|
-
|
|
579
|
-
document = remoteDocument.document;
|
|
467
|
+
document = (await (options.documentLoader ?? getDocumentLoader())(keyId)).document;
|
|
580
468
|
} catch (error) {
|
|
581
469
|
return await onFetchError(error, cacheKey, keyId, keyCache, logger);
|
|
582
470
|
}
|
|
583
471
|
return await resolveFetchedKey(document, cacheKey, keyId, cls, options, logger);
|
|
584
472
|
}
|
|
585
473
|
async function fetchKeyInternal(keyId, cls, options = {}) {
|
|
586
|
-
|
|
587
|
-
return await fetchKeyWithResult(cacheKey, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
|
|
474
|
+
return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
|
|
588
475
|
return {
|
|
589
476
|
key: null,
|
|
590
477
|
cached: true
|
|
591
478
|
};
|
|
592
|
-
}, async (error, cacheKey
|
|
479
|
+
}, async (error, cacheKey, keyId, keyCache, logger) => {
|
|
593
480
|
logger.debug("Failed to fetch key {keyId}.", {
|
|
594
|
-
keyId
|
|
481
|
+
keyId,
|
|
595
482
|
error
|
|
596
483
|
});
|
|
597
|
-
await keyCache?.set(cacheKey
|
|
598
|
-
if (error instanceof FetchError && error.response != null) await keyCache?.setFetchError?.(cacheKey
|
|
484
|
+
await keyCache?.set(cacheKey, null);
|
|
485
|
+
if (error instanceof FetchError && error.response != null) await keyCache?.setFetchError?.(cacheKey, {
|
|
599
486
|
status: error.response.status,
|
|
600
487
|
response: error.response.clone()
|
|
601
488
|
});
|
|
602
|
-
else await keyCache?.setFetchError?.(cacheKey
|
|
489
|
+
else await keyCache?.setFetchError?.(cacheKey, { error: error instanceof Error ? error : new Error(String(error)) });
|
|
603
490
|
return {
|
|
604
491
|
key: null,
|
|
605
492
|
cached: false
|
|
606
493
|
};
|
|
607
494
|
});
|
|
608
495
|
}
|
|
609
|
-
|
|
610
496
|
//#endregion
|
|
611
497
|
//#region src/sig/http.ts
|
|
612
498
|
const DEFAULT_MAX_REDIRECTION = 20;
|
|
@@ -621,9 +507,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
621
507
|
*/
|
|
622
508
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
623
509
|
validateCryptoKey(privateKey, "private");
|
|
624
|
-
|
|
625
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
626
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
510
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
627
511
|
try {
|
|
628
512
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
629
513
|
let signed;
|
|
@@ -632,7 +516,7 @@ async function signRequest(request, privateKey, keyId, options = {}) {
|
|
|
632
516
|
if (span.isRecording()) {
|
|
633
517
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, signed.method);
|
|
634
518
|
span.setAttribute(ATTR_URL_FULL, signed.url);
|
|
635
|
-
for (const [name
|
|
519
|
+
for (const [name, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
|
|
636
520
|
span.setAttribute("http_signatures.key_id", keyId.href);
|
|
637
521
|
}
|
|
638
522
|
return signed;
|
|
@@ -660,8 +544,8 @@ async function signRequestDraft(request, privateKey, keyId, span, currentTime, b
|
|
|
660
544
|
}
|
|
661
545
|
if (!headers.has("Date")) headers.set("Date", currentTime == null ? (/* @__PURE__ */ new Date()).toUTCString() : new Date(currentTime.toString()).toUTCString());
|
|
662
546
|
const serialized = [["(request-target)", `${request.method.toLowerCase()} ${url.pathname}`], ...headers];
|
|
663
|
-
const headerNames = serialized.map(([name
|
|
664
|
-
const message = serialized.map(([name
|
|
547
|
+
const headerNames = serialized.map(([name]) => name);
|
|
548
|
+
const message = serialized.map(([name, value]) => `${name}: ${value.trim()}`).join("\n");
|
|
665
549
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, new TextEncoder().encode(message));
|
|
666
550
|
const sigHeader = `keyId="${keyId.href}",algorithm="rsa-sha256",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
|
|
667
551
|
headers.set("Signature", sigHeader);
|
|
@@ -731,9 +615,7 @@ const derivedComponents = {
|
|
|
731
615
|
* @returns The formatted signature string.
|
|
732
616
|
*/
|
|
733
617
|
function formatRfc9421Signature(signature, components, parameters, label = "sig1") {
|
|
734
|
-
|
|
735
|
-
const signatureValue = `${label}=:${encodeBase64(signature)}:`;
|
|
736
|
-
return [signatureInputValue, signatureValue];
|
|
618
|
+
return [`${label}=(${components.map((c) => formatComponentId(c)).join(" ")});${parameters}`, `${label}=:${encodeBase64(signature)}:`];
|
|
737
619
|
}
|
|
738
620
|
/**
|
|
739
621
|
* Parse RFC 9421 Signature-Input header.
|
|
@@ -839,12 +721,11 @@ async function signRequestRfc9421(request, privateKey, keyId, span, currentTime,
|
|
|
839
721
|
value: "content-digest",
|
|
840
722
|
params: {}
|
|
841
723
|
}] : []];
|
|
842
|
-
const expires = rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0;
|
|
843
724
|
const signatureParams = formatRfc9421SignatureParameters({
|
|
844
725
|
algorithm: "rsa-v1_5-sha256",
|
|
845
726
|
keyId,
|
|
846
727
|
created,
|
|
847
|
-
expires,
|
|
728
|
+
expires: rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0,
|
|
848
729
|
nonce: rfc9421Options?.nonce,
|
|
849
730
|
tag: rfc9421Options?.tag
|
|
850
731
|
});
|
|
@@ -954,13 +835,11 @@ async function verifyRequest(request, options = {}) {
|
|
|
954
835
|
* @since 2.1.0
|
|
955
836
|
*/
|
|
956
837
|
async function verifyRequestDetailed(request, options = {}) {
|
|
957
|
-
|
|
958
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
959
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
838
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
960
839
|
if (span.isRecording()) {
|
|
961
840
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
962
841
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
963
|
-
for (const [name
|
|
842
|
+
for (const [name, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
|
|
964
843
|
}
|
|
965
844
|
try {
|
|
966
845
|
let spec = options.spec;
|
|
@@ -1148,11 +1027,10 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
1148
1027
|
logger.debug("Failed to verify; required headers missing in the Signature header: {headers}.", { headers });
|
|
1149
1028
|
return invalidSignatureResult(keyIdUrl);
|
|
1150
1029
|
}
|
|
1151
|
-
const message = headerNames.map((name
|
|
1030
|
+
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");
|
|
1152
1031
|
const sig = decodeBase64(signature);
|
|
1153
1032
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
1154
|
-
|
|
1155
|
-
if (!verified) {
|
|
1033
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
1156
1034
|
if (cached) {
|
|
1157
1035
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
1158
1036
|
keyId,
|
|
@@ -1166,7 +1044,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
1166
1044
|
currentTime,
|
|
1167
1045
|
keyCache: {
|
|
1168
1046
|
get: () => Promise.resolve(void 0),
|
|
1169
|
-
set: async (keyId
|
|
1047
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
1170
1048
|
}
|
|
1171
1049
|
});
|
|
1172
1050
|
}
|
|
@@ -1328,9 +1206,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
1328
1206
|
failure = invalidSignatureResult(keyId);
|
|
1329
1207
|
continue;
|
|
1330
1208
|
}
|
|
1331
|
-
|
|
1332
|
-
const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
|
|
1333
|
-
if (!digestValid) {
|
|
1209
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
|
|
1334
1210
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
1335
1211
|
failure = invalidSignatureResult(keyId);
|
|
1336
1212
|
continue;
|
|
@@ -1388,8 +1264,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
1388
1264
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
1389
1265
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
1390
1266
|
try {
|
|
1391
|
-
|
|
1392
|
-
if (verified) return {
|
|
1267
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) return {
|
|
1393
1268
|
verified: true,
|
|
1394
1269
|
key,
|
|
1395
1270
|
signatureLabel: sigName
|
|
@@ -1403,7 +1278,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
1403
1278
|
currentTime,
|
|
1404
1279
|
keyCache: {
|
|
1405
1280
|
get: () => Promise.resolve(void 0),
|
|
1406
|
-
set: async (keyId
|
|
1281
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
1407
1282
|
},
|
|
1408
1283
|
spec: "rfc9421"
|
|
1409
1284
|
});
|
|
@@ -1480,8 +1355,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
1480
1355
|
});
|
|
1481
1356
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
1482
1357
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
1483
|
-
const
|
|
1484
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
1358
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
1485
1359
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
1486
1360
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
1487
1361
|
...options,
|
|
@@ -1529,13 +1403,10 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
1529
1403
|
redirect: "manual",
|
|
1530
1404
|
signal
|
|
1531
1405
|
});
|
|
1532
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
body
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1406
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(createRedirectRequest(request, response.headers.get("Location"), body), identity, {
|
|
1407
|
+
...options,
|
|
1408
|
+
body
|
|
1409
|
+
});
|
|
1539
1410
|
}
|
|
1540
1411
|
if (fulfilled && response.status < 300) {
|
|
1541
1412
|
await specDeterminer?.rememberSpec(origin, "rfc9421");
|
|
@@ -1562,8 +1433,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
|
|
|
1562
1433
|
});
|
|
1563
1434
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
1564
1435
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
1565
|
-
const
|
|
1566
|
-
const redirectRequest = createRedirectRequest(request, location, body);
|
|
1436
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
1567
1437
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
1568
1438
|
return doubleKnockInternal(redirectRequest, identity, {
|
|
1569
1439
|
...options,
|
|
@@ -1600,6 +1470,5 @@ function timingSafeEqual(a, b) {
|
|
|
1600
1470
|
result |= lenA ^ lenB;
|
|
1601
1471
|
return result === 0;
|
|
1602
1472
|
}
|
|
1603
|
-
|
|
1604
1473
|
//#endregion
|
|
1605
|
-
export {
|
|
1474
|
+
export { version as _, verifyRequestDetailed as a, fetchKeyDetailed as c, validateCryptoKey as d, formatAcceptSignature as f, name as g, validateAcceptSignature as h, verifyRequest as i, generateCryptoKeyPair as l, parseAcceptSignature as m, parseRfc9421SignatureInput as n, exportJwk as o, fulfillAcceptSignature as p, signRequest as r, fetchKey as s, doubleKnock as t, importJwk as u };
|
|
@@ -5,7 +5,6 @@ import { TracerProvider } from "@opentelemetry/api";
|
|
|
5
5
|
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/sig/key.d.ts
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Generates a key pair which is appropriate for Fedify.
|
|
11
10
|
* @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
|
|
@@ -538,9 +537,5 @@ interface HttpMessageSignaturesSpecDeterminer {
|
|
|
538
537
|
*/
|
|
539
538
|
rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
|
|
540
539
|
}
|
|
541
|
-
/**
|
|
542
|
-
* The options for double-knock requests.
|
|
543
|
-
* @since 1.6.0
|
|
544
|
-
*/
|
|
545
540
|
//#endregion
|
|
546
|
-
export {
|
|
541
|
+
export { exportJwk as C, importJwk as D, generateCryptoKeyPair as E, KeyCache as S, fetchKeyDetailed as T, validateAcceptSignature as _, VerifyRequestDetailedResult as a, FetchKeyOptions as b, signRequest as c, AcceptSignatureMember as d, AcceptSignatureParameters as f, parseAcceptSignature as g, fulfillAcceptSignature as h, SignRequestOptions as i, verifyRequest as l, formatAcceptSignature as m, HttpMessageSignaturesSpecDeterminer as n, VerifyRequestFailureReason as o, FulfillAcceptSignatureResult as p, Rfc9421SignRequestOptions as r, VerifyRequestOptions as s, HttpMessageSignaturesSpec as t, verifyRequestDetailed as u, FetchKeyDetailedResult as v, fetchKey as w, FetchKeyResult as x, FetchKeyErrorResult as y };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { deno_default } from "./deno-DH972JvX.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as version, t as name } from "./deno-D5r_9RvZ.mjs";
|
|
7
5
|
import { Activity, getTypeId } from "@fedify/vocab";
|
|
8
|
-
import { getLogger } from "@logtape/logtape";
|
|
9
6
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
10
|
-
|
|
7
|
+
import { getLogger } from "@logtape/logtape";
|
|
11
8
|
//#region src/federation/inbox.ts
|
|
12
9
|
var InboxListenerSet = class InboxListenerSet {
|
|
13
10
|
#listeners;
|
|
@@ -53,10 +50,8 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
53
50
|
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
|
54
51
|
const strategy = idempotencyStrategy ?? "per-inbox";
|
|
55
52
|
let keyString;
|
|
56
|
-
if (typeof strategy === "function")
|
|
57
|
-
|
|
58
|
-
keyString = result;
|
|
59
|
-
} else switch (strategy) {
|
|
53
|
+
if (typeof strategy === "function") keyString = await strategy(inboxContext, activity);
|
|
54
|
+
else switch (strategy) {
|
|
60
55
|
case "global":
|
|
61
56
|
keyString = activity.id.href;
|
|
62
57
|
break;
|
|
@@ -71,8 +66,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
71
66
|
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
72
67
|
}
|
|
73
68
|
if (cacheKey != null) {
|
|
74
|
-
|
|
75
|
-
if (cached === true) {
|
|
69
|
+
if (await kv.get(cacheKey) === true) {
|
|
76
70
|
logger.debug("Activity {activityId} has already been processed.", {
|
|
77
71
|
activityId: activity.id?.href,
|
|
78
72
|
activity: json,
|
|
@@ -129,31 +123,30 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
129
123
|
return "enqueued";
|
|
130
124
|
}
|
|
131
125
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
132
|
-
|
|
133
|
-
return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
|
|
126
|
+
return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
134
127
|
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
135
128
|
if (dispatched == null) {
|
|
136
129
|
logger.error("Unsupported activity type:\n{activity}", {
|
|
137
130
|
activity: json,
|
|
138
131
|
recipient
|
|
139
132
|
});
|
|
140
|
-
span
|
|
133
|
+
span.setStatus({
|
|
141
134
|
code: SpanStatusCode.UNSET,
|
|
142
135
|
message: `Unsupported activity type: ${getTypeId(activity).href}`
|
|
143
136
|
});
|
|
144
|
-
span
|
|
137
|
+
span.end();
|
|
145
138
|
return "unsupportedActivity";
|
|
146
139
|
}
|
|
147
140
|
const { class: cls, listener } = dispatched;
|
|
148
|
-
span
|
|
141
|
+
span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
149
142
|
try {
|
|
150
143
|
await listener(inboxContextFactory(recipient, json, activity?.id?.href, getTypeId(activity).href), activity);
|
|
151
144
|
} catch (error) {
|
|
152
145
|
try {
|
|
153
146
|
await inboxErrorHandler?.(ctx, error);
|
|
154
|
-
} catch (error
|
|
147
|
+
} catch (error) {
|
|
155
148
|
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
156
|
-
error
|
|
149
|
+
error,
|
|
157
150
|
activityId: activity.id?.href,
|
|
158
151
|
activity: json,
|
|
159
152
|
recipient
|
|
@@ -165,11 +158,11 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
165
158
|
activity: json,
|
|
166
159
|
recipient
|
|
167
160
|
});
|
|
168
|
-
span
|
|
161
|
+
span.setStatus({
|
|
169
162
|
code: SpanStatusCode.ERROR,
|
|
170
163
|
message: String(error)
|
|
171
164
|
});
|
|
172
|
-
span
|
|
165
|
+
span.end();
|
|
173
166
|
return "error";
|
|
174
167
|
}
|
|
175
168
|
if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
@@ -178,10 +171,9 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
178
171
|
activity: json,
|
|
179
172
|
recipient
|
|
180
173
|
});
|
|
181
|
-
span
|
|
174
|
+
span.end();
|
|
182
175
|
return "success";
|
|
183
176
|
});
|
|
184
177
|
}
|
|
185
|
-
|
|
186
178
|
//#endregion
|
|
187
|
-
export {
|
|
179
|
+
export { routeActivity as n, InboxListenerSet as t };
|