@trustwallet/wallet-core 4.3.3 → 4.3.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.
package/dist/lib/wallet-core.js
CHANGED
@@ -36,7 +36,7 @@ function $a(a,b){var c=M;return sa||"function"!=typeof WebAssembly.instantiateSt
|
|
36
36
|
function z(a,b){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){n("Module."+a+" has been replaced with plain "+b+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}
|
37
37
|
function cb(a){return"FS_createPath"===a||"FS_createDataFile"===a||"FS_createPreloadedFile"===a||"FS_unlink"===a||"addRunDependency"===a||"FS_createLazyFile"===a||"FS_createDevice"===a||"removeRunDependency"===a}(function(a,b){"undefined"!==typeof globalThis&&Object.defineProperty(globalThis,a,{configurable:!0,get:function(){ya("`"+a+"` is not longer defined by emscripten. "+b)}})})("buffer","Please use HEAP8.buffer or wasmMemory.buffer");
|
38
38
|
function db(a){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){var b="'"+a+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";cb(a)&&(b+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you");n(b)}})}
|
39
|
-
var eb={
|
39
|
+
var eb={2185716:()=>{if(void 0===g.fa)try{var a="object"===typeof window?window:self,b="undefined"!==typeof a.crypto?a.crypto:a.msCrypto;a=function(){var d=new Uint32Array(1);b.getRandomValues(d);return d[0]>>>0};a();g.fa=a}catch(d){try{var c=require("crypto");a=function(){var e=c.randomBytes(4);return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0};a();g.fa=a}catch(e){throw"No secure random number generator found";}}},2186438:()=>g.fa()};
|
40
40
|
function qa(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}function fb(a){for(;0<a.length;)a.shift()(g)}function za(a){assert("number"===typeof a);return"0x"+a.toString(16).padStart(8,"0")}function ya(a){gb||(gb={});gb[a]||(gb[a]=1,w&&(a="warning: "+a),y(a))}var gb,hb=[];function ib(a){var b=hb[a];b||(a>=hb.length&&(hb.length=a+1),hb[a]=b=Ha.get(a));assert(Ha.get(a)==b,"JavaScript-side Wasm function table mirror is out of date!");return b}
|
41
41
|
function jb(a){this.l=a-24;this.Oa=function(b){G[this.l+4>>2]=b};this.Ja=function(b){G[this.l+8>>2]=b};this.Ka=function(){F[this.l>>2]=0};this.Ea=function(){D[this.l+12>>0]=0};this.La=function(){D[this.l+13>>0]=0};this.I=function(b,c){this.Da();this.Oa(b);this.Ja(c);this.Ka();this.Ea();this.La()};this.Da=function(){G[this.l+16>>2]=0}}
|
42
42
|
var kb=0,lb=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},mb=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=lb(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},nb=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},ob=
|
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { WalletCore, CoinType, PrivateKey, StoredKey, StoredKeyEncryption } from "../wallet-core";
|
1
|
+
import { WalletCore, CoinType, Derivation, PrivateKey, StoredKey, StoredKeyEncryption } from "../wallet-core";
|
2
2
|
import * as Types from "./types";
|
3
3
|
export declare class Default implements Types.IKeyStore {
|
4
4
|
private readonly core;
|
@@ -12,8 +12,8 @@ export declare class Default implements Types.IKeyStore {
|
|
12
12
|
mapStoredKey(wallet: Types.Wallet): StoredKey;
|
13
13
|
importWallet(wallet: Types.Wallet): Promise<void>;
|
14
14
|
import(mnemonic: string, name: string, password: string, coins: CoinType[], encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
15
|
-
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
16
|
-
importKeyEncoded(key: string, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
15
|
+
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption, derivation: Derivation): Promise<Types.Wallet>;
|
16
|
+
importKeyEncoded(key: string, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption, derivation: Derivation): Promise<Types.Wallet>;
|
17
17
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Types.Wallet>;
|
18
18
|
addAccountsWithDerivations(id: string, password: string, coins: Types.CoinWithDerivation[]): Promise<Types.Wallet>;
|
19
19
|
getKey(id: string, password: string, account: Types.ActiveAccount): Promise<PrivateKey>;
|
@@ -57,7 +57,7 @@ var Default = /** @class */ (function () {
|
|
57
57
|
.catch(function (error) { return reject(error); });
|
58
58
|
});
|
59
59
|
};
|
60
|
-
Default.prototype.importKey = function (key, name, password, coin, encryption) {
|
60
|
+
Default.prototype.importKey = function (key, name, password, coin, encryption, derivation) {
|
61
61
|
var _this = this;
|
62
62
|
return new Promise(function (resolve, reject) {
|
63
63
|
var _a = _this.core, StoredKey = _a.StoredKey, PrivateKey = _a.PrivateKey, Curve = _a.Curve, StoredKeyEncryption = _a.StoredKeyEncryption;
|
@@ -67,7 +67,7 @@ var Default = /** @class */ (function () {
|
|
67
67
|
throw Types.Error.InvalidKey;
|
68
68
|
}
|
69
69
|
var pass = Buffer.from(password);
|
70
|
-
var storedKey = StoredKey.
|
70
|
+
var storedKey = StoredKey.importPrivateKeyWithEncryptionAndDerivation(key, name, pass, coin, encryption, derivation);
|
71
71
|
var wallet = _this.mapWallet(storedKey);
|
72
72
|
storedKey.delete();
|
73
73
|
_this.importWallet(wallet)
|
@@ -75,12 +75,12 @@ var Default = /** @class */ (function () {
|
|
75
75
|
.catch(function (error) { return reject(error); });
|
76
76
|
});
|
77
77
|
};
|
78
|
-
Default.prototype.importKeyEncoded = function (key, name, password, coin, encryption) {
|
78
|
+
Default.prototype.importKeyEncoded = function (key, name, password, coin, encryption, derivation) {
|
79
79
|
var _this = this;
|
80
80
|
return new Promise(function (resolve, reject) {
|
81
81
|
var _a = _this.core, StoredKey = _a.StoredKey, PrivateKey = _a.PrivateKey, Curve = _a.Curve, StoredKeyEncryption = _a.StoredKeyEncryption;
|
82
82
|
var pass = Buffer.from(password);
|
83
|
-
var storedKey = StoredKey.
|
83
|
+
var storedKey = StoredKey.importPrivateKeyEncodedWithEncryptionAndDerivation(key, name, pass, coin, encryption, derivation);
|
84
84
|
var wallet = _this.mapWallet(storedKey);
|
85
85
|
storedKey.delete();
|
86
86
|
_this.importWallet(wallet)
|
@@ -37,7 +37,7 @@ export interface IKeyStore {
|
|
37
37
|
load(id: string): Promise<Wallet>;
|
38
38
|
loadAll(): Promise<Wallet[]>;
|
39
39
|
import(mnemonic: string, name: string, password: string, coins: CoinType[], encryption: StoredKeyEncryption): Promise<Wallet>;
|
40
|
-
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Wallet>;
|
40
|
+
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption, derivation: Derivation): Promise<Wallet>;
|
41
41
|
importWallet(wallet: Wallet): Promise<void>;
|
42
42
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Wallet>;
|
43
43
|
addAccountsWithDerivations(id: string, password: string, coins: CoinWithDerivation[]): Promise<Wallet>;
|
@@ -947,8 +947,10 @@ export class StoredKey {
|
|
947
947
|
static load(path: string): StoredKey;
|
948
948
|
static importPrivateKey(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
949
949
|
static importPrivateKeyWithEncryption(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
950
|
+
static importPrivateKeyWithEncryptionAndDerivation(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption, derivation: Derivation): StoredKey;
|
950
951
|
static importPrivateKeyEncoded(privateKey: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
951
952
|
static importPrivateKeyEncodedWithEncryption(privateKey: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
953
|
+
static importPrivateKeyEncodedWithEncryptionAndDerivation(privateKey: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption, derivation: Derivation): StoredKey;
|
952
954
|
static importHDWallet(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
953
955
|
static importHDWalletWithEncryption(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
954
956
|
static importJSON(json: Uint8Array | Buffer): StoredKey;
|