If the JWT is malformed the decode(jwt:) function will throw a JWTDecodeError.
catch let error as JWTDecodeError {
print(error)
}
Support Policy
This Policy defines the extent of the support for Xcode, Swift, and platform (iOS, macOS, tvOS, and watchOS) versions in JWTDecode.swift.
Xcode
The only supported versions of Xcode are those that can be currently used to submit apps to the App Store. Once a Xcode version becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release.
Swift
The minimum supported Swift minor version is the one released with the oldest-supported Xcode version. Once a Swift minor becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release.
Platforms
Only the last 4 major platform versions are supported, starting from:
iOS 12
macOS 10.15
macCatalyst 13
tvOS 12
watchOS 6.2
Once a platform version becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release. For example, iOS 13 will cease to be supported when iOS 17 gets released, and JWTDecode.swift will be able to drop it in a minor release.
In the case of macOS, the yearly named releases are considered a major platform version for the purposes of this Policy, regardless of the actual version numbers.
Feedback
Contributing
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
This project is licensed under the MIT license. See the LICENSE file for more info.
📚 Documentation • 🚀 Getting Started • 📃 Support Policy • 💬 Feedback
This library doesn’t validate the JWT. Any well-formed JWT can be decoded from Base64URL.
Migrating from v2? Check the Migration Guide.
Documentation
Getting Started
Requirements
Installation
Swift Package Manager
Open the following menu item in Xcode:
File > Add Packages…
In the Search or Enter Package URL search box enter this URL:
Then, select the dependency rule and press Add Package.
Cocoapods
Add the following line to your
Podfile
:Then, run
pod install
.Carthage
Add the following line to your
Cartfile
:Then, run
carthage bootstrap --use-xcframeworks
.Usage
See all the available features in the API documentation ↗
JWT parts
jwt.header
jwt.body
jwt.signature
Registered claims
jwt.audience
jwt.subject
jwt.identifier
jwt.issuer
jwt.notBefore
jwt.issuedAt
jwt.expiresAt
Custom claims
You can retrieve a custom claim through a subscript and then attempt to convert the value to a specific type.
The supported conversions are:
You can easily add a convenience accessor for a custom claim in an extension.
Error handling
If the JWT is malformed the
decode(jwt:)
function will throw aJWTDecodeError
.Support Policy
This Policy defines the extent of the support for Xcode, Swift, and platform (iOS, macOS, tvOS, and watchOS) versions in JWTDecode.swift.
Xcode
The only supported versions of Xcode are those that can be currently used to submit apps to the App Store. Once a Xcode version becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release.
Swift
The minimum supported Swift minor version is the one released with the oldest-supported Xcode version. Once a Swift minor becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release.
Platforms
Only the last 4 major platform versions are supported, starting from:
Once a platform version becomes unsupported, dropping it from JWTDecode.swift will not be considered a breaking change, and will be done in a minor release. For example, iOS 13 will cease to be supported when iOS 17 gets released, and JWTDecode.swift will be able to drop it in a minor release.
In the case of macOS, the yearly named releases are considered a major platform version for the purposes of this Policy, regardless of the actual version numbers.
Feedback
Contributing
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
Raise an issue
To provide feedback or report a bug, please raise an issue on our issue tracker.
Vulnerability reporting
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
This project is licensed under the MIT license. See the LICENSE file for more info.