"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/rb/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb" (17 Feb 2023, 2348 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "virtual_authenticator_options.rb": 4.7.0_vs_4.8.0.

    1 # frozen_string_literal: true
    2 
    3 # Licensed to the Software Freedom Conservancy (SFC) under one
    4 # or more contributor license agreements.  See the NOTICE file
    5 # distributed with this work for additional information
    6 # regarding copyright ownership.  The SFC licenses this file
    7 # to you under the Apache License, Version 2.0 (the
    8 # "License"); you may not use this file except in compliance
    9 # with the License.  You may obtain a copy of the License at
   10 #
   11 #   http://www.apache.org/licenses/LICENSE-2.0
   12 #
   13 # Unless required by applicable law or agreed to in writing,
   14 # software distributed under the License is distributed on an
   15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   16 # KIND, either express or implied.  See the License for the
   17 # specific language governing permissions and limitations
   18 # under the License.
   19 
   20 #
   21 # Options for the creation of virtual authenticators.
   22 # @see http://w3c.github.io/webauthn/#sctn-automation
   23 #
   24 
   25 module Selenium
   26   module WebDriver
   27     class VirtualAuthenticatorOptions
   28       PROTOCOL = {ctap2: 'ctap2', u2f: 'ctap1/u2f'}.freeze
   29       TRANSPORT = {ble: 'ble', usb: 'usb', nfc: 'nfc', internal: 'internal'}.freeze
   30 
   31       attr_accessor :protocol, :transport, :resident_key, :user_verification, :user_consenting, :user_verified
   32       alias resident_key? resident_key
   33       alias user_verification? user_verification
   34       alias user_consenting? user_consenting
   35       alias user_verified? user_verified
   36 
   37       def initialize(**opts)
   38         @protocol = opts.delete(:protocol) { :ctap2 }
   39         @transport = opts.delete(:transport) { :usb }
   40         @resident_key = opts.delete(:resident_key) { false }
   41         @user_verification = opts.delete(:user_verification) { false }
   42         @user_consenting = opts.delete(:user_consenting) { true }
   43         @user_verified = opts.delete(:user_verified) { false }
   44 
   45         raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
   46       end
   47 
   48       #
   49       # @api private
   50       #
   51 
   52       def as_json(*)
   53         {'protocol' => PROTOCOL[protocol],
   54          'transport' => TRANSPORT[transport],
   55          'hasResidentKey' => resident_key?,
   56          'hasUserVerification' => user_verification?,
   57          'isUserConsenting' => user_consenting?,
   58          'isUserVerified' => user_verified?}
   59       end
   60     end # VirtualAuthenticatorOptions
   61   end # WebDriver
   62 end # Selenium