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