ocaml-jose
ocaml-jose copied to clipboard
Overhaul the API
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
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
orJws
. I would lean towardsJws
, because it's simpler. - The API docs should funnel people to module
Jws
as a starting point. - In module
Jws
, the most "centerpiece" function isJws.sign
, and it should come first among all the functions. - Both
Jws.sign
andJwt.sign
take a~header:Header.t
argument. My understanding is that it's possible to get basic Jwt usage with onlyalg
, however there are 8 other fields which must be manually set toNone
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.