You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errors.go 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package protocol
  2. type Error struct {
  3. // Short name for the type of error that has occurred
  4. Type string `json:"type"`
  5. // Additional details about the error
  6. Details string `json:"error"`
  7. // Information to help debug the error
  8. DevInfo string `json:"debug"`
  9. }
  10. var (
  11. ErrBadRequest = &Error{
  12. Type: "invalid_request",
  13. Details: "Error reading the requst data",
  14. }
  15. ErrChallengeMismatch = &Error{
  16. Type: "challenge_mismatch",
  17. Details: "Stored challenge and received challenge do not match",
  18. }
  19. ErrParsingData = &Error{
  20. Type: "parse_error",
  21. Details: "Error parsing the authenticator response",
  22. }
  23. ErrAuthData = &Error{
  24. Type: "auth_data",
  25. Details: "Error verifying the authenticator data",
  26. }
  27. ErrVerification = &Error{
  28. Type: "verification_error",
  29. Details: "Error validating the authenticator response",
  30. }
  31. ErrAttestation = &Error{
  32. Type: "attesation_error",
  33. Details: "Error validating the attestation data provided",
  34. }
  35. ErrInvalidAttestation = &Error{
  36. Type: "invalid_attestation",
  37. Details: "Invalid attestation data",
  38. }
  39. ErrAttestationFormat = &Error{
  40. Type: "invalid_attestation",
  41. Details: "Invalid attestation format",
  42. }
  43. ErrAttestationCertificate = &Error{
  44. Type: "invalid_certificate",
  45. Details: "Invalid attestation certificate",
  46. }
  47. ErrAssertionSignature = &Error{
  48. Type: "invalid_signature",
  49. Details: "Assertion Signature against auth data and client hash is not valid",
  50. }
  51. ErrUnsupportedKey = &Error{
  52. Type: "invalid_key_type",
  53. Details: "Unsupported Public Key Type",
  54. }
  55. ErrUnsupportedAlgorithm = &Error{
  56. Type: "unsupported_key_algorithm",
  57. Details: "Unsupported public key algorithm",
  58. }
  59. ErrNotSpecImplemented = &Error{
  60. Type: "spec_unimplemented",
  61. Details: "This field is not yet supported by the WebAuthn spec",
  62. }
  63. ErrNotImplemented = &Error{
  64. Type: "not_implemented",
  65. Details: "This field is not yet supported by this library",
  66. }
  67. )
  68. func (err *Error) Error() string {
  69. return err.Details
  70. }
  71. func (passedError *Error) WithDetails(details string) *Error {
  72. err := *passedError
  73. err.Details = details
  74. return &err
  75. }
  76. func (passedError *Error) WithInfo(info string) *Error {
  77. err := *passedError
  78. err.DevInfo = info
  79. return &err
  80. }