gwt

Types

pub type Algorithm {
  HS256
}

Constructors

  • HS256
pub opaque type Jwt
pub type JwtDecodeError {
  MissingHeader
  MissingPayload
  MissingSignature
  InvalidHeader
  InvalidPayload
  InvalidSignature
  NoAlg
}

Constructors

  • MissingHeader
  • MissingPayload
  • MissingSignature
  • InvalidHeader
  • InvalidPayload
  • InvalidSignature
  • NoAlg

Functions

pub fn from_signed_string(
  jwt_string: String,
  secret: String,
) -> Result(Jwt, JwtDecodeError)
pub fn from_string(
  jwt_string: String,
) -> Result(Jwt, JwtDecodeError)
pub fn get_issuer(from jwt: Jwt) -> Result(String, Nil)
pub fn get_payload_claim(
  from jwt: Jwt,
  claim claim: String,
  decoder decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> Result(a, Nil)
pub fn get_subject(from jwt: Jwt) -> Result(String, Nil)
pub fn new() -> Jwt
pub fn set_header_claim(
  jwt: Jwt,
  set claim: String,
  to value: Json,
) -> Jwt
pub fn set_payload_audience(jwt: Jwt, to aud: String) -> Jwt
pub fn set_payload_claim(
  jwt: Jwt,
  set claim: String,
  to value: Json,
) -> Jwt
pub fn set_payload_expiration(jwt: Jwt, to exp: Int) -> Jwt
pub fn set_payload_issued_at(jwt: Jwt, to iat: Int) -> Jwt
pub fn set_payload_issuer(jwt: Jwt, to iss: String) -> Jwt
pub fn set_payload_jwt_id(jwt: Jwt, to jti: String) -> Jwt
pub fn set_payload_not_before(jwt: Jwt, to nbf: Int) -> Jwt
pub fn set_payload_subject(jwt: Jwt, to sub: String) -> Jwt
pub fn to_signed_string(
  jwt: Jwt,
  alg: Algorithm,
  secret: String,
) -> String
pub fn to_string(jwt: Jwt) -> String
Search Document