File: errors.rb

package info (click to toggle)
ruby-u2f 0.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 164 kB
  • sloc: ruby: 727; makefile: 12
file content (32 lines) | stat: -rw-r--r-- 928 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module U2F
  class Error < StandardError;end
  class UnmatchedChallengeError < Error; end
  class ClientDataTypeError < Error; end
  class PublicKeyDecodeError < Error; end
  class AttestationDecodeError < Error; end
  class AttestationVerificationError < Error; end
  class AttestationSignatureError < Error; end
  class NoMatchingRequestError < Error; end
  class NoMatchingRegistrationError < Error; end
  class CounterTooLowError < Error; end
  class AuthenticationFailedError < Error; end
  class UserNotPresentError < Error;end

  class RegistrationError < Error
    CODES = {
      1 => "OTHER_ERROR",
      2 => "BAD_REQUEST",
      3 => "CONFIGURATION_UNSUPPORTED",
      4 => "DEVICE_INELIGIBLE",
      5 => "TIMEOUT"
    }

    attr_reader :code

    def initialize(options = {})
      @code = options[:code]
      message = options[:message] || "Token returned #{CODES[code]}"
      super(message)
    end
  end
end