@fedify/fedify 1.7.13 → 1.7.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{actor-CPpvuBKU.d.ts → actor.d.ts} +3 -3
- package/dist/{actor-BVilnhZ3.js → actor.js} +6 -6
- package/dist/{assert-LOEeCUK5.js → assert.js} +2 -2
- package/dist/{assert_equals-B44MxcIj.js → assert_equals.js} +16 -16
- package/dist/{assert_instance_of-XtuFevV_.js → assert_instance_of.js} +2 -2
- package/dist/{assert_is_error-BTlryvT0.js → assert_is_error.js} +2 -2
- package/dist/{assert_not_equals-C685gKx6.js → assert_not_equals.js} +3 -6
- package/dist/{assert_rejects-DWQ4jaf9.js → assert_rejects.js} +3 -3
- package/dist/{assert_throws-YetpVSc-.js → assert_throws.js} +3 -3
- package/dist/{authdocloader-DqCINL6u.js → authdocloader.js} +8 -8
- package/dist/{builder-CKUAOfcL.js → builder.js} +7 -7
- package/dist/{chunk-Cx8LTkjm.js → chunk.js} +22 -15
- package/dist/{client-DvtwXO7t.d.ts → client.d.ts} +2 -2
- package/dist/{client-C5xUY491.js → client.js} +3 -3
- package/dist/{collection-Dfb0TPno.js → collection.js} +2 -3
- package/dist/compat/mod.d.ts +79 -12
- package/dist/compat/mod.js +1 -2
- package/dist/compat/transformers.test.js +34 -38
- package/dist/{context-OBWjptjU.d.ts → context.d.ts} +11 -11
- package/dist/{context-aglzx1Ww.js → context.js} +5 -5
- package/dist/{docloader-Q42SMRIB.d.ts → docloader.d.ts} +2 -2
- package/dist/{docloader-Qfs9nPiy.js → docloader.js} +32 -152
- package/dist/{docloader-09nVWLAZ.js → docloader2.js} +1 -1
- package/dist/{esm-DO9PrujO.js → esm.js} +36 -22
- package/dist/federation/builder.test.js +20 -26
- package/dist/federation/collection.test.js +11 -16
- package/dist/federation/handler.test.js +41 -48
- package/dist/federation/inbox.test.js +11 -11
- package/dist/federation/keycache.test.js +12 -11
- package/dist/federation/kv.test.js +8 -10
- package/dist/federation/middleware.test.js +105 -134
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +206 -12
- package/dist/federation/mq.test.js +12 -17
- package/dist/federation/retry.test.js +5 -4
- package/dist/federation/router.test.js +9 -10
- package/dist/federation/send.test.js +23 -24
- package/dist/{http-DMTrO3Ye.d.ts → http.d.ts} +3 -3
- package/dist/{http-CjDwMreH.js → http.js} +25 -31
- package/dist/{inbox-ApPO50Ma.js → inbox.js} +5 -5
- package/dist/key.js +16 -0
- package/dist/{key-BPUM0v_S.js → key2.js} +5 -5
- package/dist/{keycache-B7Urghlu.js → keycache.js} +2 -2
- package/dist/{keys-DGJec4-R.js → keys.js} +2 -2
- package/dist/{kv-DRaeSXco.d.ts → kv.d.ts} +1 -1
- package/dist/{kv-BMY6Qf_A.js → kv.js} +1 -1
- package/dist/{langstr-DbWheeIS.js → langstr.js} +1 -1
- package/dist/{ld-DJTavNY3.js → ld.js} +9 -12
- package/dist/{lookup-Bf-K85bV.d.ts → lookup.d.ts} +2 -2
- package/dist/{lookup-CkOdKyYR.js → lookup.js} +4 -4
- package/dist/{lookup-CnkkF4Rf.js → lookup2.js} +6 -6
- package/dist/{middleware-BxHcZC4p.js → middleware.js} +35 -39
- package/dist/middleware2.js +32 -0
- package/dist/mod.d.ts +17 -17
- package/dist/mod.js +17 -17
- package/dist/{mod-CDzlVCUF.d.ts → mod2.d.ts} +3 -3
- package/dist/{mod-CCL2cvnI.d.ts → mod3.d.ts} +4 -4
- package/dist/{mq-DYKDDJmp.d.ts → mq.d.ts} +1 -1
- package/dist/{multibase-CnLHszip.js → multibase.js} +1 -1
- package/dist/nodeinfo/client.test.js +19 -28
- package/dist/nodeinfo/handler.test.js +37 -44
- package/dist/nodeinfo/mod.d.ts +2 -5
- package/dist/nodeinfo/mod.js +2 -3
- package/dist/nodeinfo/semver.test.js +13 -21
- package/dist/nodeinfo/types.test.js +9 -11
- package/dist/{owner-D0cOz8R5.d.ts → owner.d.ts} +4 -4
- package/dist/{owner-qKULzrkx.js → owner.js} +4 -4
- package/dist/{proof-d5P09-xk.js → proof.js} +11 -13
- package/dist/{retry-BiIhZWgD.js → retry.js} +1 -1
- package/dist/{router-D_aVZZUc.js → router.js} +1 -1
- package/dist/runtime/authdocloader.test.js +22 -26
- package/dist/runtime/docloader.test.js +56 -56
- package/dist/runtime/key.test.js +31 -53
- package/dist/runtime/langstr.test.js +8 -10
- package/dist/runtime/mod.d.ts +103 -6
- package/dist/runtime/mod.js +6 -7
- package/dist/runtime/multibase/multibase.test.js +12 -18
- package/dist/runtime/url.test.js +7 -6
- package/dist/{semver-BNrOOAs9.js → semver.js} +7 -17
- package/dist/{send-BnMY3Qxa.js → send.js} +4 -4
- package/dist/sig/http.test.js +104 -168
- package/dist/sig/key.test.js +17 -20
- package/dist/sig/ld.test.js +28 -35
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -7
- package/dist/sig/owner.test.js +24 -30
- package/dist/sig/proof.test.js +24 -29
- package/dist/{std__assert-o_r9vqm1.js → std__assert.js} +7 -13
- package/dist/testing/docloader.test.js +9 -12
- package/dist/testing/mod.js +2 -1
- package/dist/{testing-DLyvtiiW.js → testing.js} +2 -2
- package/dist/{transformers-ghwJuzGY.js → transformers.js} +1 -1
- package/dist/{type-CFuiGLz9.js → type.js} +1 -1
- package/dist/{types-CJHS5pXl.js → types.js} +2 -2
- package/dist/{url-C2xuoQD1.js → url.js} +1 -1
- package/dist/vocab/actor.test.js +76 -128
- package/dist/vocab/lookup.test.js +19 -23
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +10 -10
- package/dist/vocab/vocab.test.js +90 -109
- package/dist/{vocab-CzEfWQk2.d.ts → vocab.d.ts} +2 -2
- package/dist/{vocab-S7fEn6XO.js → vocab.js} +318 -454
- package/dist/webfinger/handler.test.js +40 -48
- package/dist/webfinger/lookup.test.js +12 -15
- package/dist/webfinger/mod.d.ts +1 -4
- package/dist/webfinger/mod.js +2 -3
- package/dist/x/cfworkers.d.ts +2 -2
- package/dist/x/cfworkers.test.js +7 -9
- package/dist/x/hono.d.ts +2 -11
- package/dist/x/sveltekit.d.ts +2 -11
- package/package.json +1 -1
- package/dist/actor-CsmPeeHG.js +0 -34925
- package/dist/authdocloader-9g6RkEcR.js +0 -53
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/docloader-CchlnLWb.js +0 -4598
- package/dist/federation-B0aljx0V.js +0 -203
- package/dist/http-CP3h1SLi.js +0 -796
- package/dist/key--l6NVKdl.js +0 -257
- package/dist/key-1Fv7reaM.js +0 -16
- package/dist/key-DD37RpoD.js +0 -10
- package/dist/lookup-CN-LpF5e.js +0 -127
- package/dist/middleware-BQHe0X6Y.js +0 -17
- package/dist/middleware-C3TZ3P-v.js +0 -33
- package/dist/middleware-CEpilAEY.js +0 -3524
- package/dist/mod-1pDWKvUL.d.ts +0 -2
- package/dist/mod-DFncUgcE.d.ts +0 -82
- package/dist/mod-GIh5OYxW.d.ts +0 -2
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mod-qFMzZ3iF.d.ts +0 -104
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/proof-BfeWBNrY.js +0 -582
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/types-BZUzjGS0.js +0 -455
- package/dist/vocab-C_pE4SvE.js +0 -168
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{denokv-CvROlGYX.js → denokv.js} +0 -0
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import { test } from "../testing
|
|
10
|
-
import {
|
|
11
|
-
import { assertFalse } from "../assert_rejects
|
|
12
|
-
import "../assert_is_error
|
|
13
|
-
import "../
|
|
14
|
-
import "../assert_throws-YetpVSc-.js";
|
|
6
|
+
import "../chunk.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
+
import { t as assert } from "../assert.js";
|
|
9
|
+
import { t as test } from "../testing.js";
|
|
10
|
+
import { i as assertGreaterOrEqual, r as assertGreater } from "../std__assert.js";
|
|
11
|
+
import { n as assertFalse } from "../assert_rejects.js";
|
|
12
|
+
import "../assert_is_error.js";
|
|
13
|
+
import "../assert_throws.js";
|
|
15
14
|
import { delay } from "@es-toolkit/es-toolkit";
|
|
16
15
|
|
|
17
16
|
//#region federation/mq.ts
|
|
@@ -70,10 +69,7 @@ var InProcessMessageQueue = class {
|
|
|
70
69
|
async listen(handler, options = {}) {
|
|
71
70
|
const signal = options.signal;
|
|
72
71
|
while (signal == null || !signal.aborted) {
|
|
73
|
-
while (this.#messages.length > 0)
|
|
74
|
-
const message = this.#messages.shift();
|
|
75
|
-
await handler(message);
|
|
76
|
-
}
|
|
72
|
+
while (this.#messages.length > 0) await handler(this.#messages.shift());
|
|
77
73
|
await this.#wait(this.#pollIntervalMs, signal);
|
|
78
74
|
}
|
|
79
75
|
}
|
|
@@ -224,7 +220,7 @@ test("InProcessMessageQueue", async (t) => {
|
|
|
224
220
|
});
|
|
225
221
|
test("MessageQueue.nativeRetrial", async (t) => {
|
|
226
222
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") await t.step("DenoKvMessageQueue", async () => {
|
|
227
|
-
const { DenoKvMessageQueue } = await import("../denokv
|
|
223
|
+
const { DenoKvMessageQueue } = await import("../denokv.js");
|
|
228
224
|
const mq = new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
229
225
|
assert(mq.nativeRetrial);
|
|
230
226
|
if (Symbol.dispose in mq) {
|
|
@@ -257,13 +253,12 @@ test("MessageQueue.nativeRetrial", async (t) => {
|
|
|
257
253
|
throw new TypeError("WorkersMessageQueue does not support listen()");
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
|
-
|
|
261
|
-
assert(mq.nativeRetrial);
|
|
256
|
+
assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
|
|
262
257
|
});
|
|
263
258
|
});
|
|
264
259
|
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
|
265
260
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
|
|
266
|
-
const { DenoKvMessageQueue } = await import("../denokv
|
|
261
|
+
const { DenoKvMessageQueue } = await import("../denokv.js");
|
|
267
262
|
queues.DenoKvMessageQueue = async () => new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
268
263
|
}
|
|
269
264
|
for (const mqName in queues) test({
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import "../chunk.js";
|
|
7
|
+
import { t as assertEquals, u as AssertionError } from "../assert_equals.js";
|
|
8
|
+
import { t as createExponentialBackoffPolicy } from "../retry.js";
|
|
9
|
+
import { t as test } from "../testing.js";
|
|
10
|
+
import { t as assertNotEquals } from "../assert_not_equals.js";
|
|
10
11
|
|
|
11
12
|
//#region federation/retry.test.ts
|
|
12
13
|
test("createExponentialBackoffPolicy()", () => {
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import {
|
|
10
|
-
import { test } from "../testing
|
|
11
|
-
import "../std__assert
|
|
12
|
-
import { assertFalse } from "../assert_rejects
|
|
13
|
-
import "../assert_is_error
|
|
14
|
-
import "../
|
|
15
|
-
import { assertThrows } from "../assert_throws-YetpVSc-.js";
|
|
6
|
+
import "../chunk.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
+
import { t as assert } from "../assert.js";
|
|
9
|
+
import { n as RouterError, t as Router } from "../router.js";
|
|
10
|
+
import { t as test } from "../testing.js";
|
|
11
|
+
import "../std__assert.js";
|
|
12
|
+
import { n as assertFalse } from "../assert_rejects.js";
|
|
13
|
+
import "../assert_is_error.js";
|
|
14
|
+
import { t as assertThrows } from "../assert_throws.js";
|
|
16
15
|
|
|
17
16
|
//#region federation/router.test.ts
|
|
18
17
|
function setUp(options = {}) {
|
|
@@ -3,30 +3,29 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import "../docloader
|
|
10
|
-
import "../url
|
|
11
|
-
import "../multibase
|
|
12
|
-
import {
|
|
13
|
-
import "../langstr
|
|
14
|
-
import "../lookup
|
|
15
|
-
import "../
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import "../
|
|
23
|
-
import
|
|
24
|
-
import "../
|
|
25
|
-
import
|
|
26
|
-
import "../
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { esm_default } from "../esm-DO9PrujO.js";
|
|
6
|
+
import "../chunk.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals.js";
|
|
8
|
+
import { t as assert } from "../assert.js";
|
|
9
|
+
import "../docloader.js";
|
|
10
|
+
import "../url.js";
|
|
11
|
+
import "../multibase.js";
|
|
12
|
+
import { S as Person, T as Service, c as Endpoints, r as Application, t as Activity, u as Group } from "../vocab.js";
|
|
13
|
+
import "../langstr.js";
|
|
14
|
+
import "../lookup.js";
|
|
15
|
+
import "../actor.js";
|
|
16
|
+
import "../key2.js";
|
|
17
|
+
import { l as verifyRequest } from "../http.js";
|
|
18
|
+
import { t as doesActorOwnKey } from "../owner.js";
|
|
19
|
+
import { n as sendActivity, t as extractInboxes } from "../send.js";
|
|
20
|
+
import { t as test } from "../testing.js";
|
|
21
|
+
import "../std__assert.js";
|
|
22
|
+
import { n as assertFalse, t as assertRejects } from "../assert_rejects.js";
|
|
23
|
+
import "../assert_is_error.js";
|
|
24
|
+
import { t as assertNotEquals } from "../assert_not_equals.js";
|
|
25
|
+
import "../assert_throws.js";
|
|
26
|
+
import { t as mockDocumentLoader } from "../docloader2.js";
|
|
27
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys.js";
|
|
28
|
+
import { t as esm_default } from "../esm.js";
|
|
30
29
|
|
|
31
30
|
//#region federation/send.test.ts
|
|
32
31
|
test("extractInboxes()", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { DocumentLoader } from "./docloader
|
|
4
|
-
import {
|
|
3
|
+
import { n as DocumentLoader } from "./docloader.js";
|
|
4
|
+
import { B as Multikey, m as CryptographicKey } from "./vocab.js";
|
|
5
5
|
import { TracerProvider } from "@opentelemetry/api";
|
|
6
6
|
|
|
7
7
|
//#region sig/key.d.ts
|
|
@@ -252,4 +252,4 @@ interface HttpMessageSignaturesSpecDeterminer {
|
|
|
252
252
|
* @since 1.6.0
|
|
253
253
|
*/
|
|
254
254
|
//#endregion
|
|
255
|
-
export {
|
|
255
|
+
export { signRequest as a, FetchKeyResult as c, fetchKey as d, generateCryptoKeyPair as f, VerifyRequestOptions as i, KeyCache as l, HttpMessageSignaturesSpecDeterminer as n, verifyRequest as o, importJwk as p, SignRequestOptions as r, FetchKeyOptions as s, HttpMessageSignaturesSpec as t, exportJwk as u };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
import { CryptographicKey } from "./
|
|
7
|
-
import {
|
|
6
|
+
import { d as version, u as name } from "./docloader.js";
|
|
7
|
+
import { o as CryptographicKey } from "./vocab.js";
|
|
8
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key2.js";
|
|
8
9
|
import { getLogger } from "@logtape/logtape";
|
|
9
10
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
11
|
+
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
10
12
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
13
|
import { encodeHex } from "byte-encodings/hex";
|
|
12
|
-
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
13
14
|
import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
14
15
|
|
|
15
16
|
//#region sig/http.ts
|
|
@@ -24,7 +25,7 @@ import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
|
24
25
|
*/
|
|
25
26
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
26
27
|
validateCryptoKey(privateKey, "private");
|
|
27
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
28
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
28
29
|
try {
|
|
29
30
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
30
31
|
let signed;
|
|
@@ -33,7 +34,7 @@ async function signRequest(request, privateKey, keyId, options = {}) {
|
|
|
33
34
|
if (span.isRecording()) {
|
|
34
35
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, signed.method);
|
|
35
36
|
span.setAttribute(ATTR_URL_FULL, signed.url);
|
|
36
|
-
for (const [name, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
|
|
37
|
+
for (const [name$1, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
|
|
37
38
|
span.setAttribute("http_signatures.key_id", keyId.href);
|
|
38
39
|
}
|
|
39
40
|
return signed;
|
|
@@ -61,8 +62,8 @@ async function signRequestDraft(request, privateKey, keyId, span, currentTime, b
|
|
|
61
62
|
}
|
|
62
63
|
if (!headers.has("Date")) headers.set("Date", currentTime == null ? (/* @__PURE__ */ new Date()).toUTCString() : new Date(currentTime.toString()).toUTCString());
|
|
63
64
|
const serialized = [["(request-target)", `${request.method.toLowerCase()} ${url.pathname}`], ...headers];
|
|
64
|
-
const headerNames = serialized.map(([name]) => name);
|
|
65
|
-
const message = serialized.map(([name, value]) => `${name}: ${value.trim()}`).join("\n");
|
|
65
|
+
const headerNames = serialized.map(([name$1]) => name$1);
|
|
66
|
+
const message = serialized.map(([name$1, value]) => `${name$1}: ${value.trim()}`).join("\n");
|
|
66
67
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, new TextEncoder().encode(message));
|
|
67
68
|
const sigHeader = `keyId="${keyId.href}",algorithm="rsa-sha256",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
|
|
68
69
|
headers.set("Signature", sigHeader);
|
|
@@ -119,9 +120,7 @@ function createRfc9421SignatureBase(request, components, parameters) {
|
|
|
119
120
|
* @returns The formatted signature string.
|
|
120
121
|
*/
|
|
121
122
|
function formatRfc9421Signature(signature, components, parameters) {
|
|
122
|
-
|
|
123
|
-
const signatureValue = `sig1=:${encodeBase64(signature)}:`;
|
|
124
|
-
return [signatureInputValue, signatureValue];
|
|
123
|
+
return [`sig1=("${components.join("\" \"")}");${parameters}`, `sig1=:${encodeBase64(signature)}:`];
|
|
125
124
|
}
|
|
126
125
|
/**
|
|
127
126
|
* Parse RFC 9421 Signature-Input header.
|
|
@@ -251,11 +250,11 @@ const supportedHashAlgorithms = {
|
|
|
251
250
|
* could not be verified.
|
|
252
251
|
*/
|
|
253
252
|
async function verifyRequest(request, options = {}) {
|
|
254
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
253
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
255
254
|
if (span.isRecording()) {
|
|
256
255
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
257
256
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
258
|
-
for (const [name, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
|
|
257
|
+
for (const [name$1, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
|
|
259
258
|
}
|
|
260
259
|
try {
|
|
261
260
|
let spec = options.spec;
|
|
@@ -438,7 +437,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
438
437
|
logger.debug("Failed to verify; required headers missing in the Signature header: {headers}.", { headers });
|
|
439
438
|
return null;
|
|
440
439
|
}
|
|
441
|
-
const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
|
|
440
|
+
const message = headerNames.map((name$1) => `${name$1}: ` + (name$1 === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name$1 === "(created)" ? sigValues.created ?? "" : name$1 === "(expires)" ? sigValues.expires ?? "" : name$1 === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name$1))).join("\n");
|
|
442
441
|
const sig = decodeBase64(signature);
|
|
443
442
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
444
443
|
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
@@ -605,8 +604,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
605
604
|
logger.debug("Failed to verify; Content-Digest header required but not found.", { components: sigInput.components });
|
|
606
605
|
continue;
|
|
607
606
|
}
|
|
608
|
-
|
|
609
|
-
if (!await verifyRfc9421ContentDigest(contentDigestHeader, body)) {
|
|
607
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
|
|
610
608
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
611
609
|
continue;
|
|
612
610
|
}
|
|
@@ -728,13 +726,11 @@ async function doubleKnock(request, identity, options = {}) {
|
|
|
728
726
|
});
|
|
729
727
|
log?.(signedRequest);
|
|
730
728
|
let response = await fetch(signedRequest, { redirect: "manual" });
|
|
731
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
});
|
|
737
|
-
} else if (response.status === 400 || response.status === 401 || response.status > 401) {
|
|
729
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(createRedirectRequest(request, response.headers.get("Location"), body), identity, {
|
|
730
|
+
...options,
|
|
731
|
+
body
|
|
732
|
+
});
|
|
733
|
+
else if (response.status === 400 || response.status === 401 || response.status > 401) {
|
|
738
734
|
const spec = firstTrySpec === "draft-cavage-http-signatures-12" ? "rfc9421" : "draft-cavage-http-signatures-12";
|
|
739
735
|
getLogger([
|
|
740
736
|
"fedify",
|
|
@@ -753,13 +749,11 @@ async function doubleKnock(request, identity, options = {}) {
|
|
|
753
749
|
});
|
|
754
750
|
log?.(signedRequest);
|
|
755
751
|
response = await fetch(signedRequest, { redirect: "manual" });
|
|
756
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
});
|
|
762
|
-
} else if (response.status !== 400 && response.status !== 401) await specDeterminer?.rememberSpec(origin, spec);
|
|
752
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(createRedirectRequest(request, response.headers.get("Location"), body), identity, {
|
|
753
|
+
...options,
|
|
754
|
+
body
|
|
755
|
+
});
|
|
756
|
+
else if (response.status !== 400 && response.status !== 401) await specDeterminer?.rememberSpec(origin, spec);
|
|
763
757
|
} else await specDeterminer?.rememberSpec(origin, firstTrySpec);
|
|
764
758
|
return response;
|
|
765
759
|
}
|
|
@@ -792,4 +786,4 @@ function timingSafeEqual(a, b) {
|
|
|
792
786
|
}
|
|
793
787
|
|
|
794
788
|
//#endregion
|
|
795
|
-
export { doubleKnock, signRequest,
|
|
789
|
+
export { parseRfc9421Signature as a, timingSafeEqual as c, formatRfc9421SignatureParameters as i, verifyRequest as l, doubleKnock as n, parseRfc9421SignatureInput as o, formatRfc9421Signature as r, signRequest as s, createRfc9421SignatureBase as t };
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { Activity } from "./vocab
|
|
8
|
-
import { getTypeId } from "./type
|
|
6
|
+
import { d as version, u as name } from "./docloader.js";
|
|
7
|
+
import { t as Activity } from "./vocab.js";
|
|
8
|
+
import { t as getTypeId } from "./type.js";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
11
11
|
|
|
@@ -112,7 +112,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
112
112
|
return "enqueued";
|
|
113
113
|
}
|
|
114
114
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
115
|
-
return await tracerProvider.getTracer(
|
|
115
|
+
return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
|
|
116
116
|
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
117
117
|
if (dispatched == null) {
|
|
118
118
|
logger.error("Unsupported activity type:\n{activity}", {
|
|
@@ -166,4 +166,4 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
//#endregion
|
|
169
|
-
export {
|
|
169
|
+
export { routeActivity as n, InboxListenerSet as t };
|
package/dist/key.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
5
|
+
|
|
6
|
+
import "./chunk.js";
|
|
7
|
+
import "./docloader.js";
|
|
8
|
+
import "./url.js";
|
|
9
|
+
import "./multibase.js";
|
|
10
|
+
import "./vocab.js";
|
|
11
|
+
import "./langstr.js";
|
|
12
|
+
import "./lookup.js";
|
|
13
|
+
import "./actor.js";
|
|
14
|
+
import { a as validateCryptoKey, i as importJwk, n as fetchKey, r as generateCryptoKeyPair, t as exportJwk } from "./key2.js";
|
|
15
|
+
|
|
16
|
+
export { validateCryptoKey };
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { isActor } from "./actor
|
|
6
|
+
import { d as version, i as getDocumentLoader, u as name } from "./docloader.js";
|
|
7
|
+
import { _ as Object$1, o as CryptographicKey } from "./vocab.js";
|
|
8
|
+
import { i as isActor } from "./actor.js";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
11
11
|
|
|
@@ -102,7 +102,7 @@ async function importJwk(jwk, type) {
|
|
|
102
102
|
* @since 1.3.0
|
|
103
103
|
*/
|
|
104
104
|
function fetchKey(keyId, cls, options = {}) {
|
|
105
|
-
const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
105
|
+
const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version);
|
|
106
106
|
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
107
107
|
return tracer.startActiveSpan("activitypub.fetch_key", {
|
|
108
108
|
kind: SpanKind.CLIENT,
|
|
@@ -256,4 +256,4 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//#endregion
|
|
259
|
-
export {
|
|
259
|
+
export { validateCryptoKey as a, importJwk as i, fetchKey as n, generateCryptoKeyPair as r, exportJwk as t };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { h as Multikey, o as CryptographicKey } from "./vocab.js";
|
|
7
7
|
|
|
8
8
|
//#region federation/keycache.ts
|
|
9
9
|
var KvKeyCache = class {
|
|
@@ -45,4 +45,4 @@ var KvKeyCache = class {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
export { KvKeyCache };
|
|
48
|
+
export { KvKeyCache as t };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { P as importSpki, h as Multikey, o as CryptographicKey } from "./vocab.js";
|
|
7
7
|
|
|
8
8
|
//#region testing/keys.ts
|
|
9
9
|
const rsaPublicKey1 = new CryptographicKey({
|
|
@@ -120,4 +120,4 @@ const ed25519Multikey = new Multikey({
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
//#endregion
|
|
123
|
-
export {
|
|
123
|
+
export { rsaPrivateKey3 as a, rsaPublicKey3 as c, rsaPrivateKey2 as i, rsaPublicKey5 as l, ed25519PrivateKey as n, rsaPublicKey1 as o, ed25519PublicKey as r, rsaPublicKey2 as s, ed25519Multikey as t };
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { getTypeId } from "./type
|
|
9
|
-
import {
|
|
6
|
+
import { d as version, i as getDocumentLoader, u as name } from "./docloader.js";
|
|
7
|
+
import { _ as Object$1, o as CryptographicKey, t as Activity } from "./vocab.js";
|
|
8
|
+
import { t as getTypeId } from "./type.js";
|
|
9
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key2.js";
|
|
10
10
|
import { getLogger } from "@logtape/logtape";
|
|
11
11
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
12
12
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
@@ -54,9 +54,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
54
54
|
creator: keyId.href,
|
|
55
55
|
created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
56
56
|
};
|
|
57
|
-
const
|
|
58
|
-
const docHash = await hashJsonLd(jsonLd, contextLoader);
|
|
59
|
-
const message = optionsHash + docHash;
|
|
57
|
+
const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
|
|
60
58
|
const messageBytes = new TextEncoder().encode(message);
|
|
61
59
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
|
|
62
60
|
return {
|
|
@@ -79,7 +77,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
79
77
|
* @since 1.0.0
|
|
80
78
|
*/
|
|
81
79
|
async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
82
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
80
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
83
81
|
try {
|
|
84
82
|
const signature = await createSignature(jsonLd, privateKey, keyId, options);
|
|
85
83
|
if (span.isRecording()) {
|
|
@@ -214,7 +212,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
214
212
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
215
213
|
*/
|
|
216
214
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
217
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
215
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
218
216
|
try {
|
|
219
217
|
const object = await Object$1.fromJsonLd(jsonLd, options);
|
|
220
218
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
@@ -255,9 +253,8 @@ async function hashJsonLd(jsonLd, contextLoader) {
|
|
|
255
253
|
documentLoader: contextLoader ?? getDocumentLoader()
|
|
256
254
|
});
|
|
257
255
|
const encoder = new TextEncoder();
|
|
258
|
-
|
|
259
|
-
return encodeHex(hash);
|
|
256
|
+
return encodeHex(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
|
|
260
257
|
}
|
|
261
258
|
|
|
262
259
|
//#endregion
|
|
263
|
-
export {
|
|
260
|
+
export { signJsonLd as a, hasSignature as i, createSignature as n, verifyJsonLd as o, detachSignature as r, verifySignature as s, attachSignature as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { GetUserAgentOptions } from "./docloader
|
|
3
|
+
import { s as GetUserAgentOptions } from "./docloader.js";
|
|
4
4
|
import { TracerProvider } from "@opentelemetry/api";
|
|
5
5
|
|
|
6
6
|
//#region webfinger/jrd.d.ts
|
|
@@ -93,4 +93,4 @@ interface LookupWebFingerOptions {
|
|
|
93
93
|
*/
|
|
94
94
|
declare function lookupWebFinger(resource: URL | string, options?: LookupWebFingerOptions): Promise<ResourceDescriptor | null>;
|
|
95
95
|
//#endregion
|
|
96
|
-
export {
|
|
96
|
+
export { ResourceDescriptor as i, lookupWebFinger as n, Link as r, LookupWebFingerOptions as t };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { d as version, o as getUserAgent, u as name } from "./docloader.js";
|
|
7
|
+
import { a as validatePublicUrl, t as UrlError } from "./url.js";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ const MAX_REDIRECTION = 5;
|
|
|
23
23
|
* @since 0.2.0
|
|
24
24
|
*/
|
|
25
25
|
async function lookupWebFinger(resource, options = {}) {
|
|
26
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
26
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("webfinger.lookup", {
|
|
27
27
|
kind: SpanKind.CLIENT,
|
|
28
28
|
attributes: {
|
|
29
29
|
"webfinger.resource": resource.toString(),
|
|
@@ -126,4 +126,4 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
//#endregion
|
|
129
|
-
export { lookupWebFinger };
|
|
129
|
+
export { lookupWebFinger as t };
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { lookupWebFinger } from "./lookup
|
|
9
|
-
import { getTypeId } from "./type
|
|
6
|
+
import { d as version, i as getDocumentLoader, u as name } from "./docloader.js";
|
|
7
|
+
import { _ as Object$1 } from "./vocab.js";
|
|
8
|
+
import { t as lookupWebFinger } from "./lookup.js";
|
|
9
|
+
import { t as getTypeId } from "./type.js";
|
|
10
10
|
import { getLogger } from "@logtape/logtape";
|
|
11
11
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
12
12
|
import { delay } from "@es-toolkit/es-toolkit";
|
|
@@ -51,7 +51,7 @@ const handleRegexp = /^@?((?:[-A-Za-z0-9._~!$&'()*+,;=]|%[A-Fa-f0-9]{2})+)@([^@]
|
|
|
51
51
|
* @since 0.2.0
|
|
52
52
|
*/
|
|
53
53
|
async function lookupObject(identifier, options = {}) {
|
|
54
|
-
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(
|
|
54
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.lookup_object", async (span) => {
|
|
55
55
|
try {
|
|
56
56
|
const result = await lookupObjectInternal(identifier, options);
|
|
57
57
|
if (result == null) span.setStatus({ code: SpanStatusCode.ERROR });
|
|
@@ -155,4 +155,4 @@ async function* traverseCollection(collection, options = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
//#endregion
|
|
158
|
-
export {
|
|
158
|
+
export { traverseCollection as n, lookupObject as t };
|