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