Header

public struct Header : Codable

A representation of a JSON Web Token header. https://tools.ietf.org/html/rfc7515#section-4.1

Usage Example:

struct MyClaims: Claims {
   var name: String
}
let myHeader = Header(kid: "keyID")
let jwt = JWT(header: myHeader, claims: MyClaims(name: "Kitura"))
  • typ

    Type Header Parameter

    Declaration

    Swift

    public var typ: String?
  • alg

    Algorithm Header Parameter

    Declaration

    Swift

    public internal(set) var alg: String? { get }
  • jku

    JSON Web Token Set URL Header Parameter

    Declaration

    Swift

    public var jku: String?
  • jwk

    JSON Web Key Header Parameter

    Declaration

    Swift

    public var jwk: String?
  • kid

    Key ID Header Parameter

    Declaration

    Swift

    public var kid: String?
  • x5u

    X.509 URL Header Parameter

    Declaration

    Swift

    public var x5u: String?
  • x5c

    X.509 Certificate Chain Header Parameter

    Declaration

    Swift

    public var x5c: [String]?
  • x5t

    X.509 Certificate SHA-1 Thumbprint Header Parameter

    Declaration

    Swift

    public var x5t: String?
  • X.509 Certificate SHA-256 Thumbprint Header Parameter

    Declaration

    Swift

    public var x5tS256: String?
  • cty

    Content Type Header Parameter

    Declaration

    Swift

    public var cty: String?
  • Critical Header Parameter

    Declaration

    Swift

    public var crit: [String]?
  • Initialize a Header instance.

    Declaration

    Swift

    public init(
        typ: String? = "JWT",
        jku: String? = nil,
        jwk: String? = nil,
        kid: String? = nil,
        x5u: String? = nil,
        x5c: [String]? = nil,
        x5t: String? = nil,
        x5tS256: String? = nil,
        cty: String? = nil,
        crit: [String]? = nil
    )

    Parameters

    typ

    The Type Header Parameter

    jku

    The JSON Web Token Set URL Header Parameter

    jwk

    The JSON Web Key Header Parameter

    kid

    The Key ID Header Parameter

    x5u

    The X.509 URL Header Parameter

    x5c

    The X.509 Certificate Chain Header Parameter

    x5t

    The X.509 Certificate SHA-1 Thumbprint Header Parameter

    x5tS256

    X.509 Certificate SHA-256 Thumbprint Header Parameter

    cty

    The Content Type Header Parameter

    crit

    The Critical Header Parameter

    Return Value

    A new instance of Header.