New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fuel-ts/mnemonic

Package Overview
Dependencies
Maintainers
4
Versions
1217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fuel-ts/mnemonic - npm Package Compare versions

Comparing version 0.0.0-master-a4544ae to 0.0.0-master-ab598f7d

dist/index.global.js

82

dist/index.d.ts

@@ -1,3 +0,79 @@

export { default as Mnemonic } from './mnemonic';
export type { MnemonicPhrase } from './utils';
//# sourceMappingURL=index.d.ts.map
import { BytesLike } from '@ethersproject/bytes';
declare type MnemonicPhrase = string | Array<string>;
declare class Mnemonic {
wordlist: Array<string>;
/**
*
* @param wordlist - Provide a wordlist with the list of words used to generate the mnemonic phrase. The default value is the English list.
* @returns Mnemonic instance
*/
constructor(wordlist?: Array<string>);
/**
*
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
* @returns Entropy hash
*/
mnemonicToEntropy(phrase: MnemonicPhrase): string;
/**
*
* @param entropy - Entropy source to the mnemonic phrase.
* @returns Mnemonic phrase
*/
entropyToMnemonic(entropy: BytesLike): string;
/**
*
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
* @param wordlist - Provide a wordlist with the list of words used to generate the mnemonic phrase. The default value is the English list.
* @returns Mnemonic phrase
*/
static mnemonicToEntropy(phrase: MnemonicPhrase, wordlist?: Array<string>): string;
/**
* @param entropy - Entropy source to the mnemonic phrase.
* @param testnet - Inform if should use testnet or mainnet prefix, default value is true (`mainnet`).
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
*/
static entropyToMnemonic(entropy: BytesLike, wordlist?: Array<string>): string;
/**
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
* @param passphrase - Add additional security to protect the generated seed with a memorized passphrase. `Note: if the owner forgot the passphrase, all wallets and accounts derive from the phrase will be lost.`
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
*/
static mnemonicToSeed(phrase: MnemonicPhrase, passphrase?: BytesLike): string;
/**
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
* @param passphrase - Add additional security to protect the generated seed with a memorized passphrase. `Note: if the owner forgot the passphrase, all wallets and accounts derive from the phrase will be lost.`
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
*/
static mnemonicToMasterKeys(phrase: MnemonicPhrase, passphrase?: BytesLike): Uint8Array;
/**
* @param seed - BIP39 seed
* @param testnet - Inform if should use testnet or mainnet prefix, the default value is true (`mainnet`).
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
*/
static masterKeysFromSeed(seed: string): Uint8Array;
/**
* Get the extendKey as defined on BIP-32 from the provided seed
*
* @param seed - BIP39 seed
* @param testnet - Inform if should use testnet or mainnet prefix, default value is true (`mainnet`).
* @returns BIP-32 extended private key
*/
static seedToExtendedKey(seed: string, testnet?: boolean): string;
/**
* Create a new mnemonic using a randomly generated number as entropy.
* As defined in BIP39, the entropy must be a multiple of 32 bits, and its size must be between 128 and 256 bits.
* Therefore, the possible values for `strength` are 128, 160, 192, 224, and 256.
* If not provided, the default entropy length will be set to 256 bits.
* The return is a list of words that encodes the generated entropy.
*
*
* @param size - Number of bytes used as an entropy
* @param extraEntropy - Optional extra entropy to increase randomness
* @returns A randomly generated mnemonic
*/
static generate(size?: number, extraEntropy?: BytesLike): string;
}
export { Mnemonic, MnemonicPhrase };

10

dist/index.js

@@ -1,8 +0,2 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mnemonic = void 0;
var mnemonic_1 = require("./mnemonic");
Object.defineProperty(exports, "Mnemonic", { enumerable: true, get: function () { return __importDefault(mnemonic_1).default; } });
var d=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},z=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of F(e))!W.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=U(e,s))||n.enumerable});return t};var C=t=>z(d({},"__esModule",{value:!0}),t);var H={};j(H,{Mnemonic:()=>S});module.exports=C(H);var K=require("@ethersproject/basex"),o=require("@ethersproject/bytes"),v=require("@ethersproject/pbkdf2"),k=require("@ethersproject/random"),m=require("@ethersproject/sha2"),g=require("@fuel-ts/wordlists");var u=require("@ethersproject/bytes"),x=require("@ethersproject/sha2");function p(t){let e=t.normalize("NFKD"),r=[];for(let n=0;n<e.length;n+=1){let s=e.charCodeAt(n);if(s<128)r.push(s);else if(s<2048)r.push(s>>6|192),r.push(s&63|128);else if((s&64512)===55296){n+=1;let i=e.charCodeAt(n);if(n>=e.length||(i&64512)!==56320)throw new Error("invalid utf-8 string");let a=65536+((s&1023)<<10)+(i&1023);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(a&63|128)}else r.push(s>>12|224),r.push(s>>6&63|128),r.push(s&63|128)}return(0,u.arrayify)(r)}function D(t){return(1<<t)-1}function M(t){return(1<<t)-1<<8-t}function A(t){return Array.isArray(t)?t:t.split(" ")}function T(t){return Array.isArray(t)?t.join(" "):t}function P(t){let e=[0],r=11;for(let i=0;i<t.length;i+=1)r>8?(e[e.length-1]<<=8,e[e.length-1]|=t[i],r-=8):(e[e.length-1]<<=r,e[e.length-1]|=t[i]>>8-r,e.push(t[i]&D(8-r)),r+=3);let n=t.length/4,s=(0,u.arrayify)((0,x.sha256)(t))[0]&M(n);return e[e.length-1]<<=n,e[e.length-1]|=s>>8-n,e}function E(t,e){let r=Math.ceil(11*t.length/8),n=(0,u.arrayify)(new Uint8Array(r)),s=0;for(let h=0;h<t.length;h+=1){let f=e.indexOf(t[h].normalize("NFKD"));if(f===-1)throw new Error("invalid mnemonic");for(let l=0;l<11;l+=1)f&1<<10-l&&(n[s>>3]|=1<<7-s%8),s+=1}let i=32*t.length/3,a=t.length/3,y=M(a);if(((0,u.arrayify)((0,x.sha256)(n.slice(0,i/8)))[0]&y)!==(n[n.length-1]&y))throw new Error("invalid checksum");return n.slice(0,i/8)}var I=p("Bitcoin seed"),N=76066276,R=70615956;function b(t){if(t.length!==2048)throw new Error("Invalid word list length")}function V(t){if(t.length%4!==0||t.length<16||t.length>32)throw new Error("invalid entropy")}function L(t){if(![12,15,18,21,24].includes(t.length))throw new Error("invalid mnemonic size")}var c=class{constructor(e=g.english){this.wordlist=e,b(this.wordlist)}mnemonicToEntropy(e){return c.mnemonicToEntropy(e,this.wordlist)}entropyToMnemonic(e){return c.entropyToMnemonic(e,this.wordlist)}static mnemonicToEntropy(e,r=g.english){let n=A(e);return L(n),(0,o.hexlify)(E(n,r))}static entropyToMnemonic(e,r=g.english){let n=(0,o.arrayify)(e,{allowMissingPrefix:!0});return b(r),V(n),P(n).map(s=>r[s]).join(" ")}static mnemonicToSeed(e,r=""){L(A(e));let n=p(T(e)),s=p(`mnemonic${r}`);return(0,v.pbkdf2)(n,s,2048,64,"sha512")}static mnemonicToMasterKeys(e,r=""){let n=c.mnemonicToSeed(e,r);return c.masterKeysFromSeed(n)}static masterKeysFromSeed(e){let r=(0,o.arrayify)(e);if(r.length<16||r.length>64)throw new Error("invalid seed");return(0,o.arrayify)((0,m.computeHmac)(m.SupportedAlgorithm.sha512,I,r))}static seedToExtendedKey(e,r=!1){let n=c.masterKeysFromSeed(e),s=(0,o.arrayify)(r?R:N),i="0x00",a="0x00000000",y="0x00000000",B=n.slice(32),h=n.slice(0,32),f=(0,o.concat)([s,i,a,y,B,(0,o.concat)(["0x00",h])]),l=(0,o.hexDataSlice)((0,m.sha256)((0,m.sha256)(f)),0,4);return K.Base58.encode((0,o.concat)([f,l]))}static generate(e=32,r=""){let n=r?(0,m.sha256)((0,o.concat)([(0,k.randomBytes)(e),(0,o.arrayify)(r)])):(0,k.randomBytes)(e);return c.entropyToMnemonic(n)}},S=c;0&&(module.exports={Mnemonic});
//# sourceMappingURL=index.js.map
{
"name": "@fuel-ts/mnemonic",
"version": "0.0.0-master-a4544ae",
"version": "0.0.0-master-ab598f7d",
"description": "Mnemonic implementation from BIP39",

@@ -8,2 +8,11 @@ "author": "Fuel Labs <contact@fuel.sh> (https://fuel.network/)",

"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"typings": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"default": "./dist/index.mjs"
}
},
"files": [

@@ -19,5 +28,7 @@ "dist"

"@ethersproject/sha2": "^5.5.0",
"@fuel-ts/wordlists": "0.0.0-master-a4544ae"
"@fuel-ts/wordlists": "0.0.0-master-ab598f7d"
},
"gitHead": "20320864b80a372dd51206ff2939fed39e60a70e"
}
"scripts": {
"build": "tsup --dts"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc