A class is exposed under the cym package which allows you to use WebAuthn

Methods

initRegisterWebAuthn

global static Map<String, Object> initRegisterWebAuthn(cym.Community.Authenticator authenticator)

Params

authenticator (cym.Community.Authenticator) - Since you can have multiple authenticators which use WebAuthn, you need to provide the correct instance

Return value

Map<String, Object> : the attributes required for a WebAuthn Registration. The map has two keys :
  1. transactionId : An identifier for the transaction which must be provided back to verifyRegisterWebAuthn
  2. publicKey : A Map<String, Object> which can be passed to navigator.credentials.create

verifyRegisterWebAuthn

global static Credential verifyRegisterWebAuthn(Map<String, String> attestationResponse, cym.Community.Authenticator authenticator)

Params

attestationResponse (Map<String, String>) - The response received from navigator.credentials.create which has the following attributes :
  1. transactionId : The value retrieved from the initRegisterWebAuthn call
  2. id : The id returned by the authenticator
  3. rawId : base64url encoded value of the rawId returned by the authenticator
  4. attestationObject : base64url encoded value of the attestationObject
  5. clientDataJSON : base64url encoded value of the clientDataJSON
  6. transports : JSON.stringify value of the getTransports call on the navigator.credentials.create response
authenticator (cym.Community.Authenticator) - Since you can have multiple authenticators which use WebAuthn, you need to provide the correct instance

Return value

Credential : the credential which was created and stored on the database.

initVerificationWebAuthn

global static Map<String, Object> initVerificationWebAuthn(cym.Community.Authenticator authenticator)

Params

authenticator (cym.Community.Authenticator) - Since you can have multiple authenticators which use WebAuthn, you need to provide the correct instance

Return value

Map<String, Object> : the attributes required for a WebAuthn Verification. The map has two keys :
  1. transactionId : An identifier for the transaction which must be provided back to verifyRegisterWebAuthn
  2. publicKey : A Map<String, Object> which can be passed to navigator.credentials.get

verifyVerificationWebAuthn

global static Boolean verifyVerificationWebAuthn(Map<String, String> assertionResponse, cym.Community.Authenticator authenticator)

Params

assertionResponse (Map<String, String>) - The response received from navigator.credentials.create which has the following attributes :
  1. transactionId : The value retrieved from the initRegisterWebAuthn call
  2. id : The id returned by the authenticator
  3. rawId : base64url encoded value of the rawId returned by the authenticator
  4. authenticatorData : base64url encoded value of the authenticatorData
  5. clientDataJSON : base64url encoded value of the clientDataJSON
  6. signature : base64url value of the signature
authenticator (cym.Community.Authenticator) - Since you can have multiple authenticators which use WebAuthn, you need to provide the correct instance

Return value

Boolean : whether the signature matches the public key stored in the database

getAllCredentials

global static Credential[] getAllCredentials()

Return value

Credential[] : List all credentials stored in the database for the current user.