Skip to content

Commit

Permalink
Merge branch 'dev-E2EE-2406' into 'master'
Browse files Browse the repository at this point in the history
feat(E2EE-2406): add npm script to generate a libsodium crypto box keypair

See merge request TankerHQ/sdk-js!1032
  • Loading branch information
ntalfer committed Nov 20, 2024
2 parents 6cd90c3 + 15557a9 commit 5e7d150
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions packages/crypto/src/generate_keypair.ts
Original file line number Diff line number Diff line change
@@ -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
})();

0 comments on commit 5e7d150

Please sign in to comment.