DefaultDeviceAuthenticator
open class DefaultDeviceAuthenticator : DeviceAuthenticator
A base class for device authenticators, providing default implementations for the DeviceAuthenticator protocol.
Subclasses should override methods to provide specific authentication logic.
-
The optional
Journeyobject providing context for the authentication flow.Declaration
Swift
public var journey: Journey? -
Returns the specific type of device binding authentication this authenticator handles. Default implementation returns
.none. Subclasses should override this.Declaration
Swift
open func type() -> DeviceBindingAuthenticationType -
register()AsynchronousGenerates a new public and private key pair for the authenticator. Default implementation throws
DeviceBindingStatus.unsupported, requiring subclasses to provide concrete implementation.Throws
DeviceBindingStatus.unsupportedif not overridden by a subclass.Declaration
Swift
open func register() async throws -> KeyPairReturn Value
A
KeyPaircontaining the newly generated public and private keys. -
authenticate(keyTag:Asynchronous) Declaration
Swift
open func authenticate(keyTag: String) async -> Result<SecKey, Error>Return Value
A
Resultcontaining theSecKeyon success, or anErroron failure. -
Checks if the authenticator is supported on the current device. Default implementation returns
false. Subclasses should override this.Declaration
Swift
open func isSupported(attestation: Attestation) -> BoolParameters
attestationThe attestation type to consider for support.
Return Value
trueif the authenticator is supported,falseotherwise. -
Provides the access control settings for the authenticator’s keys. Default implementation returns
nil. Subclasses should override this to provide specific access control.Declaration
Swift
open func accessControl() -> SecAccessControl?Return Value
A
SecAccessControlobject defining key access policies, ornilif not applicable. -
deleteKeys()AsynchronousDeletes all keys associated with this authenticator. Default implementation does nothing. Subclasses should override this to provide specific key deletion logic.
Throws
KeyDeletionErrorif key deletion fails.Declaration
Swift
open func deleteKeys() async throws -
Default implementation for a signing method that generates a JWS. This constructs the JWT payload with standard claims and signs it using the provided key pair.
Throws
JwtErrorif JWT signing fails orSecKeyToJWKErrorif JWK conversion fails.Declaration
Swift
open func sign(params: SigningParameters, journey: Journey?) throws -> StringParameters
paramsThe
SigningParameterscontaining data like challenge, expiration, user ID, and key pair.journeyAn optional
Journeyobject to provide context for the issuer claim.Return Value
The compact serialized JWS string.
-
Signs the given parameters with an existing user key to generate a JWS. This constructs the JWT payload with standard and custom claims and signs it using the provided keys.
Throws
JwtErrorif JWT signing fails orSecKeyToJWKErrorif JWK conversion fails.Declaration
Swift
open func sign(params: UserKeySigningParameters, journey: Journey?) throws -> StringParameters
paramsThe
UserKeySigningParameterscontaining data like challenge, expiration, user key, and private/public keys.journeyAn optional
Journeyobject to provide context for the issuer claim.Return Value
The compact serialized JWS string.
-
Initializes the authenticator with a user ID and prompt. Calls
setPromptand theninitialize(userId:).Declaration
Swift
open func initialize(userId: String, prompt: Prompt)Parameters
userIdThe ID of the user associated with the authenticator.
promptThe prompt to display to the user.
-
Initializes the authenticator with a user ID. Default implementation does nothing. Subclasses can override this for specific initialization logic.
Declaration
Swift
open func initialize(userId: String)Parameters
userIdThe ID of the user associated with the authenticator.
-
Returns the issue time for a token, typically the current date.
Declaration
Swift
open func issueTime() -> DateReturn Value
A
Dateobject representing the issue time. -
Returns the not-before time for a token, typically the current date.
Declaration
Swift
open func notBeforeTime() -> DateReturn Value
A
Dateobject representing the not-before time. -
Validates custom claims against a list of reserved JWT claim names. This prevents custom claims from overwriting standard JWT claims.
Throws
DeviceBindingError.invalidClaimif any custom claim is a reserved JWT claim.Declaration
Swift
open func validateCustomClaims(_ customClaims: [String : Any]) -> BoolParameters
customClaimsA dictionary of custom claims to be validated.
Return Value
trueif no custom claims conflict with reserved names,falseotherwise.
View on GitHub