@eluvio/elv-client-js 3.1.94 → 3.1.95

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.
@@ -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,148 +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) {
155
- var signature;
156
- return _regeneratorRuntime.async(function _callee$(_context2) {
157
- while (1) {
158
- switch (_context2.prev = _context2.next) {
159
- case 0:
160
- _context2.next = 2;
161
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(_this2.HttpClient.Request({
162
- method: "POST",
163
- path: UrlJoin("as", "wlt", "sign", "eth", _this2.id),
164
- headers: {
165
- Authorization: "Bearer ".concat(_this2.authToken)
166
- },
167
- body: {
168
- hash: digest
169
- }
170
- })));
171
-
172
- case 2:
173
- signature = _context2.sent;
174
- signature.v = parseInt(signature.v, 16);
175
- signature.recoveryParam = signature.v - 27;
176
- resolve(signature);
177
-
178
- case 6:
179
- case "end":
180
- return _context2.stop();
181
- }
182
- }
183
- });
184
- });
185
- }
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
+ }
186
215
 
187
- _context3.next = 3;
188
- return _regeneratorRuntime.awrap(this.signatureCache[digest]);
216
+ _context3.next = 3;
217
+ return this.signatureCache[digest];
189
218
 
190
- case 3:
191
- return _context3.abrupt("return", _context3.sent);
219
+ case 3:
220
+ return _context3.abrupt("return", _context3.sent);
192
221
 
193
- case 4:
194
- case "end":
195
- return _context3.stop();
222
+ case 4:
223
+ case "end":
224
+ return _context3.stop();
225
+ }
196
226
  }
197
- }
198
- }, null, this);
199
- }
227
+ }, _callee3, this);
228
+ }));
229
+
230
+ function signDigest(_x) {
231
+ return _signDigest.apply(this, arguments);
232
+ }
233
+
234
+ return signDigest;
235
+ }()
200
236
  }, {
201
237
  key: "signMessage",
202
- value: function signMessage(message) {
203
- return _regeneratorRuntime.async(function signMessage$(_context4) {
204
- while (1) {
205
- switch (_context4.prev = _context4.next) {
206
- case 0:
207
- _context4.t0 = Promise;
208
- _context4.t1 = Ethers.utils;
209
- _context4.t2 = "0x";
210
- _context4.next = 5;
211
- return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.hashMessage(message)));
212
-
213
- case 5:
214
- _context4.t3 = _context4.sent;
215
- _context4.t4 = _context4.t2.concat.call(_context4.t2, _context4.t3);
216
- _context4.t5 = _context4.t1.joinSignature.call(_context4.t1, _context4.t4);
217
- return _context4.abrupt("return", _context4.t0.resolve.call(_context4.t0, _context4.t5));
218
-
219
- case 9:
220
- case "end":
221
- 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
+ }
222
260
  }
223
- }
224
- }, null, this);
225
- }
261
+ }, _callee4, this);
262
+ }));
263
+
264
+ function signMessage(_x4) {
265
+ return _signMessage.apply(this, arguments);
266
+ }
267
+
268
+ return signMessage;
269
+ }()
226
270
  }, {
227
271
  key: "sign",
228
- value: function sign(transaction) {
229
- var signature;
230
- return _regeneratorRuntime.async(function sign$(_context5) {
231
- while (1) {
232
- switch (_context5.prev = _context5.next) {
233
- case 0:
234
- _context5.next = 2;
235
- return _regeneratorRuntime.awrap(Ethers.utils.resolveProperties(transaction));
236
-
237
- case 2:
238
- transaction = _context5.sent;
239
- _context5.next = 5;
240
- return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction))));
241
-
242
- case 5:
243
- signature = _context5.sent;
244
- return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
245
-
246
- case 7:
247
- case "end":
248
- 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
+ }
249
295
  }
250
- }
251
- }, null, this);
252
- }
296
+ }, _callee5, this);
297
+ }));
298
+
299
+ function sign(_x5) {
300
+ return _sign.apply(this, arguments);
301
+ }
302
+
303
+ return sign;
304
+ }()
253
305
  }, {
254
306
  key: "sendTransaction",
255
- value: function sendTransaction(transaction) {
256
- var _this3 = this;
257
-
258
- return _regeneratorRuntime.async(function sendTransaction$(_context6) {
259
- while (1) {
260
- switch (_context6.prev = _context6.next) {
261
- case 0:
262
- if (!(transaction.nonce == null)) {
263
- _context6.next = 5;
264
- break;
265
- }
266
-
267
- transaction = Ethers.utils.shallowCopy(transaction);
268
- _context6.next = 4;
269
- return _regeneratorRuntime.awrap(this.provider.getTransactionCount(this.address, "pending"));
270
-
271
- case 4:
272
- transaction.nonce = _context6.sent;
273
-
274
- case 5:
275
- return _context6.abrupt("return", Ethers.utils.populateTransaction(transaction, this.provider, this.address).then(function (tx) {
276
- return _this3.sign(tx).then(function (signedTransaction) {
277
- return _this3.provider.sendTransaction(signedTransaction);
278
- });
279
- }));
280
-
281
- case 6:
282
- case "end":
283
- 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
+ }
284
338
  }
285
- }
286
- }, null, this);
287
- }
339
+ }, _callee6, this);
340
+ }));
341
+
342
+ function sendTransaction(_x6) {
343
+ return _sendTransaction.apply(this, arguments);
344
+ }
345
+
346
+ return sendTransaction;
347
+ }()
288
348
  }, {
289
349
  key: "connect",
290
350
  value: function connect() {}