ocaml-jose icon indicating copy to clipboard operation
ocaml-jose copied to clipboard

Overhaul the API

Open ulrikstrid opened this issue 3 years ago • 1 comments

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 avatar Apr 26 '21 20:04 ulrikstrid

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.

aantron avatar Apr 27 '21 11:04 aantron