register method

Implementation

Future<Fido2Attestation> register(UserRegistrationChallenge challenge) async {
  final registerResponse = await PasskeyAuthenticator().register(
    RegisterRequestType(
      challenge: challenge.challenge,
      relyingParty: this.relyingParty,
      user: UserType(
        displayName: challenge.user.displayName,
        name: challenge.user.name,
        id: base64UrlEncode(utf8.encode(challenge.user.id)),
      ),
      authSelectionType: AuthenticatorSelectionType(
        authenticatorAttachment:
            challenge.authenticatorSelection.authenticatorAttachment ??
                'platform',
        requireResidentKey:
            challenge.authenticatorSelection.requireResidentKey,
        residentKey: challenge.authenticatorSelection.residentKey,
        userVerification: challenge.authenticatorSelection.userVerification,
      ),
      pubKeyCredParams: List<PubKeyCredParamType>.from(
        challenge.pubKeyCredParams.map(
          (e) => PubKeyCredParamType(
            type: e.type,
            alg: e.alg,
          ),
        ),
      ),
      timeout: this.timeout ?? defaultWaitTimeout,
      attestation: challenge.attestation,
      excludeCredentials: List<CredentialType>.from(
        challenge.excludeCredentials.map(
          (e) => CredentialType(
            type: e.type,
            id: e.id,
            transports: [],
          ),
        ),
      ),
    ),
  );

  return Fido2Attestation(
    Fido2AttestationData(
      registerResponse.attestationObject,
      registerResponse.clientDataJSON,
      registerResponse.rawId,
    ),
    'Fido2',
  );
}