diff --git a/build.js b/build.js index de51316..1b2dce6 100755 --- a/build.js +++ b/build.js @@ -17,7 +17,7 @@ esbuild packages: 'external' }) .then(() => { - const packageJson = JSON.stringify({ type: 'module' }) + const packageJson = JSON.stringify({type: 'module'}) fs.writeFileSync(`${__dirname}/lib/esm/package.json`, packageJson, 'utf8') console.log('esm build success.') diff --git a/justfile b/justfile index 509adc6..9ba1f1f 100644 --- a/justfile +++ b/justfile @@ -18,3 +18,6 @@ emit-types: publish: build emit-types npm publish + +format: + prettier --plugin-search-dir . --write . \ No newline at end of file diff --git a/nip06.test.js b/nip06.test.js index 1e28412..643e705 100644 --- a/nip06.test.js +++ b/nip06.test.js @@ -4,12 +4,16 @@ const {nip06} = require('./lib/nostr.cjs') test('generate private key from a mnemonic', async () => { const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong' const privateKey = nip06.privateKeyFromSeedWords(mnemonic) - expect(privateKey).toEqual('c26cf31d8ba425b555ca27d00ca71b5008004f2f662470f8c8131822ec129fe2') + expect(privateKey).toEqual( + 'c26cf31d8ba425b555ca27d00ca71b5008004f2f662470f8c8131822ec129fe2' + ) }) test('generate private key from a mnemonic and passphrase', async () => { const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong' const passphrase = '123' const privateKey = nip06.privateKeyFromSeedWords(mnemonic, passphrase) - expect(privateKey).toEqual('55a22b8203273d0aaf24c22c8fbe99608e70c524b17265641074281c8b978ae4') + expect(privateKey).toEqual( + '55a22b8203273d0aaf24c22c8fbe99608e70c524b17265641074281c8b978ae4' + ) }) diff --git a/nip06.ts b/nip06.ts index 037cb9e..6d37860 100644 --- a/nip06.ts +++ b/nip06.ts @@ -7,7 +7,10 @@ import { } from '@scure/bip39' import {HDKey} from '@scure/bip32' -export function privateKeyFromSeedWords(mnemonic: string, passphrase?: string): string { +export function privateKeyFromSeedWords( + mnemonic: string, + passphrase?: string +): string { let root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase)) let privateKey = root.derive(`m/44'/1237'/0'/0/0`).privateKey if (!privateKey) throw new Error('could not derive private key') diff --git a/package.json b/package.json index 041565e..71b86ba 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "type": "git", "url": "https://github.com/nbd-wtf/nostr-tools.git" }, - "files": ["./lib/**/*"], + "files": [ + "./lib/**/*" + ], "types": "./lib/index.d.ts", "main": "lib/nostr.cjs.js", "module": "lib/esm/nostr.mjs",