Skip to content

Commit

Permalink
Clean up eslintrc, style refactor and formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmorsman committed May 21, 2024
1 parent fc695be commit 8b00fdb
Show file tree
Hide file tree
Showing 34 changed files with 174 additions and 421 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@ env:
rules:
indent: [2, 4, { SwitchCase: 1, VariableDeclarator: 1 }]
brace-style: [2, 'stroustrup', { allowSingleLine: true }]
space-before-function-paren: [2, { anonymous: 'never', named: 'never' }]
func-names: 0
prefer-destructuring: 0
object-curly-newline: 0
class-methods-use-this: 0
wrap-iife: [2, 'inside']
no-param-reassign: 0
comma-dangle: [2, 'never']
max-len: [1, 200, 2, { ignoreUrls: true, ignoreComments: false }]
no-multiple-empty-lines: [2, { max: 2, maxBOF: 0, maxEOF: 0 }]
prefer-object-spread: 0
import/no-useless-path-segments: 0
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: test
on: [push, pull_request]

Expand All @@ -12,7 +11,6 @@ jobs:
node: [16, 18, 20, 22]
eab: [0, 1]


#
# Environment
#
Expand Down Expand Up @@ -41,7 +39,6 @@ jobs:
ACME_HTTP_PORT: 5002
ACME_HTTPS_PORT: 5003


#
# Pipeline
#
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* `fixed` Upgrade `axios@0.26.1`
* `fixed` Upgrade `node-forge@1.3.0` - [CVE-2022-24771](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24771), [CVE-2022-24772](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24772), [CVE-2022-24773](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24773)

## 4.2.4 (2022-03-19)
## v4.2.4 (2022-03-19)

* `fixed` Use SHA-256 when signing CSRs

Expand Down
15 changes: 6 additions & 9 deletions examples/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function log(m) {
process.stdout.write(`${m}\n`);
}


/**
* Function used to satisfy an ACME challenge
*
Expand All @@ -25,7 +24,6 @@ async function challengeCreateFn(authz, challenge, keyAuthorization) {
log(keyAuthorization);
}


/**
* Function used to remove an ACME challenge response
*
Expand All @@ -41,30 +39,29 @@ async function challengeRemoveFn(authz, challenge, keyAuthorization) {
log(keyAuthorization);
}


/**
* Main
*/

module.exports = async function() {
module.exports = async () => {
/* Init client */
const client = new acme.Client({
directoryUrl: acme.directory.letsencrypt.staging,
accountKey: await acme.crypto.createPrivateKey()
accountKey: await acme.crypto.createPrivateKey(),
});

/* Register account */
await client.createAccount({
termsOfServiceAgreed: true,
contact: ['mailto:test@example.com']
contact: ['mailto:test@example.com'],
});

/* Place new order */
const order = await client.createOrder({
identifiers: [
{ type: 'dns', value: 'example.com' },
{ type: 'dns', value: '*.example.com' }
]
{ type: 'dns', value: '*.example.com' },
],
});

/**
Expand Down Expand Up @@ -139,7 +136,7 @@ module.exports = async function() {
/* Finalize order */
const [key, csr] = await acme.crypto.createCsr({
commonName: '*.example.com',
altNames: ['example.com']
altNames: ['example.com'],
});

const finalized = await client.finalizeOrder(order, csr);
Expand Down
11 changes: 4 additions & 7 deletions examples/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function log(m) {
process.stdout.write(`${m}\n`);
}


/**
* Function used to satisfy an ACME challenge
*
Expand Down Expand Up @@ -47,7 +46,6 @@ async function challengeCreateFn(authz, challenge, keyAuthorization) {
}
}


/**
* Function used to remove an ACME challenge response
*
Expand Down Expand Up @@ -84,21 +82,20 @@ async function challengeRemoveFn(authz, challenge, keyAuthorization) {
}
}


/**
* Main
*/

module.exports = async function() {
module.exports = async () => {
/* Init client */
const client = new acme.Client({
directoryUrl: acme.directory.letsencrypt.staging,
accountKey: await acme.crypto.createPrivateKey()
accountKey: await acme.crypto.createPrivateKey(),
});

/* Create CSR */
const [key, csr] = await acme.crypto.createCsr({
commonName: 'example.com'
commonName: 'example.com',
});

/* Certificate */
Expand All @@ -107,7 +104,7 @@ module.exports = async function() {
email: 'test@example.com',
termsOfServiceAgreed: true,
challengeCreateFn,
challengeRemoveFn
challengeRemoveFn,
});

/* Done */
Expand Down
11 changes: 4 additions & 7 deletions examples/dns-01/dns-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function log(m) {
process.stdout.write(`${(new Date()).toISOString()} ${m}\n`);
}


/**
* Main
*/
Expand All @@ -33,18 +32,17 @@ function log(m) {
log('Initializing ACME client');
const client = new acme.Client({
directoryUrl: acme.directory.letsencrypt.staging,
accountKey: await acme.crypto.createPrivateKey()
accountKey: await acme.crypto.createPrivateKey(),
});


/**
* Order wildcard certificate
*/

log(`Creating CSR for ${WILDCARD_DOMAIN}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: WILDCARD_DOMAIN,
altNames: [`*.${WILDCARD_DOMAIN}`]
altNames: [`*.${WILDCARD_DOMAIN}`],
});

log(`Ordering certificate for ${WILDCARD_DOMAIN}`);
Expand All @@ -60,12 +58,11 @@ function log(m) {
challengeRemoveFn: (authz, challenge, keyAuthorization) => {
/* TODO: Implement this */
log(`[TODO] Remove TXT record key=_acme-challenge.${authz.identifier.value} value=${keyAuthorization}`);
}
},
});

log(`Certificate for ${WILDCARD_DOMAIN} created successfully`);


/**
* HTTPS server
*/
Expand All @@ -78,7 +75,7 @@ function log(m) {

const httpsServer = https.createServer({
key,
cert
cert,
}, requestListener);

httpsServer.listen(HTTPS_SERVER_PORT, () => {
Expand Down
12 changes: 4 additions & 8 deletions examples/http-01/http-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function log(m) {
process.stdout.write(`${(new Date()).toISOString()} ${m}\n`);
}


/**
* On-demand certificate generation using http-01
*/
Expand Down Expand Up @@ -52,7 +51,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
/* Create CSR */
log(`Creating CSR for ${servername}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: servername
commonName: servername,
});

/* Order certificate */
Expand All @@ -67,7 +66,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
},
challengeRemoveFn: (authz, challenge) => {
delete challengeResponses[challenge.token];
}
},
});

/* Done, store certificate */
Expand All @@ -77,7 +76,6 @@ async function getCertOnDemand(client, servername, attempt = 0) {
return certificateStore[servername];
}


/**
* Main
*/
Expand All @@ -91,10 +89,9 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log('Initializing ACME client');
const client = new acme.Client({
directoryUrl: acme.directory.letsencrypt.staging,
accountKey: await acme.crypto.createPrivateKey()
accountKey: await acme.crypto.createPrivateKey(),
});


/**
* HTTP server
*/
Expand Down Expand Up @@ -129,7 +126,6 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log(`HTTP server listening on port ${HTTP_SERVER_PORT}`);
});


/**
* HTTPS server
*/
Expand Down Expand Up @@ -158,7 +154,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log(`[ERROR] ${e.message}`);
cb(e.message);
}
}
},
}, requestListener);

httpsServer.listen(HTTPS_SERVER_PORT, () => {
Expand Down
16 changes: 6 additions & 10 deletions examples/tls-alpn-01/tls-alpn-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function log(m) {
process.stdout.write(`${(new Date()).toISOString()} ${m}\n`);
}


/**
* On-demand certificate generation using tls-alpn-01
*/
Expand Down Expand Up @@ -51,7 +50,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
/* Create CSR */
log(`Creating CSR for ${servername}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: servername
commonName: servername,
});

/* Order certificate */
Expand All @@ -66,7 +65,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
},
challengeRemoveFn: (authz) => {
delete alpnResponses[authz.identifier.value];
}
},
});

/* Done, store certificate */
Expand All @@ -76,7 +75,6 @@ async function getCertOnDemand(client, servername, attempt = 0) {
return certificateStore[servername];
}


/**
* Main
*/
Expand All @@ -90,10 +88,9 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log('Initializing ACME client');
const client = new acme.Client({
directoryUrl: acme.directory.letsencrypt.staging,
accountKey: await acme.crypto.createPrivateKey()
accountKey: await acme.crypto.createPrivateKey(),
});


/**
* ALPN responder
*/
Expand All @@ -118,14 +115,14 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log(`Found ALPN certificate for ${servername}, serving secure context`);
cb(null, tls.createSecureContext({
key: alpnResponses[servername][0],
cert: alpnResponses[servername][1]
cert: alpnResponses[servername][1],
}));
}
catch (e) {
log(`[ERROR] ${e.message}`);
cb(e.message);
}
}
},
});

/* Terminate once TLS handshake has been established */
Expand All @@ -137,7 +134,6 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log(`ALPN responder listening on port ${ALPN_RESPONDER_PORT}`);
});


/**
* HTTPS server
*/
Expand Down Expand Up @@ -166,7 +162,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
log(`[ERROR] ${e.message}`);
cb(e.message);
}
}
},
}, requestListener);

httpsServer.listen(HTTPS_SERVER_PORT, () => {
Expand Down
Loading

0 comments on commit 8b00fdb

Please sign in to comment.