@trustwallet/wallet-core 3.0.9 → 3.1.1
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/generated/core_proto.d.ts +5311 -4201
- package/dist/generated/core_proto.js +11301 -8410
- package/dist/lib/wallet-core.js +111 -110
- package/dist/lib/wallet-core.wasm +0 -0
- package/dist/src/keystore/default-impl.d.ts +3 -3
- package/dist/src/keystore/default-impl.js +6 -6
- package/dist/src/keystore/types.d.ts +3 -3
- package/dist/src/wallet-core.d.ts +14 -0
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { WalletCore, CoinType, PrivateKey, StoredKey } from "../wallet-core";
|
1
|
+
import { WalletCore, CoinType, 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;
|
@@ -11,8 +11,8 @@ export declare class Default implements Types.IKeyStore {
|
|
11
11
|
mapWallet(storedKey: StoredKey): Types.Wallet;
|
12
12
|
mapStoredKey(wallet: Types.Wallet): StoredKey;
|
13
13
|
importWallet(wallet: Types.Wallet): Promise<void>;
|
14
|
-
import(mnemonic: string, name: string, password: string, coins: CoinType[]): Promise<Types.Wallet>;
|
15
|
-
importKey(key: Uint8Array, name: string, password: string, coin: CoinType): Promise<Types.Wallet>;
|
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
16
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Types.Wallet>;
|
17
17
|
getKey(id: string, password: string, account: Types.ActiveAccount): Promise<PrivateKey>;
|
18
18
|
export(id: string, password: string): Promise<string | Uint8Array>;
|
@@ -38,15 +38,15 @@ var Default = /** @class */ (function () {
|
|
38
38
|
Default.prototype.importWallet = function (wallet) {
|
39
39
|
return this.storage.set(wallet.id, wallet);
|
40
40
|
};
|
41
|
-
Default.prototype.import = function (mnemonic, name, password, coins) {
|
41
|
+
Default.prototype.import = function (mnemonic, name, password, coins, encryption) {
|
42
42
|
var _this = this;
|
43
43
|
return new Promise(function (resolve, reject) {
|
44
|
-
var _a = _this.core, Mnemonic = _a.Mnemonic, StoredKey = _a.StoredKey, HDWallet = _a.HDWallet;
|
44
|
+
var _a = _this.core, Mnemonic = _a.Mnemonic, StoredKey = _a.StoredKey, HDWallet = _a.HDWallet, StoredKeyEncryption = _a.StoredKeyEncryption;
|
45
45
|
if (!Mnemonic.isValid(mnemonic)) {
|
46
46
|
throw Types.Error.InvalidMnemonic;
|
47
47
|
}
|
48
48
|
var pass = Buffer.from(password);
|
49
|
-
var storedKey = StoredKey.
|
49
|
+
var storedKey = StoredKey.importHDWalletWithEncryption(mnemonic, name, pass, coins[0], encryption);
|
50
50
|
var hdWallet = HDWallet.createWithMnemonic(mnemonic, "");
|
51
51
|
coins.forEach(function (coin) {
|
52
52
|
storedKey.accountForCoin(coin, hdWallet);
|
@@ -59,17 +59,17 @@ var Default = /** @class */ (function () {
|
|
59
59
|
.catch(function (error) { return reject(error); });
|
60
60
|
});
|
61
61
|
};
|
62
|
-
Default.prototype.importKey = function (key, name, password, coin) {
|
62
|
+
Default.prototype.importKey = function (key, name, password, coin, encryption) {
|
63
63
|
var _this = this;
|
64
64
|
return new Promise(function (resolve, reject) {
|
65
|
-
var _a = _this.core, StoredKey = _a.StoredKey, PrivateKey = _a.PrivateKey, Curve = _a.Curve;
|
65
|
+
var _a = _this.core, StoredKey = _a.StoredKey, PrivateKey = _a.PrivateKey, Curve = _a.Curve, StoredKeyEncryption = _a.StoredKeyEncryption;
|
66
66
|
// FIXME: get curve from coin
|
67
67
|
if (!PrivateKey.isValid(key, Curve.secp256k1) ||
|
68
68
|
!PrivateKey.isValid(key, Curve.ed25519)) {
|
69
69
|
throw Types.Error.InvalidKey;
|
70
70
|
}
|
71
71
|
var pass = Buffer.from(password);
|
72
|
-
var storedKey = StoredKey.
|
72
|
+
var storedKey = StoredKey.importPrivateKeyWithEncryption(key, name, pass, coin, encryption);
|
73
73
|
var wallet = _this.mapWallet(storedKey);
|
74
74
|
storedKey.delete();
|
75
75
|
_this.importWallet(wallet)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CoinType, PrivateKey } from "../wallet-core";
|
1
|
+
import { CoinType, PrivateKey, StoredKeyEncryption } from "../wallet-core";
|
2
2
|
export declare enum WalletType {
|
3
3
|
Mnemonic = "mnemonic",
|
4
4
|
PrivateKey = "privateKey",
|
@@ -31,8 +31,8 @@ export interface IKeyStore {
|
|
31
31
|
hasWallet(id: string): Promise<boolean>;
|
32
32
|
load(id: string): Promise<Wallet>;
|
33
33
|
loadAll(): Promise<Wallet[]>;
|
34
|
-
import(mnemonic: string, name: string, password: string, coins: CoinType[]): Promise<Wallet>;
|
35
|
-
importKey(key: Uint8Array, name: string, password: string, coin: CoinType): Promise<Wallet>;
|
34
|
+
import(mnemonic: string, name: string, password: string, coins: CoinType[], encryption: StoredKeyEncryption): Promise<Wallet>;
|
35
|
+
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Wallet>;
|
36
36
|
importWallet(wallet: Wallet): Promise<void>;
|
37
37
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Wallet>;
|
38
38
|
getKey(id: string, password: string, account: ActiveAccount): Promise<PrivateKey>;
|
@@ -255,6 +255,13 @@ export class SS58AddressType {
|
|
255
255
|
static polkadot: SS58AddressType;
|
256
256
|
static kusama: SS58AddressType;
|
257
257
|
}
|
258
|
+
export class StoredKeyEncryption {
|
259
|
+
value: number;
|
260
|
+
static aes128Ctr: StoredKeyEncryption;
|
261
|
+
static aes128Cbc: StoredKeyEncryption;
|
262
|
+
static aes192Ctr: StoredKeyEncryption;
|
263
|
+
static aes256Ctr: StoredKeyEncryption;
|
264
|
+
}
|
258
265
|
export class Base64 {
|
259
266
|
static decode(string: string): Uint8Array;
|
260
267
|
static decodeUrl(string: string): Uint8Array;
|
@@ -442,6 +449,7 @@ export class Blockchain {
|
|
442
449
|
static nervos: Blockchain;
|
443
450
|
static everscale: Blockchain;
|
444
451
|
static aptos: Blockchain;
|
452
|
+
static hedera: Blockchain;
|
445
453
|
}
|
446
454
|
export class HDVersion {
|
447
455
|
value: number;
|
@@ -575,6 +583,7 @@ export class CoinType {
|
|
575
583
|
static nervos: CoinType;
|
576
584
|
static everscale: CoinType;
|
577
585
|
static aptos: CoinType;
|
586
|
+
static hedera: CoinType;
|
578
587
|
}
|
579
588
|
export class RippleXAddress {
|
580
589
|
static equal(lhs: RippleXAddress, rhs: RippleXAddress): boolean;
|
@@ -597,10 +606,14 @@ export class BitcoinMessageSigner {
|
|
597
606
|
export class StoredKey {
|
598
607
|
static load(path: string): StoredKey;
|
599
608
|
static importPrivateKey(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
609
|
+
static importPrivateKeyWithEncryption(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
600
610
|
static importHDWallet(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
611
|
+
static importHDWalletWithEncryption(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
601
612
|
static importJSON(json: Uint8Array | Buffer): StoredKey;
|
602
613
|
static createLevel(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel): StoredKey;
|
614
|
+
static createLevelAndEncryption(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel, encryption: StoredKeyEncryption): StoredKey;
|
603
615
|
static create(name: string, password: Uint8Array | Buffer): StoredKey;
|
616
|
+
static createEncryption(name: string, password: Uint8Array | Buffer, encryption: StoredKeyEncryption): StoredKey;
|
604
617
|
identifier(): string;
|
605
618
|
name(): string;
|
606
619
|
isMnemonic(): boolean;
|
@@ -746,6 +759,7 @@ export interface WalletCore {
|
|
746
759
|
NEARAccount: typeof NEARAccount;
|
747
760
|
Base58: typeof Base58;
|
748
761
|
SS58AddressType: typeof SS58AddressType;
|
762
|
+
StoredKeyEncryption: typeof StoredKeyEncryption;
|
749
763
|
Base64: typeof Base64;
|
750
764
|
HDWallet: typeof HDWallet;
|
751
765
|
SegwitAddress: typeof SegwitAddress;
|