@fedify/fedify 0.10.0-dev.187 → 0.10.0-dev.190
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGES.md +24 -0
- package/esm/federation/handler.js +2 -4
- package/esm/federation/middleware.js +115 -25
- package/esm/runtime/key.js +23 -3
- package/esm/sig/key.js +44 -16
- package/esm/testing/fixtures/example.com/key4 +7 -0
- package/esm/testing/fixtures/example.com/person2 +6 -0
- package/package.json +2 -1
- package/types/federation/callback.d.ts +16 -0
- package/types/federation/callback.d.ts.map +1 -1
- package/types/federation/context.d.ts +24 -2
- package/types/federation/context.d.ts.map +1 -1
- package/types/federation/handler.d.ts.map +1 -1
- package/types/federation/middleware.d.ts +14 -4
- package/types/federation/middleware.d.ts.map +1 -1
- package/types/runtime/key.d.ts +2 -0
- package/types/runtime/key.d.ts.map +1 -1
- package/types/sig/key.d.ts +5 -2
- package/types/sig/key.d.ts.map +1 -1
- package/types/testing/context.d.ts.map +1 -1
- package/types/testing/keys.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -8,6 +8,29 @@ Version 0.10.0
|
|
8
8
|
|
9
9
|
To be released.
|
10
10
|
|
11
|
+
- Besides RSA-PKCS#1-v1.5, Fedify now supports Ed25519 for signing and
|
12
|
+
verifying the activities. [[#55]]
|
13
|
+
|
14
|
+
- Added an optional parameter to `generateCryptoKeyPair()` function,
|
15
|
+
`algorithm`, which can be either `"RSASSA-PKCS1-v1_5"` or `"Ed25519"`.
|
16
|
+
- The `importJwk()` function now accepts Ed25519 keys.
|
17
|
+
- The `exportJwk()` function now exports Ed25519 keys.
|
18
|
+
- The `importSpki()` function now accepts Ed25519 keys.
|
19
|
+
- The `exportJwk()` function now exports Ed25519 keys.
|
20
|
+
|
21
|
+
- Now multiple key pairs can be registered for an actor.
|
22
|
+
|
23
|
+
- Added `Context.getActorKeyPairs()` method.
|
24
|
+
- Deprecated `Context.getActorKey()` method.
|
25
|
+
Use `Context.getActorKeyPairs()` method instead.
|
26
|
+
- Added `ActorKeyPair` interface.
|
27
|
+
- Added `ActorCallbackSetters.setKeyPairsDispatcher()` method.
|
28
|
+
- Added `ActorKeyPairsDispatcher` type.
|
29
|
+
- Deprecated `ActorCallbackSetters.setKeyPairDispatcher()` method.
|
30
|
+
- Deprecated `ActorKeyPairDispatcher` type.
|
31
|
+
- Deprecated the third parameter of the `ActorDispatcher` callback type.
|
32
|
+
Use `Context.getActorKeyPairs()` method instead.
|
33
|
+
|
11
34
|
- Deprecated `treatHttps` option in `FederationParameters` interface.
|
12
35
|
Instead, use the [x-forwarded-fetch] library to recognize the
|
13
36
|
`X-Forwarded-Host` and `X-Forwarded-Proto` headers.
|
@@ -19,6 +42,7 @@ To be released.
|
|
19
42
|
`following`, `followers`, `outbox`, `manuallyApprovesFollowers`, and
|
20
43
|
`url`.
|
21
44
|
|
45
|
+
[#55]: https://github.com/dahlia/fedify/issues/55
|
22
46
|
[x-forwarded-fetch]: https://github.com/dahlia/x-forwarded-fetch
|
23
47
|
|
24
48
|
|
@@ -18,8 +18,7 @@ export function acceptsJsonLd(request) {
|
|
18
18
|
export async function handleActor(request, { handle, context, actorDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized, }) {
|
19
19
|
if (actorDispatcher == null)
|
20
20
|
return await onNotFound(request);
|
21
|
-
const
|
22
|
-
const actor = await actorDispatcher(context, handle, key);
|
21
|
+
const actor = await context.getActor(handle);
|
23
22
|
if (actor == null)
|
24
23
|
return await onNotFound(request);
|
25
24
|
if (!acceptsJsonLd(request))
|
@@ -170,8 +169,7 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
|
|
170
169
|
return await onNotFound(request);
|
171
170
|
}
|
172
171
|
else if (handle != null) {
|
173
|
-
const
|
174
|
-
const actor = await actorDispatcher(context, handle, key);
|
172
|
+
const actor = await context.getActor(handle);
|
175
173
|
if (actor == null) {
|
176
174
|
logger.error("Actor {handle} not found.", { handle });
|
177
175
|
return await onNotFound(request);
|
@@ -145,6 +145,32 @@ export class Federation {
|
|
145
145
|
}
|
146
146
|
logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData, activityId: activity?.id?.href });
|
147
147
|
}
|
148
|
+
async #getKeyPairsFromHandle(url, contextData, handle) {
|
149
|
+
const logger = getLogger(["fedify", "federation", "actor"]);
|
150
|
+
if (this.#actorCallbacks?.keyPairsDispatcher == null) {
|
151
|
+
throw new Error("No actor key pairs dispatcher registered.");
|
152
|
+
}
|
153
|
+
const path = this.#router.build("actor", { handle });
|
154
|
+
if (path == null) {
|
155
|
+
logger.warn("No actor dispatcher registered.");
|
156
|
+
return [];
|
157
|
+
}
|
158
|
+
const actorUri = new URL(path, url);
|
159
|
+
const keyPairs = await this.#actorCallbacks?.keyPairsDispatcher(contextData, handle);
|
160
|
+
if (keyPairs.length < 1) {
|
161
|
+
logger.warn("No key pairs found for actor {handle}.", { handle });
|
162
|
+
}
|
163
|
+
let i = 0;
|
164
|
+
const result = [];
|
165
|
+
for (const keyPair of keyPairs) {
|
166
|
+
result.push({
|
167
|
+
...keyPair,
|
168
|
+
keyId: new URL(i == 0 ? `#main-key` : `#key-${i + 1}`, actorUri),
|
169
|
+
});
|
170
|
+
i++;
|
171
|
+
}
|
172
|
+
return result;
|
173
|
+
}
|
148
174
|
createContext(urlOrRequest, contextData) {
|
149
175
|
const request = urlOrRequest instanceof Request ? urlOrRequest : null;
|
150
176
|
const url = urlOrRequest instanceof URL
|
@@ -157,26 +183,28 @@ export class Federation {
|
|
157
183
|
}
|
158
184
|
if (this.#treatHttps)
|
159
185
|
url.protocol = "https:";
|
160
|
-
const
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
186
|
+
const getRsaKeyPairFromHandle = async (handle) => {
|
187
|
+
const keyPairs = await this.#getKeyPairsFromHandle(url, contextData, handle);
|
188
|
+
for (const keyPair of keyPairs) {
|
189
|
+
const { privateKey } = keyPair;
|
190
|
+
if (privateKey.algorithm.name === "RSASSA-PKCS1-v1_5" &&
|
191
|
+
privateKey.algorithm.hash
|
192
|
+
.name ===
|
193
|
+
"SHA-256") {
|
194
|
+
return keyPair;
|
195
|
+
}
|
169
196
|
}
|
170
|
-
|
171
|
-
|
172
|
-
privateKey: keyPair.privateKey,
|
173
|
-
};
|
197
|
+
getLogger(["fedify", "federation", "actor"]).warn("No RSA-PKCS#1-v1.5 SHA-256 key found for actor {handle}.", { handle });
|
198
|
+
return null;
|
174
199
|
};
|
175
200
|
const getAuthenticatedDocumentLoader = this.#authenticatedDocumentLoaderFactory;
|
201
|
+
const documentLoader = this.#documentLoader;
|
176
202
|
function getDocumentLoader(identity) {
|
177
203
|
if ("handle" in identity) {
|
178
|
-
const keyPair =
|
179
|
-
|
204
|
+
const keyPair = getRsaKeyPairFromHandle(identity.handle);
|
205
|
+
if (keyPair == null)
|
206
|
+
return documentLoader;
|
207
|
+
return keyPair.then((pair) => pair == null ? documentLoader : getAuthenticatedDocumentLoader(pair));
|
180
208
|
}
|
181
209
|
return getAuthenticatedDocumentLoader(identity);
|
182
210
|
}
|
@@ -294,23 +322,62 @@ export class Federation {
|
|
294
322
|
return result.handle;
|
295
323
|
return null;
|
296
324
|
},
|
325
|
+
getActorKeyPairs: async (handle) => {
|
326
|
+
let keyPairs;
|
327
|
+
try {
|
328
|
+
keyPairs = await this.#getKeyPairsFromHandle(url, contextData, handle);
|
329
|
+
}
|
330
|
+
catch (_) {
|
331
|
+
getLogger(["fedify", "federation", "actor"])
|
332
|
+
.warn("No actor key pairs dispatcher registered.");
|
333
|
+
return [];
|
334
|
+
}
|
335
|
+
const owner = context.getActorUri(handle);
|
336
|
+
const result = [];
|
337
|
+
for (const keyPair of keyPairs) {
|
338
|
+
const newPair = {
|
339
|
+
...keyPair,
|
340
|
+
cryptographicKey: new CryptographicKey({
|
341
|
+
id: keyPair.keyId,
|
342
|
+
owner,
|
343
|
+
publicKey: keyPair.publicKey,
|
344
|
+
}),
|
345
|
+
};
|
346
|
+
result.push(newPair);
|
347
|
+
}
|
348
|
+
return result;
|
349
|
+
},
|
297
350
|
getActorKey: async (handle) => {
|
298
|
-
|
299
|
-
|
300
|
-
|
351
|
+
getLogger(["fedify", "federation", "actor"]).warn("Context.getActorKey() method is deprecated; " +
|
352
|
+
"use Context.getActorKeyPairs() method instead.");
|
353
|
+
let keyPair;
|
354
|
+
try {
|
355
|
+
keyPair = await getRsaKeyPairFromHandle(handle);
|
356
|
+
}
|
357
|
+
catch (_) {
|
358
|
+
return null;
|
359
|
+
}
|
301
360
|
if (keyPair == null)
|
302
361
|
return null;
|
303
362
|
return new CryptographicKey({
|
304
|
-
id:
|
363
|
+
id: keyPair.keyId,
|
305
364
|
owner: context.getActorUri(handle),
|
306
365
|
publicKey: keyPair.publicKey,
|
307
366
|
});
|
308
367
|
},
|
309
368
|
getDocumentLoader,
|
310
369
|
sendActivity: async (sender, recipients, activity, options = {}) => {
|
311
|
-
|
312
|
-
|
313
|
-
|
370
|
+
let senderPair;
|
371
|
+
if ("handle" in sender) {
|
372
|
+
const keyPair = await getRsaKeyPairFromHandle(sender.handle);
|
373
|
+
if (keyPair == null) {
|
374
|
+
throw new Error(`No key pair found for actor ${sender.handle}`);
|
375
|
+
}
|
376
|
+
senderPair = keyPair;
|
377
|
+
}
|
378
|
+
else {
|
379
|
+
senderPair = sender;
|
380
|
+
}
|
314
381
|
const opts = { ...options };
|
315
382
|
let expandedRecipients;
|
316
383
|
if (Array.isArray(recipients)) {
|
@@ -349,6 +416,13 @@ export class Federation {
|
|
349
416
|
this.#actorCallbacks.dispatcher == null) {
|
350
417
|
throw new Error("No actor dispatcher registered.");
|
351
418
|
}
|
419
|
+
let rsaKey;
|
420
|
+
try {
|
421
|
+
rsaKey = await getRsaKeyPairFromHandle(handle);
|
422
|
+
}
|
423
|
+
catch (_) {
|
424
|
+
rsaKey = null;
|
425
|
+
}
|
352
426
|
return await this.#actorCallbacks.dispatcher({
|
353
427
|
...reqCtx,
|
354
428
|
getActor(handle2) {
|
@@ -357,7 +431,11 @@ export class Federation {
|
|
357
431
|
"this may cause an infinite loop.", { getActorHandle: handle2, actorDispatcherHandle: handle });
|
358
432
|
return reqCtx.getActor(handle2);
|
359
433
|
},
|
360
|
-
}, handle,
|
434
|
+
}, handle, rsaKey == null ? null : new CryptographicKey({
|
435
|
+
id: rsaKey.keyId,
|
436
|
+
owner: context.getActorUri(handle),
|
437
|
+
publicKey: rsaKey.publicKey,
|
438
|
+
}));
|
361
439
|
},
|
362
440
|
getObject: async (cls, values) => {
|
363
441
|
const callbacks = this.#objectCallbacks[cls.typeId.href];
|
@@ -431,7 +509,7 @@ export class Federation {
|
|
431
509
|
* ``` typescript
|
432
510
|
* federation.setActorDispatcher(
|
433
511
|
* "/users/{handle}",
|
434
|
-
* async (ctx, handle
|
512
|
+
* async (ctx, handle) => {
|
435
513
|
* return new Person({
|
436
514
|
* id: ctx.getActorUri(handle),
|
437
515
|
* preferredUsername: handle,
|
@@ -531,8 +609,20 @@ export class Federation {
|
|
531
609
|
};
|
532
610
|
this.#actorCallbacks = callbacks;
|
533
611
|
const setters = {
|
612
|
+
setKeyPairsDispatcher(dispatcher) {
|
613
|
+
callbacks.keyPairsDispatcher = dispatcher;
|
614
|
+
return setters;
|
615
|
+
},
|
534
616
|
setKeyPairDispatcher(dispatcher) {
|
535
|
-
|
617
|
+
getLogger(["fedify", "federation", "actor"]).warn("The ActorCallbackSetters.setKeyPairDispatcher() method is " +
|
618
|
+
"deprecated. Use the ActorCallbackSetters.setKeyPairsDispatcher() " +
|
619
|
+
"instead.");
|
620
|
+
callbacks.keyPairsDispatcher = async (ctxData, handle) => {
|
621
|
+
const key = await dispatcher(ctxData, handle);
|
622
|
+
if (key == null)
|
623
|
+
return [];
|
624
|
+
return [key];
|
625
|
+
};
|
536
626
|
return setters;
|
537
627
|
},
|
538
628
|
authorize(predicate) {
|
package/esm/runtime/key.js
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/0.224.3/base64.js";
|
3
|
+
import { PublicKeyInfo } from "pkijs";
|
4
|
+
import { validateCryptoKey } from "../sig/key.js";
|
5
|
+
const algorithms = {
|
6
|
+
"1.2.840.113549.1.1.1": { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
|
7
|
+
"1.3.101.112": "Ed25519",
|
8
|
+
};
|
3
9
|
/**
|
4
10
|
* Imports a PEM-SPKI formatted public key.
|
5
11
|
* @param pem The PEM-SPKI formatted public key.
|
6
12
|
* @returns The imported public key.
|
13
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
7
14
|
* @since 0.5.0
|
8
15
|
*/
|
9
16
|
export async function importSpki(pem) {
|
10
17
|
pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "");
|
11
|
-
|
12
|
-
|
13
|
-
|
18
|
+
let spki;
|
19
|
+
try {
|
20
|
+
spki = decodeBase64(pem);
|
21
|
+
}
|
22
|
+
catch (_) {
|
23
|
+
throw new TypeError("Invalid PEM-SPKI format.");
|
24
|
+
}
|
25
|
+
const pki = PublicKeyInfo.fromBER(spki);
|
26
|
+
const oid = pki.algorithm.algorithmId;
|
27
|
+
const algorithm = algorithms[oid];
|
28
|
+
if (algorithm == null) {
|
29
|
+
throw new TypeError("Unsupported algorithm: " + oid);
|
30
|
+
}
|
31
|
+
return await dntShim.crypto.subtle.importKey("spki", spki, algorithm, true, ["verify"]);
|
14
32
|
}
|
15
33
|
/**
|
16
34
|
* Exports a public key in PEM-SPKI format.
|
17
35
|
* @param key The public key to export.
|
18
36
|
* @returns The exported public key in PEM-SPKI format.
|
37
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
19
38
|
* @since 0.5.0
|
20
39
|
*/
|
21
40
|
export async function exportSpki(key) {
|
41
|
+
validateCryptoKey(key);
|
22
42
|
const spki = await dntShim.crypto.subtle.exportKey("spki", key);
|
23
43
|
let pem = encodeBase64(spki);
|
24
44
|
pem = (pem.match(/.{1,64}/g) || []).join("\n");
|
package/esm/sig/key.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import * as dntShim from "../_dnt.shims.js";
|
2
|
+
import { getLogger } from "@logtape/logtape";
|
1
3
|
/**
|
2
4
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
3
5
|
* otherwise throws an error.
|
@@ -6,7 +8,6 @@
|
|
6
8
|
* either public or private.
|
7
9
|
* @throws {TypeError} If the key is invalid or unsupported.
|
8
10
|
*/
|
9
|
-
import * as dntShim from "../_dnt.shims.js";
|
10
11
|
export function validateCryptoKey(key, type) {
|
11
12
|
if (type != null && key.type !== type) {
|
12
13
|
throw new TypeError(`The key is not a ${type} key.`);
|
@@ -14,28 +15,46 @@ export function validateCryptoKey(key, type) {
|
|
14
15
|
if (!key.extractable) {
|
15
16
|
throw new TypeError("The key is not extractable.");
|
16
17
|
}
|
17
|
-
if (key.algorithm.name
|
18
|
-
|
18
|
+
if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" &&
|
19
|
+
key.algorithm.name !== "Ed25519") {
|
20
|
+
throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. " +
|
19
21
|
"More algorithms will be added in the future!");
|
20
22
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"
|
23
|
+
if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
24
|
+
// @ts-ignore TS2304
|
25
|
+
const algorithm = key.algorithm;
|
26
|
+
if (algorithm.hash.name !== "SHA-256") {
|
27
|
+
throw new TypeError("For compatibility with the existing Fediverse software " +
|
28
|
+
"(e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys " +
|
29
|
+
"must be SHA-256.");
|
30
|
+
}
|
26
31
|
}
|
27
32
|
}
|
28
33
|
/**
|
29
34
|
* Generates a key pair which is appropriate for Fedify.
|
35
|
+
* @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
|
36
|
+
* Ed25519 are supported.
|
30
37
|
* @returns The generated key pair.
|
38
|
+
* @throws {TypeError} If the algorithm is unsupported.
|
31
39
|
*/
|
32
|
-
export function generateCryptoKeyPair() {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
export function generateCryptoKeyPair(algorithm) {
|
41
|
+
if (algorithm == null) {
|
42
|
+
getLogger(["fedify", "sig", "key"]).warn("No algorithm specified. Using RSASSA-PKCS1-v1_5 by default, but " +
|
43
|
+
"it is recommended to specify the algorithm explicitly as " +
|
44
|
+
"the parameter will be required in the future.");
|
45
|
+
}
|
46
|
+
if (algorithm == null || algorithm === "RSASSA-PKCS1-v1_5") {
|
47
|
+
return dntShim.crypto.subtle.generateKey({
|
48
|
+
name: "RSASSA-PKCS1-v1_5",
|
49
|
+
modulusLength: 4096,
|
50
|
+
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
51
|
+
hash: "SHA-256",
|
52
|
+
}, true, ["sign", "verify"]);
|
53
|
+
}
|
54
|
+
else if (algorithm === "Ed25519") {
|
55
|
+
return dntShim.crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
|
56
|
+
}
|
57
|
+
throw new TypeError("Unsupported algorithm: " + algorithm);
|
39
58
|
}
|
40
59
|
/**
|
41
60
|
* Exports a key in JWK format.
|
@@ -56,7 +75,16 @@ export async function exportJwk(key) {
|
|
56
75
|
* @throws {TypeError} If the key is invalid or unsupported.
|
57
76
|
*/
|
58
77
|
export async function importJwk(jwk, type) {
|
59
|
-
|
78
|
+
let key;
|
79
|
+
if (jwk.kty === "RSA" && jwk.alg === "RS256") {
|
80
|
+
key = await dntShim.crypto.subtle.importKey("jwk", jwk, { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, true, type === "public" ? ["verify"] : ["sign"]);
|
81
|
+
}
|
82
|
+
else if (jwk.kty === "OKP" && jwk.crv === "Ed25519") {
|
83
|
+
key = await dntShim.crypto.subtle.importKey("jwk", jwk, "Ed25519", true, type === "public" ? ["verify"] : ["sign"]);
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
throw new TypeError("Unsupported JWK format.");
|
87
|
+
}
|
60
88
|
validateCryptoKey(key, type);
|
61
89
|
return key;
|
62
90
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"@context": "https://w3id.org/security/v1",
|
3
|
+
"id": "https://example.com/key4",
|
4
|
+
"type": "CryptographicKey",
|
5
|
+
"owner": "https://example.com/person2",
|
6
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
7
|
+
}
|
@@ -12,6 +12,12 @@
|
|
12
12
|
"type": "CryptographicKey",
|
13
13
|
"owner": "https://example.com/person2",
|
14
14
|
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"id": "https://example.com/key4",
|
18
|
+
"type": "CryptographicKey",
|
19
|
+
"owner": "https://example.com/person2",
|
20
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
15
21
|
}
|
16
22
|
]
|
17
23
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fedify/fedify",
|
3
|
-
"version": "0.10.0-dev.
|
3
|
+
"version": "0.10.0-dev.190+4dffb89a",
|
4
4
|
"description": "An ActivityPub server framework",
|
5
5
|
"keywords": [
|
6
6
|
"ActivityPub",
|
@@ -85,6 +85,7 @@
|
|
85
85
|
"@logtape/logtape": "^0.4.0",
|
86
86
|
"@phensley/language-tag": "^1.8.0",
|
87
87
|
"jsonld": "^8.3.2",
|
88
|
+
"pkijs": "^3.1.0",
|
88
89
|
"uri-template-router": "^0.0.16",
|
89
90
|
"url-template": "^3.1.1",
|
90
91
|
"@deno/shim-deno": "~0.18.0",
|
@@ -15,12 +15,28 @@ export type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContext
|
|
15
15
|
* A callback that dispatches an {@link Actor} object.
|
16
16
|
*
|
17
17
|
* @typeParam TContextData The context data to pass to the {@link Context}.
|
18
|
+
* @param context The request context.
|
19
|
+
* @param handle The actor's handle.
|
20
|
+
* @param key The public key of the actor. **Deprecated: Do not rely on this
|
21
|
+
* parameter. Instead, use the {@link Context.getActorKeyPairs}
|
22
|
+
* method.**
|
18
23
|
*/
|
19
24
|
export type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, handle: string, key: CryptographicKey | null) => Actor | null | Promise<Actor | null>;
|
25
|
+
/**
|
26
|
+
* A callback that dispatches key pairs for an actor.
|
27
|
+
*
|
28
|
+
* @typeParam TContextData The context data to pass to the {@link Context}.
|
29
|
+
* @param contextData The context data.
|
30
|
+
* @param handle The actor's handle.
|
31
|
+
* @returns The key pairs.
|
32
|
+
* @since 0.10.0
|
33
|
+
*/
|
34
|
+
export type ActorKeyPairsDispatcher<TContextData> = (contextData: TContextData, handle: string) => dntShim.CryptoKeyPair[] | Promise<dntShim.CryptoKeyPair[]>;
|
20
35
|
/**
|
21
36
|
* A callback that dispatches a key pair for an actor.
|
22
37
|
*
|
23
38
|
* @typeParam TContextData The context data to pass to the {@link Context}.
|
39
|
+
* @deprecated
|
24
40
|
*/
|
25
41
|
export type ActorKeyPairDispatcher<TContextData> = (contextData: TContextData, handle: string) => dntShim.CryptoKeyPair | null | Promise<dntShim.CryptoKeyPair | null>;
|
26
42
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/federation/callback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,YAAY,IAAI,CAC7C,OAA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;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,YAAY,EAAE,SAAS,SAAS,QAAQ,IAAI,CACpE,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,QAAQ,EAAE,SAAS,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,YAAY,IAAI,CAC5C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,KAAK,EAAE,KAAK,KACT,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAAG,IAAI,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,CAAC,YAAY,IAAI,CAC7C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,EAAE,MAAM,SAAS,MAAM,IAAI,CAC1E,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
@@ -90,13 +90,22 @@ export interface Context<TContextData> {
|
|
90
90
|
* Extracts the actor's handle from an actor URI, if it is a valid actor URI.
|
91
91
|
* @param actorUri The actor's URI.
|
92
92
|
* @returns The actor's handle, or `null` if the URI is not a valid actor URI.
|
93
|
-
* @deprecated Use {@link parseUri} instead.
|
93
|
+
* @deprecated Use {@link Context.parseUri} instead.
|
94
94
|
*/
|
95
95
|
getHandleFromActorUri(actorUri: URL): string | null;
|
96
96
|
/**
|
97
|
-
* Gets
|
97
|
+
* Gets the key pairs for an actor.
|
98
|
+
* @param handle The actor's handle.
|
99
|
+
* @returns An async iterable of the actor's key pairs. It can be empty.
|
100
|
+
* @since 0.10.0
|
101
|
+
*/
|
102
|
+
getActorKeyPairs(handle: string): Promise<ActorKeyPair[]>;
|
103
|
+
/**
|
104
|
+
* Gets a public RSA-PKCS#1-v1.5 {@link CryptographicKey} for an actor,
|
105
|
+
* if any exists.
|
98
106
|
* @param handle The actor's handle.
|
99
107
|
* @returns The actor's public key, or `null` if the actor has no key.
|
108
|
+
* @deprecated Use {@link Context.getActorKeyPairs} instead.
|
100
109
|
*/
|
101
110
|
getActorKey(handle: string): Promise<CryptographicKey | null>;
|
102
111
|
/**
|
@@ -305,4 +314,17 @@ export interface SendActivityOptions {
|
|
305
314
|
*/
|
306
315
|
excludeBaseUris?: URL[];
|
307
316
|
}
|
317
|
+
/**
|
318
|
+
* A pair of a public key and a private key in various formats.
|
319
|
+
*/
|
320
|
+
export interface ActorKeyPair extends dntShim.CryptoKeyPair {
|
321
|
+
/**
|
322
|
+
* The URI of the public key, which is used for verifying HTTP Signatures.
|
323
|
+
*/
|
324
|
+
keyId: URL;
|
325
|
+
/**
|
326
|
+
* A {@link CryptographicKey} instance of the public key.
|
327
|
+
*/
|
328
|
+
cryptographicKey: CryptographicKey;
|
329
|
+
}
|
308
330
|
//# sourceMappingURL=context.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/federation/context.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EA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YAAY,CAAC,CAAC;IAChD,cAAc,EAAE,GAAG,CACjB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,EACpC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CACtC,CAAC;IACF,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;CACpD;AAED,wBAAsB,WAAW,CAAC,YAAY,EAC5C,OAAO,EAAE,OAAO,EAChB,EACE,MAAM,EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CA+HnB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,aAAa,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
|
@@ -4,7 +4,7 @@ import * as dntShim from "../_dnt.shims.js";
|
|
4
4
|
import { type AuthenticatedDocumentLoaderFactory, type DocumentLoader } from "../runtime/docloader.js";
|
5
5
|
import type { Actor, Recipient } from "../vocab/actor.js";
|
6
6
|
import { Activity, type Object } from "../vocab/mod.js";
|
7
|
-
import type { ActorDispatcher, ActorKeyPairDispatcher, AuthorizePredicate, CollectionCounter, CollectionCursor, CollectionDispatcher, InboxErrorHandler, InboxListener, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectDispatcher, OutboxErrorHandler } from "./callback.js";
|
7
|
+
import type { ActorDispatcher, ActorKeyPairDispatcher, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCounter, CollectionCursor, CollectionDispatcher, InboxErrorHandler, InboxListener, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectDispatcher, OutboxErrorHandler } from "./callback.js";
|
8
8
|
import type { Context, RequestContext, SendActivityOptions } from "./context.js";
|
9
9
|
import type { KvKey, KvStore } from "./kv.js";
|
10
10
|
import type { MessageQueue } from "./mq.js";
|
@@ -143,7 +143,7 @@ export declare class Federation<TContextData> {
|
|
143
143
|
* ``` typescript
|
144
144
|
* federation.setActorDispatcher(
|
145
145
|
* "/users/{handle}",
|
146
|
-
* async (ctx, handle
|
146
|
+
* async (ctx, handle) => {
|
147
147
|
* return new Person({
|
148
148
|
* id: ctx.getActorUri(handle),
|
149
149
|
* preferredUsername: handle,
|
@@ -425,16 +425,26 @@ export interface FederationFetchOptions<TContextData> {
|
|
425
425
|
* federation.setActorDispatcher("/users/{handle}", async (ctx, handle, key) => {
|
426
426
|
* ...
|
427
427
|
* })
|
428
|
-
* .
|
428
|
+
* .setKeyPairsDispatcher(async (ctxData, handle) => {
|
429
429
|
* ...
|
430
430
|
* });
|
431
431
|
* ```
|
432
432
|
*/
|
433
433
|
export interface ActorCallbackSetters<TContextData> {
|
434
434
|
/**
|
435
|
-
* Sets the key
|
435
|
+
* Sets the key pairs dispatcher for actors.
|
436
|
+
* @param dispatcher A callback that returns the key pairs for an actor.
|
437
|
+
* @returns The setters object so that settings can be chained.
|
438
|
+
* @since 0.10.0
|
439
|
+
*/
|
440
|
+
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
441
|
+
/**
|
442
|
+
* Sets the RSA-PKCS#1-v1.5 key pair dispatcher for actors.
|
443
|
+
*
|
444
|
+
* Use {@link ActorCallbackSetters.setKeyPairsDispatcher} instead.
|
436
445
|
* @param dispatcher A callback that returns the key pair for an actor.
|
437
446
|
* @returns The setters object so that settings can be chained.
|
447
|
+
* @deprecated
|
438
448
|
*/
|
439
449
|
setKeyPairDispatcher(dispatcher: ActorKeyPairDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
440
450
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAoB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAoB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV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gB,CAAC,YAAY,EAAE,OAAO,CAAC,GAC9C,yBAAyB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpD;;;;OAIG;IACH,aAAa,CACX,MAAM,EAAE,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,GAC9C,yBAAyB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,SAAS,CACP,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,GAC1C,yBAAyB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,YAAY;IAC/C;;;;;;OAMG;IACH,EAAE,CAAC,SAAS,SAAS,QAAQ,EAE3B,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EACvC,QAAQ,EAAE,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,GAC/C,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAErC;;;;;;OAMG;IACH,OAAO,CACL,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACvC,mBAAmB,CAAC,YAAY,CAAC,CAAC;CACtC;AAED,UAAU,2BAA4B,SAAQ,mBAAmB;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
package/types/runtime/key.d.ts
CHANGED
@@ -3,6 +3,7 @@ import * as dntShim from "../_dnt.shims.js";
|
|
3
3
|
* Imports a PEM-SPKI formatted public key.
|
4
4
|
* @param pem The PEM-SPKI formatted public key.
|
5
5
|
* @returns The imported public key.
|
6
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
6
7
|
* @since 0.5.0
|
7
8
|
*/
|
8
9
|
export declare function importSpki(pem: string): Promise<dntShim.CryptoKey>;
|
@@ -10,6 +11,7 @@ export declare function importSpki(pem: string): Promise<dntShim.CryptoKey>;
|
|
10
11
|
* Exports a public key in PEM-SPKI format.
|
11
12
|
* @param key The public key to export.
|
12
13
|
* @returns The exported public key in PEM-SPKI format.
|
14
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
13
15
|
* @since 0.5.0
|
14
16
|
*/
|
15
17
|
export declare function exportSpki(key: dntShim.CryptoKey): Promise<string>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/runtime/key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/runtime/key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAgB5C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAqBxE;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxE"}
|
package/types/sig/key.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import * as dntShim from "../_dnt.shims.js";
|
1
2
|
/**
|
2
3
|
* Checks if the given key is valid and supported. No-op if the key is valid,
|
3
4
|
* otherwise throws an error.
|
@@ -6,13 +7,15 @@
|
|
6
7
|
* either public or private.
|
7
8
|
* @throws {TypeError} If the key is invalid or unsupported.
|
8
9
|
*/
|
9
|
-
import * as dntShim from "../_dnt.shims.js";
|
10
10
|
export declare function validateCryptoKey(key: dntShim.CryptoKey, type?: "public" | "private"): void;
|
11
11
|
/**
|
12
12
|
* Generates a key pair which is appropriate for Fedify.
|
13
|
+
* @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
|
14
|
+
* Ed25519 are supported.
|
13
15
|
* @returns The generated key pair.
|
16
|
+
* @throws {TypeError} If the algorithm is unsupported.
|
14
17
|
*/
|
15
|
-
export declare function generateCryptoKeyPair(): Promise<dntShim.CryptoKeyPair>;
|
18
|
+
export declare function generateCryptoKeyPair(algorithm?: "RSASSA-PKCS1-v1_5" | "Ed25519"): Promise<dntShim.CryptoKeyPair>;
|
16
19
|
/**
|
17
20
|
* Exports a key in JWK format.
|
18
21
|
* @param key The key to export. Either public or private key.
|
package/types/sig/key.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/sig/key.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/sig/key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,CAAC,SAAS,EACtB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,GAC1B,IAAI,CA2BN;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,CAAC,EAAE,mBAAmB,GAAG,SAAS,GAC1C,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CA2BhC;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAGnF;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,OAAO,CAAC,UAAU,EACvB,IAAI,EAAE,QAAQ,GAAG,SAAS,GACzB,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAuB5B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/testing/context.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/testing/context.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAKxE,wBAAgB,aAAa,CAAC,YAAY,EACxC,EACE,IAAI,EACJ,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACzD,OAAO,CAAC,YAAY,CAAC,CAyDvB;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAC/C,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,GAAG;IAC5C,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,YAAY,CAAC;CACpB,GACA,cAAc,CAAC,YAAY,CAAC,CAa9B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/testing/keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/testing/keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,aAAa,kBA2BxB,CAAC;AAEH,eAAO,MAAM,cAAc,mBAyC1B,CAAC;AAEF,eAAO,MAAM,aAAa,kBAuBxB,CAAC;AAEH,eAAO,MAAM,cAAc,mBA6D1B,CAAC;AAEF,eAAO,MAAM,aAAa,kBA6BxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,mBAe7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,kBAkB3B,CAAC"}
|