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.

jwt, paseto: migrate to new Json API (Codec. submodule, of_string, structured errors)

- Codec combinators moved to Json.Codec.* (Object, string, int, etc.).
- Json_bytesrw sublib collapsed into core: Json.of_string / Json.to_string.
- Json.Error.t returned by decode/encode; wrap with Json.Error.to_string when
feeding into library-specific string error types.
- Dune files drop the json.bytesrw dep (rolled into json).

+13 -12
+1 -1
lib/dune
··· 1 1 (library 2 2 (name paseto) 3 3 (public_name paseto) 4 - (libraries crypto crypto-rng digestif eqaf base64 fmt json json.bytesrw)) 4 + (libraries crypto crypto-rng digestif eqaf base64 fmt json))
+12 -11
lib/paseto.ml
··· 381 381 382 382 (** JSON codec for claims *) 383 383 let claims_jsont = 384 - Json.Object.map ~kind:"paseto_claims" (fun iss sub aud exp nbf iat jti -> 384 + Json.Codec.Object.map ~kind:"paseto_claims" 385 + (fun iss sub aud exp nbf iat jti -> 385 386 { iss; sub; aud; exp; nbf; iat; jti; custom = [] }) 386 - |> Json.Object.opt_mem "iss" Json.string ~enc:(fun c -> c.iss) 387 - |> Json.Object.opt_mem "sub" Json.string ~enc:(fun c -> c.sub) 388 - |> Json.Object.opt_mem "aud" Json.string ~enc:(fun c -> c.aud) 389 - |> Json.Object.opt_mem "exp" Json.string ~enc:(fun c -> c.exp) 390 - |> Json.Object.opt_mem "nbf" Json.string ~enc:(fun c -> c.nbf) 391 - |> Json.Object.opt_mem "iat" Json.string ~enc:(fun c -> c.iat) 392 - |> Json.Object.opt_mem "jti" Json.string ~enc:(fun c -> c.jti) 393 - |> Json.Object.skip_unknown |> Json.Object.finish 387 + |> Json.Codec.Object.opt_mem "iss" Json.Codec.string ~enc:(fun c -> c.iss) 388 + |> Json.Codec.Object.opt_mem "sub" Json.Codec.string ~enc:(fun c -> c.sub) 389 + |> Json.Codec.Object.opt_mem "aud" Json.Codec.string ~enc:(fun c -> c.aud) 390 + |> Json.Codec.Object.opt_mem "exp" Json.Codec.string ~enc:(fun c -> c.exp) 391 + |> Json.Codec.Object.opt_mem "nbf" Json.Codec.string ~enc:(fun c -> c.nbf) 392 + |> Json.Codec.Object.opt_mem "iat" Json.Codec.string ~enc:(fun c -> c.iat) 393 + |> Json.Codec.Object.opt_mem "jti" Json.Codec.string ~enc:(fun c -> c.jti) 394 + |> Json.Codec.Object.skip_unknown |> Json.Codec.Object.finish 394 395 395 - let encode_claims claims = Json_bytesrw.encode_string claims_jsont claims 396 - let decode_claims s = Json_bytesrw.decode_string claims_jsont s 396 + let encode_claims claims = Json.to_string claims_jsont claims 397 + let decode_claims s = Json.of_string claims_jsont s 397 398 398 399 (** {1 Convenience functions} *) 399 400