# frozen_string_literal: truerequire"openssl"require"webauthn/credential"require"webauthn/encoder"require"webauthn/error"moduleWebAuthnclassRootCertificateFinderNotSupportedError<Error;endclassRelyingPartydefself.if_pss_supported(algorithm)OpenSSL::PKey::RSA.instance_methods.include?(:verify_pss)?algorithm:nilendDEFAULT_ALGORITHMS=["ES256","PS256","RS256"].compact.freezedefinitialize(algorithms: DEFAULT_ALGORITHMS.dup,encoding: WebAuthn::Encoder::STANDARD_ENCODING,origin: nil,id: nil,name: nil,verify_attestation_statement: true,credential_options_timeout: 120000,silent_authentication: false,acceptable_attestation_types: ['None','Self','Basic','AttCA','Basic_or_AttCA','AnonCA'],attestation_root_certificates_finders: [],legacy_u2f_appid: nil)@algorithms=algorithms@encoding=encoding@origin=origin@id=id@name=name@verify_attestation_statement=verify_attestation_statement@credential_options_timeout=credential_options_timeout@silent_authentication=silent_authentication@acceptable_attestation_types=acceptable_attestation_types@legacy_u2f_appid=legacy_u2f_appidself.attestation_root_certificates_finders=attestation_root_certificates_findersendattr_accessor:algorithms,:encoding,:origin,:id,:name,:verify_attestation_statement,:credential_options_timeout,:silent_authentication,:acceptable_attestation_types,:legacy_u2f_appidattr_reader:attestation_root_certificates_finders# This is the user-data encoder.# Used to decode user input and to encode data provided to the user.defencoder@encoder||=WebAuthn::Encoder.new(encoding)enddefattestation_root_certificates_finders=(finders)if!finders.respond_to?(:each)finders=[finders]endfinders.eachdo|finder|unlessfinder.respond_to?(:find)raiseRootCertificateFinderNotSupportedError,"Finder must implement `find` method"endend@attestation_root_certificates_finders=findersenddefoptions_for_registration(**keyword_arguments)WebAuthn::Credential.options_for_create(**keyword_arguments,relying_party: self)enddefverify_registration(raw_credential,challenge,user_presence: nil,user_verification: nil)webauthn_credential=WebAuthn::Credential.from_create(raw_credential,relying_party: self)ifwebauthn_credential.verify(challenge,user_presence: user_presence,user_verification: user_verification)webauthn_credentialendenddefoptions_for_authentication(**keyword_arguments)WebAuthn::Credential.options_for_get(**keyword_arguments,relying_party: self)enddefverify_authentication(raw_credential,challenge,user_presence: nil,user_verification: nil,public_key: nil,sign_count: nil)webauthn_credential=WebAuthn::Credential.from_get(raw_credential,relying_party: self)stored_credential=yield(webauthn_credential)ifblock_given?ifwebauthn_credential.verify(challenge,public_key: public_key||stored_credential.public_key,sign_count: sign_count||stored_credential.sign_count,user_presence: user_presence,user_verification: user_verification)block_given??[webauthn_credential,stored_credential]:webauthn_credentialendendendend