Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow api inferring capabilities #259

Merged
merged 5 commits into from
Mar 14, 2023
Merged

feat: allow api inferring capabilities #259

merged 5 commits into from
Mar 14, 2023

Conversation

Gozala
Copy link
Collaborator

@Gozala Gozala commented Mar 14, 2023

Implements subset of #254 that can be used to derive set of capabilities provided by one or more delegations.

@Gozala Gozala requested a review from gobengo March 14, 2023 07:09
capabilities: [
{
with: alice.did(),
can: 'store/*',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to test that store/* allows store/add

Copy link
Contributor

@gobengo gobengo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple questions above, but no need to block

@Gozala Gozala added this to the w3up phase 3 milestone Mar 14, 2023
@travis
Copy link
Contributor

travis commented Mar 14, 2023

this looks awesome! I've started using it in my local so I'm excited for this to ship. one question - you aren't re-exporting the new function from lib.js so the only way I could use this locally was like:

import * as ucanto from '@ucanto/core'
...
export function canDelegateCapability(delegation, child) {
  const allowsCapabilities = ucanto.Delegation.allows(delegation)
...

which typescript still isn't super happy with (but it compiles and runs just fine):

Property 'allows' does not exist on type 'typeof import("/Users/travis/dev/pl/w3protocol/node_modules/.pnpm/@[email protected]/node_modules/@ucanto/core/dist/src/delegation")'.ts(2339)

could just be a transient TS failure but curious if you think this function is worth re-exporting manually like we do with delegation and isDelegation in https://github.com/web3-storage/ucanto/blob/feat/cap-query/packages/core/src/lib.js ?

@Gozala
Copy link
Collaborator Author

Gozala commented Mar 14, 2023


could just be a transient TS failure but curious if you think this function is worth re-exporting manually like we do with delegation and isDelegation in https://github.com/web3-storage/ucanto/blob/feat/cap-query/packages/core/src/lib.js ?

I suspect that error happens because typedefs have not been generated when you linked locally so it still refers to and old version.

In other words I would expect ucanto.Delegation.allows to work fine. For now I don't want to expose this using ucanto.allows as I'm not confident we're going to keep it as is, so making it less prominent seems like a better idea.

@Gozala Gozala requested a review from gobengo March 14, 2023 21:07
@Gozala
Copy link
Collaborator Author

Gozala commented Mar 14, 2023

@gobengo I have addressed some of the comments and added more tests, which lead me discover cases where behavior was not accurate. I did bunch of changes to address those cases & it would help to have another review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants