diff --git a/src/main/jwt.nim b/src/main/jwt.nim index 438eaf0..67d2c62 100644 --- a/src/main/jwt.nim +++ b/src/main/jwt.nim @@ -1,3 +1,17 @@ +# jwt.nim +# Copyright 2021 Jonathan Bernard + +## +## =============================== +## jwt +## =============================== +## +## ------------------------------- +## JSON Web Token (JWT) - RFC 7519 +## ------------------------------- +## +## + import jwt/jwa, jwt/jwe, jwt/jwk, jwt/jws, jwt/jwt export jwa, jwe, jwk, jws, jwt diff --git a/src/main/jwt/claims.nim b/src/main/jwt/claims.nim index 402c819..058b3f4 100644 --- a/src/main/jwt/claims.nim +++ b/src/main/jwt/claims.nim @@ -1,3 +1,19 @@ +# jwt/claims.nim +# Copyright 2021 Jonathan Bernard + +## ==================================== +## claims +## ==================================== +## +## ------------------------------------ +## JWT Claims Object +## ------------------------------------ +## +## Data structures and utility procedures for working with JWT claims objects. +## This module follows the common pattern in this library of providing direct +## access to all of the claims members via the `[]` syntax, as well as +## convencience accessors for the publicly-defined claims. + import std/json, std/options, std/times import ../private/encoding @@ -16,8 +32,8 @@ type iat: Option[DateTime] jti: Option[string] -## Public read-only accessors to JwtClaims members -## ----------------------------------------------- +# Public read-only accessors to JwtClaims members +# ----------------------------------------------- func rawB64*(c: JwtClaims): string = c.rawB64 func iss*(c: JwtClaims): Option[string] = c.iss @@ -33,7 +49,10 @@ func `[]`*(c: JwtClaims, key: string): Option[JsonNode] = if c.json.hasKey(key): some(c.json[key]) else: none[JsonNode]() -proc `$`*(claims: JwtClaims): string = claims.rawB64 +proc `$`*(claims: JwtClaims): string = + ## Serialize a JwtClaims object to a Base64url-encoded string (as per the JWT + ## standard). + claims.rawB64 proc initJwtClaims*(n: JsonNode): JwtClaims = ## Create a JwtClaims from a given set of claims as a JsonNOde diff --git a/src/main/jwt/joseheader.nim b/src/main/jwt/joseheader.nim index 274cc31..f3546df 100644 --- a/src/main/jwt/joseheader.nim +++ b/src/main/jwt/joseheader.nim @@ -1,3 +1,19 @@ +# jwt/joseheader.nim +# Copyright 2021 Jonathan Bernard + +## ==================================== +## joseheader +## ==================================== +## +## ------------------------------------ +## JOSE Header +## ------------------------------------ +## +## Data structures and utility procedures for working with JOSE headers. This +## module follows the common pattern in this library of providing direct access +## to all of the header parameters via the `[]` syntax, as well as convencience +## accessors for the publicly-defined header parameters. + import std/json, std/options, std/sequtils, std/strutils import ./jwa, ./jwk diff --git a/src/main/jwt/jwa.nim b/src/main/jwt/jwa.nim index 174e157..640259e 100644 --- a/src/main/jwt/jwa.nim +++ b/src/main/jwt/jwa.nim @@ -1,3 +1,17 @@ +# jwt/jwa.nim +# Copyright 2021 Jonathan Bernard + +## +## ==================================== +## jwa +## ==================================== +## +## ------------------------------------ +## JSON Web Algorithms (JWA) - RFC 7518 +## ------------------------------------ +## +## Enum values reflecting the names of algorithms defined by JWA RFC 7518. + type JwtKeyType* = enum ktyEC = "EC", ktyRSA = "RSA", ktyOctet = "oct" diff --git a/src/main/jwt/jwe.nim b/src/main/jwt/jwe.nim index 82f5ae7..c210e24 100644 --- a/src/main/jwt/jwe.nim +++ b/src/main/jwt/jwe.nim @@ -1,3 +1,15 @@ +# jwt/jwe.nim +# Copyright 2021 Jonathan Bernard + +## ==================================== +## jwe +## ==================================== +## +## ------------------------------------ +## JSON Web Encryption (JWE) - RFC 7516 +## ------------------------------------ +## + import ./joseheader type diff --git a/src/main/jwt/jwk.nim b/src/main/jwt/jwk.nim index 86db528..674760b 100644 --- a/src/main/jwt/jwk.nim +++ b/src/main/jwt/jwk.nim @@ -1,3 +1,16 @@ +# jwt/jwk.nim +# Copyright 2021 Jonathan Bernard + +## ============================== +## jwk +## ============================== +## +## ------------------------------ +## JSON Web Keys (JWK) - RFC 7518 +## ------------------------------ +## +## Nim implementation of the data structures and constants defined in RFC 7518. + import std/json, std/options, std/sequtils, std/strutils import ../private/jsonutils @@ -63,8 +76,8 @@ type JwkSet* = seq[JWK] -## Read-only public accessors to JWK members -## ----------------------------------------- +# Read-only public accessors to JWK members +# ----------------------------------------- func kty*(jwk: JWK): string = jwk.kty func use*(jwk: JWK): Option[string] = jwk.use diff --git a/src/main/jwt/jws.nim b/src/main/jwt/jws.nim index ee52b09..905eb23 100644 --- a/src/main/jwt/jws.nim +++ b/src/main/jwt/jws.nim @@ -1,3 +1,15 @@ +# jwt/jws.nim +# Copyright 2021 Jonathan Bernard + +## ==================================== +## jws +## ==================================== +## +## ------------------------------------ +## JSON Web Signature (JWS) - RFC 7515 +## ------------------------------------ +## + import std/json, std/logging, std/options, std/sequtils, std/strutils import ../private/crypto diff --git a/src/main/jwt/jwssig.nim b/src/main/jwt/jwssig.nim index 311d543..75e1ec2 100644 --- a/src/main/jwt/jwssig.nim +++ b/src/main/jwt/jwssig.nim @@ -1,3 +1,14 @@ +# jwt/jwssig.nim +# Copyright 2021 Jonathan Bernard + +## ===================================== +## JwsSig +## ===================================== +## +## ------------------------------------- +## JwsSignature object and procedures. +## ------------------------------------- + import std/json, std/options import ./jwa diff --git a/src/main/jwt/jwt.nim b/src/main/jwt/jwt.nim index 0d5df4d..c78a4d2 100644 --- a/src/main/jwt/jwt.nim +++ b/src/main/jwt/jwt.nim @@ -1,3 +1,16 @@ +# jwt/jwt.nim +# Copyright 2021 Jonathan Bernard + +## =============================== +## jwt +## =============================== +## +## ------------------------------- +## JSON Web Token (JWT) - RFC 7519 +## ------------------------------- +## +## + import std/json, std/options, std/strutils, std/times import ./claims, ./joseheader, ./jwa, ./jwe, ./jwk, ./jws, ./jwssig @@ -15,8 +28,8 @@ type of jkJWE: jwe: JWE of jkJWS: jws: JWS -## Public read-only accessors to JWT members -## ----------------------------------------- +# Public read-only accessors to JWT members +# ----------------------------------------- func claims*(jwt: JWT): JwtClaims = jwt.claims