Instance Method
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.
Return Value
The same instance of the collection (Self), enabling method chaining.
Discussion
Example Usage:
let collection = await JWTKeyCollection()
.addHS256(key: "mySecretKey")