@eluvio/elv-client-js 4.0.5 → 4.0.6
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 +12 -11
- package/dist/ElvClient-node-min.js +12 -17
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +11 -10
- package/dist/ElvWalletClient-node-min.js +12 -17
- package/dist/src/AuthorizationClient.js +1556 -2077
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +225 -322
- package/dist/src/ElvClient.js +823 -1117
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +160 -302
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3263 -4132
- package/dist/src/client/ContentManagement.js +1811 -2283
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1505 -1845
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1348 -1735
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1168 -1493
- package/package.json +2 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/testScripts/Test.js +0 -1
- package/utilities/NFTIngest.js +527 -0
- package/utilities/lib/concerns/LocalFile.js +2 -1
package/dist/src/ElvClient.js
CHANGED
|
@@ -1,66 +1,42 @@
|
|
|
1
1
|
var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
|
|
2
|
-
|
|
3
2
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
3
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
6
|
-
|
|
7
4
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
8
|
-
|
|
9
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
10
|
-
|
|
11
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
12
|
-
|
|
13
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
14
|
-
|
|
15
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
|
-
if (typeof Buffer === "undefined") {
|
|
20
|
-
Buffer = require("buffer/").Buffer;
|
|
21
|
-
}
|
|
22
|
-
|
|
10
|
+
require("buffer");
|
|
23
11
|
var URI = require("urijs");
|
|
24
|
-
|
|
25
12
|
var Ethers = require("ethers");
|
|
26
|
-
|
|
27
13
|
var AuthorizationClient = require("./AuthorizationClient");
|
|
28
|
-
|
|
29
14
|
var ElvWallet = require("./ElvWallet");
|
|
30
|
-
|
|
31
15
|
var EthClient = require("./EthClient");
|
|
32
|
-
|
|
33
16
|
var UserProfileClient = require("./UserProfileClient");
|
|
34
|
-
|
|
35
17
|
var HttpClient = require("./HttpClient");
|
|
18
|
+
var RemoteSigner = require("./RemoteSigner");
|
|
36
19
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
// const ContentObjectVerification = require("./ContentObjectVerification");
|
|
40
21
|
var Utils = require("./Utils");
|
|
41
|
-
|
|
42
22
|
var Crypto = require("./Crypto");
|
|
43
|
-
|
|
44
23
|
var _require = require("./LogMessage"),
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
LogMessage = _require.LogMessage;
|
|
47
25
|
var Pako = require("pako");
|
|
48
|
-
|
|
49
26
|
var _require2 = require("./Validation"),
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
ValidatePresence = _require2.ValidatePresence;
|
|
52
28
|
var networks = {
|
|
53
29
|
"main": "https://main.net955305.contentfabric.io",
|
|
54
30
|
"demo": "https://demov3.net955210.contentfabric.io",
|
|
55
31
|
"demov3": "https://demov3.net955210.contentfabric.io",
|
|
56
32
|
"test": "https://test.net955203.contentfabric.io"
|
|
57
33
|
};
|
|
58
|
-
|
|
59
34
|
if (Utils.Platform() === Utils.PLATFORM_NODE) {
|
|
60
35
|
// Define Response in node
|
|
61
36
|
// eslint-disable-next-line no-global-assign
|
|
62
37
|
global.Response = require("node-fetch").Response;
|
|
63
38
|
}
|
|
39
|
+
|
|
64
40
|
/**
|
|
65
41
|
* See the Modules section on the sidebar for details about methods related to interacting with the Fabric.
|
|
66
42
|
*
|
|
@@ -68,8 +44,6 @@ if (Utils.Platform() === Utils.PLATFORM_NODE) {
|
|
|
68
44
|
*
|
|
69
45
|
* For information about the Eluvio Wallet Client, go <a href="wallet-client/index.html">here</a>.
|
|
70
46
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
47
|
var ElvClient = /*#__PURE__*/function () {
|
|
74
48
|
"use strict";
|
|
75
49
|
|
|
@@ -103,28 +77,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
103
77
|
*/
|
|
104
78
|
function ElvClient(_ref) {
|
|
105
79
|
var contentSpaceId = _ref.contentSpaceId,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
80
|
+
networkId = _ref.networkId,
|
|
81
|
+
networkName = _ref.networkName,
|
|
82
|
+
fabricVersion = _ref.fabricVersion,
|
|
83
|
+
fabricURIs = _ref.fabricURIs,
|
|
84
|
+
ethereumURIs = _ref.ethereumURIs,
|
|
85
|
+
authServiceURIs = _ref.authServiceURIs,
|
|
86
|
+
searchURIs = _ref.searchURIs,
|
|
87
|
+
_ref$ethereumContract = _ref.ethereumContractTimeout,
|
|
88
|
+
ethereumContractTimeout = _ref$ethereumContract === void 0 ? 10 : _ref$ethereumContract,
|
|
89
|
+
trustAuthorityId = _ref.trustAuthorityId,
|
|
90
|
+
staticToken = _ref.staticToken,
|
|
91
|
+
_ref$noCache = _ref.noCache,
|
|
92
|
+
noCache = _ref$noCache === void 0 ? false : _ref$noCache,
|
|
93
|
+
_ref$noAuth = _ref.noAuth,
|
|
94
|
+
noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth,
|
|
95
|
+
_ref$assumeV = _ref.assumeV3,
|
|
96
|
+
assumeV3 = _ref$assumeV === void 0 ? false : _ref$assumeV,
|
|
97
|
+
_ref$service = _ref.service,
|
|
98
|
+
service = _ref$service === void 0 ? "default" : _ref$service;
|
|
126
99
|
_classCallCheck(this, ElvClient);
|
|
127
|
-
|
|
128
100
|
this.utils = Utils;
|
|
129
101
|
this.contentSpaceId = contentSpaceId;
|
|
130
102
|
this.contentSpaceAddress = this.utils.HashToAddress(contentSpaceId);
|
|
@@ -142,17 +114,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
142
114
|
this.noCache = noCache;
|
|
143
115
|
this.noAuth = noAuth;
|
|
144
116
|
this.assumeV3 = assumeV3;
|
|
145
|
-
|
|
146
117
|
if (!["search", "default"].includes(service)) {
|
|
147
118
|
throw Error("Invalid service: ".concat(service));
|
|
148
119
|
}
|
|
149
|
-
|
|
150
120
|
this.service = service;
|
|
151
121
|
this.debug = false;
|
|
152
122
|
this.InitializeClients({
|
|
153
123
|
staticToken: staticToken
|
|
154
124
|
});
|
|
155
125
|
}
|
|
126
|
+
|
|
156
127
|
/**
|
|
157
128
|
* Retrieve content space info and preferred fabric and blockchain URLs from the fabric
|
|
158
129
|
*
|
|
@@ -165,14 +136,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
165
136
|
*
|
|
166
137
|
* @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
|
|
167
138
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
139
|
_createClass(ElvClient, [{
|
|
171
140
|
key: "Log",
|
|
172
141
|
value: function Log(message) {
|
|
173
142
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
174
143
|
LogMessage(this, message, error);
|
|
175
144
|
}
|
|
145
|
+
|
|
176
146
|
/**
|
|
177
147
|
* Enable or disable verbose logging
|
|
178
148
|
*
|
|
@@ -184,12 +154,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
184
154
|
* - error: custom error() function
|
|
185
155
|
* - (custom functions must accept same arguments as console.log/console.error)
|
|
186
156
|
*/
|
|
187
|
-
|
|
188
157
|
}, {
|
|
189
158
|
key: "ToggleLogging",
|
|
190
159
|
value: function ToggleLogging(enable) {
|
|
191
160
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
192
|
-
|
|
193
161
|
// define func with closure to pass to forEach
|
|
194
162
|
var setDebug = function setDebug(reporter) {
|
|
195
163
|
if (reporter) {
|
|
@@ -197,9 +165,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
197
165
|
reporter.debugOptions = options;
|
|
198
166
|
}
|
|
199
167
|
};
|
|
200
|
-
|
|
201
168
|
[this, this.authClient, this.ethClient, this.HttpClient, this.userProfileClient].forEach(setDebug);
|
|
202
|
-
|
|
203
169
|
if (enable) {
|
|
204
170
|
this.Log("Debug Logging Enabled:\n Content Space: ".concat(this.contentSpaceId, "\n Fabric URLs: [\n\t\t").concat(this.fabricURIs.join(", \n\t\t"), "\n\t]\n Ethereum URLs: [\n\t\t").concat(this.ethereumURIs.join(", \n\t\t"), "\n\t]\n Auth Service URLs: [\n\t\t").concat(this.authServiceURIs.join(", \n\t\t"), "\n\t]\n "));
|
|
205
171
|
}
|
|
@@ -212,59 +178,48 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
212
178
|
return typeof klass[method] === "function";
|
|
213
179
|
}).forEach(function (methodName) {
|
|
214
180
|
var originalMethod = klass[methodName].bind(klass);
|
|
215
|
-
|
|
216
181
|
if (originalMethod.constructor.name === "AsyncFunction") {
|
|
217
182
|
klass[methodName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
218
183
|
var start,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
184
|
+
_len,
|
|
185
|
+
args,
|
|
186
|
+
_key,
|
|
187
|
+
result,
|
|
188
|
+
_args = arguments;
|
|
225
189
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
226
|
-
while (1) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return _context.abrupt("return", result);
|
|
243
|
-
|
|
244
|
-
case 7:
|
|
245
|
-
case "end":
|
|
246
|
-
return _context.stop();
|
|
247
|
-
}
|
|
190
|
+
while (1) switch (_context.prev = _context.next) {
|
|
191
|
+
case 0:
|
|
192
|
+
start = Date.now();
|
|
193
|
+
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
194
|
+
args[_key] = _args[_key];
|
|
195
|
+
}
|
|
196
|
+
_context.next = 4;
|
|
197
|
+
return originalMethod.apply(void 0, args);
|
|
198
|
+
case 4:
|
|
199
|
+
result = _context.sent;
|
|
200
|
+
// eslint-disable-next-line no-console
|
|
201
|
+
console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
|
|
202
|
+
return _context.abrupt("return", result);
|
|
203
|
+
case 7:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context.stop();
|
|
248
206
|
}
|
|
249
207
|
}, _callee);
|
|
250
208
|
}));
|
|
251
209
|
} else {
|
|
252
210
|
klass[methodName] = function () {
|
|
253
211
|
var start = Date.now();
|
|
254
|
-
|
|
255
212
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
256
213
|
args[_key2] = arguments[_key2];
|
|
257
214
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
215
|
+
var result = originalMethod.apply(void 0, args);
|
|
216
|
+
// eslint-disable-next-line no-console
|
|
261
217
|
console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
|
|
262
218
|
return result;
|
|
263
219
|
};
|
|
264
220
|
}
|
|
265
221
|
});
|
|
266
222
|
};
|
|
267
|
-
|
|
268
223
|
MethodLogger(this);
|
|
269
224
|
}
|
|
270
225
|
}, {
|
|
@@ -272,85 +227,78 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
272
227
|
value: function () {
|
|
273
228
|
var _InitializeClients = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
274
229
|
var _ref3,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
230
|
+
staticToken,
|
|
231
|
+
uris,
|
|
232
|
+
wallet,
|
|
233
|
+
signer,
|
|
234
|
+
_args2 = arguments;
|
|
281
235
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
282
|
-
while (1) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
236
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
237
|
+
case 0:
|
|
238
|
+
_ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
|
|
239
|
+
// Cached info
|
|
240
|
+
this.contentTypes = {};
|
|
241
|
+
this.encryptionConks = {};
|
|
242
|
+
this.stateChannelAccess = {};
|
|
243
|
+
this.objectTenantIds = {};
|
|
244
|
+
this.objectLibraryIds = {};
|
|
245
|
+
this.objectImageUrls = {};
|
|
246
|
+
this.visibilityInfo = {};
|
|
247
|
+
this.inaccessibleLibraries = {};
|
|
248
|
+
uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
|
|
249
|
+
this.HttpClient = new HttpClient({
|
|
250
|
+
uris: uris,
|
|
251
|
+
debug: this.debug
|
|
252
|
+
});
|
|
253
|
+
this.AuthHttpClient = new HttpClient({
|
|
254
|
+
uris: this.authServiceURIs,
|
|
255
|
+
debug: this.debug
|
|
256
|
+
});
|
|
257
|
+
this.ethClient = new EthClient({
|
|
258
|
+
client: this,
|
|
259
|
+
uris: this.ethereumURIs,
|
|
260
|
+
networkId: this.networkId,
|
|
261
|
+
debug: this.debug,
|
|
262
|
+
timeout: this.ethereumContractTimeout
|
|
263
|
+
});
|
|
264
|
+
if (!this.signer) {
|
|
265
|
+
wallet = this.GenerateWallet();
|
|
266
|
+
signer = wallet.AddAccountFromMnemonic({
|
|
267
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
299
268
|
});
|
|
300
|
-
this.
|
|
301
|
-
|
|
302
|
-
|
|
269
|
+
this.SetSigner({
|
|
270
|
+
signer: signer,
|
|
271
|
+
reset: false
|
|
303
272
|
});
|
|
304
|
-
this.
|
|
305
|
-
|
|
306
|
-
uris: this.ethereumURIs,
|
|
307
|
-
networkId: this.networkId,
|
|
308
|
-
debug: this.debug,
|
|
309
|
-
timeout: this.ethereumContractTimeout
|
|
273
|
+
this.SetStaticToken({
|
|
274
|
+
token: staticToken
|
|
310
275
|
});
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
noAuth: this.noAuth,
|
|
332
|
-
debug: this.debug
|
|
333
|
-
});
|
|
334
|
-
this.userProfileClient = new UserProfileClient({
|
|
335
|
-
client: this,
|
|
336
|
-
debug: this.debug
|
|
337
|
-
}); // Initialize crypto wasm
|
|
338
|
-
|
|
339
|
-
this.Crypto = Crypto;
|
|
340
|
-
this.Crypto.ElvCrypto();
|
|
341
|
-
|
|
342
|
-
case 18:
|
|
343
|
-
case "end":
|
|
344
|
-
return _context2.stop();
|
|
345
|
-
}
|
|
276
|
+
}
|
|
277
|
+
this.authClient = new AuthorizationClient({
|
|
278
|
+
client: this,
|
|
279
|
+
contentSpaceId: this.contentSpaceId,
|
|
280
|
+
signer: this.signer,
|
|
281
|
+
noCache: this.noCache,
|
|
282
|
+
noAuth: this.noAuth,
|
|
283
|
+
debug: this.debug
|
|
284
|
+
});
|
|
285
|
+
this.userProfileClient = new UserProfileClient({
|
|
286
|
+
client: this,
|
|
287
|
+
debug: this.debug
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// Initialize crypto wasm
|
|
291
|
+
this.Crypto = Crypto;
|
|
292
|
+
this.Crypto.ElvCrypto();
|
|
293
|
+
case 18:
|
|
294
|
+
case "end":
|
|
295
|
+
return _context2.stop();
|
|
346
296
|
}
|
|
347
297
|
}, _callee2, this);
|
|
348
298
|
}));
|
|
349
|
-
|
|
350
299
|
function InitializeClients() {
|
|
351
300
|
return _InitializeClients.apply(this, arguments);
|
|
352
301
|
}
|
|
353
|
-
|
|
354
302
|
return InitializeClients;
|
|
355
303
|
}()
|
|
356
304
|
}, {
|
|
@@ -364,6 +312,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
364
312
|
this.noAuth = !auth;
|
|
365
313
|
this.authClient.noAuth = !auth;
|
|
366
314
|
}
|
|
315
|
+
|
|
367
316
|
/**
|
|
368
317
|
* Update fabric URLs to prefer the specified region.
|
|
369
318
|
*
|
|
@@ -376,65 +325,54 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
376
325
|
*
|
|
377
326
|
* @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
|
|
378
327
|
*/
|
|
379
|
-
|
|
380
328
|
}, {
|
|
381
329
|
key: "UseRegion",
|
|
382
330
|
value: function () {
|
|
383
331
|
var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
384
332
|
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, searchURIs;
|
|
385
|
-
|
|
386
333
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
387
|
-
while (1) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
searchURIs: searchURIs
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
case 19:
|
|
427
|
-
case "end":
|
|
428
|
-
return _context3.stop();
|
|
429
|
-
}
|
|
334
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
335
|
+
case 0:
|
|
336
|
+
region = _ref4.region;
|
|
337
|
+
if (this.configUrl) {
|
|
338
|
+
_context3.next = 3;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
throw Error("Unable to change region: Configuration URL not set");
|
|
342
|
+
case 3:
|
|
343
|
+
_context3.next = 5;
|
|
344
|
+
return ElvClient.Configuration({
|
|
345
|
+
configUrl: this.configUrl,
|
|
346
|
+
region: region
|
|
347
|
+
});
|
|
348
|
+
case 5:
|
|
349
|
+
_yield$ElvClient$Conf = _context3.sent;
|
|
350
|
+
fabricURIs = _yield$ElvClient$Conf.fabricURIs;
|
|
351
|
+
ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
|
|
352
|
+
authServiceURIs = _yield$ElvClient$Conf.authServiceURIs;
|
|
353
|
+
searchURIs = _yield$ElvClient$Conf.searchURIs;
|
|
354
|
+
this.authServiceURIs = authServiceURIs;
|
|
355
|
+
this.fabricURIs = fabricURIs;
|
|
356
|
+
this.ethereumURIs = ethereumURIs;
|
|
357
|
+
this.searchURIs = searchURIs;
|
|
358
|
+
this.HttpClient.uris = fabricURIs;
|
|
359
|
+
this.HttpClient.uriIndex = 0;
|
|
360
|
+
this.ethClient.ethereumURIs = ethereumURIs;
|
|
361
|
+
this.ethClient.ethereumURIIndex = 0;
|
|
362
|
+
return _context3.abrupt("return", {
|
|
363
|
+
fabricURIs: fabricURIs,
|
|
364
|
+
ethereumURIs: ethereumURIs,
|
|
365
|
+
searchURIs: searchURIs
|
|
366
|
+
});
|
|
367
|
+
case 19:
|
|
368
|
+
case "end":
|
|
369
|
+
return _context3.stop();
|
|
430
370
|
}
|
|
431
371
|
}, _callee3, this);
|
|
432
372
|
}));
|
|
433
|
-
|
|
434
373
|
function UseRegion(_x) {
|
|
435
374
|
return _UseRegion.apply(this, arguments);
|
|
436
375
|
}
|
|
437
|
-
|
|
438
376
|
return UseRegion;
|
|
439
377
|
}()
|
|
440
378
|
/**
|
|
@@ -446,43 +384,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
446
384
|
*
|
|
447
385
|
* @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
|
|
448
386
|
*/
|
|
449
|
-
|
|
450
387
|
}, {
|
|
451
388
|
key: "ResetRegion",
|
|
452
389
|
value: function () {
|
|
453
390
|
var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
454
391
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
455
|
-
while (1) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return _context4.abrupt("return", _context4.sent);
|
|
473
|
-
|
|
474
|
-
case 5:
|
|
475
|
-
case "end":
|
|
476
|
-
return _context4.stop();
|
|
477
|
-
}
|
|
392
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
393
|
+
case 0:
|
|
394
|
+
if (this.configUrl) {
|
|
395
|
+
_context4.next = 2;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
throw Error("Unable to change region: Configuration URL not set");
|
|
399
|
+
case 2:
|
|
400
|
+
_context4.next = 4;
|
|
401
|
+
return this.UseRegion({
|
|
402
|
+
region: ""
|
|
403
|
+
});
|
|
404
|
+
case 4:
|
|
405
|
+
return _context4.abrupt("return", _context4.sent);
|
|
406
|
+
case 5:
|
|
407
|
+
case "end":
|
|
408
|
+
return _context4.stop();
|
|
478
409
|
}
|
|
479
410
|
}, _callee4, this);
|
|
480
411
|
}));
|
|
481
|
-
|
|
482
412
|
function ResetRegion() {
|
|
483
413
|
return _ResetRegion.apply(this, arguments);
|
|
484
414
|
}
|
|
485
|
-
|
|
486
415
|
return ResetRegion;
|
|
487
416
|
}()
|
|
488
417
|
/**
|
|
@@ -497,41 +426,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
497
426
|
*
|
|
498
427
|
* @return {Promise<string>} - The node ID reported by the fabric
|
|
499
428
|
*/
|
|
500
|
-
|
|
501
429
|
}, {
|
|
502
430
|
key: "NodeId",
|
|
503
431
|
value: function () {
|
|
504
432
|
var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
505
433
|
var region, _yield$ElvClient$Conf2, nodeId;
|
|
506
|
-
|
|
507
434
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
508
|
-
while (1) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
case 6:
|
|
524
|
-
case "end":
|
|
525
|
-
return _context5.stop();
|
|
526
|
-
}
|
|
435
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
436
|
+
case 0:
|
|
437
|
+
region = _ref5.region;
|
|
438
|
+
_context5.next = 3;
|
|
439
|
+
return ElvClient.Configuration({
|
|
440
|
+
configUrl: this.configUrl,
|
|
441
|
+
region: region
|
|
442
|
+
});
|
|
443
|
+
case 3:
|
|
444
|
+
_yield$ElvClient$Conf2 = _context5.sent;
|
|
445
|
+
nodeId = _yield$ElvClient$Conf2.nodeId;
|
|
446
|
+
return _context5.abrupt("return", nodeId);
|
|
447
|
+
case 6:
|
|
448
|
+
case "end":
|
|
449
|
+
return _context5.stop();
|
|
527
450
|
}
|
|
528
451
|
}, _callee5, this);
|
|
529
452
|
}));
|
|
530
|
-
|
|
531
453
|
function NodeId(_x2) {
|
|
532
454
|
return _NodeId.apply(this, arguments);
|
|
533
455
|
}
|
|
534
|
-
|
|
535
456
|
return NodeId;
|
|
536
457
|
}()
|
|
537
458
|
/**
|
|
@@ -541,7 +462,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
541
462
|
*
|
|
542
463
|
* @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
|
|
543
464
|
*/
|
|
544
|
-
|
|
545
465
|
}, {
|
|
546
466
|
key: "Nodes",
|
|
547
467
|
value: function Nodes() {
|
|
@@ -552,6 +472,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
552
472
|
searchURIs: this.searchURIs
|
|
553
473
|
};
|
|
554
474
|
}
|
|
475
|
+
|
|
555
476
|
/**
|
|
556
477
|
* Set the client to use the specified fabric, ethereum, auth service, and search nodes, in preference order
|
|
557
478
|
*
|
|
@@ -563,44 +484,39 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
563
484
|
*
|
|
564
485
|
* @methodGroup Nodes
|
|
565
486
|
*/
|
|
566
|
-
|
|
567
487
|
}, {
|
|
568
488
|
key: "SetNodes",
|
|
569
489
|
value: function SetNodes(_ref6) {
|
|
570
490
|
var fabricURIs = _ref6.fabricURIs,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
491
|
+
ethereumURIs = _ref6.ethereumURIs,
|
|
492
|
+
authServiceURIs = _ref6.authServiceURIs,
|
|
493
|
+
searchURIs = _ref6.searchURIs;
|
|
575
494
|
if (fabricURIs) {
|
|
576
495
|
this.fabricURIs = fabricURIs;
|
|
577
496
|
this.HttpClient.uris = fabricURIs;
|
|
578
497
|
this.HttpClient.uriIndex = 0;
|
|
579
498
|
}
|
|
580
|
-
|
|
581
499
|
if (ethereumURIs) {
|
|
582
500
|
this.ethereumURIs = ethereumURIs;
|
|
583
501
|
this.ethClient.ethereumURIs = ethereumURIs;
|
|
584
502
|
this.ethClient.ethereumURIIndex = 0;
|
|
585
503
|
}
|
|
586
|
-
|
|
587
504
|
if (authServiceURIs) {
|
|
588
505
|
this.authServiceURIs = authServiceURIs;
|
|
589
506
|
this.AuthHttpClient.uris = authServiceURIs;
|
|
590
507
|
this.AuthHttpClient.uriIndex = 0;
|
|
591
508
|
}
|
|
592
|
-
|
|
593
509
|
if (searchURIs) {
|
|
594
510
|
this.searchURIs = searchURIs;
|
|
595
511
|
}
|
|
596
512
|
}
|
|
513
|
+
|
|
597
514
|
/**
|
|
598
515
|
* Return information about how the client was connected to the network
|
|
599
516
|
*
|
|
600
517
|
* @methodGroup Nodes
|
|
601
518
|
* @returns {Object} - The name, ID and configuration URL of the network
|
|
602
519
|
*/
|
|
603
|
-
|
|
604
520
|
}, {
|
|
605
521
|
key: "NetworkInfo",
|
|
606
522
|
value: function NetworkInfo() {
|
|
@@ -610,6 +526,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
610
526
|
configUrl: this.configUrl
|
|
611
527
|
};
|
|
612
528
|
}
|
|
529
|
+
|
|
613
530
|
/* Wallet and signers */
|
|
614
531
|
|
|
615
532
|
/**
|
|
@@ -618,35 +535,35 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
618
535
|
* @methodGroup Signers
|
|
619
536
|
* @returns {ElvWallet} - ElvWallet instance with this client's provider
|
|
620
537
|
*/
|
|
621
|
-
|
|
622
538
|
}, {
|
|
623
539
|
key: "GenerateWallet",
|
|
624
540
|
value: function GenerateWallet() {
|
|
625
541
|
return new ElvWallet(this.ethClient.Provider());
|
|
626
542
|
}
|
|
543
|
+
|
|
627
544
|
/**
|
|
628
545
|
* Remove the signer from this client
|
|
629
546
|
*
|
|
630
547
|
* @methodGroup Signers
|
|
631
548
|
*/
|
|
632
|
-
|
|
633
549
|
}, {
|
|
634
550
|
key: "ClearSigner",
|
|
635
551
|
value: function ClearSigner() {
|
|
636
552
|
this.signer = undefined;
|
|
637
553
|
this.InitializeClients();
|
|
638
554
|
}
|
|
555
|
+
|
|
639
556
|
/**
|
|
640
557
|
* Clear saved access and state channel tokens
|
|
641
558
|
*
|
|
642
559
|
* @methodGroup Access Requests
|
|
643
560
|
*/
|
|
644
|
-
|
|
645
561
|
}, {
|
|
646
562
|
key: "ClearCache",
|
|
647
563
|
value: function ClearCache() {
|
|
648
564
|
this.authClient.ClearCache();
|
|
649
565
|
}
|
|
566
|
+
|
|
650
567
|
/**
|
|
651
568
|
* Set the signer for this client to use for blockchain transactions
|
|
652
569
|
*
|
|
@@ -654,22 +571,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
654
571
|
* @namedParams
|
|
655
572
|
* @param {object} signer - The ethers.js signer object
|
|
656
573
|
*/
|
|
657
|
-
|
|
658
574
|
}, {
|
|
659
575
|
key: "SetSigner",
|
|
660
576
|
value: function SetSigner(_ref7) {
|
|
661
577
|
var signer = _ref7.signer,
|
|
662
|
-
|
|
663
|
-
|
|
578
|
+
_ref7$reset = _ref7.reset,
|
|
579
|
+
reset = _ref7$reset === void 0 ? true : _ref7$reset;
|
|
664
580
|
this.staticToken = undefined;
|
|
665
581
|
signer.connect(this.ethClient.Provider());
|
|
666
582
|
signer.provider.pollingInterval = 500;
|
|
667
583
|
this.signer = signer;
|
|
668
|
-
|
|
669
584
|
if (reset) {
|
|
670
585
|
this.InitializeClients();
|
|
671
586
|
}
|
|
672
587
|
}
|
|
588
|
+
|
|
673
589
|
/**
|
|
674
590
|
* Set signer using OAuth ID token
|
|
675
591
|
*
|
|
@@ -682,59 +598,51 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
682
598
|
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
683
599
|
* @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)
|
|
684
600
|
*/
|
|
685
|
-
|
|
686
601
|
}, {
|
|
687
602
|
key: "SetRemoteSigner",
|
|
688
603
|
value: function () {
|
|
689
604
|
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref8) {
|
|
690
605
|
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
691
606
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
692
|
-
while (1) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
_context6.
|
|
708
|
-
_context6.
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
case 16:
|
|
727
|
-
case "end":
|
|
728
|
-
return _context6.stop();
|
|
729
|
-
}
|
|
607
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
608
|
+
case 0:
|
|
609
|
+
idToken = _ref8.idToken, authToken = _ref8.authToken, tenantId = _ref8.tenantId, extraData = _ref8.extraData, signerURIs = _ref8.signerURIs, unsignedPublicAuth = _ref8.unsignedPublicAuth;
|
|
610
|
+
_context6.t0 = RemoteSigner;
|
|
611
|
+
_context6.t1 = signerURIs || this.authServiceURIs;
|
|
612
|
+
_context6.t2 = idToken;
|
|
613
|
+
_context6.t3 = authToken;
|
|
614
|
+
_context6.t4 = tenantId;
|
|
615
|
+
_context6.next = 8;
|
|
616
|
+
return this.ethClient.Provider();
|
|
617
|
+
case 8:
|
|
618
|
+
_context6.t5 = _context6.sent;
|
|
619
|
+
_context6.t6 = extraData;
|
|
620
|
+
_context6.t7 = unsignedPublicAuth;
|
|
621
|
+
_context6.t8 = {
|
|
622
|
+
signerURIs: _context6.t1,
|
|
623
|
+
idToken: _context6.t2,
|
|
624
|
+
authToken: _context6.t3,
|
|
625
|
+
tenantId: _context6.t4,
|
|
626
|
+
provider: _context6.t5,
|
|
627
|
+
extraData: _context6.t6,
|
|
628
|
+
unsignedPublicAuth: _context6.t7
|
|
629
|
+
};
|
|
630
|
+
signer = new _context6.t0(_context6.t8);
|
|
631
|
+
_context6.next = 15;
|
|
632
|
+
return signer.Initialize();
|
|
633
|
+
case 15:
|
|
634
|
+
this.SetSigner({
|
|
635
|
+
signer: signer
|
|
636
|
+
});
|
|
637
|
+
case 16:
|
|
638
|
+
case "end":
|
|
639
|
+
return _context6.stop();
|
|
730
640
|
}
|
|
731
641
|
}, _callee6, this);
|
|
732
642
|
}));
|
|
733
|
-
|
|
734
643
|
function SetRemoteSigner(_x3) {
|
|
735
644
|
return _SetRemoteSigner.apply(this, arguments);
|
|
736
645
|
}
|
|
737
|
-
|
|
738
646
|
return SetRemoteSigner;
|
|
739
647
|
}()
|
|
740
648
|
/**
|
|
@@ -747,41 +655,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
747
655
|
* @namedParams
|
|
748
656
|
* @param {object} provider - The web3 provider object
|
|
749
657
|
*/
|
|
750
|
-
|
|
751
658
|
}, {
|
|
752
659
|
key: "SetSignerFromWeb3Provider",
|
|
753
660
|
value: function () {
|
|
754
661
|
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref9) {
|
|
755
662
|
var provider, ethProvider;
|
|
756
663
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
757
|
-
while (1) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
case 10:
|
|
774
|
-
case "end":
|
|
775
|
-
return _context7.stop();
|
|
776
|
-
}
|
|
664
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
665
|
+
case 0:
|
|
666
|
+
provider = _ref9.provider;
|
|
667
|
+
this.staticToken = undefined;
|
|
668
|
+
ethProvider = new Ethers.providers.Web3Provider(provider);
|
|
669
|
+
ethProvider.pollingInterval = 250;
|
|
670
|
+
this.signer = ethProvider.getSigner();
|
|
671
|
+
_context7.next = 7;
|
|
672
|
+
return this.signer.getAddress();
|
|
673
|
+
case 7:
|
|
674
|
+
this.signer.address = _context7.sent;
|
|
675
|
+
_context7.next = 10;
|
|
676
|
+
return this.InitializeClients();
|
|
677
|
+
case 10:
|
|
678
|
+
case "end":
|
|
679
|
+
return _context7.stop();
|
|
777
680
|
}
|
|
778
681
|
}, _callee7, this);
|
|
779
682
|
}));
|
|
780
|
-
|
|
781
683
|
function SetSignerFromWeb3Provider(_x4) {
|
|
782
684
|
return _SetSignerFromWeb3Provider.apply(this, arguments);
|
|
783
685
|
}
|
|
784
|
-
|
|
785
686
|
return SetSignerFromWeb3Provider;
|
|
786
687
|
}()
|
|
787
688
|
/**
|
|
@@ -799,86 +700,72 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
799
700
|
*
|
|
800
701
|
* @return {string} - The address of the user
|
|
801
702
|
*/
|
|
802
|
-
|
|
803
703
|
}, {
|
|
804
704
|
key: "CreateAccount",
|
|
805
705
|
value: function () {
|
|
806
706
|
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
|
|
807
707
|
var tenantId, fundingToken, _ref10$funds, funds, groupToken, wallet, signer;
|
|
808
|
-
|
|
809
708
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
810
|
-
while (1) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
wallet
|
|
817
|
-
signer = wallet.AddAccountFromMnemonic({
|
|
818
|
-
mnemonic: wallet.GenerateMnemonic()
|
|
819
|
-
});
|
|
820
|
-
this.SetSigner({
|
|
821
|
-
signer: signer
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
_context8.next = 4;
|
|
826
|
-
return this.authClient.MakeKMSRequest({
|
|
827
|
-
method: "POST",
|
|
828
|
-
path: "/ks/otp/fnd/".concat(tenantId),
|
|
829
|
-
body: {
|
|
830
|
-
toAddr: this.signer.address,
|
|
831
|
-
amtStr: this.utils.EtherToWei(funds)
|
|
832
|
-
},
|
|
833
|
-
headers: {
|
|
834
|
-
Authorization: "Bearer ".concat(fundingToken)
|
|
835
|
-
}
|
|
709
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
710
|
+
case 0:
|
|
711
|
+
tenantId = _ref10.tenantId, fundingToken = _ref10.fundingToken, _ref10$funds = _ref10.funds, funds = _ref10$funds === void 0 ? 0.5 : _ref10$funds, groupToken = _ref10.groupToken;
|
|
712
|
+
if (!this.signer) {
|
|
713
|
+
wallet = this.GenerateWallet();
|
|
714
|
+
signer = wallet.AddAccountFromMnemonic({
|
|
715
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
836
716
|
});
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
_context8.next = 6;
|
|
840
|
-
return this.userProfileClient.CreateWallet();
|
|
841
|
-
|
|
842
|
-
case 6:
|
|
843
|
-
_context8.next = 8;
|
|
844
|
-
return this.userProfileClient.ReplaceUserMetadata({
|
|
845
|
-
metadataSubtree: "tenantContractId",
|
|
846
|
-
metadata: tenantId
|
|
717
|
+
this.SetSigner({
|
|
718
|
+
signer: signer
|
|
847
719
|
});
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
720
|
+
}
|
|
721
|
+
_context8.next = 4;
|
|
722
|
+
return this.authClient.MakeKMSRequest({
|
|
723
|
+
method: "POST",
|
|
724
|
+
path: "/ks/otp/fnd/".concat(tenantId),
|
|
725
|
+
body: {
|
|
726
|
+
toAddr: this.signer.address,
|
|
727
|
+
amtStr: this.utils.EtherToWei(funds)
|
|
728
|
+
},
|
|
729
|
+
headers: {
|
|
730
|
+
Authorization: "Bearer ".concat(fundingToken)
|
|
853
731
|
}
|
|
854
|
-
|
|
732
|
+
});
|
|
733
|
+
case 4:
|
|
734
|
+
_context8.next = 6;
|
|
735
|
+
return this.userProfileClient.CreateWallet();
|
|
736
|
+
case 6:
|
|
737
|
+
_context8.next = 8;
|
|
738
|
+
return this.userProfileClient.ReplaceUserMetadata({
|
|
739
|
+
metadataSubtree: "tenantContractId",
|
|
740
|
+
metadata: tenantId
|
|
741
|
+
});
|
|
742
|
+
case 8:
|
|
743
|
+
if (!groupToken) {
|
|
855
744
|
_context8.next = 11;
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
_context8.next = 11;
|
|
748
|
+
return this.authClient.MakeKMSRequest({
|
|
749
|
+
method: "POST",
|
|
750
|
+
path: "/ks/otp/grp/".concat(tenantId),
|
|
751
|
+
body: {
|
|
752
|
+
addAddr: this.signer.address
|
|
753
|
+
},
|
|
754
|
+
headers: {
|
|
755
|
+
Authorization: "Bearer ".concat(groupToken)
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
case 11:
|
|
759
|
+
return _context8.abrupt("return", this.utils.FormatAddress(this.signer.address));
|
|
760
|
+
case 12:
|
|
761
|
+
case "end":
|
|
762
|
+
return _context8.stop();
|
|
874
763
|
}
|
|
875
764
|
}, _callee8, this);
|
|
876
765
|
}));
|
|
877
|
-
|
|
878
766
|
function CreateAccount(_x5) {
|
|
879
767
|
return _CreateAccount.apply(this, arguments);
|
|
880
768
|
}
|
|
881
|
-
|
|
882
769
|
return CreateAccount;
|
|
883
770
|
}()
|
|
884
771
|
/*
|
|
@@ -890,65 +777,50 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
890
777
|
PAYLOAD 85b json-compressed
|
|
891
778
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
892
779
|
*/
|
|
893
|
-
|
|
894
780
|
}, {
|
|
895
781
|
key: "PersonalSign",
|
|
896
782
|
value: function () {
|
|
897
783
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref11) {
|
|
898
784
|
var _this = this;
|
|
899
|
-
|
|
900
785
|
var message, addEthereumPrefix, Sign;
|
|
901
786
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
902
|
-
while (1) {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
_context10.next = 5;
|
|
935
|
-
return Sign(message);
|
|
936
|
-
|
|
937
|
-
case 5:
|
|
938
|
-
return _context10.abrupt("return", _context10.sent);
|
|
939
|
-
|
|
940
|
-
case 6:
|
|
941
|
-
case "end":
|
|
942
|
-
return _context10.stop();
|
|
943
|
-
}
|
|
787
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
788
|
+
case 0:
|
|
789
|
+
message = _ref11.message, addEthereumPrefix = _ref11.addEthereumPrefix, Sign = _ref11.Sign;
|
|
790
|
+
if (!Sign) {
|
|
791
|
+
Sign = /*#__PURE__*/function () {
|
|
792
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
|
|
793
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
794
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
795
|
+
case 0:
|
|
796
|
+
return _context9.abrupt("return", _this.authClient.Sign(message));
|
|
797
|
+
case 1:
|
|
798
|
+
case "end":
|
|
799
|
+
return _context9.stop();
|
|
800
|
+
}
|
|
801
|
+
}, _callee9);
|
|
802
|
+
}));
|
|
803
|
+
return function Sign(_x7) {
|
|
804
|
+
return _ref12.apply(this, arguments);
|
|
805
|
+
};
|
|
806
|
+
}();
|
|
807
|
+
}
|
|
808
|
+
if (addEthereumPrefix) {
|
|
809
|
+
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
810
|
+
}
|
|
811
|
+
_context10.next = 5;
|
|
812
|
+
return Sign(message);
|
|
813
|
+
case 5:
|
|
814
|
+
return _context10.abrupt("return", _context10.sent);
|
|
815
|
+
case 6:
|
|
816
|
+
case "end":
|
|
817
|
+
return _context10.stop();
|
|
944
818
|
}
|
|
945
819
|
}, _callee10);
|
|
946
820
|
}));
|
|
947
|
-
|
|
948
821
|
function PersonalSign(_x6) {
|
|
949
822
|
return _PersonalSign.apply(this, arguments);
|
|
950
823
|
}
|
|
951
|
-
|
|
952
824
|
return PersonalSign;
|
|
953
825
|
}()
|
|
954
826
|
/**
|
|
@@ -962,77 +834,68 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
962
834
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
963
835
|
* @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
|
|
964
836
|
*/
|
|
965
|
-
|
|
966
837
|
}, {
|
|
967
838
|
key: "CreateFabricToken",
|
|
968
839
|
value: function () {
|
|
969
840
|
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
970
841
|
var _ref13,
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
842
|
+
_ref13$duration,
|
|
843
|
+
duration,
|
|
844
|
+
_ref13$spec,
|
|
845
|
+
spec,
|
|
846
|
+
address,
|
|
847
|
+
Sign,
|
|
848
|
+
_ref13$addEthereumPre,
|
|
849
|
+
addEthereumPrefix,
|
|
850
|
+
token,
|
|
851
|
+
message,
|
|
852
|
+
signature,
|
|
853
|
+
compressedToken,
|
|
854
|
+
_args11 = arguments;
|
|
985
855
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
986
|
-
while (1) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
_context11.
|
|
1003
|
-
_context11.
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
case 20:
|
|
1025
|
-
case "end":
|
|
1026
|
-
return _context11.stop();
|
|
1027
|
-
}
|
|
856
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
857
|
+
case 0:
|
|
858
|
+
_ref13 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, _ref13$duration = _ref13.duration, duration = _ref13$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref13$duration, _ref13$spec = _ref13.spec, spec = _ref13$spec === void 0 ? {} : _ref13$spec, address = _ref13.address, Sign = _ref13.Sign, _ref13$addEthereumPre = _ref13.addEthereumPrefix, addEthereumPrefix = _ref13$addEthereumPre === void 0 ? true : _ref13$addEthereumPre;
|
|
859
|
+
address = address || this.CurrentAccountAddress();
|
|
860
|
+
_context11.t0 = _objectSpread;
|
|
861
|
+
_context11.t1 = _objectSpread({}, spec);
|
|
862
|
+
_context11.t2 = {};
|
|
863
|
+
_context11.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
864
|
+
_context11.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
865
|
+
_context11.next = 9;
|
|
866
|
+
return this.ContentSpaceId();
|
|
867
|
+
case 9:
|
|
868
|
+
_context11.t5 = _context11.sent;
|
|
869
|
+
_context11.t6 = Date.now();
|
|
870
|
+
_context11.t7 = Date.now() + duration;
|
|
871
|
+
_context11.t8 = {
|
|
872
|
+
sub: _context11.t3,
|
|
873
|
+
adr: _context11.t4,
|
|
874
|
+
spc: _context11.t5,
|
|
875
|
+
iat: _context11.t6,
|
|
876
|
+
exp: _context11.t7
|
|
877
|
+
};
|
|
878
|
+
token = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t8);
|
|
879
|
+
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
880
|
+
_context11.next = 17;
|
|
881
|
+
return this.PersonalSign({
|
|
882
|
+
message: message,
|
|
883
|
+
addEthereumPrefix: addEthereumPrefix,
|
|
884
|
+
Sign: Sign
|
|
885
|
+
});
|
|
886
|
+
case 17:
|
|
887
|
+
signature = _context11.sent;
|
|
888
|
+
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
889
|
+
return _context11.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
890
|
+
case 20:
|
|
891
|
+
case "end":
|
|
892
|
+
return _context11.stop();
|
|
1028
893
|
}
|
|
1029
894
|
}, _callee11, this);
|
|
1030
895
|
}));
|
|
1031
|
-
|
|
1032
896
|
function CreateFabricToken() {
|
|
1033
897
|
return _CreateFabricToken.apply(this, arguments);
|
|
1034
898
|
}
|
|
1035
|
-
|
|
1036
899
|
return CreateFabricToken;
|
|
1037
900
|
}()
|
|
1038
901
|
/**
|
|
@@ -1051,131 +914,105 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1051
914
|
* enabling the user of this token to download encrypted content from the specified object
|
|
1052
915
|
* @param {Object=} context - Additional JSON context
|
|
1053
916
|
*/
|
|
1054
|
-
|
|
1055
917
|
}, {
|
|
1056
918
|
key: "CreateSignedToken",
|
|
1057
919
|
value: function () {
|
|
1058
920
|
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref14) {
|
|
1059
921
|
var libraryId, objectId, versionHash, policyId, subject, _ref14$grantType, grantType, _ref14$allowDecryptio, allowDecryption, duration, _ref14$context, context, token, cap, compressedToken, signature;
|
|
1060
|
-
|
|
1061
922
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1062
|
-
while (1) {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
_context12.t8
|
|
1100
|
-
_context12.t9
|
|
1101
|
-
_context12.t10
|
|
1102
|
-
_context12.t11
|
|
1103
|
-
_context12.t12
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
return this.authClient.ReEncryptionConk({
|
|
1150
|
-
libraryId: libraryId,
|
|
1151
|
-
objectId: objectId
|
|
1152
|
-
});
|
|
1153
|
-
|
|
1154
|
-
case 35:
|
|
1155
|
-
cap = _context12.sent;
|
|
1156
|
-
token.apk = cap.public_key;
|
|
1157
|
-
|
|
1158
|
-
case 37:
|
|
1159
|
-
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1160
|
-
_context12.next = 40;
|
|
1161
|
-
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1162
|
-
|
|
1163
|
-
case 40:
|
|
1164
|
-
signature = _context12.sent;
|
|
1165
|
-
return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1166
|
-
|
|
1167
|
-
case 42:
|
|
1168
|
-
case "end":
|
|
1169
|
-
return _context12.stop();
|
|
1170
|
-
}
|
|
923
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
924
|
+
case 0:
|
|
925
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, versionHash = _ref14.versionHash, policyId = _ref14.policyId, subject = _ref14.subject, _ref14$grantType = _ref14.grantType, grantType = _ref14$grantType === void 0 ? "read" : _ref14$grantType, _ref14$allowDecryptio = _ref14.allowDecryption, allowDecryption = _ref14$allowDecryptio === void 0 ? false : _ref14$allowDecryptio, duration = _ref14.duration, _ref14$context = _ref14.context, context = _ref14$context === void 0 ? {} : _ref14$context;
|
|
926
|
+
if (subject) {
|
|
927
|
+
_context12.next = 9;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
_context12.t0 = "iusr";
|
|
931
|
+
_context12.t1 = this.utils;
|
|
932
|
+
_context12.next = 6;
|
|
933
|
+
return this.CurrentAccountAddress();
|
|
934
|
+
case 6:
|
|
935
|
+
_context12.t2 = _context12.sent;
|
|
936
|
+
_context12.t3 = _context12.t1.AddressToHash.call(_context12.t1, _context12.t2);
|
|
937
|
+
subject = _context12.t0.concat.call(_context12.t0, _context12.t3);
|
|
938
|
+
case 9:
|
|
939
|
+
if (policyId) {
|
|
940
|
+
context["elv:delegation-id"] = policyId;
|
|
941
|
+
}
|
|
942
|
+
_context12.t4 = Buffer;
|
|
943
|
+
_context12.next = 13;
|
|
944
|
+
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
945
|
+
case 13:
|
|
946
|
+
_context12.t5 = _context12.sent;
|
|
947
|
+
_context12.t6 = _context12.t4.from.call(_context12.t4, _context12.t5, "hex").toString("base64");
|
|
948
|
+
_context12.t7 = subject;
|
|
949
|
+
_context12.next = 18;
|
|
950
|
+
return this.ContentSpaceId();
|
|
951
|
+
case 18:
|
|
952
|
+
_context12.t8 = _context12.sent;
|
|
953
|
+
_context12.t9 = Date.now();
|
|
954
|
+
_context12.t10 = Date.now() + duration;
|
|
955
|
+
_context12.t11 = grantType;
|
|
956
|
+
_context12.t12 = context;
|
|
957
|
+
token = {
|
|
958
|
+
adr: _context12.t6,
|
|
959
|
+
sub: _context12.t7,
|
|
960
|
+
spc: _context12.t8,
|
|
961
|
+
iat: _context12.t9,
|
|
962
|
+
exp: _context12.t10,
|
|
963
|
+
gra: _context12.t11,
|
|
964
|
+
ctx: _context12.t12
|
|
965
|
+
};
|
|
966
|
+
if (versionHash) {
|
|
967
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
968
|
+
}
|
|
969
|
+
if (!objectId) {
|
|
970
|
+
_context12.next = 31;
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
token.qid = objectId;
|
|
974
|
+
if (libraryId) {
|
|
975
|
+
_context12.next = 31;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
_context12.next = 30;
|
|
979
|
+
return this.ContentObjectLibraryId({
|
|
980
|
+
objectId: objectId
|
|
981
|
+
});
|
|
982
|
+
case 30:
|
|
983
|
+
libraryId = _context12.sent;
|
|
984
|
+
case 31:
|
|
985
|
+
if (libraryId) {
|
|
986
|
+
token.lib = libraryId;
|
|
987
|
+
}
|
|
988
|
+
if (!allowDecryption) {
|
|
989
|
+
_context12.next = 37;
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
_context12.next = 35;
|
|
993
|
+
return this.authClient.ReEncryptionConk({
|
|
994
|
+
libraryId: libraryId,
|
|
995
|
+
objectId: objectId
|
|
996
|
+
});
|
|
997
|
+
case 35:
|
|
998
|
+
cap = _context12.sent;
|
|
999
|
+
token.apk = cap.public_key;
|
|
1000
|
+
case 37:
|
|
1001
|
+
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1002
|
+
_context12.next = 40;
|
|
1003
|
+
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1004
|
+
case 40:
|
|
1005
|
+
signature = _context12.sent;
|
|
1006
|
+
return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1007
|
+
case 42:
|
|
1008
|
+
case "end":
|
|
1009
|
+
return _context12.stop();
|
|
1171
1010
|
}
|
|
1172
1011
|
}, _callee12, this);
|
|
1173
1012
|
}));
|
|
1174
|
-
|
|
1175
1013
|
function CreateSignedToken(_x8) {
|
|
1176
1014
|
return _CreateSignedToken.apply(this, arguments);
|
|
1177
1015
|
}
|
|
1178
|
-
|
|
1179
1016
|
return CreateSignedToken;
|
|
1180
1017
|
}()
|
|
1181
1018
|
/**
|
|
@@ -1184,12 +1021,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1184
1021
|
* @methodGroup Signers
|
|
1185
1022
|
* @returns {string} - The address of the current signer
|
|
1186
1023
|
*/
|
|
1187
|
-
|
|
1188
1024
|
}, {
|
|
1189
1025
|
key: "CurrentAccountAddress",
|
|
1190
1026
|
value: function CurrentAccountAddress() {
|
|
1191
1027
|
return this.signer ? this.utils.FormatAddress(this.signer.address) : "";
|
|
1192
1028
|
}
|
|
1029
|
+
|
|
1193
1030
|
/**
|
|
1194
1031
|
* Set the OAuth token for use in state channel calls
|
|
1195
1032
|
*
|
|
@@ -1197,38 +1034,32 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1197
1034
|
* @namedParams
|
|
1198
1035
|
* @param {string} token - The OAuth ID token
|
|
1199
1036
|
*/
|
|
1200
|
-
|
|
1201
1037
|
}, {
|
|
1202
1038
|
key: "SetOauthToken",
|
|
1203
1039
|
value: function () {
|
|
1204
1040
|
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref15) {
|
|
1205
1041
|
var token, wallet, signer;
|
|
1206
1042
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1207
|
-
while (1) {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
case "end":
|
|
1222
|
-
return _context13.stop();
|
|
1223
|
-
}
|
|
1043
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1044
|
+
case 0:
|
|
1045
|
+
token = _ref15.token;
|
|
1046
|
+
this.oauthToken = token;
|
|
1047
|
+
wallet = this.GenerateWallet();
|
|
1048
|
+
signer = wallet.AddAccountFromMnemonic({
|
|
1049
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
1050
|
+
});
|
|
1051
|
+
this.SetSigner({
|
|
1052
|
+
signer: signer
|
|
1053
|
+
});
|
|
1054
|
+
case 5:
|
|
1055
|
+
case "end":
|
|
1056
|
+
return _context13.stop();
|
|
1224
1057
|
}
|
|
1225
1058
|
}, _callee13, this);
|
|
1226
1059
|
}));
|
|
1227
|
-
|
|
1228
1060
|
function SetOauthToken(_x9) {
|
|
1229
1061
|
return _SetOauthToken.apply(this, arguments);
|
|
1230
1062
|
}
|
|
1231
|
-
|
|
1232
1063
|
return SetOauthToken;
|
|
1233
1064
|
}()
|
|
1234
1065
|
/**
|
|
@@ -1241,122 +1072,101 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1241
1072
|
* @namedParams
|
|
1242
1073
|
* @param {string} token - The OAuth ID
|
|
1243
1074
|
*/
|
|
1244
|
-
|
|
1245
1075
|
}, {
|
|
1246
1076
|
key: "SetSignerFromOauthToken",
|
|
1247
1077
|
value: function () {
|
|
1248
1078
|
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref16) {
|
|
1249
1079
|
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1250
|
-
|
|
1251
1080
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1252
|
-
while (1) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
if (this.trustAuthorityId) {
|
|
1258
|
-
_context14.next = 3;
|
|
1259
|
-
break;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1263
|
-
|
|
1264
|
-
case 3:
|
|
1265
|
-
wallet = this.GenerateWallet();
|
|
1266
|
-
_context14.prev = 4;
|
|
1267
|
-
|
|
1268
|
-
if (this.kmsURIs) {
|
|
1269
|
-
_context14.next = 17;
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
_context14.next = 8;
|
|
1274
|
-
return ElvClient.FromConfigurationUrl({
|
|
1275
|
-
configUrl: this.configUrl
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
|
-
case 8:
|
|
1279
|
-
client = _context14.sent;
|
|
1280
|
-
client.SetSigner({
|
|
1281
|
-
signer: wallet.AddAccountFromMnemonic({
|
|
1282
|
-
mnemonic: wallet.GenerateMnemonic()
|
|
1283
|
-
})
|
|
1284
|
-
});
|
|
1285
|
-
_context14.next = 12;
|
|
1286
|
-
return client.authClient.KMSInfo({
|
|
1287
|
-
kmsId: this.trustAuthorityId
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
case 12:
|
|
1291
|
-
_yield$client$authCli = _context14.sent;
|
|
1292
|
-
urls = _yield$client$authCli.urls;
|
|
1293
|
-
|
|
1294
|
-
if (!(!urls || urls.length === 0)) {
|
|
1295
|
-
_context14.next = 16;
|
|
1296
|
-
break;
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
1300
|
-
|
|
1301
|
-
case 16:
|
|
1302
|
-
this.kmsURIs = urls;
|
|
1303
|
-
|
|
1304
|
-
case 17:
|
|
1305
|
-
this.oauthToken = token;
|
|
1306
|
-
path = "/ks/jwt/wlt";
|
|
1307
|
-
httpClient = new HttpClient({
|
|
1308
|
-
uris: this.kmsURIs,
|
|
1309
|
-
debug: this.debug
|
|
1310
|
-
});
|
|
1311
|
-
_context14.next = 22;
|
|
1312
|
-
return this.utils.ResponseToJson(httpClient.Request({
|
|
1313
|
-
headers: {
|
|
1314
|
-
Authorization: "Bearer ".concat(token)
|
|
1315
|
-
},
|
|
1316
|
-
method: "PUT",
|
|
1317
|
-
path: path,
|
|
1318
|
-
forceFailover: true
|
|
1319
|
-
}));
|
|
1320
|
-
|
|
1321
|
-
case 22:
|
|
1322
|
-
response = _context14.sent;
|
|
1323
|
-
privateKey = response["UserSKHex"];
|
|
1324
|
-
this.SetSigner({
|
|
1325
|
-
signer: wallet.AddAccount({
|
|
1326
|
-
privateKey: privateKey
|
|
1327
|
-
})
|
|
1328
|
-
}); // Ensure wallet is initialized
|
|
1329
|
-
|
|
1330
|
-
_context14.next = 27;
|
|
1331
|
-
return this.userProfileClient.WalletAddress();
|
|
1332
|
-
|
|
1333
|
-
case 27:
|
|
1334
|
-
_context14.next = 36;
|
|
1081
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1082
|
+
case 0:
|
|
1083
|
+
token = _ref16.token;
|
|
1084
|
+
if (this.trustAuthorityId) {
|
|
1085
|
+
_context14.next = 3;
|
|
1335
1086
|
break;
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
_context14.next =
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1087
|
+
}
|
|
1088
|
+
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1089
|
+
case 3:
|
|
1090
|
+
wallet = this.GenerateWallet();
|
|
1091
|
+
_context14.prev = 4;
|
|
1092
|
+
if (this.kmsURIs) {
|
|
1093
|
+
_context14.next = 17;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
_context14.next = 8;
|
|
1097
|
+
return ElvClient.FromConfigurationUrl({
|
|
1098
|
+
configUrl: this.configUrl
|
|
1099
|
+
});
|
|
1100
|
+
case 8:
|
|
1101
|
+
client = _context14.sent;
|
|
1102
|
+
client.SetSigner({
|
|
1103
|
+
signer: wallet.AddAccountFromMnemonic({
|
|
1104
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
1105
|
+
})
|
|
1106
|
+
});
|
|
1107
|
+
_context14.next = 12;
|
|
1108
|
+
return client.authClient.KMSInfo({
|
|
1109
|
+
kmsId: this.trustAuthorityId
|
|
1110
|
+
});
|
|
1111
|
+
case 12:
|
|
1112
|
+
_yield$client$authCli = _context14.sent;
|
|
1113
|
+
urls = _yield$client$authCli.urls;
|
|
1114
|
+
if (!(!urls || urls.length === 0)) {
|
|
1115
|
+
_context14.next = 16;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
1119
|
+
case 16:
|
|
1120
|
+
this.kmsURIs = urls;
|
|
1121
|
+
case 17:
|
|
1122
|
+
this.oauthToken = token;
|
|
1123
|
+
path = "/ks/jwt/wlt";
|
|
1124
|
+
httpClient = new HttpClient({
|
|
1125
|
+
uris: this.kmsURIs,
|
|
1126
|
+
debug: this.debug
|
|
1127
|
+
});
|
|
1128
|
+
_context14.next = 22;
|
|
1129
|
+
return this.utils.ResponseToJson(httpClient.Request({
|
|
1130
|
+
headers: {
|
|
1131
|
+
Authorization: "Bearer ".concat(token)
|
|
1132
|
+
},
|
|
1133
|
+
method: "PUT",
|
|
1134
|
+
path: path,
|
|
1135
|
+
forceFailover: true
|
|
1136
|
+
}));
|
|
1137
|
+
case 22:
|
|
1138
|
+
response = _context14.sent;
|
|
1139
|
+
privateKey = response["UserSKHex"];
|
|
1140
|
+
this.SetSigner({
|
|
1141
|
+
signer: wallet.AddAccount({
|
|
1142
|
+
privateKey: privateKey
|
|
1143
|
+
})
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// Ensure wallet is initialized
|
|
1147
|
+
_context14.next = 27;
|
|
1148
|
+
return this.userProfileClient.WalletAddress();
|
|
1149
|
+
case 27:
|
|
1150
|
+
_context14.next = 36;
|
|
1151
|
+
break;
|
|
1152
|
+
case 29:
|
|
1153
|
+
_context14.prev = 29;
|
|
1154
|
+
_context14.t0 = _context14["catch"](4);
|
|
1155
|
+
this.Log("Failed to set signer from OAuth token:", true);
|
|
1156
|
+
this.Log(_context14.t0, true);
|
|
1157
|
+
_context14.next = 35;
|
|
1158
|
+
return this.ClearSigner();
|
|
1159
|
+
case 35:
|
|
1160
|
+
throw _context14.t0;
|
|
1161
|
+
case 36:
|
|
1162
|
+
case "end":
|
|
1163
|
+
return _context14.stop();
|
|
1352
1164
|
}
|
|
1353
1165
|
}, _callee14, this, [[4, 29]]);
|
|
1354
1166
|
}));
|
|
1355
|
-
|
|
1356
1167
|
function SetSignerFromOauthToken(_x10) {
|
|
1357
1168
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1358
1169
|
}
|
|
1359
|
-
|
|
1360
1170
|
return SetSignerFromOauthToken;
|
|
1361
1171
|
}()
|
|
1362
1172
|
/**
|
|
@@ -1366,30 +1176,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1366
1176
|
* @namedParams
|
|
1367
1177
|
* @param {string=} token - The static token to use. If not provided, the default static token will be set.
|
|
1368
1178
|
*/
|
|
1369
|
-
|
|
1370
1179
|
}, {
|
|
1371
1180
|
key: "SetStaticToken",
|
|
1372
1181
|
value: function SetStaticToken() {
|
|
1373
1182
|
var _ref17 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1374
|
-
|
|
1375
|
-
|
|
1183
|
+
token = _ref17.token;
|
|
1376
1184
|
if (!token) {
|
|
1377
1185
|
token = this.utils.B64(JSON.stringify({
|
|
1378
1186
|
qspace_id: this.contentSpaceId
|
|
1379
1187
|
}));
|
|
1380
1188
|
}
|
|
1381
|
-
|
|
1382
1189
|
this.staticToken = token;
|
|
1383
1190
|
}
|
|
1191
|
+
|
|
1384
1192
|
/**
|
|
1385
1193
|
* Clear the set static token for the client
|
|
1386
1194
|
*/
|
|
1387
|
-
|
|
1388
1195
|
}, {
|
|
1389
1196
|
key: "ClearStaticToken",
|
|
1390
1197
|
value: function ClearStaticToken() {
|
|
1391
1198
|
this.staticToken = undefined;
|
|
1392
1199
|
}
|
|
1200
|
+
|
|
1393
1201
|
/**
|
|
1394
1202
|
* Authorize the client against the specified policy.
|
|
1395
1203
|
*
|
|
@@ -1399,43 +1207,35 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1399
1207
|
* @namedParams
|
|
1400
1208
|
* @param {string} objectId - The ID of the policy object
|
|
1401
1209
|
*/
|
|
1402
|
-
|
|
1403
1210
|
}, {
|
|
1404
1211
|
key: "SetPolicyAuthorization",
|
|
1405
1212
|
value: function () {
|
|
1406
1213
|
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref18) {
|
|
1407
1214
|
var objectId;
|
|
1408
1215
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1409
|
-
while (1) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
_context15.t1
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
case 7:
|
|
1428
|
-
case "end":
|
|
1429
|
-
return _context15.stop();
|
|
1430
|
-
}
|
|
1216
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1217
|
+
case 0:
|
|
1218
|
+
objectId = _ref18.objectId;
|
|
1219
|
+
_context15.t0 = this;
|
|
1220
|
+
_context15.next = 4;
|
|
1221
|
+
return this.GenerateStateChannelToken({
|
|
1222
|
+
objectId: objectId
|
|
1223
|
+
});
|
|
1224
|
+
case 4:
|
|
1225
|
+
_context15.t1 = _context15.sent;
|
|
1226
|
+
_context15.t2 = {
|
|
1227
|
+
token: _context15.t1
|
|
1228
|
+
};
|
|
1229
|
+
_context15.t0.SetStaticToken.call(_context15.t0, _context15.t2);
|
|
1230
|
+
case 7:
|
|
1231
|
+
case "end":
|
|
1232
|
+
return _context15.stop();
|
|
1431
1233
|
}
|
|
1432
1234
|
}, _callee15, this);
|
|
1433
1235
|
}));
|
|
1434
|
-
|
|
1435
1236
|
function SetPolicyAuthorization(_x11) {
|
|
1436
1237
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1437
1238
|
}
|
|
1438
|
-
|
|
1439
1239
|
return SetPolicyAuthorization;
|
|
1440
1240
|
}()
|
|
1441
1241
|
/**
|
|
@@ -1444,35 +1244,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1444
1244
|
* @param {string} string - The string to sign
|
|
1445
1245
|
* @return {Promise<string>} - The signed string
|
|
1446
1246
|
*/
|
|
1447
|
-
|
|
1448
1247
|
}, {
|
|
1449
1248
|
key: "Sign",
|
|
1450
1249
|
value: function () {
|
|
1451
1250
|
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(string) {
|
|
1452
1251
|
var signature;
|
|
1453
1252
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1454
|
-
while (1) {
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
case 4:
|
|
1465
|
-
case "end":
|
|
1466
|
-
return _context16.stop();
|
|
1467
|
-
}
|
|
1253
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1254
|
+
case 0:
|
|
1255
|
+
_context16.next = 2;
|
|
1256
|
+
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1257
|
+
case 2:
|
|
1258
|
+
signature = _context16.sent;
|
|
1259
|
+
return _context16.abrupt("return", this.utils.FormatSignature(signature));
|
|
1260
|
+
case 4:
|
|
1261
|
+
case "end":
|
|
1262
|
+
return _context16.stop();
|
|
1468
1263
|
}
|
|
1469
1264
|
}, _callee16, this);
|
|
1470
1265
|
}));
|
|
1471
|
-
|
|
1472
1266
|
function Sign(_x12) {
|
|
1473
1267
|
return _Sign.apply(this, arguments);
|
|
1474
1268
|
}
|
|
1475
|
-
|
|
1476
1269
|
return Sign;
|
|
1477
1270
|
}()
|
|
1478
1271
|
/**
|
|
@@ -1484,45 +1277,35 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1484
1277
|
*
|
|
1485
1278
|
* @return {Promise<string>} - The encrypted message
|
|
1486
1279
|
*/
|
|
1487
|
-
|
|
1488
1280
|
}, {
|
|
1489
1281
|
key: "EncryptECIES",
|
|
1490
1282
|
value: function () {
|
|
1491
1283
|
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref19) {
|
|
1492
1284
|
var message, publicKey;
|
|
1493
1285
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1494
|
-
while (1) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
case 6:
|
|
1512
|
-
return _context17.abrupt("return", _context17.sent);
|
|
1513
|
-
|
|
1514
|
-
case 7:
|
|
1515
|
-
case "end":
|
|
1516
|
-
return _context17.stop();
|
|
1517
|
-
}
|
|
1286
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1287
|
+
case 0:
|
|
1288
|
+
message = _ref19.message, publicKey = _ref19.publicKey;
|
|
1289
|
+
if (this.signer) {
|
|
1290
|
+
_context17.next = 3;
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
throw "Signer not set";
|
|
1294
|
+
case 3:
|
|
1295
|
+
ValidatePresence("message", message);
|
|
1296
|
+
_context17.next = 6;
|
|
1297
|
+
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1298
|
+
case 6:
|
|
1299
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1300
|
+
case 7:
|
|
1301
|
+
case "end":
|
|
1302
|
+
return _context17.stop();
|
|
1518
1303
|
}
|
|
1519
1304
|
}, _callee17, this);
|
|
1520
1305
|
}));
|
|
1521
|
-
|
|
1522
1306
|
function EncryptECIES(_x13) {
|
|
1523
1307
|
return _EncryptECIES.apply(this, arguments);
|
|
1524
1308
|
}
|
|
1525
|
-
|
|
1526
1309
|
return EncryptECIES;
|
|
1527
1310
|
}()
|
|
1528
1311
|
/**
|
|
@@ -1533,45 +1316,35 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1533
1316
|
*
|
|
1534
1317
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1535
1318
|
*/
|
|
1536
|
-
|
|
1537
1319
|
}, {
|
|
1538
1320
|
key: "DecryptECIES",
|
|
1539
1321
|
value: function () {
|
|
1540
1322
|
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref20) {
|
|
1541
1323
|
var message;
|
|
1542
1324
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1543
|
-
while (1) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
case 6:
|
|
1561
|
-
return _context18.abrupt("return", _context18.sent);
|
|
1562
|
-
|
|
1563
|
-
case 7:
|
|
1564
|
-
case "end":
|
|
1565
|
-
return _context18.stop();
|
|
1566
|
-
}
|
|
1325
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1326
|
+
case 0:
|
|
1327
|
+
message = _ref20.message;
|
|
1328
|
+
if (this.signer) {
|
|
1329
|
+
_context18.next = 3;
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
throw "Signer not set";
|
|
1333
|
+
case 3:
|
|
1334
|
+
ValidatePresence("message", message);
|
|
1335
|
+
_context18.next = 6;
|
|
1336
|
+
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1337
|
+
case 6:
|
|
1338
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1339
|
+
case 7:
|
|
1340
|
+
case "end":
|
|
1341
|
+
return _context18.stop();
|
|
1567
1342
|
}
|
|
1568
1343
|
}, _callee18, this);
|
|
1569
1344
|
}));
|
|
1570
|
-
|
|
1571
1345
|
function DecryptECIES(_x14) {
|
|
1572
1346
|
return _DecryptECIES.apply(this, arguments);
|
|
1573
1347
|
}
|
|
1574
|
-
|
|
1575
1348
|
return DecryptECIES;
|
|
1576
1349
|
}()
|
|
1577
1350
|
/**
|
|
@@ -1585,157 +1358,129 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1585
1358
|
*
|
|
1586
1359
|
* @return {Promise<*>} - Response in the specified format
|
|
1587
1360
|
*/
|
|
1588
|
-
|
|
1589
1361
|
}, {
|
|
1590
1362
|
key: "Request",
|
|
1591
1363
|
value: function () {
|
|
1592
1364
|
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref21) {
|
|
1593
1365
|
var url, _ref21$format, format, _ref21$method, method, _ref21$headers, headers, body;
|
|
1594
|
-
|
|
1595
1366
|
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1596
|
-
while (1) {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
case "end":
|
|
1608
|
-
return _context19.stop();
|
|
1609
|
-
}
|
|
1367
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1368
|
+
case 0:
|
|
1369
|
+
url = _ref21.url, _ref21$format = _ref21.format, format = _ref21$format === void 0 ? "json" : _ref21$format, _ref21$method = _ref21.method, method = _ref21$method === void 0 ? "GET" : _ref21$method, _ref21$headers = _ref21.headers, headers = _ref21$headers === void 0 ? {} : _ref21$headers, body = _ref21.body;
|
|
1370
|
+
return _context19.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1371
|
+
method: method,
|
|
1372
|
+
headers: headers,
|
|
1373
|
+
body: body
|
|
1374
|
+
})));
|
|
1375
|
+
case 2:
|
|
1376
|
+
case "end":
|
|
1377
|
+
return _context19.stop();
|
|
1610
1378
|
}
|
|
1611
1379
|
}, _callee19, this);
|
|
1612
1380
|
}));
|
|
1613
|
-
|
|
1614
1381
|
function Request(_x15) {
|
|
1615
1382
|
return _Request.apply(this, arguments);
|
|
1616
1383
|
}
|
|
1617
|
-
|
|
1618
1384
|
return Request;
|
|
1619
1385
|
}()
|
|
1620
1386
|
/* FrameClient related */
|
|
1621
1387
|
// Whitelist of methods allowed to be called using the frame API
|
|
1622
|
-
|
|
1623
1388
|
}, {
|
|
1624
1389
|
key: "FrameAllowedMethods",
|
|
1625
1390
|
value: function FrameAllowedMethods() {
|
|
1626
1391
|
var _this2 = this;
|
|
1627
|
-
|
|
1628
1392
|
var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
|
|
1629
1393
|
return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
|
|
1630
1394
|
return typeof _this2[method] === "function" && !forbiddenMethods.includes(method);
|
|
1631
1395
|
});
|
|
1632
|
-
}
|
|
1396
|
+
}
|
|
1633
1397
|
|
|
1398
|
+
// Call a method specified in a message from a frame
|
|
1634
1399
|
}, {
|
|
1635
1400
|
key: "CallFromFrameMessage",
|
|
1636
1401
|
value: function () {
|
|
1637
1402
|
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(message, Respond) {
|
|
1638
1403
|
var _this3 = this;
|
|
1639
|
-
|
|
1640
1404
|
var callback, method, methodResults, responseError;
|
|
1641
1405
|
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1642
|
-
while (1) {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
_context20.next = 2;
|
|
1647
|
-
break;
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
return _context20.abrupt("return");
|
|
1651
|
-
|
|
1652
|
-
case 2:
|
|
1653
|
-
if (message.callbackId) {
|
|
1654
|
-
callback = function callback(result) {
|
|
1655
|
-
Respond(_this3.utils.MakeClonable({
|
|
1656
|
-
type: "ElvFrameResponse",
|
|
1657
|
-
requestId: message.callbackId,
|
|
1658
|
-
response: result
|
|
1659
|
-
}));
|
|
1660
|
-
};
|
|
1661
|
-
|
|
1662
|
-
message.args.callback = callback;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
_context20.prev = 3;
|
|
1666
|
-
method = message.calledMethod;
|
|
1667
|
-
|
|
1668
|
-
if (!(message.module === "userProfileClient")) {
|
|
1669
|
-
_context20.next = 13;
|
|
1670
|
-
break;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1674
|
-
_context20.next = 8;
|
|
1675
|
-
break;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
throw Error("Invalid user profile method: " + method);
|
|
1679
|
-
|
|
1680
|
-
case 8:
|
|
1681
|
-
_context20.next = 10;
|
|
1682
|
-
return this.userProfileClient[method](message.args);
|
|
1683
|
-
|
|
1684
|
-
case 10:
|
|
1685
|
-
methodResults = _context20.sent;
|
|
1686
|
-
_context20.next = 18;
|
|
1406
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1407
|
+
case 0:
|
|
1408
|
+
if (!(message.type !== "ElvFrameRequest")) {
|
|
1409
|
+
_context20.next = 2;
|
|
1687
1410
|
break;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
Respond(this.utils.MakeClonable({
|
|
1706
|
-
type: "ElvFrameResponse",
|
|
1707
|
-
requestId: message.requestId,
|
|
1708
|
-
response: methodResults
|
|
1709
|
-
}));
|
|
1710
|
-
_context20.next = 27;
|
|
1411
|
+
}
|
|
1412
|
+
return _context20.abrupt("return");
|
|
1413
|
+
case 2:
|
|
1414
|
+
if (message.callbackId) {
|
|
1415
|
+
callback = function callback(result) {
|
|
1416
|
+
Respond(_this3.utils.MakeClonable({
|
|
1417
|
+
type: "ElvFrameResponse",
|
|
1418
|
+
requestId: message.callbackId,
|
|
1419
|
+
response: result
|
|
1420
|
+
}));
|
|
1421
|
+
};
|
|
1422
|
+
message.args.callback = callback;
|
|
1423
|
+
}
|
|
1424
|
+
_context20.prev = 3;
|
|
1425
|
+
method = message.calledMethod;
|
|
1426
|
+
if (!(message.module === "userProfileClient")) {
|
|
1427
|
+
_context20.next = 13;
|
|
1711
1428
|
break;
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
_context20.
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1429
|
+
}
|
|
1430
|
+
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1431
|
+
_context20.next = 8;
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
throw Error("Invalid user profile method: " + method);
|
|
1435
|
+
case 8:
|
|
1436
|
+
_context20.next = 10;
|
|
1437
|
+
return this.userProfileClient[method](message.args);
|
|
1438
|
+
case 10:
|
|
1439
|
+
methodResults = _context20.sent;
|
|
1440
|
+
_context20.next = 18;
|
|
1441
|
+
break;
|
|
1442
|
+
case 13:
|
|
1443
|
+
if (this.FrameAllowedMethods().includes(method)) {
|
|
1444
|
+
_context20.next = 15;
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
throw Error("Invalid method: " + method);
|
|
1448
|
+
case 15:
|
|
1449
|
+
_context20.next = 17;
|
|
1450
|
+
return this[method](message.args);
|
|
1451
|
+
case 17:
|
|
1452
|
+
methodResults = _context20.sent;
|
|
1453
|
+
case 18:
|
|
1454
|
+
Respond(this.utils.MakeClonable({
|
|
1455
|
+
type: "ElvFrameResponse",
|
|
1456
|
+
requestId: message.requestId,
|
|
1457
|
+
response: methodResults
|
|
1458
|
+
}));
|
|
1459
|
+
_context20.next = 27;
|
|
1460
|
+
break;
|
|
1461
|
+
case 21:
|
|
1462
|
+
_context20.prev = 21;
|
|
1463
|
+
_context20.t0 = _context20["catch"](3);
|
|
1464
|
+
// eslint-disable-next-line no-console
|
|
1465
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context20.t0) === "object" ? JSON.stringify(_context20.t0, null, 2) : _context20.t0), true);
|
|
1466
|
+
|
|
1467
|
+
// eslint-disable-next-line no-console
|
|
1468
|
+
console.error(_context20.t0);
|
|
1469
|
+
responseError = _context20.t0 instanceof Error ? _context20.t0.message : _context20.t0;
|
|
1470
|
+
Respond(this.utils.MakeClonable({
|
|
1471
|
+
type: "ElvFrameResponse",
|
|
1472
|
+
requestId: message.requestId,
|
|
1473
|
+
error: responseError
|
|
1474
|
+
}));
|
|
1475
|
+
case 27:
|
|
1476
|
+
case "end":
|
|
1477
|
+
return _context20.stop();
|
|
1731
1478
|
}
|
|
1732
1479
|
}, _callee20, this, [[3, 21]]);
|
|
1733
1480
|
}));
|
|
1734
|
-
|
|
1735
1481
|
function CallFromFrameMessage(_x16, _x17) {
|
|
1736
1482
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1737
1483
|
}
|
|
1738
|
-
|
|
1739
1484
|
return CallFromFrameMessage;
|
|
1740
1485
|
}()
|
|
1741
1486
|
}], [{
|
|
@@ -1743,85 +1488,67 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1743
1488
|
value: function () {
|
|
1744
1489
|
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref22) {
|
|
1745
1490
|
var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
|
|
1746
|
-
|
|
1747
1491
|
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1748
|
-
while (1) {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
case 20:
|
|
1805
|
-
_context21.prev = 20;
|
|
1806
|
-
_context21.t0 = _context21["catch"](1);
|
|
1807
|
-
// eslint-disable-next-line no-console
|
|
1808
|
-
console.error("Error retrieving fabric configuration:"); // eslint-disable-next-line no-console
|
|
1809
|
-
|
|
1810
|
-
console.error(_context21.t0);
|
|
1811
|
-
throw _context21.t0;
|
|
1812
|
-
|
|
1813
|
-
case 25:
|
|
1814
|
-
case "end":
|
|
1815
|
-
return _context21.stop();
|
|
1816
|
-
}
|
|
1492
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1493
|
+
case 0:
|
|
1494
|
+
configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
|
|
1495
|
+
_context21.prev = 1;
|
|
1496
|
+
uri = new URI(configUrl);
|
|
1497
|
+
uri.pathname("/config");
|
|
1498
|
+
if (region) {
|
|
1499
|
+
uri.addSearch("elvgeo", region);
|
|
1500
|
+
}
|
|
1501
|
+
_context21.next = 7;
|
|
1502
|
+
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1503
|
+
case 7:
|
|
1504
|
+
fabricInfo = _context21.sent;
|
|
1505
|
+
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1506
|
+
filterHTTPS = function filterHTTPS(uri) {
|
|
1507
|
+
return uri.toLowerCase().startsWith("https");
|
|
1508
|
+
};
|
|
1509
|
+
fabricURIs = fabricInfo.network.services.fabric_api;
|
|
1510
|
+
if (fabricURIs.find(filterHTTPS)) {
|
|
1511
|
+
fabricURIs = fabricURIs.filter(filterHTTPS);
|
|
1512
|
+
}
|
|
1513
|
+
ethereumURIs = fabricInfo.network.services.ethereum_api;
|
|
1514
|
+
if (ethereumURIs.find(filterHTTPS)) {
|
|
1515
|
+
ethereumURIs = ethereumURIs.filter(filterHTTPS);
|
|
1516
|
+
}
|
|
1517
|
+
authServiceURIs = fabricInfo.network.services.authority_service || [];
|
|
1518
|
+
if (authServiceURIs.find(filterHTTPS)) {
|
|
1519
|
+
authServiceURIs = authServiceURIs.filter(filterHTTPS);
|
|
1520
|
+
}
|
|
1521
|
+
searchURIs = fabricInfo.network.services.search || [];
|
|
1522
|
+
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1523
|
+
return _context21.abrupt("return", {
|
|
1524
|
+
nodeId: fabricInfo.node_id,
|
|
1525
|
+
contentSpaceId: fabricInfo.qspace.id,
|
|
1526
|
+
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
1527
|
+
networkName: ((fabricInfo.qspace || {}).names || [])[0],
|
|
1528
|
+
fabricURIs: fabricURIs,
|
|
1529
|
+
ethereumURIs: ethereumURIs,
|
|
1530
|
+
authServiceURIs: authServiceURIs,
|
|
1531
|
+
kmsURIs: kmsUrls,
|
|
1532
|
+
searchURIs: searchURIs,
|
|
1533
|
+
fabricVersion: fabricVersion
|
|
1534
|
+
});
|
|
1535
|
+
case 20:
|
|
1536
|
+
_context21.prev = 20;
|
|
1537
|
+
_context21.t0 = _context21["catch"](1);
|
|
1538
|
+
// eslint-disable-next-line no-console
|
|
1539
|
+
console.error("Error retrieving fabric configuration:");
|
|
1540
|
+
// eslint-disable-next-line no-console
|
|
1541
|
+
console.error(_context21.t0);
|
|
1542
|
+
throw _context21.t0;
|
|
1543
|
+
case 25:
|
|
1544
|
+
case "end":
|
|
1545
|
+
return _context21.stop();
|
|
1817
1546
|
}
|
|
1818
1547
|
}, _callee21, null, [[1, 20]]);
|
|
1819
1548
|
}));
|
|
1820
|
-
|
|
1821
1549
|
function Configuration(_x18) {
|
|
1822
1550
|
return _Configuration.apply(this, arguments);
|
|
1823
1551
|
}
|
|
1824
|
-
|
|
1825
1552
|
return Configuration;
|
|
1826
1553
|
}()
|
|
1827
1554
|
/**
|
|
@@ -1839,55 +1566,44 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1839
1566
|
*
|
|
1840
1567
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
1841
1568
|
*/
|
|
1842
|
-
|
|
1843
1569
|
}, {
|
|
1844
1570
|
key: "FromNetworkName",
|
|
1845
1571
|
value: function () {
|
|
1846
1572
|
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref23) {
|
|
1847
1573
|
var networkName, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
|
|
1848
|
-
|
|
1849
1574
|
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1850
|
-
while (1) {
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
case 6:
|
|
1877
|
-
return _context22.abrupt("return", _context22.sent);
|
|
1878
|
-
|
|
1879
|
-
case 7:
|
|
1880
|
-
case "end":
|
|
1881
|
-
return _context22.stop();
|
|
1882
|
-
}
|
|
1575
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1576
|
+
case 0:
|
|
1577
|
+
networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
|
|
1578
|
+
configUrl = networks[networkName];
|
|
1579
|
+
if (configUrl) {
|
|
1580
|
+
_context22.next = 4;
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
throw Error("Invalid network name: " + networkName);
|
|
1584
|
+
case 4:
|
|
1585
|
+
_context22.next = 6;
|
|
1586
|
+
return this.FromConfigurationUrl({
|
|
1587
|
+
configUrl: configUrl,
|
|
1588
|
+
region: region,
|
|
1589
|
+
trustAuthorityId: trustAuthorityId,
|
|
1590
|
+
staticToken: staticToken,
|
|
1591
|
+
ethereumContractTimeout: ethereumContractTimeout,
|
|
1592
|
+
noCache: noCache,
|
|
1593
|
+
noAuth: noAuth,
|
|
1594
|
+
assumeV3: assumeV3
|
|
1595
|
+
});
|
|
1596
|
+
case 6:
|
|
1597
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1598
|
+
case 7:
|
|
1599
|
+
case "end":
|
|
1600
|
+
return _context22.stop();
|
|
1883
1601
|
}
|
|
1884
1602
|
}, _callee22, this);
|
|
1885
1603
|
}));
|
|
1886
|
-
|
|
1887
1604
|
function FromNetworkName(_x19) {
|
|
1888
1605
|
return _FromNetworkName.apply(this, arguments);
|
|
1889
1606
|
}
|
|
1890
|
-
|
|
1891
1607
|
return FromNetworkName;
|
|
1892
1608
|
}()
|
|
1893
1609
|
/**
|
|
@@ -1905,72 +1621,62 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1905
1621
|
*
|
|
1906
1622
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
1907
1623
|
*/
|
|
1908
|
-
|
|
1909
1624
|
}, {
|
|
1910
1625
|
key: "FromConfigurationUrl",
|
|
1911
1626
|
value: function () {
|
|
1912
1627
|
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref24) {
|
|
1913
1628
|
var configUrl, region, trustAuthorityId, staticToken, _ref24$ethereumContra, ethereumContractTimeout, _ref24$noCache, noCache, _ref24$noAuth, noAuth, _ref24$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion, client;
|
|
1914
|
-
|
|
1915
1629
|
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1916
|
-
while (1) {
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
case 15:
|
|
1956
|
-
case "end":
|
|
1957
|
-
return _context23.stop();
|
|
1958
|
-
}
|
|
1630
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1631
|
+
case 0:
|
|
1632
|
+
configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
|
|
1633
|
+
_context23.next = 3;
|
|
1634
|
+
return ElvClient.Configuration({
|
|
1635
|
+
configUrl: configUrl,
|
|
1636
|
+
region: region
|
|
1637
|
+
});
|
|
1638
|
+
case 3:
|
|
1639
|
+
_yield$ElvClient$Conf3 = _context23.sent;
|
|
1640
|
+
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
1641
|
+
networkId = _yield$ElvClient$Conf3.networkId;
|
|
1642
|
+
networkName = _yield$ElvClient$Conf3.networkName;
|
|
1643
|
+
fabricURIs = _yield$ElvClient$Conf3.fabricURIs;
|
|
1644
|
+
ethereumURIs = _yield$ElvClient$Conf3.ethereumURIs;
|
|
1645
|
+
authServiceURIs = _yield$ElvClient$Conf3.authServiceURIs;
|
|
1646
|
+
searchURIs = _yield$ElvClient$Conf3.searchURIs;
|
|
1647
|
+
fabricVersion = _yield$ElvClient$Conf3.fabricVersion;
|
|
1648
|
+
client = new ElvClient({
|
|
1649
|
+
contentSpaceId: contentSpaceId,
|
|
1650
|
+
networkId: networkId,
|
|
1651
|
+
networkName: networkName,
|
|
1652
|
+
fabricVersion: fabricVersion,
|
|
1653
|
+
fabricURIs: fabricURIs,
|
|
1654
|
+
ethereumURIs: ethereumURIs,
|
|
1655
|
+
authServiceURIs: authServiceURIs,
|
|
1656
|
+
searchURIs: searchURIs,
|
|
1657
|
+
ethereumContractTimeout: ethereumContractTimeout,
|
|
1658
|
+
trustAuthorityId: trustAuthorityId,
|
|
1659
|
+
staticToken: staticToken,
|
|
1660
|
+
noCache: noCache,
|
|
1661
|
+
noAuth: noAuth,
|
|
1662
|
+
assumeV3: assumeV3
|
|
1663
|
+
});
|
|
1664
|
+
client.configUrl = configUrl;
|
|
1665
|
+
return _context23.abrupt("return", client);
|
|
1666
|
+
case 15:
|
|
1667
|
+
case "end":
|
|
1668
|
+
return _context23.stop();
|
|
1959
1669
|
}
|
|
1960
1670
|
}, _callee23);
|
|
1961
1671
|
}));
|
|
1962
|
-
|
|
1963
1672
|
function FromConfigurationUrl(_x20) {
|
|
1964
1673
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
1965
1674
|
}
|
|
1966
|
-
|
|
1967
1675
|
return FromConfigurationUrl;
|
|
1968
1676
|
}()
|
|
1969
1677
|
}]);
|
|
1970
|
-
|
|
1971
1678
|
return ElvClient;
|
|
1972
1679
|
}();
|
|
1973
|
-
|
|
1974
1680
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
1975
1681
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|
|
1976
1682
|
Object.assign(ElvClient.prototype, require("./client/Contracts"));
|