@eluvio/elv-client-js 4.0.7 → 4.0.9
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/ElvClient-min.js +10 -11
- package/dist/ElvClient-node-min.js +10 -11
- package/dist/ElvFrameClient-min.js +10 -11
- package/dist/ElvPermissionsClient-min.js +9 -10
- package/dist/ElvWalletClient-min.js +10 -11
- package/dist/ElvWalletClient-node-min.js +9 -10
- package/dist/src/AuthorizationClient.js +2069 -1548
- package/dist/src/ContentObjectVerification.js +185 -134
- package/dist/src/Crypto.js +323 -226
- package/dist/src/ElvClient.js +1118 -824
- package/dist/src/ElvWallet.js +106 -64
- package/dist/src/EthClient.js +974 -719
- package/dist/src/FrameClient.js +318 -222
- package/dist/src/HttpClient.js +154 -112
- package/dist/src/Id.js +6 -1
- package/dist/src/LogMessage.js +8 -4
- package/dist/src/PermissionsClient.js +1271 -973
- package/dist/src/RemoteSigner.js +232 -161
- package/dist/src/UserProfileClient.js +1038 -781
- package/dist/src/Utils.js +302 -160
- package/dist/src/Validation.js +17 -2
- package/dist/src/client/ABRPublishing.js +942 -772
- package/dist/src/client/AccessGroups.js +1095 -849
- package/dist/src/client/ContentAccess.js +4198 -3272
- package/dist/src/client/ContentManagement.js +2284 -1812
- package/dist/src/client/Contracts.js +614 -468
- package/dist/src/client/Files.js +1831 -1491
- package/dist/src/client/NFT.js +116 -94
- package/dist/src/client/NTP.js +425 -326
- package/dist/src/index.js +5 -2
- package/dist/src/walletClient/ClientMethods.js +1766 -1350
- package/dist/src/walletClient/Configuration.js +2 -4
- package/dist/src/walletClient/Notifications.js +127 -98
- package/dist/src/walletClient/Profile.js +246 -184
- package/dist/src/walletClient/Utils.js +124 -78
- package/dist/src/walletClient/index.js +1498 -1169
- package/package.json +1 -1
- package/src/Crypto.js +2 -2
- package/src/ElvClient.js +2 -2
- package/src/Utils.js +1 -1
- package/src/client/ContentAccess.js +27 -10
- package/src/client/Files.js +1 -1
- package/src/walletClient/ClientMethods.js +18 -10
- package/src/walletClient/Utils.js +2 -2
- package/src/walletClient/index.js +7 -2
package/dist/src/ElvWallet.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
|
+
|
|
2
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
3
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
|
+
|
|
4
7
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
8
|
+
|
|
5
9
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
10
|
+
|
|
6
11
|
var Ethers = require("ethers");
|
|
12
|
+
|
|
7
13
|
var ElvWallet = /*#__PURE__*/function () {
|
|
8
14
|
"use strict";
|
|
9
15
|
|
|
@@ -16,21 +22,22 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
16
22
|
*/
|
|
17
23
|
function ElvWallet(provider) {
|
|
18
24
|
_classCallCheck(this, ElvWallet);
|
|
25
|
+
|
|
19
26
|
this.provider = provider;
|
|
20
27
|
this.signers = {};
|
|
21
28
|
}
|
|
22
|
-
|
|
23
29
|
/**
|
|
24
30
|
* Generate a mnemonic that can be used to initialize a private key
|
|
25
31
|
*
|
|
26
32
|
* @returns {string} - Space-separated list of random words
|
|
27
33
|
*/
|
|
34
|
+
|
|
35
|
+
|
|
28
36
|
_createClass(ElvWallet, [{
|
|
29
37
|
key: "GenerateMnemonic",
|
|
30
38
|
value: function GenerateMnemonic() {
|
|
31
39
|
return Ethers.Wallet.createRandom().mnemonic.phrase;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
41
|
/**
|
|
35
42
|
* Generate a private key from the given mnemonic
|
|
36
43
|
*
|
|
@@ -40,18 +47,18 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
40
47
|
*
|
|
41
48
|
* @returns {Signer} - Signer with the generated private key, connected to the provider
|
|
42
49
|
*/
|
|
50
|
+
|
|
43
51
|
}, {
|
|
44
52
|
key: "AddAccountFromMnemonic",
|
|
45
53
|
value: function AddAccountFromMnemonic(_ref) {
|
|
46
54
|
var accountName = _ref.accountName,
|
|
47
|
-
|
|
55
|
+
mnemonic = _ref.mnemonic;
|
|
48
56
|
var signer = Ethers.Wallet.fromMnemonic(mnemonic);
|
|
49
57
|
return this.AddAccount({
|
|
50
58
|
accountName: accountName,
|
|
51
59
|
privateKey: signer.privateKey
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
|
-
|
|
55
62
|
/**
|
|
56
63
|
* Add an account from an encrypted private key (Ethereum keystore format)
|
|
57
64
|
*
|
|
@@ -62,35 +69,44 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
62
69
|
*
|
|
63
70
|
* @returns {Promise<Signer>} - Signer with the decrypted private key, connected to the provider
|
|
64
71
|
*/
|
|
72
|
+
|
|
65
73
|
}, {
|
|
66
74
|
key: "AddAccountFromEncryptedPK",
|
|
67
75
|
value: function () {
|
|
68
76
|
var _AddAccountFromEncryptedPK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
69
77
|
var accountName, encryptedPrivateKey, password, signer;
|
|
70
78
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
71
|
-
while (1)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
accountName = _ref2.accountName, encryptedPrivateKey = _ref2.encryptedPrivateKey, password = _ref2.password;
|
|
83
|
+
|
|
84
|
+
if (_typeof(encryptedPrivateKey) === "object") {
|
|
85
|
+
encryptedPrivateKey = JSON.stringify(encryptedPrivateKey);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_context.next = 4;
|
|
89
|
+
return Ethers.Wallet.fromEncryptedJson(encryptedPrivateKey, password);
|
|
90
|
+
|
|
91
|
+
case 4:
|
|
92
|
+
signer = _context.sent;
|
|
93
|
+
return _context.abrupt("return", this.AddAccount({
|
|
94
|
+
accountName: accountName,
|
|
95
|
+
privateKey: signer.privateKey
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
case 6:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context.stop();
|
|
101
|
+
}
|
|
88
102
|
}
|
|
89
103
|
}, _callee, this);
|
|
90
104
|
}));
|
|
105
|
+
|
|
91
106
|
function AddAccountFromEncryptedPK(_x) {
|
|
92
107
|
return _AddAccountFromEncryptedPK.apply(this, arguments);
|
|
93
108
|
}
|
|
109
|
+
|
|
94
110
|
return AddAccountFromEncryptedPK;
|
|
95
111
|
}()
|
|
96
112
|
/**
|
|
@@ -102,23 +118,26 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
102
118
|
*
|
|
103
119
|
* @returns {Signer} - Signer with the private key, connected to the provider
|
|
104
120
|
*/
|
|
121
|
+
|
|
105
122
|
}, {
|
|
106
123
|
key: "AddAccount",
|
|
107
124
|
value: function AddAccount(_ref3) {
|
|
108
125
|
var accountName = _ref3.accountName,
|
|
109
|
-
|
|
126
|
+
privateKey = _ref3.privateKey;
|
|
127
|
+
|
|
110
128
|
try {
|
|
111
129
|
var signer = new Ethers.Wallet(privateKey);
|
|
112
130
|
signer = signer.connect(this.provider);
|
|
131
|
+
|
|
113
132
|
if (accountName) {
|
|
114
133
|
this.signers[accountName] = signer;
|
|
115
134
|
}
|
|
135
|
+
|
|
116
136
|
return signer;
|
|
117
137
|
} catch (error) {
|
|
118
138
|
throw Error("Invalid private key");
|
|
119
139
|
}
|
|
120
140
|
}
|
|
121
|
-
|
|
122
141
|
/**
|
|
123
142
|
* Get the balance of the account. The account to query can be specified either by
|
|
124
143
|
* passing the signer object, or by passing the account name of a saved account
|
|
@@ -131,39 +150,49 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
131
150
|
*
|
|
132
151
|
* @returns {number} - Account balance of the specified account, in ETH
|
|
133
152
|
*/
|
|
153
|
+
|
|
134
154
|
}, {
|
|
135
155
|
key: "GetAccountBalance",
|
|
136
156
|
value: function () {
|
|
137
157
|
var _GetAccountBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4) {
|
|
138
158
|
var accountName, signer, accountSigner;
|
|
139
159
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
140
|
-
while (1)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
while (1) {
|
|
161
|
+
switch (_context2.prev = _context2.next) {
|
|
162
|
+
case 0:
|
|
163
|
+
accountName = _ref4.accountName, signer = _ref4.signer;
|
|
164
|
+
accountSigner = signer || this.GetAccount({
|
|
165
|
+
accountName: accountName
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (accountSigner) {
|
|
169
|
+
_context2.next = 4;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
throw Error("Unknown account: " + accountName);
|
|
174
|
+
|
|
175
|
+
case 4:
|
|
176
|
+
_context2.t0 = Ethers.utils;
|
|
177
|
+
_context2.next = 7;
|
|
178
|
+
return accountSigner.getBalance();
|
|
179
|
+
|
|
180
|
+
case 7:
|
|
181
|
+
_context2.t1 = _context2.sent;
|
|
182
|
+
return _context2.abrupt("return", _context2.t0.formatEther.call(_context2.t0, _context2.t1));
|
|
183
|
+
|
|
184
|
+
case 9:
|
|
185
|
+
case "end":
|
|
186
|
+
return _context2.stop();
|
|
187
|
+
}
|
|
161
188
|
}
|
|
162
189
|
}, _callee2, this);
|
|
163
190
|
}));
|
|
191
|
+
|
|
164
192
|
function GetAccountBalance(_x2) {
|
|
165
193
|
return _GetAccountBalance.apply(this, arguments);
|
|
166
194
|
}
|
|
195
|
+
|
|
167
196
|
return GetAccountBalance;
|
|
168
197
|
}()
|
|
169
198
|
/**
|
|
@@ -180,37 +209,47 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
180
209
|
*
|
|
181
210
|
* @returns {Promise<string>} - The encrypted private key (in Ethereum keystore format)
|
|
182
211
|
*/
|
|
212
|
+
|
|
183
213
|
}, {
|
|
184
214
|
key: "GenerateEncryptedPrivateKey",
|
|
185
215
|
value: function () {
|
|
186
216
|
var _GenerateEncryptedPrivateKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
187
217
|
var accountName, signer, password, options, accountSigner;
|
|
188
218
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
189
|
-
while (1)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
219
|
+
while (1) {
|
|
220
|
+
switch (_context3.prev = _context3.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
accountName = _ref5.accountName, signer = _ref5.signer, password = _ref5.password, options = _ref5.options;
|
|
223
|
+
accountSigner = signer || this.GetAccount({
|
|
224
|
+
accountName: accountName
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (accountSigner) {
|
|
228
|
+
_context3.next = 4;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
throw Error("Unknown account: " + accountName);
|
|
233
|
+
|
|
234
|
+
case 4:
|
|
235
|
+
_context3.next = 6;
|
|
236
|
+
return accountSigner.encrypt(password, options);
|
|
237
|
+
|
|
238
|
+
case 6:
|
|
239
|
+
return _context3.abrupt("return", _context3.sent);
|
|
240
|
+
|
|
241
|
+
case 7:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context3.stop();
|
|
244
|
+
}
|
|
208
245
|
}
|
|
209
246
|
}, _callee3, this);
|
|
210
247
|
}));
|
|
248
|
+
|
|
211
249
|
function GenerateEncryptedPrivateKey(_x3) {
|
|
212
250
|
return _GenerateEncryptedPrivateKey.apply(this, arguments);
|
|
213
251
|
}
|
|
252
|
+
|
|
214
253
|
return GenerateEncryptedPrivateKey;
|
|
215
254
|
}()
|
|
216
255
|
/**
|
|
@@ -220,19 +259,20 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
220
259
|
* @param {string} accountName - Name of the account
|
|
221
260
|
* @returns {(Signer|undefined)} - Signer of the saved account, if it exists
|
|
222
261
|
*/
|
|
262
|
+
|
|
223
263
|
}, {
|
|
224
264
|
key: "GetAccount",
|
|
225
265
|
value: function GetAccount(_ref6) {
|
|
226
266
|
var accountName = _ref6.accountName;
|
|
227
267
|
return this.signers[accountName];
|
|
228
268
|
}
|
|
229
|
-
|
|
230
269
|
/**
|
|
231
270
|
* Remove a previously saved account from this wallet
|
|
232
271
|
*
|
|
233
272
|
* @namedParams
|
|
234
273
|
* @param {string} accountName - Name of the account to delete
|
|
235
274
|
*/
|
|
275
|
+
|
|
236
276
|
}, {
|
|
237
277
|
key: "RemoveAccount",
|
|
238
278
|
value: function RemoveAccount(_ref7) {
|
|
@@ -240,6 +280,8 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
240
280
|
delete this.signers[accountName];
|
|
241
281
|
}
|
|
242
282
|
}]);
|
|
283
|
+
|
|
243
284
|
return ElvWallet;
|
|
244
285
|
}();
|
|
286
|
+
|
|
245
287
|
module.exports = ElvWallet;
|