@fedify/fedify 2.1.0 → 2.1.2
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-WiHhZvjW.js → builder-DkJDAzes.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-C5VMwnFV.mjs +8 -0
- package/dist/{docloader-bVO2EvL9.js → docloader-X9mcJ9Tz.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-DhH623ma.js → http-BLZWcpzg.js} +67 -187
- package/dist/{http-CKDim8Tw.js → http-BTLPIzFa.mjs} +37 -45
- package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
- package/dist/{http-gvnJbMS1.cjs → http-CxodXLwi.cjs} +186 -300
- package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
- package/dist/{inbox-CA9AUEGa.js → inbox-mcbmhjTW.mjs} +18 -26
- package/dist/{key-BsSCz8Z_.js → key-1MaItIGc.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-DK4GFVWx.cjs → kv-cache-DjC82_4n.cjs} +27 -34
- package/dist/{kv-cache-CxoHCR44.js → kv-cache-GIDK1oLs.js} +6 -13
- package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
- package/dist/{ld-Bo_Rx0Fc.js → ld-94uHZ1eO.mjs} +17 -31
- package/dist/{middleware-BkrUA3da.js → middleware-B5Er10wE.js} +336 -383
- package/dist/middleware-CDuHbSVE.mjs +5 -0
- package/dist/middleware-CTyq5KB0.cjs +4 -0
- package/dist/{middleware-CpAnWzjC.cjs → middleware-CqDJSLoG.cjs} +532 -587
- package/dist/{middleware-CZ8jOOa3.js → middleware-DMZGXHm3.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-Bj_IbwIT.js → owner-B4aIDhg_.mjs} +11 -16
- package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
- package/dist/{proof-u6Y358J-.js → proof-DYZWMWOC.mjs} +21 -33
- package/dist/{proof-BhFF_JVj.cjs → proof-DqCjiFwb.cjs} +133 -157
- package/dist/{proof-D5BQTIcU.js → proof-j-of9m5W.js} +33 -59
- 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-CE8h59oe.js → send-uLjD0uAe.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} +209 -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 +7 -7
- 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-BRMCYThi.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-BtT_mKsB.cjs +0 -12
- package/dist/middleware-CUMoHNCA.js +0 -12
- package/dist/middleware-CzeVJTA1.js +0 -27
- 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
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { deno_default, fetchKey, validateCryptoKey } from "./http-DhH623ma.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
import { _ as version, d as validateCryptoKey, g as name, s as fetchKey } from "./http-BLZWcpzg.js";
|
|
6
4
|
import { getLogger } from "@logtape/logtape";
|
|
7
5
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "@fedify/vocab";
|
|
8
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
7
|
import { encodeHex } from "byte-encodings/hex";
|
|
10
|
-
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
9
|
+
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
12
10
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
13
11
|
import serialize from "json-canon";
|
|
14
|
-
|
|
15
12
|
//#region src/sig/ld.ts
|
|
16
13
|
const logger$1 = getLogger([
|
|
17
14
|
"fedify",
|
|
@@ -53,11 +50,8 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
53
50
|
creator: keyId.href,
|
|
54
51
|
created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
55
52
|
};
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const message = optionsHash + docHash;
|
|
59
|
-
const encoder = new TextEncoder();
|
|
60
|
-
const messageBytes = encoder.encode(message);
|
|
53
|
+
const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
|
|
54
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
61
55
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
|
|
62
56
|
return {
|
|
63
57
|
...options,
|
|
@@ -79,9 +73,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
79
73
|
* @since 1.0.0
|
|
80
74
|
*/
|
|
81
75
|
async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
82
|
-
|
|
83
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
84
|
-
return await tracer.startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
76
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
85
77
|
try {
|
|
86
78
|
const signature = await createSignature(jsonLd, privateKey, keyId, options);
|
|
87
79
|
if (span.isRecording()) {
|
|
@@ -183,23 +175,21 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
183
175
|
const encoder = new TextEncoder();
|
|
184
176
|
const message = sigOptsHash + docHash;
|
|
185
177
|
const messageBytes = encoder.encode(message);
|
|
186
|
-
|
|
187
|
-
if (verified) return key;
|
|
178
|
+
if (await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes)) return key;
|
|
188
179
|
if (cached) {
|
|
189
180
|
logger$1.debug("Failed to verify with the cached key {keyId}; signature {signatureValue} is invalid. Retrying with the freshly fetched key...", {
|
|
190
181
|
keyId: sig.creator,
|
|
191
182
|
...sig
|
|
192
183
|
});
|
|
193
|
-
const { key
|
|
184
|
+
const { key } = await fetchKey(new URL(sig.creator), CryptographicKey, {
|
|
194
185
|
...options,
|
|
195
186
|
keyCache: {
|
|
196
187
|
get: () => Promise.resolve(void 0),
|
|
197
|
-
set: async (keyId, key
|
|
188
|
+
set: async (keyId, key) => await options.keyCache?.set(keyId, key)
|
|
198
189
|
}
|
|
199
190
|
});
|
|
200
|
-
if (key
|
|
201
|
-
|
|
202
|
-
return verified$1 ? key$1 : null;
|
|
191
|
+
if (key == null) return null;
|
|
192
|
+
return await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes) ? key : null;
|
|
203
193
|
}
|
|
204
194
|
logger$1.debug("Failed to verify with the fetched key {keyId}; signature {signatureValue} is invalid. Check if the key is correct or if the signed message is correct. The message to sign is:\n{message}", {
|
|
205
195
|
keyId: sig.creator,
|
|
@@ -218,9 +208,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
218
208
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
219
209
|
*/
|
|
220
210
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
221
|
-
|
|
222
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
223
|
-
return await tracer.startActiveSpan("ld_signatures.verify", async (span) => {
|
|
211
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
224
212
|
try {
|
|
225
213
|
const object = await Object$1.fromJsonLd(jsonLd, options);
|
|
226
214
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
@@ -261,10 +249,8 @@ async function hashJsonLd(jsonLd, contextLoader) {
|
|
|
261
249
|
documentLoader: contextLoader ?? getDocumentLoader()
|
|
262
250
|
});
|
|
263
251
|
const encoder = new TextEncoder();
|
|
264
|
-
|
|
265
|
-
return encodeHex(hash);
|
|
252
|
+
return encodeHex(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
|
|
266
253
|
}
|
|
267
|
-
|
|
268
254
|
//#endregion
|
|
269
255
|
//#region src/sig/owner.ts
|
|
270
256
|
/**
|
|
@@ -275,9 +261,7 @@ async function hashJsonLd(jsonLd, contextLoader) {
|
|
|
275
261
|
* @returns Whether the actor is the owner of the key.
|
|
276
262
|
*/
|
|
277
263
|
async function doesActorOwnKey(activity, key, options) {
|
|
278
|
-
|
|
279
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
280
|
-
return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
|
|
264
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
|
|
281
265
|
kind: SpanKind.INTERNAL,
|
|
282
266
|
attributes: {
|
|
283
267
|
"activitypub.actor.id": activity.actorId?.href ?? "",
|
|
@@ -358,9 +342,9 @@ async function getKeyOwner(keyId, options) {
|
|
|
358
342
|
contextLoader,
|
|
359
343
|
tracerProvider
|
|
360
344
|
});
|
|
361
|
-
} catch (e
|
|
362
|
-
if (e
|
|
363
|
-
throw e
|
|
345
|
+
} catch (e) {
|
|
346
|
+
if (e instanceof TypeError) return null;
|
|
347
|
+
throw e;
|
|
364
348
|
}
|
|
365
349
|
}
|
|
366
350
|
}
|
|
@@ -378,7 +362,6 @@ async function getKeyOwner(keyId, options) {
|
|
|
378
362
|
for (const kid of owner.publicKeyIds) if (kid.href === keyId.href) return owner;
|
|
379
363
|
return null;
|
|
380
364
|
}
|
|
381
|
-
|
|
382
365
|
//#endregion
|
|
383
366
|
//#region src/sig/proof.ts
|
|
384
367
|
const logger = getLogger([
|
|
@@ -396,29 +379,27 @@ const logger = getLogger([
|
|
|
396
379
|
* @throws {TypeError} If the private key is invalid or unsupported.
|
|
397
380
|
* @since 0.10.0
|
|
398
381
|
*/
|
|
399
|
-
async function createProof(object, privateKey, keyId, { contextLoader, context
|
|
382
|
+
async function createProof(object, privateKey, keyId, { contextLoader, context, created } = {}) {
|
|
400
383
|
validateCryptoKey(privateKey, "private");
|
|
401
384
|
if (privateKey.algorithm.name !== "Ed25519") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
|
|
402
|
-
const
|
|
403
|
-
const compactMsg = await objectWithoutProofs.toJsonLd({
|
|
385
|
+
const compactMsg = await object.clone({ proofs: [] }).toJsonLd({
|
|
404
386
|
format: "compact",
|
|
405
387
|
contextLoader,
|
|
406
|
-
context
|
|
388
|
+
context
|
|
407
389
|
});
|
|
408
390
|
const msgCanon = serialize(compactMsg);
|
|
409
391
|
const encoder = new TextEncoder();
|
|
410
392
|
const msgBytes = encoder.encode(msgCanon);
|
|
411
393
|
const msgDigest = await crypto.subtle.digest("SHA-256", msgBytes);
|
|
412
394
|
created ??= Temporal.Now.instant();
|
|
413
|
-
const
|
|
395
|
+
const proofCanon = serialize({
|
|
414
396
|
"@context": compactMsg["@context"],
|
|
415
397
|
type: "DataIntegrityProof",
|
|
416
398
|
cryptosuite: "eddsa-jcs-2022",
|
|
417
399
|
verificationMethod: keyId.href,
|
|
418
400
|
proofPurpose: "assertionMethod",
|
|
419
401
|
created: created.toString()
|
|
420
|
-
};
|
|
421
|
-
const proofCanon = serialize(proofConfig);
|
|
402
|
+
});
|
|
422
403
|
const proofBytes = encoder.encode(proofCanon);
|
|
423
404
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
424
405
|
const digest = new Uint8Array(proofDigest.byteLength + msgDigest.byteLength);
|
|
@@ -444,13 +425,11 @@ async function createProof(object, privateKey, keyId, { contextLoader, context:
|
|
|
444
425
|
* @since 0.10.0
|
|
445
426
|
*/
|
|
446
427
|
async function signObject(object, privateKey, keyId, options = {}) {
|
|
447
|
-
|
|
448
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
449
|
-
return await tracer.startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
|
|
428
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.sign", { attributes: { "activitypub.object.type": getTypeId(object).href } }, async (span) => {
|
|
450
429
|
try {
|
|
451
430
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
452
431
|
const existingProofs = [];
|
|
453
|
-
for await (const proof
|
|
432
|
+
for await (const proof of object.getProofs(options)) existingProofs.push(proof);
|
|
454
433
|
const proof = await createProof(object, privateKey, keyId, options);
|
|
455
434
|
if (span.isRecording()) {
|
|
456
435
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
@@ -480,9 +459,7 @@ async function signObject(object, privateKey, keyId, options = {}) {
|
|
|
480
459
|
* @since 0.10.0
|
|
481
460
|
*/
|
|
482
461
|
async function verifyProof(jsonLd, proof, options = {}) {
|
|
483
|
-
|
|
484
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
485
|
-
return await tracer.startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
462
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
|
|
486
463
|
if (span.isRecording()) {
|
|
487
464
|
if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
|
|
488
465
|
if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
|
|
@@ -506,15 +483,14 @@ async function verifyProof(jsonLd, proof, options = {}) {
|
|
|
506
483
|
async function verifyProofInternal(jsonLd, proof, options) {
|
|
507
484
|
if (typeof jsonLd !== "object" || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
|
|
508
485
|
const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
|
|
509
|
-
const
|
|
486
|
+
const proofCanon = serialize({
|
|
510
487
|
"@context": jsonLd["@context"],
|
|
511
488
|
type: "DataIntegrityProof",
|
|
512
489
|
cryptosuite: proof.cryptosuite,
|
|
513
490
|
verificationMethod: proof.verificationMethodId.href,
|
|
514
491
|
proofPurpose: proof.proofPurpose,
|
|
515
492
|
created: proof.created.toString()
|
|
516
|
-
};
|
|
517
|
-
const proofCanon = serialize(proofConfig);
|
|
493
|
+
});
|
|
518
494
|
const encoder = new TextEncoder();
|
|
519
495
|
const proofBytes = encoder.encode(proofCanon);
|
|
520
496
|
const proofDigest = await crypto.subtle.digest("SHA-256", proofBytes);
|
|
@@ -565,8 +541,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
565
541
|
});
|
|
566
542
|
return null;
|
|
567
543
|
}
|
|
568
|
-
|
|
569
|
-
if (!verified) {
|
|
544
|
+
if (!await crypto.subtle.verify("Ed25519", publicKey.publicKey, proof.proofValue.slice(), digest)) {
|
|
570
545
|
if (fetchedKey.cached) {
|
|
571
546
|
logger.debug("Failed to verify the proof with the cached key {keyId}; retrying with the freshly fetched key...", {
|
|
572
547
|
keyId: proof.verificationMethodId.href,
|
|
@@ -603,7 +578,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
|
|
|
603
578
|
* @since 0.10.0
|
|
604
579
|
*/
|
|
605
580
|
async function verifyObject(cls, jsonLd, options = {}) {
|
|
606
|
-
const logger
|
|
581
|
+
const logger = getLogger([
|
|
607
582
|
"fedify",
|
|
608
583
|
"sig",
|
|
609
584
|
"proof"
|
|
@@ -615,17 +590,16 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
615
590
|
const key = await verifyProof(jsonLd, proof, options);
|
|
616
591
|
if (key === null) return null;
|
|
617
592
|
if (key.controllerId == null) {
|
|
618
|
-
logger
|
|
593
|
+
logger.debug("Key {keyId} does not have a controller.", { keyId: key.id?.href });
|
|
619
594
|
continue;
|
|
620
595
|
}
|
|
621
596
|
attributions.delete(key.controllerId.href);
|
|
622
597
|
}
|
|
623
598
|
if (attributions.size > 0) {
|
|
624
|
-
logger
|
|
599
|
+
logger.debug("Some attributions are not authenticated by the proofs: {attributions}.", { attributions: [...attributions] });
|
|
625
600
|
return null;
|
|
626
601
|
}
|
|
627
602
|
return object;
|
|
628
603
|
}
|
|
629
|
-
|
|
630
604
|
//#endregion
|
|
631
|
-
export {
|
|
605
|
+
export { doesActorOwnKey as a, createSignature as c, signJsonLd as d, verifyJsonLd as f, verifyProof as i, detachSignature as l, signObject as n, getKeyOwner as o, verifySignature as p, verifyObject as r, attachSignature as s, createProof as t, hasSignature as u };
|
|
@@ -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 };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
6
4
|
import { cloneDeep } from "es-toolkit";
|
|
7
5
|
import { Router } from "uri-template-router";
|
|
8
6
|
import { parseTemplate } from "url-template";
|
|
9
|
-
|
|
10
7
|
//#region src/federation/router.ts
|
|
11
8
|
function cloneInnerRouter(router) {
|
|
12
9
|
const clone = new Router();
|
|
@@ -113,6 +110,5 @@ var RouterError = class extends Error {
|
|
|
113
110
|
this.name = "RouterError";
|
|
114
111
|
}
|
|
115
112
|
};
|
|
116
|
-
|
|
117
113
|
//#endregion
|
|
118
|
-
export { Router$1 as
|
|
114
|
+
export { RouterError as n, Router$1 as t };
|
package/dist/runtime/mod.cjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get: function () { return __fedify_vocab_runtime[k]; }
|
|
13
|
-
});
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
+
require("../chunk-DDcVe30Y.cjs");
|
|
4
|
+
var _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
5
|
+
Object.keys(_fedify_vocab_runtime).forEach(function(k) {
|
|
6
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _fedify_vocab_runtime[k];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
14
12
|
});
|
package/dist/runtime/mod.d.cts
CHANGED
package/dist/runtime/mod.d.ts
CHANGED
package/dist/runtime/mod.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "../runtime-poamPCMb.js";
|
|
6
|
-
|
|
7
|
-
export * from "@fedify/vocab-runtime"
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
import "../chunk-nlSIicah.js";
|
|
4
|
+
export * from "@fedify/vocab-runtime";
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { deno_default } from "./deno-BRMCYThi.js";
|
|
7
|
-
import { doubleKnock } from "./http-CKDim8Tw.js";
|
|
8
|
-
import { getLogger } from "@logtape/logtape";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as version, t as name } from "./deno-C5VMwnFV.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-BTLPIzFa.mjs";
|
|
9
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
|
-
|
|
7
|
+
import { getLogger } from "@logtape/logtape";
|
|
11
8
|
//#region src/federation/send.ts
|
|
12
9
|
/**
|
|
13
10
|
* Extracts the inbox URLs from recipients.
|
|
@@ -44,8 +41,7 @@ function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
|
|
|
44
41
|
*/
|
|
45
42
|
function sendActivity(options) {
|
|
46
43
|
const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
|
|
47
|
-
|
|
48
|
-
return tracer.startActiveSpan("activitypub.send_activity", {
|
|
44
|
+
return tracerProvider.getTracer(name, version).startActiveSpan("activitypub.send_activity", {
|
|
49
45
|
kind: SpanKind.CLIENT,
|
|
50
46
|
attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
|
|
51
47
|
}, async (span) => {
|
|
@@ -193,6 +189,5 @@ var SendActivityError = class extends Error {
|
|
|
193
189
|
this.responseBody = responseBody;
|
|
194
190
|
}
|
|
195
191
|
};
|
|
196
|
-
|
|
197
192
|
//#endregion
|
|
198
|
-
export {
|
|
193
|
+
export { extractInboxes as n, sendActivity as r, SendActivityError as t };
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { formatAcceptSignature, fulfillAcceptSignature, parseAcceptSignature, validateAcceptSignature } from "../accept-D7sAxyNa.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-Dd__NiUL.mjs";
|
|
7
5
|
import { test } from "@fedify/fixture";
|
|
8
6
|
import { deepStrictEqual, strictEqual } from "node:assert/strict";
|
|
9
|
-
|
|
10
7
|
//#region src/sig/accept.test.ts
|
|
11
8
|
test("parseAcceptSignature(): single entry", () => {
|
|
12
|
-
|
|
13
|
-
deepStrictEqual(result, [{
|
|
9
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"@method\" \"@target-uri\")"), [{
|
|
14
10
|
label: "sig1",
|
|
15
11
|
components: [{
|
|
16
12
|
value: "@method",
|
|
@@ -23,8 +19,7 @@ test("parseAcceptSignature(): single entry", () => {
|
|
|
23
19
|
}]);
|
|
24
20
|
});
|
|
25
21
|
test("parseAcceptSignature(): multiple entries", () => {
|
|
26
|
-
|
|
27
|
-
deepStrictEqual(result, [{
|
|
22
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"@method\"), sig2=(\"@authority\")"), [{
|
|
28
23
|
label: "sig1",
|
|
29
24
|
components: [{
|
|
30
25
|
value: "@method",
|
|
@@ -41,8 +36,7 @@ test("parseAcceptSignature(): multiple entries", () => {
|
|
|
41
36
|
}]);
|
|
42
37
|
});
|
|
43
38
|
test("parseAcceptSignature(): all six parameters", () => {
|
|
44
|
-
|
|
45
|
-
deepStrictEqual(result, [{
|
|
39
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"@method\");keyid=\"k1\";alg=\"rsa-v1_5-sha256\";created;expires;nonce=\"abc\";tag=\"t1\""), [{
|
|
46
40
|
label: "sig1",
|
|
47
41
|
components: [{
|
|
48
42
|
value: "@method",
|
|
@@ -59,8 +53,7 @@ test("parseAcceptSignature(): all six parameters", () => {
|
|
|
59
53
|
}]);
|
|
60
54
|
});
|
|
61
55
|
test("parseAcceptSignature(): preserves string component parameters", () => {
|
|
62
|
-
|
|
63
|
-
deepStrictEqual(result, [{
|
|
56
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"@query-param\";name=\"foo\" \"@method\")"), [{
|
|
64
57
|
label: "sig1",
|
|
65
58
|
components: [{
|
|
66
59
|
value: "@query-param",
|
|
@@ -73,8 +66,7 @@ test("parseAcceptSignature(): preserves string component parameters", () => {
|
|
|
73
66
|
}]);
|
|
74
67
|
});
|
|
75
68
|
test("parseAcceptSignature(): preserves boolean component parameters", () => {
|
|
76
|
-
|
|
77
|
-
deepStrictEqual(result, [{
|
|
69
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"content-type\";sf \"content-digest\";bs)"), [{
|
|
78
70
|
label: "sig1",
|
|
79
71
|
components: [{
|
|
80
72
|
value: "content-type",
|
|
@@ -87,8 +79,7 @@ test("parseAcceptSignature(): preserves boolean component parameters", () => {
|
|
|
87
79
|
}]);
|
|
88
80
|
});
|
|
89
81
|
test("parseAcceptSignature(): preserves multiple parameters on one component", () => {
|
|
90
|
-
|
|
91
|
-
deepStrictEqual(result, [{
|
|
82
|
+
deepStrictEqual(parseAcceptSignature("sig1=(\"@request-response\";key=\"sig1\";req)"), [{
|
|
92
83
|
label: "sig1",
|
|
93
84
|
components: [{
|
|
94
85
|
value: "@request-response",
|
|
@@ -123,9 +114,7 @@ test("formatAcceptSignature(): single entry with created", () => {
|
|
|
123
114
|
],
|
|
124
115
|
parameters: { created: true }
|
|
125
116
|
}];
|
|
126
|
-
|
|
127
|
-
const parsed = parseAcceptSignature(header);
|
|
128
|
-
deepStrictEqual(parsed, members);
|
|
117
|
+
deepStrictEqual(parseAcceptSignature(formatAcceptSignature(members)), members);
|
|
129
118
|
});
|
|
130
119
|
test("formatAcceptSignature(): created + nonce", () => {
|
|
131
120
|
const members = [{
|
|
@@ -139,9 +128,7 @@ test("formatAcceptSignature(): created + nonce", () => {
|
|
|
139
128
|
nonce: "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
|
|
140
129
|
}
|
|
141
130
|
}];
|
|
142
|
-
|
|
143
|
-
const parsed = parseAcceptSignature(header);
|
|
144
|
-
deepStrictEqual(parsed, members);
|
|
131
|
+
deepStrictEqual(parseAcceptSignature(formatAcceptSignature(members)), members);
|
|
145
132
|
});
|
|
146
133
|
test("formatAcceptSignature(): multiple entries", () => {
|
|
147
134
|
const members = [{
|
|
@@ -162,9 +149,7 @@ test("formatAcceptSignature(): multiple entries", () => {
|
|
|
162
149
|
}],
|
|
163
150
|
parameters: { tag: "app-123" }
|
|
164
151
|
}];
|
|
165
|
-
|
|
166
|
-
const parsed = parseAcceptSignature(header);
|
|
167
|
-
deepStrictEqual(parsed, members);
|
|
152
|
+
deepStrictEqual(parseAcceptSignature(formatAcceptSignature(members)), members);
|
|
168
153
|
});
|
|
169
154
|
test("formatAcceptSignature(): round-trip with all parameters", () => {
|
|
170
155
|
const input = [{
|
|
@@ -196,9 +181,7 @@ test("formatAcceptSignature(): round-trip with all parameters", () => {
|
|
|
196
181
|
tag: "app-123"
|
|
197
182
|
}
|
|
198
183
|
}];
|
|
199
|
-
|
|
200
|
-
const members = parseAcceptSignature(header);
|
|
201
|
-
deepStrictEqual(members, input);
|
|
184
|
+
deepStrictEqual(parseAcceptSignature(formatAcceptSignature(input)), input);
|
|
202
185
|
});
|
|
203
186
|
test("formatAcceptSignature(): round-trip with parameterized components", () => {
|
|
204
187
|
const input = [{
|
|
@@ -219,9 +202,7 @@ test("formatAcceptSignature(): round-trip with parameterized components", () =>
|
|
|
219
202
|
],
|
|
220
203
|
parameters: { created: true }
|
|
221
204
|
}];
|
|
222
|
-
|
|
223
|
-
const members = parseAcceptSignature(header);
|
|
224
|
-
deepStrictEqual(members, input);
|
|
205
|
+
deepStrictEqual(parseAcceptSignature(formatAcceptSignature(input)), input);
|
|
225
206
|
});
|
|
226
207
|
test("validateAcceptSignature(): filters out @status", () => {
|
|
227
208
|
const valid = {
|
|
@@ -246,12 +227,9 @@ test("validateAcceptSignature(): filters out @status", () => {
|
|
|
246
227
|
}],
|
|
247
228
|
parameters: {}
|
|
248
229
|
};
|
|
249
|
-
|
|
250
|
-
deepStrictEqual(validateAcceptSignature(
|
|
251
|
-
|
|
252
|
-
deepStrictEqual(validateAcceptSignature(invalidOnly), []);
|
|
253
|
-
const mixed = [valid, invalid];
|
|
254
|
-
deepStrictEqual(validateAcceptSignature(mixed), [valid]);
|
|
230
|
+
deepStrictEqual(validateAcceptSignature([valid]), [valid]);
|
|
231
|
+
deepStrictEqual(validateAcceptSignature([invalid]), []);
|
|
232
|
+
deepStrictEqual(validateAcceptSignature([valid, invalid]), [valid]);
|
|
255
233
|
});
|
|
256
234
|
test("validateAcceptSignature(): passes entries with parameterized components", () => {
|
|
257
235
|
const members = [{
|
|
@@ -268,7 +246,7 @@ test("validateAcceptSignature(): passes entries with parameterized components",
|
|
|
268
246
|
deepStrictEqual(validateAcceptSignature(members), members);
|
|
269
247
|
});
|
|
270
248
|
test("fulfillAcceptSignature(): compatible alg and keyid", () => {
|
|
271
|
-
|
|
249
|
+
deepStrictEqual(fulfillAcceptSignature({
|
|
272
250
|
label: "sig1",
|
|
273
251
|
components: [
|
|
274
252
|
{
|
|
@@ -290,9 +268,7 @@ test("fulfillAcceptSignature(): compatible alg and keyid", () => {
|
|
|
290
268
|
nonce: "abc",
|
|
291
269
|
tag: "t1"
|
|
292
270
|
}
|
|
293
|
-
}
|
|
294
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
295
|
-
deepStrictEqual(result, {
|
|
271
|
+
}, "https://example.com/key", "rsa-v1_5-sha256"), {
|
|
296
272
|
label: "sig1",
|
|
297
273
|
components: [
|
|
298
274
|
{
|
|
@@ -314,46 +290,40 @@ test("fulfillAcceptSignature(): compatible alg and keyid", () => {
|
|
|
314
290
|
});
|
|
315
291
|
});
|
|
316
292
|
test("fulfillAcceptSignature(): incompatible alg", () => {
|
|
317
|
-
|
|
293
|
+
strictEqual(fulfillAcceptSignature({
|
|
318
294
|
label: "sig1",
|
|
319
295
|
components: [{
|
|
320
296
|
value: "@method",
|
|
321
297
|
params: {}
|
|
322
298
|
}],
|
|
323
299
|
parameters: { alg: "ecdsa-p256-sha256" }
|
|
324
|
-
};
|
|
325
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
326
|
-
strictEqual(result, null);
|
|
300
|
+
}, "https://example.com/key", "rsa-v1_5-sha256"), null);
|
|
327
301
|
});
|
|
328
302
|
test("fulfillAcceptSignature(): incompatible keyid", () => {
|
|
329
|
-
|
|
303
|
+
strictEqual(fulfillAcceptSignature({
|
|
330
304
|
label: "sig1",
|
|
331
305
|
components: [{
|
|
332
306
|
value: "@method",
|
|
333
307
|
params: {}
|
|
334
308
|
}],
|
|
335
309
|
parameters: { keyid: "https://other.example/key" }
|
|
336
|
-
};
|
|
337
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
338
|
-
strictEqual(result, null);
|
|
310
|
+
}, "https://example.com/key", "rsa-v1_5-sha256"), null);
|
|
339
311
|
});
|
|
340
312
|
test("fulfillAcceptSignature(): components returned exactly as requested", () => {
|
|
341
|
-
|
|
313
|
+
deepStrictEqual(fulfillAcceptSignature({
|
|
342
314
|
label: "sig1",
|
|
343
315
|
components: [{
|
|
344
316
|
value: "content-digest",
|
|
345
317
|
params: {}
|
|
346
318
|
}],
|
|
347
319
|
parameters: {}
|
|
348
|
-
}
|
|
349
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
350
|
-
deepStrictEqual(result.components, [{
|
|
320
|
+
}, "https://example.com/key", "rsa-v1_5-sha256").components, [{
|
|
351
321
|
value: "content-digest",
|
|
352
322
|
params: {}
|
|
353
323
|
}]);
|
|
354
324
|
});
|
|
355
325
|
test("fulfillAcceptSignature(): no alg/keyid constraints", () => {
|
|
356
|
-
|
|
326
|
+
deepStrictEqual(fulfillAcceptSignature({
|
|
357
327
|
label: "custom",
|
|
358
328
|
components: [
|
|
359
329
|
{
|
|
@@ -370,9 +340,7 @@ test("fulfillAcceptSignature(): no alg/keyid constraints", () => {
|
|
|
370
340
|
}
|
|
371
341
|
],
|
|
372
342
|
parameters: {}
|
|
373
|
-
}
|
|
374
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
375
|
-
deepStrictEqual(result, {
|
|
343
|
+
}, "https://example.com/key", "rsa-v1_5-sha256"), {
|
|
376
344
|
label: "custom",
|
|
377
345
|
components: [
|
|
378
346
|
{
|
|
@@ -394,7 +362,7 @@ test("fulfillAcceptSignature(): no alg/keyid constraints", () => {
|
|
|
394
362
|
});
|
|
395
363
|
});
|
|
396
364
|
test("fulfillAcceptSignature(): passes through expires when requested", () => {
|
|
397
|
-
const
|
|
365
|
+
const result = fulfillAcceptSignature({
|
|
398
366
|
label: "sig1",
|
|
399
367
|
components: [
|
|
400
368
|
{
|
|
@@ -411,13 +379,12 @@ test("fulfillAcceptSignature(): passes through expires when requested", () => {
|
|
|
411
379
|
}
|
|
412
380
|
],
|
|
413
381
|
parameters: { expires: true }
|
|
414
|
-
};
|
|
415
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
382
|
+
}, "https://example.com/key", "rsa-v1_5-sha256");
|
|
416
383
|
strictEqual(result != null, true);
|
|
417
384
|
strictEqual(result.expires, true);
|
|
418
385
|
});
|
|
419
386
|
test("fulfillAcceptSignature(): preserves component parameters in result", () => {
|
|
420
|
-
const
|
|
387
|
+
const result = fulfillAcceptSignature({
|
|
421
388
|
label: "sig1",
|
|
422
389
|
components: [
|
|
423
390
|
{
|
|
@@ -438,14 +405,12 @@ test("fulfillAcceptSignature(): preserves component parameters in result", () =>
|
|
|
438
405
|
}
|
|
439
406
|
],
|
|
440
407
|
parameters: {}
|
|
441
|
-
};
|
|
442
|
-
const result = fulfillAcceptSignature(entry, "https://example.com/key", "rsa-v1_5-sha256");
|
|
408
|
+
}, "https://example.com/key", "rsa-v1_5-sha256");
|
|
443
409
|
strictEqual(result != null, true);
|
|
444
|
-
|
|
445
|
-
deepStrictEqual(qp, {
|
|
410
|
+
deepStrictEqual(result.components.find((c) => c.value === "@query-param"), {
|
|
446
411
|
value: "@query-param",
|
|
447
412
|
params: { name: "foo" }
|
|
448
413
|
});
|
|
449
414
|
});
|
|
450
|
-
|
|
451
|
-
|
|
415
|
+
//#endregion
|
|
416
|
+
export {};
|