@eluvio/elv-client-js 3.2.4 → 3.2.5

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 (46) hide show
  1. package/dist/ElvClient-min.js +15 -11
  2. package/dist/ElvClient-node-min.js +17 -13
  3. package/dist/ElvFrameClient-min.js +12 -8
  4. package/dist/ElvPermissionsClient-min.js +13 -9
  5. package/dist/ElvWalletClient-min.js +58 -0
  6. package/dist/ElvWalletClient-node-min.js +78 -0
  7. package/dist/src/AuthorizationClient.js +2248 -1990
  8. package/dist/src/ContentObjectVerification.js +164 -173
  9. package/dist/src/Crypto.js +376 -324
  10. package/dist/src/ElvClient.js +1185 -1019
  11. package/dist/src/ElvWallet.js +119 -95
  12. package/dist/src/EthClient.js +1040 -896
  13. package/dist/src/FrameClient.js +331 -300
  14. package/dist/src/HttpClient.js +153 -147
  15. package/dist/src/Id.js +1 -3
  16. package/dist/src/PermissionsClient.js +1294 -1168
  17. package/dist/src/RemoteSigner.js +263 -211
  18. package/dist/src/UserProfileClient.js +1164 -1023
  19. package/dist/src/Utils.js +229 -184
  20. package/dist/src/client/ABRPublishing.js +895 -858
  21. package/dist/src/client/AccessGroups.js +1102 -959
  22. package/dist/src/client/ContentAccess.js +3724 -3431
  23. package/dist/src/client/ContentManagement.js +2252 -2068
  24. package/dist/src/client/Contracts.js +647 -563
  25. package/dist/src/client/Files.js +1886 -1757
  26. package/dist/src/client/NFT.js +126 -112
  27. package/dist/src/client/NTP.js +478 -422
  28. package/dist/src/index.js +11 -0
  29. package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
  30. package/dist/src/marketplaceClient/Configuration.js +29 -0
  31. package/dist/src/marketplaceClient/Utils.js +304 -0
  32. package/dist/src/marketplaceClient/index.js +1553 -0
  33. package/dist/src/walletClient/ClientMethods.js +1978 -0
  34. package/dist/src/walletClient/Configuration.js +29 -0
  35. package/dist/src/walletClient/Utils.js +304 -0
  36. package/dist/src/walletClient/index.js +1571 -0
  37. package/package.json +8 -4
  38. package/src/ElvClient.js +4 -1
  39. package/src/Utils.js +22 -4
  40. package/src/index.js +7 -0
  41. package/src/walletClient/ClientMethods.js +1048 -0
  42. package/src/walletClient/Configuration.js +40 -0
  43. package/src/walletClient/README.md +185 -0
  44. package/src/walletClient/Utils.js +234 -0
  45. package/src/walletClient/index.js +884 -0
  46. package/testScripts/TestMarketplaceClient.js +25 -0
@@ -1,14 +1,20 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
 
3
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
+
3
5
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
4
6
 
5
7
  var _createClass = require("@babel/runtime/helpers/createClass");
6
8
 
9
+ var _inherits = require("@babel/runtime/helpers/inherits");
10
+
7
11
  var _possibleConstructorReturn = require("@babel/runtime/helpers/possibleConstructorReturn");
8
12
 
9
13
  var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf");
10
14
 
11
- var _inherits = require("@babel/runtime/helpers/inherits");
15
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
+
17
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
18
 
13
19
  var Ethers = require("ethers");
14
20
 
@@ -18,13 +24,13 @@ var HttpClient = require("./HttpClient");
18
24
 
19
25
  var UrlJoin = require("url-join");
20
26
 
21
- var RemoteSigner =
22
- /*#__PURE__*/
23
- function (_Ethers$Signer) {
27
+ var RemoteSigner = /*#__PURE__*/function (_Ethers$Signer) {
24
28
  "use strict";
25
29
 
26
30
  _inherits(RemoteSigner, _Ethers$Signer);
27
31
 
32
+ var _super = _createSuper(RemoteSigner);
33
+
28
34
  function RemoteSigner(_ref) {
29
35
  var _this;
30
36
 
@@ -40,7 +46,7 @@ function (_Ethers$Signer) {
40
46
 
41
47
  _classCallCheck(this, RemoteSigner);
42
48
 
43
- _this = _possibleConstructorReturn(this, _getPrototypeOf(RemoteSigner).call(this));
49
+ _this = _super.call(this);
44
50
  _this.remoteSigner = true;
45
51
  _this.unsignedPublicAuth = unsignedPublicAuth;
46
52
  _this.HttpClient = new HttpClient({
@@ -57,78 +63,86 @@ function (_Ethers$Signer) {
57
63
 
58
64
  _createClass(RemoteSigner, [{
59
65
  key: "Initialize",
60
- value: function Initialize() {
61
- var _ref2, addr, eth, token, keys, address;
62
-
63
- return _regeneratorRuntime.async(function Initialize$(_context) {
64
- while (1) {
65
- switch (_context.prev = _context.next) {
66
- case 0:
67
- if (this.authToken) {
68
- _context.next = 10;
69
- break;
70
- }
71
-
72
- _context.next = 3;
73
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.HttpClient.Request({
74
- path: UrlJoin("as", "wlt", "login", "jwt"),
75
- method: "POST",
76
- body: this.tenantId ? {
77
- tid: this.tenantId,
78
- ext: this.extraLoginData || {}
79
- } : {
80
- ext: this.extraLoginData || {}
81
- },
82
- headers: {
83
- Authorization: "Bearer ".concat(this.idToken)
66
+ value: function () {
67
+ var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
68
+ var _yield$Utils$Response, addr, eth, token, keys, address;
69
+
70
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
71
+ while (1) {
72
+ switch (_context.prev = _context.next) {
73
+ case 0:
74
+ if (this.authToken) {
75
+ _context.next = 10;
76
+ break;
84
77
  }
85
- })));
86
-
87
- case 3:
88
- _ref2 = _context.sent;
89
- addr = _ref2.addr;
90
- eth = _ref2.eth;
91
- token = _ref2.token;
92
- this.authToken = token;
93
- this.address = Utils.FormatAddress(addr);
94
- this.id = eth;
95
-
96
- case 10:
97
- if (this.address) {
98
- _context.next = 16;
99
- break;
100
- }
101
-
102
- _context.next = 13;
103
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.HttpClient.Request({
104
- method: "GET",
105
- path: UrlJoin("as", "wlt", "keys"),
106
- headers: {
107
- Authorization: "Bearer ".concat(this.authToken)
108
- }
109
- })));
110
78
 
111
- case 13:
112
- keys = _context.sent;
113
- address = keys.eth[0];
79
+ _context.next = 3;
80
+ return Utils.ResponseToJson(this.HttpClient.Request({
81
+ path: UrlJoin("as", "wlt", "login", "jwt"),
82
+ method: "POST",
83
+ body: this.tenantId ? {
84
+ tid: this.tenantId,
85
+ ext: this.extraLoginData || {}
86
+ } : {
87
+ ext: this.extraLoginData || {}
88
+ },
89
+ headers: {
90
+ Authorization: "Bearer ".concat(this.idToken)
91
+ }
92
+ }));
93
+
94
+ case 3:
95
+ _yield$Utils$Response = _context.sent;
96
+ addr = _yield$Utils$Response.addr;
97
+ eth = _yield$Utils$Response.eth;
98
+ token = _yield$Utils$Response.token;
99
+ this.authToken = token;
100
+ this.address = Utils.FormatAddress(addr);
101
+ this.id = eth;
102
+
103
+ case 10:
104
+ if (this.address) {
105
+ _context.next = 16;
106
+ break;
107
+ }
114
108
 
115
- if (address && address.startsWith("0x")) {
116
- this.address = address;
117
- } else {
118
- this.address = Utils.HashToAddress(keys.eth[0]);
119
- }
109
+ _context.next = 13;
110
+ return Utils.ResponseToJson(this.HttpClient.Request({
111
+ method: "GET",
112
+ path: UrlJoin("as", "wlt", "keys"),
113
+ headers: {
114
+ Authorization: "Bearer ".concat(this.authToken)
115
+ }
116
+ }));
117
+
118
+ case 13:
119
+ keys = _context.sent;
120
+ address = keys.eth[0];
121
+
122
+ if (address && address.startsWith("0x")) {
123
+ this.address = address;
124
+ } else {
125
+ this.address = Utils.HashToAddress(keys.eth[0]);
126
+ }
120
127
 
121
- case 16:
122
- this.id = this.address ? "ikms".concat(Utils.AddressToHash(this.address)) : undefined;
123
- this.signer = this.provider.getSigner(this.address);
128
+ case 16:
129
+ this.id = this.address ? "ikms".concat(Utils.AddressToHash(this.address)) : undefined;
130
+ this.signer = this.provider.getSigner(this.address);
124
131
 
125
- case 18:
126
- case "end":
127
- return _context.stop();
132
+ case 18:
133
+ case "end":
134
+ return _context.stop();
135
+ }
128
136
  }
129
- }
130
- }, null, this);
131
- } // Overrides
137
+ }, _callee, this);
138
+ }));
139
+
140
+ function Initialize() {
141
+ return _Initialize.apply(this, arguments);
142
+ }
143
+
144
+ return Initialize;
145
+ }() // Overrides
132
146
 
133
147
  }, {
134
148
  key: "getAddress",
@@ -143,156 +157,194 @@ function (_Ethers$Signer) {
143
157
 
144
158
  }, {
145
159
  key: "signDigest",
146
- value: function signDigest(digest) {
147
- var _this2 = this;
148
-
149
- return _regeneratorRuntime.async(function signDigest$(_context3) {
150
- while (1) {
151
- switch (_context3.prev = _context3.next) {
152
- case 0:
153
- if (!this.signatureCache[digest]) {
154
- this.signatureCache[digest] = new Promise(function _callee(resolve, reject) {
155
- var signature;
156
- return _regeneratorRuntime.async(function _callee$(_context2) {
157
- while (1) {
158
- switch (_context2.prev = _context2.next) {
159
- case 0:
160
- _context2.prev = 0;
161
- _context2.next = 3;
162
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(_this2.HttpClient.Request({
163
- method: "POST",
164
- path: UrlJoin("as", "wlt", "sign", "eth", _this2.id),
165
- headers: {
166
- Authorization: "Bearer ".concat(_this2.authToken)
167
- },
168
- body: {
169
- hash: digest
170
- }
171
- })));
172
-
173
- case 3:
174
- signature = _context2.sent;
175
- signature.v = parseInt(signature.v, 16);
176
- signature.recoveryParam = signature.v - 27;
177
- resolve(signature);
178
- _context2.next = 12;
179
- break;
180
-
181
- case 9:
182
- _context2.prev = 9;
183
- _context2.t0 = _context2["catch"](0);
184
- reject(_context2.t0);
185
-
186
- case 12:
187
- case "end":
188
- return _context2.stop();
189
- }
190
- }
191
- }, null, null, [[0, 9]]);
192
- });
193
- }
194
-
195
- _context3.next = 3;
196
- return _regeneratorRuntime.awrap(this.signatureCache[digest]);
197
-
198
- case 3:
199
- return _context3.abrupt("return", _context3.sent);
200
-
201
- case 4:
202
- case "end":
203
- return _context3.stop();
160
+ value: function () {
161
+ var _signDigest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(digest) {
162
+ var _this2 = this;
163
+
164
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
165
+ while (1) {
166
+ switch (_context3.prev = _context3.next) {
167
+ case 0:
168
+ if (!this.signatureCache[digest]) {
169
+ this.signatureCache[digest] = new Promise( /*#__PURE__*/function () {
170
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
171
+ var signature;
172
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
173
+ while (1) {
174
+ switch (_context2.prev = _context2.next) {
175
+ case 0:
176
+ _context2.prev = 0;
177
+ _context2.next = 3;
178
+ return Utils.ResponseToJson(_this2.HttpClient.Request({
179
+ method: "POST",
180
+ path: UrlJoin("as", "wlt", "sign", "eth", _this2.id),
181
+ headers: {
182
+ Authorization: "Bearer ".concat(_this2.authToken)
183
+ },
184
+ body: {
185
+ hash: digest
186
+ }
187
+ }));
188
+
189
+ case 3:
190
+ signature = _context2.sent;
191
+ signature.v = parseInt(signature.v, 16);
192
+ signature.recoveryParam = signature.v - 27;
193
+ resolve(signature);
194
+ _context2.next = 12;
195
+ break;
196
+
197
+ case 9:
198
+ _context2.prev = 9;
199
+ _context2.t0 = _context2["catch"](0);
200
+ reject(_context2.t0);
201
+
202
+ case 12:
203
+ case "end":
204
+ return _context2.stop();
205
+ }
206
+ }
207
+ }, _callee2, null, [[0, 9]]);
208
+ }));
209
+
210
+ return function (_x2, _x3) {
211
+ return _ref2.apply(this, arguments);
212
+ };
213
+ }());
214
+ }
215
+
216
+ _context3.next = 3;
217
+ return this.signatureCache[digest];
218
+
219
+ case 3:
220
+ return _context3.abrupt("return", _context3.sent);
221
+
222
+ case 4:
223
+ case "end":
224
+ return _context3.stop();
225
+ }
204
226
  }
205
- }
206
- }, null, this);
207
- }
227
+ }, _callee3, this);
228
+ }));
229
+
230
+ function signDigest(_x) {
231
+ return _signDigest.apply(this, arguments);
232
+ }
233
+
234
+ return signDigest;
235
+ }()
208
236
  }, {
209
237
  key: "signMessage",
210
- value: function signMessage(message) {
211
- return _regeneratorRuntime.async(function signMessage$(_context4) {
212
- while (1) {
213
- switch (_context4.prev = _context4.next) {
214
- case 0:
215
- _context4.t0 = Promise;
216
- _context4.t1 = Ethers.utils;
217
- _context4.t2 = "0x";
218
- _context4.next = 5;
219
- return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.hashMessage(message)));
220
-
221
- case 5:
222
- _context4.t3 = _context4.sent;
223
- _context4.t4 = _context4.t2.concat.call(_context4.t2, _context4.t3);
224
- _context4.t5 = _context4.t1.joinSignature.call(_context4.t1, _context4.t4);
225
- return _context4.abrupt("return", _context4.t0.resolve.call(_context4.t0, _context4.t5));
226
-
227
- case 9:
228
- case "end":
229
- return _context4.stop();
238
+ value: function () {
239
+ var _signMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(message) {
240
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
241
+ while (1) {
242
+ switch (_context4.prev = _context4.next) {
243
+ case 0:
244
+ _context4.t0 = Promise;
245
+ _context4.t1 = Ethers.utils;
246
+ _context4.t2 = "0x";
247
+ _context4.next = 5;
248
+ return this.signDigest(Ethers.utils.hashMessage(message));
249
+
250
+ case 5:
251
+ _context4.t3 = _context4.sent;
252
+ _context4.t4 = _context4.t2.concat.call(_context4.t2, _context4.t3);
253
+ _context4.t5 = _context4.t1.joinSignature.call(_context4.t1, _context4.t4);
254
+ return _context4.abrupt("return", _context4.t0.resolve.call(_context4.t0, _context4.t5));
255
+
256
+ case 9:
257
+ case "end":
258
+ return _context4.stop();
259
+ }
230
260
  }
231
- }
232
- }, null, this);
233
- }
261
+ }, _callee4, this);
262
+ }));
263
+
264
+ function signMessage(_x4) {
265
+ return _signMessage.apply(this, arguments);
266
+ }
267
+
268
+ return signMessage;
269
+ }()
234
270
  }, {
235
271
  key: "sign",
236
- value: function sign(transaction) {
237
- var signature;
238
- return _regeneratorRuntime.async(function sign$(_context5) {
239
- while (1) {
240
- switch (_context5.prev = _context5.next) {
241
- case 0:
242
- _context5.next = 2;
243
- return _regeneratorRuntime.awrap(Ethers.utils.resolveProperties(transaction));
244
-
245
- case 2:
246
- transaction = _context5.sent;
247
- _context5.next = 5;
248
- return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction))));
249
-
250
- case 5:
251
- signature = _context5.sent;
252
- return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
253
-
254
- case 7:
255
- case "end":
256
- return _context5.stop();
272
+ value: function () {
273
+ var _sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(transaction) {
274
+ var signature;
275
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
276
+ while (1) {
277
+ switch (_context5.prev = _context5.next) {
278
+ case 0:
279
+ _context5.next = 2;
280
+ return Ethers.utils.resolveProperties(transaction);
281
+
282
+ case 2:
283
+ transaction = _context5.sent;
284
+ _context5.next = 5;
285
+ return this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction)));
286
+
287
+ case 5:
288
+ signature = _context5.sent;
289
+ return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
290
+
291
+ case 7:
292
+ case "end":
293
+ return _context5.stop();
294
+ }
257
295
  }
258
- }
259
- }, null, this);
260
- }
296
+ }, _callee5, this);
297
+ }));
298
+
299
+ function sign(_x5) {
300
+ return _sign.apply(this, arguments);
301
+ }
302
+
303
+ return sign;
304
+ }()
261
305
  }, {
262
306
  key: "sendTransaction",
263
- value: function sendTransaction(transaction) {
264
- var _this3 = this;
265
-
266
- return _regeneratorRuntime.async(function sendTransaction$(_context6) {
267
- while (1) {
268
- switch (_context6.prev = _context6.next) {
269
- case 0:
270
- if (!(transaction.nonce == null)) {
271
- _context6.next = 5;
272
- break;
273
- }
274
-
275
- transaction = Ethers.utils.shallowCopy(transaction);
276
- _context6.next = 4;
277
- return _regeneratorRuntime.awrap(this.provider.getTransactionCount(this.address, "pending"));
278
-
279
- case 4:
280
- transaction.nonce = _context6.sent;
281
-
282
- case 5:
283
- return _context6.abrupt("return", Ethers.utils.populateTransaction(transaction, this.provider, this.address).then(function (tx) {
284
- return _this3.sign(tx).then(function (signedTransaction) {
285
- return _this3.provider.sendTransaction(signedTransaction);
286
- });
287
- }));
288
-
289
- case 6:
290
- case "end":
291
- return _context6.stop();
307
+ value: function () {
308
+ var _sendTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(transaction) {
309
+ var _this3 = this;
310
+
311
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
312
+ while (1) {
313
+ switch (_context6.prev = _context6.next) {
314
+ case 0:
315
+ if (!(transaction.nonce == null)) {
316
+ _context6.next = 5;
317
+ break;
318
+ }
319
+
320
+ transaction = Ethers.utils.shallowCopy(transaction);
321
+ _context6.next = 4;
322
+ return this.provider.getTransactionCount(this.address, "pending");
323
+
324
+ case 4:
325
+ transaction.nonce = _context6.sent;
326
+
327
+ case 5:
328
+ return _context6.abrupt("return", Ethers.utils.populateTransaction(transaction, this.provider, this.address).then(function (tx) {
329
+ return _this3.sign(tx).then(function (signedTransaction) {
330
+ return _this3.provider.sendTransaction(signedTransaction);
331
+ });
332
+ }));
333
+
334
+ case 6:
335
+ case "end":
336
+ return _context6.stop();
337
+ }
292
338
  }
293
- }
294
- }, null, this);
295
- }
339
+ }, _callee6, this);
340
+ }));
341
+
342
+ function sendTransaction(_x6) {
343
+ return _sendTransaction.apply(this, arguments);
344
+ }
345
+
346
+ return sendTransaction;
347
+ }()
296
348
  }, {
297
349
  key: "connect",
298
350
  value: function connect() {}