@fedify/fedify 2.1.27 → 2.1.28
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/{builder-CKQkP3a2.mjs → builder-CW1BrLbm.mjs} +3 -3
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-BR2CGENT.mjs → deno-CJgU2mcr.mjs} +1 -1
- package/dist/{docloader-BDHKVMoV.mjs → docloader-o3fCIlIa.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +6 -6
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +6 -6
- 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/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-QzHm1vsW.mjs → http-Dcj1ulAh.mjs} +2 -2
- package/dist/{http-DQVY5EMT.js → http-DtypHuuK.js} +104 -10
- package/dist/{http-CsQRvInz.cjs → http-EEfKB8Qb.cjs} +103 -9
- package/dist/{inbox-DEXoNgGa.mjs → inbox-CVYVJI0M.mjs} +1 -1
- package/dist/{key-CDIMbgsc.mjs → key-DRLvwDTh.mjs} +104 -10
- package/dist/{kv-cache-FfmHQljR.cjs → kv-cache-BWVKAAmc.cjs} +1 -1
- package/dist/{kv-cache-cTsPZ49Z.js → kv-cache-CEJCaF4E.js} +1 -1
- package/dist/{ld-BpkaBh2H.mjs → ld-C5BZ98YK.mjs} +2 -2
- package/dist/{middleware-C9vVE-6R.mjs → middleware-CqQoREZ9.mjs} +1 -1
- package/dist/{middleware-Ddrg18eD.cjs → middleware-DZxmsbPB.cjs} +1 -1
- package/dist/{middleware-Bla8jBXk.cjs → middleware-Dw9sPiec.cjs} +4 -4
- package/dist/{middleware-DVaturw-.mjs → middleware-SSrXiJIV.mjs} +11 -11
- package/dist/{middleware-DwEVn3gK.js → middleware-wCgWm4Eh.js} +3 -3
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/{owner-DnOwKsK6.mjs → owner-cPOoPvmr.mjs} +2 -2
- package/dist/{proof-CShmVLWt.mjs → proof-BTknCsN7.mjs} +2 -2
- package/dist/{proof-uEay4EIq.js → proof-DPU3poip.js} +1 -1
- package/dist/{proof-JfqNWc2E.cjs → proof-De1y2j-e.cjs} +1 -1
- package/dist/{send-DCg0WblG.mjs → send-DDuHNgHz.mjs} +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +198 -4
- 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 +1 -1
- package/dist/{temporal-C96jXvaM.mjs → temporal-CxXY--ZL.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
|
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
6
|
-
import { t as InboxListenerSet } from "./inbox-
|
|
5
|
+
import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
|
|
6
|
+
import { t as InboxListenerSet } from "./inbox-CVYVJI0M.mjs";
|
|
7
7
|
import { getTypeId } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -44,7 +44,7 @@ var FederationBuilderImpl = class {
|
|
|
44
44
|
this.collectionTypeIds = {};
|
|
45
45
|
}
|
|
46
46
|
async build(options) {
|
|
47
|
-
const { FederationImpl } = await import("./middleware-
|
|
47
|
+
const { FederationImpl } = await import("./middleware-CqQoREZ9.mjs");
|
|
48
48
|
const f = new FederationImpl(options);
|
|
49
49
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
50
50
|
f.router = this.router.clone();
|
|
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
6
6
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
7
|
-
import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-
|
|
7
|
+
import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-SSrXiJIV.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
import { Follow, Person } from "@fedify/vocab";
|
|
10
10
|
//#region src/compat/transformers.test.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { s as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { s as validateCryptoKey } from "./key-DRLvwDTh.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-Dcj1ulAh.mjs";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
7
7
|
import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { i as assertExists, n as assertStrictEquals } from "../std__assert-BUOJXi-Z.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
8
|
-
import { n as createFederationBuilder } from "../builder-
|
|
8
|
+
import { n as createFederationBuilder } from "../builder-CW1BrLbm.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/federation/builder.test.ts
|
|
@@ -7,14 +7,14 @@ import "../std__assert-BUOJXi-Z.mjs";
|
|
|
7
7
|
import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
8
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
9
|
import { r as parseAcceptSignature } from "../accept-BavzedPB.mjs";
|
|
10
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
11
|
-
import { s as signRequest } from "../http-
|
|
10
|
+
import { a as generateCryptoKeyPair } from "../key-DRLvwDTh.mjs";
|
|
11
|
+
import { s as signRequest } from "../http-Dcj1ulAh.mjs";
|
|
12
12
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-CtZLJq76.mjs";
|
|
13
13
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
14
|
-
import { a as compactJsonLd, f as signJsonLd } from "../ld-
|
|
15
|
-
import { n as signObject } from "../proof-
|
|
16
|
-
import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-
|
|
17
|
-
import { t as InboxListenerSet } from "../inbox-
|
|
14
|
+
import { a as compactJsonLd, f as signJsonLd } from "../ld-C5BZ98YK.mjs";
|
|
15
|
+
import { n as signObject } from "../proof-BTknCsN7.mjs";
|
|
16
|
+
import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-SSrXiJIV.mjs";
|
|
17
|
+
import { t as InboxListenerSet } from "../inbox-CVYVJI0M.mjs";
|
|
18
18
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
19
19
|
import { Create, CryptographicKey, Multikey, Note, Person } from "@fedify/vocab";
|
|
20
20
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -5,8 +5,8 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import "../std__assert-BUOJXi-Z.mjs";
|
|
6
6
|
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
8
|
-
import { n as signObject } from "../proof-
|
|
9
|
-
import { a as createFederation } from "../middleware-
|
|
8
|
+
import { n as signObject } from "../proof-BTknCsN7.mjs";
|
|
9
|
+
import { a as createFederation } from "../middleware-SSrXiJIV.mjs";
|
|
10
10
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
12
12
|
//#region src/federation/idempotency.test.ts
|
|
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
6
|
-
import { t as InboxListenerSet } from "../inbox-
|
|
6
|
+
import { t as InboxListenerSet } from "../inbox-CVYVJI0M.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
|
|
9
9
|
//#region src/federation/inbox.test.ts
|
|
@@ -9,14 +9,14 @@ import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z
|
|
|
9
9
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
10
10
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
11
11
|
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
12
|
-
import { l as verifyRequest, s as signRequest } from "../http-
|
|
12
|
+
import { l as verifyRequest, s as signRequest } from "../http-Dcj1ulAh.mjs";
|
|
13
13
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
14
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
14
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-o3fCIlIa.mjs";
|
|
15
15
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
16
|
-
import { a as compactJsonLd, f as signJsonLd, m as verifyJsonLd, s as detachSignature } from "../ld-
|
|
17
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
18
|
-
import { n as signObject, r as verifyObject } from "../proof-
|
|
19
|
-
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-
|
|
16
|
+
import { a as compactJsonLd, f as signJsonLd, m as verifyJsonLd, s as detachSignature } from "../ld-C5BZ98YK.mjs";
|
|
17
|
+
import { t as doesActorOwnKey } from "../owner-cPOoPvmr.mjs";
|
|
18
|
+
import { n as signObject, r as verifyObject } from "../proof-BTknCsN7.mjs";
|
|
19
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-SSrXiJIV.mjs";
|
|
20
20
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
21
21
|
import * as vocab from "@fedify/vocab";
|
|
22
22
|
import { Create, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
require("../chunk-DDcVe30Y.cjs");
|
|
5
|
-
const require_middleware = require("../middleware-
|
|
5
|
+
const require_middleware = require("../middleware-Dw9sPiec.cjs");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
//#region src/federation/kv.ts
|
|
8
8
|
/**
|
package/dist/federation/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-
|
|
3
|
+
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-wCgWm4Eh.js";
|
|
4
4
|
import { isEqual } from "es-toolkit";
|
|
5
5
|
//#region src/federation/kv.ts
|
|
6
6
|
/**
|
|
@@ -7,10 +7,10 @@ import "../std__assert-BUOJXi-Z.mjs";
|
|
|
7
7
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
8
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
9
|
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
10
|
-
import { l as verifyRequest } from "../http-
|
|
10
|
+
import { l as verifyRequest } from "../http-Dcj1ulAh.mjs";
|
|
11
11
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
12
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
13
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-
|
|
12
|
+
import { t as doesActorOwnKey } from "../owner-cPOoPvmr.mjs";
|
|
13
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DDuHNgHz.mjs";
|
|
14
14
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
15
15
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
16
16
|
import { FetchError, UrlError } from "@fedify/vocab-runtime";
|
|
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import "../std__assert-BUOJXi-Z.mjs";
|
|
5
5
|
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
6
6
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
|
-
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-
|
|
7
|
+
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-CxXY--ZL.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/temporal.test.ts
|
|
10
10
|
test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
|
|
@@ -5,7 +5,7 @@ import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
6
|
import "../std__assert-BUOJXi-Z.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
8
|
-
import { a as createFederation, o as handleWebFinger } from "../middleware-
|
|
8
|
+
import { a as createFederation, o as handleWebFinger } from "../middleware-SSrXiJIV.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Image, Link, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/federation/webfinger.test.ts
|
|
@@ -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-
|
|
4
|
+
import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
|
|
5
5
|
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-BavzedPB.mjs";
|
|
6
|
-
import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-
|
|
6
|
+
import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-DRLvwDTh.mjs";
|
|
7
7
|
import { CryptographicKey } from "@fedify/vocab";
|
|
8
8
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -4,13 +4,13 @@ import { getLogger } from "@logtape/logtape";
|
|
|
4
4
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
5
5
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
6
6
|
import { encodeHex } from "byte-encodings/hex";
|
|
7
|
-
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
7
|
+
import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
8
8
|
import { Item, decodeDict, encodeDict, encodeItem } from "structured-field-values";
|
|
9
9
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "2.1.
|
|
13
|
+
var version = "2.1.28";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -152,6 +152,64 @@ function fulfillAcceptSignature(entry, localKeyId, localAlg) {
|
|
|
152
152
|
}
|
|
153
153
|
//#endregion
|
|
154
154
|
//#region src/sig/key.ts
|
|
155
|
+
/** Classifies decoding failures without hiding unexpected loader errors. */
|
|
156
|
+
function classifyKeyJsonLdError(error, seen = /* @__PURE__ */ new Set()) {
|
|
157
|
+
if (!(error instanceof Error) || !error.name.startsWith("jsonld.")) return null;
|
|
158
|
+
if (seen.has(error)) throw error;
|
|
159
|
+
seen.add(error);
|
|
160
|
+
const details = error.details;
|
|
161
|
+
if (typeof details?.code !== "string") return null;
|
|
162
|
+
if (details.code !== "loading remote context failed" || !("cause" in details) && !("cause" in error)) return "invalid";
|
|
163
|
+
const cause = "cause" in details ? details.cause : error.cause;
|
|
164
|
+
const nestedFailure = classifyKeyJsonLdError(cause, seen);
|
|
165
|
+
if (nestedFailure != null) return nestedFailure;
|
|
166
|
+
if (cause instanceof SyntaxError) return "invalid";
|
|
167
|
+
if (cause instanceof FetchError || cause instanceof UrlError) return "fetch";
|
|
168
|
+
if (cause instanceof Error && [
|
|
169
|
+
"AbortError",
|
|
170
|
+
"TimeoutError",
|
|
171
|
+
"NetworkError"
|
|
172
|
+
].includes(cause.name)) return "fetch";
|
|
173
|
+
if (cause instanceof TypeError) {
|
|
174
|
+
const urlCode = cause.code;
|
|
175
|
+
if (cause.name === "InvalidContextReferenceError") return "invalid";
|
|
176
|
+
if (urlCode === "ERR_INVALID_URL" || cause.message === "Invalid URL string." || /^Invalid URL(?::|$)/.test(cause.message) || / cannot be parsed as a URL\.?$/.test(cause.message)) return typeof details.url === "string" && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(details.url) && !URL.canParse(details.url) ? "invalid" : "fetch";
|
|
177
|
+
const networkCause = cause.cause;
|
|
178
|
+
const code = cause.code ?? networkCause?.code;
|
|
179
|
+
if (typeof code === "string" && [
|
|
180
|
+
"ECONNREFUSED",
|
|
181
|
+
"ECONNRESET",
|
|
182
|
+
"ECONNABORTED",
|
|
183
|
+
"ETIMEDOUT",
|
|
184
|
+
"EHOSTUNREACH",
|
|
185
|
+
"ENETUNREACH",
|
|
186
|
+
"ENOTFOUND",
|
|
187
|
+
"EAI_AGAIN",
|
|
188
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
189
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
190
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
191
|
+
"UND_ERR_SOCKET"
|
|
192
|
+
].includes(code) || /^(fetch failed|Failed to fetch|error sending request|error reading a body from connection|Unable to connect|ConnectionRefused|Network connection lost|The socket connection was closed unexpectedly)/.test(cause.message)) return "fetch";
|
|
193
|
+
}
|
|
194
|
+
throw cause;
|
|
195
|
+
}
|
|
196
|
+
/** Carries a context transport failure through the key decoding boundary. */
|
|
197
|
+
var KeyContextFetchError = class extends Error {
|
|
198
|
+
constructor(error) {
|
|
199
|
+
super("Failed to fetch a key's JSON-LD context.", { cause: error });
|
|
200
|
+
this.error = error;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
function contextFetchError(error) {
|
|
204
|
+
const seen = /* @__PURE__ */ new Set();
|
|
205
|
+
while (error instanceof Error && !seen.has(error)) {
|
|
206
|
+
seen.add(error);
|
|
207
|
+
const details = error.details;
|
|
208
|
+
if (!error.name.startsWith("jsonld.") || details?.code !== "loading remote context failed") break;
|
|
209
|
+
error = "cause" in details ? details.cause : error.cause;
|
|
210
|
+
}
|
|
211
|
+
return new KeyContextFetchError(error);
|
|
212
|
+
}
|
|
155
213
|
/**
|
|
156
214
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
|
157
215
|
* otherwise throws an error.
|
|
@@ -246,6 +304,9 @@ async function importJwk(jwk, type) {
|
|
|
246
304
|
* @internal
|
|
247
305
|
*/
|
|
248
306
|
async function fetchActorDocument(actorId, options = {}) {
|
|
307
|
+
return await fetchActorDocumentInternal(actorId, options, false);
|
|
308
|
+
}
|
|
309
|
+
async function fetchActorDocumentInternal(actorId, options, propagateContextFetchErrors) {
|
|
249
310
|
const logger = getLogger([
|
|
250
311
|
"fedify",
|
|
251
312
|
"sig",
|
|
@@ -276,9 +337,12 @@ async function fetchActorDocument(actorId, options = {}) {
|
|
|
276
337
|
baseUrl: documentUrl
|
|
277
338
|
});
|
|
278
339
|
} catch (error) {
|
|
279
|
-
|
|
280
|
-
|
|
340
|
+
const failure = classifyKeyJsonLdError(error);
|
|
341
|
+
if (failure === "fetch" && propagateContextFetchErrors) throw contextFetchError(error);
|
|
342
|
+
if (failure == null && !(error instanceof TypeError)) throw error;
|
|
343
|
+
logger.debug("Failed to decode the actor document at {documentUrl}: {error}", {
|
|
281
344
|
documentUrl: documentUrl.href,
|
|
345
|
+
failure: failure ?? "invalid",
|
|
282
346
|
error
|
|
283
347
|
});
|
|
284
348
|
return null;
|
|
@@ -317,6 +381,9 @@ async function fetchActorDocument(actorId, options = {}) {
|
|
|
317
381
|
* @internal
|
|
318
382
|
*/
|
|
319
383
|
async function verifyKeyOwnership(key, options = {}) {
|
|
384
|
+
return await verifyKeyOwnershipInternal(key, options, false);
|
|
385
|
+
}
|
|
386
|
+
async function verifyKeyOwnershipInternal(key, options, propagateContextFetchErrors) {
|
|
320
387
|
const logger = getLogger([
|
|
321
388
|
"fedify",
|
|
322
389
|
"sig",
|
|
@@ -326,7 +393,7 @@ async function verifyKeyOwnership(key, options = {}) {
|
|
|
326
393
|
if (keyId == null) return null;
|
|
327
394
|
const claimedOwnerId = key instanceof CryptographicKey ? key.ownerId : key.controllerId;
|
|
328
395
|
if (claimedOwnerId == null) return null;
|
|
329
|
-
const owner = await
|
|
396
|
+
const owner = await fetchActorDocumentInternal(claimedOwnerId, options, propagateContextFetchErrors);
|
|
330
397
|
if (owner == null) {
|
|
331
398
|
logger.debug("The owner ({claimedOwnerId}) that key {keyId} claims could not be resolved.", {
|
|
332
399
|
keyId: keyId.href,
|
|
@@ -478,6 +545,21 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
478
545
|
tracerProvider
|
|
479
546
|
});
|
|
480
547
|
} catch (e) {
|
|
548
|
+
const failure = classifyKeyJsonLdError(e);
|
|
549
|
+
if (failure === "fetch") throw contextFetchError(e);
|
|
550
|
+
if (failure != null) {
|
|
551
|
+
logger.debug("Failed to decode key {keyId}: {error}", {
|
|
552
|
+
keyId,
|
|
553
|
+
failure,
|
|
554
|
+
error: e
|
|
555
|
+
});
|
|
556
|
+
await keyCache?.set(cacheKey, null);
|
|
557
|
+
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
558
|
+
return {
|
|
559
|
+
key: null,
|
|
560
|
+
cached: false
|
|
561
|
+
};
|
|
562
|
+
}
|
|
481
563
|
if (!(e instanceof TypeError)) throw e;
|
|
482
564
|
try {
|
|
483
565
|
object = await cls.fromJsonLd(document, {
|
|
@@ -486,8 +568,14 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
486
568
|
tracerProvider
|
|
487
569
|
});
|
|
488
570
|
} catch (e) {
|
|
489
|
-
|
|
490
|
-
|
|
571
|
+
const failure = classifyKeyJsonLdError(e);
|
|
572
|
+
if (failure === "fetch") throw contextFetchError(e);
|
|
573
|
+
if (failure != null || e instanceof TypeError) {
|
|
574
|
+
logger.debug("Failed to decode key {keyId}: {error}", {
|
|
575
|
+
keyId,
|
|
576
|
+
failure: failure ?? "invalid",
|
|
577
|
+
error: e
|
|
578
|
+
});
|
|
491
579
|
await keyCache?.set(cacheKey, null);
|
|
492
580
|
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
493
581
|
return {
|
|
@@ -579,16 +667,17 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
579
667
|
const claimedOwnerId = key instanceof CryptographicKey ? key.ownerId : key.controllerId;
|
|
580
668
|
if (ownerDocument != null && claimedOwnerId == null) key = key instanceof CryptographicKey ? key.clone({ owner: ownerDocument.id }) : key.clone({ controller: ownerDocument.id });
|
|
581
669
|
else if (claimedOwnerId != null && claimedOwnerId.href !== ownerDocument?.id?.href) {
|
|
582
|
-
if (await
|
|
670
|
+
if (await verifyKeyOwnershipInternal(key, {
|
|
583
671
|
documentLoader,
|
|
584
672
|
contextLoader,
|
|
585
673
|
tracerProvider
|
|
586
|
-
}) == null) {
|
|
674
|
+
}, true) == null) {
|
|
587
675
|
logger.debug("Failed to verify; the owner {claimedOwnerId} that key {keyId} claims does not list the key as its own.", {
|
|
588
676
|
keyId,
|
|
589
677
|
claimedOwnerId: claimedOwnerId.href
|
|
590
678
|
});
|
|
591
679
|
await keyCache?.set(cacheKey, null);
|
|
680
|
+
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
592
681
|
return {
|
|
593
682
|
key: null,
|
|
594
683
|
cached: false
|
|
@@ -626,7 +715,12 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
|
|
|
626
715
|
} catch (error) {
|
|
627
716
|
return await onFetchError(error, cacheKey, keyId, keyCache, logger);
|
|
628
717
|
}
|
|
629
|
-
|
|
718
|
+
try {
|
|
719
|
+
return await resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, options, logger);
|
|
720
|
+
} catch (error) {
|
|
721
|
+
if (!(error instanceof KeyContextFetchError)) throw error;
|
|
722
|
+
return await onFetchError(error.error, cacheKey, keyId, keyCache, logger);
|
|
723
|
+
}
|
|
630
724
|
}
|
|
631
725
|
async function fetchKeyInternal(keyId, cls, options = {}) {
|
|
632
726
|
return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
|
|
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
|
|
|
11
11
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
12
12
|
//#region deno.json
|
|
13
13
|
var name = "@fedify/fedify";
|
|
14
|
-
var version = "2.1.
|
|
14
|
+
var version = "2.1.28";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sig/accept.ts
|
|
17
17
|
/**
|
|
@@ -153,6 +153,64 @@ function fulfillAcceptSignature(entry, localKeyId, localAlg) {
|
|
|
153
153
|
}
|
|
154
154
|
//#endregion
|
|
155
155
|
//#region src/sig/key.ts
|
|
156
|
+
/** Classifies decoding failures without hiding unexpected loader errors. */
|
|
157
|
+
function classifyKeyJsonLdError(error, seen = /* @__PURE__ */ new Set()) {
|
|
158
|
+
if (!(error instanceof Error) || !error.name.startsWith("jsonld.")) return null;
|
|
159
|
+
if (seen.has(error)) throw error;
|
|
160
|
+
seen.add(error);
|
|
161
|
+
const details = error.details;
|
|
162
|
+
if (typeof details?.code !== "string") return null;
|
|
163
|
+
if (details.code !== "loading remote context failed" || !("cause" in details) && !("cause" in error)) return "invalid";
|
|
164
|
+
const cause = "cause" in details ? details.cause : error.cause;
|
|
165
|
+
const nestedFailure = classifyKeyJsonLdError(cause, seen);
|
|
166
|
+
if (nestedFailure != null) return nestedFailure;
|
|
167
|
+
if (cause instanceof SyntaxError) return "invalid";
|
|
168
|
+
if (cause instanceof _fedify_vocab_runtime.FetchError || cause instanceof _fedify_vocab_runtime.UrlError) return "fetch";
|
|
169
|
+
if (cause instanceof Error && [
|
|
170
|
+
"AbortError",
|
|
171
|
+
"TimeoutError",
|
|
172
|
+
"NetworkError"
|
|
173
|
+
].includes(cause.name)) return "fetch";
|
|
174
|
+
if (cause instanceof TypeError) {
|
|
175
|
+
const urlCode = cause.code;
|
|
176
|
+
if (cause.name === "InvalidContextReferenceError") return "invalid";
|
|
177
|
+
if (urlCode === "ERR_INVALID_URL" || cause.message === "Invalid URL string." || /^Invalid URL(?::|$)/.test(cause.message) || / cannot be parsed as a URL\.?$/.test(cause.message)) return typeof details.url === "string" && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(details.url) && !URL.canParse(details.url) ? "invalid" : "fetch";
|
|
178
|
+
const networkCause = cause.cause;
|
|
179
|
+
const code = cause.code ?? networkCause?.code;
|
|
180
|
+
if (typeof code === "string" && [
|
|
181
|
+
"ECONNREFUSED",
|
|
182
|
+
"ECONNRESET",
|
|
183
|
+
"ECONNABORTED",
|
|
184
|
+
"ETIMEDOUT",
|
|
185
|
+
"EHOSTUNREACH",
|
|
186
|
+
"ENETUNREACH",
|
|
187
|
+
"ENOTFOUND",
|
|
188
|
+
"EAI_AGAIN",
|
|
189
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
190
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
191
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
192
|
+
"UND_ERR_SOCKET"
|
|
193
|
+
].includes(code) || /^(fetch failed|Failed to fetch|error sending request|error reading a body from connection|Unable to connect|ConnectionRefused|Network connection lost|The socket connection was closed unexpectedly)/.test(cause.message)) return "fetch";
|
|
194
|
+
}
|
|
195
|
+
throw cause;
|
|
196
|
+
}
|
|
197
|
+
/** Carries a context transport failure through the key decoding boundary. */
|
|
198
|
+
var KeyContextFetchError = class extends Error {
|
|
199
|
+
constructor(error) {
|
|
200
|
+
super("Failed to fetch a key's JSON-LD context.", { cause: error });
|
|
201
|
+
this.error = error;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
function contextFetchError(error) {
|
|
205
|
+
const seen = /* @__PURE__ */ new Set();
|
|
206
|
+
while (error instanceof Error && !seen.has(error)) {
|
|
207
|
+
seen.add(error);
|
|
208
|
+
const details = error.details;
|
|
209
|
+
if (!error.name.startsWith("jsonld.") || details?.code !== "loading remote context failed") break;
|
|
210
|
+
error = "cause" in details ? details.cause : error.cause;
|
|
211
|
+
}
|
|
212
|
+
return new KeyContextFetchError(error);
|
|
213
|
+
}
|
|
156
214
|
/**
|
|
157
215
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
|
158
216
|
* otherwise throws an error.
|
|
@@ -247,6 +305,9 @@ async function importJwk(jwk, type) {
|
|
|
247
305
|
* @internal
|
|
248
306
|
*/
|
|
249
307
|
async function fetchActorDocument(actorId, options = {}) {
|
|
308
|
+
return await fetchActorDocumentInternal(actorId, options, false);
|
|
309
|
+
}
|
|
310
|
+
async function fetchActorDocumentInternal(actorId, options, propagateContextFetchErrors) {
|
|
250
311
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
251
312
|
"fedify",
|
|
252
313
|
"sig",
|
|
@@ -277,9 +338,12 @@ async function fetchActorDocument(actorId, options = {}) {
|
|
|
277
338
|
baseUrl: documentUrl
|
|
278
339
|
});
|
|
279
340
|
} catch (error) {
|
|
280
|
-
|
|
281
|
-
|
|
341
|
+
const failure = classifyKeyJsonLdError(error);
|
|
342
|
+
if (failure === "fetch" && propagateContextFetchErrors) throw contextFetchError(error);
|
|
343
|
+
if (failure == null && !(error instanceof TypeError)) throw error;
|
|
344
|
+
logger.debug("Failed to decode the actor document at {documentUrl}: {error}", {
|
|
282
345
|
documentUrl: documentUrl.href,
|
|
346
|
+
failure: failure ?? "invalid",
|
|
283
347
|
error
|
|
284
348
|
});
|
|
285
349
|
return null;
|
|
@@ -318,6 +382,9 @@ async function fetchActorDocument(actorId, options = {}) {
|
|
|
318
382
|
* @internal
|
|
319
383
|
*/
|
|
320
384
|
async function verifyKeyOwnership(key, options = {}) {
|
|
385
|
+
return await verifyKeyOwnershipInternal(key, options, false);
|
|
386
|
+
}
|
|
387
|
+
async function verifyKeyOwnershipInternal(key, options, propagateContextFetchErrors) {
|
|
321
388
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
322
389
|
"fedify",
|
|
323
390
|
"sig",
|
|
@@ -327,7 +394,7 @@ async function verifyKeyOwnership(key, options = {}) {
|
|
|
327
394
|
if (keyId == null) return null;
|
|
328
395
|
const claimedOwnerId = key instanceof _fedify_vocab.CryptographicKey ? key.ownerId : key.controllerId;
|
|
329
396
|
if (claimedOwnerId == null) return null;
|
|
330
|
-
const owner = await
|
|
397
|
+
const owner = await fetchActorDocumentInternal(claimedOwnerId, options, propagateContextFetchErrors);
|
|
331
398
|
if (owner == null) {
|
|
332
399
|
logger.debug("The owner ({claimedOwnerId}) that key {keyId} claims could not be resolved.", {
|
|
333
400
|
keyId: keyId.href,
|
|
@@ -479,6 +546,21 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
479
546
|
tracerProvider
|
|
480
547
|
});
|
|
481
548
|
} catch (e) {
|
|
549
|
+
const failure = classifyKeyJsonLdError(e);
|
|
550
|
+
if (failure === "fetch") throw contextFetchError(e);
|
|
551
|
+
if (failure != null) {
|
|
552
|
+
logger.debug("Failed to decode key {keyId}: {error}", {
|
|
553
|
+
keyId,
|
|
554
|
+
failure,
|
|
555
|
+
error: e
|
|
556
|
+
});
|
|
557
|
+
await keyCache?.set(cacheKey, null);
|
|
558
|
+
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
559
|
+
return {
|
|
560
|
+
key: null,
|
|
561
|
+
cached: false
|
|
562
|
+
};
|
|
563
|
+
}
|
|
482
564
|
if (!(e instanceof TypeError)) throw e;
|
|
483
565
|
try {
|
|
484
566
|
object = await cls.fromJsonLd(document, {
|
|
@@ -487,8 +569,14 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
487
569
|
tracerProvider
|
|
488
570
|
});
|
|
489
571
|
} catch (e) {
|
|
490
|
-
|
|
491
|
-
|
|
572
|
+
const failure = classifyKeyJsonLdError(e);
|
|
573
|
+
if (failure === "fetch") throw contextFetchError(e);
|
|
574
|
+
if (failure != null || e instanceof TypeError) {
|
|
575
|
+
logger.debug("Failed to decode key {keyId}: {error}", {
|
|
576
|
+
keyId,
|
|
577
|
+
failure: failure ?? "invalid",
|
|
578
|
+
error: e
|
|
579
|
+
});
|
|
492
580
|
await keyCache?.set(cacheKey, null);
|
|
493
581
|
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
494
582
|
return {
|
|
@@ -580,16 +668,17 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
|
|
|
580
668
|
const claimedOwnerId = key instanceof _fedify_vocab.CryptographicKey ? key.ownerId : key.controllerId;
|
|
581
669
|
if (ownerDocument != null && claimedOwnerId == null) key = key instanceof _fedify_vocab.CryptographicKey ? key.clone({ owner: ownerDocument.id }) : key.clone({ controller: ownerDocument.id });
|
|
582
670
|
else if (claimedOwnerId != null && claimedOwnerId.href !== ownerDocument?.id?.href) {
|
|
583
|
-
if (await
|
|
671
|
+
if (await verifyKeyOwnershipInternal(key, {
|
|
584
672
|
documentLoader,
|
|
585
673
|
contextLoader,
|
|
586
674
|
tracerProvider
|
|
587
|
-
}) == null) {
|
|
675
|
+
}, true) == null) {
|
|
588
676
|
logger.debug("Failed to verify; the owner {claimedOwnerId} that key {keyId} claims does not list the key as its own.", {
|
|
589
677
|
keyId,
|
|
590
678
|
claimedOwnerId: claimedOwnerId.href
|
|
591
679
|
});
|
|
592
680
|
await keyCache?.set(cacheKey, null);
|
|
681
|
+
await clearFetchErrorMetadata(cacheKey, keyCache);
|
|
593
682
|
return {
|
|
594
683
|
key: null,
|
|
595
684
|
cached: false
|
|
@@ -627,7 +716,12 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
|
|
|
627
716
|
} catch (error) {
|
|
628
717
|
return await onFetchError(error, cacheKey, keyId, keyCache, logger);
|
|
629
718
|
}
|
|
630
|
-
|
|
719
|
+
try {
|
|
720
|
+
return await resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, options, logger);
|
|
721
|
+
} catch (error) {
|
|
722
|
+
if (!(error instanceof KeyContextFetchError)) throw error;
|
|
723
|
+
return await onFetchError(error.error, cacheKey, keyId, keyCache, logger);
|
|
724
|
+
}
|
|
631
725
|
}
|
|
632
726
|
async function fetchKeyInternal(keyId, cls, options = {}) {
|
|
633
727
|
return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
+
import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
|
|
5
5
|
import { Activity, getTypeId } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|