-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Problem
Given that we have support for can: * and with: ucan:* it is no longer clear just by looking at the .capabilities what resources and actions are delegated by the specific delegation. In most cases { can: *, with: ucan:* } would be re-delegating capabilities from the linked proofs.
Proposal
It would be a good idea to introduce new function into the @ucanto/core that allows querying capabilities provided, which could look something along the lines of:
interface Extension {
allows(delegation: Delegation, match?: Allows): Allows
}
interface Allows {
[key:Resource]: {
[key:Ability]: Record<string, unknown>[]
}
}Note that it maps the structure we're considering in next version of UCANs, but it also provides more convenient way to identify resources (spaces). Optional match also seems like good way to check for specific capability without having to iterate over results and what not.
I would expect implementation to go down the delegation chain until it's able to loose all the * or until it reaches the bottom.
It would be nice to provide a way to consider linked proofs that aren't included, but it's probably out of scope here.
Doing validation is also tempting but I think it should be out of scope here as well.