Skip to content

Commit

Permalink
update to [email protected] for NginxPeriodicSession; rename clientAuto…
Browse files Browse the repository at this point in the history
…ModeWeb to clientAutoModeHTTP; fix unused var warning
  • Loading branch information
zsteinkamp committed Mar 11, 2024
1 parent c2b996a commit 84130fa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 36 deletions.
2 changes: 1 addition & 1 deletion integration-tests/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ http {
}

location = /acme/auto {
js_content acme.clientAutoModeWeb;
js_content acme.clientAutoModeHTTP;
}

location = / {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
generateKey,
getVariable,
joinPaths,
NginxPeriodicSession,
readCertificateInfo,
readOrCreateAccountKey,
toPEM,
Expand Down Expand Up @@ -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<void> {
async function clientAutoModeHTTP(r: NginxHTTPRequest): Promise<void> {
try {
const result = await clientAutoModeInternal(r)
if (!result.success) {
Expand Down Expand Up @@ -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}`
)
Expand Down Expand Up @@ -425,7 +424,7 @@ export default {
acmeNewAccount,
challengeResponse,
clientNewAccount,
clientAutoModeWeb,
clientAutoModeHTTP,
clientAutoMode,
createCsrHandler,
LogLevel,
Expand Down
22 changes: 0 additions & 22 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 84130fa

Please sign in to comment.