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

Overhaul the API #34

Open
ulrikstrid opened this issue Apr 26, 2021 · 1 comment
Open

Overhaul the API #34

ulrikstrid opened this issue Apr 26, 2021 · 1 comment
Milestone

Comments

@ulrikstrid
Copy link
Owner

The API is needlessly complex currently, we can simplify a lot of the things that are normally done with the library like signing things.

I would love suggestions and hear pain points of the current API.

cc @aantron and @anmonteiro that might have some ideas

@ulrikstrid ulrikstrid added this to the 1.0.0 milestone Apr 26, 2021
@aantron
Copy link

aantron commented Apr 27, 2021

I suggest:

  • Adding an example to the README of using what I think (based on your explanation, thank you) are the most basic modules: either Jwt or Jws. I would lean towards Jws, because it's simpler.
  • The API docs should funnel people to module Jws as a starting point.
  • In module Jws, the most "centerpiece" function is Jws.sign, and it should come first among all the functions.
  • Both Jws.sign and Jwt.sign take a ~header:Header.t argument. My understanding is that it's possible to get basic Jwt usage with only alg, however there are 8 other fields which must be manually set to None for such usage. If that's accurate, I'd recommend turning this record into a bunch of optional arguments, or a single argument where the fields are given as elements of a polymorphic variant list.
  • The reasons why signing can fail should probably be explained — normally, you'd expect anything to be signable, so I suspect this is due to constraints on keys.

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

No branches or pull requests

2 participants