@eluvio/elv-client-js 3.1.85 → 3.1.89
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 +1 -1
- package/dist/ElvClient-node-min.js +2 -2
- package/dist/src/AuthorizationClient.js +1 -1
- package/dist/src/ElvClient.js +5 -3
- package/dist/src/RemoteSigner.js +78 -51
- package/package-lock.json +140 -114
- package/package.json +4 -5
- package/src/AuthorizationClient.js +1 -1
- package/src/ElvClient.js +4 -2
- package/src/RemoteSigner.js +27 -17
- package/src/UserProfileClient.js +7 -2
- package/src/Utils.js +30 -1
- package/src/client/ContentManagement.js +4 -0
package/dist/src/ElvClient.js
CHANGED
|
@@ -614,24 +614,26 @@ function () {
|
|
|
614
614
|
* @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
|
|
615
615
|
* @param {string=} tenantId - If specified, user will be associated with the tenant
|
|
616
616
|
* @param {Object=} extraData - Additional data to pass to the login API
|
|
617
|
+
* @param {boolean=} unsignedPublicAuth=false - If specified, the client will use an unsigned static token for calls that don't require authorization (reduces remote signature calls)
|
|
617
618
|
*/
|
|
618
619
|
|
|
619
620
|
}, {
|
|
620
621
|
key: "SetRemoteSigner",
|
|
621
622
|
value: function SetRemoteSigner(_ref9) {
|
|
622
|
-
var idToken, authToken, tenantId, extraData, signer;
|
|
623
|
+
var idToken, authToken, tenantId, extraData, unsignedPublicAuth, signer;
|
|
623
624
|
return _regeneratorRuntime.async(function SetRemoteSigner$(_context6) {
|
|
624
625
|
while (1) {
|
|
625
626
|
switch (_context6.prev = _context6.next) {
|
|
626
627
|
case 0:
|
|
627
|
-
idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId, extraData = _ref9.extraData;
|
|
628
|
+
idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId, extraData = _ref9.extraData, unsignedPublicAuth = _ref9.unsignedPublicAuth;
|
|
628
629
|
signer = new RemoteSigner({
|
|
629
630
|
rpcUris: this.authServiceURIs,
|
|
630
631
|
idToken: idToken,
|
|
631
632
|
authToken: authToken,
|
|
632
633
|
tenantId: tenantId,
|
|
633
634
|
provider: this.ethClient.provider,
|
|
634
|
-
extraData: extraData
|
|
635
|
+
extraData: extraData,
|
|
636
|
+
unsignedPublicAuth: unsignedPublicAuth
|
|
635
637
|
});
|
|
636
638
|
_context6.next = 4;
|
|
637
639
|
return _regeneratorRuntime.awrap(signer.Initialize());
|
package/dist/src/RemoteSigner.js
CHANGED
|
@@ -34,12 +34,15 @@ function (_Ethers$Signer) {
|
|
|
34
34
|
tenantId = _ref.tenantId,
|
|
35
35
|
provider = _ref.provider,
|
|
36
36
|
_ref$extraData = _ref.extraData,
|
|
37
|
-
extraData = _ref$extraData === void 0 ? {} : _ref$extraData
|
|
37
|
+
extraData = _ref$extraData === void 0 ? {} : _ref$extraData,
|
|
38
|
+
_ref$unsignedPublicAu = _ref.unsignedPublicAuth,
|
|
39
|
+
unsignedPublicAuth = _ref$unsignedPublicAu === void 0 ? false : _ref$unsignedPublicAu;
|
|
38
40
|
|
|
39
41
|
_classCallCheck(this, RemoteSigner);
|
|
40
42
|
|
|
41
43
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(RemoteSigner).call(this));
|
|
42
44
|
_this.remoteSigner = true;
|
|
45
|
+
_this.unsignedPublicAuth = unsignedPublicAuth;
|
|
43
46
|
_this.HttpClient = new HttpClient({
|
|
44
47
|
uris: rpcUris
|
|
45
48
|
});
|
|
@@ -48,6 +51,7 @@ function (_Ethers$Signer) {
|
|
|
48
51
|
_this.authToken = authToken;
|
|
49
52
|
_this.extraLoginData = extraData || {};
|
|
50
53
|
_this.provider = provider;
|
|
54
|
+
_this.signatureCache = {};
|
|
51
55
|
return _this;
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -140,32 +144,55 @@ function (_Ethers$Signer) {
|
|
|
140
144
|
}, {
|
|
141
145
|
key: "signDigest",
|
|
142
146
|
value: function signDigest(digest) {
|
|
143
|
-
var
|
|
144
|
-
|
|
147
|
+
var _this2 = this;
|
|
148
|
+
|
|
149
|
+
return _regeneratorRuntime.async(function signDigest$(_context3) {
|
|
145
150
|
while (1) {
|
|
146
|
-
switch (
|
|
151
|
+
switch (_context3.prev = _context3.next) {
|
|
147
152
|
case 0:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
+
}
|
|
159
186
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
signature.v = parseInt(signature.v, 16);
|
|
163
|
-
signature.recoveryParam = signature.v - 27;
|
|
164
|
-
return _context2.abrupt("return", signature);
|
|
187
|
+
_context3.next = 3;
|
|
188
|
+
return _regeneratorRuntime.awrap(this.signatureCache[digest]);
|
|
165
189
|
|
|
166
|
-
case
|
|
190
|
+
case 3:
|
|
191
|
+
return _context3.abrupt("return", _context3.sent);
|
|
192
|
+
|
|
193
|
+
case 4:
|
|
167
194
|
case "end":
|
|
168
|
-
return
|
|
195
|
+
return _context3.stop();
|
|
169
196
|
}
|
|
170
197
|
}
|
|
171
198
|
}, null, this);
|
|
@@ -173,25 +200,25 @@ function (_Ethers$Signer) {
|
|
|
173
200
|
}, {
|
|
174
201
|
key: "signMessage",
|
|
175
202
|
value: function signMessage(message) {
|
|
176
|
-
return _regeneratorRuntime.async(function signMessage$(
|
|
203
|
+
return _regeneratorRuntime.async(function signMessage$(_context4) {
|
|
177
204
|
while (1) {
|
|
178
|
-
switch (
|
|
205
|
+
switch (_context4.prev = _context4.next) {
|
|
179
206
|
case 0:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
_context4.t0 = Promise;
|
|
208
|
+
_context4.t1 = Ethers.utils;
|
|
209
|
+
_context4.t2 = "0x";
|
|
210
|
+
_context4.next = 5;
|
|
184
211
|
return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.hashMessage(message)));
|
|
185
212
|
|
|
186
213
|
case 5:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return
|
|
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));
|
|
191
218
|
|
|
192
219
|
case 9:
|
|
193
220
|
case "end":
|
|
194
|
-
return
|
|
221
|
+
return _context4.stop();
|
|
195
222
|
}
|
|
196
223
|
}
|
|
197
224
|
}, null, this);
|
|
@@ -200,25 +227,25 @@ function (_Ethers$Signer) {
|
|
|
200
227
|
key: "sign",
|
|
201
228
|
value: function sign(transaction) {
|
|
202
229
|
var signature;
|
|
203
|
-
return _regeneratorRuntime.async(function sign$(
|
|
230
|
+
return _regeneratorRuntime.async(function sign$(_context5) {
|
|
204
231
|
while (1) {
|
|
205
|
-
switch (
|
|
232
|
+
switch (_context5.prev = _context5.next) {
|
|
206
233
|
case 0:
|
|
207
|
-
|
|
234
|
+
_context5.next = 2;
|
|
208
235
|
return _regeneratorRuntime.awrap(Ethers.utils.resolveProperties(transaction));
|
|
209
236
|
|
|
210
237
|
case 2:
|
|
211
|
-
transaction =
|
|
212
|
-
|
|
238
|
+
transaction = _context5.sent;
|
|
239
|
+
_context5.next = 5;
|
|
213
240
|
return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction))));
|
|
214
241
|
|
|
215
242
|
case 5:
|
|
216
|
-
signature =
|
|
217
|
-
return
|
|
243
|
+
signature = _context5.sent;
|
|
244
|
+
return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
|
|
218
245
|
|
|
219
246
|
case 7:
|
|
220
247
|
case "end":
|
|
221
|
-
return
|
|
248
|
+
return _context5.stop();
|
|
222
249
|
}
|
|
223
250
|
}
|
|
224
251
|
}, null, this);
|
|
@@ -226,34 +253,34 @@ function (_Ethers$Signer) {
|
|
|
226
253
|
}, {
|
|
227
254
|
key: "sendTransaction",
|
|
228
255
|
value: function sendTransaction(transaction) {
|
|
229
|
-
var
|
|
256
|
+
var _this3 = this;
|
|
230
257
|
|
|
231
|
-
return _regeneratorRuntime.async(function sendTransaction$(
|
|
258
|
+
return _regeneratorRuntime.async(function sendTransaction$(_context6) {
|
|
232
259
|
while (1) {
|
|
233
|
-
switch (
|
|
260
|
+
switch (_context6.prev = _context6.next) {
|
|
234
261
|
case 0:
|
|
235
262
|
if (!(transaction.nonce == null)) {
|
|
236
|
-
|
|
263
|
+
_context6.next = 5;
|
|
237
264
|
break;
|
|
238
265
|
}
|
|
239
266
|
|
|
240
267
|
transaction = Ethers.utils.shallowCopy(transaction);
|
|
241
|
-
|
|
268
|
+
_context6.next = 4;
|
|
242
269
|
return _regeneratorRuntime.awrap(this.provider.getTransactionCount(this.address, "pending"));
|
|
243
270
|
|
|
244
271
|
case 4:
|
|
245
|
-
transaction.nonce =
|
|
272
|
+
transaction.nonce = _context6.sent;
|
|
246
273
|
|
|
247
274
|
case 5:
|
|
248
|
-
return
|
|
249
|
-
return
|
|
250
|
-
return
|
|
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);
|
|
251
278
|
});
|
|
252
279
|
}));
|
|
253
280
|
|
|
254
281
|
case 6:
|
|
255
282
|
case "end":
|
|
256
|
-
return
|
|
283
|
+
return _context6.stop();
|
|
257
284
|
}
|
|
258
285
|
}
|
|
259
286
|
}, null, this);
|