errors.js 5.3 KB

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