@fedify/fedify 2.3.0-dev.1110 → 2.3.0-dev.1119
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/{assert_rejects-B-qJtC9Z.mjs → assert_rejects-DQP-q39h.mjs} +27 -2
- package/dist/{builder-B-Y6fwSu.mjs → builder-Ond_h57y.mjs} +3 -3
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +1 -1
- package/dist/compat/public-audience.test.mjs +1 -1
- package/dist/compat/transformers.test.mjs +2 -2
- package/dist/{context-C0C_sRha.d.cts → context-Ch-ZLyTQ.d.cts} +1 -1
- package/dist/{context-Dqgt8saU.d.ts → context-cSUMk2da.d.ts} +1 -1
- package/dist/{deno-hqC7tKJn.mjs → deno-DVsHS7rA.mjs} +1 -1
- package/dist/{docloader-BOEuuXkX.mjs → docloader-WsWfKaE5.mjs} +2 -2
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +2 -2
- package/dist/federation/handler.test.mjs +8 -7
- package/dist/federation/idempotency.test.mjs +5 -5
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/keycache.test.mjs +1 -1
- package/dist/federation/kv.test.mjs +2 -2
- package/dist/federation/metrics.test.d.mts +2 -0
- package/dist/federation/metrics.test.mjs +107 -0
- package/dist/federation/middleware.test.mjs +390 -10
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +2 -2
- package/dist/federation/negotiation.test.mjs +2 -2
- package/dist/federation/router.test.mjs +2 -2
- package/dist/federation/send.test.mjs +11 -11
- package/dist/federation/webfinger.test.mjs +3 -3
- package/dist/{getMachineId-bsd-etIyxDet.mjs → getMachineId-bsd-BY01PL1n.mjs} +1 -1
- package/dist/{getMachineId-darwin-D23zTf4g.mjs → getMachineId-darwin-Dr1gkBkp.mjs} +1 -1
- package/dist/{getMachineId-win-Dpap6v5i.mjs → getMachineId-win-QEYwcJiy.mjs} +1 -1
- package/dist/{http-O8MYWwk8.js → http-CouJSFVK.js} +461 -37
- package/dist/{http-DV0il3vk.cjs → http-CubOB9wq.cjs} +513 -35
- package/dist/{http-BDZeS5om.d.ts → http-D6LP89UO.d.ts} +7 -1
- package/dist/{http-C87EWkO0.d.cts → http-D6aw3j2U.d.cts} +7 -1
- package/dist/{http-BLopFpvC.mjs → http-DUV8ysti.mjs} +86 -37
- package/dist/{key-DW1EVmtP.mjs → key-BoWaYRHm.mjs} +1 -1
- package/dist/{kv-cache-C3NWWiTg.js → kv-cache-DBNpsneh.js} +1 -1
- package/dist/{kv-cache-Dya-TWMe.cjs → kv-cache-Dz31ATUT.cjs} +1 -1
- package/dist/{ld-BNkk2Yal.mjs → ld-B5K1mSuG.mjs} +60 -9
- package/dist/{send-hokVCPu6.mjs → metrics-C4attqv0.mjs} +124 -224
- package/dist/{middleware-D6FbOjuK.mjs → middleware-BDKFRjue.mjs} +1 -1
- package/dist/{middleware-DUWeXjZR.cjs → middleware-CmsDtIHI.cjs} +75 -309
- package/dist/{middleware-CjzI3aYo.js → middleware-Dtjz-hSk.js} +46 -280
- package/dist/{middleware-DA2WTBr4.mjs → middleware-t0jC8I99.mjs} +59 -34
- package/dist/{mod-DXY9JF28.d.cts → mod-B-Lin9Sy.d.ts} +25 -2
- package/dist/{mod-DHO9lk3D.d.ts → mod-BDhgfjP7.d.cts} +25 -2
- package/dist/{mod-B0rWmfW5.d.cts → mod-BR_BB0bh.d.cts} +1 -1
- package/dist/{mod-Dx3-hqyo.d.ts → mod-C6E8rkcz.d.ts} +1 -1
- package/dist/{mod-BhU_H1I_.d.ts → mod-DLrRb0dx.d.ts} +1 -1
- package/dist/{mod-CLPnQPsv.d.cts → mod-P9tE2WmM.d.cts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +2 -2
- package/dist/nodeinfo/handler.test.mjs +3 -3
- package/dist/nodeinfo/types.test.mjs +2 -2
- package/dist/otel/exporter.test.mjs +2 -2
- package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-BNL8AC14.mjs} +1 -1
- package/dist/{owner-jvJAtR5O.mjs → owner-hDxI0ufu.mjs} +2 -2
- package/dist/{proof-BD92WeqV.cjs → proof-BUWfVr6Q.cjs} +78 -11
- package/dist/{proof-mfmHH9j0.mjs → proof-DhVuz4bc.mjs} +25 -7
- package/dist/{proof-5kT7OUPV.js → proof-n60t8o9P.js} +78 -11
- package/dist/send-BPhyR5Oo.mjs +225 -0
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +212 -6
- package/dist/sig/key.test.mjs +4 -4
- package/dist/sig/ld.test.mjs +138 -5
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +4 -4
- package/dist/sig/proof.test.mjs +167 -6
- package/dist/{std__assert-CRDpx_HF.mjs → std__assert-BTEgfoJo.mjs} +2 -27
- package/dist/utils/docloader.test.mjs +5 -5
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
- /package/dist/{accept-CceiKpCy.mjs → accept-CgDcxvjV.mjs} +0 -0
- /package/dist/{activity-listener-tztVvlNb.mjs → activity-listener-BeTGV3wc.mjs} +0 -0
- /package/dist/{client-B_A6mfn3.mjs → client-Bneh_DYR.mjs} +0 -0
- /package/dist/{collection-CA3V5zyK.mjs → collection-Cc3DVAhE.mjs} +0 -0
- /package/dist/{execAsync-DCBrgFiV.mjs → execAsync-Dxb7rNf3.mjs} +0 -0
- /package/dist/{getMachineId-linux-ObI47Hql.mjs → getMachineId-linux-Bbhofx-s.mjs} +0 -0
- /package/dist/{getMachineId-unsupported-Ddu-PFeh.mjs → getMachineId-unsupported-dIOte2Ct.mjs} +0 -0
- /package/dist/{keys-C3kae-6B.mjs → keys-CSYsOMFG.mjs} +0 -0
- /package/dist/{kv-x2IvBUyq.mjs → kv-QHE0oeM3.mjs} +0 -0
- /package/dist/{kv-cache-CiiNwT6W.mjs → kv-cache-DihufyAQ.mjs} +0 -0
- /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-c9zmYKgA.mjs} +0 -0
- /package/dist/{types-BFowWFTT.mjs → types-D09GN0uZ.mjs} +0 -0
package/dist/sig/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-
|
|
2
|
+
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-D6LP89UO.js";
|
|
3
3
|
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-CnngXDNJ.js";
|
|
4
|
-
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-
|
|
4
|
+
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-B-Lin9Sy.js";
|
|
5
5
|
export { AcceptSignatureMember, AcceptSignatureParameters, CreateProofOptions, CreateSignatureOptions, DoesActorOwnKeyOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, GetKeyOwnerOptions, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
|
package/dist/sig/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import {
|
|
4
|
-
import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "../proof-
|
|
3
|
+
import { C as parseAcceptSignature, S as fulfillAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk, w as validateAcceptSignature, x as formatAcceptSignature } from "../http-CouJSFVK.js";
|
|
4
|
+
import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "../proof-n60t8o9P.js";
|
|
5
5
|
export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
|
package/dist/sig/owner.test.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import {
|
|
5
|
+
import "../std__assert-BTEgfoJo.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_rejects-DQP-q39h.mjs";
|
|
7
7
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
8
|
-
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
8
|
+
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-hDxI0ufu.mjs";
|
|
10
10
|
import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
|
|
11
11
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/sig/owner.test.ts
|
package/dist/sig/proof.test.mjs
CHANGED
|
@@ -2,15 +2,15 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { n as assertFalse, t as assertRejects } from "../assert_rejects-
|
|
5
|
+
import "../std__assert-BTEgfoJo.mjs";
|
|
6
|
+
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DQP-q39h.mjs";
|
|
7
7
|
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
8
8
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
9
|
-
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-
|
|
10
|
-
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-
|
|
11
|
-
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-
|
|
9
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
10
|
+
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-BNL8AC14.mjs";
|
|
11
|
+
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-DhVuz4bc.mjs";
|
|
12
12
|
import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
|
|
13
|
-
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
|
+
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
15
15
|
import { decodeHex } from "byte-encodings/hex";
|
|
16
16
|
//#region src/sig/proof.test.ts
|
|
@@ -326,6 +326,167 @@ test("verifyProof()", async () => {
|
|
|
326
326
|
}), null);
|
|
327
327
|
assertFalse(contextLoaderCalls.includes("https://attacker.example/ctx"));
|
|
328
328
|
});
|
|
329
|
+
test("verifyProof() records verification duration metric", async (t) => {
|
|
330
|
+
const jsonLd = {
|
|
331
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
|
|
332
|
+
id: "https://server.example/activities/1",
|
|
333
|
+
type: "Create",
|
|
334
|
+
actor: "https://server.example/users/alice",
|
|
335
|
+
object: {
|
|
336
|
+
id: "https://server.example/objects/1",
|
|
337
|
+
type: "Note",
|
|
338
|
+
attributedTo: "https://server.example/users/alice",
|
|
339
|
+
content: "Hello world",
|
|
340
|
+
location: {
|
|
341
|
+
type: "Place",
|
|
342
|
+
longitude: -71.184902,
|
|
343
|
+
latitude: 25.273962
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const proof = new DataIntegrityProof({
|
|
348
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
349
|
+
verificationMethod: new URL("https://server.example/users/alice#ed25519-key"),
|
|
350
|
+
proofPurpose: "assertionMethod",
|
|
351
|
+
proofValue: decodeMultibase("zLaewdp4H9kqtwyrLatK4cjY5oRHwVcw4gibPSUDYDMhi4M49v8pcYk3ZB6D69dNpAPbUmY8ocuJ3m9KhKJEEg7z"),
|
|
352
|
+
created: Temporal.Instant.from("2023-02-24T23:36:38Z")
|
|
353
|
+
});
|
|
354
|
+
await t.step("verified path records result=verified with bounded cryptosuite", async () => {
|
|
355
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
356
|
+
assert(await verifyProof(jsonLd, proof, {
|
|
357
|
+
documentLoader: mockDocumentLoader,
|
|
358
|
+
contextLoader: mockDocumentLoader,
|
|
359
|
+
meterProvider
|
|
360
|
+
}) != null);
|
|
361
|
+
const measurements = recorder.getMeasurements("activitypub.signature.verification.duration");
|
|
362
|
+
assertEquals(measurements.length, 1);
|
|
363
|
+
const m = measurements[0];
|
|
364
|
+
assertEquals(m.type, "histogram");
|
|
365
|
+
assertGreaterOrEqual(m.value, 0);
|
|
366
|
+
assertEquals(m.attributes["activitypub.signature.kind"], "object_integrity");
|
|
367
|
+
assertEquals(m.attributes["activitypub.signature.result"], "verified");
|
|
368
|
+
assertEquals(m.attributes["object_integrity_proofs.cryptosuite"], "eddsa-jcs-2022");
|
|
369
|
+
});
|
|
370
|
+
await t.step("rejected path records result=rejected", async () => {
|
|
371
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
372
|
+
assertEquals(await verifyProof({
|
|
373
|
+
...jsonLd,
|
|
374
|
+
object: {
|
|
375
|
+
...jsonLd.object,
|
|
376
|
+
content: "bye"
|
|
377
|
+
}
|
|
378
|
+
}, proof, {
|
|
379
|
+
documentLoader: mockDocumentLoader,
|
|
380
|
+
contextLoader: mockDocumentLoader,
|
|
381
|
+
meterProvider
|
|
382
|
+
}), null);
|
|
383
|
+
const measurements = recorder.getMeasurements("activitypub.signature.verification.duration");
|
|
384
|
+
assertEquals(measurements.length, 1);
|
|
385
|
+
assertEquals(measurements[0].attributes["activitypub.signature.result"], "rejected");
|
|
386
|
+
assertEquals(measurements[0].attributes["object_integrity_proofs.cryptosuite"], "eddsa-jcs-2022");
|
|
387
|
+
});
|
|
388
|
+
await t.step("cached-key retry emits one measurement, not two", async () => {
|
|
389
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
390
|
+
const cache = { ["https://server.example/users/alice#ed25519-key"]: ed25519Multikey };
|
|
391
|
+
assert(await verifyProof(jsonLd, proof, {
|
|
392
|
+
documentLoader: mockDocumentLoader,
|
|
393
|
+
contextLoader: mockDocumentLoader,
|
|
394
|
+
meterProvider,
|
|
395
|
+
keyCache: {
|
|
396
|
+
get(id) {
|
|
397
|
+
return Promise.resolve(cache[id.href]);
|
|
398
|
+
},
|
|
399
|
+
set(id, k) {
|
|
400
|
+
cache[id.href] = k;
|
|
401
|
+
return Promise.resolve();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}) != null);
|
|
405
|
+
assertEquals(recorder.getMeasurements("activitypub.signature.verification.duration").length, 1);
|
|
406
|
+
const keyFetches = recorder.getMeasurements("activitypub.signature.key_fetch.duration");
|
|
407
|
+
assertEquals(keyFetches.length, 2);
|
|
408
|
+
assertEquals(keyFetches[0].attributes["activitypub.signature.key_fetch.result"], "hit");
|
|
409
|
+
assertEquals(keyFetches[1].attributes["activitypub.signature.key_fetch.result"], "fetched");
|
|
410
|
+
});
|
|
411
|
+
await t.step("key fetch records result=fetched on a cold cache", async () => {
|
|
412
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
413
|
+
assert(await verifyProof(jsonLd, proof, {
|
|
414
|
+
documentLoader: mockDocumentLoader,
|
|
415
|
+
contextLoader: mockDocumentLoader,
|
|
416
|
+
meterProvider
|
|
417
|
+
}) != null);
|
|
418
|
+
const measurements = recorder.getMeasurements("activitypub.signature.key_fetch.duration");
|
|
419
|
+
assertEquals(measurements.length, 1);
|
|
420
|
+
assertGreaterOrEqual(measurements[0].value, 0);
|
|
421
|
+
assertEquals(measurements[0].attributes["activitypub.signature.kind"], "object_integrity");
|
|
422
|
+
assertEquals(measurements[0].attributes["activitypub.signature.key_fetch.result"], "fetched");
|
|
423
|
+
});
|
|
424
|
+
await t.step("key fetch records result=hit when served from the key cache", async () => {
|
|
425
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
426
|
+
const cache = { "https://server.example/users/alice#ed25519-key": new Multikey({
|
|
427
|
+
id: new URL("https://server.example/users/alice#ed25519-key"),
|
|
428
|
+
controller: new URL("https://server.example/users/alice"),
|
|
429
|
+
publicKey: await importMultibaseKey("z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2")
|
|
430
|
+
}) };
|
|
431
|
+
assert(await verifyProof(jsonLd, proof, {
|
|
432
|
+
documentLoader: mockDocumentLoader,
|
|
433
|
+
contextLoader: mockDocumentLoader,
|
|
434
|
+
meterProvider,
|
|
435
|
+
keyCache: {
|
|
436
|
+
get(id) {
|
|
437
|
+
return Promise.resolve(cache[id.href]);
|
|
438
|
+
},
|
|
439
|
+
set(id, k) {
|
|
440
|
+
cache[id.href] = k;
|
|
441
|
+
return Promise.resolve();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}) != null);
|
|
445
|
+
const measurements = recorder.getMeasurements("activitypub.signature.key_fetch.duration");
|
|
446
|
+
assertEquals(measurements.length, 1);
|
|
447
|
+
assertEquals(measurements[0].attributes["activitypub.signature.key_fetch.result"], "hit");
|
|
448
|
+
});
|
|
449
|
+
await t.step("verifyObject() wrapper emits one measurement per inner verifyProof()", async () => {
|
|
450
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
451
|
+
assert(await verifyObject(Create, {
|
|
452
|
+
...jsonLd,
|
|
453
|
+
proof: await proof.toJsonLd({
|
|
454
|
+
format: "compact",
|
|
455
|
+
contextLoader: mockDocumentLoader
|
|
456
|
+
})
|
|
457
|
+
}, {
|
|
458
|
+
documentLoader: mockDocumentLoader,
|
|
459
|
+
contextLoader: mockDocumentLoader,
|
|
460
|
+
meterProvider
|
|
461
|
+
}) != null);
|
|
462
|
+
assertEquals(recorder.getMeasurements("activitypub.signature.verification.duration").length, 1);
|
|
463
|
+
});
|
|
464
|
+
await t.step("unknown cryptosuite omits the cryptosuite metric attribute", async () => {
|
|
465
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
466
|
+
const exoticProof = await DataIntegrityProof.fromJsonLd({
|
|
467
|
+
"@context": "https://w3id.org/security/data-integrity/v1",
|
|
468
|
+
type: "DataIntegrityProof",
|
|
469
|
+
cryptosuite: "made-up-suite-9999",
|
|
470
|
+
verificationMethod: "https://server.example/users/alice#ed25519-key",
|
|
471
|
+
proofPurpose: "assertionMethod",
|
|
472
|
+
proofValue: "zLaewdp4H9kqtwyrLatK4cjY5oRHwVcw4gibPSUDYDMhi4M49v8pcYk3ZB6D69dNpAPbUmY8ocuJ3m9KhKJEEg7z",
|
|
473
|
+
created: "2023-02-24T23:36:38Z"
|
|
474
|
+
}, {
|
|
475
|
+
documentLoader: mockDocumentLoader,
|
|
476
|
+
contextLoader: mockDocumentLoader
|
|
477
|
+
});
|
|
478
|
+
assertEquals(exoticProof.cryptosuite, "made-up-suite-9999");
|
|
479
|
+
assertEquals(await verifyProof(jsonLd, exoticProof, {
|
|
480
|
+
documentLoader: mockDocumentLoader,
|
|
481
|
+
contextLoader: mockDocumentLoader,
|
|
482
|
+
meterProvider
|
|
483
|
+
}), null);
|
|
484
|
+
const measurements = recorder.getMeasurements("activitypub.signature.verification.duration");
|
|
485
|
+
assertEquals(measurements.length, 1);
|
|
486
|
+
assertEquals(measurements[0].attributes["activitypub.signature.result"], "rejected");
|
|
487
|
+
assertFalse("object_integrity_proofs.cryptosuite" in measurements[0].attributes);
|
|
488
|
+
});
|
|
489
|
+
});
|
|
329
490
|
test("verifyObject()", async () => {
|
|
330
491
|
const options = {
|
|
331
492
|
documentLoader: mockDocumentLoader,
|
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { l as AssertionError, s as format } from "./assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "./assert_rejects-
|
|
5
|
+
import "./assert_rejects-DQP-q39h.mjs";
|
|
6
6
|
import "./assert_throws-4NwKEy2q.mjs";
|
|
7
7
|
import "./assert_strict_equals-Dmjbg-bA.mjs";
|
|
8
8
|
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_exists.js
|
|
@@ -28,31 +28,6 @@ import "./assert_strict_equals-Dmjbg-bA.mjs";
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_greater_or_equal.js
|
|
32
|
-
/**
|
|
33
|
-
* Make an assertion that `actual` is greater than or equal to `expected`.
|
|
34
|
-
* If not then throw.
|
|
35
|
-
*
|
|
36
|
-
* @example Usage
|
|
37
|
-
* ```ts no-eval
|
|
38
|
-
* import { assertGreaterOrEqual } from "@std/assert/assert-greater-or-equal";
|
|
39
|
-
*
|
|
40
|
-
* assertGreaterOrEqual(2, 1); // Doesn't throw
|
|
41
|
-
* assertGreaterOrEqual(1, 1); // Doesn't throw
|
|
42
|
-
* assertGreaterOrEqual(0, 1); // Throws
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @typeParam T The type of the values to compare.
|
|
46
|
-
* @param actual The actual value to compare.
|
|
47
|
-
* @param expected The expected value to compare.
|
|
48
|
-
* @param msg The optional message to display if the assertion fails.
|
|
49
|
-
*/ function assertGreaterOrEqual(actual, expected, msg) {
|
|
50
|
-
if (actual >= expected) return;
|
|
51
|
-
const actualString = format(actual);
|
|
52
|
-
const expectedString = format(expected);
|
|
53
|
-
throw new AssertionError(msg ?? `Expect ${actualString} >= ${expectedString}`);
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
31
|
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_greater.js
|
|
57
32
|
/**
|
|
58
33
|
* Make an assertion that `actual` is greater than `expected`.
|
|
@@ -101,4 +76,4 @@ import "./assert_strict_equals-Dmjbg-bA.mjs";
|
|
|
101
76
|
}
|
|
102
77
|
}
|
|
103
78
|
//#endregion
|
|
104
|
-
export {
|
|
79
|
+
export { assertGreater as n, assertExists as r, assertStringIncludes as t };
|
|
@@ -2,12 +2,12 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assertRejects } from "../assert_rejects-
|
|
5
|
+
import "../std__assert-BTEgfoJo.mjs";
|
|
6
|
+
import { t as assertRejects } from "../assert_rejects-DQP-q39h.mjs";
|
|
7
7
|
import { t as esm_default } from "../esm-sdtqOUPu.mjs";
|
|
8
|
-
import { l as verifyRequest } from "../http-
|
|
9
|
-
import { i as rsaPrivateKey2 } from "../keys-
|
|
10
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
8
|
+
import { l as verifyRequest } from "../http-DUV8ysti.mjs";
|
|
9
|
+
import { i as rsaPrivateKey2 } from "../keys-CSYsOMFG.mjs";
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-WsWfKaE5.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { UrlError } from "@fedify/vocab-runtime";
|
|
13
13
|
//#region src/utils/docloader.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as kvCache, t as MockKvStore } from "../kv-cache-
|
|
4
|
+
import { n as kvCache, t as MockKvStore } from "../kv-cache-DihufyAQ.mjs";
|
|
5
5
|
import { deepStrictEqual, throws } from "node:assert";
|
|
6
6
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
7
7
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
package/dist/utils/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_kv_cache = require("../kv-cache-
|
|
4
|
+
const require_kv_cache = require("../kv-cache-Dz31ATUT.cjs");
|
|
5
5
|
exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
|
|
6
6
|
exports.kvCache = require_kv_cache.kvCache;
|
package/dist/utils/mod.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-
|
|
2
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-BR_BB0bh.cjs";
|
|
3
3
|
export { getAuthenticatedDocumentLoader, kvCache };
|
package/dist/utils/mod.d.ts
CHANGED
package/dist/utils/mod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-
|
|
3
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-DBNpsneh.js";
|
|
4
4
|
export { getAuthenticatedDocumentLoader, kvCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/fedify",
|
|
3
|
-
"version": "2.3.0-dev.
|
|
3
|
+
"version": "2.3.0-dev.1119+6cc02662",
|
|
4
4
|
"description": "An ActivityPub server framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ActivityPub",
|
|
@@ -153,9 +153,9 @@
|
|
|
153
153
|
"uri-template-router": "^1.0.0",
|
|
154
154
|
"url-template": "^3.1.1",
|
|
155
155
|
"urlpattern-polyfill": "^10.1.0",
|
|
156
|
-
"@fedify/vocab": "2.3.0-dev.
|
|
157
|
-
"@fedify/vocab-runtime": "2.3.0-dev.
|
|
158
|
-
"@fedify/webfinger": "2.3.0-dev.
|
|
156
|
+
"@fedify/vocab": "2.3.0-dev.1119+6cc02662",
|
|
157
|
+
"@fedify/vocab-runtime": "2.3.0-dev.1119+6cc02662",
|
|
158
|
+
"@fedify/webfinger": "2.3.0-dev.1119+6cc02662"
|
|
159
159
|
},
|
|
160
160
|
"devDependencies": {
|
|
161
161
|
"@opentelemetry/sdk-metrics": "2.7.1",
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"typescript": "^6.0.0",
|
|
170
170
|
"wrangler": "^4.17.0",
|
|
171
171
|
"@fedify/fixture": "2.0.0",
|
|
172
|
-
"@fedify/vocab-tools": "^2.3.0-dev.
|
|
172
|
+
"@fedify/vocab-tools": "^2.3.0-dev.1119+6cc02662"
|
|
173
173
|
},
|
|
174
174
|
"scripts": {
|
|
175
175
|
"build:self": "tsdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{getMachineId-unsupported-Ddu-PFeh.mjs → getMachineId-unsupported-dIOte2Ct.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|