@totemsdk/core 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bip39.js +10 -3
  2. package/package.json +1 -1
package/dist/bip39.js CHANGED
@@ -402,16 +402,23 @@ function phraseToSeed(rawPhrase) {
402
402
  * @returns Array of 24 random BIP39 words (lowercase)
403
403
  */
404
404
  function generateWordList() {
405
- const words = [];
406
405
  const randomValues = new Uint32Array(24);
407
406
  if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
408
407
  crypto.getRandomValues(randomValues);
409
408
  }
410
- else {
409
+ else if (typeof process !== 'undefined' && process.versions?.node) {
410
+ const nodeCrypto = Function('return require')()('crypto');
411
+ const bytes = nodeCrypto.randomBytes(96);
411
412
  for (let i = 0; i < 24; i++) {
412
- randomValues[i] = Math.floor(Math.random() * 0x100000000);
413
+ randomValues[i] = bytes.readUInt32BE(i * 4);
413
414
  }
414
415
  }
416
+ else {
417
+ throw new Error('generateWordList: no cryptographically secure random source available. ' +
418
+ 'Seed generation requires crypto.getRandomValues (browser/Node 19+) or node:crypto.randomBytes (Node). ' +
419
+ 'Math.random() is not acceptable for key material.');
420
+ }
421
+ const words = [];
415
422
  for (let i = 0; i < 24; i++) {
416
423
  const index = randomValues[i] % exports.WORD_LIST.length;
417
424
  words.push(exports.WORD_LIST[index]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/core",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Core cryptographic primitives for Totem SDK — backed by Rust/WASM",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",