Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/dashmate/src/ssl/zerossl/createCertificate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fetch = require('node-fetch');
const qs = require('qs');
const errorDescriptions = require('./errors/errorDescriptions');

/**
* Create a ZeroSSL Certificate
Expand Down Expand Up @@ -36,7 +37,9 @@ async function createCertificate(
const data = await response.json();

if (data.error) {
throw new Error(JSON.stringify(data.error));
const errorMessage = errorDescriptions[data.error.code];

throw new Error(errorMessage || JSON.stringify(data.error));
}

return data;
Expand Down
5 changes: 4 additions & 1 deletion packages/dashmate/src/ssl/zerossl/downloadCertificate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fetch = require('node-fetch');
const wait = require('../../util/wait');
const errorDescriptions = require('./errors/errorDescriptions');

/**
* Download the certificate specified by id
Expand Down Expand Up @@ -40,7 +41,9 @@ async function downloadCertificate(id, apiKey) {
}

if (data.error) {
throw new Error(data.error.type);
const errorMessage = errorDescriptions[data.error.code];

throw new Error(errorMessage || JSON.stringify(data.error));
}

return `${data['certificate.crt']}\n${data['ca_bundle.crt']}`;
Expand Down
24 changes: 24 additions & 0 deletions packages/dashmate/src/ssl/zerossl/errors/errorDescriptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
2804: 'The current certificate cannot be issued due to unpaid invoices on your ZeroSSL account.',
2808: 'Your domain is not valid',
2813: 'Only issued certificates can be renewed or replaced by a new certificate.',
2814: 'Yo do not have the permissions to access ZeroSSL certificate to renew.',
2815: 'Only issued certificates can be renewed or replaced by a new certificate.',
2816: 'ZeroSSL certificate to renew was not found.',
2817: 'Limit of certificates on your ZeroSSL account was reached',
2820: 'Internal error processing CSR. Please contact ZeroSSL support if this error occurs.',
2821: 'Internal error generating certificate. Please contact ZeroSSL support if this error occurs.',
2839: 'ZeroSSL requires an upgrade from Free Plan to Basic Plan',
2841: 'Your ZeroSSL account has been temporarily suspended due to unpaid invoices',
101: 'ZeroSSL API key is invalid',
102: 'Your ZeroSSL account is not active',
111: 'Something went wrong. If the problem persists please contact ZeroSSL support team (support@zerossl.com)',
2801: 'You do not have the permissions to access ZeroSSL resource',
2803: 'Your ZeroSSL certificate ID (hash) could not be found',
2822: 'The requested ZeroSSL certificate could not be retrieved.',
2823: 'ZeroSSL domain verification failed and must be retried.',
2826: 'Internal error verifying domains. Please contact ZeroSSL support if this error occurs',
2874: 'ZeroSSL is not able to issue certificates for this Top-Level-Domain at the moment',
2832: 'The given certificate has not been issued yet',
2860: 'The certificate can currently not be downloaded',
};
5 changes: 4 additions & 1 deletion packages/dashmate/src/ssl/zerossl/getCertificate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fetch = require('node-fetch');
const errorDescriptions = require('./errors/errorDescriptions');

/**
* Get ZeroSSL certificate
Expand All @@ -21,7 +22,9 @@ async function getCertificate(apiKey, id) {
const data = await response.json();

if (data.error) {
throw new Error(data.error.type);
const errorMessage = errorDescriptions[data.error.code];

throw new Error(errorMessage || JSON.stringify(data.error));
}

return data;
Expand Down
5 changes: 4 additions & 1 deletion packages/dashmate/src/ssl/zerossl/listCertificates.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fetch = require('node-fetch');
const errorDescriptions = require('./errors/errorDescriptions');

/**
* List ZeroSSL certificates
Expand All @@ -20,7 +21,9 @@ async function listCertificates(apiKey) {
const data = await response.json();

if (data.error) {
throw new Error(data.error.type);
const errorMessage = errorDescriptions[data.error.code];

throw new Error(errorMessage || JSON.stringify(data.error));
}

return data;
Expand Down
5 changes: 4 additions & 1 deletion packages/dashmate/src/ssl/zerossl/verifyDomain.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fetch = require('node-fetch');

const qs = require('qs');
const errorDescriptions = require('./errors/errorDescriptions');

/**
* Verify the domain/ip specified by certificate id
Expand Down Expand Up @@ -30,7 +31,9 @@ async function verifyDomain(id, apiKey) {
const data = await response.json();

if (data.error) {
throw new Error(data.error.type);
const errorMessage = errorDescriptions[data.error.code];

throw new Error(errorMessage || JSON.stringify(data.error));
}

return data;
Expand Down