ucan-wg / ts-ucan

Auth tokens for a distributed, user-controlled world
https://www.npmjs.com/package/ucans
Apache License 2.0
101 stars 12 forks source link

Builder.delegateCapability fails for tokens originating from delegation #86

Open dholms opened 2 years ago

dholms commented 2 years ago

delegateCapability on the Builder API passes the issuer as both audience and requiredIssuer to Store.findWithCapability.

This works if the UCAN you are looking for has the capability by parenthood but not if the capability came from delegation

https://github.com/ucan-wg/ts-ucan/blob/main/packages/core/src/builder.ts#L224

matheus23 commented 2 years ago

Yeah, right.

It seems like we'd need to actually provide the expected rootIssuer to delegateCapability, in case a Store was passed to it.

Maybe delegateCapability should just be two functions with two different signatures.

Possibly with better names :sweat_smile:

Maybe we can drop the Capability, so it's just delegate and delegateFromStore. And simplify the param name from requiredCapability to capability.