@fedify/fedify 1.9.0-pr.428.1588 → 1.9.0-pr.431.1597
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-CHOM_AN3.d.cts +128 -0
- package/dist/actor-CfaqWvJb.cjs +37783 -0
- package/dist/{actor-CdM_sJLC.js → actor-Detmisdi.js} +190 -190
- package/dist/{actor-ByOSf9n9.js → actor-Dw7av4Zk.js} +1 -1
- package/dist/{authdocloader-VVd0U8Qg.js → authdocloader-5UJ5Gme-.js} +6 -6
- package/dist/authdocloader-BVYv0Ct8.cjs +58 -0
- package/dist/{authdocloader-CfP6lfxM.js → authdocloader-ZlLoXSxM.js} +3 -3
- package/dist/{builder-mfXmda-W.js → builder-BbKfqPmR.js} +4 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/{client-DB8N2RwI.js → client-DgRjF0ha.js} +1 -1
- package/dist/client-DjT_tegg.d.cts +294 -0
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +16 -16
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/context-KXVF2AhH.d.cts +2261 -0
- package/dist/{docloader-XJzCMWY-.js → docloader-BKf9RWX4.js} +4 -4
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/docloader-eqgyMp7h.cjs +4682 -0
- package/dist/{esm-BVYQVacR.js → esm-B_ZjJ1sB.js} +1 -1
- package/dist/federation/builder.test.js +5 -5
- package/dist/federation/collection.test.js +3 -3
- package/dist/federation/handler.test.js +17 -17
- package/dist/federation/inbox.test.js +4 -4
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +3 -3
- package/dist/federation/middleware.test.js +18 -18
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +3 -3
- package/dist/federation/retry.test.js +3 -3
- package/dist/federation/router.test.js +3 -3
- package/dist/federation/send.test.js +10 -10
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/http-B_zBcsai.d.cts +253 -0
- package/dist/{http-B_bBrm6N.js → http-C5XLveZw.js} +2 -2
- package/dist/{http-DYB4M8Pr.js → http-CwlUFNG4.js} +6 -6
- package/dist/http-_vjuGcXn.cjs +826 -0
- package/dist/{inbox-B4k2JQpE.js → inbox-sVXiVBbT.js} +1 -1
- package/dist/key-19P2dWvf.cjs +290 -0
- package/dist/{key-BdBFUTr5.js → key-BCWvPOkD.js} +5 -5
- package/dist/key-CsQ7J8-m.js +10 -0
- package/dist/key-Dt7qJaQT.cjs +10 -0
- package/dist/{key-feGm-IP3.js → key-Jrnr66vx.js} +2 -2
- package/dist/{key-BcVEPl--.js → key-lpATOAE4.js} +3 -3
- package/dist/{keycache-b7FYgzB9.js → keycache-ogQInQck.js} +1 -1
- package/dist/{keys-B7uX1KoX.js → keys-DcGsKtHW.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-DJCemZO2.js → ld-BSE4jnyK.js} +2 -2
- package/dist/lookup-D96ipStp.cjs +137 -0
- package/dist/{lookup-CIsbr_Qi.js → lookup-D_-F1hLw.js} +4 -4
- package/dist/{lookup-CXaZBmuy.js → lookup-DdxOle8f.js} +1 -1
- package/dist/middleware-B0f850Ei.cjs +17 -0
- package/dist/middleware-B2DFqtJ-.cjs +4240 -0
- package/dist/middleware-COHAbwGs.js +17 -0
- package/dist/{middleware-D5JRdsEc.js → middleware-CuTcPjfP.js} +13 -13
- package/dist/middleware-Dt7C7qpw.js +26 -0
- package/dist/{middleware-e_Gw7sQy.js → middleware-T_y4Bnvw.js} +14 -14
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-C3CGxYoF.d.cts +102 -0
- package/dist/mod-COw_caPC.d.cts +266 -0
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-NKH_G-IY.d.cts +289 -0
- package/dist/mod-YfAcrVbP.d.cts +80 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +152 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/nodeinfo/client.test.js +5 -5
- package/dist/nodeinfo/handler.test.js +16 -16
- package/dist/nodeinfo/mod.cjs +13 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/semver.test.js +3 -3
- package/dist/nodeinfo/types.test.js +3 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-C9Ry0TOI.d.cts +67 -0
- package/dist/{owner-i9FkgZwa.js → owner-DJtc8evi.js} +2 -2
- package/dist/{proof-Bvtdd-Ul.js → proof-9OMp0o4n.js} +2 -2
- package/dist/{proof-DKGUTtBt.js → proof-BuPk23Er.js} +6 -6
- package/dist/proof-CRHppbRk.cjs +673 -0
- package/dist/runtime/authdocloader.test.js +9 -9
- package/dist/runtime/docloader.test.js +4 -4
- package/dist/runtime/key.test.js +5 -5
- package/dist/runtime/langstr.test.js +3 -3
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +3 -3
- package/dist/runtime/url.test.js +3 -3
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-Cuw-wTCx.js → send-cXerEJm9.js} +2 -2
- package/dist/sig/http.test.js +8 -8
- package/dist/sig/key.test.js +6 -6
- package/dist/sig/ld.test.js +7 -7
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +7 -7
- package/dist/sig/proof.test.js +7 -7
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +3 -3
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-DUFWSgSt.js → testing-BX6IA3LR.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-DDwsy8fI.js → type-DF9yoIpt.js} +186 -186
- package/dist/types-DcKQIzdO.cjs +488 -0
- package/dist/{types-CuvNqe2X.js → types-Q17QxOOC.js} +4 -4
- package/dist/vocab/actor.test.js +5 -5
- package/dist/vocab/lookup.test.js +4 -4
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +4 -4
- package/dist/{vocab-CEXwobaS.js → vocab-BUc_4ZsW.js} +6 -6
- package/dist/vocab-BzGg7ltX.d.cts +14629 -0
- package/dist/vocab-Du8FV6H1.cjs +282 -0
- package/dist/webfinger/handler.test.js +16 -16
- package/dist/webfinger/lookup.test.js +4 -4
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +3 -3
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -12
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-0hFXQUQz.js +0 -10
- package/dist/middleware-BhQdOVAF.js +0 -17
- package/dist/middleware-DVy3ms0C.js +0 -26
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
@@ -3,7 +3,7 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, deno_default, getTypeId } from "./type-
|
6
|
+
import { Activity, deno_default, getTypeId } from "./type-DF9yoIpt.js";
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
8
8
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
9
9
|
|
@@ -0,0 +1,290 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
6
|
+
const require_docloader = require('./docloader-eqgyMp7h.cjs');
|
7
|
+
const require_actor = require('./actor-CfaqWvJb.cjs');
|
8
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
9
|
+
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
10
|
+
|
11
|
+
//#region src/sig/key.ts
|
12
|
+
/**
|
13
|
+
* Checks if the given key is valid and supported. No-op if the key is valid,
|
14
|
+
* otherwise throws an error.
|
15
|
+
* @param key The key to check.
|
16
|
+
* @param type Which type of key to check. If not specified, the key can be
|
17
|
+
* either public or private.
|
18
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
19
|
+
*/
|
20
|
+
function validateCryptoKey(key, type) {
|
21
|
+
if (type != null && key.type !== type) throw new TypeError(`The key is not a ${type} key.`);
|
22
|
+
if (!key.extractable) throw new TypeError("The key is not extractable.");
|
23
|
+
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!");
|
24
|
+
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
25
|
+
const algorithm = key.algorithm;
|
26
|
+
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.");
|
27
|
+
}
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Generates a key pair which is appropriate for Fedify.
|
31
|
+
* @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
|
32
|
+
* Ed25519 are supported.
|
33
|
+
* @returns The generated key pair.
|
34
|
+
* @throws {TypeError} If the algorithm is unsupported.
|
35
|
+
*/
|
36
|
+
function generateCryptoKeyPair(algorithm) {
|
37
|
+
if (algorithm == null) (0, __logtape_logtape.getLogger)([
|
38
|
+
"fedify",
|
39
|
+
"sig",
|
40
|
+
"key"
|
41
|
+
]).warn("No algorithm specified. Using RSASSA-PKCS1-v1_5 by default, but it is recommended to specify the algorithm explicitly as the parameter will be required in the future.");
|
42
|
+
if (algorithm == null || algorithm === "RSASSA-PKCS1-v1_5") return crypto.subtle.generateKey({
|
43
|
+
name: "RSASSA-PKCS1-v1_5",
|
44
|
+
modulusLength: 4096,
|
45
|
+
publicExponent: new Uint8Array([
|
46
|
+
1,
|
47
|
+
0,
|
48
|
+
1
|
49
|
+
]),
|
50
|
+
hash: "SHA-256"
|
51
|
+
}, true, ["sign", "verify"]);
|
52
|
+
else if (algorithm === "Ed25519") return crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
|
53
|
+
throw new TypeError("Unsupported algorithm: " + algorithm);
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* Exports a key in JWK format.
|
57
|
+
* @param key The key to export. Either public or private key.
|
58
|
+
* @returns The exported key in JWK format. The key is suitable for
|
59
|
+
* serialization and storage.
|
60
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
61
|
+
*/
|
62
|
+
async function exportJwk(key) {
|
63
|
+
validateCryptoKey(key);
|
64
|
+
const jwk = await crypto.subtle.exportKey("jwk", key);
|
65
|
+
if (jwk.crv === "Ed25519") jwk.alg = "Ed25519";
|
66
|
+
return jwk;
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Imports a key from JWK format.
|
70
|
+
* @param jwk The key in JWK format.
|
71
|
+
* @param type Which type of key to import, either `"public"` or `"private"`.
|
72
|
+
* @returns The imported key.
|
73
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
74
|
+
*/
|
75
|
+
async function importJwk(jwk, type) {
|
76
|
+
let key;
|
77
|
+
if (jwk.kty === "RSA" && jwk.alg === "RS256") key = await crypto.subtle.importKey("jwk", jwk, {
|
78
|
+
name: "RSASSA-PKCS1-v1_5",
|
79
|
+
hash: "SHA-256"
|
80
|
+
}, true, type === "public" ? ["verify"] : ["sign"]);
|
81
|
+
else if (jwk.kty === "OKP" && jwk.crv === "Ed25519") {
|
82
|
+
if (navigator?.userAgent === "Cloudflare-Workers") {
|
83
|
+
jwk = { ...jwk };
|
84
|
+
delete jwk.alg;
|
85
|
+
}
|
86
|
+
key = await crypto.subtle.importKey("jwk", jwk, "Ed25519", true, type === "public" ? ["verify"] : ["sign"]);
|
87
|
+
} else throw new TypeError("Unsupported JWK format.");
|
88
|
+
validateCryptoKey(key, type);
|
89
|
+
return key;
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Fetches a {@link CryptographicKey} or {@link Multikey} from the given URL.
|
93
|
+
* If the given URL contains an {@link Actor} object, it tries to find
|
94
|
+
* the corresponding key in the `publicKey` or `assertionMethod` property.
|
95
|
+
* @template T The type of the key to fetch. Either {@link CryptographicKey}
|
96
|
+
* or {@link Multikey}.
|
97
|
+
* @param keyId The URL of the key.
|
98
|
+
* @param cls The class of the key to fetch. Either {@link CryptographicKey}
|
99
|
+
* or {@link Multikey}.
|
100
|
+
* @param options Options for fetching the key. See {@link FetchKeyOptions}.
|
101
|
+
* @returns The fetched key or `null` if the key is not found.
|
102
|
+
* @since 1.3.0
|
103
|
+
*/
|
104
|
+
function fetchKey(keyId, cls, options = {}) {
|
105
|
+
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
106
|
+
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
107
|
+
keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
|
108
|
+
return tracer.startActiveSpan("activitypub.fetch_key", {
|
109
|
+
kind: __opentelemetry_api.SpanKind.CLIENT,
|
110
|
+
attributes: {
|
111
|
+
"http.method": "GET",
|
112
|
+
"url.full": keyId.href,
|
113
|
+
"url.scheme": keyId.protocol.replace(/:$/, ""),
|
114
|
+
"url.domain": keyId.hostname,
|
115
|
+
"url.path": keyId.pathname,
|
116
|
+
"url.query": keyId.search.replace(/^\?/, ""),
|
117
|
+
"url.fragment": keyId.hash.replace(/^#/, "")
|
118
|
+
}
|
119
|
+
}, async (span) => {
|
120
|
+
try {
|
121
|
+
const result = await fetchKeyInternal(keyId, cls, options);
|
122
|
+
span.setAttribute("activitypub.actor.key.cached", result.cached);
|
123
|
+
return result;
|
124
|
+
} catch (e) {
|
125
|
+
span.setStatus({
|
126
|
+
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
127
|
+
message: String(e)
|
128
|
+
});
|
129
|
+
throw e;
|
130
|
+
} finally {
|
131
|
+
span.end();
|
132
|
+
}
|
133
|
+
});
|
134
|
+
}
|
135
|
+
async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, keyCache, tracerProvider } = {}) {
|
136
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
137
|
+
"fedify",
|
138
|
+
"sig",
|
139
|
+
"key"
|
140
|
+
]);
|
141
|
+
const cacheKey = typeof keyId === "string" ? new URL(keyId) : keyId;
|
142
|
+
keyId = typeof keyId === "string" ? keyId : keyId.href;
|
143
|
+
if (keyCache != null) {
|
144
|
+
const cachedKey = await keyCache.get(cacheKey);
|
145
|
+
if (cachedKey instanceof cls && cachedKey.publicKey != null) {
|
146
|
+
logger.debug("Key {keyId} found in cache.", { keyId });
|
147
|
+
return {
|
148
|
+
key: cachedKey,
|
149
|
+
cached: true
|
150
|
+
};
|
151
|
+
} else if (cachedKey === null) {
|
152
|
+
logger.debug("Entry {keyId} found in cache, but it is unavailable.", { keyId });
|
153
|
+
return {
|
154
|
+
key: null,
|
155
|
+
cached: true
|
156
|
+
};
|
157
|
+
}
|
158
|
+
}
|
159
|
+
logger.debug("Fetching key {keyId} to verify signature...", { keyId });
|
160
|
+
let document;
|
161
|
+
try {
|
162
|
+
const remoteDocument = await (documentLoader ?? require_docloader.getDocumentLoader())(keyId);
|
163
|
+
document = remoteDocument.document;
|
164
|
+
} catch (_) {
|
165
|
+
logger.debug("Failed to fetch key {keyId}.", { keyId });
|
166
|
+
await keyCache?.set(cacheKey, null);
|
167
|
+
return {
|
168
|
+
key: null,
|
169
|
+
cached: false
|
170
|
+
};
|
171
|
+
}
|
172
|
+
let object;
|
173
|
+
try {
|
174
|
+
object = await require_actor.Object.fromJsonLd(document, {
|
175
|
+
documentLoader,
|
176
|
+
contextLoader,
|
177
|
+
tracerProvider
|
178
|
+
});
|
179
|
+
} catch (e) {
|
180
|
+
if (!(e instanceof TypeError)) throw e;
|
181
|
+
try {
|
182
|
+
object = await cls.fromJsonLd(document, {
|
183
|
+
documentLoader,
|
184
|
+
contextLoader,
|
185
|
+
tracerProvider
|
186
|
+
});
|
187
|
+
} catch (e$1) {
|
188
|
+
if (e$1 instanceof TypeError) {
|
189
|
+
logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
|
190
|
+
await keyCache?.set(cacheKey, null);
|
191
|
+
return {
|
192
|
+
key: null,
|
193
|
+
cached: false
|
194
|
+
};
|
195
|
+
}
|
196
|
+
throw e$1;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
let key = null;
|
200
|
+
if (object instanceof cls) key = object;
|
201
|
+
else if (require_actor.isActor(object)) {
|
202
|
+
const keys = cls === require_actor.CryptographicKey ? object.getPublicKeys({
|
203
|
+
documentLoader,
|
204
|
+
contextLoader,
|
205
|
+
tracerProvider
|
206
|
+
}) : object.getAssertionMethods({
|
207
|
+
documentLoader,
|
208
|
+
contextLoader,
|
209
|
+
tracerProvider
|
210
|
+
});
|
211
|
+
let length = 0;
|
212
|
+
let lastKey = null;
|
213
|
+
for await (const k of keys) {
|
214
|
+
length++;
|
215
|
+
lastKey = k;
|
216
|
+
if (k.id?.href === keyId) {
|
217
|
+
key = k;
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
const keyIdUrl = new URL(keyId);
|
222
|
+
if (key == null && keyIdUrl.hash === "" && length === 1) key = lastKey;
|
223
|
+
if (key == null) {
|
224
|
+
logger.debug("Failed to verify; object {keyId} returned an {actorType}, but has no key matching {keyId}.", {
|
225
|
+
keyId,
|
226
|
+
actorType: object.constructor.name
|
227
|
+
});
|
228
|
+
await keyCache?.set(cacheKey, null);
|
229
|
+
return {
|
230
|
+
key: null,
|
231
|
+
cached: false
|
232
|
+
};
|
233
|
+
}
|
234
|
+
} else {
|
235
|
+
logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
|
236
|
+
await keyCache?.set(cacheKey, null);
|
237
|
+
return {
|
238
|
+
key: null,
|
239
|
+
cached: false
|
240
|
+
};
|
241
|
+
}
|
242
|
+
if (key.publicKey == null) {
|
243
|
+
logger.debug("Failed to verify; key {keyId} has no publicKeyPem field.", { keyId });
|
244
|
+
await keyCache?.set(cacheKey, null);
|
245
|
+
return {
|
246
|
+
key: null,
|
247
|
+
cached: false
|
248
|
+
};
|
249
|
+
}
|
250
|
+
if (keyCache != null) {
|
251
|
+
await keyCache.set(cacheKey, key);
|
252
|
+
logger.debug("Key {keyId} cached.", { keyId });
|
253
|
+
}
|
254
|
+
return {
|
255
|
+
key,
|
256
|
+
cached: false
|
257
|
+
};
|
258
|
+
}
|
259
|
+
|
260
|
+
//#endregion
|
261
|
+
Object.defineProperty(exports, 'exportJwk', {
|
262
|
+
enumerable: true,
|
263
|
+
get: function () {
|
264
|
+
return exportJwk;
|
265
|
+
}
|
266
|
+
});
|
267
|
+
Object.defineProperty(exports, 'fetchKey', {
|
268
|
+
enumerable: true,
|
269
|
+
get: function () {
|
270
|
+
return fetchKey;
|
271
|
+
}
|
272
|
+
});
|
273
|
+
Object.defineProperty(exports, 'generateCryptoKeyPair', {
|
274
|
+
enumerable: true,
|
275
|
+
get: function () {
|
276
|
+
return generateCryptoKeyPair;
|
277
|
+
}
|
278
|
+
});
|
279
|
+
Object.defineProperty(exports, 'importJwk', {
|
280
|
+
enumerable: true,
|
281
|
+
get: function () {
|
282
|
+
return importJwk;
|
283
|
+
}
|
284
|
+
});
|
285
|
+
Object.defineProperty(exports, 'validateCryptoKey', {
|
286
|
+
enumerable: true,
|
287
|
+
get: function () {
|
288
|
+
return validateCryptoKey;
|
289
|
+
}
|
290
|
+
});
|
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
6
|
-
import { CryptographicKey, Object as Object$1, isActor } from "./actor-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { deno_default, getDocumentLoader } from "./docloader-BKf9RWX4.js";
|
6
|
+
import { CryptographicKey, Object as Object$1, isActor } from "./actor-Detmisdi.js";
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
9
9
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "./docloader-BKf9RWX4.js";
|
6
|
+
import "./actor-Detmisdi.js";
|
7
|
+
import "./lookup-D_-F1hLw.js";
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-BCWvPOkD.js";
|
9
|
+
|
10
|
+
export { validateCryptoKey };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('./docloader-eqgyMp7h.cjs');
|
6
|
+
require('./actor-CfaqWvJb.cjs');
|
7
|
+
require('./lookup-D96ipStp.cjs');
|
8
|
+
const require_key = require('./key-19P2dWvf.cjs');
|
9
|
+
|
10
|
+
exports.validateCryptoKey = require_key.validateCryptoKey;
|
@@ -3,8 +3,8 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, Object as Object$1, deno_default, getDocumentLoader } from "./type-
|
7
|
-
import { isActor } from "./actor-
|
6
|
+
import { CryptographicKey, Object as Object$1, deno_default, getDocumentLoader } from "./type-DF9yoIpt.js";
|
7
|
+
import { isActor } from "./actor-Dw7av4Zk.js";
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
9
9
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
10
10
|
|
@@ -3,8 +3,8 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "./type-
|
7
|
-
import "./actor-
|
8
|
-
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-
|
6
|
+
import "./type-DF9yoIpt.js";
|
7
|
+
import "./actor-Dw7av4Zk.js";
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-Jrnr66vx.js";
|
9
9
|
|
10
10
|
export { validateCryptoKey };
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, Multikey } from "./type-
|
6
|
+
import { CryptographicKey, Multikey } from "./type-DF9yoIpt.js";
|
7
7
|
|
8
8
|
//#region src/federation/keycache.ts
|
9
9
|
var KvKeyCache = class {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, Multikey, importSpki } from "./type-
|
6
|
+
import { CryptographicKey, Multikey, importSpki } from "./type-DF9yoIpt.js";
|
7
7
|
|
8
8
|
//#region src/testing/keys.ts
|
9
9
|
const rsaPublicKey1 = new CryptographicKey({
|
@@ -0,0 +1,81 @@
|
|
1
|
+
//#region src/federation/kv.d.ts
|
2
|
+
/**
|
3
|
+
* A key for a key–value store. An array of one or more strings.
|
4
|
+
*
|
5
|
+
* @since 0.5.0
|
6
|
+
*/
|
7
|
+
type KvKey = readonly [string] | readonly [string, ...string[]];
|
8
|
+
/**
|
9
|
+
* Additional options for setting a value in a key–value store.
|
10
|
+
*
|
11
|
+
* @since 0.5.0
|
12
|
+
*/
|
13
|
+
interface KvStoreSetOptions {
|
14
|
+
/**
|
15
|
+
* The time-to-live (TTL) for the value.
|
16
|
+
*/
|
17
|
+
ttl?: Temporal.Duration;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* An abstract interface for a key–value store.
|
21
|
+
*
|
22
|
+
* @since 0.5.0
|
23
|
+
*/
|
24
|
+
interface KvStore {
|
25
|
+
/**
|
26
|
+
* Gets the value for the given key.
|
27
|
+
* @param key The key to get the value for.
|
28
|
+
* @returns The value for the key, or `undefined` if the key does not exist.
|
29
|
+
* @template T The type of the value to get.
|
30
|
+
*/
|
31
|
+
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
32
|
+
/**
|
33
|
+
* Sets the value for the given key.
|
34
|
+
* @param key The key to set the value for.
|
35
|
+
* @param value The value to set.
|
36
|
+
* @param options Additional options for setting the value.
|
37
|
+
*/
|
38
|
+
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
39
|
+
/**
|
40
|
+
* Deletes the value for the given key.
|
41
|
+
* @param key The key to delete.
|
42
|
+
*/
|
43
|
+
delete(key: KvKey): Promise<void>;
|
44
|
+
/**
|
45
|
+
* Compare-and-swap (CAS) operation for the key–value store.
|
46
|
+
* @param key The key to perform the CAS operation on.
|
47
|
+
* @param expectedValue The expected value for the key.
|
48
|
+
* @param newValue The new value to set if the expected value matches.
|
49
|
+
* @param options Additional options for setting the value.
|
50
|
+
* @return `true` if the CAS operation was successful, `false` otherwise.
|
51
|
+
* @since 1.8.0
|
52
|
+
*/
|
53
|
+
cas?: (key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions) => Promise<boolean>;
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* A key–value store that stores values in memory.
|
57
|
+
* Do not use this in production as it does not persist values.
|
58
|
+
*
|
59
|
+
* @since 0.5.0
|
60
|
+
*/
|
61
|
+
declare class MemoryKvStore implements KvStore {
|
62
|
+
#private;
|
63
|
+
/**
|
64
|
+
* {@inheritDoc KvStore.get}
|
65
|
+
*/
|
66
|
+
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
67
|
+
/**
|
68
|
+
* {@inheritDoc KvStore.set}
|
69
|
+
*/
|
70
|
+
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
71
|
+
/**
|
72
|
+
* {@inheritDoc KvStore.delete}
|
73
|
+
*/
|
74
|
+
delete(key: KvKey): Promise<void>;
|
75
|
+
/**
|
76
|
+
* {@inheritDoc KvStore.cas}
|
77
|
+
*/
|
78
|
+
cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
|
79
|
+
}
|
80
|
+
//#endregion
|
81
|
+
export { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore };
|
@@ -3,8 +3,8 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, CryptographicKey, Object as Object$1, deno_default, getDocumentLoader, getTypeId } from "./type-
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
6
|
+
import { Activity, CryptographicKey, Object as Object$1, deno_default, getDocumentLoader, getTypeId } from "./type-DF9yoIpt.js";
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-Jrnr66vx.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";
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
6
|
+
const require_docloader = require('./docloader-eqgyMp7h.cjs');
|
7
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
8
|
+
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
9
|
+
|
10
|
+
//#region src/webfinger/lookup.ts
|
11
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
12
|
+
"fedify",
|
13
|
+
"webfinger",
|
14
|
+
"lookup"
|
15
|
+
]);
|
16
|
+
const DEFAULT_MAX_REDIRECTION = 5;
|
17
|
+
/**
|
18
|
+
* Looks up a WebFinger resource.
|
19
|
+
* @param resource The resource URL to look up.
|
20
|
+
* @param options Extra options for looking up the resource.
|
21
|
+
* @returns The resource descriptor, or `null` if not found.
|
22
|
+
* @since 0.2.0
|
23
|
+
*/
|
24
|
+
async function lookupWebFinger(resource, options = {}) {
|
25
|
+
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
26
|
+
const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
|
27
|
+
return await tracer.startActiveSpan("webfinger.lookup", {
|
28
|
+
kind: __opentelemetry_api.SpanKind.CLIENT,
|
29
|
+
attributes: {
|
30
|
+
"webfinger.resource": resource.toString(),
|
31
|
+
"webfinger.resource.scheme": typeof resource === "string" ? resource.replace(/:.*$/, "") : resource.protocol.replace(/:$/, "")
|
32
|
+
}
|
33
|
+
}, async (span) => {
|
34
|
+
try {
|
35
|
+
const result = await lookupWebFingerInternal(resource, options);
|
36
|
+
span.setStatus({ code: result === null ? __opentelemetry_api.SpanStatusCode.ERROR : __opentelemetry_api.SpanStatusCode.OK });
|
37
|
+
return result;
|
38
|
+
} catch (error) {
|
39
|
+
span.setStatus({
|
40
|
+
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
41
|
+
message: String(error)
|
42
|
+
});
|
43
|
+
throw error;
|
44
|
+
} finally {
|
45
|
+
span.end();
|
46
|
+
}
|
47
|
+
});
|
48
|
+
}
|
49
|
+
async function lookupWebFingerInternal(resource, options = {}) {
|
50
|
+
if (typeof resource === "string") resource = new URL(resource);
|
51
|
+
let protocol = "https:";
|
52
|
+
let server;
|
53
|
+
if (resource.protocol === "acct:") {
|
54
|
+
const atPos = resource.pathname.lastIndexOf("@");
|
55
|
+
if (atPos < 0) return null;
|
56
|
+
server = resource.pathname.substring(atPos + 1);
|
57
|
+
if (server === "") return null;
|
58
|
+
} else {
|
59
|
+
protocol = resource.protocol;
|
60
|
+
server = resource.host;
|
61
|
+
}
|
62
|
+
let url = new URL(`${protocol}//${server}/.well-known/webfinger`);
|
63
|
+
url.searchParams.set("resource", resource.href);
|
64
|
+
let redirected = 0;
|
65
|
+
while (true) {
|
66
|
+
logger.debug("Fetching WebFinger resource descriptor from {url}...", { url: url.href });
|
67
|
+
let response;
|
68
|
+
if (options.allowPrivateAddress !== true) try {
|
69
|
+
await require_docloader.validatePublicUrl(url.href);
|
70
|
+
} catch (e) {
|
71
|
+
if (e instanceof require_docloader.UrlError) {
|
72
|
+
logger.error("Invalid URL for WebFinger resource descriptor: {error}", { error: e });
|
73
|
+
return null;
|
74
|
+
}
|
75
|
+
throw e;
|
76
|
+
}
|
77
|
+
try {
|
78
|
+
response = await fetch(url, {
|
79
|
+
headers: {
|
80
|
+
Accept: "application/jrd+json",
|
81
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
|
82
|
+
},
|
83
|
+
redirect: "manual",
|
84
|
+
signal: options.signal
|
85
|
+
});
|
86
|
+
} catch (error) {
|
87
|
+
logger.debug("Failed to fetch WebFinger resource descriptor: {error}", {
|
88
|
+
url: url.href,
|
89
|
+
error
|
90
|
+
});
|
91
|
+
return null;
|
92
|
+
}
|
93
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
94
|
+
redirected++;
|
95
|
+
const maxRedirection = options.maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
96
|
+
if (redirected >= maxRedirection) {
|
97
|
+
logger.error("Too many redirections ({redirections}) while fetching WebFinger resource descriptor.", { redirections: redirected });
|
98
|
+
return null;
|
99
|
+
}
|
100
|
+
const redirectedUrl = new URL(response.headers.get("Location"), response.url == null || response.url === "" ? url : response.url);
|
101
|
+
if (redirectedUrl.protocol !== url.protocol) {
|
102
|
+
logger.error("Redirected to a different protocol ({protocol} to {redirectedProtocol}) while fetching WebFinger resource descriptor.", {
|
103
|
+
protocol: url.protocol,
|
104
|
+
redirectedProtocol: redirectedUrl.protocol
|
105
|
+
});
|
106
|
+
return null;
|
107
|
+
}
|
108
|
+
url = redirectedUrl;
|
109
|
+
continue;
|
110
|
+
}
|
111
|
+
if (!response.ok) {
|
112
|
+
logger.debug("Failed to fetch WebFinger resource descriptor: {status} {statusText}.", {
|
113
|
+
url: url.href,
|
114
|
+
status: response.status,
|
115
|
+
statusText: response.statusText
|
116
|
+
});
|
117
|
+
return null;
|
118
|
+
}
|
119
|
+
try {
|
120
|
+
return await response.json();
|
121
|
+
} catch (e) {
|
122
|
+
if (e instanceof SyntaxError) {
|
123
|
+
logger.debug("Failed to parse WebFinger resource descriptor as JSON: {error}", { error: e });
|
124
|
+
return null;
|
125
|
+
}
|
126
|
+
throw e;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
//#endregion
|
132
|
+
Object.defineProperty(exports, 'lookupWebFinger', {
|
133
|
+
enumerable: true,
|
134
|
+
get: function () {
|
135
|
+
return lookupWebFinger;
|
136
|
+
}
|
137
|
+
});
|
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-BKf9RWX4.js";
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
8
8
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-
|
6
|
+
import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-DF9yoIpt.js";
|
7
7
|
import { cloneDeep, delay } from "es-toolkit";
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('./transformers-CoBS-oFG.cjs');
|
6
|
+
require('./docloader-eqgyMp7h.cjs');
|
7
|
+
require('./actor-CfaqWvJb.cjs');
|
8
|
+
const require_middleware = require('./middleware-B2DFqtJ-.cjs');
|
9
|
+
require('./lookup-D96ipStp.cjs');
|
10
|
+
require('./key-19P2dWvf.cjs');
|
11
|
+
require('./http-_vjuGcXn.cjs');
|
12
|
+
require('./proof-CRHppbRk.cjs');
|
13
|
+
require('./types-DcKQIzdO.cjs');
|
14
|
+
require('./authdocloader-BVYv0Ct8.cjs');
|
15
|
+
require('./vocab-Du8FV6H1.cjs');
|
16
|
+
|
17
|
+
exports.FederationImpl = require_middleware.FederationImpl;
|