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: server validation hooks #34

Merged
merged 2 commits into from
Jun 15, 2022
Merged

feat: server validation hooks #34

merged 2 commits into from
Jun 15, 2022

Conversation

Gozala
Copy link
Collaborator

@Gozala Gozala commented Jun 15, 2022

This pull request partially implements capability validation on the server. Here is rough overview of the changes:

  1. Server.create now requires id: Identity field and will check validate that received invocations have it as audience.
  2. Server.create now takes optional canIssue, my, resolve and authority fields and passes them via context argument so that they can be passed to validator's access function. If not provided sensible defaults are derived.
  3. New handler.js module on the server exports provide(capability, handler) function which can be used to bind capability parser with it's handler. This could be used to simplify UCAN validation until better API is added. (see handler.spec.js for the examples)
  4. ⚠️ URI parser thingy got replaced with slightly different URI thingy. Now you can use with: URI when you don't care about protocol and you have to use URI.match({ protocol: 'did:' }) when you want URIs with a specific protocol.
    • API changes was required to make some typings work better as TS would sometimes fail with the older one.
  5. Link decoder had been added, which is roughly equivalent of URI decoder but for CIDs. (I found myself writing it all over the place and it made sense to just have a thing out of the box).
  6. I end up reexporting dag-ucan from @ucanto/core to avoid depending on both from everywhere. This way less things can get out of sync.

- server now takes `id` to compare it with invocation `audience`
- added new provide function that binds capability to a its handler
@Gozala Gozala requested a review from hugomrdias June 15, 2022 08:23
@Gozala Gozala merged commit ea89f97 into main Jun 15, 2022
@Gozala Gozala mentioned this pull request Dec 2, 2022
This was referenced Dec 14, 2022
@github-actions github-actions bot mentioned this pull request Apr 11, 2023
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.

1 participant