Instance MethodJWTKit
add(rsa:digestAlgorithm:kid:parser:serializer:)
Adds an RSA key to the collection.
@discardableResult func add(rsa key: some RSAKey, digestAlgorithm: DigestAlgorithm, kid: JWKIdentifier? = nil, parser: some JWTParser = DefaultJWTParser(), serializer: some JWTSerializer = DefaultJWTSerializer()) -> Self
Parameters
keyThe
RSAKeyto use for signing. This key should be kept secure and not exposed.kidAn optional
JWKIdentifier(Key ID). If provided, it will be used to identify this key in the JWTkidheader field.jsonEncoderAn optional custom JSON encoder conforming to
JWTJSONEncoderused for encoding JWTs. Ifnil, a default encoder is used.jsonDecoderAn optional custom JSON decoder conforming to
JWTJSONDecoderused for decoding JWTs. Ifnil, a default decoder is used.ReturnsThe same instance of the collection (
Self), enabling method chaining.
Discussion
This method configures and adds an RSA key to the collection. The key is used for signing JWTs
Example Usage:
let collection = await JWTKeyCollection()
.addRSA(key: myRSAKey)