@fedify/fedify 1.7.11 → 1.7.12
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-DgWryCk8.js → actor-GZRoTRqg.js} +1059 -2276
- package/dist/{actor-2ENhJMd7.js → actor-TYqJGdVq.js} +6 -9
- package/dist/{assert-DmFG7ppO.js → assert-LOEeCUK5.js} +1 -1
- package/dist/{assert_equals-CTYbeopb.js → assert_equals-B44MxcIj.js} +2 -4
- package/dist/{assert_instance_of-CF09JHYM.js → assert_instance_of-XtuFevV_.js} +1 -1
- package/dist/{assert_is_error-nrwA1GeT.js → assert_is_error-BTlryvT0.js} +1 -1
- package/dist/{assert_not_equals-Dc7y-V5Q.js → assert_not_equals-C685gKx6.js} +1 -1
- package/dist/{assert_rejects-C-sxEMM5.js → assert_rejects-DWQ4jaf9.js} +2 -2
- package/dist/{assert_throws-Cn9C6Jur.js → assert_throws-YetpVSc-.js} +2 -2
- package/dist/{authdocloader-BUJAQQAE.js → authdocloader-BopfyipD.js} +3 -3
- package/dist/{authdocloader-CK17fG7y.js → authdocloader-hiFSyM7V.js} +4 -4
- package/dist/{builder-CZM8EtHh.js → builder-mi6RdzNE.js} +7 -10
- package/dist/{chunk-HsBuZ-b2.js → chunk-Cx8LTkjm.js} +3 -1
- package/dist/{client-D83KwIk4.js → client-DuUKk4pk.js} +6 -6
- package/dist/compat/transformers.test.js +27 -28
- package/dist/{context-MUHrGcK9.js → context-RMU32mk4.js} +2 -2
- package/dist/{docloader-BcyuO_kK.js → docloader-DJxET2fN.js} +5 -9
- package/dist/{docloader-D4wl8z_4.js → docloader-bgBm1Hd1.js} +4 -6
- package/dist/{esm-Db4De7AS.js → esm-DO9PrujO.js} +23 -34
- package/dist/federation/builder.test.js +23 -29
- package/dist/federation/collection.test.js +9 -9
- package/dist/federation/handler.test.js +33 -33
- package/dist/federation/inbox.test.js +10 -10
- package/dist/federation/keycache.test.js +9 -9
- package/dist/federation/kv.test.js +10 -9
- package/dist/federation/middleware.test.js +76 -99
- package/dist/federation/mod.js +11 -11
- package/dist/federation/mq.test.js +10 -11
- package/dist/federation/retry.test.js +3 -3
- package/dist/federation/router.test.js +9 -9
- package/dist/federation/send.test.js +22 -22
- package/dist/{federation-BRIQn-GV.js → federation-B0aljx0V.js} +1 -2
- package/dist/{http-DFHfa9tA.js → http-D2DkwsjA.js} +8 -15
- package/dist/{http-Dsj_eYDw.js → http-vqMAvOVs.js} +8 -15
- package/dist/{inbox-CltmHpHc.js → inbox-DAAZZl2k.js} +5 -7
- package/dist/key-5ssHQ67E.js +16 -0
- package/dist/{key-bBurC_PZ.js → key-DSJGnD10.js} +4 -4
- package/dist/{key-qFVeObG1.js → key-DmqJj57e.js} +5 -8
- package/dist/{key-bttcdrh5.js → key-KVhaUM92.js} +6 -9
- package/dist/{keycache-DijbBawF.js → keycache-C1pEuRyQ.js} +2 -2
- package/dist/{keys-DJ5t4jB4.js → keys-C4XQHW5_.js} +1 -1
- package/dist/{ld-U-lGfuzj.js → ld-DzlJ_IpT.js} +9 -16
- package/dist/{lookup-BlPHJ-Ff.js → lookup-CSngxuWm.js} +2 -4
- package/dist/{lookup-C8ZpflGI.js → lookup-D0je8AqR.js} +7 -11
- package/dist/{lookup-BGqnk7rW.js → lookup-DL62q3Xh.js} +3 -5
- package/dist/{middleware-D66R1UZl.js → middleware-3wVT6S9E.js} +34 -52
- package/dist/middleware-CxFoFBD8.js +33 -0
- package/dist/{middleware-BRzqW-QG.js → middleware-DlDXugwZ.js} +34 -58
- package/dist/middleware-w7_U3fFi.js +17 -0
- package/dist/mod.js +11 -11
- package/dist/{multibase-DeCHcK8L.js → multibase-CnLHszip.js} +1 -2
- package/dist/nodeinfo/client.test.js +20 -23
- package/dist/nodeinfo/handler.test.js +32 -32
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/semver.test.js +23 -30
- package/dist/nodeinfo/types.test.js +11 -11
- package/dist/{owner-2zho-3Ew.js → owner-81ey_76X.js} +3 -3
- package/dist/{proof-BYHc1mMr.js → proof-BlULDH4H.js} +8 -14
- package/dist/{proof-3J23UdVg.js → proof-DlI7QNdn.js} +12 -25
- package/dist/runtime/authdocloader.test.js +21 -21
- package/dist/runtime/docloader.test.js +16 -18
- package/dist/runtime/key.test.js +17 -17
- package/dist/runtime/langstr.test.js +9 -9
- package/dist/runtime/mod.js +6 -6
- package/dist/runtime/multibase/multibase.test.js +11 -12
- package/dist/runtime/url.test.js +6 -6
- package/dist/{semver-DWClQt_5.js → semver-BNrOOAs9.js} +1 -3
- package/dist/{send-CW7iJ-b9.js → send-DdxfTHo6.js} +3 -4
- package/dist/sig/http.test.js +40 -54
- package/dist/sig/key.test.js +18 -18
- package/dist/sig/ld.test.js +20 -22
- package/dist/sig/mod.js +6 -6
- package/dist/sig/owner.test.js +20 -20
- package/dist/sig/proof.test.js +19 -19
- package/dist/{std__assert-vp0TKMS1.js → std__assert-o_r9vqm1.js} +1 -1
- package/dist/testing/docloader.test.js +9 -9
- package/dist/testing/mod.js +1 -1
- package/dist/{testing-BZ0dJ4qn.js → testing-DLyvtiiW.js} +3 -5
- package/dist/{type-D2s5lmbZ.js → type-CFuiGLz9.js} +1 -2
- package/dist/{types-C7C_l-jz.js → types-CJHS5pXl.js} +1 -1
- package/dist/{types-DXmLob1B.js → types-CmVV9LT1.js} +6 -8
- package/dist/{url-kTAI6_KP.js → url-C2xuoQD1.js} +2 -4
- package/dist/vocab/actor.test.js +104 -156
- package/dist/vocab/lookup.test.js +17 -17
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +11 -15
- package/dist/vocab/vocab.test.js +45 -49
- package/dist/{vocab-Cy9XhW_T.js → vocab-BebR0kAy.js} +6 -10
- package/dist/{vocab-BojAnGjI.js → vocab-DFlq4Wa6.js} +1057 -2270
- package/dist/webfinger/handler.test.js +33 -34
- package/dist/webfinger/lookup.test.js +13 -13
- package/dist/webfinger/mod.js +2 -2
- package/dist/x/cfworkers.test.js +9 -9
- package/package.json +1 -1
- package/dist/key-BROjrzkW.js +0 -16
- package/dist/middleware-BhqeOJrC.js +0 -17
- package/dist/middleware-DFra19vb.js +0 -33
package/dist/federation/mod.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
5
|
import "../transformers-ghwJuzGY.js";
|
|
6
|
-
import "../docloader-
|
|
7
|
-
import "../actor-
|
|
8
|
-
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-
|
|
9
|
-
import "../lookup-
|
|
10
|
-
import "../key-
|
|
11
|
-
import "../http-
|
|
12
|
-
import "../proof-
|
|
13
|
-
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-
|
|
14
|
-
import "../types-
|
|
15
|
-
import "../authdocloader-
|
|
16
|
-
import "../vocab-
|
|
6
|
+
import "../docloader-DJxET2fN.js";
|
|
7
|
+
import "../actor-GZRoTRqg.js";
|
|
8
|
+
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-DlDXugwZ.js";
|
|
9
|
+
import "../lookup-CSngxuWm.js";
|
|
10
|
+
import "../key-DmqJj57e.js";
|
|
11
|
+
import "../http-vqMAvOVs.js";
|
|
12
|
+
import "../proof-DlI7QNdn.js";
|
|
13
|
+
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-B0aljx0V.js";
|
|
14
|
+
import "../types-CmVV9LT1.js";
|
|
15
|
+
import "../authdocloader-BopfyipD.js";
|
|
16
|
+
import "../vocab-BebR0kAy.js";
|
|
17
17
|
|
|
18
18
|
export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { assertEquals } from "../assert_equals-
|
|
7
|
-
import { assert } from "../assert-
|
|
8
|
-
import "../assert_instance_of-
|
|
9
|
-
import { test } from "../testing-
|
|
10
|
-
import { assertGreater, assertGreaterOrEqual } from "../std__assert-
|
|
11
|
-
import { assertFalse } from "../assert_rejects-
|
|
12
|
-
import "../assert_is_error-
|
|
13
|
-
import "../assert_not_equals-
|
|
14
|
-
import "../assert_throws-
|
|
6
|
+
import { assertEquals } from "../assert_equals-B44MxcIj.js";
|
|
7
|
+
import { assert } from "../assert-LOEeCUK5.js";
|
|
8
|
+
import "../assert_instance_of-XtuFevV_.js";
|
|
9
|
+
import { test } from "../testing-DLyvtiiW.js";
|
|
10
|
+
import { assertGreater, assertGreaterOrEqual } from "../std__assert-o_r9vqm1.js";
|
|
11
|
+
import { assertFalse } from "../assert_rejects-DWQ4jaf9.js";
|
|
12
|
+
import "../assert_is_error-BTlryvT0.js";
|
|
13
|
+
import "../assert_not_equals-C685gKx6.js";
|
|
14
|
+
import "../assert_throws-YetpVSc-.js";
|
|
15
15
|
import { delay } from "@es-toolkit/es-toolkit";
|
|
16
16
|
|
|
17
17
|
//#region federation/mq.ts
|
|
@@ -136,8 +136,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
136
136
|
}
|
|
137
137
|
async enqueueMany(messages, options) {
|
|
138
138
|
if (this.queue.enqueueMany == null) {
|
|
139
|
-
const
|
|
140
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
139
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
141
140
|
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
142
141
|
else if (errors.length === 1) throw errors[0];
|
|
143
142
|
return;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { AssertionError, assertEquals } from "../assert_equals-
|
|
6
|
+
import { AssertionError, assertEquals } from "../assert_equals-B44MxcIj.js";
|
|
7
7
|
import { createExponentialBackoffPolicy } from "../retry-BiIhZWgD.js";
|
|
8
|
-
import { test } from "../testing-
|
|
9
|
-
import { assertNotEquals } from "../assert_not_equals-
|
|
8
|
+
import { test } from "../testing-DLyvtiiW.js";
|
|
9
|
+
import { assertNotEquals } from "../assert_not_equals-C685gKx6.js";
|
|
10
10
|
|
|
11
11
|
//#region federation/retry.test.ts
|
|
12
12
|
test("createExponentialBackoffPolicy()", () => {
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { assertEquals } from "../assert_equals-
|
|
7
|
-
import { assert } from "../assert-
|
|
8
|
-
import "../assert_instance_of-
|
|
6
|
+
import { assertEquals } from "../assert_equals-B44MxcIj.js";
|
|
7
|
+
import { assert } from "../assert-LOEeCUK5.js";
|
|
8
|
+
import "../assert_instance_of-XtuFevV_.js";
|
|
9
9
|
import { Router, RouterError } from "../router-D_aVZZUc.js";
|
|
10
|
-
import { test } from "../testing-
|
|
11
|
-
import "../std__assert-
|
|
12
|
-
import { assertFalse } from "../assert_rejects-
|
|
13
|
-
import "../assert_is_error-
|
|
14
|
-
import "../assert_not_equals-
|
|
15
|
-
import { assertThrows } from "../assert_throws-
|
|
10
|
+
import { test } from "../testing-DLyvtiiW.js";
|
|
11
|
+
import "../std__assert-o_r9vqm1.js";
|
|
12
|
+
import { assertFalse } from "../assert_rejects-DWQ4jaf9.js";
|
|
13
|
+
import "../assert_is_error-BTlryvT0.js";
|
|
14
|
+
import "../assert_not_equals-C685gKx6.js";
|
|
15
|
+
import { assertThrows } from "../assert_throws-YetpVSc-.js";
|
|
16
16
|
|
|
17
17
|
//#region federation/router.test.ts
|
|
18
18
|
function setUp(options = {}) {
|
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { assertEquals } from "../assert_equals-
|
|
7
|
-
import { assert } from "../assert-
|
|
8
|
-
import "../assert_instance_of-
|
|
9
|
-
import "../docloader-
|
|
10
|
-
import "../url-
|
|
11
|
-
import "../multibase-
|
|
12
|
-
import { Activity, Application, Endpoints, Group, Person, Service } from "../vocab-
|
|
6
|
+
import { assertEquals } from "../assert_equals-B44MxcIj.js";
|
|
7
|
+
import { assert } from "../assert-LOEeCUK5.js";
|
|
8
|
+
import "../assert_instance_of-XtuFevV_.js";
|
|
9
|
+
import "../docloader-bgBm1Hd1.js";
|
|
10
|
+
import "../url-C2xuoQD1.js";
|
|
11
|
+
import "../multibase-CnLHszip.js";
|
|
12
|
+
import { Activity, Application, Endpoints, Group, Person, Service } from "../vocab-DFlq4Wa6.js";
|
|
13
13
|
import "../langstr-DbWheeIS.js";
|
|
14
|
-
import "../lookup-
|
|
15
|
-
import "../type-
|
|
16
|
-
import "../actor-
|
|
17
|
-
import "../key-
|
|
18
|
-
import { verifyRequest } from "../http-
|
|
19
|
-
import { doesActorOwnKey } from "../owner-
|
|
20
|
-
import { extractInboxes, sendActivity } from "../send-
|
|
21
|
-
import { test } from "../testing-
|
|
22
|
-
import "../std__assert-
|
|
23
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
|
24
|
-
import "../assert_is_error-
|
|
25
|
-
import { assertNotEquals } from "../assert_not_equals-
|
|
26
|
-
import "../assert_throws-
|
|
14
|
+
import "../lookup-DL62q3Xh.js";
|
|
15
|
+
import "../type-CFuiGLz9.js";
|
|
16
|
+
import "../actor-TYqJGdVq.js";
|
|
17
|
+
import "../key-KVhaUM92.js";
|
|
18
|
+
import { verifyRequest } from "../http-D2DkwsjA.js";
|
|
19
|
+
import { doesActorOwnKey } from "../owner-81ey_76X.js";
|
|
20
|
+
import { extractInboxes, sendActivity } from "../send-DdxfTHo6.js";
|
|
21
|
+
import { test } from "../testing-DLyvtiiW.js";
|
|
22
|
+
import "../std__assert-o_r9vqm1.js";
|
|
23
|
+
import { assertFalse, assertRejects } from "../assert_rejects-DWQ4jaf9.js";
|
|
24
|
+
import "../assert_is_error-BTlryvT0.js";
|
|
25
|
+
import { assertNotEquals } from "../assert_not_equals-C685gKx6.js";
|
|
26
|
+
import "../assert_throws-YetpVSc-.js";
|
|
27
27
|
import { mockDocumentLoader } from "../docloader-09nVWLAZ.js";
|
|
28
|
-
import { ed25519Multikey, ed25519PrivateKey, rsaPrivateKey2, rsaPublicKey2 } from "../keys-
|
|
29
|
-
import { esm_default } from "../esm-
|
|
28
|
+
import { ed25519Multikey, ed25519PrivateKey, rsaPrivateKey2, rsaPublicKey2 } from "../keys-C4XQHW5_.js";
|
|
29
|
+
import { esm_default } from "../esm-DO9PrujO.js";
|
|
30
30
|
|
|
31
31
|
//#region federation/send.test.ts
|
|
32
32
|
test("extractInboxes()", () => {
|
|
@@ -170,8 +170,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
170
170
|
}
|
|
171
171
|
async enqueueMany(messages, options) {
|
|
172
172
|
if (this.queue.enqueueMany == null) {
|
|
173
|
-
const
|
|
174
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
173
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
175
174
|
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
176
175
|
else if (errors.length === 1) throw errors[0];
|
|
177
176
|
return;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { deno_default } from "./docloader-
|
|
7
|
-
import { CryptographicKey } from "./vocab-
|
|
8
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
|
6
|
+
import { deno_default } from "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import { CryptographicKey } from "./vocab-DFlq4Wa6.js";
|
|
8
|
+
import { fetchKey, validateCryptoKey } from "./key-KVhaUM92.js";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
11
11
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
@@ -25,9 +25,7 @@ import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
|
25
25
|
*/
|
|
26
26
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
27
27
|
validateCryptoKey(privateKey, "private");
|
|
28
|
-
|
|
29
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
30
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
28
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
31
29
|
try {
|
|
32
30
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
33
31
|
let signed;
|
|
@@ -254,9 +252,7 @@ const supportedHashAlgorithms = {
|
|
|
254
252
|
* could not be verified.
|
|
255
253
|
*/
|
|
256
254
|
async function verifyRequest(request, options = {}) {
|
|
257
|
-
|
|
258
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
259
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
255
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
260
256
|
if (span.isRecording()) {
|
|
261
257
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
262
258
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
@@ -446,8 +442,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
446
442
|
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");
|
|
447
443
|
const sig = decodeBase64(signature);
|
|
448
444
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
449
|
-
|
|
450
|
-
if (!verified) {
|
|
445
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
451
446
|
if (cached) {
|
|
452
447
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
453
448
|
keyId,
|
|
@@ -612,8 +607,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
612
607
|
continue;
|
|
613
608
|
}
|
|
614
609
|
const body = await request.arrayBuffer();
|
|
615
|
-
|
|
616
|
-
if (!digestValid) {
|
|
610
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, body)) {
|
|
617
611
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
618
612
|
continue;
|
|
619
613
|
}
|
|
@@ -659,8 +653,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
659
653
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
660
654
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
661
655
|
try {
|
|
662
|
-
|
|
663
|
-
if (verified) {
|
|
656
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
|
|
664
657
|
validKey = key;
|
|
665
658
|
break;
|
|
666
659
|
} else if (cached) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { deno_default } from "./docloader-
|
|
6
|
-
import { CryptographicKey } from "./actor-
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
|
5
|
+
import { deno_default } from "./docloader-DJxET2fN.js";
|
|
6
|
+
import { CryptographicKey } from "./actor-GZRoTRqg.js";
|
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-DmqJj57e.js";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
@@ -24,9 +24,7 @@ import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
|
24
24
|
*/
|
|
25
25
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
26
26
|
validateCryptoKey(privateKey, "private");
|
|
27
|
-
|
|
28
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
29
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
27
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
30
28
|
try {
|
|
31
29
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
32
30
|
let signed;
|
|
@@ -253,9 +251,7 @@ const supportedHashAlgorithms = {
|
|
|
253
251
|
* could not be verified.
|
|
254
252
|
*/
|
|
255
253
|
async function verifyRequest(request, options = {}) {
|
|
256
|
-
|
|
257
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
258
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
254
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
259
255
|
if (span.isRecording()) {
|
|
260
256
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
261
257
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
@@ -445,8 +441,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
445
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");
|
|
446
442
|
const sig = decodeBase64(signature);
|
|
447
443
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
448
|
-
|
|
449
|
-
if (!verified) {
|
|
444
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
450
445
|
if (cached) {
|
|
451
446
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
452
447
|
keyId,
|
|
@@ -611,8 +606,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
611
606
|
continue;
|
|
612
607
|
}
|
|
613
608
|
const body = await request.arrayBuffer();
|
|
614
|
-
|
|
615
|
-
if (!digestValid) {
|
|
609
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, body)) {
|
|
616
610
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
617
611
|
continue;
|
|
618
612
|
}
|
|
@@ -658,8 +652,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
658
652
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
659
653
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
660
654
|
try {
|
|
661
|
-
|
|
662
|
-
if (verified) {
|
|
655
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
|
|
663
656
|
validKey = key;
|
|
664
657
|
break;
|
|
665
658
|
} else if (cached) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { deno_default } from "./docloader-
|
|
7
|
-
import { Activity } from "./vocab-
|
|
8
|
-
import { getTypeId } from "./type-
|
|
6
|
+
import { deno_default } from "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import { Activity } from "./vocab-DFlq4Wa6.js";
|
|
8
|
+
import { getTypeId } from "./type-CFuiGLz9.js";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
11
11
|
|
|
@@ -55,8 +55,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
55
55
|
activity.id.href
|
|
56
56
|
];
|
|
57
57
|
if (cacheKey != null) {
|
|
58
|
-
|
|
59
|
-
if (cached === true) {
|
|
58
|
+
if (await kv.get(cacheKey) === true) {
|
|
60
59
|
logger.debug("Activity {activityId} has already been processed.", {
|
|
61
60
|
activityId: activity.id?.href,
|
|
62
61
|
activity: json,
|
|
@@ -113,8 +112,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
113
112
|
return "enqueued";
|
|
114
113
|
}
|
|
115
114
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
116
|
-
|
|
117
|
-
return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
|
|
115
|
+
return await tracerProvider.getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span$1) => {
|
|
118
116
|
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
119
117
|
if (dispatched == null) {
|
|
120
118
|
logger.error("Unsupported activity type:\n{activity}", {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
5
|
+
|
|
6
|
+
import "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import "./url-C2xuoQD1.js";
|
|
8
|
+
import "./multibase-CnLHszip.js";
|
|
9
|
+
import "./vocab-DFlq4Wa6.js";
|
|
10
|
+
import "./langstr-DbWheeIS.js";
|
|
11
|
+
import "./lookup-DL62q3Xh.js";
|
|
12
|
+
import "./type-CFuiGLz9.js";
|
|
13
|
+
import "./actor-TYqJGdVq.js";
|
|
14
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-KVhaUM92.js";
|
|
15
|
+
|
|
16
|
+
export { validateCryptoKey };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import "./docloader-
|
|
6
|
-
import "./actor-
|
|
7
|
-
import "./lookup-
|
|
8
|
-
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-
|
|
5
|
+
import "./docloader-DJxET2fN.js";
|
|
6
|
+
import "./actor-GZRoTRqg.js";
|
|
7
|
+
import "./lookup-CSngxuWm.js";
|
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-DmqJj57e.js";
|
|
9
9
|
|
|
10
10
|
export { validateCryptoKey };
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
|
6
|
-
import { CryptographicKey, Object as Object$1, isActor } from "./actor-
|
|
5
|
+
import { deno_default, getDocumentLoader } from "./docloader-DJxET2fN.js";
|
|
6
|
+
import { CryptographicKey, Object as Object$1, isActor } from "./actor-GZRoTRqg.js";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
|
|
@@ -21,8 +21,7 @@ function validateCryptoKey(key, type) {
|
|
|
21
21
|
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
|
22
22
|
if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
|
|
23
23
|
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
24
|
-
|
|
25
|
-
if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
24
|
+
if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
@@ -101,8 +100,7 @@ async function importJwk(jwk, type) {
|
|
|
101
100
|
* @since 1.3.0
|
|
102
101
|
*/
|
|
103
102
|
function fetchKey(keyId, cls, options = {}) {
|
|
104
|
-
const
|
|
105
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
103
|
+
const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version);
|
|
106
104
|
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
107
105
|
return tracer.startActiveSpan("activitypub.fetch_key", {
|
|
108
106
|
kind: SpanKind.CLIENT,
|
|
@@ -158,8 +156,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
158
156
|
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
159
157
|
let document;
|
|
160
158
|
try {
|
|
161
|
-
|
|
162
|
-
document = remoteDocument.document;
|
|
159
|
+
document = (await (documentLoader ?? getDocumentLoader())(keyId)).document;
|
|
163
160
|
} catch (_) {
|
|
164
161
|
logger.debug("Failed to fetch key {keyId}.", { keyId });
|
|
165
162
|
await keyCache?.set(cacheKey, null);
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
|
7
|
-
import { CryptographicKey, Object as Object$1 } from "./vocab-
|
|
8
|
-
import { isActor } from "./actor-
|
|
6
|
+
import { deno_default, getDocumentLoader } from "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import { CryptographicKey, Object as Object$1 } from "./vocab-DFlq4Wa6.js";
|
|
8
|
+
import { isActor } from "./actor-TYqJGdVq.js";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
11
11
|
|
|
@@ -23,8 +23,7 @@ function validateCryptoKey(key, type) {
|
|
|
23
23
|
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
|
24
24
|
if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
|
|
25
25
|
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
26
|
-
|
|
27
|
-
if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
26
|
+
if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
@@ -103,8 +102,7 @@ async function importJwk(jwk, type) {
|
|
|
103
102
|
* @since 1.3.0
|
|
104
103
|
*/
|
|
105
104
|
function fetchKey(keyId, cls, options = {}) {
|
|
106
|
-
const
|
|
107
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
105
|
+
const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version);
|
|
108
106
|
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
|
109
107
|
return tracer.startActiveSpan("activitypub.fetch_key", {
|
|
110
108
|
kind: SpanKind.CLIENT,
|
|
@@ -160,8 +158,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
|
|
|
160
158
|
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
|
161
159
|
let document;
|
|
162
160
|
try {
|
|
163
|
-
|
|
164
|
-
document = remoteDocument.document;
|
|
161
|
+
document = (await (documentLoader ?? getDocumentLoader())(keyId)).document;
|
|
165
162
|
} catch (_) {
|
|
166
163
|
logger.debug("Failed to fetch key {keyId}.", { keyId });
|
|
167
164
|
await keyCache?.set(cacheKey, null);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { CryptographicKey, Multikey } from "./vocab-
|
|
6
|
+
import { CryptographicKey, Multikey } from "./vocab-DFlq4Wa6.js";
|
|
7
7
|
|
|
8
8
|
//#region federation/keycache.ts
|
|
9
9
|
var KvKeyCache = class {
|
|
@@ -28,7 +28,7 @@ var KvKeyCache = class {
|
|
|
28
28
|
return await Multikey.fromJsonLd(serialized, this.options);
|
|
29
29
|
} catch {
|
|
30
30
|
await this.kv.delete([...this.prefix, keyId.href]);
|
|
31
|
-
return
|
|
31
|
+
return;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { CryptographicKey, Multikey, importSpki } from "./vocab-
|
|
6
|
+
import { CryptographicKey, Multikey, importSpki } from "./vocab-DFlq4Wa6.js";
|
|
7
7
|
|
|
8
8
|
//#region testing/keys.ts
|
|
9
9
|
const rsaPublicKey1 = new CryptographicKey({
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
|
7
|
-
import { Activity, CryptographicKey, Object as Object$1 } from "./vocab-
|
|
8
|
-
import { getTypeId } from "./type-
|
|
9
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
|
6
|
+
import { deno_default, getDocumentLoader } from "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import { Activity, CryptographicKey, Object as Object$1 } from "./vocab-DFlq4Wa6.js";
|
|
8
|
+
import { getTypeId } from "./type-CFuiGLz9.js";
|
|
9
|
+
import { fetchKey, validateCryptoKey } from "./key-KVhaUM92.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";
|
|
@@ -57,8 +57,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
57
57
|
const optionsHash = await hashJsonLd(options, contextLoader);
|
|
58
58
|
const docHash = await hashJsonLd(jsonLd, contextLoader);
|
|
59
59
|
const message = optionsHash + docHash;
|
|
60
|
-
const
|
|
61
|
-
const messageBytes = encoder.encode(message);
|
|
60
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
62
61
|
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
|
|
63
62
|
return {
|
|
64
63
|
...options,
|
|
@@ -80,9 +79,7 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
|
|
|
80
79
|
* @since 1.0.0
|
|
81
80
|
*/
|
|
82
81
|
async function signJsonLd(jsonLd, privateKey, keyId, options) {
|
|
83
|
-
|
|
84
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
85
|
-
return await tracer.startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
82
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("ld_signatures.sign", { attributes: { "ld_signatures.key_id": keyId.href } }, async (span) => {
|
|
86
83
|
try {
|
|
87
84
|
const signature = await createSignature(jsonLd, privateKey, keyId, options);
|
|
88
85
|
if (span.isRecording()) {
|
|
@@ -184,8 +181,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
184
181
|
const encoder = new TextEncoder();
|
|
185
182
|
const message = sigOptsHash + docHash;
|
|
186
183
|
const messageBytes = encoder.encode(message);
|
|
187
|
-
|
|
188
|
-
if (verified) return key;
|
|
184
|
+
if (await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, signature.slice(), messageBytes)) return key;
|
|
189
185
|
if (cached) {
|
|
190
186
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signatureValue} is invalid. Retrying with the freshly fetched key...", {
|
|
191
187
|
keyId: sig.creator,
|
|
@@ -199,8 +195,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
199
195
|
}
|
|
200
196
|
});
|
|
201
197
|
if (key$1 == null) return null;
|
|
202
|
-
|
|
203
|
-
return verified$1 ? key$1 : null;
|
|
198
|
+
return await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key$1.publicKey, signature.slice(), messageBytes) ? key$1 : null;
|
|
204
199
|
}
|
|
205
200
|
logger.debug("Failed to verify with the fetched key {keyId}; signature {signatureValue} is invalid. Check if the key is correct or if the signed message is correct. The message to sign is:\n{message}", {
|
|
206
201
|
keyId: sig.creator,
|
|
@@ -219,9 +214,7 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
219
214
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
220
215
|
*/
|
|
221
216
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
222
|
-
|
|
223
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
224
|
-
return await tracer.startActiveSpan("ld_signatures.verify", async (span) => {
|
|
217
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
225
218
|
try {
|
|
226
219
|
const object = await Object$1.fromJsonLd(jsonLd, options);
|
|
227
220
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-
|
|
5
|
+
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-DJxET2fN.js";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
|
|
@@ -21,9 +21,7 @@ const MAX_REDIRECTION = 5;
|
|
|
21
21
|
* @since 0.2.0
|
|
22
22
|
*/
|
|
23
23
|
async function lookupWebFinger(resource, options = {}) {
|
|
24
|
-
|
|
25
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
26
|
-
return await tracer.startActiveSpan("webfinger.lookup", {
|
|
24
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("webfinger.lookup", {
|
|
27
25
|
kind: SpanKind.CLIENT,
|
|
28
26
|
attributes: {
|
|
29
27
|
"webfinger.resource": resource.toString(),
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
|
7
|
-
import { Object as Object$1 } from "./vocab-
|
|
8
|
-
import { lookupWebFinger } from "./lookup-
|
|
9
|
-
import { getTypeId } from "./type-
|
|
6
|
+
import { deno_default, getDocumentLoader } from "./docloader-bgBm1Hd1.js";
|
|
7
|
+
import { Object as Object$1 } from "./vocab-DFlq4Wa6.js";
|
|
8
|
+
import { lookupWebFinger } from "./lookup-DL62q3Xh.js";
|
|
9
|
+
import { getTypeId } from "./type-CFuiGLz9.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,9 +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
|
-
|
|
55
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
56
|
-
return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
|
|
54
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(deno_default.name, deno_default.version).startActiveSpan("activitypub.lookup_object", async (span) => {
|
|
57
55
|
try {
|
|
58
56
|
const result = await lookupObjectInternal(identifier, options);
|
|
59
57
|
if (result == null) span.setStatus({ code: SpanStatusCode.ERROR });
|
|
@@ -83,8 +81,7 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
|
83
81
|
}
|
|
84
82
|
let document = null;
|
|
85
83
|
if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
|
|
86
|
-
|
|
87
|
-
document = remoteDoc.document;
|
|
84
|
+
document = (await documentLoader(identifier.href)).document;
|
|
88
85
|
} catch (error) {
|
|
89
86
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
|
90
87
|
}
|
|
@@ -98,8 +95,7 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
|
98
95
|
for (const l of jrd.links) {
|
|
99
96
|
if (l.type !== "application/activity+json" && !l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) || l.rel !== "self") continue;
|
|
100
97
|
try {
|
|
101
|
-
|
|
102
|
-
document = remoteDoc.document;
|
|
98
|
+
document = (await documentLoader(l.href)).document;
|
|
103
99
|
break;
|
|
104
100
|
} catch (error) {
|
|
105
101
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|