index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const denyList = new Set([
  3. 'ENOTFOUND',
  4. 'ENETUNREACH',
  5. // SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
  6. 'UNABLE_TO_GET_ISSUER_CERT',
  7. 'UNABLE_TO_GET_CRL',
  8. 'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
  9. 'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
  10. 'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
  11. 'CERT_SIGNATURE_FAILURE',
  12. 'CRL_SIGNATURE_FAILURE',
  13. 'CERT_NOT_YET_VALID',
  14. 'CERT_HAS_EXPIRED',
  15. 'CRL_NOT_YET_VALID',
  16. 'CRL_HAS_EXPIRED',
  17. 'ERROR_IN_CERT_NOT_BEFORE_FIELD',
  18. 'ERROR_IN_CERT_NOT_AFTER_FIELD',
  19. 'ERROR_IN_CRL_LAST_UPDATE_FIELD',
  20. 'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
  21. 'OUT_OF_MEM',
  22. 'DEPTH_ZERO_SELF_SIGNED_CERT',
  23. 'SELF_SIGNED_CERT_IN_CHAIN',
  24. 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
  25. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  26. 'CERT_CHAIN_TOO_LONG',
  27. 'CERT_REVOKED',
  28. 'INVALID_CA',
  29. 'PATH_LENGTH_EXCEEDED',
  30. 'INVALID_PURPOSE',
  31. 'CERT_UNTRUSTED',
  32. 'CERT_REJECTED',
  33. 'HOSTNAME_MISMATCH'
  34. ]);
  35. // TODO: Use `error?.code` when targeting Node.js 14
  36. module.exports = error => !denyList.has(error && error.code);