diff --git a/.vscode/settings.json b/.vscode/settings.json index 510d61ee..52b34187 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "eslint.validate": [ "javascript", diff --git a/package.json b/package.json index b789f2fd..4694f6e1 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "debug:errors": "karma start packages/errors/config/karma.config.debug.js", "debug:streams": "karma start packages/stream/config/karma.config.debug.js", "proof": "poetry install && poetry run python run-ci.py lint && npm run test", - "coverage": "nyc npm run test" + "coverage": "nyc npm run test", + "gen:keypair": "npm run build:crypto && node ./packages/crypto/dist/node/generate_keypair.js" }, "devDependencies": { "@types/chai": "^4.3.4", diff --git a/packages/crypto/src/generate_keypair.ts b/packages/crypto/src/generate_keypair.ts new file mode 100644 index 00000000..faa19f6c --- /dev/null +++ b/packages/crypto/src/generate_keypair.ts @@ -0,0 +1,12 @@ +import sodium from 'libsodium-wrappers'; +import { toBase64 } from './utils'; + +(async () => { + await sodium.ready; + const keypair = sodium.crypto_box_keypair(); + const b64keypair = { + privateKey: toBase64(keypair.privateKey), + publicKey: toBase64(keypair.publicKey), + }; + console.log(b64keypair); // eslint-disable-line no-console +})();