STRUCT
WebAuthnAuthenticationClientOperationStep
Contents
- Properties
actionsactionModelcontinueActionmetadatamessageslinkspropertiesrawJsonStringtypecontinueFormActionModelfallbackActions
- Methods
buildParameters(authenticatorData:clientDataJSON:signature:userHandle:rawId:type:)formattedParametersForAssertion(rawAuthenticatorData:rawClientDataJSON:signature:credentialID:credentialParamType:userId:)init(from:)encode(to:)==(_:_:)
public struct WebAuthnAuthenticationClientOperationStep: ClientOperationStep
A step that instructs a client that it should use the device's platform Authentication Services API to perform a User Authentication Assertion WebAuthn flow
After running the ceremony, the client application should invoke
buildParameters(authenticatorData:clientDataJSON:signature:userHandle:rawId:type:) with the assertion response, and submit the
result with continueFormActionModel to proceed with the flow.
Fallback actions are provided to assist on fallback if an error happens.
For more information, refer to the HAAPI Data Model documentation.
- Note: Starting on iOS 15,
WebAuthncan be used with the Authentication Services ASAuthorizationPublicKey APIs (native) but it is also possible to use the fallbackActions (web browser). Below iOS 15, fallbackActions (web browser) is the only way to handle WebAuthn.
Properties
actions
public let actions: [any Action]
An array of Action that contains possible actions a user or the client may choose to take to continue the flow.
actionModel
public let actionModel: WebAuthnAuthenticationClientOperationActionModel
the WebAuthn client operation action model that contains the necessary details for the client to use the device's platform Authentication Services.
continueAction
public let continueAction: FormAction
Returns the form action that has to be submitted alongside the result of buildParameters(authenticatorData:clientDataJSON:signature:userHandle:rawId:type:) after receiving the callback from the authenticator interaction.
metadata
public let metadata: Metadata?
messages
public let messages: [UserMessage]
links
public let links: [Link]
properties
public let properties: (any Properties)?
rawJsonString
public let rawJsonString: String?
type
public let type: RepresentationType
continueFormActionModel
public var continueFormActionModel: FormActionModel
The form action model to submit the result of buildParameters(authenticatorData:clientDataJSON:signature:userHandle:rawId:type:) with.
fallbackActions
public var fallbackActions: [any Action]
Returns the actions that should be triggered when WebAuthnhandling fails or is impossible to use with the native APIs.
Methods
buildParameters(authenticatorData:clientDataJSON:signature:userHandle:rawId:type:)
public func buildParameters(
authenticatorData: Data,
clientDataJSON: Data,
signature: Data,
userHandle: Data?,
rawId: Data,
type: String
) throws -> [String: any Sendable]
Builds the parameters to submit with continueFormActionModel after a WebAuthn authentication ceremony.
Pass the raw values of the assertion returned by any WebAuthn driver; they are base64url-encoded here.
- Parameters:
- authenticatorData: The assertion response's
authenticatorData. - clientDataJSON: The assertion response's
clientDataJSON. - signature: The assertion response's
signature. - userHandle: The assertion response's
userHandle, if any; left out of the parameters whennil. - rawId: The credential's raw id.
- type: The credential type,
public-keyfor WebAuthn.
- authenticatorData: The assertion response's
- Returns: The parameters to submit with
continueFormActionModel. - Throws: An
IdsvrErrorwhen the continue form has nocredentialcontext field.
Parameters
| Name | Description |
|---|---|
| authenticatorData | The assertion response’s authenticatorData. |
| clientDataJSON | The assertion response’s clientDataJSON. |
| signature | The assertion response’s signature. |
| userHandle | The assertion response’s userHandle, if any; left out of the parameters when nil. |
| rawId | The credential’s raw id. |
| type | The credential type, public-key for WebAuthn. |
formattedParametersForAssertion(rawAuthenticatorData:rawClientDataJSON:signature:credentialID:credentialParamType:userId:)
public func formattedParametersForAssertion(
rawAuthenticatorData: Data,
rawClientDataJSON: Data,
signature: Data,
credentialID: Data,
credentialParamType: String = "public-key",
userId: Data? = nil
) -> [String: Any]
Builds the form parameters necessary to submit a WebAuthn Assertion request.
- Parameters:
- rawAuthenticatorData: the attestation object's data provided by the device's platform Authorization Controller
ASAuthorization.credentialresponse. - rawClientDataJSON: the clientDataJSON's data provided by the device's platform Authorization Controller
ASAuthorization.credentialresponse. - signature: the signature's data provided by the device's platform Authorization Controller
ASAuthorization.credentialresponse. - credentialID: the credentialID's data provided by the device's platform Authorization Controller
ASAuthorization.credentialresponse. - credentialParamType: the credential type used to setup the authorization assertion request. Defaults to "public-key".
- userId: the userId's data provided by the device's platform Authorization Controller
ASAuthorization.credentialresponse. This parameter is required when supporting PassKeys Discoverable Credentials mode. Left out of the parameters whennil.
- rawAuthenticatorData: the attestation object's data provided by the device's platform Authorization Controller
- Returns: a
Dictionary<String: Any>containing the parameters to use when submiting the form action, or an empty dictionary when they cannot be built. - Note: ASAuthorizationPlatformPublicKeyCredentialAssertion is only available starting on iOS15 in AuthenticationServices framework.
Parameters
| Name | Description |
|---|---|
| rawAuthenticatorData | the attestation object’s data provided by the device’s platform Authorization Controller ASAuthorization.credential response. |
| rawClientDataJSON | the clientDataJSON’s data provided by the device’s platform Authorization Controller ASAuthorization.credential response. |
| signature | the signature’s data provided by the device’s platform Authorization Controller ASAuthorization.credential response. |
| credentialID | the credentialID’s data provided by the device’s platform Authorization Controller ASAuthorization.credential response. |
| credentialParamType | the credential type used to setup the authorization assertion request. Defaults to “public-key”. |
| userId | the userId’s data provided by the device’s platform Authorization Controller ASAuthorization.credential response. This parameter is required when supporting PassKeys Discoverable Credentials mode. Left out of the parameters when nil. |
init(from:)
public init(from decoder: Decoder) throws
Parameters
| Name | Description |
|---|---|
| decoder | The decoder to read data from. |
encode(to:)
public func encode(to encoder: Encoder) throws
Parameters
| Name | Description |
|---|---|
| encoder | The encoder to write data to. |
==(::)
public static func == (lhs: WebAuthnAuthenticationClientOperationStep,
rhs: WebAuthnAuthenticationClientOperationStep) -> Bool
Parameters
| Name | Description |
|---|---|
| lhs | A value to compare. |
| rhs | Another value to compare. |