Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Instance MethodJWTKit

add(ecdsa:kid:parser:serializer:)

Adds an ECDSA key to the collection.
@discardableResult func add(ecdsa key: some ECDSAKey, kid: JWKIdentifier? = nil, parser: some JWTParser = DefaultJWTParser(), serializer: some JWTSerializer = DefaultJWTSerializer()) -> Self

Parameters

key

The ECDSAKey to be used for signing. This key should be securely stored and not exposed.

kid

An optional JWKIdentifier (Key ID). If provided, this identifier will be used in the JWT kid header field to identify the key.

jsonEncoder

An optional custom JSON encoder conforming to JWTJSONEncoder, used for encoding JWTs. If nil, a default encoder is used.

jsonDecoder

An optional custom JSON decoder conforming to JWTJSONDecoder, used for decoding JWTs. If nil, a default decoder is used.

Return Value

The same instance of the collection (Self), which allows for method chaining.

Discussion

Example Usage:

let collection = await JWTKeyCollection()
    .addECDSA(key: myECDSAKey)