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