From 92224513d7afd47e3c002fe48bc2a8bce34574b0 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 12 Jul 2023 16:04:45 +0000 Subject: [PATCH 1/2] Fix ESM/cjs import of bip39 --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5463190..1d53175 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,9 @@ "default": "./aes.js" }, "./bip39": { - "types": "./bip39.d.ts", - "import": "./esm/bip39.js", - "default": "./bip39.js" + "types": "./bip39/index.d.ts", + "import": "./esm/bip39/index.js", + "default": "./bip39/index.js" }, "./blake2b": { "types": "./blake2b.d.ts", @@ -167,9 +167,9 @@ "default": "./aes.js" }, "./bip39.js": { - "types": "./bip39.d.ts", - "import": "./esm/bip39.js", - "default": "./bip39.js" + "types": "./bip39/index.d.ts", + "import": "./esm/bip39/index.js", + "default": "./bip39/index.js" }, "./blake2b.js": { "types": "./blake2b.d.ts", From f7d9334eef66c6b734e3c792eacaa853f3b2ec2d Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 12 Jul 2023 16:06:22 +0000 Subject: [PATCH 2/2] Add import tests --- test/test-imports-1.mjs | 37 +++++++++++++++++++++++++++++++++++++ test/test-imports-2.mjs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 test/test-imports-1.mjs create mode 100644 test/test-imports-2.mjs diff --git a/test/test-imports-1.mjs b/test/test-imports-1.mjs new file mode 100644 index 0000000..a082f7e --- /dev/null +++ b/test/test-imports-1.mjs @@ -0,0 +1,37 @@ +// Hashes +import { sha256 } from "ethereum-cryptography/sha256.js"; +import { keccak256 } from "ethereum-cryptography/keccak.js"; +import { ripemd160 } from "ethereum-cryptography/ripemd160.js"; +import { blake2b } from "ethereum-cryptography/blake2b.js"; + +// KDFs +import { pbkdf2Sync } from "ethereum-cryptography/pbkdf2.js"; +import { scryptSync } from "ethereum-cryptography/scrypt.js"; + +// Random +import { getRandomBytesSync } from "ethereum-cryptography/random.js"; + +// AES encryption +import { encrypt } from "ethereum-cryptography/aes.js"; + +// secp256k1 elliptic curve operations +import { secp256k1 } from "ethereum-cryptography/secp256k1.js"; + +// BIP32 HD Keygen, BIP39 Mnemonic Phrases +import { HDKey } from "ethereum-cryptography/hdkey.js"; +import { generateMnemonic as gm1 } from "ethereum-cryptography/bip39.js"; +import { generateMnemonic as gm2 } from "ethereum-cryptography/bip39/index.js"; +import { wordlist } from "ethereum-cryptography/bip39/wordlists/english.js"; + +// utilities +import { hexToBytes, toHex, utf8ToBytes } from "ethereum-cryptography/utils.js"; + +import * as w1 from 'ethereum-cryptography/bip39/wordlists/czech.js'; +import * as w2 from 'ethereum-cryptography/bip39/wordlists/english.js'; +import * as w3 from 'ethereum-cryptography/bip39/wordlists/french.js'; +import * as w4 from 'ethereum-cryptography/bip39/wordlists/italian.js'; +import * as w5 from 'ethereum-cryptography/bip39/wordlists/japanese.js'; +import * as w6 from 'ethereum-cryptography/bip39/wordlists/korean.js'; +import * as w7 from 'ethereum-cryptography/bip39/wordlists/simplified-chinese.js'; +import * as w8 from 'ethereum-cryptography/bip39/wordlists/spanish.js'; +import * as w9 from 'ethereum-cryptography/bip39/wordlists/traditional-chinese.js'; diff --git a/test/test-imports-2.mjs b/test/test-imports-2.mjs new file mode 100644 index 0000000..bc12b06 --- /dev/null +++ b/test/test-imports-2.mjs @@ -0,0 +1,37 @@ +// Hashes +import { sha256 } from "ethereum-cryptography/sha256"; +import { keccak256 } from "ethereum-cryptography/keccak"; +import { ripemd160 } from "ethereum-cryptography/ripemd160"; +import { blake2b } from "ethereum-cryptography/blake2b"; + +// KDFs +import { pbkdf2Sync } from "ethereum-cryptography/pbkdf2"; +import { scryptSync } from "ethereum-cryptography/scrypt"; + +// Random +import { getRandomBytesSync } from "ethereum-cryptography/random"; + +// AES encryption +import { encrypt } from "ethereum-cryptography/aes"; + +// secp256k1 elliptic curve operations +import { secp256k1 } from "ethereum-cryptography/secp256k1"; + +// BIP32 HD Keygen, BIP39 Mnemonic Phrases +import { HDKey } from "ethereum-cryptography/hdkey"; +import { generateMnemonic as gm1 } from "ethereum-cryptography/bip39"; +import { generateMnemonic as gm2 } from "ethereum-cryptography/bip39/index"; +import { wordlist } from "ethereum-cryptography/bip39/wordlists/english"; + +// utilities +import { hexToBytes, toHex, utf8ToBytes } from "ethereum-cryptography/utils"; + +import * as w1 from 'ethereum-cryptography/bip39/wordlists/czech'; +import * as w2 from 'ethereum-cryptography/bip39/wordlists/english'; +import * as w3 from 'ethereum-cryptography/bip39/wordlists/french'; +import * as w4 from 'ethereum-cryptography/bip39/wordlists/italian'; +import * as w5 from 'ethereum-cryptography/bip39/wordlists/japanese'; +import * as w6 from 'ethereum-cryptography/bip39/wordlists/korean'; +import * as w7 from 'ethereum-cryptography/bip39/wordlists/simplified-chinese'; +import * as w8 from 'ethereum-cryptography/bip39/wordlists/spanish'; +import * as w9 from 'ethereum-cryptography/bip39/wordlists/traditional-chinese';