DeviceAuthenticator
public protocol DeviceAuthenticator
A protocol defining the capabilities and requirements for any device authenticator. Authenticators conforming to this protocol are responsible for key management (generation, authentication, deletion) and JWT signing operations specific to their authentication type (e.g., biometrics, PIN).
-
An optional
Journeyobject providing context for the authentication flow.Declaration
Swift
var journey: Journey? { get set } -
register()Asynchronous -
authenticate(keyTag:Asynchronous) Declaration
Swift
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.
Declaration
Swift
func isSupported(attestation: Attestation) -> BoolParameters
attestationThe attestation type to consider for support.
Return Value
trueif the authenticator is supported,falseotherwise. -
Returns the specific type of device binding authentication this authenticator handles.
Declaration
Swift
func type() -> DeviceBindingAuthenticationType -
Provides the access control settings for the authenticator’s keys.
Declaration
Swift
func accessControl() -> SecAccessControl?Return Value
A
SecAccessControlobject defining key access policies, ornilif not applicable. -
Initializes the authenticator with a user ID and prompt.
Declaration
Swift
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.
Declaration
Swift
func initialize(userId: String)Parameters
userIdThe ID of the user associated with the authenticator.
-
deleteKeys()AsynchronousDeletes all keys associated with this authenticator.
Throws
KeyDeletionErrorif key deletion fails.Declaration
Swift
func deleteKeys() async throws -
Returns the issue time for a token, typically the current date.
Declaration
Swift
func issueTime() -> DateReturn Value
A
Dateobject representing the issue time. -
Returns the not-before time for a token, typically the current date.
Declaration
Swift
func notBeforeTime() -> DateReturn Value
A
Dateobject representing the not-before time. -
Validates custom claims against a list of reserved JWT claim names.
Declaration
Swift
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. -
sign(params:Default implementationjourney: ) Signs the given parameters to generate a JWS (JSON Web Signature). This method is used for initial device binding where a new key pair is generated.
Throws
JwtErrorif JWT signing fails.Default Implementation
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
func sign(params: SigningParameters, journey: Journey?) throws -> StringParameters
paramsThe
SigningParameterscontaining all necessary data for signing.journeyAn optional
Journeyobject for context, used to derive the issuer.Return Value
The compact serialized JWS string.
-
Signs the given parameters to generate a JWS (JSON Web Signature). This method is used for subsequent signing operations with an already bound user key.
Throws
JwtErrorif JWT signing fails.Declaration
Swift
func sign(params: UserKeySigningParameters, journey: Journey?) throws -> StringParameters
paramsThe
UserKeySigningParameterscontaining all necessary data for signing.journeyAn optional
Journeyobject for context, used to derive the issuer.Return Value
The compact serialized JWS string.
View on GitHub