Class: WebAuthn::CredentialRequestOptions

Inherits:
CredentialOptions show all
Defined in:
lib/webauthn/credential_request_options.rb

Constant Summary

Constants inherited from CredentialOptions

WebAuthn::CredentialOptions::CHALLENGE_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CredentialOptions

#challenge, #timeout

Constructor Details

#initialize(allow_credentials: [], extensions: nil, user_verification: nil) ⇒ CredentialRequestOptions

Returns a new instance of CredentialRequestOptions.



18
19
20
21
22
23
24
# File 'lib/webauthn/credential_request_options.rb', line 18

def initialize(allow_credentials: [], extensions: nil, user_verification: nil)
  super()

  @allow_credentials = allow_credentials
  @extensions = extensions
  @user_verification = user_verification
end

Instance Attribute Details

#allow_credentialsObject

Returns the value of attribute allow_credentials.



16
17
18
# File 'lib/webauthn/credential_request_options.rb', line 16

def allow_credentials
  @allow_credentials
end

#extensionsObject

Returns the value of attribute extensions.



16
17
18
# File 'lib/webauthn/credential_request_options.rb', line 16

def extensions
  @extensions
end

#user_verificationObject

Returns the value of attribute user_verification.



16
17
18
# File 'lib/webauthn/credential_request_options.rb', line 16

def user_verification
  @user_verification
end

Instance Method Details

#to_hObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/webauthn/credential_request_options.rb', line 26

def to_h
  options = {
    challenge: challenge,
    timeout: timeout,
    allowCredentials: allow_credentials
  }

  if extensions
    options[:extensions] = extensions
  end

  if user_verification
    options[:userVerification] = user_verification
  end

  options
end