PASETO tokens for OCaml - v3.local (AES-256-CTR) and v4.local (XChaCha20)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-paseto: rewrite README example against the real API

The block called [Paseto.V4.Local.encrypt] and [Json.obj] / [Json.string]
— neither exists in the library. The high-level claims API is
[Paseto.v3_encrypt] / [Paseto.v3_decrypt] over [Paseto.claims].
Wrap as [issue_and_validate ~key = ...], build claims via
[{ Paseto.empty_claims with sub = ... }], and pattern-match the
[(_, error) result] returns. Add [fmt] to the mdx libraries.

+9 -9
+8 -8
README.md
··· 29 29 the claims: 30 30 31 31 ```ocaml 32 - let claims = 33 - Json.obj 34 - [ "sub", Json.string "user-123" 35 - ; "scope", Json.string "admin" 36 - ] 37 - 38 - let token = Paseto.V4.Local.encrypt ~key claims 39 - let claims = Paseto.V4.Local.decrypt ~key token 32 + let issue_and_validate ~key = 33 + let claims = { Paseto.empty_claims with sub = Some "user-123" } in 34 + match Paseto.v3_encrypt ~key claims with 35 + | Error e -> Fmt.failwith "encrypt: %a" Paseto.pp_error e 36 + | Ok token -> ( 37 + match Paseto.v3_decrypt ~key token with 38 + | Ok decoded -> decoded 39 + | Error e -> Fmt.failwith "decrypt: %a" Paseto.pp_error e) 40 40 ```
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries paseto nox-json)) 7 + (libraries paseto nox-json fmt))