@fedify/fedify 2.4.0-dev.1570 → 2.4.0-dev.1571
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/README.md +0 -4
- package/dist/{builder-CJnWbgbj.mjs → builder-CBgmNPaS.mjs} +2 -2
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-klNxGW7W.mjs → deno-ColSXZB4.mjs} +1 -1
- package/dist/{docloader-CuFH35j1.mjs → docloader-BQGU0tG-.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +13 -3
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +7 -7
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/tasks/enqueue.test.mjs +1 -1
- package/dist/federation/tasks/tasks.test.mjs +2 -2
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-D0jH0kco.js → http-BciNZ5qO.js} +77 -11
- package/dist/{http-DeuPW1Oh.cjs → http-Be6MS-3k.cjs} +75 -9
- package/dist/{http-JdRPUYku.mjs → http-CuG4iKEH.mjs} +3 -3
- package/dist/{key-o0_ipvUR.mjs → key-C5fRM_21.mjs} +76 -10
- package/dist/{kv-cache-DSWq2JHU.js → kv-cache-6cpvv2tC.js} +1 -1
- package/dist/{kv-cache-CM7w20U5.mjs → kv-cache-Bn_DvESZ.mjs} +1 -1
- package/dist/{kv-cache-C3rqzQvu.cjs → kv-cache-C51pYkUU.cjs} +1 -1
- package/dist/{ld-C__CEgQH.mjs → ld-DxtnUVwj.mjs} +3 -3
- package/dist/{metrics-CLSPm4dZ.mjs → metrics-C60MEuIn.mjs} +3 -3
- package/dist/{middleware-CdMiavoh.mjs → middleware-B9bNYUM5.mjs} +1 -1
- package/dist/{middleware-B502nwxx.cjs → middleware-Cp410Lku.cjs} +3 -3
- package/dist/{middleware-zuLSkPIk.js → middleware-DY9SToNd.js} +3 -3
- package/dist/{middleware-CjHqy-1i.mjs → middleware-DkRMEKQc.mjs} +12 -12
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/{owner-gz4TUfKG.mjs → owner-DA4lyeXg.mjs} +2 -2
- package/dist/{proof-DQWTf6oB.js → proof-BlD1HSeA.js} +1 -1
- package/dist/{proof-CuQpZ_AT.mjs → proof-BpDfPXQU.mjs} +3 -3
- package/dist/{proof-CiDzRtr0.cjs → proof-CB7yrPSS.cjs} +1 -1
- package/dist/{send-B60teucv.mjs → send-DfeB83F0.mjs} +3 -3
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +187 -3
- package/dist/sig/ld.test.mjs +2 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +62 -2
- package/dist/{temporal-CvVMrvJJ.mjs → temporal-CIHMi9QT.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-C60MEuIn.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
|
-
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
|
+
import { CryptographicKey, Multikey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
|
-
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
9
|
+
import { FetchError, getDocumentLoader, parseDidKeyVerificationMethod } from "@fedify/vocab-runtime";
|
|
10
10
|
//#region src/sig/key.ts
|
|
11
11
|
/**
|
|
12
12
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
|
@@ -195,16 +195,22 @@ async function fetchKeyDetailed(keyId, cls, options = {}) {
|
|
|
195
195
|
async function getCachedFetchKey(cacheKey, keyId, cls, keyCache, logger) {
|
|
196
196
|
if (keyCache == null) return null;
|
|
197
197
|
const cachedKey = await keyCache.get(cacheKey);
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
const hit = checkCachedKeyHit(cachedKey, keyId, cls, logger);
|
|
199
|
+
if (hit != null) return hit;
|
|
200
|
+
if (cachedKey === null) {
|
|
201
|
+
logger.debug("Entry {keyId} found in cache, but it is unavailable.", { keyId });
|
|
200
202
|
return {
|
|
201
|
-
key:
|
|
203
|
+
key: null,
|
|
202
204
|
cached: true
|
|
203
205
|
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
function checkCachedKeyHit(cachedKey, keyId, cls, logger) {
|
|
210
|
+
if (cachedKey instanceof cls && cachedKey.publicKey != null) {
|
|
211
|
+
logger.debug("Key {keyId} found in cache.", { keyId });
|
|
206
212
|
return {
|
|
207
|
-
key:
|
|
213
|
+
key: cachedKey,
|
|
208
214
|
cached: true
|
|
209
215
|
};
|
|
210
216
|
}
|
|
@@ -213,6 +219,61 @@ async function getCachedFetchKey(cacheKey, keyId, cls, keyCache, logger) {
|
|
|
213
219
|
async function clearFetchErrorMetadata(keyId, keyCache) {
|
|
214
220
|
await keyCache?.setFetchError?.(keyId, null);
|
|
215
221
|
}
|
|
222
|
+
function isDidKeyUrl(keyId) {
|
|
223
|
+
return keyId.protocol === "did:" && keyId.pathname.startsWith("key:");
|
|
224
|
+
}
|
|
225
|
+
async function doRawKeysMatch(left, right) {
|
|
226
|
+
const [leftRaw, rightRaw] = await Promise.all([crypto.subtle.exportKey("raw", left), crypto.subtle.exportKey("raw", right)]);
|
|
227
|
+
if (leftRaw.byteLength !== rightRaw.byteLength) return false;
|
|
228
|
+
const leftBytes = new Uint8Array(leftRaw);
|
|
229
|
+
const rightBytes = new Uint8Array(rightRaw);
|
|
230
|
+
return leftBytes.every((byte, index) => byte === rightBytes[index]);
|
|
231
|
+
}
|
|
232
|
+
async function isCachedDidKeyValid(key, verificationMethod) {
|
|
233
|
+
try {
|
|
234
|
+
return key.id?.href === verificationMethod.id.href && key.controllerId?.href === verificationMethod.controller.href && await doRawKeysMatch(key.publicKey, verificationMethod.publicKey);
|
|
235
|
+
} catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async function resolveDidKey(cacheKey, cls, keyCache, logger) {
|
|
240
|
+
if (!isDidKeyUrl(cacheKey)) return null;
|
|
241
|
+
const keyId = cacheKey.href;
|
|
242
|
+
if (!(cls === Multikey)) {
|
|
243
|
+
logger.debug("Failed to resolve did:key {keyId}; did:key verification methods are only supported as Multikey values.", { keyId });
|
|
244
|
+
return {
|
|
245
|
+
key: null,
|
|
246
|
+
cached: false
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
let verificationMethod;
|
|
250
|
+
try {
|
|
251
|
+
verificationMethod = await parseDidKeyVerificationMethod(cacheKey);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
logger.debug("Failed to resolve did:key verification method {keyId}: {error}", {
|
|
254
|
+
keyId,
|
|
255
|
+
error
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
key: null,
|
|
259
|
+
cached: false
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const hit = checkCachedKeyHit(await keyCache?.get(cacheKey), keyId, cls, logger);
|
|
263
|
+
if (hit?.key instanceof Multikey && await isCachedDidKeyValid(hit.key, verificationMethod)) return hit;
|
|
264
|
+
const key = new Multikey({
|
|
265
|
+
id: verificationMethod.id,
|
|
266
|
+
controller: verificationMethod.controller,
|
|
267
|
+
publicKey: verificationMethod.publicKey
|
|
268
|
+
});
|
|
269
|
+
await keyCache?.set(cacheKey, key);
|
|
270
|
+
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
271
|
+
logger.debug("Resolved did:key verification method {keyId}.", { keyId });
|
|
272
|
+
return {
|
|
273
|
+
key,
|
|
274
|
+
cached: false
|
|
275
|
+
};
|
|
276
|
+
}
|
|
216
277
|
async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoader, contextLoader, keyCache, tracerProvider }, logger) {
|
|
217
278
|
let object;
|
|
218
279
|
try {
|
|
@@ -327,6 +388,11 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
|
|
|
327
388
|
]);
|
|
328
389
|
const keyId = cacheKey.href;
|
|
329
390
|
const keyCache = options.keyCache;
|
|
391
|
+
const didKey = await resolveDidKey(cacheKey, cls, keyCache, logger);
|
|
392
|
+
if (didKey != null) {
|
|
393
|
+
outcome = { result: didKey.key == null ? "invalid" : didKey.cached ? "hit" : "fetched" };
|
|
394
|
+
return didKey;
|
|
395
|
+
}
|
|
330
396
|
const cached = await getCachedFetchKey(cacheKey, keyId, cls, keyCache, logger);
|
|
331
397
|
if (cached?.key === null && cached.cached) {
|
|
332
398
|
const cachedUnavailable = await onCachedUnavailable(cacheKey, keyId, keyCache, logger);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-
|
|
3
|
+
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-BciNZ5qO.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { curry } from "es-toolkit";
|
|
6
6
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -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 { p as recordDocumentCache } from "./metrics-
|
|
4
|
+
import { p as recordDocumentCache } from "./metrics-C60MEuIn.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
6
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/utils/kv-cache.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-Be6MS-3k.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-C60MEuIn.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-C5fRM_21.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/federation/metrics.ts
|
|
@@ -167,11 +167,11 @@ var FederationMetrics = class {
|
|
|
167
167
|
unit: "{change}"
|
|
168
168
|
});
|
|
169
169
|
this.keyLookup = meter.createCounter("activitypub.key.lookup", {
|
|
170
|
-
description: "Public-key lookup attempts performed by Fedify, including
|
|
170
|
+
description: "Public-key lookup attempts performed by Fedify, including cache hits, local resolutions, and remote fetches.",
|
|
171
171
|
unit: "{lookup}"
|
|
172
172
|
});
|
|
173
173
|
this.keyLookupDuration = meter.createHistogram("activitypub.key.lookup.duration", {
|
|
174
|
-
description: "Duration of public-key lookups performed by Fedify, including any remote fetch.",
|
|
174
|
+
description: "Duration of public-key lookups performed by Fedify, including cache hits, local resolutions, and any remote fetch.",
|
|
175
175
|
unit: "ms",
|
|
176
176
|
advice: { explicitBucketBoundaries: [
|
|
177
177
|
5,
|
|
@@ -2,10 +2,10 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
4
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
5
|
-
const require_http = require("./http-
|
|
6
|
-
const require_proof = require("./proof-
|
|
5
|
+
const require_http = require("./http-Be6MS-3k.cjs");
|
|
6
|
+
const require_proof = require("./proof-CB7yrPSS.cjs");
|
|
7
7
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
8
|
-
const require_kv_cache = require("./kv-cache-
|
|
8
|
+
const require_kv_cache = require("./kv-cache-C51pYkUU.cjs");
|
|
9
9
|
let _logtape_logtape = require("@logtape/logtape");
|
|
10
10
|
let _fedify_uri_template = require("@fedify/uri-template");
|
|
11
11
|
let _fedify_vocab = require("@fedify/vocab");
|
|
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { t as __exportAll } from "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { r as getDefaultActivityTransformers } from "./transformers-BGMIq1cs.js";
|
|
5
|
-
import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-
|
|
6
|
-
import { _ as hasSignatureLike, b as signJsonLd, c as getKeyOwner, f as compactJsonLd, g as hasSignature, h as getNormalizationContextLoader, i as verifyObject, l as InvalidContextReferenceError, m as detachSignature, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, r as signObject, s as doesActorOwnKey, u as assertSafeJsonLd, v as isClearlyMalformedContextReference, w as wrapContextLoaderForJsonLd, x as verifyCompactJsonLd, y as isInvalidUrlTypeError } from "./proof-
|
|
5
|
+
import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-BciNZ5qO.js";
|
|
6
|
+
import { _ as hasSignatureLike, b as signJsonLd, c as getKeyOwner, f as compactJsonLd, g as hasSignature, h as getNormalizationContextLoader, i as verifyObject, l as InvalidContextReferenceError, m as detachSignature, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, r as signObject, s as doesActorOwnKey, u as assertSafeJsonLd, v as isClearlyMalformedContextReference, w as wrapContextLoaderForJsonLd, x as verifyCompactJsonLd, y as isInvalidUrlTypeError } from "./proof-BlD1HSeA.js";
|
|
7
7
|
import { n as getNodeInfo, t as nodeInfoToJson } from "./types-CAY3OdLq.js";
|
|
8
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
8
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-6cpvv2tC.js";
|
|
9
9
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
10
10
|
import { Router, RouterError, assertPath } from "@fedify/uri-template";
|
|
11
11
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-C60MEuIn.mjs";
|
|
6
6
|
import { t as formatAcceptSignature } from "./accept-CgDcxvjV.mjs";
|
|
7
|
-
import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-
|
|
8
|
-
import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-
|
|
9
|
-
import { t as getAuthenticatedDocumentLoader } from "./docloader-
|
|
10
|
-
import { n as kvCache } from "./kv-cache-
|
|
11
|
-
import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-
|
|
12
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-
|
|
7
|
+
import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-C5fRM_21.mjs";
|
|
8
|
+
import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-CuG4iKEH.mjs";
|
|
9
|
+
import { t as getAuthenticatedDocumentLoader } from "./docloader-BQGU0tG-.mjs";
|
|
10
|
+
import { n as kvCache } from "./kv-cache-Bn_DvESZ.mjs";
|
|
11
|
+
import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-DxtnUVwj.mjs";
|
|
12
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-DA4lyeXg.mjs";
|
|
13
13
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BNL8AC14.mjs";
|
|
14
|
-
import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-
|
|
14
|
+
import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-BpDfPXQU.mjs";
|
|
15
15
|
import { t as getNodeInfo } from "./client-B_A6mfn3.mjs";
|
|
16
16
|
import { t as nodeInfoToJson } from "./types-BFowWFTT.mjs";
|
|
17
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-
|
|
18
|
-
import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-
|
|
17
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-DfeB83F0.mjs";
|
|
18
|
+
import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-CBgmNPaS.mjs";
|
|
19
19
|
import { t as CircuitBreaker } from "./circuit-breaker-hJBB6jwA.mjs";
|
|
20
20
|
import { t as buildCollectionSynchronizationHeader } from "./collection-Dp5ky45w.mjs";
|
|
21
21
|
import { t as KvKeyCache } from "./keycache-CaOR6NYg.mjs";
|
|
22
22
|
import { t as acceptsJsonLd } from "./negotiation-m_L2nyS3.mjs";
|
|
23
|
-
import { t as hasMalformedKnownTemporalLiteral } from "./temporal-
|
|
23
|
+
import { t as hasMalformedKnownTemporalLiteral } from "./temporal-CIHMi9QT.mjs";
|
|
24
24
|
import { t as createExponentialBackoffPolicy } from "./retry-DI4O-zYl.mjs";
|
|
25
25
|
import { t as TaskCodec } from "./codec-nfBU4Up4.mjs";
|
|
26
26
|
import { n as ParallelMessageQueue } from "./mq-03vS-C9P.mjs";
|
package/dist/mod.cjs
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
require("./chunk-DDcVe30Y.cjs");
|
|
5
5
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
6
6
|
require("./compat/mod.cjs");
|
|
7
|
-
const require_http = require("./http-
|
|
8
|
-
const require_middleware = require("./middleware-
|
|
9
|
-
const require_proof = require("./proof-
|
|
7
|
+
const require_http = require("./http-Be6MS-3k.cjs");
|
|
8
|
+
const require_middleware = require("./middleware-Cp410Lku.cjs");
|
|
9
|
+
const require_proof = require("./proof-CB7yrPSS.cjs");
|
|
10
10
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
11
|
-
const require_kv_cache = require("./kv-cache-
|
|
11
|
+
const require_kv_cache = require("./kv-cache-C51pYkUU.cjs");
|
|
12
12
|
const require_federation_mod = require("./federation/mod.cjs");
|
|
13
13
|
require("./nodeinfo/mod.cjs");
|
|
14
14
|
require("./runtime/mod.cjs");
|
package/dist/mod.js
CHANGED
|
@@ -3,11 +3,11 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
|
3
3
|
import "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-BGMIq1cs.js";
|
|
5
5
|
import "./compat/mod.js";
|
|
6
|
-
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "./http-
|
|
7
|
-
import { a as ParallelMessageQueue, c as respondWithObject, d as digest, f as CircuitBreaker, h as createFederationBuilder, i as InProcessMessageQueue, l as respondWithObjectIfAcceptable, m as parseCircuitBreakerKvState, o as createExponentialBackoffPolicy, p as normalizeCircuitBreakerOptions, r as handleWebFinger, s as SendActivityError, t as createFederation, u as buildCollectionSynchronizationHeader } from "./middleware-
|
|
8
|
-
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "./proof-
|
|
6
|
+
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "./http-BciNZ5qO.js";
|
|
7
|
+
import { a as ParallelMessageQueue, c as respondWithObject, d as digest, f as CircuitBreaker, h as createFederationBuilder, i as InProcessMessageQueue, l as respondWithObjectIfAcceptable, m as parseCircuitBreakerKvState, o as createExponentialBackoffPolicy, p as normalizeCircuitBreakerOptions, r as handleWebFinger, s as SendActivityError, t as createFederation, u as buildCollectionSynchronizationHeader } from "./middleware-DY9SToNd.js";
|
|
8
|
+
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "./proof-BlD1HSeA.js";
|
|
9
9
|
import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-CAY3OdLq.js";
|
|
10
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
10
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-6cpvv2tC.js";
|
|
11
11
|
import { MemoryKvStore, Router, RouterError } from "./federation/mod.js";
|
|
12
12
|
import "./nodeinfo/mod.js";
|
|
13
13
|
import "./runtime/mod.js";
|
|
@@ -5,7 +5,7 @@ import { r as createRequestContext } from "../context-BBRTgkrs.mjs";
|
|
|
5
5
|
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
7
7
|
import "../std__assert-Dh6uLf_q.mjs";
|
|
8
|
-
import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-
|
|
8
|
+
import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-DkRMEKQc.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/nodeinfo/handler.test.ts
|
|
11
11
|
test("handleNodeInfo()", async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import "./key-C5fRM_21.mjs";
|
|
6
6
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-
|
|
3
|
+
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-BciNZ5qO.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-C60MEuIn.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-C5fRM_21.mjs";
|
|
7
7
|
import { n as preloadedOnlyDocumentLoader } from "./public-audience-c9zmYKgA.mjs";
|
|
8
8
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BNL8AC14.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-Be6MS-3k.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _fedify_vocab = require("@fedify/vocab");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-
|
|
6
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-ColSXZB4.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-C60MEuIn.mjs";
|
|
6
|
+
import { n as doubleKnock } from "./http-CuG4iKEH.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { r as assertExists, t as assertStringIncludes } from "../std__assert-Dh6
|
|
|
7
7
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
|
|
8
8
|
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
9
9
|
import { t as assert } from "../assert-DvVHoIZ0.mjs";
|
|
10
|
-
import { t as exportJwk } from "../key-
|
|
11
|
-
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-
|
|
10
|
+
import { t as exportJwk } from "../key-C5fRM_21.mjs";
|
|
11
|
+
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-CuG4iKEH.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
|
|
13
13
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -5,11 +5,11 @@ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
|
5
5
|
import "../std__assert-Dh6uLf_q.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
8
|
-
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-
|
|
9
|
-
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
8
|
+
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-C5fRM_21.mjs";
|
|
9
|
+
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
10
10
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
11
11
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
|
-
import { FetchError } from "@fedify/vocab-runtime";
|
|
12
|
+
import { FetchError, exportDidKey } from "@fedify/vocab-runtime";
|
|
13
13
|
//#region src/sig/key.test.ts
|
|
14
14
|
test("validateCryptoKey()", async () => {
|
|
15
15
|
const pkcs1v15 = await crypto.subtle.generateKey({
|
|
@@ -303,6 +303,190 @@ test("fetchKeyDetailed() returns detailed fetch errors", async () => {
|
|
|
303
303
|
if (detailedError == null || !("error" in detailedError)) throw new Error("Expected non-HTTP fetch error details.");
|
|
304
304
|
assertEquals(detailedError.error, failure);
|
|
305
305
|
});
|
|
306
|
+
test("fetchKey() resolves did:key Multikeys without document loading", async () => {
|
|
307
|
+
const did = await exportDidKey(ed25519PublicKey.publicKey);
|
|
308
|
+
const keyId = `${did}#${did.slice(8)}`;
|
|
309
|
+
const expectedKey = new Multikey({
|
|
310
|
+
id: new URL(keyId),
|
|
311
|
+
controller: new URL(did),
|
|
312
|
+
publicKey: ed25519PublicKey.publicKey
|
|
313
|
+
});
|
|
314
|
+
const cache = { [keyId]: null };
|
|
315
|
+
let documentLoaderCalls = 0;
|
|
316
|
+
const options = {
|
|
317
|
+
documentLoader() {
|
|
318
|
+
documentLoaderCalls++;
|
|
319
|
+
throw new TypeError("did:key must not use the document loader");
|
|
320
|
+
},
|
|
321
|
+
contextLoader: mockDocumentLoader,
|
|
322
|
+
keyCache: {
|
|
323
|
+
get(keyId) {
|
|
324
|
+
return Promise.resolve(cache[keyId.href]);
|
|
325
|
+
},
|
|
326
|
+
set(keyId, key) {
|
|
327
|
+
cache[keyId.href] = key;
|
|
328
|
+
return Promise.resolve();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
assertEquals(await fetchKey(keyId, Multikey, options), {
|
|
333
|
+
key: expectedKey,
|
|
334
|
+
cached: false
|
|
335
|
+
});
|
|
336
|
+
assertEquals(documentLoaderCalls, 0);
|
|
337
|
+
assertEquals(cache[keyId], expectedKey);
|
|
338
|
+
assertEquals(await fetchKey(keyId, Multikey, options), {
|
|
339
|
+
key: expectedKey,
|
|
340
|
+
cached: true
|
|
341
|
+
});
|
|
342
|
+
assertEquals(documentLoaderCalls, 0);
|
|
343
|
+
});
|
|
344
|
+
test("fetchKey() validates cached did:key Multikeys", async () => {
|
|
345
|
+
const did = await exportDidKey(ed25519PublicKey.publicKey);
|
|
346
|
+
const keyId = `${did}#${did.slice(8)}`;
|
|
347
|
+
const wrongKeyPair = await generateCryptoKeyPair("Ed25519");
|
|
348
|
+
const cachedKey = new Multikey({
|
|
349
|
+
id: new URL(keyId),
|
|
350
|
+
controller: new URL(did),
|
|
351
|
+
publicKey: wrongKeyPair.publicKey
|
|
352
|
+
});
|
|
353
|
+
const expectedKey = new Multikey({
|
|
354
|
+
id: new URL(keyId),
|
|
355
|
+
controller: new URL(did),
|
|
356
|
+
publicKey: ed25519PublicKey.publicKey
|
|
357
|
+
});
|
|
358
|
+
const cache = { [keyId]: cachedKey };
|
|
359
|
+
let documentLoaderCalls = 0;
|
|
360
|
+
assertEquals(await fetchKey(keyId, Multikey, {
|
|
361
|
+
documentLoader() {
|
|
362
|
+
documentLoaderCalls++;
|
|
363
|
+
throw new TypeError("did:key must not use the document loader");
|
|
364
|
+
},
|
|
365
|
+
contextLoader: mockDocumentLoader,
|
|
366
|
+
keyCache: {
|
|
367
|
+
get(keyId) {
|
|
368
|
+
return Promise.resolve(cache[keyId.href]);
|
|
369
|
+
},
|
|
370
|
+
set(keyId, key) {
|
|
371
|
+
cache[keyId.href] = key;
|
|
372
|
+
return Promise.resolve();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}), {
|
|
376
|
+
key: expectedKey,
|
|
377
|
+
cached: false
|
|
378
|
+
});
|
|
379
|
+
assertEquals(documentLoaderCalls, 0);
|
|
380
|
+
assertEquals(cache[keyId], expectedKey);
|
|
381
|
+
});
|
|
382
|
+
test("fetchKey() rejects unsupported did:key values locally", async () => {
|
|
383
|
+
const invalidKeyId = "did:key:z6MksHj1MJnidCtDiyYW9ugNFftoX9fLK4bornTxmMZ6X7vq#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK";
|
|
384
|
+
const cache = {};
|
|
385
|
+
let documentLoaderCalls = 0;
|
|
386
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
387
|
+
assertEquals(await fetchKey(invalidKeyId, Multikey, {
|
|
388
|
+
documentLoader() {
|
|
389
|
+
documentLoaderCalls++;
|
|
390
|
+
throw new TypeError("did:key must not use the document loader");
|
|
391
|
+
},
|
|
392
|
+
contextLoader: mockDocumentLoader,
|
|
393
|
+
meterProvider,
|
|
394
|
+
keyCache: {
|
|
395
|
+
get(keyId) {
|
|
396
|
+
return Promise.resolve(cache[keyId.href]);
|
|
397
|
+
},
|
|
398
|
+
set(keyId, key) {
|
|
399
|
+
cache[keyId.href] = key;
|
|
400
|
+
return Promise.resolve();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}), {
|
|
404
|
+
key: null,
|
|
405
|
+
cached: false
|
|
406
|
+
});
|
|
407
|
+
assertEquals(documentLoaderCalls, 0);
|
|
408
|
+
assertEquals(cache, {});
|
|
409
|
+
assertEquals(recorder.getMeasurement("activitypub.key.lookup")?.attributes["activitypub.lookup.result"], "invalid");
|
|
410
|
+
});
|
|
411
|
+
test("fetchKeyDetailed() resolves did:key without fetchError", async () => {
|
|
412
|
+
const did = await exportDidKey(ed25519PublicKey.publicKey);
|
|
413
|
+
const result = await fetchKeyDetailed(`${did}#${did.slice(8)}`, Multikey, {
|
|
414
|
+
documentLoader() {
|
|
415
|
+
throw new TypeError("did:key must not use the document loader");
|
|
416
|
+
},
|
|
417
|
+
contextLoader: mockDocumentLoader
|
|
418
|
+
});
|
|
419
|
+
assertEquals(result.key instanceof Multikey, true);
|
|
420
|
+
assertEquals(result.cached, false);
|
|
421
|
+
assertEquals(result.fetchError, void 0);
|
|
422
|
+
});
|
|
423
|
+
test("fetchKeyDetailed() rejects invalid did:key without fetchError", async () => {
|
|
424
|
+
const invalidKeyId = "did:key:z6MksHj1MJnidCtDiyYW9ugNFftoX9fLK4bornTxmMZ6X7vq#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK";
|
|
425
|
+
const cache = {};
|
|
426
|
+
let documentLoaderCalls = 0;
|
|
427
|
+
const result = await fetchKeyDetailed(invalidKeyId, Multikey, {
|
|
428
|
+
documentLoader() {
|
|
429
|
+
documentLoaderCalls++;
|
|
430
|
+
throw new TypeError("did:key must not use the document loader");
|
|
431
|
+
},
|
|
432
|
+
contextLoader: mockDocumentLoader,
|
|
433
|
+
keyCache: {
|
|
434
|
+
get(keyId) {
|
|
435
|
+
return Promise.resolve(cache[keyId.href]);
|
|
436
|
+
},
|
|
437
|
+
set(keyId, key) {
|
|
438
|
+
cache[keyId.href] = key;
|
|
439
|
+
return Promise.resolve();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
assertEquals(result.key, null);
|
|
444
|
+
assertEquals(result.cached, false);
|
|
445
|
+
assertEquals(result.fetchError, void 0);
|
|
446
|
+
assertEquals(documentLoaderCalls, 0);
|
|
447
|
+
assertEquals(cache, {});
|
|
448
|
+
});
|
|
449
|
+
test("fetchKey() does not resolve did:key as CryptographicKey", async () => {
|
|
450
|
+
const did = await exportDidKey(ed25519PublicKey.publicKey);
|
|
451
|
+
const keyId = `${did}#${did.slice(8)}`;
|
|
452
|
+
let cacheGets = 0;
|
|
453
|
+
let documentLoaderCalls = 0;
|
|
454
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
455
|
+
documentLoader() {
|
|
456
|
+
documentLoaderCalls++;
|
|
457
|
+
throw new TypeError("did:key must not use the document loader");
|
|
458
|
+
},
|
|
459
|
+
contextLoader: mockDocumentLoader,
|
|
460
|
+
keyCache: {
|
|
461
|
+
get() {
|
|
462
|
+
cacheGets++;
|
|
463
|
+
throw new TypeError("did:key must not check the cache");
|
|
464
|
+
},
|
|
465
|
+
set() {
|
|
466
|
+
throw new TypeError("did:key must not write to the cache");
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}), {
|
|
470
|
+
key: null,
|
|
471
|
+
cached: false
|
|
472
|
+
});
|
|
473
|
+
assertEquals(cacheGets, 0);
|
|
474
|
+
assertEquals(documentLoaderCalls, 0);
|
|
475
|
+
});
|
|
476
|
+
test("fetchKey() records did:key lookup metrics", async () => {
|
|
477
|
+
const did = await exportDidKey(ed25519PublicKey.publicKey);
|
|
478
|
+
const keyId = `${did}#${did.slice(8)}`;
|
|
479
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
480
|
+
assertEquals((await fetchKey(keyId, Multikey, {
|
|
481
|
+
documentLoader: mockDocumentLoader,
|
|
482
|
+
contextLoader: mockDocumentLoader,
|
|
483
|
+
meterProvider
|
|
484
|
+
})).cached, false);
|
|
485
|
+
const counter = recorder.getMeasurement("activitypub.key.lookup");
|
|
486
|
+
assertEquals(counter?.attributes["activitypub.lookup.result"], "fetched");
|
|
487
|
+
assertEquals(counter?.attributes["activitypub.cache.enabled"], false);
|
|
488
|
+
assertEquals(counter?.attributes["activitypub.remote.host"], "");
|
|
489
|
+
});
|
|
306
490
|
test("fetchKey() records activitypub.key.lookup with hit on cached key", async () => {
|
|
307
491
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
308
492
|
const cache = {};
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
|
5
5
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
7
7
|
import { t as assert } from "../assert-DvVHoIZ0.mjs";
|
|
8
|
-
import { i as generateCryptoKeyPair } from "../key-
|
|
8
|
+
import { i as generateCryptoKeyPair } from "../key-C5fRM_21.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
10
|
-
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-
|
|
10
|
+
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-DxtnUVwj.mjs";
|
|
11
11
|
import { CryptographicKey } from "@fedify/vocab";
|
|
12
12
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
package/dist/sig/mod.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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_http = require("../http-
|
|
5
|
-
const require_proof = require("../proof-
|
|
4
|
+
const require_http = require("../http-Be6MS-3k.cjs");
|
|
5
|
+
const require_proof = require("../proof-CB7yrPSS.cjs");
|
|
6
6
|
exports.attachSignature = require_proof.attachSignature;
|
|
7
7
|
exports.createProof = require_proof.createProof;
|
|
8
8
|
exports.createSignature = require_proof.createSignature;
|
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 { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-
|
|
4
|
-
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-
|
|
3
|
+
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-BciNZ5qO.js";
|
|
4
|
+
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-BlD1HSeA.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 };
|