@fedify/testing 1.10.1 → 1.10.2

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/mod.cjs CHANGED
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const __fedify_fedify_federation = __toESM(require("@fedify/fedify/federation"));
25
24
  const __fedify_fedify_vocab = __toESM(require("@fedify/fedify/vocab"));
25
+ const __fedify_fedify_federation = __toESM(require("@fedify/fedify/federation"));
26
26
 
27
27
  //#region src/docloader.ts
28
28
  const mockDocumentLoader = async (url) => ({
@@ -205,6 +205,7 @@ var MockFederation = class {
205
205
  nodeInfoDispatcher;
206
206
  webFingerDispatcher;
207
207
  actorDispatchers = /* @__PURE__ */ new Map();
208
+ actorKeyPairsDispatcher;
208
209
  actorPath;
209
210
  inboxPath;
210
211
  outboxPath;
@@ -242,7 +243,10 @@ var MockFederation = class {
242
243
  this.actorDispatchers.set(path, dispatcher);
243
244
  this.actorPath = path;
244
245
  return {
245
- setKeyPairsDispatcher: () => this,
246
+ setKeyPairsDispatcher: (keyPairsDispatcher) => {
247
+ this.actorKeyPairsDispatcher = keyPairsDispatcher;
248
+ return this;
249
+ },
246
250
  mapHandle: () => this,
247
251
  mapAlias: () => this,
248
252
  authorize: () => this
@@ -678,8 +682,25 @@ var MockContext = class MockContext {
678
682
  }
679
683
  return null;
680
684
  }
681
- getActorKeyPairs(_identifier) {
682
- return Promise.resolve([]);
685
+ async getActorKeyPairs(identifier) {
686
+ if (this.federation instanceof MockFederation && this.federation.actorKeyPairsDispatcher) {
687
+ const keyPairs = await this.federation.actorKeyPairsDispatcher(this, identifier);
688
+ const owner = this.getActorUri(identifier);
689
+ return keyPairs.map((kp) => ({
690
+ ...kp,
691
+ cryptographicKey: new __fedify_fedify_vocab.CryptographicKey({
692
+ id: kp.keyId,
693
+ owner,
694
+ publicKey: kp.publicKey
695
+ }),
696
+ multikey: new __fedify_fedify_vocab.Multikey({
697
+ id: kp.keyId,
698
+ controller: owner,
699
+ publicKey: kp.publicKey
700
+ })
701
+ }));
702
+ }
703
+ return [];
683
704
  }
684
705
  getDocumentLoader(params) {
685
706
  if ("keyId" in params) return this.documentLoader;
package/dist/mod.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Context, Federation, InboxContext, RequestContext } from "@fedify/fedify/federation";
2
1
  import { Activity } from "@fedify/fedify/vocab";
2
+ import { Context, Federation, InboxContext, RequestContext } from "@fedify/fedify/federation";
3
3
 
4
4
  //#region src/context.d.ts
5
5
  declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
package/dist/mod.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { CryptographicKey, Multikey, lookupObject, traverseCollection } from "@fedify/fedify/vocab";
1
2
  import { RouterError } from "@fedify/fedify/federation";
2
- import { lookupObject, traverseCollection } from "@fedify/fedify/vocab";
3
3
 
4
4
  //#region src/docloader.ts
5
5
  const mockDocumentLoader = async (url) => ({
@@ -182,6 +182,7 @@ var MockFederation = class {
182
182
  nodeInfoDispatcher;
183
183
  webFingerDispatcher;
184
184
  actorDispatchers = /* @__PURE__ */ new Map();
185
+ actorKeyPairsDispatcher;
185
186
  actorPath;
186
187
  inboxPath;
187
188
  outboxPath;
@@ -219,7 +220,10 @@ var MockFederation = class {
219
220
  this.actorDispatchers.set(path, dispatcher);
220
221
  this.actorPath = path;
221
222
  return {
222
- setKeyPairsDispatcher: () => this,
223
+ setKeyPairsDispatcher: (keyPairsDispatcher) => {
224
+ this.actorKeyPairsDispatcher = keyPairsDispatcher;
225
+ return this;
226
+ },
223
227
  mapHandle: () => this,
224
228
  mapAlias: () => this,
225
229
  authorize: () => this
@@ -655,8 +659,25 @@ var MockContext = class MockContext {
655
659
  }
656
660
  return null;
657
661
  }
658
- getActorKeyPairs(_identifier) {
659
- return Promise.resolve([]);
662
+ async getActorKeyPairs(identifier) {
663
+ if (this.federation instanceof MockFederation && this.federation.actorKeyPairsDispatcher) {
664
+ const keyPairs = await this.federation.actorKeyPairsDispatcher(this, identifier);
665
+ const owner = this.getActorUri(identifier);
666
+ return keyPairs.map((kp) => ({
667
+ ...kp,
668
+ cryptographicKey: new CryptographicKey({
669
+ id: kp.keyId,
670
+ owner,
671
+ publicKey: kp.publicKey
672
+ }),
673
+ multikey: new Multikey({
674
+ id: kp.keyId,
675
+ controller: owner,
676
+ publicKey: kp.publicKey
677
+ })
678
+ }));
679
+ }
680
+ return [];
660
681
  }
661
682
  getDocumentLoader(params) {
662
683
  if ("keyId" in params) return this.documentLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/testing",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "Testing utilities for Fedify applications",
5
5
  "keywords": [
6
6
  "fedify",
@@ -50,7 +50,7 @@
50
50
  "package.json"
51
51
  ],
52
52
  "peerDependencies": {
53
- "@fedify/fedify": "^1.10.1"
53
+ "@fedify/fedify": "^1.10.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@js-temporal/polyfill": "^0.5.1",