diff --git a/.npmignore b/.npmignore index bd2bb48..42d1c3a 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,5 @@ __tests__ -test-package +__test_package__ .github coverage tmp diff --git a/test-package/functions.js b/__test_package__/functions.js similarity index 66% rename from test-package/functions.js rename to __test_package__/functions.js index 1a42ca6..7871449 100644 --- a/test-package/functions.js +++ b/__test_package__/functions.js @@ -11,7 +11,9 @@ function testEncryptAndDigest(encryptAndDigest) { hmacSecret, encryptionKey }); - assert.ok(result); + assert.ok(result, "nothing returned from package"); + assert.ok(result.digest.length > 0, 'no digest returned from package'); + assert.ok(result.payload.length > 0, 'no payload returned from package'); } module.exports = { diff --git a/test-package/index.js b/__test_package__/index.js similarity index 97% rename from test-package/index.js rename to __test_package__/index.js index 9dc5f7f..e2d3c65 100644 --- a/test-package/index.js +++ b/__test_package__/index.js @@ -84,13 +84,13 @@ function pack () { } /** - * Run `npm i` + * Run `npm i --production=true` * @returns Promise that resolves on success, rejects with msg on error */ function install () { console.log('--- install ---'); return new Promise((resolve, reject) => { - const install = spawn('npm', ['i'], { + const install = spawn('npm', ['i', '--production=true'], { cwd: `${localNodeModulesPath}/package` }); install.on('close', installCode => { diff --git a/test-package/package.json b/__test_package__/package.json similarity index 100% rename from test-package/package.json rename to __test_package__/package.json diff --git a/test-package/test-import.cjs b/__test_package__/test-import.cjs similarity index 100% rename from test-package/test-import.cjs rename to __test_package__/test-import.cjs diff --git a/test-package/test-import.mjs b/__test_package__/test-import.mjs similarity index 100% rename from test-package/test-import.mjs rename to __test_package__/test-import.mjs diff --git a/test-package/test-require.cjs b/__test_package__/test-require.cjs similarity index 100% rename from test-package/test-require.cjs rename to __test_package__/test-require.cjs diff --git a/lib/helpers.js b/lib/helpers.js index c755e89..f8b79e5 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -31,8 +31,9 @@ export function encryptAndDigest (input, options) { export function decryptAndTest (originalDigest, encryptedInput, options) { const decrypted = symmetricDecrypt(encryptedInput, options); const digest = generateHmac(decrypted, options); + const ok = originalDigest && digest && digest === originalDigest; return { - ok: digest === originalDigest, + ok, decrypted }; } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bed1ba3..5b36092 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,22 +1,22 @@ { "name": "@localnerve/hmac-symmetric", - "version": "0.1.0", + "version": "0.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@localnerve/hmac-symmetric", - "version": "0.1.0", + "version": "0.3.1", "license": "BSD-3-Clause", "devDependencies": { - "@babel/cli": "^7.22.10", - "@babel/preset-env": "^7.22.14", + "@babel/cli": "^7.22.15", + "@babel/preset-env": "^7.22.15", "cross-env": "^7.0.3", "eslint": "^8.48.0", - "glob": "^10.3.3", + "glob": "^10.3.4", "jest": "^29.6.4", "rimraf": "^5.0.1", - "tar": "^6.1.15" + "tar": "^6.2.0" }, "engines": { "node": ">= 16" diff --git a/package.json b/package.json index 6ed8d02..420a750 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@localnerve/hmac-symmetric", - "version": "0.3.0", + "version": "0.3.1", "description": "A library to generate hmac and symmetrically encrypted payloads", "main": "index.js", "type": "module", @@ -18,7 +18,7 @@ "transpile": "babel lib -d cjs --out-file-extension .cjs", "posttranspile": "node posttranspile.js", "test": "cross-env HS_HMAC_SECRET=deadbeef HS_ENCRYPTION_KEY=56c6a9c6fb56a39e05fb993918ab01dda24439e2658dd7b06aa0f8fcc7fe0627 jest && npm run test-package", - "test-package": "node ./test-package/index.js" + "test-package": "node ./__test_package__/index.js" }, "repository": { "type": "git", @@ -44,14 +44,14 @@ }, "homepage": "https://github.com/localnerve/hmac-symmetric#readme", "devDependencies": { - "@babel/cli": "^7.22.10", - "@babel/preset-env": "^7.22.14", + "@babel/cli": "^7.22.15", + "@babel/preset-env": "^7.22.15", "cross-env": "^7.0.3", "rimraf": "^5.0.1", "jest": "^29.6.4", "eslint": "^8.48.0", - "tar": "^6.1.15", - "glob": "^10.3.3" + "tar": "^6.2.0", + "glob": "^10.3.4" }, "engines": { "node": ">= 16" diff --git a/test-package/public/images/1997805.png b/test-package/public/images/1997805.png deleted file mode 100644 index c8318b3..0000000 Binary files a/test-package/public/images/1997805.png and /dev/null differ