diff --git a/packages/interface/src/lib.ts b/packages/interface/src/lib.ts index 46bcb6f2..185c4035 100644 --- a/packages/interface/src/lib.ts +++ b/packages/interface/src/lib.ts @@ -386,6 +386,9 @@ export type InvocationError = export interface InvocationContext extends ValidatorOptions { id: Verifier + /** Additional authorities that may verify the invocation. */ + authorities?: Verifier[] + resolve?: (proof: UCANLink) => Await> principal: PrincipalParser diff --git a/packages/server/src/handler.js b/packages/server/src/handler.js index 2a73cd1e..1900beea 100644 --- a/packages/server/src/handler.js +++ b/packages/server/src/handler.js @@ -54,6 +54,26 @@ export const provideAdvanced = return new InvalidAudience({ cause: result }) } + // Find valid proof chain by checking configured authroities. + for (const authority of options.authorities ?? []) { + const authorization = await access(invocation, { + ...options, + authority, + capability + }) + if (authorization.error) { + continue + } else { + return /** @type {API.Result, {error:true} & Exclude>|API.InvocationError>} */ ( + handler({ + capability: authorization.capability, + invocation, + context: options + }) + ) + } + } + const authorization = await access(invocation, { ...options, authority: options.id,