-
-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
component/actorActor dispatcher relatedActor dispatcher relatedcomponent/federationFederation object relatedFederation object relatedexamplesExample code relatedExample code relatedgood first issueGood for newcomersGood for newcomerstype/enhancementImprovements to existing featuresImprovements to existing features
Description
Summary
Add Context.getActorFirstKeyByUsage(id) and Context.getActorKeysByUsage(id) s.t
federation.setActorDispatcher(
"/users/{identifier}",
async (ctx, id) => {
const { publicKey, assertionMethod } = await ctx.getActorFirstKeyByUsage(id)`.
return new Person({ /* ... */, publicKey, assertionMethod });
},
)and
federation.setActorDispatcher(
"/users/{identifier}",
async (ctx, id) => {
const { publicKeys, assertionMethods } = await ctx.getActorKeysByUsage(id)`.
return new Person({ /* ... */, publicKeys, assertionMethods });
},
)Problem
Because this is too confused:
federation.setActorDispatcher(
"/users/{identifier}",
async (ctx, id) => {
const keys = await ctx.getActorKeyPairs(id);
return new Person({
// ...
publicKey: keys.map((key) => key.cryptographicKey)[0],
assertionMethod: keys.map((key) => key.multikey)[0],
});
},
)Proposed Solution
Add followings to packages/fedify/src/federation/middleware.ts:
export class ContextImpl<TContextData> implements Context<TContextData> {
// ...
async getActorKeysByUsage(identifier: string): Promise<{
publicKeys: CryptographicKey[];
assertionMethods: Multikey[];
}> {
return this.getActorKeyPairs(identifier)
.then((keys) => ({
publicKeys: keys.map((k) => k.cryptographicKey),
assertionMethods: keys.map((k) => k.multikey),
}));
}
async getActorFirstKeyByUsage(identifier: string): Promise<{
publicKey: CryptographicKey;
assertionMethod: Multikey;
}> {
return this.getActorKeysByUsage(identifier)
.then(({ publicKeys, assertionMethods }) => ({
publicKey: publicKeys[0],
assertionMethod: assertionMethods[0],
}));
}
}Alternatives Considered
No response
Scope / Dependencies
No response
Metadata
Metadata
Assignees
Labels
component/actorActor dispatcher relatedActor dispatcher relatedcomponent/federationFederation object relatedFederation object relatedexamplesExample code relatedExample code relatedgood first issueGood for newcomersGood for newcomerstype/enhancementImprovements to existing featuresImprovements to existing features