Jwt

@objc(VSSJwt)
public final class Jwt : NSObject, AccessToken

Class implementing AccessToken in terms of Virgil JWT

  • Represents JWT Header content

    Declaration

    Swift

    @objc
    public let headerContent: JwtHeaderContent
  • Represents JWT Body content

    Declaration

    Swift

    @objc
    public let bodyContent: JwtBodyContent
  • Represents JWT Signature content

    Declaration

    Swift

    @objc
    public let signatureContent: JwtSignatureContent
  • Initializes Jwt with provided header, body and signature content

    Declaration

    Swift

    @objc
    public init(headerContent: JwtHeaderContent, bodyContent: JwtBodyContent,
                signatureContent: JwtSignatureContent) throws

    Parameters

    headerContent

    header of Jwt

    bodyContent

    body of Jwt

    signatureContent

    signature of Jwt

  • Initializes Jwt from its string representation

    Declaration

    Swift

    @objc
    public init(stringRepresentation: String) throws

    Parameters

    stringRepresentation

    must be equal to base64UrlEncode(JWT Header) + “.” + base64UrlEncode(JWT Body) + “.” + base64UrlEncode(Jwt Signature)

  • Returns JWT data that should be signed

    Throws

    JwtError.utf8StrIsInvalid if utf8 string is invalid

    Declaration

    Swift

    @objc
    public func dataToSign() throws -> Data

    Return Value

    JWT data that should be signed

  • Returns JWT data that should be signed

    Throws

    JwtError.utf8StrIsInvalid if utf8 string is invalid

    Declaration

    Swift

    @objc
    public static func dataToSign(headerContent: JwtHeaderContent, bodyContent: JwtBodyContent) throws -> Data

    Parameters

    headerContent

    JWT header

    bodyContent

    JWT body

    Return Value

    JWT data that should be signed

  • Provides string representation of token

    Declaration

    Swift

    public func stringRepresentation() -> String

    Return Value

    string representation of token

  • Extracts identity

    Declaration

    Swift

    public func identity() -> String

    Return Value

    identity

  • Returns whether or not token is expired

    Declaration

    Swift

    @objc
    public func isExpired(date: Date = Date()) -> Bool

    Parameters

    date

    current date

    Return Value

    true if token is expired, false otherwise