Bot releases are visible (Hide)
Published by Widcket about 2 years ago
💡 Check the Migration Guide to understand the changes required to migrate your application to v3.
⚠️ BREAKING CHANGES
DecodeError
and error case #162 (Widcket)Added
Changed
Published by Widcket over 2 years ago
💡 Check the Migration Guide to understand the changes required to migrate your application to v3.
⚠️ BREAKING CHANGES
DecodeError
and error case #162 (Widcket)Added
Changed
Published by cocojoe almost 6 years ago
Published by hzalaz about 8 years ago
Support for Xcode 8 & Swift 3.
Following Swift API Guidelines, all functions and methods requires a parameter label.
So now to decode a token
try JWTDecode.decode(jwt: "token")
Also now JWTDecode errors conforms the protocol LocalizableError
public enum DecodeError: LocalizedError {
case invalidBase64Url(String)
case invalidJSON(String)
case invalidPartCount(String, Int)
public var localizedDescription: String {
switch self {
case .invalidJSON(let value):
return NSLocalizedString("Malformed jwt token, failed to parse JSON value from base64Url \(value)", comment: "Invalid JSON value inside base64Url")
case .invalidPartCount(let jwt, let parts):
return NSLocalizedString("Malformed jwt token \(jwt) has \(parts) parts when it should have 3 parts", comment: "Invalid amount of jwt parts")
case .invalidBase64Url(let value):
return NSLocalizedString("Malformed jwt token, failed to decode base64Url value \(value)", comment: "Invalid JWT token base64Url value")
}
}
}
Published by hzalaz about 8 years ago
Support for Xcode 8 & Swift 2.3.
Published by hzalaz about 8 years ago
Changed:
Added:
Deprecated:
To provide a better experience while dealing with claims and converting their values to Swift types, we deprecated the following method to retrive JWT claims
public func claim<T>(name: String) -> T?
In favor of the following method to retrieve the claim
let claim = jwt.claim(name: "claim_name")
and then you can try converting it's value to the proper type like
if let email = claim.string {
print("JWT had email \(email)")
}
The supported conversions are:
var string: String?
var integer: Int?
var double: Double?
var date: NSDate?
var array: [String]?