From 84130faf41f1677da00eb5c028fcbdc0c3696a21 Mon Sep 17 00:00:00 2001 From: Zack Steinkamp Date: Tue, 16 Jan 2024 14:08:47 -0800 Subject: [PATCH] update to njs-types@0.8.2 for NginxPeriodicSession; rename clientAutoModeWeb to clientAutoModeHTTP; fix unused var warning --- integration-tests/nginx.conf | 2 +- package-lock.json | 14 +++++++------- package.json | 2 +- src/index.ts | 9 ++++----- src/utils.ts | 22 ---------------------- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/integration-tests/nginx.conf b/integration-tests/nginx.conf index d365411..2b8fa3c 100644 --- a/integration-tests/nginx.conf +++ b/integration-tests/nginx.conf @@ -45,7 +45,7 @@ http { } location = /acme/auto { - js_content acme.clientAutoModeWeb; + js_content acme.clientAutoModeHTTP; } location = / { diff --git a/package-lock.json b/package-lock.json index 5dc6d05..082ca50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "mocha": "^10.2.0", "mocha-suite-hooks": "^0.1.0", "nginx-testing": "^0.4.0", - "njs-types": "^0.8.0", + "njs-types": "^0.8.2", "npm-run-all": "^4.1.5", "power-assert": "^1.6.1", "prettier": "^2.8.8", @@ -4538,9 +4538,9 @@ "dev": true }, "node_modules/njs-types": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/njs-types/-/njs-types-0.8.0.tgz", - "integrity": "sha512-txbfYbBNW+j6qw4NHMBh7luvpgNFjl3RGHtoaYFYajWpN4fehTnoHk9iE5fIuYFfiohYI42Xiy5A7gmvvvpg6A==", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/njs-types/-/njs-types-0.8.2.tgz", + "integrity": "sha512-6uv1Tcb4khW45LHZqj5vu1uo7WbvB6nINZjDVmryOxiO3K7rDMqRVNJbYtLHOKNbGDqLygIip9iYZbFViIVGqA==", "dev": true }, "node_modules/node-fetch": { @@ -9779,9 +9779,9 @@ "dev": true }, "njs-types": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/njs-types/-/njs-types-0.8.0.tgz", - "integrity": "sha512-txbfYbBNW+j6qw4NHMBh7luvpgNFjl3RGHtoaYFYajWpN4fehTnoHk9iE5fIuYFfiohYI42Xiy5A7gmvvvpg6A==", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/njs-types/-/njs-types-0.8.2.tgz", + "integrity": "sha512-6uv1Tcb4khW45LHZqj5vu1uo7WbvB6nINZjDVmryOxiO3K7rDMqRVNJbYtLHOKNbGDqLygIip9iYZbFViIVGqA==", "dev": true }, "node-fetch": { diff --git a/package.json b/package.json index f8c7e78..04342d6 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "mocha": "^10.2.0", "mocha-suite-hooks": "^0.1.0", "nginx-testing": "^0.4.0", - "njs-types": "^0.8.0", + "njs-types": "^0.8.2", "npm-run-all": "^4.1.5", "power-assert": "^1.6.1", "prettier": "^2.8.8", diff --git a/src/index.ts b/src/index.ts index 0196304..745ec7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,6 @@ import { generateKey, getVariable, joinPaths, - NginxPeriodicSession, readCertificateInfo, readOrCreateAccountKey, toPEM, @@ -49,10 +48,10 @@ type clientAutoModeReturnType = { * Method to use if you want to be able to trigger a certificate refresh from an HTTP request. * * - * @param {NginxPeriodicSession | NginxHTTPRequest} r Incoming session or request + * @param {NginxHTTPRequest} r Incoming session or request * @returns void */ -async function clientAutoModeWeb(r: NginxHTTPRequest): Promise { +async function clientAutoModeHTTP(r: NginxHTTPRequest): Promise { try { const result = await clientAutoModeInternal(r) if (!result.success) { @@ -184,7 +183,7 @@ async function clientAutoModeInternal( csr: Buffer.from(csr.pkcs10Ber), email, termsOfServiceAgreed: true, - challengeCreateFn: async (authz, challenge, keyAuthorization) => { + challengeCreateFn: async (_, challenge, keyAuthorization) => { log.info( `Writing challenge file so nginx can serve it via .well-known/acme-challenge/${challenge.token}` ) @@ -425,7 +424,7 @@ export default { acmeNewAccount, challengeResponse, clientNewAccount, - clientAutoModeWeb, + clientAutoModeHTTP, clientAutoMode, createCsrHandler, LogLevel, diff --git a/src/utils.ts b/src/utils.ts index 05a1050..3224af3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,28 +8,6 @@ import { Logger } from './logger' const log = new Logger('utils') -/** - * TODO DELETE THIS ONCE njs-0.8.1 is released (0.8.1 defines this interface) - * NginxPeriodicSession object is available as the first argument in the js_periodic handler. - * @since 0.8.1 - */ -export interface NginxPeriodicSession { - /** - * nginx variables as Buffers. - * - * @see variables - */ - readonly rawVariables: NginxRawVariables - /** - * nginx variables as strings. - * - * **Warning:** Bytes invalid in UTF-8 encoding may be converted into the replacement character. - * - * @see rawVariables - */ - readonly variables: NginxVariables -} - // workaround for PKI.JS to work globalThis.unescape = querystring.unescape