Instance MethodJWTKit
add(hmac:digestAlgorithm:kid:parser:serializer:)
Adds an HMAC key to the collection.
@discardableResult func add(hmac key: HMACKey, digestAlgorithm: DigestAlgorithm, kid: JWKIdentifier? = nil, parser: some JWTParser = DefaultJWTParser(), serializer: some JWTSerializer = DefaultJWTSerializer()) -> Self
Parameters
keyThe
SymmetricKeyused for HMAC signing. This key should be kept confidential and secure, as it can be used for both signing and verification.kidAn optional
JWKIdentifier(Key ID). If given, it is used in the JWTkidheader field to identify this key.jsonEncoderAn optional custom JSON encoder conforming to
JWTJSONEncoder, used for encoding JWTs. Ifnil, a default encoder is employed.jsonDecoderAn optional custom JSON decoder conforming to
JWTJSONDecoder, used for decoding JWTs. Ifnil, a default decoder is used.
Return Value
The same instance of the collection (Self), enabling method chaining.
Discussion
Example Usage:
let collection = await JWTKeyCollection()
.addHS256(key: "mySecretKey")