Module: Practical::Test::Helpers::Passkey::System::Base
Instance Method Summary collapse
- #administrator_webauthn_client ⇒ Object
- #create_webauthn_credential_from_scratch(webauthn_client:, rp_id: nil, relying_party:) ⇒ Object
- #fake_authenticator ⇒ Object
- #user_relying_party ⇒ Object
- #user_webauthn_client ⇒ Object
Instance Method Details
#administrator_webauthn_client ⇒ Object
14 15 16 |
# File 'app/lib/practical/test/helpers/passkey/system/base.rb', line 14 def administrator_webauthn_client @webauthn_client ||= WebAuthn::FakeClient.new(, authenticator: fake_authenticator) end |
#create_webauthn_credential_from_scratch(webauthn_client:, rp_id: nil, relying_party:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/lib/practical/test/helpers/passkey/system/base.rb', line 25 def create_webauthn_credential_from_scratch(webauthn_client:, rp_id: nil, relying_party:) rp_id ||= .id || URI.parse(webauthn_client.origin).host create_result = webauthn_client.create(rp_id: rp_id) attestation_object = if webauthn_client.encoding .encoder.decode(create_result["response"]["attestationObject"]) else create_result["response"]["attestationObject"] end client_data_json = if webauthn_client.encoding .encoder.decode(create_result["response"]["clientDataJSON"]) else create_result["response"]["clientDataJSON"] end response = WebAuthn::AuthenticatorAttestationResponse.new( attestation_object: attestation_object, client_data_json: client_data_json, relying_party: ) return response.credential end |
#fake_authenticator ⇒ Object
6 7 8 |
# File 'app/lib/practical/test/helpers/passkey/system/base.rb', line 6 def fake_authenticator @fake_authenticator ||= WebAuthn::FakeAuthenticator.new end |
#user_relying_party ⇒ Object
18 19 20 21 22 23 |
# File 'app/lib/practical/test/helpers/passkey/system/base.rb', line 18 def return WebAuthn::.new( allowed_origins: , name: I18n.translate("app_title.text") ) end |
#user_webauthn_client ⇒ Object
10 11 12 |
# File 'app/lib/practical/test/helpers/passkey/system/base.rb', line 10 def user_webauthn_client @webauthn_client ||= WebAuthn::FakeClient.new(, authenticator: fake_authenticator) end |