@eluvio/elv-client-js 4.0.10 → 4.0.11

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 (40) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +9 -10
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2070 -1550
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +319 -224
  10. package/dist/src/ElvClient.js +1114 -822
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +299 -159
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4196 -3323
  25. package/dist/src/client/ContentManagement.js +2288 -1814
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1490
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1763 -1368
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +122 -76
  36. package/dist/src/walletClient/index.js +1496 -1171
  37. package/package.json +1 -1
  38. package/src/AuthorizationClient.js +5 -5
  39. package/src/client/Files.js +1 -1
  40. package/testScripts/CreateMezMonolithic.js +0 -779
@@ -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
- mnemonic = _ref.mnemonic;
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) switch (_context.prev = _context.next) {
72
- case 0:
73
- accountName = _ref2.accountName, encryptedPrivateKey = _ref2.encryptedPrivateKey, password = _ref2.password;
74
- if (_typeof(encryptedPrivateKey) === "object") {
75
- encryptedPrivateKey = JSON.stringify(encryptedPrivateKey);
76
- }
77
- _context.next = 4;
78
- return Ethers.Wallet.fromEncryptedJson(encryptedPrivateKey, password);
79
- case 4:
80
- signer = _context.sent;
81
- return _context.abrupt("return", this.AddAccount({
82
- accountName: accountName,
83
- privateKey: signer.privateKey
84
- }));
85
- case 6:
86
- case "end":
87
- return _context.stop();
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
- privateKey = _ref3.privateKey;
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) switch (_context2.prev = _context2.next) {
141
- case 0:
142
- accountName = _ref4.accountName, signer = _ref4.signer;
143
- accountSigner = signer || this.GetAccount({
144
- accountName: accountName
145
- });
146
- if (accountSigner) {
147
- _context2.next = 4;
148
- break;
149
- }
150
- throw Error("Unknown account: " + accountName);
151
- case 4:
152
- _context2.t0 = Ethers.utils;
153
- _context2.next = 7;
154
- return accountSigner.getBalance();
155
- case 7:
156
- _context2.t1 = _context2.sent;
157
- return _context2.abrupt("return", _context2.t0.formatEther.call(_context2.t0, _context2.t1));
158
- case 9:
159
- case "end":
160
- return _context2.stop();
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) switch (_context3.prev = _context3.next) {
190
- case 0:
191
- accountName = _ref5.accountName, signer = _ref5.signer, password = _ref5.password, options = _ref5.options;
192
- accountSigner = signer || this.GetAccount({
193
- accountName: accountName
194
- });
195
- if (accountSigner) {
196
- _context3.next = 4;
197
- break;
198
- }
199
- throw Error("Unknown account: " + accountName);
200
- case 4:
201
- _context3.next = 6;
202
- return accountSigner.encrypt(password, options);
203
- case 6:
204
- return _context3.abrupt("return", _context3.sent);
205
- case 7:
206
- case "end":
207
- return _context3.stop();
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;