From ff27341d9479ac5d75e95bfd5f40270a421da343 Mon Sep 17 00:00:00 2001 From: alex4386 Date: Mon, 24 May 2021 21:52:55 +0900 Subject: [PATCH] chore: bump up version to 0.0.2 --- package.json | 2 +- src/index.ts | 67 +++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 925ad2b..4625ce2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "acme-wizard-for-console", - "version": "0.0.1", + "version": "0.0.2", "description": "A Let's Encrypt ACME Wizard for Stella IT Console", "main": "dist/", "repository": "https://github.com/Stella-IT/acme-wizard-for-console", diff --git a/src/index.ts b/src/index.ts index 6dfee89..9c3df06 100644 --- a/src/index.ts +++ b/src/index.ts @@ -166,44 +166,47 @@ let tokens: TokenStore | undefined = undefined; email, }), ); + + tosAgree = await (prompts.confirm({ + type: 'confirm', + name: 'tos', + message: `Do you agree to Let's Encrypt Terms of Service? (${chalk.cyanBright( + chalk.underline('https://letsencrypt.org/repository/'), + )})`, + }) as unknown as Promise); + + if (!tosAgree) { + Log.error( + "Setup can not continue. Consenting to Let's Encrypt ToS is required to issue valid certificate.", + ); + return; + } + + email = await (prompts.text({ + type: 'text', + name: 'email', + message: 'Enter the email:', + validate: (input) => { + return /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/g.test( + input, + ) + ? true + : 'Not a valid email'; + }, + initial: email, + }) as unknown as Promise); + } else { + Log.error("Setup can not continue. Account Key generation is required to request Let's Encrypt Server."); + return; } } else { accountKey = choice.accountKey; email = choice.email; - } - } - if (!accountKey) { - Log.error("Setup can not continue. Account Key generation is required to request Let's Encrypt Server."); - return; - } - - tosAgree = await (prompts.confirm({ - type: 'confirm', - name: 'tos', - message: `Do you agree to Let's Encrypt Terms of Service? (${chalk.cyanBright( - chalk.underline('https://letsencrypt.org/repository/'), - )})`, - }) as unknown as Promise); - - if (!tosAgree) { - Log.error("Setup can not continue. Consenting to Let's Encrypt ToS is required to issue valid certificate."); - return; + tosAgree = true; + Log.info("Skipping ToS since it was previously used in Let's Encrypt"); + } } - - email = await (prompts.text({ - type: 'text', - name: 'email', - message: 'Enter the email:', - validate: (input) => { - return /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/g.test( - input, - ) - ? true - : 'Not a valid email'; - }, - initial: email, - }) as unknown as Promise); } else { Log.info("This domain was previously registered on Let's Encrypt. Skipping ToS Agreement"); tosAgree = true;