errors.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. export class JOSEError extends Error {
  2. static get code() {
  3. return 'ERR_JOSE_GENERIC';
  4. }
  5. constructor(message) {
  6. var _a;
  7. super(message);
  8. this.code = 'ERR_JOSE_GENERIC';
  9. this.name = this.constructor.name;
  10. (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
  11. }
  12. }
  13. export class JWTClaimValidationFailed extends JOSEError {
  14. static get code() {
  15. return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
  16. }
  17. constructor(message, claim = 'unspecified', reason = 'unspecified') {
  18. super(message);
  19. this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
  20. this.claim = claim;
  21. this.reason = reason;
  22. }
  23. }
  24. export class JWTExpired extends JOSEError {
  25. static get code() {
  26. return 'ERR_JWT_EXPIRED';
  27. }
  28. constructor(message, claim = 'unspecified', reason = 'unspecified') {
  29. super(message);
  30. this.code = 'ERR_JWT_EXPIRED';
  31. this.claim = claim;
  32. this.reason = reason;
  33. }
  34. }
  35. export class JOSEAlgNotAllowed extends JOSEError {
  36. constructor() {
  37. super(...arguments);
  38. this.code = 'ERR_JOSE_ALG_NOT_ALLOWED';
  39. }
  40. static get code() {
  41. return 'ERR_JOSE_ALG_NOT_ALLOWED';
  42. }
  43. }
  44. export class JOSENotSupported extends JOSEError {
  45. constructor() {
  46. super(...arguments);
  47. this.code = 'ERR_JOSE_NOT_SUPPORTED';
  48. }
  49. static get code() {
  50. return 'ERR_JOSE_NOT_SUPPORTED';
  51. }
  52. }
  53. export class JWEDecryptionFailed extends JOSEError {
  54. constructor() {
  55. super(...arguments);
  56. this.code = 'ERR_JWE_DECRYPTION_FAILED';
  57. this.message = 'decryption operation failed';
  58. }
  59. static get code() {
  60. return 'ERR_JWE_DECRYPTION_FAILED';
  61. }
  62. }
  63. export class JWEDecompressionFailed extends JOSEError {
  64. constructor() {
  65. super(...arguments);
  66. this.code = 'ERR_JWE_DECOMPRESSION_FAILED';
  67. this.message = 'decompression operation failed';
  68. }
  69. static get code() {
  70. return 'ERR_JWE_DECOMPRESSION_FAILED';
  71. }
  72. }
  73. export class JWEInvalid extends JOSEError {
  74. constructor() {
  75. super(...arguments);
  76. this.code = 'ERR_JWE_INVALID';
  77. }
  78. static get code() {
  79. return 'ERR_JWE_INVALID';
  80. }
  81. }
  82. export class JWSInvalid extends JOSEError {
  83. constructor() {
  84. super(...arguments);
  85. this.code = 'ERR_JWS_INVALID';
  86. }
  87. static get code() {
  88. return 'ERR_JWS_INVALID';
  89. }
  90. }
  91. export class JWTInvalid extends JOSEError {
  92. constructor() {
  93. super(...arguments);
  94. this.code = 'ERR_JWT_INVALID';
  95. }
  96. static get code() {
  97. return 'ERR_JWT_INVALID';
  98. }
  99. }
  100. export class JWKInvalid extends JOSEError {
  101. constructor() {
  102. super(...arguments);
  103. this.code = 'ERR_JWK_INVALID';
  104. }
  105. static get code() {
  106. return 'ERR_JWK_INVALID';
  107. }
  108. }
  109. export class JWKSInvalid extends JOSEError {
  110. constructor() {
  111. super(...arguments);
  112. this.code = 'ERR_JWKS_INVALID';
  113. }
  114. static get code() {
  115. return 'ERR_JWKS_INVALID';
  116. }
  117. }
  118. export class JWKSNoMatchingKey extends JOSEError {
  119. constructor() {
  120. super(...arguments);
  121. this.code = 'ERR_JWKS_NO_MATCHING_KEY';
  122. this.message = 'no applicable key found in the JSON Web Key Set';
  123. }
  124. static get code() {
  125. return 'ERR_JWKS_NO_MATCHING_KEY';
  126. }
  127. }
  128. export class JWKSMultipleMatchingKeys extends JOSEError {
  129. constructor() {
  130. super(...arguments);
  131. this.code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
  132. this.message = 'multiple matching keys found in the JSON Web Key Set';
  133. }
  134. static get code() {
  135. return 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
  136. }
  137. }
  138. Symbol.asyncIterator;
  139. export class JWKSTimeout extends JOSEError {
  140. constructor() {
  141. super(...arguments);
  142. this.code = 'ERR_JWKS_TIMEOUT';
  143. this.message = 'request timed out';
  144. }
  145. static get code() {
  146. return 'ERR_JWKS_TIMEOUT';
  147. }
  148. }
  149. export class JWSSignatureVerificationFailed extends JOSEError {
  150. constructor() {
  151. super(...arguments);
  152. this.code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
  153. this.message = 'signature verification failed';
  154. }
  155. static get code() {
  156. return 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
  157. }
  158. }