PasskeyLoginRequest.fromPlatformType constructor

PasskeyLoginRequest.fromPlatformType(
  1. String relyingPartyId,
  2. String challenge,
  3. int? timeout,
  4. String? platformUserVerification,
  5. List<CredentialType>? platformAllowCredentials,
  6. MediationType platformMediation,
)

Implementation

factory PasskeyLoginRequest.fromPlatformType(
  String relyingPartyId,
  String challenge,
  int? timeout,
  String? platformUserVerification,
  List<CredentialType>? platformAllowCredentials,
  MediationType platformMediation,
) {
  final allowCredentials = platformAllowCredentials?.map((e) {
        return PasskeyLoginAllowCredentialType(
          e.type,
          e.id,
          e.transports.map(AuthenticatorTransport.fromPlatformType).toList(),
        );
      }).toList() ??
      [];

  final publicKey = PasskeyLoginPublicKey(
    challenge: challenge,
    timeout: timeout,
    rpId: relyingPartyId,
    userVerification: platformUserVerification != null
        ? UserVerificationRequirement.fromPlatformType(
            platformUserVerification)
        : null,
    allowCredentials: allowCredentials,
  );

  final mediation =
      PasskeyLoginMediationType.fromPlatformType(platformMediation);
  return PasskeyLoginRequest(publicKey, mediation);
}