From ee36154ffad6be1fb8da2623e06803c116c99988 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Sun, 28 Jul 2024 09:38:10 -0700 Subject: [PATCH 1/5] remove systeminformation command. unnecessary --- src/cli/actions/settings/systemInformation.js | 21 ---------- src/cli/commands/settings.js | 38 ++++++++----------- 2 files changed, 15 insertions(+), 44 deletions(-) delete mode 100644 src/cli/actions/settings/systemInformation.js diff --git a/src/cli/actions/settings/systemInformation.js b/src/cli/actions/settings/systemInformation.js deleted file mode 100644 index 53f3f88..0000000 --- a/src/cli/actions/settings/systemInformation.js +++ /dev/null @@ -1,21 +0,0 @@ -const { logger } = require('./../../../shared/logger') - -const systemInformationHelper = require('./../../../lib/helpers/systemInformation') - -async function systemInformation () { - const options = this.opts() - logger.debug(`options: ${JSON.stringify(options)}`) - - const value = await systemInformationHelper() - - let space = 0 - if (options.prettyPrint) { - space = 2 - } - - console.log(JSON.stringify(value)) - - process.stdout.write(JSON.stringify(value, null, space)) -} - -module.exports = systemInformation diff --git a/src/cli/commands/settings.js b/src/cli/commands/settings.js index 9996050..ce1ab3c 100644 --- a/src/cli/commands/settings.js +++ b/src/cli/commands/settings.js @@ -6,21 +6,6 @@ settings .description('⚙️ settings') .allowUnknownOption() -// dotenvx pro settings status -const statusAction = require('./../actions/settings/status') -settings.command('status') - .description('check account status (--unmask)') - .option('--unmask', 'unmask access token') - .action(statusAction) - -// dotenvx pro settings token -const tokenAction = require('./../actions/settings/token') -settings - .command('token') - .description('print your dotenvx access token (--unmask)') - .option('--unmask', 'unmask access token') - .action(tokenAction) - // dotenvx pro settings publickey const publicKeyAction = require('./../actions/settings/publicKey') settings @@ -44,14 +29,6 @@ settings .option('--unmask', 'unmask recovery phrase') .action(recoveryPhraseAction) -// dotenvx pro settings systeminformation -const systemInformationAction = require('./../actions/settings/systemInformation') -settings - .command('systeminformation') - .description('print your machine\'s systeminformation') - .option('-pp, --pretty-print', 'pretty print output') - .action(systemInformationAction) - // dotenvx pro settings emergencykit const emergencyKitAction = require('./../actions/settings/emergencyKit') settings @@ -67,4 +44,19 @@ settings .description('recover your account 🔐') .action(recover) +// dotenvx pro settings token +const tokenAction = require('./../actions/settings/token') +settings + .command('token') + .description('print your dotenvx access token (--unmask)') + .option('--unmask', 'unmask access token') + .action(tokenAction) + +// dotenvx pro settings status +const statusAction = require('./../actions/settings/status') +settings.command('status') + .description('check account status (--unmask)') + .option('--unmask', 'unmask access token') + .action(statusAction) + module.exports = settings From 0aedc71219bfe413feffe8397b063c95abe4a4f8 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Sun, 28 Jul 2024 10:10:19 -0700 Subject: [PATCH 2/5] reorder commands --- src/cli/commands/settings.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cli/commands/settings.js b/src/cli/commands/settings.js index ce1ab3c..eda89da 100644 --- a/src/cli/commands/settings.js +++ b/src/cli/commands/settings.js @@ -44,6 +44,13 @@ settings .description('recover your account 🔐') .action(recover) +// dotenvx pro settings status +const statusAction = require('./../actions/settings/status') +settings.command('status') + .description('check account status (--unmask)') + .option('--unmask', 'unmask access token') + .action(statusAction) + // dotenvx pro settings token const tokenAction = require('./../actions/settings/token') settings @@ -52,11 +59,4 @@ settings .option('--unmask', 'unmask access token') .action(tokenAction) -// dotenvx pro settings status -const statusAction = require('./../actions/settings/status') -settings.command('status') - .description('check account status (--unmask)') - .option('--unmask', 'unmask access token') - .action(statusAction) - module.exports = settings From 2ae28b9f83e1f938d174ffa77659380552794d06 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Sun, 28 Jul 2024 10:28:55 -0700 Subject: [PATCH 3/5] update blank design --- generators/emergencyKitBlank.js | 76 ++++++++------ generators/emergencyKitPoster.js | 172 +++++++++++++++++++++++++++++++ src/assets/emergencyKitBlank.pdf | Bin 80017 -> 80203 bytes 3 files changed, 217 insertions(+), 31 deletions(-) create mode 100755 generators/emergencyKitPoster.js diff --git a/generators/emergencyKitBlank.js b/generators/emergencyKitBlank.js index 3a37000..530eb64 100755 --- a/generators/emergencyKitBlank.js +++ b/generators/emergencyKitBlank.js @@ -4,30 +4,33 @@ const path = require('path') const Pdfkit = require('pdfkit') const qrcode = require('qrcode') -// const mask = require('../src/lib/helpers/mask') -// const maskRecoveryPhrase = require('../src/lib/helpers/maskRecoveryPhrase') -// const formatRecoveryPhrase = require('../src/lib/helpers/formatRecoveryPhrase') - -function emergencyKitBlank (options = {}) { - // function smartMask (str) { - // if (options.unmask) { - // return str - // } else { - // return mask(str) - // } - // } - // function smartMaskRecoveryPhrase (str) { - // if (options.unmask) { - // return str - // } else { - // return maskRecoveryPhrase(str) - // } - // } - // let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' - // let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' - // recoveryPhrase = smartMaskRecoveryPhrase(recoveryPhrase) - // recoveryPhrase = formatRecoveryPhrase(recoveryPhrase) - // privateKey = smartMask(privateKey) +const mask = require('../src/lib/helpers/mask') +const maskRecoveryPhrase = require('../src/lib/helpers/maskRecoveryPhrase') +const formatRecoveryPhrase = require('../src/lib/helpers/formatRecoveryPhrase') + +// let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' +privateKey = ' ' +// let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' +recoveryPhrase = '' + +function emergencyKitBlank (options = { unmask: true }) { + function smartMask (str) { + if (options.unmask) { + return str + } else { + return mask(str) + } + } + function smartMaskRecoveryPhrase (str) { + if (options.unmask) { + return str + } else { + return maskRecoveryPhrase(str) + } + } + recoveryPhrase = smartMaskRecoveryPhrase(recoveryPhrase) + recoveryPhrase = formatRecoveryPhrase(recoveryPhrase) + privateKey = smartMask(privateKey) // set up doc to pipe to process.stdout const doc = new Pdfkit() @@ -45,12 +48,23 @@ function emergencyKitBlank (options = {}) { // logo const logoPath = path.join(__dirname, './assets/dotenvx.png') - const logoWidth = 44 - const x = 50 - const y = 50 - doc.image(logoPath, x, y, { width: logoWidth, height: logoWidth }) + const logoWidth = 36 + doc.image(logoPath, 100, 675, { width: logoWidth, height: logoWidth }) + + const crossSize = 50 + const crossThickness = 14 + const centerX = page.width / 2 + + // Draw the horizontal part of the cross + doc.rect(centerX - crossSize / 2, 100 - crossThickness / 2, crossSize, crossThickness) + doc.fill('red') + + // Draw the vertical part of the cross + doc.rect(centerX - crossThickness / 2, 100 - crossSize / 2, crossThickness, crossSize) + doc.fill('red') // title + doc.fillColor('black') doc.fontSize(40) const title1 = 'dotenvx. ' const title2 = 'emergency kit.' @@ -103,7 +117,7 @@ function emergencyKitBlank (options = {}) { // privateKey value doc.fontSize(10) doc.font('Courier') - doc.text('', 110, 412, { align: 'left', width: (page.width - (100 * 2) - 20) }) + doc.text(privateKey, 110, 412, { align: 'left', width: (page.width - (100 * 2) - 20) }) // label2 const label2 = 'RECOVERY PHRASE' @@ -122,7 +136,7 @@ function emergencyKitBlank (options = {}) { // recoveryPhrase value doc.fontSize(12) doc.font('Courier') - doc.text('', 110, 482, { align: 'left', width: (page.width - (100 * 2) - 20) }) + doc.text(recoveryPhrase, 110, 482, { align: 'left', width: (page.width - (100 * 2) - 20) }) // help left column const help = 'Need help?' @@ -138,7 +152,7 @@ function emergencyKitBlank (options = {}) { doc.text(email, { link: mailtoLink, underline: true, align: 'left', width: ((page.width - (100 * 2)) / 3) }) doc.fillColor('black') - qrcode.toDataURL('', function (err, url) { + qrcode.toDataURL(privateKey, function (err, url) { if (err) { throw err } diff --git a/generators/emergencyKitPoster.js b/generators/emergencyKitPoster.js new file mode 100755 index 0000000..fc76773 --- /dev/null +++ b/generators/emergencyKitPoster.js @@ -0,0 +1,172 @@ +#!/usr/bin/env node + +const path = require('path') +const Pdfkit = require('pdfkit') +const qrcode = require('qrcode') + +const mask = require('../src/lib/helpers/mask') +const maskRecoveryPhrase = require('../src/lib/helpers/maskRecoveryPhrase') +const formatRecoveryPhrase = require('../src/lib/helpers/formatRecoveryPhrase') + +let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' +let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' + +function emergencyKitPoster (options = {}) { + function smartMask (str) { + if (options.unmask) { + return str + } else { + return mask(str) + } + } + function smartMaskRecoveryPhrase (str) { + if (options.unmask) { + return str + } else { + return maskRecoveryPhrase(str) + } + } + recoveryPhrase = smartMaskRecoveryPhrase(recoveryPhrase) + recoveryPhrase = formatRecoveryPhrase(recoveryPhrase) + privateKey = smartMask(privateKey) + + // set up doc to pipe to process.stdout + const doc = new Pdfkit() + doc.pipe(process.stdout) + + // meta + const page = doc.page + + // red background + doc.rect(0, 0, page.width, page.height) + doc.fill('#8B0000') + + // fonts + doc.registerFont('Display-Bold', path.join(__dirname, './assets/SF-Pro-Display-Bold.otf')) + doc.registerFont('Text-Regular', path.join(__dirname, './assets/SF-Pro-Text-Regular.otf')) + doc.registerFont('Text-Bold', path.join(__dirname, './assets/SF-Pro-Text-Bold.otf')) + doc.registerFont('Text-Heavy', path.join(__dirname, './assets/SF-Pro-Text-Heavy.otf')) + doc.registerFont('Text-ThinItalic', path.join(__dirname, './assets/SF-Pro-Text-ThinItalic.otf')) + + // logo + const logoPath = path.join(__dirname, './assets/dotenvx.png') + const logoWidth = 44 + const x = 50 + const y = 50 + doc.image(logoPath, x, y, { width: logoWidth, height: logoWidth }) + + // title + doc.fontSize(40) + const title1 = 'dotenvx. ' + const title2 = 'emergency kit.' + const titleX = (page.width - doc.widthOfString(`${title1}${title2}`)) / 2 + doc.font('Display-Bold') + doc.text(title1, titleX, 140, { continued: true }) + doc.fillColor('red') + doc.text(title2) + doc.fillColor('black') + + // created-for + // doc.fontSize(9) + // const createdFor = `created for ${store.getUsername()} on ${currentDate()}` + // const createdForX = (page.width - doc.widthOfString(createdFor)) / 2 + // doc.font('Text-ThinItalic') + // doc.fillColor('gray') + // doc.text(createdFor, createdForX, 200) + // doc.fillColor('black') + + // text + doc.fontSize(12) + const intro = 'The details below can be used to sign in to your dotenvx account in an emergency.' + doc.font('Text-Regular') + doc.text(intro, 100, 260, { align: 'left', width: page.width - (100 * 2) }) + + // step 1 + const one = '1. Print out this document.' + doc.font('Text-Regular') + doc.text(one, 100, 310, { align: 'left', width: page.width - (100 * 2) }) + + // step 2 + const two = '2. Store in a secure place where you can find it, e.g. a safe deposit box.' + doc.font('Text-Regular') + doc.text(two, 100, 330, { align: 'left', width: page.width - (100 * 2) }) + + // label1 + const label1 = 'PRIVATE KEY' + doc.fillColor('red') + doc.fontSize(10) + doc.font('Text-Heavy') + doc.text(label1, 100, 380, { align: 'left', width: page.width - (100 * 2) }) + doc.fillColor('black') + + // privateKey input + doc.strokeColor('red') + doc.roundedRect(100, 400, page.width - (100 * 2), 30, 4) + doc.stroke() + doc.strokeColor('black') + + // privateKey value + doc.fontSize(10) + doc.font('Courier') + doc.text(privateKey, 110, 412, { align: 'left', width: (page.width - (100 * 2) - 20) }) + + // label2 + const label2 = 'RECOVERY PHRASE' + doc.fillColor('blue') + doc.fontSize(10) + doc.font('Text-Heavy') + doc.text(label2, 100, 450, { align: 'left', width: page.width - (100 * 2) }) + doc.fillColor('black') + + // recoveryPhrase input + doc.strokeColor('blue') + doc.roundedRect(100, 470, page.width - (100 * 2), 120, 4) + doc.stroke() + doc.strokeColor('black') + + // recoveryPhrase value + doc.fontSize(12) + doc.font('Courier') + doc.text(recoveryPhrase, 110, 482, { align: 'left', width: (page.width - (100 * 2) - 20) }) + + // help left column + const help = 'Need help?' + const email = 'support@dotenvx.com' + const contactUsAt = 'Contact us at: ' + const mailtoLink = `mailto:${email}` + doc.font('Text-Bold') + doc.fontSize(10) + doc.text(help, 100, 620, { align: 'left', width: (page.width - (100 * 2)) }) + doc.font('Text-Regular') + doc.text(contactUsAt, 100, 640, { align: 'left', width: ((page.width - (100 * 2)) / 3), continued: true }) + doc.fillColor('gray') + doc.text(email, { link: mailtoLink, underline: true, align: 'left', width: ((page.width - (100 * 2)) / 3) }) + doc.fillColor('black') + + qrcode.toDataURL(privateKey, function (err, url) { + if (err) { + throw err + } + + // qr code center column + // const qrBuffer = Buffer.from(url.replace(/^data:image\/png;base64,/, ''), 'base64') + // const qrX = (page.width / 2) - (120 / 2) + // doc.image(qrBuffer, qrX, 610, { width: 120, height: 120 }) + + // explainer right column + const setup = 'Setup code' + const setupMore = 'Your PRIVATE KEY is embedded in this QR Code. In the future, we\'ll provide tools to scan this code - setting up your account quickly and easily on new devices.' + doc.font('Text-Bold') + doc.fontSize(10) + doc.text(setup, 380, 620, { align: 'left', width: (page.width - (100 * 2)) }) + doc.font('Text-Regular') + doc.fontSize(9) + doc.text(setupMore, 380, 640, { align: 'left', width: ((page.width - (100 * 2)) / 3) }) + doc.end() + + // doc.addPage() + // doc.fontSize(14).text('This is page 2', 100, 100) + }) +} + +emergencyKitPoster() diff --git a/src/assets/emergencyKitBlank.pdf b/src/assets/emergencyKitBlank.pdf index aa64d6f6d7e073309b7b3d5b9506c5d90d2de26b..e2236ebbb6234f9fb8d50b550c322724c98b061e 100644 GIT binary patch delta 2574 zcmZ`*3s@6Z7G^|w1W*zl;iV0VB3Q{hGLwuVSRPS8Q4sKfr~wiPl>{PSpw?i~wPt}8 z2b)C%1w>qg66NIrx*`Q?5e0mpf?}u@L0n$8prG!Awkwa_^L;blz2}_!pL70u@0m#( zn%guym%4Pb8+Rq-fKZlxB!vR8(x}cvua)?MUsw48LyQI;j1fN`GLj>Zna*tCMl~{w}$rly7OE%v@~H^5I~Z zG;O)(Z;!dk7WsK89`+(ipySforP<>AnNM;_UHcc+ogU)N_ZD1#KX4Ej8X8cI0-E1m zIO0Did8~(1GcKJN9g$A_+%pv6958P}3u)-X?Iz9z3zF*@R%sIdQG&juGb zz~YV7OB`M$OYqJpZ!>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t8sJxxTS!#|M`7jR?_Om*9fCK+UR#awXoGvv*_|KY_Gj7I^mI#BOMKuU0d;l z^@kqY#(r0N@y5gWMnB$wNA|YP4F=~3uVn^AdS$U|6IL8+@Zr8e63%;5BB;KTmu2~~ zU06Sh2T7)5d=!qjYKju;Y-8DR2gm=-yV$Pb#k}q`lLN&36W@uH;Cg8lX;+->pvgPBy!9cX~M{O?jW1j?Sr>I2yYt zw|f?7z9o7Na$~~c6XLiWy=d8#zcm7caXLhoP0Xa%m?tm6oV=@Kxy;1|fe;j8B1{B9 z5r|-$f6B*5NLkxLw#py0c9wD_@Z;z(^Rt-8k8$B7aOp511IZYD8filT$vhn$vRb*7 zk&fc?0gJmAkvPSk6|c7dVKRS z9Am&mk8yzIz{I89Hvc7z6VeV^fH5ICVwlN5ij;9+g#ac{bm0mFhUH5}Sqp7I5aJ*5 zSn}2|5Nx3}5QBxtbOq8{KlzWM5Gp5(qD*{jrI3Fp&gZp;NP^dMU_bSs9U2!TRS zXc&hHBLoZL65*j7l(`k+;9Pt9|4#`9rQdCQ0w*pZC5{^oGFdPRgT}_+__zY#{{R*p BfARnT From a67d83326ed7e22e5d8355386462f3648463f365 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Sun, 28 Jul 2024 10:30:32 -0700 Subject: [PATCH 4/5] standard formatting --- generators/emergencyKitBlank.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/emergencyKitBlank.js b/generators/emergencyKitBlank.js index 530eb64..81dd133 100755 --- a/generators/emergencyKitBlank.js +++ b/generators/emergencyKitBlank.js @@ -9,9 +9,9 @@ const maskRecoveryPhrase = require('../src/lib/helpers/maskRecoveryPhrase') const formatRecoveryPhrase = require('../src/lib/helpers/formatRecoveryPhrase') // let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' -privateKey = ' ' +let privateKey = ' ' // let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' -recoveryPhrase = '' +let recoveryPhrase = '' function emergencyKitBlank (options = { unmask: true }) { function smartMask (str) { From 81c44bff87588d7cc0b2c9d8a227fd6d8c642b59 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Sun, 28 Jul 2024 11:14:52 -0700 Subject: [PATCH 5/5] example --- generators/emergencyKitBlank.js | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/generators/emergencyKitBlank.js b/generators/emergencyKitBlank.js index 81dd133..3391660 100755 --- a/generators/emergencyKitBlank.js +++ b/generators/emergencyKitBlank.js @@ -8,12 +8,12 @@ const mask = require('../src/lib/helpers/mask') const maskRecoveryPhrase = require('../src/lib/helpers/maskRecoveryPhrase') const formatRecoveryPhrase = require('../src/lib/helpers/formatRecoveryPhrase') -// let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' -let privateKey = ' ' -// let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' -let recoveryPhrase = '' +let privateKey = '2c93601cba85b3b2474817897826ebef977415c097f0bf57dcbaa3056e5d64d0' +// privateKey = ' ' +let recoveryPhrase = 'cart guess electric adult carpet ritual wisdom obscure season tiger spatial stable arrow narrow rely almost brisk arrange dune dawn roast venture install dinosaur' +// recoveryPhrase = '' -function emergencyKitBlank (options = { unmask: true }) { +function emergencyKitBlank (options = { unmask: false, example: true }) { function smartMask (str) { if (options.unmask) { return str @@ -158,9 +158,9 @@ function emergencyKitBlank (options = { unmask: true }) { } // qr code center column - // const qrBuffer = Buffer.from(url.replace(/^data:image\/png;base64,/, ''), 'base64') - // const qrX = (page.width / 2) - (120 / 2) - // doc.image(qrBuffer, qrX, 610, { width: 120, height: 120 }) + const qrBuffer = Buffer.from(url.replace(/^data:image\/png;base64,/, ''), 'base64') + const qrX = (page.width / 2) - (120 / 2) + doc.image(qrBuffer, qrX, 610, { width: 120, height: 120 }) // explainer right column const setup = 'Setup code' @@ -171,6 +171,29 @@ function emergencyKitBlank (options = { unmask: true }) { doc.font('Text-Regular') doc.fontSize(9) doc.text(setupMore, 380, 640, { align: 'left', width: ((page.width - (100 * 2)) / 3) }) + + // example + if (options.example) { + // Calculate the position to center the text diagonally + const angle = Math.atan(page.height / page.width) + + // Save the graphics state + doc.save() + + // Translate and rotate the coordinate system + doc.translate(page.width / 2, page.height / 2) + doc.rotate((angle * 180) / Math.PI) + + // Set the opacity and draw the text + doc.fillColor('gray') + doc.opacity(0.3) + doc.fontSize(160) + doc.text('EXAMPLE', -600, -120, { align: 'center' }) + + // restore + doc.restore() + } + doc.end() // doc.addPage()