@eluvio/elv-client-js 3.1.96 → 3.1.97

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.
@@ -1,7 +1,5 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
 
3
- var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
-
5
3
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
6
4
 
7
5
  var _createClass = require("@babel/runtime/helpers/createClass");
@@ -10,9 +8,9 @@ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
10
8
 
11
9
  var _v, _v2;
12
10
 
13
- 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; }
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
14
12
 
15
- 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; }
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
14
 
17
15
  var HttpClient = require("./HttpClient");
18
16
 
@@ -54,9 +52,19 @@ var CONTRACTS = {
54
52
  v3: (_v2 = {}, _defineProperty(_v2, ACCESS_TYPES.SPACE, require("./contracts/v3/BaseContentSpace")), _defineProperty(_v2, ACCESS_TYPES.LIBRARY, require("./contracts/v3/BaseLibrary")), _defineProperty(_v2, ACCESS_TYPES.TYPE, require("./contracts/v3/BaseContentType")), _defineProperty(_v2, ACCESS_TYPES.OBJECT, require("./contracts/v3/BaseContent")), _defineProperty(_v2, ACCESS_TYPES.WALLET, require("./contracts/v3/BaseAccessWallet")), _defineProperty(_v2, ACCESS_TYPES.GROUP, require("./contracts/v3/BaseAccessControlGroup")), _defineProperty(_v2, ACCESS_TYPES.ACCESSIBLE, require("./contracts/v3/Accessible")), _defineProperty(_v2, ACCESS_TYPES.EDITABLE, require("./contracts/v3/Editable")), _defineProperty(_v2, ACCESS_TYPES.TENANT, require("./contracts/v3/BaseTenantSpace")), _v2)
55
53
  };
56
54
 
57
- var AuthorizationClient = /*#__PURE__*/function () {
55
+ var AuthorizationClient =
56
+ /*#__PURE__*/
57
+ function () {
58
58
  "use strict";
59
59
 
60
+ _createClass(AuthorizationClient, [{
61
+ key: "Log",
62
+ value: function Log(message) {
63
+ var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
64
+ LogMessage(this, message, error);
65
+ }
66
+ }]);
67
+
60
68
  function AuthorizationClient(_ref) {
61
69
  var client = _ref.client,
62
70
  contentSpaceId = _ref.contentSpaceId,
@@ -90,12 +98,6 @@ var AuthorizationClient = /*#__PURE__*/function () {
90
98
  }
91
99
 
92
100
  _createClass(AuthorizationClient, [{
93
- key: "Log",
94
- value: function Log(message) {
95
- var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
96
- LogMessage(this, message, error);
97
- }
98
- }, {
99
101
  key: "CreateStaticToken",
100
102
  value: function CreateStaticToken(_ref2) {
101
103
  var libraryId = _ref2.libraryId;
@@ -112,729 +114,681 @@ var AuthorizationClient = /*#__PURE__*/function () {
112
114
 
113
115
  }, {
114
116
  key: "AuthorizationHeader",
115
- value: function () {
116
- var _AuthorizationHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
117
- var authorizationToken, headers;
118
- return _regeneratorRuntime.wrap(function _callee$(_context) {
119
- while (1) {
120
- switch (_context.prev = _context.next) {
121
- case 0:
122
- _context.next = 2;
123
- return this.AuthorizationToken(params);
124
-
125
- case 2:
126
- authorizationToken = _context.sent;
127
- headers = {
128
- Authorization: "Bearer " + authorizationToken
129
- };
130
-
131
- if (params.encryption && params.encryption !== "none") {
132
- headers["X-Content-Fabric-Encryption-Scheme"] = params.encryption;
133
- }
134
-
135
- return _context.abrupt("return", headers);
136
-
137
- case 6:
138
- case "end":
139
- return _context.stop();
140
- }
117
+ value: function AuthorizationHeader(params) {
118
+ var authorizationToken, headers;
119
+ return _regeneratorRuntime.async(function AuthorizationHeader$(_context) {
120
+ while (1) {
121
+ switch (_context.prev = _context.next) {
122
+ case 0:
123
+ _context.next = 2;
124
+ return _regeneratorRuntime.awrap(this.AuthorizationToken(params));
125
+
126
+ case 2:
127
+ authorizationToken = _context.sent;
128
+ headers = {
129
+ Authorization: "Bearer " + authorizationToken
130
+ };
131
+
132
+ if (params.encryption && params.encryption !== "none") {
133
+ headers["X-Content-Fabric-Encryption-Scheme"] = params.encryption;
134
+ }
135
+
136
+ return _context.abrupt("return", headers);
137
+
138
+ case 6:
139
+ case "end":
140
+ return _context.stop();
141
141
  }
142
- }, _callee, this);
143
- }));
144
-
145
- function AuthorizationHeader(_x) {
146
- return _AuthorizationHeader.apply(this, arguments);
147
- }
148
-
149
- return AuthorizationHeader;
150
- }()
142
+ }
143
+ }, null, this);
144
+ }
151
145
  }, {
152
146
  key: "AuthorizationToken",
153
- value: function () {
154
- var _AuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
155
- var libraryId, objectId, versionHash, partHash, encryption, audienceData, context, _ref3$update, update, _ref3$channelAuth, channelAuth, oauthToken, _ref3$noCache, noCache, _ref3$noAuth, noAuth, isWalletRequest, initialNoCache, authorizationToken;
156
-
157
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
158
- while (1) {
159
- switch (_context2.prev = _context2.next) {
160
- case 0:
161
- libraryId = _ref3.libraryId, objectId = _ref3.objectId, versionHash = _ref3.versionHash, partHash = _ref3.partHash, encryption = _ref3.encryption, audienceData = _ref3.audienceData, context = _ref3.context, _ref3$update = _ref3.update, update = _ref3$update === void 0 ? false : _ref3$update, _ref3$channelAuth = _ref3.channelAuth, channelAuth = _ref3$channelAuth === void 0 ? false : _ref3$channelAuth, oauthToken = _ref3.oauthToken, _ref3$noCache = _ref3.noCache, noCache = _ref3$noCache === void 0 ? false : _ref3$noCache, _ref3$noAuth = _ref3.noAuth, noAuth = _ref3$noAuth === void 0 ? false : _ref3$noAuth;
162
-
163
- if (versionHash) {
164
- objectId = this.client.utils.DecodeVersionHash(versionHash).objectId;
165
- }
166
-
167
- _context2.t0 = objectId && this.client.signer;
168
-
169
- if (!_context2.t0) {
170
- _context2.next = 10;
171
- break;
172
- }
147
+ value: function AuthorizationToken(_ref3) {
148
+ var libraryId, objectId, versionHash, partHash, encryption, audienceData, context, _ref3$update, update, _ref3$channelAuth, channelAuth, oauthToken, _ref3$noCache, noCache, _ref3$noAuth, noAuth, isWalletRequest, initialNoCache, authorizationToken;
173
149
 
174
- _context2.t1 = this.client.utils;
175
- _context2.next = 7;
176
- return this.client.userProfileClient.WalletAddress(false);
177
-
178
- case 7:
179
- _context2.t2 = _context2.sent;
180
- _context2.t3 = this.client.utils.HashToAddress(objectId);
181
- _context2.t0 = _context2.t1.EqualAddress.call(_context2.t1, _context2.t2, _context2.t3);
182
-
183
- case 10:
184
- isWalletRequest = _context2.t0;
185
-
186
- if (!(this.client.staticToken && !isWalletRequest)) {
187
- _context2.next = 13;
188
- break;
189
- }
150
+ return _regeneratorRuntime.async(function AuthorizationToken$(_context2) {
151
+ while (1) {
152
+ switch (_context2.prev = _context2.next) {
153
+ case 0:
154
+ libraryId = _ref3.libraryId, objectId = _ref3.objectId, versionHash = _ref3.versionHash, partHash = _ref3.partHash, encryption = _ref3.encryption, audienceData = _ref3.audienceData, context = _ref3.context, _ref3$update = _ref3.update, update = _ref3$update === void 0 ? false : _ref3$update, _ref3$channelAuth = _ref3.channelAuth, channelAuth = _ref3$channelAuth === void 0 ? false : _ref3$channelAuth, oauthToken = _ref3.oauthToken, _ref3$noCache = _ref3.noCache, noCache = _ref3$noCache === void 0 ? false : _ref3$noCache, _ref3$noAuth = _ref3.noAuth, noAuth = _ref3$noAuth === void 0 ? false : _ref3$noAuth;
190
155
 
191
- return _context2.abrupt("return", this.client.staticToken);
156
+ if (versionHash) {
157
+ objectId = this.client.utils.DecodeVersionHash(versionHash).objectId;
158
+ }
192
159
 
193
- case 13:
194
- initialNoCache = this.noCache;
195
- _context2.prev = 14;
160
+ _context2.t0 = objectId && this.client.signer;
196
161
 
197
- // noCache enabled for this call
198
- if (noCache && !this.noCache) {
199
- this.noCache = true;
200
- }
162
+ if (!_context2.t0) {
163
+ _context2.next = 10;
164
+ break;
165
+ }
201
166
 
202
- if (channelAuth && this.client.signer && this.client.signer.remoteSigner) {
203
- // Channel auth not supported for remote signer, use a self-signed no-auth token instead
204
- noAuth = true;
205
- channelAuth = false;
206
- }
167
+ _context2.t1 = this.client.utils;
168
+ _context2.next = 7;
169
+ return _regeneratorRuntime.awrap(this.client.userProfileClient.WalletAddress(false));
207
170
 
208
- if (!channelAuth) {
209
- _context2.next = 23;
210
- break;
211
- }
171
+ case 7:
172
+ _context2.t2 = _context2.sent;
173
+ _context2.t3 = this.client.utils.HashToAddress(objectId);
174
+ _context2.t0 = _context2.t1.EqualAddress.call(_context2.t1, _context2.t2, _context2.t3);
212
175
 
213
- _context2.next = 20;
214
- return this.GenerateChannelContentToken({
215
- objectId: objectId,
216
- versionHash: versionHash,
217
- audienceData: audienceData,
218
- context: context,
219
- oauthToken: oauthToken
220
- });
176
+ case 10:
177
+ isWalletRequest = _context2.t0;
221
178
 
222
- case 20:
223
- authorizationToken = _context2.sent;
224
- _context2.next = 28;
179
+ if (!(this.client.staticToken && !isWalletRequest)) {
180
+ _context2.next = 13;
225
181
  break;
182
+ }
226
183
 
227
- case 23:
228
- if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
229
- _context2.next = 25;
230
- break;
231
- }
232
-
233
- return _context2.abrupt("return", this.CreateStaticToken({
234
- libraryId: libraryId
235
- }));
236
-
237
- case 25:
238
- _context2.next = 27;
239
- return this.GenerateAuthorizationToken({
240
- libraryId: libraryId,
241
- objectId: objectId,
242
- versionHash: versionHash,
243
- partHash: partHash,
244
- encryption: encryption,
245
- update: update,
246
- noAuth: noAuth
247
- });
248
-
249
- case 27:
250
- authorizationToken = _context2.sent;
184
+ return _context2.abrupt("return", this.client.staticToken);
251
185
 
252
- case 28:
253
- return _context2.abrupt("return", authorizationToken);
186
+ case 13:
187
+ initialNoCache = this.noCache;
188
+ _context2.prev = 14;
254
189
 
255
- case 31:
256
- _context2.prev = 31;
257
- _context2.t4 = _context2["catch"](14);
258
- throw _context2.t4;
190
+ // noCache enabled for this call
191
+ if (noCache && !this.noCache) {
192
+ this.noCache = true;
193
+ }
259
194
 
260
- case 34:
261
- _context2.prev = 34;
262
- this.noCache = initialNoCache;
263
- return _context2.finish(34);
195
+ if (channelAuth && this.client.signer && this.client.signer.remoteSigner) {
196
+ // Channel auth not supported for remote signer, use a self-signed no-auth token instead
197
+ noAuth = true;
198
+ channelAuth = false;
199
+ }
264
200
 
265
- case 37:
266
- case "end":
267
- return _context2.stop();
268
- }
201
+ if (!channelAuth) {
202
+ _context2.next = 23;
203
+ break;
204
+ }
205
+
206
+ _context2.next = 20;
207
+ return _regeneratorRuntime.awrap(this.GenerateChannelContentToken({
208
+ objectId: objectId,
209
+ versionHash: versionHash,
210
+ audienceData: audienceData,
211
+ context: context,
212
+ oauthToken: oauthToken
213
+ }));
214
+
215
+ case 20:
216
+ authorizationToken = _context2.sent;
217
+ _context2.next = 28;
218
+ break;
219
+
220
+ case 23:
221
+ if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
222
+ _context2.next = 25;
223
+ break;
224
+ }
225
+
226
+ return _context2.abrupt("return", this.CreateStaticToken({
227
+ libraryId: libraryId
228
+ }));
229
+
230
+ case 25:
231
+ _context2.next = 27;
232
+ return _regeneratorRuntime.awrap(this.GenerateAuthorizationToken({
233
+ libraryId: libraryId,
234
+ objectId: objectId,
235
+ versionHash: versionHash,
236
+ partHash: partHash,
237
+ encryption: encryption,
238
+ update: update,
239
+ noAuth: noAuth
240
+ }));
241
+
242
+ case 27:
243
+ authorizationToken = _context2.sent;
244
+
245
+ case 28:
246
+ return _context2.abrupt("return", authorizationToken);
247
+
248
+ case 31:
249
+ _context2.prev = 31;
250
+ _context2.t4 = _context2["catch"](14);
251
+ throw _context2.t4;
252
+
253
+ case 34:
254
+ _context2.prev = 34;
255
+ this.noCache = initialNoCache;
256
+ return _context2.finish(34);
257
+
258
+ case 37:
259
+ case "end":
260
+ return _context2.stop();
269
261
  }
270
- }, _callee2, this, [[14, 31, 34, 37]]);
271
- }));
272
-
273
- function AuthorizationToken(_x2) {
274
- return _AuthorizationToken.apply(this, arguments);
275
- }
276
-
277
- return AuthorizationToken;
278
- }()
262
+ }
263
+ }, null, this, [[14, 31, 34, 37]]);
264
+ }
279
265
  }, {
280
266
  key: "GenerateAuthorizationToken",
281
- value: function () {
282
- var _GenerateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
283
- var libraryId, objectId, versionHash, partHash, encryption, _ref4$update, update, _ref4$noAuth, noAuth, publicKey, owner, ownerCapKey, ownerCap, cap, token, _yield$this$MakeAcces, transactionHash, signature, multiSig;
284
-
285
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
286
- while (1) {
287
- switch (_context3.prev = _context3.next) {
288
- case 0:
289
- libraryId = _ref4.libraryId, objectId = _ref4.objectId, versionHash = _ref4.versionHash, partHash = _ref4.partHash, encryption = _ref4.encryption, _ref4$update = _ref4.update, update = _ref4$update === void 0 ? false : _ref4$update, _ref4$noAuth = _ref4.noAuth, noAuth = _ref4$noAuth === void 0 ? false : _ref4$noAuth;
290
-
291
- if (versionHash) {
292
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
293
- } // Generate AFGH public key if encryption is specified
294
-
295
-
296
- _context3.t0 = encryption && encryption !== "none" && objectId;
297
-
298
- if (!_context3.t0) {
299
- _context3.next = 9;
300
- break;
301
- }
302
-
303
- _context3.next = 6;
304
- return this.AccessType(objectId);
305
-
306
- case 6:
307
- _context3.t1 = _context3.sent;
308
- _context3.t2 = ACCESS_TYPES.OBJECT;
309
- _context3.t0 = _context3.t1 === _context3.t2;
310
-
311
- case 9:
312
- if (!_context3.t0) {
313
- _context3.next = 22;
314
- break;
315
- }
316
-
317
- _context3.next = 12;
318
- return this.Owner({
319
- id: objectId
320
- });
267
+ value: function GenerateAuthorizationToken(_ref4) {
268
+ var libraryId, objectId, versionHash, partHash, encryption, _ref4$update, update, _ref4$noAuth, noAuth, publicKey, owner, ownerCapKey, ownerCap, cap, token, _ref5, transactionHash, signature, multiSig;
321
269
 
322
- case 12:
323
- owner = _context3.sent;
324
- ownerCapKey = "eluv.caps.iusr".concat(Utils.AddressToHash(this.client.signer.address));
325
- _context3.next = 16;
326
- return this.client.ContentObjectMetadata({
327
- libraryId: libraryId,
328
- objectId: objectId,
329
- metadataSubtree: ownerCapKey
330
- });
331
-
332
- case 16:
333
- ownerCap = _context3.sent;
334
-
335
- if (!(!Utils.EqualAddress(owner, this.client.signer.address) && !ownerCap)) {
336
- _context3.next = 22;
337
- break;
338
- }
339
-
340
- _context3.next = 20;
341
- return this.ReEncryptionConk({
342
- libraryId: libraryId,
343
- objectId: objectId
344
- });
345
-
346
- case 20:
347
- cap = _context3.sent;
348
- publicKey = cap.public_key;
349
-
350
- case 22:
351
- token = {
352
- qspace_id: this.contentSpaceId,
353
- addr: Utils.FormatAddress(this.client.signer && this.client.signer.address || "")
354
- };
355
-
356
- if (this.noAuth || noAuth) {
357
- _context3.next = 29;
358
- break;
359
- }
360
-
361
- _context3.next = 26;
362
- return this.MakeAccessRequest({
363
- libraryId: libraryId,
364
- objectId: objectId,
365
- versionHash: versionHash,
366
- update: update,
367
- publicKey: publicKey,
368
- noCache: this.noCache,
369
- noAuth: this.noAuth || noAuth
370
- });
270
+ return _regeneratorRuntime.async(function GenerateAuthorizationToken$(_context3) {
271
+ while (1) {
272
+ switch (_context3.prev = _context3.next) {
273
+ case 0:
274
+ libraryId = _ref4.libraryId, objectId = _ref4.objectId, versionHash = _ref4.versionHash, partHash = _ref4.partHash, encryption = _ref4.encryption, _ref4$update = _ref4.update, update = _ref4$update === void 0 ? false : _ref4$update, _ref4$noAuth = _ref4.noAuth, noAuth = _ref4$noAuth === void 0 ? false : _ref4$noAuth;
371
275
 
372
- case 26:
373
- _yield$this$MakeAcces = _context3.sent;
374
- transactionHash = _yield$this$MakeAcces.transactionHash;
276
+ if (versionHash) {
277
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
278
+ } // Generate AFGH public key if encryption is specified
375
279
 
376
- if (transactionHash) {
377
- token.tx_id = transactionHash;
378
- }
379
-
380
- case 29:
381
- if (libraryId) {
382
- token.qlib_id = libraryId;
383
- }
384
280
 
385
- if (partHash) {
386
- token.qphash = partHash;
387
- }
281
+ _context3.t0 = encryption && encryption !== "none" && objectId;
388
282
 
389
- if (publicKey) {
390
- token.afgh_pk = publicKey;
391
- }
283
+ if (!_context3.t0) {
284
+ _context3.next = 9;
285
+ break;
286
+ }
392
287
 
393
- token = Utils.B64(JSON.stringify(token));
394
- _context3.next = 35;
395
- return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(token)));
288
+ _context3.next = 6;
289
+ return _regeneratorRuntime.awrap(this.AccessType(objectId));
396
290
 
397
- case 35:
398
- signature = _context3.sent;
399
- multiSig = Utils.FormatSignature(signature);
400
- return _context3.abrupt("return", "".concat(token, ".").concat(Utils.B64(multiSig)));
291
+ case 6:
292
+ _context3.t1 = _context3.sent;
293
+ _context3.t2 = ACCESS_TYPES.OBJECT;
294
+ _context3.t0 = _context3.t1 === _context3.t2;
401
295
 
402
- case 38:
403
- case "end":
404
- return _context3.stop();
405
- }
296
+ case 9:
297
+ if (!_context3.t0) {
298
+ _context3.next = 22;
299
+ break;
300
+ }
301
+
302
+ _context3.next = 12;
303
+ return _regeneratorRuntime.awrap(this.Owner({
304
+ id: objectId
305
+ }));
306
+
307
+ case 12:
308
+ owner = _context3.sent;
309
+ ownerCapKey = "eluv.caps.iusr".concat(Utils.AddressToHash(this.client.signer.address));
310
+ _context3.next = 16;
311
+ return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
312
+ libraryId: libraryId,
313
+ objectId: objectId,
314
+ metadataSubtree: ownerCapKey
315
+ }));
316
+
317
+ case 16:
318
+ ownerCap = _context3.sent;
319
+
320
+ if (!(!Utils.EqualAddress(owner, this.client.signer.address) && !ownerCap)) {
321
+ _context3.next = 22;
322
+ break;
323
+ }
324
+
325
+ _context3.next = 20;
326
+ return _regeneratorRuntime.awrap(this.ReEncryptionConk({
327
+ libraryId: libraryId,
328
+ objectId: objectId
329
+ }));
330
+
331
+ case 20:
332
+ cap = _context3.sent;
333
+ publicKey = cap.public_key;
334
+
335
+ case 22:
336
+ token = {
337
+ qspace_id: this.contentSpaceId,
338
+ addr: Utils.FormatAddress(this.client.signer && this.client.signer.address || "")
339
+ };
340
+
341
+ if (this.noAuth || noAuth) {
342
+ _context3.next = 29;
343
+ break;
344
+ }
345
+
346
+ _context3.next = 26;
347
+ return _regeneratorRuntime.awrap(this.MakeAccessRequest({
348
+ libraryId: libraryId,
349
+ objectId: objectId,
350
+ versionHash: versionHash,
351
+ update: update,
352
+ publicKey: publicKey,
353
+ noCache: this.noCache,
354
+ noAuth: this.noAuth || noAuth
355
+ }));
356
+
357
+ case 26:
358
+ _ref5 = _context3.sent;
359
+ transactionHash = _ref5.transactionHash;
360
+
361
+ if (transactionHash) {
362
+ token.tx_id = transactionHash;
363
+ }
364
+
365
+ case 29:
366
+ if (libraryId) {
367
+ token.qlib_id = libraryId;
368
+ }
369
+
370
+ if (partHash) {
371
+ token.qphash = partHash;
372
+ }
373
+
374
+ if (publicKey) {
375
+ token.afgh_pk = publicKey;
376
+ }
377
+
378
+ token = Utils.B64(JSON.stringify(token));
379
+ _context3.next = 35;
380
+ return _regeneratorRuntime.awrap(this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(token))));
381
+
382
+ case 35:
383
+ signature = _context3.sent;
384
+ multiSig = Utils.FormatSignature(signature);
385
+ return _context3.abrupt("return", "".concat(token, ".").concat(Utils.B64(multiSig)));
386
+
387
+ case 38:
388
+ case "end":
389
+ return _context3.stop();
406
390
  }
407
- }, _callee3, this);
408
- }));
409
-
410
- function GenerateAuthorizationToken(_x3) {
411
- return _GenerateAuthorizationToken.apply(this, arguments);
412
- }
413
-
414
- return GenerateAuthorizationToken;
415
- }()
391
+ }
392
+ }, null, this);
393
+ }
416
394
  }, {
417
395
  key: "MakeAccessRequest",
418
- value: function () {
419
- var _MakeAccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
420
- var _this = this;
421
-
422
- var libraryId, objectId, versionHash, _ref5$args, args, _ref5$publicKey, publicKey, _ref5$update, update, _ref5$skipCache, skipCache, _ref5$noCache, noCache, cacheOnly, walletContractAddress, walletCreated, id, _yield$this$ContractI, isV3, accessType, abi, _yield$this$AccessInf, accessArgs, checkAccessCharge, address, elapsed, _cache, accessRequest, cache;
396
+ value: function MakeAccessRequest(_ref6) {
397
+ var _this = this;
423
398
 
424
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
425
- while (1) {
426
- switch (_context4.prev = _context4.next) {
427
- case 0:
428
- libraryId = _ref5.libraryId, objectId = _ref5.objectId, versionHash = _ref5.versionHash, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$publicKey = _ref5.publicKey, publicKey = _ref5$publicKey === void 0 ? "" : _ref5$publicKey, _ref5$update = _ref5.update, update = _ref5$update === void 0 ? false : _ref5$update, _ref5$skipCache = _ref5.skipCache, skipCache = _ref5$skipCache === void 0 ? false : _ref5$skipCache, _ref5$noCache = _ref5.noCache, noCache = _ref5$noCache === void 0 ? false : _ref5$noCache, cacheOnly = _ref5.cacheOnly;
429
-
430
- if (this.client.signer) {
431
- _context4.next = 3;
432
- break;
433
- }
399
+ var libraryId, objectId, versionHash, _ref6$args, args, _ref6$publicKey, publicKey, _ref6$update, update, _ref6$skipCache, skipCache, _ref6$noCache, noCache, cacheOnly, walletContractAddress, walletCreated, id, _ref7, isV3, accessType, abi, _ref8, accessArgs, checkAccessCharge, address, elapsed, _cache, accessRequest, cache;
434
400
 
435
- return _context4.abrupt("return", {
436
- transactionHash: ""
437
- });
401
+ return _regeneratorRuntime.async(function MakeAccessRequest$(_context4) {
402
+ while (1) {
403
+ switch (_context4.prev = _context4.next) {
404
+ case 0:
405
+ libraryId = _ref6.libraryId, objectId = _ref6.objectId, versionHash = _ref6.versionHash, _ref6$args = _ref6.args, args = _ref6$args === void 0 ? [] : _ref6$args, _ref6$publicKey = _ref6.publicKey, publicKey = _ref6$publicKey === void 0 ? "" : _ref6$publicKey, _ref6$update = _ref6.update, update = _ref6$update === void 0 ? false : _ref6$update, _ref6$skipCache = _ref6.skipCache, skipCache = _ref6$skipCache === void 0 ? false : _ref6$skipCache, _ref6$noCache = _ref6.noCache, noCache = _ref6$noCache === void 0 ? false : _ref6$noCache, cacheOnly = _ref6.cacheOnly;
438
406
 
439
- case 3:
440
- _context4.next = 5;
441
- return this.client.userProfileClient.UserWalletAddress({
442
- address: this.client.signer.address
443
- });
407
+ if (this.client.signer) {
408
+ _context4.next = 3;
409
+ break;
410
+ }
444
411
 
445
- case 5:
446
- walletContractAddress = _context4.sent;
412
+ return _context4.abrupt("return", {
413
+ transactionHash: ""
414
+ });
447
415
 
448
- if (walletContractAddress) {
449
- _context4.next = 12;
450
- break;
451
- }
416
+ case 3:
417
+ _context4.next = 5;
418
+ return _regeneratorRuntime.awrap(this.client.userProfileClient.UserWalletAddress({
419
+ address: this.client.signer.address
420
+ }));
452
421
 
453
- _context4.next = 9;
454
- return this.client.userProfileClient.WalletAddress();
422
+ case 5:
423
+ walletContractAddress = _context4.sent;
455
424
 
456
- case 9:
457
- walletCreated = _context4.sent;
425
+ if (walletContractAddress) {
426
+ _context4.next = 12;
427
+ break;
428
+ }
458
429
 
459
- if (walletCreated) {
460
- _context4.next = 12;
461
- break;
462
- }
430
+ _context4.next = 9;
431
+ return _regeneratorRuntime.awrap(this.client.userProfileClient.WalletAddress());
463
432
 
464
- throw Error("User wallet contract is required to make access requests");
433
+ case 9:
434
+ walletCreated = _context4.sent;
465
435
 
466
- case 12:
467
- if (versionHash) {
468
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
469
- }
436
+ if (walletCreated) {
437
+ _context4.next = 12;
438
+ break;
439
+ }
470
440
 
471
- id = objectId || libraryId || this.contentSpaceId;
472
- _context4.next = 16;
473
- return this.ContractInfo({
474
- id: id
475
- });
441
+ throw Error("User wallet contract is required to make access requests");
476
442
 
477
- case 16:
478
- _yield$this$ContractI = _context4.sent;
479
- isV3 = _yield$this$ContractI.isV3;
480
- accessType = _yield$this$ContractI.accessType;
481
- abi = _yield$this$ContractI.abi;
443
+ case 12:
444
+ if (versionHash) {
445
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
446
+ }
482
447
 
483
- if (!(typeof accessType === "undefined")) {
484
- _context4.next = 22;
485
- break;
486
- }
448
+ id = objectId || libraryId || this.contentSpaceId;
449
+ _context4.next = 16;
450
+ return _regeneratorRuntime.awrap(this.ContractInfo({
451
+ id: id
452
+ }));
487
453
 
488
- throw Error("Unable to determine contract info for ".concat(id, " (").concat(this.client.utils.HashToAddress(id), ") - Wrong network?"));
454
+ case 16:
455
+ _ref7 = _context4.sent;
456
+ isV3 = _ref7.isV3;
457
+ accessType = _ref7.accessType;
458
+ abi = _ref7.abi;
489
459
 
490
- case 22:
491
- _context4.next = 24;
492
- return this.AccessInfo({
493
- accessType: accessType,
494
- publicKey: publicKey,
495
- update: update,
496
- args: args,
497
- isV3: isV3
498
- });
460
+ if (!(typeof accessType === "undefined")) {
461
+ _context4.next = 22;
462
+ break;
463
+ }
464
+
465
+ throw Error("Unable to determine contract info for ".concat(id, " (").concat(this.client.utils.HashToAddress(id), ") - Wrong network?"));
466
+
467
+ case 22:
468
+ _context4.next = 24;
469
+ return _regeneratorRuntime.awrap(this.AccessInfo({
470
+ accessType: accessType,
471
+ publicKey: publicKey,
472
+ update: update,
473
+ args: args,
474
+ isV3: isV3
475
+ }));
476
+
477
+ case 24:
478
+ _ref8 = _context4.sent;
479
+ accessArgs = _ref8.accessArgs;
480
+ checkAccessCharge = _ref8.checkAccessCharge;
481
+ address = Utils.HashToAddress(id);
482
+ elapsed = 0;
483
+
484
+ case 29:
485
+ if (!this.transactionLocks[id]) {
486
+ _context4.next = 36;
487
+ break;
488
+ }
499
489
 
500
- case 24:
501
- _yield$this$AccessInf = _context4.sent;
502
- accessArgs = _yield$this$AccessInf.accessArgs;
503
- checkAccessCharge = _yield$this$AccessInf.checkAccessCharge;
504
- address = Utils.HashToAddress(id);
505
- elapsed = 0;
490
+ _context4.next = 32;
491
+ return _regeneratorRuntime.awrap(new Promise(function (resolve) {
492
+ return setTimeout(resolve, 100);
493
+ }));
506
494
 
507
- case 29:
508
- if (!this.transactionLocks[id]) {
509
- _context4.next = 36;
510
- break;
511
- }
495
+ case 32:
496
+ elapsed += 100;
512
497
 
513
- _context4.next = 32;
514
- return new Promise(function (resolve) {
515
- return setTimeout(resolve, 100);
516
- });
498
+ if (elapsed > 15000) {
499
+ this.Log("Lock never released for ".concat(id, " - releasing lock"));
500
+ delete this.transactionLocks[id];
501
+ }
517
502
 
518
- case 32:
519
- elapsed += 100;
503
+ _context4.next = 29;
504
+ break;
520
505
 
521
- if (elapsed > 15000) {
522
- this.Log("Lock never released for ".concat(id, " - releasing lock"));
523
- delete this.transactionLocks[id];
524
- }
506
+ case 36:
507
+ _context4.prev = 36;
508
+ this.transactionLocks[id] = true; // Check cache for existing transaction
525
509
 
526
- _context4.next = 29;
510
+ if (!(!noCache && !skipCache)) {
511
+ _context4.next = 46;
527
512
  break;
513
+ }
528
514
 
529
- case 36:
530
- _context4.prev = 36;
531
- this.transactionLocks[id] = true; // Check cache for existing transaction
532
-
533
- if (!(!noCache && !skipCache)) {
534
- _context4.next = 46;
535
- break;
536
- }
537
-
538
- _cache = update ? this.modifyTransactions : this.accessTransactions;
539
-
540
- if (!_cache[address]) {
541
- _context4.next = 46;
542
- break;
543
- }
544
-
545
- if (!(_cache[address].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
546
- _context4.next = 45;
547
- break;
548
- }
515
+ _cache = update ? this.modifyTransactions : this.accessTransactions;
549
516
 
550
- return _context4.abrupt("return", _cache[address]);
517
+ if (!_cache[address]) {
518
+ _context4.next = 46;
519
+ break;
520
+ }
551
521
 
552
- case 45:
553
- // Token expired
554
- delete _cache[address];
522
+ if (!(_cache[address].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
523
+ _context4.next = 45;
524
+ break;
525
+ }
555
526
 
556
- case 46:
557
- if (!cacheOnly) {
558
- _context4.next = 48;
559
- break;
560
- }
527
+ return _context4.abrupt("return", _cache[address]);
561
528
 
562
- return _context4.abrupt("return");
529
+ case 45:
530
+ // Token expired
531
+ delete _cache[address];
563
532
 
564
- case 48:
565
- if (!update) {
566
- _context4.next = 55;
567
- break;
568
- }
533
+ case 46:
534
+ if (!cacheOnly) {
535
+ _context4.next = 48;
536
+ break;
537
+ }
569
538
 
570
- this.Log("Making update request on ".concat(accessType, " ").concat(id));
571
- _context4.next = 52;
572
- return this.UpdateRequest({
573
- id: id,
574
- abi: abi
575
- });
539
+ return _context4.abrupt("return");
576
540
 
577
- case 52:
578
- accessRequest = _context4.sent;
579
- _context4.next = 59;
541
+ case 48:
542
+ if (!update) {
543
+ _context4.next = 55;
580
544
  break;
581
-
582
- case 55:
583
- this.Log("Making access request on ".concat(accessType, " ").concat(id));
584
- _context4.next = 58;
585
- return this.AccessRequest({
586
- id: id,
587
- args: accessArgs,
588
- checkAccessCharge: checkAccessCharge
545
+ }
546
+
547
+ this.Log("Making update request on ".concat(accessType, " ").concat(id));
548
+ _context4.next = 52;
549
+ return _regeneratorRuntime.awrap(this.UpdateRequest({
550
+ id: id,
551
+ abi: abi
552
+ }));
553
+
554
+ case 52:
555
+ accessRequest = _context4.sent;
556
+ _context4.next = 59;
557
+ break;
558
+
559
+ case 55:
560
+ this.Log("Making access request on ".concat(accessType, " ").concat(id));
561
+ _context4.next = 58;
562
+ return _regeneratorRuntime.awrap(this.AccessRequest({
563
+ id: id,
564
+ args: accessArgs,
565
+ checkAccessCharge: checkAccessCharge
566
+ }));
567
+
568
+ case 58:
569
+ accessRequest = _context4.sent;
570
+
571
+ case 59:
572
+ cache = update ? this.modifyTransactions : this.accessTransactions;
573
+ _context4.prev = 60;
574
+
575
+ if (!noCache) {
576
+ cache[address] = {
577
+ issuedAt: Date.now(),
578
+ transactionHash: accessRequest.transactionHash
579
+ }; // Save request ID if present
580
+
581
+ accessRequest.logs.some(function (log) {
582
+ if (log.values && (log.values.requestID || log.values.requestNonce)) {
583
+ _this.requestIds[address] = (log.values.requestID || log.values.requestNonce || "").toString().replace(/^0x/, "");
584
+ return true;
585
+ }
589
586
  });
587
+ }
590
588
 
591
- case 58:
592
- accessRequest = _context4.sent;
593
-
594
- case 59:
595
- cache = update ? this.modifyTransactions : this.accessTransactions;
596
- _context4.prev = 60;
597
-
598
- if (!noCache) {
599
- cache[address] = {
600
- issuedAt: Date.now(),
601
- transactionHash: accessRequest.transactionHash
602
- }; // Save request ID if present
603
-
604
- accessRequest.logs.some(function (log) {
605
- if (log.values && (log.values.requestID || log.values.requestNonce)) {
606
- _this.requestIds[address] = (log.values.requestID || log.values.requestNonce || "").toString().replace(/^0x/, "");
607
- return true;
608
- }
609
- });
610
- }
611
-
612
- return _context4.abrupt("return", accessRequest);
589
+ return _context4.abrupt("return", accessRequest);
613
590
 
614
- case 65:
615
- _context4.prev = 65;
616
- _context4.t0 = _context4["catch"](60);
591
+ case 65:
592
+ _context4.prev = 65;
593
+ _context4.t0 = _context4["catch"](60);
617
594
 
618
- if (!noCache) {
619
- delete cache[address];
620
- }
595
+ if (!noCache) {
596
+ delete cache[address];
597
+ }
621
598
 
622
- throw _context4.t0;
599
+ throw _context4.t0;
623
600
 
624
- case 69:
625
- _context4.prev = 69;
626
- delete this.transactionLocks[id];
627
- return _context4.finish(69);
601
+ case 69:
602
+ _context4.prev = 69;
603
+ delete this.transactionLocks[id];
604
+ return _context4.finish(69);
628
605
 
629
- case 72:
630
- case "end":
631
- return _context4.stop();
632
- }
606
+ case 72:
607
+ case "end":
608
+ return _context4.stop();
633
609
  }
634
- }, _callee4, this, [[36,, 69, 72], [60, 65]]);
635
- }));
636
-
637
- function MakeAccessRequest(_x4) {
638
- return _MakeAccessRequest.apply(this, arguments);
639
- }
640
-
641
- return MakeAccessRequest;
642
- }()
610
+ }
611
+ }, null, this, [[36,, 69, 72], [60, 65]]);
612
+ }
643
613
  }, {
644
614
  key: "AccessRequest",
645
- value: function () {
646
- var _AccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref6) {
647
- var id, _ref6$args, args, _ref6$checkAccessChar, checkAccessCharge, _yield$this$ContractI2, isV3, accessType, abi, accessCharge, owner, accessChargeArgs, event, methodName, contractAddress;
648
-
649
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
650
- while (1) {
651
- switch (_context5.prev = _context5.next) {
652
- case 0:
653
- id = _ref6.id, _ref6$args = _ref6.args, args = _ref6$args === void 0 ? [] : _ref6$args, _ref6$checkAccessChar = _ref6.checkAccessCharge, checkAccessCharge = _ref6$checkAccessChar === void 0 ? false : _ref6$checkAccessChar;
654
- _context5.next = 3;
655
- return this.ContractInfo({
656
- id: id
657
- });
658
-
659
- case 3:
660
- _yield$this$ContractI2 = _context5.sent;
661
- isV3 = _yield$this$ContractI2.isV3;
662
- accessType = _yield$this$ContractI2.accessType;
663
- abi = _yield$this$ContractI2.abi;
664
- // Send some bux if access charge is required
665
- accessCharge = 0;
666
-
667
- if (!(checkAccessCharge && accessType === ACCESS_TYPES.OBJECT)) {
668
- _context5.next = 26;
669
- break;
670
- }
671
-
672
- _context5.next = 11;
673
- return this.Owner({
674
- id: id,
675
- abi: abi
676
- });
677
-
678
- case 11:
679
- owner = _context5.sent;
680
-
681
- if (Utils.EqualAddress(this.client.signer.address, owner)) {
682
- _context5.next = 26;
683
- break;
684
- }
685
-
686
- _context5.prev = 13;
687
- // Extract level, custom values and stakeholders from accessRequest arguments
688
- accessChargeArgs = isV3 ? [0, [], []] : [args[0], args[3], args[4]]; // Access charge is in wei, but methods take ether - convert to charge to ether
689
-
690
- _context5.t0 = Utils;
691
- _context5.next = 18;
692
- return this.GetAccessCharge({
693
- objectId: id,
694
- args: accessChargeArgs
695
- });
696
-
697
- case 18:
698
- _context5.t1 = _context5.sent;
699
- accessCharge = _context5.t0.WeiToEther.call(_context5.t0, _context5.t1);
615
+ value: function AccessRequest(_ref9) {
616
+ var id, _ref9$args, args, _ref9$checkAccessChar, checkAccessCharge, _ref10, isV3, accessType, abi, accessCharge, owner, accessChargeArgs, event, methodName, contractAddress;
617
+
618
+ return _regeneratorRuntime.async(function AccessRequest$(_context5) {
619
+ while (1) {
620
+ switch (_context5.prev = _context5.next) {
621
+ case 0:
622
+ id = _ref9.id, _ref9$args = _ref9.args, args = _ref9$args === void 0 ? [] : _ref9$args, _ref9$checkAccessChar = _ref9.checkAccessCharge, checkAccessCharge = _ref9$checkAccessChar === void 0 ? false : _ref9$checkAccessChar;
623
+ _context5.next = 3;
624
+ return _regeneratorRuntime.awrap(this.ContractInfo({
625
+ id: id
626
+ }));
627
+
628
+ case 3:
629
+ _ref10 = _context5.sent;
630
+ isV3 = _ref10.isV3;
631
+ accessType = _ref10.accessType;
632
+ abi = _ref10.abi;
633
+ // Send some bux if access charge is required
634
+ accessCharge = 0;
635
+
636
+ if (!(checkAccessCharge && accessType === ACCESS_TYPES.OBJECT)) {
700
637
  _context5.next = 26;
701
638
  break;
639
+ }
702
640
 
703
- case 22:
704
- _context5.prev = 22;
705
- _context5.t2 = _context5["catch"](13);
706
- this.Log("Failed to get access charge for", id);
707
- this.Log(_context5.t2);
708
-
709
- case 26:
710
- if (accessCharge > 0) {
711
- this.Log("Access charge: ".concat(accessCharge));
712
- }
713
-
714
- contractAddress = Utils.HashToAddress(id);
715
-
716
- if (isV3) {
717
- methodName = "accessRequestV3";
718
- } else {
719
- methodName = "accessRequest";
720
- }
721
-
722
- _context5.next = 31;
723
- return this.ContractHasMethod({
724
- contractAddress: contractAddress,
725
- abi: abi,
726
- methodName: methodName
727
- });
728
-
729
- case 31:
730
- if (_context5.sent) {
731
- _context5.next = 34;
732
- break;
733
- }
734
-
735
- this.Log("".concat(accessType, " ").concat(id, " has no ").concat(methodName, " method. Skipping"));
736
- return _context5.abrupt("return", {
737
- transactionHash: "",
738
- logs: []
739
- });
740
-
741
- case 34:
742
- _context5.next = 36;
743
- return this.client.CallContractMethodAndWait({
744
- contractAddress: contractAddress,
745
- abi: abi,
746
- methodName: methodName,
747
- methodArgs: args,
748
- value: accessCharge
749
- });
641
+ _context5.next = 11;
642
+ return _regeneratorRuntime.awrap(this.Owner({
643
+ id: id,
644
+ abi: abi
645
+ }));
750
646
 
751
- case 36:
752
- event = _context5.sent;
647
+ case 11:
648
+ owner = _context5.sent;
753
649
 
754
- if (!(event.logs.length === 0)) {
755
- _context5.next = 39;
756
- break;
757
- }
650
+ if (Utils.EqualAddress(this.client.signer.address, owner)) {
651
+ _context5.next = 26;
652
+ break;
653
+ }
654
+
655
+ _context5.prev = 13;
656
+ // Extract level, custom values and stakeholders from accessRequest arguments
657
+ accessChargeArgs = isV3 ? [0, [], []] : [args[0], args[3], args[4]]; // Access charge is in wei, but methods take ether - convert to charge to ether
658
+
659
+ _context5.t0 = Utils;
660
+ _context5.next = 18;
661
+ return _regeneratorRuntime.awrap(this.GetAccessCharge({
662
+ objectId: id,
663
+ args: accessChargeArgs
664
+ }));
665
+
666
+ case 18:
667
+ _context5.t1 = _context5.sent;
668
+ accessCharge = _context5.t0.WeiToEther.call(_context5.t0, _context5.t1);
669
+ _context5.next = 26;
670
+ break;
671
+
672
+ case 22:
673
+ _context5.prev = 22;
674
+ _context5.t2 = _context5["catch"](13);
675
+ this.Log("Failed to get access charge for", id);
676
+ this.Log(_context5.t2);
677
+
678
+ case 26:
679
+ if (accessCharge > 0) {
680
+ this.Log("Access charge: ".concat(accessCharge));
681
+ }
682
+
683
+ contractAddress = Utils.HashToAddress(id);
684
+
685
+ if (isV3) {
686
+ methodName = "accessRequestV3";
687
+ } else {
688
+ methodName = "accessRequest";
689
+ }
690
+
691
+ _context5.next = 31;
692
+ return _regeneratorRuntime.awrap(this.ContractHasMethod({
693
+ contractAddress: contractAddress,
694
+ abi: abi,
695
+ methodName: methodName
696
+ }));
697
+
698
+ case 31:
699
+ if (_context5.sent) {
700
+ _context5.next = 34;
701
+ break;
702
+ }
703
+
704
+ this.Log("".concat(accessType, " ").concat(id, " has no ").concat(methodName, " method. Skipping"));
705
+ return _context5.abrupt("return", {
706
+ transactionHash: "",
707
+ logs: []
708
+ });
709
+
710
+ case 34:
711
+ _context5.next = 36;
712
+ return _regeneratorRuntime.awrap(this.client.CallContractMethodAndWait({
713
+ contractAddress: contractAddress,
714
+ abi: abi,
715
+ methodName: methodName,
716
+ methodArgs: args,
717
+ value: accessCharge
718
+ }));
719
+
720
+ case 36:
721
+ event = _context5.sent;
722
+
723
+ if (!(event.logs.length === 0)) {
724
+ _context5.next = 39;
725
+ break;
726
+ }
758
727
 
759
- throw Error("Access denied (".concat(id, ")"));
728
+ throw Error("Access denied (".concat(id, ")"));
760
729
 
761
- case 39:
762
- return _context5.abrupt("return", event);
730
+ case 39:
731
+ return _context5.abrupt("return", event);
763
732
 
764
- case 40:
765
- case "end":
766
- return _context5.stop();
767
- }
733
+ case 40:
734
+ case "end":
735
+ return _context5.stop();
768
736
  }
769
- }, _callee5, this, [[13, 22]]);
770
- }));
771
-
772
- function AccessRequest(_x5) {
773
- return _AccessRequest.apply(this, arguments);
774
- }
775
-
776
- return AccessRequest;
777
- }()
737
+ }
738
+ }, null, this, [[13, 22]]);
739
+ }
778
740
  }, {
779
741
  key: "UpdateRequest",
780
- value: function () {
781
- var _UpdateRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
782
- var id, abi, event, updateRequestEvent;
783
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
784
- while (1) {
785
- switch (_context6.prev = _context6.next) {
786
- case 0:
787
- id = _ref7.id, abi = _ref7.abi;
788
- _context6.next = 3;
789
- return this.client.CallContractMethodAndWait({
790
- contractAddress: Utils.HashToAddress(id),
791
- abi: abi,
792
- methodName: "updateRequest",
793
- methodArgs: []
794
- });
795
-
796
- case 3:
797
- event = _context6.sent;
798
- updateRequestEvent = this.client.ExtractEventFromLogs({
799
- abi: abi,
800
- event: event,
801
- eventName: "UpdateRequest"
802
- });
803
-
804
- if (!(event.logs.length === 0 || !updateRequestEvent)) {
805
- _context6.next = 7;
806
- break;
807
- }
742
+ value: function UpdateRequest(_ref11) {
743
+ var id, abi, event, updateRequestEvent;
744
+ return _regeneratorRuntime.async(function UpdateRequest$(_context6) {
745
+ while (1) {
746
+ switch (_context6.prev = _context6.next) {
747
+ case 0:
748
+ id = _ref11.id, abi = _ref11.abi;
749
+ _context6.next = 3;
750
+ return _regeneratorRuntime.awrap(this.client.CallContractMethodAndWait({
751
+ contractAddress: Utils.HashToAddress(id),
752
+ abi: abi,
753
+ methodName: "updateRequest",
754
+ methodArgs: []
755
+ }));
756
+
757
+ case 3:
758
+ event = _context6.sent;
759
+ updateRequestEvent = this.client.ExtractEventFromLogs({
760
+ abi: abi,
761
+ event: event,
762
+ eventName: "UpdateRequest"
763
+ });
764
+
765
+ if (!(event.logs.length === 0 || !updateRequestEvent)) {
766
+ _context6.next = 7;
767
+ break;
768
+ }
808
769
 
809
- throw Error("Update request denied for ".concat(id));
770
+ throw Error("Update request denied for ".concat(id));
810
771
 
811
- case 7:
812
- return _context6.abrupt("return", event);
772
+ case 7:
773
+ return _context6.abrupt("return", event);
813
774
 
814
- case 8:
815
- case "end":
816
- return _context6.stop();
817
- }
775
+ case 8:
776
+ case "end":
777
+ return _context6.stop();
818
778
  }
819
- }, _callee6, this);
820
- }));
821
-
822
- function UpdateRequest(_x6) {
823
- return _UpdateRequest.apply(this, arguments);
824
- }
825
-
826
- return UpdateRequest;
827
- }()
779
+ }
780
+ }, null, this);
781
+ }
828
782
  }, {
829
783
  key: "AudienceData",
830
- value: function AudienceData(_ref8) {
831
- var objectId = _ref8.objectId,
832
- versionHash = _ref8.versionHash,
833
- _ref8$protocols = _ref8.protocols,
834
- protocols = _ref8$protocols === void 0 ? [] : _ref8$protocols,
835
- _ref8$drms = _ref8.drms,
836
- drms = _ref8$drms === void 0 ? [] : _ref8$drms,
837
- context = _ref8.context;
784
+ value: function AudienceData(_ref12) {
785
+ var objectId = _ref12.objectId,
786
+ versionHash = _ref12.versionHash,
787
+ _ref12$protocols = _ref12.protocols,
788
+ protocols = _ref12$protocols === void 0 ? [] : _ref12$protocols,
789
+ _ref12$drms = _ref12.drms,
790
+ drms = _ref12$drms === void 0 ? [] : _ref12$drms,
791
+ context = _ref12.context;
838
792
  this.Log("Retrieving audience data: ".concat(objectId));
839
793
  context = context || this.client.authContext || {};
840
794
 
@@ -864,1797 +818,1585 @@ var AuthorizationClient = /*#__PURE__*/function () {
864
818
  }
865
819
  }, {
866
820
  key: "GenerateChannelContentToken",
867
- value: function () {
868
- var _GenerateChannelContentToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref9) {
869
- var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref9$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams, payload, signature, multiSig;
870
-
871
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
872
- while (1) {
873
- switch (_context7.prev = _context7.next) {
874
- case 0:
875
- objectId = _ref9.objectId, versionHash = _ref9.versionHash, issuer = _ref9.issuer, code = _ref9.code, email = _ref9.email, audienceData = _ref9.audienceData, context = _ref9.context, oauthToken = _ref9.oauthToken, _ref9$value = _ref9.value, value = _ref9$value === void 0 ? 0 : _ref9$value;
876
-
877
- if (!oauthToken) {
878
- _context7.next = 5;
879
- break;
880
- }
881
-
882
- _context7.next = 4;
883
- return this.GenerateOauthChannelToken({
884
- objectId: objectId,
885
- token: oauthToken
886
- });
887
-
888
- case 4:
889
- return _context7.abrupt("return", _context7.sent);
890
-
891
- case 5:
892
- if (!(!this.noCache && this.channelContentTokens[objectId])) {
893
- _context7.next = 11;
894
- break;
895
- }
896
-
897
- if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
898
- _context7.next = 10;
899
- break;
900
- }
901
-
902
- return _context7.abrupt("return", this.channelContentTokens[objectId].token);
903
-
904
- case 10:
905
- // Token expired
906
- delete this.channelContentTokens[objectId];
821
+ value: function GenerateChannelContentToken(_ref13) {
822
+ var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref13$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams, payload, signature, multiSig;
907
823
 
908
- case 11:
909
- this.Log("Making state channel access request: ".concat(objectId));
824
+ return _regeneratorRuntime.async(function GenerateChannelContentToken$(_context7) {
825
+ while (1) {
826
+ switch (_context7.prev = _context7.next) {
827
+ case 0:
828
+ objectId = _ref13.objectId, versionHash = _ref13.versionHash, issuer = _ref13.issuer, code = _ref13.code, email = _ref13.email, audienceData = _ref13.audienceData, context = _ref13.context, oauthToken = _ref13.oauthToken, _ref13$value = _ref13.value, value = _ref13$value === void 0 ? 0 : _ref13$value;
910
829
 
911
- if (!issuer) {
912
- _context7.next = 43;
913
- break;
914
- }
915
-
916
- // Ticket API
917
- tenantId = issuer.replace(/^\//, "").split("/")[2];
918
- _context7.prev = 14;
919
- _context7.next = 17;
920
- return this.client.CallContractMethod({
921
- contractAddress: Utils.HashToAddress(tenantId),
922
- methodName: "addressKMS"
923
- });
924
-
925
- case 17:
926
- kmsAddress = _context7.sent;
830
+ if (!oauthToken) {
831
+ _context7.next = 5;
832
+ break;
833
+ }
927
834
 
928
- if (kmsAddress) {
929
- _context7.next = 20;
930
- break;
931
- }
835
+ _context7.next = 4;
836
+ return _regeneratorRuntime.awrap(this.GenerateOauthChannelToken({
837
+ objectId: objectId,
838
+ token: oauthToken
839
+ }));
932
840
 
933
- throw "";
841
+ case 4:
842
+ return _context7.abrupt("return", _context7.sent);
934
843
 
935
- case 20:
936
- _context7.next = 27;
844
+ case 5:
845
+ if (!(!this.noCache && this.channelContentTokens[objectId])) {
846
+ _context7.next = 11;
937
847
  break;
848
+ }
938
849
 
939
- case 22:
940
- _context7.prev = 22;
941
- _context7.t0 = _context7["catch"](14);
942
- _context7.next = 26;
943
- return this.client.DefaultKMSAddress();
944
-
945
- case 26:
946
- kmsAddress = _context7.sent;
947
-
948
- case 27:
949
- _context7.prev = 27;
950
- _context7.next = 30;
951
- return Utils.ResponseToFormat("text", this.MakeAuthServiceRequest({
952
- kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
953
- method: "POST",
954
- path: UrlJoin("as", issuer),
955
- body: {
956
- "_PASSWORD": code,
957
- "_EMAIL": email
958
- }
959
- }));
960
-
961
- case 30:
962
- token = _context7.sent;
963
- _context7.next = 40;
850
+ if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
851
+ _context7.next = 10;
964
852
  break;
853
+ }
965
854
 
966
- case 33:
967
- _context7.prev = 33;
968
- _context7.t1 = _context7["catch"](27);
969
- this.Log("/as token redemption failed:", true);
970
- this.Log(_context7.t1, true);
971
- _context7.next = 39;
972
- return Utils.ResponseToFormat("text", this.MakeKMSRequest({
973
- kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
974
- method: "POST",
975
- path: UrlJoin("ks", issuer),
976
- body: {
977
- "_PASSWORD": code,
978
- "_EMAIL": email
979
- }
980
- }));
981
-
982
- case 39:
983
- token = _context7.sent;
855
+ return _context7.abrupt("return", this.channelContentTokens[objectId].token);
984
856
 
985
- case 40:
986
- // Pull target object from token so token can be cached
987
- objectId = JSON.parse(Utils.FromB64(token)).qid;
988
- _context7.next = 54;
989
- break;
857
+ case 10:
858
+ // Token expired
859
+ delete this.channelContentTokens[objectId];
990
860
 
991
- case 43:
992
- // State channel API
993
- if (!audienceData) {
994
- audienceData = this.AudienceData({
995
- objectId: objectId,
996
- versionHash: versionHash,
997
- context: context
998
- });
999
- }
861
+ case 11:
862
+ this.Log("Making state channel access request: ".concat(objectId));
1000
863
 
1001
- stateChannelApi = "elv_channelContentRequestContext";
1002
- additionalParams = [JSON.stringify(audienceData)];
1003
- _context7.next = 48;
1004
- return this.MakeKMSCall({
864
+ if (!issuer) {
865
+ _context7.next = 43;
866
+ break;
867
+ }
868
+
869
+ // Ticket API
870
+ tenantId = issuer.replace(/^\//, "").split("/")[2];
871
+ _context7.prev = 14;
872
+ _context7.next = 17;
873
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
874
+ contractAddress: Utils.HashToAddress(tenantId),
875
+ methodName: "addressKMS"
876
+ }));
877
+
878
+ case 17:
879
+ kmsAddress = _context7.sent;
880
+
881
+ if (kmsAddress) {
882
+ _context7.next = 20;
883
+ break;
884
+ }
885
+
886
+ throw "";
887
+
888
+ case 20:
889
+ _context7.next = 27;
890
+ break;
891
+
892
+ case 22:
893
+ _context7.prev = 22;
894
+ _context7.t0 = _context7["catch"](14);
895
+ _context7.next = 26;
896
+ return _regeneratorRuntime.awrap(this.client.DefaultKMSAddress());
897
+
898
+ case 26:
899
+ kmsAddress = _context7.sent;
900
+
901
+ case 27:
902
+ _context7.prev = 27;
903
+ _context7.next = 30;
904
+ return _regeneratorRuntime.awrap(Utils.ResponseToFormat("text", this.MakeAuthServiceRequest({
905
+ kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
906
+ method: "POST",
907
+ path: UrlJoin("as", issuer),
908
+ body: {
909
+ "_PASSWORD": code,
910
+ "_EMAIL": email
911
+ }
912
+ })));
913
+
914
+ case 30:
915
+ token = _context7.sent;
916
+ _context7.next = 40;
917
+ break;
918
+
919
+ case 33:
920
+ _context7.prev = 33;
921
+ _context7.t1 = _context7["catch"](27);
922
+ this.Log("/as token redemption failed:", true);
923
+ this.Log(_context7.t1, true);
924
+ _context7.next = 39;
925
+ return _regeneratorRuntime.awrap(Utils.ResponseToFormat("text", this.MakeKMSRequest({
926
+ kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
927
+ method: "POST",
928
+ path: UrlJoin("ks", issuer),
929
+ body: {
930
+ "_PASSWORD": code,
931
+ "_EMAIL": email
932
+ }
933
+ })));
934
+
935
+ case 39:
936
+ token = _context7.sent;
937
+
938
+ case 40:
939
+ // Pull target object from token so token can be cached
940
+ objectId = JSON.parse(Utils.FromB64(token)).qid;
941
+ _context7.next = 54;
942
+ break;
943
+
944
+ case 43:
945
+ // State channel API
946
+ if (!audienceData) {
947
+ audienceData = this.AudienceData({
1005
948
  objectId: objectId,
1006
- methodName: stateChannelApi,
1007
- paramTypes: ["address", "address", "uint", "uint"],
1008
- params: [this.client.signer.address, Utils.HashToAddress(objectId), value, Date.now()],
1009
- additionalParams: additionalParams
1010
- });
1011
-
1012
- case 48:
1013
- payload = _context7.sent;
1014
- _context7.next = 51;
1015
- return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(payload)));
1016
-
1017
- case 51:
1018
- signature = _context7.sent;
1019
- multiSig = Utils.FormatSignature(signature);
1020
- token = "".concat(payload, ".").concat(Utils.B64(multiSig));
1021
-
1022
- case 54:
1023
- if (!this.noCache) {
1024
- this.channelContentTokens[objectId] = {
1025
- token: token,
1026
- issuedAt: Date.now()
1027
- };
1028
- }
949
+ versionHash: versionHash,
950
+ context: context
951
+ });
952
+ }
953
+
954
+ stateChannelApi = "elv_channelContentRequestContext";
955
+ additionalParams = [JSON.stringify(audienceData)];
956
+ _context7.next = 48;
957
+ return _regeneratorRuntime.awrap(this.MakeKMSCall({
958
+ objectId: objectId,
959
+ methodName: stateChannelApi,
960
+ paramTypes: ["address", "address", "uint", "uint"],
961
+ params: [this.client.signer.address, Utils.HashToAddress(objectId), value, Date.now()],
962
+ additionalParams: additionalParams
963
+ }));
964
+
965
+ case 48:
966
+ payload = _context7.sent;
967
+ _context7.next = 51;
968
+ return _regeneratorRuntime.awrap(this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(payload))));
969
+
970
+ case 51:
971
+ signature = _context7.sent;
972
+ multiSig = Utils.FormatSignature(signature);
973
+ token = "".concat(payload, ".").concat(Utils.B64(multiSig));
974
+
975
+ case 54:
976
+ if (!this.noCache) {
977
+ this.channelContentTokens[objectId] = {
978
+ token: token,
979
+ issuedAt: Date.now()
980
+ };
981
+ }
1029
982
 
1030
- return _context7.abrupt("return", token);
983
+ return _context7.abrupt("return", token);
1031
984
 
1032
- case 56:
1033
- case "end":
1034
- return _context7.stop();
1035
- }
985
+ case 56:
986
+ case "end":
987
+ return _context7.stop();
1036
988
  }
1037
- }, _callee7, this, [[14, 22], [27, 33]]);
1038
- }));
1039
-
1040
- function GenerateChannelContentToken(_x7) {
1041
- return _GenerateChannelContentToken.apply(this, arguments);
1042
- }
1043
-
1044
- return GenerateChannelContentToken;
1045
- }()
989
+ }
990
+ }, null, this, [[14, 22], [27, 33]]);
991
+ }
1046
992
  }, {
1047
993
  key: "ChannelContentFinalize",
1048
- value: function () {
1049
- var _ChannelContentFinalize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
1050
- var objectId, versionHash, _ref10$percent, percent, result;
1051
-
1052
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
1053
- while (1) {
1054
- switch (_context8.prev = _context8.next) {
1055
- case 0:
1056
- objectId = _ref10.objectId, versionHash = _ref10.versionHash, _ref10$percent = _ref10.percent, percent = _ref10$percent === void 0 ? 0 : _ref10$percent;
1057
- this.Log("Making state channel finalize request: ".concat(objectId));
1058
- _context8.next = 4;
1059
- return this.MakeKMSCall({
994
+ value: function ChannelContentFinalize(_ref14) {
995
+ var objectId, versionHash, _ref14$percent, percent, result;
996
+
997
+ return _regeneratorRuntime.async(function ChannelContentFinalize$(_context8) {
998
+ while (1) {
999
+ switch (_context8.prev = _context8.next) {
1000
+ case 0:
1001
+ objectId = _ref14.objectId, versionHash = _ref14.versionHash, _ref14$percent = _ref14.percent, percent = _ref14$percent === void 0 ? 0 : _ref14$percent;
1002
+ this.Log("Making state channel finalize request: ".concat(objectId));
1003
+ _context8.next = 4;
1004
+ return _regeneratorRuntime.awrap(this.MakeKMSCall({
1005
+ objectId: objectId,
1006
+ methodName: "elv_channelContentFinalizeContext",
1007
+ paramTypes: ["address", "address", "uint", "uint"],
1008
+ params: [this.client.signer.address, Utils.HashToAddress(objectId), percent, Date.now()],
1009
+ additionalParams: [JSON.stringify(this.AudienceData({
1060
1010
  objectId: objectId,
1061
- methodName: "elv_channelContentFinalizeContext",
1062
- paramTypes: ["address", "address", "uint", "uint"],
1063
- params: [this.client.signer.address, Utils.HashToAddress(objectId), percent, Date.now()],
1064
- additionalParams: [JSON.stringify(this.AudienceData({
1065
- objectId: objectId,
1066
- versionHash: versionHash
1067
- }))]
1068
- });
1011
+ versionHash: versionHash
1012
+ }))]
1013
+ }));
1069
1014
 
1070
- case 4:
1071
- result = _context8.sent;
1072
- this.channelContentTokens[objectId] = undefined;
1073
- return _context8.abrupt("return", result);
1015
+ case 4:
1016
+ result = _context8.sent;
1017
+ this.channelContentTokens[objectId] = undefined;
1018
+ return _context8.abrupt("return", result);
1074
1019
 
1075
- case 7:
1076
- case "end":
1077
- return _context8.stop();
1078
- }
1020
+ case 7:
1021
+ case "end":
1022
+ return _context8.stop();
1079
1023
  }
1080
- }, _callee8, this);
1081
- }));
1082
-
1083
- function ChannelContentFinalize(_x8) {
1084
- return _ChannelContentFinalize.apply(this, arguments);
1085
- }
1086
-
1087
- return ChannelContentFinalize;
1088
- }()
1024
+ }
1025
+ }, null, this);
1026
+ }
1089
1027
  }, {
1090
1028
  key: "GenerateOauthChannelToken",
1091
- value: function () {
1092
- var _GenerateOauthChannelToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref11) {
1093
- var objectId, versionHash, token, fabricToken;
1094
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
1095
- while (1) {
1096
- switch (_context9.prev = _context9.next) {
1097
- case 0:
1098
- objectId = _ref11.objectId, versionHash = _ref11.versionHash, token = _ref11.token;
1099
-
1100
- if (versionHash) {
1101
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
1102
- }
1029
+ value: function GenerateOauthChannelToken(_ref15) {
1030
+ var objectId, versionHash, token, fabricToken;
1031
+ return _regeneratorRuntime.async(function GenerateOauthChannelToken$(_context9) {
1032
+ while (1) {
1033
+ switch (_context9.prev = _context9.next) {
1034
+ case 0:
1035
+ objectId = _ref15.objectId, versionHash = _ref15.versionHash, token = _ref15.token;
1036
+
1037
+ if (versionHash) {
1038
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1039
+ }
1040
+
1041
+ if (!(!this.noCache && this.channelContentTokens[objectId])) {
1042
+ _context9.next = 6;
1043
+ break;
1044
+ }
1103
1045
 
1104
- if (!(!this.noCache && this.channelContentTokens[objectId])) {
1105
- _context9.next = 6;
1106
- break;
1107
- }
1046
+ if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
1047
+ _context9.next = 5;
1048
+ break;
1049
+ }
1050
+
1051
+ return _context9.abrupt("return", this.channelContentTokens[objectId].token);
1052
+
1053
+ case 5:
1054
+ // Token expired
1055
+ this.channelContentTokens[objectId] = undefined;
1056
+
1057
+ case 6:
1058
+ _context9.t0 = _regeneratorRuntime;
1059
+ _context9.next = 9;
1060
+ return _regeneratorRuntime.awrap(this.MakeKMSRequest({
1061
+ objectId: objectId,
1062
+ versionHash: versionHash,
1063
+ method: "GET",
1064
+ path: UrlJoin("ks", "jwt", "q", objectId),
1065
+ bodyType: "NONE",
1066
+ headers: {
1067
+ Authorization: "Bearer ".concat(token)
1068
+ }
1069
+ }));
1070
+
1071
+ case 9:
1072
+ _context9.t1 = _context9.sent.text();
1073
+ _context9.next = 12;
1074
+ return _context9.t0.awrap.call(_context9.t0, _context9.t1);
1075
+
1076
+ case 12:
1077
+ fabricToken = _context9.sent;
1078
+
1079
+ if (!this.noCache) {
1080
+ this.channelContentTokens[objectId] = {
1081
+ token: fabricToken,
1082
+ issuedAt: Date.now()
1083
+ };
1084
+ }
1108
1085
 
1109
- if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
1110
- _context9.next = 5;
1111
- break;
1112
- }
1086
+ return _context9.abrupt("return", fabricToken);
1087
+
1088
+ case 15:
1089
+ case "end":
1090
+ return _context9.stop();
1091
+ }
1092
+ }
1093
+ }, null, this);
1094
+ }
1095
+ }, {
1096
+ key: "IsV3",
1097
+ value: function IsV3(_ref16) {
1098
+ var id, contractName;
1099
+ return _regeneratorRuntime.async(function IsV3$(_context10) {
1100
+ while (1) {
1101
+ switch (_context10.prev = _context10.next) {
1102
+ case 0:
1103
+ id = _ref16.id;
1104
+
1105
+ if (!this.client.assumeV3) {
1106
+ _context10.next = 3;
1107
+ break;
1108
+ }
1113
1109
 
1114
- return _context9.abrupt("return", this.channelContentTokens[objectId].token);
1110
+ return _context10.abrupt("return", true);
1115
1111
 
1116
- case 5:
1117
- // Token expired
1118
- this.channelContentTokens[objectId] = undefined;
1112
+ case 3:
1113
+ _context10.next = 5;
1114
+ return _regeneratorRuntime.awrap(this.client.ethClient.ContractName(Utils.HashToAddress(id), true));
1119
1115
 
1120
- case 6:
1121
- _context9.next = 8;
1122
- return this.MakeKMSRequest({
1123
- objectId: objectId,
1124
- versionHash: versionHash,
1125
- method: "GET",
1126
- path: UrlJoin("ks", "jwt", "q", objectId),
1127
- bodyType: "NONE",
1128
- headers: {
1129
- Authorization: "Bearer ".concat(token)
1130
- }
1116
+ case 5:
1117
+ contractName = _context10.sent;
1118
+
1119
+ if (!this.accessVersions[contractName]) {
1120
+ this.accessVersions[contractName] = this.ContractHasMethod({
1121
+ contractAddress: this.client.utils.HashToAddress(id),
1122
+ abi: this.CONTRACTS.v3[this.ACCESS_TYPES.ACCESSIBLE].abi,
1123
+ methodName: "accessRequestV3"
1131
1124
  });
1125
+ }
1126
+
1127
+ _context10.next = 9;
1128
+ return _regeneratorRuntime.awrap(this.accessVersions[contractName]);
1132
1129
 
1133
- case 8:
1134
- _context9.next = 10;
1135
- return _context9.sent.text();
1130
+ case 9:
1131
+ return _context10.abrupt("return", _context10.sent);
1136
1132
 
1137
- case 10:
1138
- fabricToken = _context9.sent;
1133
+ case 10:
1134
+ case "end":
1135
+ return _context10.stop();
1136
+ }
1137
+ }
1138
+ }, null, this);
1139
+ }
1140
+ }, {
1141
+ key: "AccessInfo",
1142
+ value: function AccessInfo(_ref17) {
1143
+ var accessType, publicKey, args, isV3, checkAccessCharge;
1144
+ return _regeneratorRuntime.async(function AccessInfo$(_context11) {
1145
+ while (1) {
1146
+ switch (_context11.prev = _context11.next) {
1147
+ case 0:
1148
+ accessType = _ref17.accessType, publicKey = _ref17.publicKey, args = _ref17.args, isV3 = _ref17.isV3;
1149
+ checkAccessCharge = false;
1150
+
1151
+ if (accessType === ACCESS_TYPES.OBJECT) {
1152
+ checkAccessCharge = true;
1139
1153
 
1140
- if (!this.noCache) {
1141
- this.channelContentTokens[objectId] = {
1142
- token: fabricToken,
1143
- issuedAt: Date.now()
1144
- };
1154
+ if (!isV3) {
1155
+ if (args && args.length > 0) {
1156
+ // Inject public key of requester
1157
+ args[1] = this.client.signer.signingKey ? this.client.signer.signingKey.publicKey : "";
1158
+ } else {
1159
+ // Set default args
1160
+ args = [0, // Access level
1161
+ this.client.signer.signingKey ? this.client.signer.signingKey.publicKey : "", // Public key of requester
1162
+ publicKey, //cap.public_key,
1163
+ [], // Custom values
1164
+ [] // Stakeholders
1165
+ ];
1166
+ }
1145
1167
  }
1168
+ }
1146
1169
 
1147
- return _context9.abrupt("return", fabricToken);
1170
+ if (isV3 && (!args || args.length === 0)) {
1171
+ args = [[], // customValues
1172
+ [] // stakeholders
1173
+ ];
1174
+ }
1148
1175
 
1149
- case 13:
1150
- case "end":
1151
- return _context9.stop();
1152
- }
1153
- }
1154
- }, _callee9, this);
1155
- }));
1176
+ return _context11.abrupt("return", {
1177
+ accessArgs: args,
1178
+ checkAccessCharge: checkAccessCharge
1179
+ });
1156
1180
 
1157
- function GenerateOauthChannelToken(_x9) {
1158
- return _GenerateOauthChannelToken.apply(this, arguments);
1159
- }
1181
+ case 5:
1182
+ case "end":
1183
+ return _context11.stop();
1184
+ }
1185
+ }
1186
+ }, null, this);
1187
+ } // Determine type of ID based on contract version string
1160
1188
 
1161
- return GenerateOauthChannelToken;
1162
- }()
1163
1189
  }, {
1164
- key: "IsV3",
1165
- value: function () {
1166
- var _IsV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref12) {
1167
- var id, contractName;
1168
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
1169
- while (1) {
1170
- switch (_context10.prev = _context10.next) {
1171
- case 0:
1172
- id = _ref12.id;
1173
-
1174
- if (!this.client.assumeV3) {
1175
- _context10.next = 3;
1176
- break;
1177
- }
1190
+ key: "AccessType",
1191
+ value: function AccessType(id) {
1192
+ var contractName, accessType;
1193
+ return _regeneratorRuntime.async(function AccessType$(_context12) {
1194
+ while (1) {
1195
+ switch (_context12.prev = _context12.next) {
1196
+ case 0:
1197
+ _context12.next = 2;
1198
+ return _regeneratorRuntime.awrap(this.client.ethClient.ContractName(Utils.HashToAddress(id)));
1199
+
1200
+ case 2:
1201
+ contractName = _context12.sent;
1202
+
1203
+ if (this.accessTypes[id]) {
1204
+ _context12.next = 23;
1205
+ break;
1206
+ }
1178
1207
 
1179
- return _context10.abrupt("return", true);
1208
+ _context12.t0 = contractName;
1209
+ _context12.next = _context12.t0 === "BaseContentSpace" ? 7 : _context12.t0 === "BaseLibrary" ? 9 : _context12.t0 === "BaseContentType" ? 11 : _context12.t0 === "BsAccessWallet" ? 13 : _context12.t0 === "BsAccessCtrlGrp" ? 15 : _context12.t0 === "BaseContent" ? 17 : _context12.t0 === "BaseTenantSpace" ? 19 : 21;
1210
+ break;
1180
1211
 
1181
- case 3:
1182
- _context10.next = 5;
1183
- return this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
1212
+ case 7:
1213
+ accessType = ACCESS_TYPES.SPACE;
1214
+ return _context12.abrupt("break", 22);
1184
1215
 
1185
- case 5:
1186
- contractName = _context10.sent;
1216
+ case 9:
1217
+ accessType = ACCESS_TYPES.LIBRARY;
1218
+ return _context12.abrupt("break", 22);
1187
1219
 
1188
- if (!this.accessVersions[contractName]) {
1189
- this.accessVersions[contractName] = this.ContractHasMethod({
1190
- contractAddress: this.client.utils.HashToAddress(id),
1191
- abi: this.CONTRACTS.v3[this.ACCESS_TYPES.ACCESSIBLE].abi,
1192
- methodName: "accessRequestV3"
1193
- });
1194
- }
1220
+ case 11:
1221
+ accessType = ACCESS_TYPES.TYPE;
1222
+ return _context12.abrupt("break", 22);
1195
1223
 
1196
- _context10.next = 9;
1197
- return this.accessVersions[contractName];
1224
+ case 13:
1225
+ accessType = ACCESS_TYPES.WALLET;
1226
+ return _context12.abrupt("break", 22);
1198
1227
 
1199
- case 9:
1200
- return _context10.abrupt("return", _context10.sent);
1228
+ case 15:
1229
+ accessType = ACCESS_TYPES.GROUP;
1230
+ return _context12.abrupt("break", 22);
1201
1231
 
1202
- case 10:
1203
- case "end":
1204
- return _context10.stop();
1205
- }
1206
- }
1207
- }, _callee10, this);
1208
- }));
1232
+ case 17:
1233
+ accessType = ACCESS_TYPES.OBJECT;
1234
+ return _context12.abrupt("break", 22);
1209
1235
 
1210
- function IsV3(_x10) {
1211
- return _IsV.apply(this, arguments);
1212
- }
1236
+ case 19:
1237
+ accessType = ACCESS_TYPES.TENANT;
1238
+ return _context12.abrupt("break", 22);
1213
1239
 
1214
- return IsV3;
1215
- }()
1216
- }, {
1217
- key: "AccessInfo",
1218
- value: function () {
1219
- var _AccessInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref13) {
1220
- var accessType, publicKey, args, isV3, checkAccessCharge;
1221
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
1222
- while (1) {
1223
- switch (_context11.prev = _context11.next) {
1224
- case 0:
1225
- accessType = _ref13.accessType, publicKey = _ref13.publicKey, args = _ref13.args, isV3 = _ref13.isV3;
1226
- checkAccessCharge = false;
1227
-
1228
- if (accessType === ACCESS_TYPES.OBJECT) {
1229
- checkAccessCharge = true;
1230
-
1231
- if (!isV3) {
1232
- if (args && args.length > 0) {
1233
- // Inject public key of requester
1234
- args[1] = this.client.signer.signingKey ? this.client.signer.signingKey.publicKey : "";
1235
- } else {
1236
- // Set default args
1237
- args = [0, // Access level
1238
- this.client.signer.signingKey ? this.client.signer.signingKey.publicKey : "", // Public key of requester
1239
- publicKey, //cap.public_key,
1240
- [], // Custom values
1241
- [] // Stakeholders
1242
- ];
1243
- }
1244
- }
1245
- }
1246
-
1247
- if (isV3 && (!args || args.length === 0)) {
1248
- args = [[], // customValues
1249
- [] // stakeholders
1250
- ];
1251
- }
1252
-
1253
- return _context11.abrupt("return", {
1254
- accessArgs: args,
1255
- checkAccessCharge: checkAccessCharge
1256
- });
1257
-
1258
- case 5:
1259
- case "end":
1260
- return _context11.stop();
1261
- }
1262
- }
1263
- }, _callee11, this);
1264
- }));
1265
-
1266
- function AccessInfo(_x11) {
1267
- return _AccessInfo.apply(this, arguments);
1268
- }
1269
-
1270
- return AccessInfo;
1271
- }() // Determine type of ID based on contract version string
1272
-
1273
- }, {
1274
- key: "AccessType",
1275
- value: function () {
1276
- var _AccessType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id) {
1277
- var contractName, accessType;
1278
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1279
- while (1) {
1280
- switch (_context12.prev = _context12.next) {
1281
- case 0:
1282
- _context12.next = 2;
1283
- return this.client.ethClient.ContractName(Utils.HashToAddress(id));
1284
-
1285
- case 2:
1286
- contractName = _context12.sent;
1287
-
1288
- if (this.accessTypes[id]) {
1289
- _context12.next = 23;
1290
- break;
1291
- }
1292
-
1293
- _context12.t0 = contractName;
1294
- _context12.next = _context12.t0 === "BaseContentSpace" ? 7 : _context12.t0 === "BaseLibrary" ? 9 : _context12.t0 === "BaseContentType" ? 11 : _context12.t0 === "BsAccessWallet" ? 13 : _context12.t0 === "BsAccessCtrlGrp" ? 15 : _context12.t0 === "BaseContent" ? 17 : _context12.t0 === "BaseTenantSpace" ? 19 : 21;
1295
- break;
1296
-
1297
- case 7:
1298
- accessType = ACCESS_TYPES.SPACE;
1299
- return _context12.abrupt("break", 22);
1300
-
1301
- case 9:
1302
- accessType = ACCESS_TYPES.LIBRARY;
1303
- return _context12.abrupt("break", 22);
1304
-
1305
- case 11:
1306
- accessType = ACCESS_TYPES.TYPE;
1307
- return _context12.abrupt("break", 22);
1240
+ case 21:
1241
+ accessType = ACCESS_TYPES.OTHER;
1308
1242
 
1309
- case 13:
1310
- accessType = ACCESS_TYPES.WALLET;
1311
- return _context12.abrupt("break", 22);
1243
+ case 22:
1244
+ this.accessTypes[id] = accessType;
1312
1245
 
1313
- case 15:
1314
- accessType = ACCESS_TYPES.GROUP;
1315
- return _context12.abrupt("break", 22);
1246
+ case 23:
1247
+ return _context12.abrupt("return", this.accessTypes[id]);
1316
1248
 
1317
- case 17:
1318
- accessType = ACCESS_TYPES.OBJECT;
1319
- return _context12.abrupt("break", 22);
1320
-
1321
- case 19:
1322
- accessType = ACCESS_TYPES.TENANT;
1323
- return _context12.abrupt("break", 22);
1324
-
1325
- case 21:
1326
- accessType = ACCESS_TYPES.OTHER;
1327
-
1328
- case 22:
1329
- this.accessTypes[id] = accessType;
1330
-
1331
- case 23:
1332
- return _context12.abrupt("return", this.accessTypes[id]);
1333
-
1334
- case 24:
1335
- case "end":
1336
- return _context12.stop();
1337
- }
1249
+ case 24:
1250
+ case "end":
1251
+ return _context12.stop();
1338
1252
  }
1339
- }, _callee12, this);
1340
- }));
1341
-
1342
- function AccessType(_x12) {
1343
- return _AccessType.apply(this, arguments);
1344
- }
1345
-
1346
- return AccessType;
1347
- }()
1253
+ }
1254
+ }, null, this);
1255
+ }
1348
1256
  }, {
1349
1257
  key: "AccessComplete",
1350
- value: function () {
1351
- var _AccessComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref14) {
1352
- var id, score, _yield$this$ContractI3, abi, isV3, address, requestId, event;
1353
-
1354
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1355
- while (1) {
1356
- switch (_context13.prev = _context13.next) {
1357
- case 0:
1358
- id = _ref14.id, score = _ref14.score;
1359
- this.Log("Calling access complete on ".concat(id, " with score ").concat(score));
1360
- _context13.next = 4;
1361
- return this.ContractInfo({
1362
- id: id
1363
- });
1364
-
1365
- case 4:
1366
- _yield$this$ContractI3 = _context13.sent;
1367
- abi = _yield$this$ContractI3.abi;
1368
- isV3 = _yield$this$ContractI3.isV3;
1369
- address = Utils.HashToAddress(id);
1370
- requestId = this.requestIds[address];
1371
-
1372
- if (requestId) {
1373
- _context13.next = 11;
1374
- break;
1375
- }
1376
-
1377
- throw Error("Unknown request ID for " + id);
1378
-
1379
- case 11:
1380
- if (!isV3) {
1381
- _context13.next = 17;
1382
- break;
1383
- }
1384
-
1385
- _context13.next = 14;
1386
- return this.client.CallContractMethodAndWait({
1387
- contractAddress: address,
1388
- abi: abi,
1389
- methodName: "accessCompleteV3",
1390
- methodArgs: [requestId, [], []]
1391
- });
1392
-
1393
- case 14:
1394
- event = _context13.sent;
1395
- _context13.next = 20;
1258
+ value: function AccessComplete(_ref18) {
1259
+ var id, score, _ref19, abi, isV3, address, requestId, event;
1260
+
1261
+ return _regeneratorRuntime.async(function AccessComplete$(_context13) {
1262
+ while (1) {
1263
+ switch (_context13.prev = _context13.next) {
1264
+ case 0:
1265
+ id = _ref18.id, score = _ref18.score;
1266
+ this.Log("Calling access complete on ".concat(id, " with score ").concat(score));
1267
+ _context13.next = 4;
1268
+ return _regeneratorRuntime.awrap(this.ContractInfo({
1269
+ id: id
1270
+ }));
1271
+
1272
+ case 4:
1273
+ _ref19 = _context13.sent;
1274
+ abi = _ref19.abi;
1275
+ isV3 = _ref19.isV3;
1276
+ address = Utils.HashToAddress(id);
1277
+ requestId = this.requestIds[address];
1278
+
1279
+ if (requestId) {
1280
+ _context13.next = 11;
1396
1281
  break;
1282
+ }
1397
1283
 
1398
- case 17:
1399
- _context13.next = 19;
1400
- return this.client.CallContractMethodAndWait({
1401
- contractAddress: address,
1402
- abi: abi,
1403
- methodName: isV3 ? "accessCompleteV3" : "accessComplete",
1404
- methodArgs: [requestId, score, ""]
1405
- });
1406
-
1407
- case 19:
1408
- event = _context13.sent;
1284
+ throw Error("Unknown request ID for " + id);
1409
1285
 
1410
- case 20:
1411
- delete this.requestIds[address];
1412
- delete this.accessTransactions[address];
1413
- return _context13.abrupt("return", event);
1414
-
1415
- case 23:
1416
- case "end":
1417
- return _context13.stop();
1418
- }
1286
+ case 11:
1287
+ if (!isV3) {
1288
+ _context13.next = 17;
1289
+ break;
1290
+ }
1291
+
1292
+ _context13.next = 14;
1293
+ return _regeneratorRuntime.awrap(this.client.CallContractMethodAndWait({
1294
+ contractAddress: address,
1295
+ abi: abi,
1296
+ methodName: "accessCompleteV3",
1297
+ methodArgs: [requestId, [], []]
1298
+ }));
1299
+
1300
+ case 14:
1301
+ event = _context13.sent;
1302
+ _context13.next = 20;
1303
+ break;
1304
+
1305
+ case 17:
1306
+ _context13.next = 19;
1307
+ return _regeneratorRuntime.awrap(this.client.CallContractMethodAndWait({
1308
+ contractAddress: address,
1309
+ abi: abi,
1310
+ methodName: isV3 ? "accessCompleteV3" : "accessComplete",
1311
+ methodArgs: [requestId, score, ""]
1312
+ }));
1313
+
1314
+ case 19:
1315
+ event = _context13.sent;
1316
+
1317
+ case 20:
1318
+ delete this.requestIds[address];
1319
+ delete this.accessTransactions[address];
1320
+ return _context13.abrupt("return", event);
1321
+
1322
+ case 23:
1323
+ case "end":
1324
+ return _context13.stop();
1419
1325
  }
1420
- }, _callee13, this);
1421
- }));
1422
-
1423
- function AccessComplete(_x13) {
1424
- return _AccessComplete.apply(this, arguments);
1425
- }
1426
-
1427
- return AccessComplete;
1428
- }()
1326
+ }
1327
+ }, null, this);
1328
+ }
1429
1329
  /* Utility methods */
1430
1330
 
1431
1331
  }, {
1432
1332
  key: "ContractInfo",
1433
- value: function () {
1434
- var _ContractInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref15) {
1435
- var id, address, isV3, version, accessType;
1436
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1437
- while (1) {
1438
- switch (_context14.prev = _context14.next) {
1439
- case 0:
1440
- id = _ref15.id, address = _ref15.address;
1441
-
1442
- if (!address) {
1443
- address = Utils.HashToAddress(id);
1444
- }
1333
+ value: function ContractInfo(_ref20) {
1334
+ var id, address, isV3, version, accessType;
1335
+ return _regeneratorRuntime.async(function ContractInfo$(_context14) {
1336
+ while (1) {
1337
+ switch (_context14.prev = _context14.next) {
1338
+ case 0:
1339
+ id = _ref20.id, address = _ref20.address;
1340
+
1341
+ if (!address) {
1342
+ address = Utils.HashToAddress(id);
1343
+ }
1445
1344
 
1446
- if (!id) {
1447
- id = Utils.AddressToObjectId(address);
1448
- }
1345
+ if (!id) {
1346
+ id = Utils.AddressToObjectId(address);
1347
+ }
1449
1348
 
1450
- _context14.next = 5;
1451
- return this.IsV3({
1452
- id: id
1453
- });
1349
+ _context14.next = 5;
1350
+ return _regeneratorRuntime.awrap(this.IsV3({
1351
+ id: id
1352
+ }));
1454
1353
 
1455
- case 5:
1456
- isV3 = _context14.sent;
1457
- version = isV3 ? "v3" : "v2";
1458
- _context14.next = 9;
1459
- return this.AccessType(id);
1354
+ case 5:
1355
+ isV3 = _context14.sent;
1356
+ version = isV3 ? "v3" : "v2";
1357
+ _context14.next = 9;
1358
+ return _regeneratorRuntime.awrap(this.AccessType(id));
1460
1359
 
1461
- case 9:
1462
- accessType = _context14.sent;
1360
+ case 9:
1361
+ accessType = _context14.sent;
1463
1362
 
1464
- if (!(accessType === this.ACCESS_TYPES.OTHER)) {
1465
- _context14.next = 12;
1466
- break;
1467
- }
1363
+ if (!(accessType === this.ACCESS_TYPES.OTHER)) {
1364
+ _context14.next = 12;
1365
+ break;
1366
+ }
1468
1367
 
1469
- return _context14.abrupt("return", {});
1368
+ return _context14.abrupt("return", {});
1470
1369
 
1471
- case 12:
1472
- return _context14.abrupt("return", {
1473
- isV3: isV3,
1474
- accessType: accessType,
1475
- abi: this.CONTRACTS[version][accessType].abi
1476
- });
1370
+ case 12:
1371
+ return _context14.abrupt("return", {
1372
+ isV3: isV3,
1373
+ accessType: accessType,
1374
+ abi: this.CONTRACTS[version][accessType].abi
1375
+ });
1477
1376
 
1478
- case 13:
1479
- case "end":
1480
- return _context14.stop();
1481
- }
1377
+ case 13:
1378
+ case "end":
1379
+ return _context14.stop();
1482
1380
  }
1483
- }, _callee14, this);
1484
- }));
1485
-
1486
- function ContractInfo(_x14) {
1487
- return _ContractInfo.apply(this, arguments);
1488
- }
1489
-
1490
- return ContractInfo;
1491
- }()
1381
+ }
1382
+ }, null, this);
1383
+ }
1492
1384
  }, {
1493
1385
  key: "GetAccessCharge",
1494
- value: function () {
1495
- var _GetAccessCharge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref16) {
1496
- var objectId, args, _yield$this$ContractI4, abi, info;
1497
-
1498
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1499
- while (1) {
1500
- switch (_context15.prev = _context15.next) {
1501
- case 0:
1502
- objectId = _ref16.objectId, args = _ref16.args;
1503
- _context15.next = 3;
1504
- return this.ContractInfo({
1505
- id: objectId
1506
- });
1507
-
1508
- case 3:
1509
- _yield$this$ContractI4 = _context15.sent;
1510
- abi = _yield$this$ContractI4.abi;
1511
- _context15.next = 7;
1512
- return this.client.CallContractMethod({
1513
- contractAddress: Utils.HashToAddress(objectId),
1514
- abi: abi,
1515
- methodName: "getAccessInfo",
1516
- methodArgs: args
1517
- });
1518
-
1519
- case 7:
1520
- info = _context15.sent;
1521
- return _context15.abrupt("return", info[1] === 0 ? 0 : info[2]);
1522
-
1523
- case 9:
1524
- case "end":
1525
- return _context15.stop();
1526
- }
1386
+ value: function GetAccessCharge(_ref21) {
1387
+ var objectId, args, _ref22, abi, info;
1388
+
1389
+ return _regeneratorRuntime.async(function GetAccessCharge$(_context15) {
1390
+ while (1) {
1391
+ switch (_context15.prev = _context15.next) {
1392
+ case 0:
1393
+ objectId = _ref21.objectId, args = _ref21.args;
1394
+ _context15.next = 3;
1395
+ return _regeneratorRuntime.awrap(this.ContractInfo({
1396
+ id: objectId
1397
+ }));
1398
+
1399
+ case 3:
1400
+ _ref22 = _context15.sent;
1401
+ abi = _ref22.abi;
1402
+ _context15.next = 7;
1403
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
1404
+ contractAddress: Utils.HashToAddress(objectId),
1405
+ abi: abi,
1406
+ methodName: "getAccessInfo",
1407
+ methodArgs: args
1408
+ }));
1409
+
1410
+ case 7:
1411
+ info = _context15.sent;
1412
+ return _context15.abrupt("return", info[1] === 0 ? 0 : info[2]);
1413
+
1414
+ case 9:
1415
+ case "end":
1416
+ return _context15.stop();
1527
1417
  }
1528
- }, _callee15, this);
1529
- }));
1530
-
1531
- function GetAccessCharge(_x15) {
1532
- return _GetAccessCharge.apply(this, arguments);
1533
- }
1534
-
1535
- return GetAccessCharge;
1536
- }()
1418
+ }
1419
+ }, null, this);
1420
+ }
1537
1421
  }, {
1538
1422
  key: "Owner",
1539
- value: function () {
1540
- var _Owner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref17) {
1541
- var id, address, ownerAddress;
1542
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1543
- while (1) {
1544
- switch (_context16.prev = _context16.next) {
1545
- case 0:
1546
- id = _ref17.id, address = _ref17.address;
1547
-
1548
- if (this.client.signer) {
1549
- _context16.next = 3;
1550
- break;
1551
- }
1552
-
1553
- return _context16.abrupt("return", false);
1554
-
1555
- case 3:
1556
- if (id) {
1557
- address = Utils.HashToAddress(id);
1558
- }
1559
-
1560
- _context16.next = 6;
1561
- return this.client.CallContractMethod({
1562
- contractAddress: address,
1563
- methodName: "owner",
1564
- methodArgs: []
1565
- });
1423
+ value: function Owner(_ref23) {
1424
+ var id, address, ownerAddress;
1425
+ return _regeneratorRuntime.async(function Owner$(_context16) {
1426
+ while (1) {
1427
+ switch (_context16.prev = _context16.next) {
1428
+ case 0:
1429
+ id = _ref23.id, address = _ref23.address;
1430
+
1431
+ if (this.client.signer) {
1432
+ _context16.next = 3;
1433
+ break;
1434
+ }
1566
1435
 
1567
- case 6:
1568
- ownerAddress = _context16.sent;
1569
- return _context16.abrupt("return", Utils.FormatAddress(ownerAddress));
1436
+ return _context16.abrupt("return", false);
1570
1437
 
1571
- case 8:
1572
- case "end":
1573
- return _context16.stop();
1574
- }
1438
+ case 3:
1439
+ if (id) {
1440
+ address = Utils.HashToAddress(id);
1441
+ }
1442
+
1443
+ _context16.next = 6;
1444
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
1445
+ contractAddress: address,
1446
+ methodName: "owner",
1447
+ methodArgs: []
1448
+ }));
1449
+
1450
+ case 6:
1451
+ ownerAddress = _context16.sent;
1452
+ return _context16.abrupt("return", Utils.FormatAddress(ownerAddress));
1453
+
1454
+ case 8:
1455
+ case "end":
1456
+ return _context16.stop();
1575
1457
  }
1576
- }, _callee16, this);
1577
- }));
1578
-
1579
- function Owner(_x16) {
1580
- return _Owner.apply(this, arguments);
1581
- }
1582
-
1583
- return Owner;
1584
- }()
1458
+ }
1459
+ }, null, this);
1460
+ }
1585
1461
  }, {
1586
1462
  key: "Sign",
1587
- value: function () {
1588
- var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(message) {
1589
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1590
- while (1) {
1591
- switch (_context17.prev = _context17.next) {
1592
- case 0:
1593
- _context17.t0 = Ethers.utils;
1594
-
1595
- if (!this.client.signer.signDigest) {
1596
- _context17.next = 7;
1597
- break;
1598
- }
1599
-
1600
- _context17.next = 4;
1601
- return this.client.signer.signDigest(message);
1602
-
1603
- case 4:
1604
- _context17.t1 = _context17.sent;
1605
- _context17.next = 10;
1463
+ value: function Sign(message) {
1464
+ return _regeneratorRuntime.async(function Sign$(_context17) {
1465
+ while (1) {
1466
+ switch (_context17.prev = _context17.next) {
1467
+ case 0:
1468
+ _context17.t0 = _regeneratorRuntime;
1469
+ _context17.t1 = Ethers.utils;
1470
+
1471
+ if (!this.client.signer.signDigest) {
1472
+ _context17.next = 8;
1606
1473
  break;
1474
+ }
1607
1475
 
1608
- case 7:
1609
- _context17.next = 9;
1610
- return this.client.signer.signingKey.signDigest(message);
1476
+ _context17.next = 5;
1477
+ return _regeneratorRuntime.awrap(this.client.signer.signDigest(message));
1611
1478
 
1612
- case 9:
1613
- _context17.t1 = _context17.sent;
1479
+ case 5:
1480
+ _context17.t2 = _context17.sent;
1481
+ _context17.next = 11;
1482
+ break;
1614
1483
 
1615
- case 10:
1616
- _context17.t2 = _context17.t1;
1617
- _context17.next = 13;
1618
- return _context17.t0.joinSignature.call(_context17.t0, _context17.t2);
1484
+ case 8:
1485
+ _context17.next = 10;
1486
+ return _regeneratorRuntime.awrap(this.client.signer.signingKey.signDigest(message));
1619
1487
 
1620
- case 13:
1621
- return _context17.abrupt("return", _context17.sent);
1488
+ case 10:
1489
+ _context17.t2 = _context17.sent;
1622
1490
 
1623
- case 14:
1624
- case "end":
1625
- return _context17.stop();
1626
- }
1627
- }
1628
- }, _callee17, this);
1629
- }));
1491
+ case 11:
1492
+ _context17.t3 = _context17.t2;
1493
+ _context17.t4 = _context17.t1.joinSignature.call(_context17.t1, _context17.t3);
1494
+ _context17.next = 15;
1495
+ return _context17.t0.awrap.call(_context17.t0, _context17.t4);
1630
1496
 
1631
- function Sign(_x17) {
1632
- return _Sign.apply(this, arguments);
1633
- }
1497
+ case 15:
1498
+ return _context17.abrupt("return", _context17.sent);
1634
1499
 
1635
- return Sign;
1636
- }()
1500
+ case 16:
1501
+ case "end":
1502
+ return _context17.stop();
1503
+ }
1504
+ }
1505
+ }, null, this);
1506
+ }
1637
1507
  }, {
1638
1508
  key: "KMSAddress",
1639
- value: function () {
1640
- var _KMSAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1641
- var objectId, versionHash, _yield$this$ContractI5, abi;
1642
-
1643
- return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1644
- while (1) {
1645
- switch (_context18.prev = _context18.next) {
1646
- case 0:
1647
- objectId = _ref18.objectId, versionHash = _ref18.versionHash;
1648
-
1649
- if (versionHash) {
1650
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
1651
- }
1652
-
1653
- _context18.next = 4;
1654
- return this.ContractInfo({
1655
- id: objectId
1656
- });
1657
-
1658
- case 4:
1659
- _yield$this$ContractI5 = _context18.sent;
1660
- abi = _yield$this$ContractI5.abi;
1661
-
1662
- if (abi) {
1663
- _context18.next = 8;
1664
- break;
1665
- }
1509
+ value: function KMSAddress(_ref24) {
1510
+ var objectId, versionHash, _ref25, abi;
1511
+
1512
+ return _regeneratorRuntime.async(function KMSAddress$(_context18) {
1513
+ while (1) {
1514
+ switch (_context18.prev = _context18.next) {
1515
+ case 0:
1516
+ objectId = _ref24.objectId, versionHash = _ref24.versionHash;
1517
+
1518
+ if (versionHash) {
1519
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1520
+ }
1521
+
1522
+ _context18.next = 4;
1523
+ return _regeneratorRuntime.awrap(this.ContractInfo({
1524
+ id: objectId
1525
+ }));
1526
+
1527
+ case 4:
1528
+ _ref25 = _context18.sent;
1529
+ abi = _ref25.abi;
1530
+
1531
+ if (abi) {
1532
+ _context18.next = 8;
1533
+ break;
1534
+ }
1666
1535
 
1667
- throw Error("Unable to determine contract info for ".concat(objectId, " - wrong network?"));
1536
+ throw Error("Unable to determine contract info for ".concat(objectId, " - wrong network?"));
1668
1537
 
1669
- case 8:
1670
- _context18.next = 10;
1671
- return this.client.CallContractMethod({
1672
- contractAddress: Utils.HashToAddress(objectId),
1673
- abi: abi,
1674
- methodName: "addressKMS"
1675
- });
1538
+ case 8:
1539
+ _context18.next = 10;
1540
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
1541
+ contractAddress: Utils.HashToAddress(objectId),
1542
+ abi: abi,
1543
+ methodName: "addressKMS"
1544
+ }));
1676
1545
 
1677
- case 10:
1678
- return _context18.abrupt("return", _context18.sent);
1546
+ case 10:
1547
+ return _context18.abrupt("return", _context18.sent);
1679
1548
 
1680
- case 11:
1681
- case "end":
1682
- return _context18.stop();
1683
- }
1549
+ case 11:
1550
+ case "end":
1551
+ return _context18.stop();
1684
1552
  }
1685
- }, _callee18, this);
1686
- }));
1687
-
1688
- function KMSAddress(_x18) {
1689
- return _KMSAddress.apply(this, arguments);
1690
- }
1691
-
1692
- return KMSAddress;
1693
- }()
1553
+ }
1554
+ }, null, this);
1555
+ }
1694
1556
  }, {
1695
1557
  key: "KMSInfo",
1696
- value: function () {
1697
- var _KMSInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref19) {
1698
- var objectId, versionHash, kmsId, KMSInfo, _yield$this$ContractI6, abi, _yield$this$ContractI7, _abi, publicKey;
1699
-
1700
- return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1701
- while (1) {
1702
- switch (_context19.prev = _context19.next) {
1703
- case 0:
1704
- objectId = _ref19.objectId, versionHash = _ref19.versionHash, kmsId = _ref19.kmsId;
1705
-
1706
- if (!kmsId) {
1707
- _context19.next = 11;
1708
- break;
1709
- }
1558
+ value: function KMSInfo(_ref26) {
1559
+ var objectId, versionHash, kmsId, KMSInfo, _ref27, abi, _ref28, _abi, publicKey;
1710
1560
 
1711
- _context19.next = 4;
1712
- return this.ContractInfo({
1713
- address: this.client.contentSpaceAddress
1714
- });
1715
-
1716
- case 4:
1717
- _yield$this$ContractI6 = _context19.sent;
1718
- abi = _yield$this$ContractI6.abi;
1719
- _context19.next = 8;
1720
- return this.client.CallContractMethod({
1721
- contractAddress: this.client.contentSpaceAddress,
1722
- abi: abi,
1723
- methodName: "getKMSInfo",
1724
- methodArgs: [kmsId, []],
1725
- formatArguments: false
1726
- });
1561
+ return _regeneratorRuntime.async(function KMSInfo$(_context19) {
1562
+ while (1) {
1563
+ switch (_context19.prev = _context19.next) {
1564
+ case 0:
1565
+ objectId = _ref26.objectId, versionHash = _ref26.versionHash, kmsId = _ref26.kmsId;
1727
1566
 
1728
- case 8:
1729
- KMSInfo = _context19.sent;
1730
- _context19.next = 19;
1567
+ if (!kmsId) {
1568
+ _context19.next = 11;
1731
1569
  break;
1732
-
1733
- case 11:
1734
- if (versionHash) {
1735
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
1736
- }
1737
-
1738
- _context19.next = 14;
1739
- return this.ContractInfo({
1740
- id: objectId
1741
- });
1742
-
1743
- case 14:
1744
- _yield$this$ContractI7 = _context19.sent;
1745
- _abi = _yield$this$ContractI7.abi;
1746
- _context19.next = 18;
1747
- return this.client.CallContractMethod({
1748
- contractAddress: Utils.HashToAddress(objectId),
1749
- abi: _abi,
1750
- methodName: "getKMSInfo",
1751
- methodArgs: [[]],
1752
- formatArguments: false
1753
- });
1754
-
1755
- case 18:
1756
- KMSInfo = _context19.sent;
1757
-
1758
- case 19:
1759
- // Public key is compressed and hashed
1760
- publicKey = Ethers.utils.computePublicKey(Utils.HashToAddress(KMSInfo[1]), false);
1761
- return _context19.abrupt("return", {
1762
- urls: KMSInfo[0].split(","),
1763
- publicKey: publicKey
1764
- });
1765
-
1766
- case 21:
1767
- case "end":
1768
- return _context19.stop();
1769
- }
1570
+ }
1571
+
1572
+ _context19.next = 4;
1573
+ return _regeneratorRuntime.awrap(this.ContractInfo({
1574
+ address: this.client.contentSpaceAddress
1575
+ }));
1576
+
1577
+ case 4:
1578
+ _ref27 = _context19.sent;
1579
+ abi = _ref27.abi;
1580
+ _context19.next = 8;
1581
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
1582
+ contractAddress: this.client.contentSpaceAddress,
1583
+ abi: abi,
1584
+ methodName: "getKMSInfo",
1585
+ methodArgs: [kmsId, []],
1586
+ formatArguments: false
1587
+ }));
1588
+
1589
+ case 8:
1590
+ KMSInfo = _context19.sent;
1591
+ _context19.next = 19;
1592
+ break;
1593
+
1594
+ case 11:
1595
+ if (versionHash) {
1596
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1597
+ }
1598
+
1599
+ _context19.next = 14;
1600
+ return _regeneratorRuntime.awrap(this.ContractInfo({
1601
+ id: objectId
1602
+ }));
1603
+
1604
+ case 14:
1605
+ _ref28 = _context19.sent;
1606
+ _abi = _ref28.abi;
1607
+ _context19.next = 18;
1608
+ return _regeneratorRuntime.awrap(this.client.CallContractMethod({
1609
+ contractAddress: Utils.HashToAddress(objectId),
1610
+ abi: _abi,
1611
+ methodName: "getKMSInfo",
1612
+ methodArgs: [[]],
1613
+ formatArguments: false
1614
+ }));
1615
+
1616
+ case 18:
1617
+ KMSInfo = _context19.sent;
1618
+
1619
+ case 19:
1620
+ // Public key is compressed and hashed
1621
+ publicKey = Ethers.utils.computePublicKey(Utils.HashToAddress(KMSInfo[1]), false);
1622
+ return _context19.abrupt("return", {
1623
+ urls: KMSInfo[0].split(","),
1624
+ publicKey: publicKey
1625
+ });
1626
+
1627
+ case 21:
1628
+ case "end":
1629
+ return _context19.stop();
1770
1630
  }
1771
- }, _callee19, this);
1772
- }));
1773
-
1774
- function KMSInfo(_x19) {
1775
- return _KMSInfo.apply(this, arguments);
1776
- }
1777
-
1778
- return KMSInfo;
1779
- }() // Retrieve symmetric key for object
1631
+ }
1632
+ }, null, this);
1633
+ } // Retrieve symmetric key for object
1780
1634
 
1781
1635
  }, {
1782
1636
  key: "RetrieveConk",
1783
- value: function () {
1784
- var _RetrieveConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref20) {
1785
- var libraryId, objectId, kmsAddress, kmsCapId, kmsCap, cap;
1786
- return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1787
- while (1) {
1788
- switch (_context20.prev = _context20.next) {
1789
- case 0:
1790
- libraryId = _ref20.libraryId, objectId = _ref20.objectId;
1791
-
1792
- if (libraryId) {
1793
- _context20.next = 5;
1794
- break;
1795
- }
1796
-
1797
- _context20.next = 4;
1798
- return this.client.ContentObjectLibraryId({
1799
- objectId: objectId
1800
- });
1801
-
1802
- case 4:
1803
- libraryId = _context20.sent;
1804
-
1805
- case 5:
1806
- _context20.next = 7;
1807
- return this.KMSAddress({
1808
- objectId: objectId
1809
- });
1810
-
1811
- case 7:
1812
- kmsAddress = _context20.sent;
1813
- kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1814
- _context20.next = 11;
1815
- return this.client.ContentObjectMetadata({
1816
- libraryId: libraryId,
1817
- objectId: objectId,
1818
- metadataSubtree: kmsCapId
1819
- });
1820
-
1821
- case 11:
1822
- kmsCap = _context20.sent;
1823
-
1824
- if (kmsCap) {
1825
- _context20.next = 14;
1826
- break;
1827
- }
1828
-
1829
- throw Error("No KMS key set for this object");
1830
-
1831
- case 14:
1832
- _context20.next = 16;
1833
- return this.MakeKMSCall({
1834
- objectId: objectId,
1835
- methodName: "elv_getEncryptionKey",
1836
- paramTypes: ["string", "string", "string", "string", "string"],
1837
- params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1838
- });
1839
-
1840
- case 16:
1841
- cap = _context20.sent;
1842
- return _context20.abrupt("return", JSON.parse(Utils.FromB58(cap.replace(/^kp__/, "")).toString("utf-8")));
1843
-
1844
- case 18:
1845
- case "end":
1846
- return _context20.stop();
1847
- }
1637
+ value: function RetrieveConk(_ref29) {
1638
+ var libraryId, objectId, kmsAddress, kmsCapId, kmsCap, cap;
1639
+ return _regeneratorRuntime.async(function RetrieveConk$(_context20) {
1640
+ while (1) {
1641
+ switch (_context20.prev = _context20.next) {
1642
+ case 0:
1643
+ libraryId = _ref29.libraryId, objectId = _ref29.objectId;
1644
+
1645
+ if (libraryId) {
1646
+ _context20.next = 5;
1647
+ break;
1648
+ }
1649
+
1650
+ _context20.next = 4;
1651
+ return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
1652
+ objectId: objectId
1653
+ }));
1654
+
1655
+ case 4:
1656
+ libraryId = _context20.sent;
1657
+
1658
+ case 5:
1659
+ _context20.next = 7;
1660
+ return _regeneratorRuntime.awrap(this.KMSAddress({
1661
+ objectId: objectId
1662
+ }));
1663
+
1664
+ case 7:
1665
+ kmsAddress = _context20.sent;
1666
+ kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1667
+ _context20.next = 11;
1668
+ return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
1669
+ libraryId: libraryId,
1670
+ objectId: objectId,
1671
+ metadataSubtree: kmsCapId
1672
+ }));
1673
+
1674
+ case 11:
1675
+ kmsCap = _context20.sent;
1676
+
1677
+ if (kmsCap) {
1678
+ _context20.next = 14;
1679
+ break;
1680
+ }
1681
+
1682
+ throw Error("No KMS key set for this object");
1683
+
1684
+ case 14:
1685
+ _context20.next = 16;
1686
+ return _regeneratorRuntime.awrap(this.MakeKMSCall({
1687
+ objectId: objectId,
1688
+ methodName: "elv_getEncryptionKey",
1689
+ paramTypes: ["string", "string", "string", "string", "string"],
1690
+ params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1691
+ }));
1692
+
1693
+ case 16:
1694
+ cap = _context20.sent;
1695
+ return _context20.abrupt("return", JSON.parse(Utils.FromB58(cap.replace(/^kp__/, "")).toString("utf-8")));
1696
+
1697
+ case 18:
1698
+ case "end":
1699
+ return _context20.stop();
1848
1700
  }
1849
- }, _callee20, this);
1850
- }));
1851
-
1852
- function RetrieveConk(_x20) {
1853
- return _RetrieveConk.apply(this, arguments);
1854
- }
1855
-
1856
- return RetrieveConk;
1857
- }() // Retrieve symmetric key for object
1701
+ }
1702
+ }, null, this);
1703
+ } // Retrieve symmetric key for object
1858
1704
 
1859
1705
  }, {
1860
1706
  key: "RetrieveReencryptionSymmetricKey",
1861
- value: function () {
1862
- var _RetrieveReencryptionSymmetricKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref21) {
1863
- var libraryId, objectId, kmsAddress, kmsCapId, kmsCap;
1864
- return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1865
- while (1) {
1866
- switch (_context21.prev = _context21.next) {
1867
- case 0:
1868
- libraryId = _ref21.libraryId, objectId = _ref21.objectId;
1869
-
1870
- if (libraryId) {
1871
- _context21.next = 5;
1872
- break;
1873
- }
1874
-
1875
- _context21.next = 4;
1876
- return this.client.ContentObjectLibraryId({
1877
- objectId: objectId
1878
- });
1879
-
1880
- case 4:
1881
- libraryId = _context21.sent;
1882
-
1883
- case 5:
1884
- _context21.next = 7;
1885
- return this.KMSAddress({
1886
- objectId: objectId
1887
- });
1888
-
1889
- case 7:
1890
- kmsAddress = _context21.sent;
1891
- kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1892
- _context21.next = 11;
1893
- return this.client.ContentObjectMetadata({
1894
- libraryId: libraryId,
1895
- objectId: objectId,
1896
- metadataSubtree: kmsCapId
1897
- });
1898
-
1899
- case 11:
1900
- kmsCap = _context21.sent;
1901
-
1902
- if (kmsCap) {
1903
- _context21.next = 14;
1904
- break;
1905
- }
1707
+ value: function RetrieveReencryptionSymmetricKey(_ref30) {
1708
+ var libraryId, objectId, kmsAddress, kmsCapId, kmsCap;
1709
+ return _regeneratorRuntime.async(function RetrieveReencryptionSymmetricKey$(_context21) {
1710
+ while (1) {
1711
+ switch (_context21.prev = _context21.next) {
1712
+ case 0:
1713
+ libraryId = _ref30.libraryId, objectId = _ref30.objectId;
1714
+
1715
+ if (libraryId) {
1716
+ _context21.next = 5;
1717
+ break;
1718
+ }
1719
+
1720
+ _context21.next = 4;
1721
+ return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
1722
+ objectId: objectId
1723
+ }));
1724
+
1725
+ case 4:
1726
+ libraryId = _context21.sent;
1727
+
1728
+ case 5:
1729
+ _context21.next = 7;
1730
+ return _regeneratorRuntime.awrap(this.KMSAddress({
1731
+ objectId: objectId
1732
+ }));
1733
+
1734
+ case 7:
1735
+ kmsAddress = _context21.sent;
1736
+ kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1737
+ _context21.next = 11;
1738
+ return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
1739
+ libraryId: libraryId,
1740
+ objectId: objectId,
1741
+ metadataSubtree: kmsCapId
1742
+ }));
1743
+
1744
+ case 11:
1745
+ kmsCap = _context21.sent;
1746
+
1747
+ if (kmsCap) {
1748
+ _context21.next = 14;
1749
+ break;
1750
+ }
1906
1751
 
1907
- throw Error("No KMS key set for this object");
1752
+ throw Error("No KMS key set for this object");
1908
1753
 
1909
- case 14:
1910
- _context21.next = 16;
1911
- return this.MakeKMSCall({
1912
- objectId: objectId,
1913
- methodName: "elv_getSymmetricKeyAuth",
1914
- paramTypes: ["string", "string", "string", "string", "string"],
1915
- params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1916
- });
1754
+ case 14:
1755
+ _context21.next = 16;
1756
+ return _regeneratorRuntime.awrap(this.MakeKMSCall({
1757
+ objectId: objectId,
1758
+ methodName: "elv_getSymmetricKeyAuth",
1759
+ paramTypes: ["string", "string", "string", "string", "string"],
1760
+ params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1761
+ }));
1917
1762
 
1918
- case 16:
1919
- return _context21.abrupt("return", _context21.sent);
1763
+ case 16:
1764
+ return _context21.abrupt("return", _context21.sent);
1920
1765
 
1921
- case 17:
1922
- case "end":
1923
- return _context21.stop();
1924
- }
1766
+ case 17:
1767
+ case "end":
1768
+ return _context21.stop();
1925
1769
  }
1926
- }, _callee21, this);
1927
- }));
1928
-
1929
- function RetrieveReencryptionSymmetricKey(_x21) {
1930
- return _RetrieveReencryptionSymmetricKey.apply(this, arguments);
1931
- }
1932
-
1933
- return RetrieveReencryptionSymmetricKey;
1934
- }() // Make an RPC call to the KMS with signed parameters
1770
+ }
1771
+ }, null, this);
1772
+ } // Make an RPC call to the KMS with signed parameters
1935
1773
 
1936
1774
  }, {
1937
1775
  key: "MakeKMSCall",
1938
- value: function () {
1939
- var _MakeKMSCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref22) {
1940
- var kmsId, tenantId, objectId, versionHash, methodName, params, paramTypes, _ref22$additionalPara, additionalParams, _ref22$signature, signature, packedHash, KMSUrls, i, kmsUrl;
1941
-
1942
- return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1943
- while (1) {
1944
- switch (_context22.prev = _context22.next) {
1945
- case 0:
1946
- kmsId = _ref22.kmsId, tenantId = _ref22.tenantId, objectId = _ref22.objectId, versionHash = _ref22.versionHash, methodName = _ref22.methodName, params = _ref22.params, paramTypes = _ref22.paramTypes, _ref22$additionalPara = _ref22.additionalParams, additionalParams = _ref22$additionalPara === void 0 ? [] : _ref22$additionalPara, _ref22$signature = _ref22.signature, signature = _ref22$signature === void 0 ? true : _ref22$signature;
1947
-
1948
- if (versionHash) {
1949
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
1950
- }
1951
-
1952
- if (objectId) {
1953
- _context22.next = 10;
1954
- break;
1955
- }
1956
-
1957
- _context22.t0 = "ikms";
1958
- _context22.t1 = Utils;
1959
- _context22.next = 7;
1960
- return this.client.DefaultKMSAddress({
1961
- tenantId: tenantId
1962
- });
1963
-
1964
- case 7:
1965
- _context22.t2 = _context22.sent;
1966
- _context22.t3 = _context22.t1.AddressToHash.call(_context22.t1, _context22.t2);
1967
- kmsId = _context22.t0.concat.call(_context22.t0, _context22.t3);
1968
-
1969
- case 10:
1970
- if (!signature) {
1971
- _context22.next = 17;
1972
- break;
1973
- }
1776
+ value: function MakeKMSCall(_ref31) {
1777
+ var kmsId, tenantId, objectId, versionHash, methodName, params, paramTypes, _ref31$additionalPara, additionalParams, _ref31$signature, signature, packedHash, KMSUrls, i, kmsUrl;
1974
1778
 
1975
- packedHash = Ethers.utils.solidityKeccak256(paramTypes, params);
1976
- _context22.t4 = params;
1977
- _context22.next = 15;
1978
- return this.Sign(packedHash);
1779
+ return _regeneratorRuntime.async(function MakeKMSCall$(_context22) {
1780
+ while (1) {
1781
+ switch (_context22.prev = _context22.next) {
1782
+ case 0:
1783
+ kmsId = _ref31.kmsId, tenantId = _ref31.tenantId, objectId = _ref31.objectId, versionHash = _ref31.versionHash, methodName = _ref31.methodName, params = _ref31.params, paramTypes = _ref31.paramTypes, _ref31$additionalPara = _ref31.additionalParams, additionalParams = _ref31$additionalPara === void 0 ? [] : _ref31$additionalPara, _ref31$signature = _ref31.signature, signature = _ref31$signature === void 0 ? true : _ref31$signature;
1979
1784
 
1980
- case 15:
1981
- _context22.t5 = _context22.sent;
1785
+ if (versionHash) {
1786
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1787
+ }
1982
1788
 
1983
- _context22.t4.push.call(_context22.t4, _context22.t5);
1984
-
1985
- case 17:
1986
- params = params.concat(additionalParams);
1987
- _context22.next = 20;
1988
- return this.KMSInfo({
1989
- kmsId: kmsId,
1990
- objectId: objectId,
1991
- versionHash: versionHash
1992
- });
1993
-
1994
- case 20:
1995
- KMSUrls = _context22.sent.urls;
1996
- i = 0;
1997
-
1998
- case 22:
1999
- if (!(i < KMSUrls.length)) {
2000
- _context22.next = 40;
2001
- break;
2002
- }
2003
-
2004
- _context22.prev = 23;
2005
- this.Log("Making KMS request:\n URL: ".concat(KMSUrls[i], "\n Method: ").concat(methodName, "\n Params: ").concat(params.join(", ")));
2006
- kmsUrl = KMSUrls[i];
2007
-
2008
- if (!this.providers[kmsUrl]) {
2009
- this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
2010
- }
1789
+ if (objectId) {
1790
+ _context22.next = 10;
1791
+ break;
1792
+ }
1793
+
1794
+ _context22.t0 = "ikms";
1795
+ _context22.t1 = Utils;
1796
+ _context22.next = 7;
1797
+ return _regeneratorRuntime.awrap(this.client.DefaultKMSAddress({
1798
+ tenantId: tenantId
1799
+ }));
1800
+
1801
+ case 7:
1802
+ _context22.t2 = _context22.sent;
1803
+ _context22.t3 = _context22.t1.AddressToHash.call(_context22.t1, _context22.t2);
1804
+ kmsId = _context22.t0.concat.call(_context22.t0, _context22.t3);
1805
+
1806
+ case 10:
1807
+ if (!signature) {
1808
+ _context22.next = 17;
1809
+ break;
1810
+ }
1811
+
1812
+ packedHash = Ethers.utils.solidityKeccak256(paramTypes, params);
1813
+ _context22.t4 = params;
1814
+ _context22.next = 15;
1815
+ return _regeneratorRuntime.awrap(this.Sign(packedHash));
1816
+
1817
+ case 15:
1818
+ _context22.t5 = _context22.sent;
1819
+
1820
+ _context22.t4.push.call(_context22.t4, _context22.t5);
1821
+
1822
+ case 17:
1823
+ params = params.concat(additionalParams);
1824
+ _context22.next = 20;
1825
+ return _regeneratorRuntime.awrap(this.KMSInfo({
1826
+ kmsId: kmsId,
1827
+ objectId: objectId,
1828
+ versionHash: versionHash
1829
+ }));
1830
+
1831
+ case 20:
1832
+ KMSUrls = _context22.sent.urls;
1833
+ i = 0;
1834
+
1835
+ case 22:
1836
+ if (!(i < KMSUrls.length)) {
1837
+ _context22.next = 40;
1838
+ break;
1839
+ }
2011
1840
 
2012
- _context22.next = 29;
2013
- return this.providers[kmsUrl].send(methodName, params);
1841
+ _context22.prev = 23;
1842
+ this.Log("Making KMS request:\n URL: ".concat(KMSUrls[i], "\n Method: ").concat(methodName, "\n Params: ").concat(params.join(", ")));
1843
+ kmsUrl = KMSUrls[i];
2014
1844
 
2015
- case 29:
2016
- return _context22.abrupt("return", _context22.sent);
1845
+ if (!this.providers[kmsUrl]) {
1846
+ this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
1847
+ }
2017
1848
 
2018
- case 32:
2019
- _context22.prev = 32;
2020
- _context22.t6 = _context22["catch"](23);
2021
- this.Log("KMS Call Error: ".concat(_context22.t6), true); // If the request has been attempted on all KMS urls, throw the error
1849
+ _context22.next = 29;
1850
+ return _regeneratorRuntime.awrap(this.providers[kmsUrl].send(methodName, params));
2022
1851
 
2023
- if (!(i === KMSUrls.length - 1)) {
2024
- _context22.next = 37;
2025
- break;
2026
- }
1852
+ case 29:
1853
+ return _context22.abrupt("return", _context22.sent);
2027
1854
 
2028
- throw _context22.t6;
1855
+ case 32:
1856
+ _context22.prev = 32;
1857
+ _context22.t6 = _context22["catch"](23);
1858
+ this.Log("KMS Call Error: ".concat(_context22.t6), true); // If the request has been attempted on all KMS urls, throw the error
2029
1859
 
2030
- case 37:
2031
- i++;
2032
- _context22.next = 22;
1860
+ if (!(i === KMSUrls.length - 1)) {
1861
+ _context22.next = 37;
2033
1862
  break;
1863
+ }
2034
1864
 
2035
- case 40:
2036
- case "end":
2037
- return _context22.stop();
2038
- }
2039
- }
2040
- }, _callee22, this, [[23, 32]]);
2041
- }));
1865
+ throw _context22.t6;
2042
1866
 
2043
- function MakeKMSCall(_x22) {
2044
- return _MakeKMSCall.apply(this, arguments);
2045
- }
1867
+ case 37:
1868
+ i++;
1869
+ _context22.next = 22;
1870
+ break;
2046
1871
 
2047
- return MakeKMSCall;
2048
- }() // Make an arbitrary HTTP call to an authority server
1872
+ case 40:
1873
+ case "end":
1874
+ return _context22.stop();
1875
+ }
1876
+ }
1877
+ }, null, this, [[23, 32]]);
1878
+ } // Make an arbitrary HTTP call to an authority server
2049
1879
 
2050
1880
  }, {
2051
1881
  key: "MakeAuthServiceRequest",
2052
- value: function () {
2053
- var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref23) {
2054
- var kmsId, objectId, versionHash, _ref23$method, method, path, bodyType, _ref23$body, body, _ref23$queryParams, queryParams, headers;
2055
-
2056
- return _regeneratorRuntime.wrap(function _callee23$(_context23) {
2057
- while (1) {
2058
- switch (_context23.prev = _context23.next) {
2059
- case 0:
2060
- kmsId = _ref23.kmsId, objectId = _ref23.objectId, versionHash = _ref23.versionHash, _ref23$method = _ref23.method, method = _ref23$method === void 0 ? "GET" : _ref23$method, path = _ref23.path, bodyType = _ref23.bodyType, _ref23$body = _ref23.body, body = _ref23$body === void 0 ? {} : _ref23$body, _ref23$queryParams = _ref23.queryParams, queryParams = _ref23$queryParams === void 0 ? {} : _ref23$queryParams, headers = _ref23.headers;
2061
-
2062
- if (!(this.client.authServiceURIs.length === 0)) {
2063
- _context23.next = 5;
2064
- break;
2065
- }
1882
+ value: function MakeAuthServiceRequest(_ref32) {
1883
+ var kmsId, objectId, versionHash, _ref32$method, method, path, bodyType, _ref32$body, body, _ref32$queryParams, queryParams, headers;
2066
1884
 
2067
- _context23.next = 4;
2068
- return this.MakeKMSRequest({
2069
- kmsId: kmsId,
2070
- objectId: objectId,
2071
- versionHash: versionHash,
2072
- method: method,
2073
- path: path,
2074
- bodyType: bodyType,
2075
- body: body,
2076
- queryParams: queryParams,
2077
- headers: headers
2078
- });
2079
-
2080
- case 4:
2081
- return _context23.abrupt("return", _context23.sent);
2082
-
2083
- case 5:
2084
- _context23.next = 7;
2085
- return this.client.AuthHttpClient.Request({
2086
- method: method,
2087
- path: path,
2088
- bodyType: bodyType,
2089
- body: body,
2090
- headers: headers,
2091
- queryParams: queryParams
2092
- });
1885
+ return _regeneratorRuntime.async(function MakeAuthServiceRequest$(_context23) {
1886
+ while (1) {
1887
+ switch (_context23.prev = _context23.next) {
1888
+ case 0:
1889
+ kmsId = _ref32.kmsId, objectId = _ref32.objectId, versionHash = _ref32.versionHash, _ref32$method = _ref32.method, method = _ref32$method === void 0 ? "GET" : _ref32$method, path = _ref32.path, bodyType = _ref32.bodyType, _ref32$body = _ref32.body, body = _ref32$body === void 0 ? {} : _ref32$body, _ref32$queryParams = _ref32.queryParams, queryParams = _ref32$queryParams === void 0 ? {} : _ref32$queryParams, headers = _ref32.headers;
2093
1890
 
2094
- case 7:
2095
- return _context23.abrupt("return", _context23.sent);
2096
-
2097
- case 8:
2098
- case "end":
2099
- return _context23.stop();
2100
- }
1891
+ if (!(this.client.authServiceURIs.length === 0)) {
1892
+ _context23.next = 5;
1893
+ break;
1894
+ }
1895
+
1896
+ _context23.next = 4;
1897
+ return _regeneratorRuntime.awrap(this.MakeKMSRequest({
1898
+ kmsId: kmsId,
1899
+ objectId: objectId,
1900
+ versionHash: versionHash,
1901
+ method: method,
1902
+ path: path,
1903
+ bodyType: bodyType,
1904
+ body: body,
1905
+ queryParams: queryParams,
1906
+ headers: headers
1907
+ }));
1908
+
1909
+ case 4:
1910
+ return _context23.abrupt("return", _context23.sent);
1911
+
1912
+ case 5:
1913
+ _context23.next = 7;
1914
+ return _regeneratorRuntime.awrap(this.client.AuthHttpClient.Request({
1915
+ method: method,
1916
+ path: path,
1917
+ bodyType: bodyType,
1918
+ body: body,
1919
+ headers: headers,
1920
+ queryParams: queryParams
1921
+ }));
1922
+
1923
+ case 7:
1924
+ return _context23.abrupt("return", _context23.sent);
1925
+
1926
+ case 8:
1927
+ case "end":
1928
+ return _context23.stop();
2101
1929
  }
2102
- }, _callee23, this);
2103
- }));
2104
-
2105
- function MakeAuthServiceRequest(_x23) {
2106
- return _MakeAuthServiceRequest.apply(this, arguments);
2107
- }
2108
-
2109
- return MakeAuthServiceRequest;
2110
- }() // Make an arbitrary HTTP call to the KMS
1930
+ }
1931
+ }, null, this);
1932
+ } // Make an arbitrary HTTP call to the KMS
2111
1933
 
2112
1934
  }, {
2113
1935
  key: "MakeKMSRequest",
2114
- value: function () {
2115
- var _MakeKMSRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref24) {
2116
- var kmsId, objectId, versionHash, _ref24$method, method, path, bodyType, _ref24$body, body, _ref24$queryParams, queryParams, headers, kmsUrls, kmsHttpClient;
2117
-
2118
- return _regeneratorRuntime.wrap(function _callee24$(_context24) {
2119
- while (1) {
2120
- switch (_context24.prev = _context24.next) {
2121
- case 0:
2122
- kmsId = _ref24.kmsId, objectId = _ref24.objectId, versionHash = _ref24.versionHash, _ref24$method = _ref24.method, method = _ref24$method === void 0 ? "GET" : _ref24$method, path = _ref24.path, bodyType = _ref24.bodyType, _ref24$body = _ref24.body, body = _ref24$body === void 0 ? {} : _ref24$body, _ref24$queryParams = _ref24.queryParams, queryParams = _ref24$queryParams === void 0 ? {} : _ref24$queryParams, headers = _ref24.headers;
2123
-
2124
- if (versionHash) {
2125
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
2126
- }
1936
+ value: function MakeKMSRequest(_ref33) {
1937
+ var kmsId, objectId, versionHash, _ref33$method, method, path, bodyType, _ref33$body, body, _ref33$queryParams, queryParams, headers, kmsUrls, kmsHttpClient;
2127
1938
 
2128
- if (!(!objectId && !kmsId)) {
2129
- _context24.next = 10;
2130
- break;
2131
- }
2132
-
2133
- _context24.t0 = "ikms";
2134
- _context24.t1 = Utils;
2135
- _context24.next = 7;
2136
- return this.client.DefaultKMSAddress();
2137
-
2138
- case 7:
2139
- _context24.t2 = _context24.sent;
2140
- _context24.t3 = _context24.t1.AddressToHash.call(_context24.t1, _context24.t2);
2141
- kmsId = _context24.t0.concat.call(_context24.t0, _context24.t3);
2142
-
2143
- case 10:
2144
- _context24.next = 12;
2145
- return this.KMSInfo({
2146
- kmsId: kmsId,
2147
- objectId: objectId,
2148
- versionHash: versionHash
2149
- });
2150
-
2151
- case 12:
2152
- kmsUrls = _context24.sent.urls;
2153
-
2154
- if (!(!kmsUrls || !kmsUrls[0])) {
2155
- _context24.next = 15;
2156
- break;
2157
- }
1939
+ return _regeneratorRuntime.async(function MakeKMSRequest$(_context24) {
1940
+ while (1) {
1941
+ switch (_context24.prev = _context24.next) {
1942
+ case 0:
1943
+ kmsId = _ref33.kmsId, objectId = _ref33.objectId, versionHash = _ref33.versionHash, _ref33$method = _ref33.method, method = _ref33$method === void 0 ? "GET" : _ref33$method, path = _ref33.path, bodyType = _ref33.bodyType, _ref33$body = _ref33.body, body = _ref33$body === void 0 ? {} : _ref33$body, _ref33$queryParams = _ref33.queryParams, queryParams = _ref33$queryParams === void 0 ? {} : _ref33$queryParams, headers = _ref33.headers;
2158
1944
 
2159
- throw Error("No KMS info set for ".concat(versionHash || objectId || "default KMS"));
1945
+ if (versionHash) {
1946
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1947
+ }
2160
1948
 
2161
- case 15:
2162
- kmsHttpClient = new HttpClient({
2163
- uris: kmsUrls
2164
- });
2165
- _context24.next = 18;
2166
- return kmsHttpClient.Request({
2167
- method: method,
2168
- path: path,
2169
- bodyType: bodyType,
2170
- body: body,
2171
- headers: headers,
2172
- queryParams: queryParams
2173
- });
2174
-
2175
- case 18:
2176
- return _context24.abrupt("return", _context24.sent);
2177
-
2178
- case 19:
2179
- case "end":
2180
- return _context24.stop();
2181
- }
1949
+ if (!(!objectId && !kmsId)) {
1950
+ _context24.next = 10;
1951
+ break;
1952
+ }
1953
+
1954
+ _context24.t0 = "ikms";
1955
+ _context24.t1 = Utils;
1956
+ _context24.next = 7;
1957
+ return _regeneratorRuntime.awrap(this.client.DefaultKMSAddress());
1958
+
1959
+ case 7:
1960
+ _context24.t2 = _context24.sent;
1961
+ _context24.t3 = _context24.t1.AddressToHash.call(_context24.t1, _context24.t2);
1962
+ kmsId = _context24.t0.concat.call(_context24.t0, _context24.t3);
1963
+
1964
+ case 10:
1965
+ _context24.next = 12;
1966
+ return _regeneratorRuntime.awrap(this.KMSInfo({
1967
+ kmsId: kmsId,
1968
+ objectId: objectId,
1969
+ versionHash: versionHash
1970
+ }));
1971
+
1972
+ case 12:
1973
+ kmsUrls = _context24.sent.urls;
1974
+
1975
+ if (!(!kmsUrls || !kmsUrls[0])) {
1976
+ _context24.next = 15;
1977
+ break;
1978
+ }
1979
+
1980
+ throw Error("No KMS info set for ".concat(versionHash || objectId || "default KMS"));
1981
+
1982
+ case 15:
1983
+ kmsHttpClient = new HttpClient({
1984
+ uris: kmsUrls
1985
+ });
1986
+ _context24.next = 18;
1987
+ return _regeneratorRuntime.awrap(kmsHttpClient.Request({
1988
+ method: method,
1989
+ path: path,
1990
+ bodyType: bodyType,
1991
+ body: body,
1992
+ headers: headers,
1993
+ queryParams: queryParams
1994
+ }));
1995
+
1996
+ case 18:
1997
+ return _context24.abrupt("return", _context24.sent);
1998
+
1999
+ case 19:
2000
+ case "end":
2001
+ return _context24.stop();
2182
2002
  }
2183
- }, _callee24, this);
2184
- }));
2185
-
2186
- function MakeKMSRequest(_x24) {
2187
- return _MakeKMSRequest.apply(this, arguments);
2188
- }
2189
-
2190
- return MakeKMSRequest;
2191
- }()
2003
+ }
2004
+ }, null, this);
2005
+ }
2192
2006
  }, {
2193
2007
  key: "ContractHasMethod",
2194
- value: function () {
2195
- var _ContractHasMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref25) {
2196
- var contractAddress, abi, methodName, key, method, methodSignature, methodId;
2197
- return _regeneratorRuntime.wrap(function _callee25$(_context25) {
2198
- while (1) {
2199
- switch (_context25.prev = _context25.next) {
2200
- case 0:
2201
- contractAddress = _ref25.contractAddress, abi = _ref25.abi, methodName = _ref25.methodName;
2202
- contractAddress = Utils.FormatAddress(contractAddress);
2203
- key = "".concat(contractAddress, "-").concat(methodName);
2204
-
2205
- if (!(this.methodAvailability[key] === undefined)) {
2206
- _context25.next = 19;
2207
- break;
2208
- }
2209
-
2210
- this.Log("Checking method availability: ".concat(contractAddress, " ").concat(methodName));
2211
-
2212
- if (abi) {
2213
- _context25.next = 9;
2214
- break;
2215
- }
2216
-
2217
- _context25.next = 8;
2218
- return this.ContractInfo({
2219
- address: contractAddress
2220
- });
2008
+ value: function ContractHasMethod(_ref34) {
2009
+ var contractAddress, abi, methodName, key, method, methodSignature, methodId;
2010
+ return _regeneratorRuntime.async(function ContractHasMethod$(_context25) {
2011
+ while (1) {
2012
+ switch (_context25.prev = _context25.next) {
2013
+ case 0:
2014
+ contractAddress = _ref34.contractAddress, abi = _ref34.abi, methodName = _ref34.methodName;
2015
+ contractAddress = Utils.FormatAddress(contractAddress);
2016
+ key = "".concat(contractAddress, "-").concat(methodName);
2017
+
2018
+ if (!(this.methodAvailability[key] === undefined)) {
2019
+ _context25.next = 19;
2020
+ break;
2021
+ }
2221
2022
 
2222
- case 8:
2223
- abi = _context25.sent.abi;
2023
+ this.Log("Checking method availability: ".concat(contractAddress, " ").concat(methodName));
2224
2024
 
2225
- case 9:
2226
- if (abi) {
2227
- _context25.next = 11;
2228
- break;
2229
- }
2025
+ if (abi) {
2026
+ _context25.next = 9;
2027
+ break;
2028
+ }
2230
2029
 
2231
- throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
2030
+ _context25.next = 8;
2031
+ return _regeneratorRuntime.awrap(this.ContractInfo({
2032
+ address: contractAddress
2033
+ }));
2232
2034
 
2233
- case 11:
2234
- method = abi.find(function (method) {
2235
- return method.name === methodName;
2236
- });
2035
+ case 8:
2036
+ abi = _context25.sent.abi;
2237
2037
 
2238
- if (method) {
2239
- _context25.next = 14;
2240
- break;
2241
- }
2242
-
2243
- return _context25.abrupt("return", false);
2244
-
2245
- case 14:
2246
- methodSignature = "".concat(method.name, "(").concat(method.inputs.map(function (i) {
2247
- return i.type;
2248
- }).join(","), ")");
2249
- methodId = Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(methodSignature)).replace("0x", "").slice(0, 8);
2250
- _context25.next = 18;
2251
- return this.MakeElvMasterCall({
2252
- methodName: "elv_deployedContractHasMethod",
2253
- params: [contractAddress, methodId]
2254
- });
2038
+ case 9:
2039
+ if (abi) {
2040
+ _context25.next = 11;
2041
+ break;
2042
+ }
2255
2043
 
2256
- case 18:
2257
- this.methodAvailability[key] = _context25.sent;
2044
+ throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
2258
2045
 
2259
- case 19:
2260
- return _context25.abrupt("return", this.methodAvailability[key]);
2046
+ case 11:
2047
+ method = abi.find(function (method) {
2048
+ return method.name === methodName;
2049
+ });
2261
2050
 
2262
- case 20:
2263
- case "end":
2264
- return _context25.stop();
2265
- }
2051
+ if (method) {
2052
+ _context25.next = 14;
2053
+ break;
2054
+ }
2055
+
2056
+ return _context25.abrupt("return", false);
2057
+
2058
+ case 14:
2059
+ methodSignature = "".concat(method.name, "(").concat(method.inputs.map(function (i) {
2060
+ return i.type;
2061
+ }).join(","), ")");
2062
+ methodId = Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(methodSignature)).replace("0x", "").slice(0, 8);
2063
+ _context25.next = 18;
2064
+ return _regeneratorRuntime.awrap(this.MakeElvMasterCall({
2065
+ methodName: "elv_deployedContractHasMethod",
2066
+ params: [contractAddress, methodId]
2067
+ }));
2068
+
2069
+ case 18:
2070
+ this.methodAvailability[key] = _context25.sent;
2071
+
2072
+ case 19:
2073
+ return _context25.abrupt("return", this.methodAvailability[key]);
2074
+
2075
+ case 20:
2076
+ case "end":
2077
+ return _context25.stop();
2266
2078
  }
2267
- }, _callee25, this);
2268
- }));
2269
-
2270
- function ContractHasMethod(_x25) {
2271
- return _ContractHasMethod.apply(this, arguments);
2272
- }
2273
-
2274
- return ContractHasMethod;
2275
- }()
2079
+ }
2080
+ }, null, this);
2081
+ }
2276
2082
  }, {
2277
2083
  key: "MakeElvMasterCall",
2278
- value: function () {
2279
- var _MakeElvMasterCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref26) {
2280
- var methodName, params;
2281
- return _regeneratorRuntime.wrap(function _callee26$(_context26) {
2282
- while (1) {
2283
- switch (_context26.prev = _context26.next) {
2284
- case 0:
2285
- methodName = _ref26.methodName, params = _ref26.params;
2286
- _context26.next = 3;
2287
- return this.client.ethClient.MakeProviderCall({
2288
- methodName: "send",
2289
- args: [methodName, params]
2290
- });
2291
-
2292
- case 3:
2293
- return _context26.abrupt("return", _context26.sent);
2294
-
2295
- case 4:
2296
- case "end":
2297
- return _context26.stop();
2298
- }
2084
+ value: function MakeElvMasterCall(_ref35) {
2085
+ var methodName, params;
2086
+ return _regeneratorRuntime.async(function MakeElvMasterCall$(_context26) {
2087
+ while (1) {
2088
+ switch (_context26.prev = _context26.next) {
2089
+ case 0:
2090
+ methodName = _ref35.methodName, params = _ref35.params;
2091
+ _context26.next = 3;
2092
+ return _regeneratorRuntime.awrap(this.client.ethClient.MakeProviderCall({
2093
+ methodName: "send",
2094
+ args: [methodName, params]
2095
+ }));
2096
+
2097
+ case 3:
2098
+ return _context26.abrupt("return", _context26.sent);
2099
+
2100
+ case 4:
2101
+ case "end":
2102
+ return _context26.stop();
2299
2103
  }
2300
- }, _callee26, this);
2301
- }));
2302
-
2303
- function MakeElvMasterCall(_x26) {
2304
- return _MakeElvMasterCall.apply(this, arguments);
2305
- }
2306
-
2307
- return MakeElvMasterCall;
2308
- }()
2104
+ }
2105
+ }, null, this);
2106
+ }
2309
2107
  }, {
2310
2108
  key: "ReEncryptionConk",
2311
- value: function () {
2312
- var _ReEncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref27) {
2313
- var libraryId, objectId, versionHash, cap;
2314
- return _regeneratorRuntime.wrap(function _callee27$(_context27) {
2315
- while (1) {
2316
- switch (_context27.prev = _context27.next) {
2317
- case 0:
2318
- libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash;
2319
-
2320
- if (versionHash) {
2321
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
2322
- }
2323
-
2324
- if (this.reencryptionKeys[objectId]) {
2325
- _context27.next = 10;
2326
- break;
2327
- }
2109
+ value: function ReEncryptionConk(_ref36) {
2110
+ var libraryId, objectId, versionHash, cap;
2111
+ return _regeneratorRuntime.async(function ReEncryptionConk$(_context27) {
2112
+ while (1) {
2113
+ switch (_context27.prev = _context27.next) {
2114
+ case 0:
2115
+ libraryId = _ref36.libraryId, objectId = _ref36.objectId, versionHash = _ref36.versionHash;
2116
+
2117
+ if (versionHash) {
2118
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
2119
+ }
2120
+
2121
+ if (this.reencryptionKeys[objectId]) {
2122
+ _context27.next = 10;
2123
+ break;
2124
+ }
2328
2125
 
2329
- _context27.next = 5;
2330
- return this.client.Crypto.GenerateTargetConk();
2126
+ _context27.next = 5;
2127
+ return _regeneratorRuntime.awrap(this.client.Crypto.GenerateTargetConk());
2331
2128
 
2332
- case 5:
2333
- cap = _context27.sent;
2334
- _context27.next = 8;
2335
- return this.RetrieveReencryptionSymmetricKey({
2336
- libraryId: libraryId,
2337
- objectId: objectId
2338
- });
2129
+ case 5:
2130
+ cap = _context27.sent;
2131
+ _context27.next = 8;
2132
+ return _regeneratorRuntime.awrap(this.RetrieveReencryptionSymmetricKey({
2133
+ libraryId: libraryId,
2134
+ objectId: objectId
2135
+ }));
2339
2136
 
2340
- case 8:
2341
- cap.symm_key = _context27.sent;
2342
- this.reencryptionKeys[objectId] = cap;
2137
+ case 8:
2138
+ cap.symm_key = _context27.sent;
2139
+ this.reencryptionKeys[objectId] = cap;
2343
2140
 
2344
- case 10:
2345
- return _context27.abrupt("return", this.reencryptionKeys[objectId]);
2141
+ case 10:
2142
+ return _context27.abrupt("return", this.reencryptionKeys[objectId]);
2346
2143
 
2347
- case 11:
2348
- case "end":
2349
- return _context27.stop();
2350
- }
2144
+ case 11:
2145
+ case "end":
2146
+ return _context27.stop();
2351
2147
  }
2352
- }, _callee27, this);
2353
- }));
2354
-
2355
- function ReEncryptionConk(_x27) {
2356
- return _ReEncryptionConk.apply(this, arguments);
2357
- }
2358
-
2359
- return ReEncryptionConk;
2360
- }()
2148
+ }
2149
+ }, null, this);
2150
+ }
2361
2151
  }, {
2362
2152
  key: "EncryptionConk",
2363
- value: function () {
2364
- var _EncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref28) {
2365
- var libraryId, objectId, versionHash, conk, _yield$this$client$Cr, secret_key;
2366
-
2367
- return _regeneratorRuntime.wrap(function _callee28$(_context28) {
2368
- while (1) {
2369
- switch (_context28.prev = _context28.next) {
2370
- case 0:
2371
- libraryId = _ref28.libraryId, objectId = _ref28.objectId, versionHash = _ref28.versionHash;
2372
-
2373
- if (versionHash) {
2374
- objectId = Utils.DecodeVersionHash(versionHash).objectId;
2375
- }
2153
+ value: function EncryptionConk(_ref37) {
2154
+ var libraryId, objectId, versionHash, conk, _ref38, secret_key;
2376
2155
 
2377
- if (libraryId) {
2378
- _context28.next = 6;
2379
- break;
2380
- }
2381
-
2382
- _context28.next = 5;
2383
- return this.client.ContentObjectLibraryId({
2384
- objectId: objectId
2385
- });
2156
+ return _regeneratorRuntime.async(function EncryptionConk$(_context28) {
2157
+ while (1) {
2158
+ switch (_context28.prev = _context28.next) {
2159
+ case 0:
2160
+ libraryId = _ref37.libraryId, objectId = _ref37.objectId, versionHash = _ref37.versionHash;
2386
2161
 
2387
- case 5:
2388
- libraryId = _context28.sent;
2162
+ if (versionHash) {
2163
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
2164
+ }
2389
2165
 
2390
- case 6:
2391
- if (this.encryptionKeys[objectId]) {
2392
- _context28.next = 16;
2393
- break;
2394
- }
2395
-
2396
- _context28.next = 9;
2397
- return this.RetrieveConk({
2398
- libraryId: libraryId,
2399
- objectId: objectId
2400
- });
2401
-
2402
- case 9:
2403
- conk = _context28.sent;
2404
- _context28.next = 12;
2405
- return this.client.Crypto.GeneratePrimaryConk({
2406
- objectId: objectId
2407
- });
2408
-
2409
- case 12:
2410
- _yield$this$client$Cr = _context28.sent;
2411
- secret_key = _yield$this$client$Cr.secret_key;
2412
- conk.secret_key = secret_key; // { secret_key, public_key, symm_key, block_size }
2166
+ if (libraryId) {
2167
+ _context28.next = 6;
2168
+ break;
2169
+ }
2413
2170
 
2414
- this.encryptionKeys[objectId] = conk;
2171
+ _context28.next = 5;
2172
+ return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
2173
+ objectId: objectId
2174
+ }));
2415
2175
 
2416
- case 16:
2417
- return _context28.abrupt("return", this.encryptionKeys[objectId]);
2176
+ case 5:
2177
+ libraryId = _context28.sent;
2418
2178
 
2419
- case 17:
2420
- case "end":
2421
- return _context28.stop();
2422
- }
2179
+ case 6:
2180
+ if (this.encryptionKeys[objectId]) {
2181
+ _context28.next = 16;
2182
+ break;
2183
+ }
2184
+
2185
+ _context28.next = 9;
2186
+ return _regeneratorRuntime.awrap(this.RetrieveConk({
2187
+ libraryId: libraryId,
2188
+ objectId: objectId
2189
+ }));
2190
+
2191
+ case 9:
2192
+ conk = _context28.sent;
2193
+ _context28.next = 12;
2194
+ return _regeneratorRuntime.awrap(this.client.Crypto.GeneratePrimaryConk({
2195
+ objectId: objectId
2196
+ }));
2197
+
2198
+ case 12:
2199
+ _ref38 = _context28.sent;
2200
+ secret_key = _ref38.secret_key;
2201
+ conk.secret_key = secret_key; // { secret_key, public_key, symm_key, block_size }
2202
+
2203
+ this.encryptionKeys[objectId] = conk;
2204
+
2205
+ case 16:
2206
+ return _context28.abrupt("return", this.encryptionKeys[objectId]);
2207
+
2208
+ case 17:
2209
+ case "end":
2210
+ return _context28.stop();
2423
2211
  }
2424
- }, _callee28, this);
2425
- }));
2426
-
2427
- function EncryptionConk(_x28) {
2428
- return _EncryptionConk.apply(this, arguments);
2429
- }
2430
-
2431
- return EncryptionConk;
2432
- }()
2212
+ }
2213
+ }, null, this);
2214
+ }
2433
2215
  }, {
2434
2216
  key: "RecordTags",
2435
- value: function () {
2436
- var _RecordTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref29) {
2437
- var accessType, libraryId, objectId, versionHash, _yield$this$ContractI8, abi, owner;
2438
-
2439
- return _regeneratorRuntime.wrap(function _callee29$(_context29) {
2440
- while (1) {
2441
- switch (_context29.prev = _context29.next) {
2442
- case 0:
2443
- accessType = _ref29.accessType, libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash;
2444
-
2445
- if (!(accessType !== ACCESS_TYPES.OBJECT)) {
2446
- _context29.next = 3;
2447
- break;
2448
- }
2217
+ value: function RecordTags(_ref39) {
2218
+ var accessType, libraryId, objectId, versionHash, _ref40, abi, owner;
2449
2219
 
2450
- return _context29.abrupt("return");
2220
+ return _regeneratorRuntime.async(function RecordTags$(_context29) {
2221
+ while (1) {
2222
+ switch (_context29.prev = _context29.next) {
2223
+ case 0:
2224
+ accessType = _ref39.accessType, libraryId = _ref39.libraryId, objectId = _ref39.objectId, versionHash = _ref39.versionHash;
2451
2225
 
2452
- case 3:
2453
- _context29.next = 5;
2454
- return this.ContractInfo({
2455
- id: objectId
2456
- });
2226
+ if (!(accessType !== ACCESS_TYPES.OBJECT)) {
2227
+ _context29.next = 3;
2228
+ break;
2229
+ }
2457
2230
 
2458
- case 5:
2459
- _yield$this$ContractI8 = _context29.sent;
2460
- abi = _yield$this$ContractI8.abi;
2461
- _context29.next = 9;
2462
- return this.Owner({
2463
- id: objectId,
2464
- abi: abi
2465
- });
2231
+ return _context29.abrupt("return");
2466
2232
 
2467
- case 9:
2468
- owner = _context29.sent;
2233
+ case 3:
2234
+ _context29.next = 5;
2235
+ return _regeneratorRuntime.awrap(this.ContractInfo({
2236
+ id: objectId
2237
+ }));
2469
2238
 
2470
- if (Utils.EqualAddress(owner, this.client.signer.address)) {
2471
- _context29.next = 13;
2472
- break;
2473
- }
2239
+ case 5:
2240
+ _ref40 = _context29.sent;
2241
+ abi = _ref40.abi;
2242
+ _context29.next = 9;
2243
+ return _regeneratorRuntime.awrap(this.Owner({
2244
+ id: objectId,
2245
+ abi: abi
2246
+ }));
2474
2247
 
2475
- _context29.next = 13;
2476
- return this.client.userProfileClient.RecordTags({
2477
- libraryId: libraryId,
2478
- objectId: objectId,
2479
- versionHash: versionHash
2480
- });
2248
+ case 9:
2249
+ owner = _context29.sent;
2481
2250
 
2482
- case 13:
2483
- case "end":
2484
- return _context29.stop();
2485
- }
2251
+ if (Utils.EqualAddress(owner, this.client.signer.address)) {
2252
+ _context29.next = 13;
2253
+ break;
2254
+ }
2255
+
2256
+ _context29.next = 13;
2257
+ return _regeneratorRuntime.awrap(this.client.userProfileClient.RecordTags({
2258
+ libraryId: libraryId,
2259
+ objectId: objectId,
2260
+ versionHash: versionHash
2261
+ }));
2262
+
2263
+ case 13:
2264
+ case "end":
2265
+ return _context29.stop();
2486
2266
  }
2487
- }, _callee29, this);
2488
- }));
2489
-
2490
- function RecordTags(_x29) {
2491
- return _RecordTags.apply(this, arguments);
2492
- }
2493
-
2494
- return RecordTags;
2495
- }()
2267
+ }
2268
+ }, null, this);
2269
+ }
2496
2270
  /* Creation methods */
2497
2271
 
2498
2272
  }, {
2499
2273
  key: "CreateAccessGroup",
2500
- value: function () {
2501
- var _CreateAccessGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
2502
- var _yield$this$client$et, contractAddress, transactionHash;
2503
-
2504
- return _regeneratorRuntime.wrap(function _callee30$(_context30) {
2505
- while (1) {
2506
- switch (_context30.prev = _context30.next) {
2507
- case 0:
2508
- _context30.next = 2;
2509
- return this.client.ethClient.DeployAccessGroupContract({
2510
- contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2511
- signer: this.client.signer
2512
- });
2513
-
2514
- case 2:
2515
- _yield$this$client$et = _context30.sent;
2516
- contractAddress = _yield$this$client$et.contractAddress;
2517
- transactionHash = _yield$this$client$et.transactionHash;
2518
- return _context30.abrupt("return", {
2519
- contractAddress: contractAddress,
2520
- transactionHash: transactionHash
2521
- });
2522
-
2523
- case 6:
2524
- case "end":
2525
- return _context30.stop();
2526
- }
2274
+ value: function CreateAccessGroup() {
2275
+ var _ref41, contractAddress, transactionHash;
2276
+
2277
+ return _regeneratorRuntime.async(function CreateAccessGroup$(_context30) {
2278
+ while (1) {
2279
+ switch (_context30.prev = _context30.next) {
2280
+ case 0:
2281
+ _context30.next = 2;
2282
+ return _regeneratorRuntime.awrap(this.client.ethClient.DeployAccessGroupContract({
2283
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2284
+ signer: this.client.signer
2285
+ }));
2286
+
2287
+ case 2:
2288
+ _ref41 = _context30.sent;
2289
+ contractAddress = _ref41.contractAddress;
2290
+ transactionHash = _ref41.transactionHash;
2291
+ return _context30.abrupt("return", {
2292
+ contractAddress: contractAddress,
2293
+ transactionHash: transactionHash
2294
+ });
2295
+
2296
+ case 6:
2297
+ case "end":
2298
+ return _context30.stop();
2527
2299
  }
2528
- }, _callee30, this);
2529
- }));
2530
-
2531
- function CreateAccessGroup() {
2532
- return _CreateAccessGroup.apply(this, arguments);
2533
- }
2534
-
2535
- return CreateAccessGroup;
2536
- }()
2300
+ }
2301
+ }, null, this);
2302
+ }
2537
2303
  }, {
2538
2304
  key: "CreateContentType",
2539
- value: function () {
2540
- var _CreateContentType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
2541
- var _yield$this$client$et2, contractAddress, transactionHash;
2542
-
2543
- return _regeneratorRuntime.wrap(function _callee31$(_context31) {
2544
- while (1) {
2545
- switch (_context31.prev = _context31.next) {
2546
- case 0:
2547
- _context31.next = 2;
2548
- return this.client.ethClient.DeployTypeContract({
2549
- contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2550
- signer: this.client.signer
2551
- });
2552
-
2553
- case 2:
2554
- _yield$this$client$et2 = _context31.sent;
2555
- contractAddress = _yield$this$client$et2.contractAddress;
2556
- transactionHash = _yield$this$client$et2.transactionHash;
2557
- return _context31.abrupt("return", {
2558
- contractAddress: contractAddress,
2559
- transactionHash: transactionHash
2560
- });
2561
-
2562
- case 6:
2563
- case "end":
2564
- return _context31.stop();
2565
- }
2305
+ value: function CreateContentType() {
2306
+ var _ref42, contractAddress, transactionHash;
2307
+
2308
+ return _regeneratorRuntime.async(function CreateContentType$(_context31) {
2309
+ while (1) {
2310
+ switch (_context31.prev = _context31.next) {
2311
+ case 0:
2312
+ _context31.next = 2;
2313
+ return _regeneratorRuntime.awrap(this.client.ethClient.DeployTypeContract({
2314
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2315
+ signer: this.client.signer
2316
+ }));
2317
+
2318
+ case 2:
2319
+ _ref42 = _context31.sent;
2320
+ contractAddress = _ref42.contractAddress;
2321
+ transactionHash = _ref42.transactionHash;
2322
+ return _context31.abrupt("return", {
2323
+ contractAddress: contractAddress,
2324
+ transactionHash: transactionHash
2325
+ });
2326
+
2327
+ case 6:
2328
+ case "end":
2329
+ return _context31.stop();
2566
2330
  }
2567
- }, _callee31, this);
2568
- }));
2569
-
2570
- function CreateContentType() {
2571
- return _CreateContentType.apply(this, arguments);
2572
- }
2573
-
2574
- return CreateContentType;
2575
- }()
2331
+ }
2332
+ }, null, this);
2333
+ }
2576
2334
  }, {
2577
2335
  key: "CreateContentLibrary",
2578
- value: function () {
2579
- var _CreateContentLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref30) {
2580
- var kmsId, _yield$this$client$et3, contractAddress, transactionHash;
2581
-
2582
- return _regeneratorRuntime.wrap(function _callee32$(_context32) {
2583
- while (1) {
2584
- switch (_context32.prev = _context32.next) {
2585
- case 0:
2586
- kmsId = _ref30.kmsId;
2587
- _context32.next = 3;
2588
- return this.client.ethClient.DeployLibraryContract({
2589
- contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2590
- kmsId: kmsId,
2591
- signer: this.client.signer
2592
- });
2593
-
2594
- case 3:
2595
- _yield$this$client$et3 = _context32.sent;
2596
- contractAddress = _yield$this$client$et3.contractAddress;
2597
- transactionHash = _yield$this$client$et3.transactionHash;
2598
- return _context32.abrupt("return", {
2599
- contractAddress: contractAddress,
2600
- transactionHash: transactionHash
2601
- });
2602
-
2603
- case 7:
2604
- case "end":
2605
- return _context32.stop();
2606
- }
2336
+ value: function CreateContentLibrary(_ref43) {
2337
+ var kmsId, _ref44, contractAddress, transactionHash;
2338
+
2339
+ return _regeneratorRuntime.async(function CreateContentLibrary$(_context32) {
2340
+ while (1) {
2341
+ switch (_context32.prev = _context32.next) {
2342
+ case 0:
2343
+ kmsId = _ref43.kmsId;
2344
+ _context32.next = 3;
2345
+ return _regeneratorRuntime.awrap(this.client.ethClient.DeployLibraryContract({
2346
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2347
+ kmsId: kmsId,
2348
+ signer: this.client.signer
2349
+ }));
2350
+
2351
+ case 3:
2352
+ _ref44 = _context32.sent;
2353
+ contractAddress = _ref44.contractAddress;
2354
+ transactionHash = _ref44.transactionHash;
2355
+ return _context32.abrupt("return", {
2356
+ contractAddress: contractAddress,
2357
+ transactionHash: transactionHash
2358
+ });
2359
+
2360
+ case 7:
2361
+ case "end":
2362
+ return _context32.stop();
2607
2363
  }
2608
- }, _callee32, this);
2609
- }));
2610
-
2611
- function CreateContentLibrary(_x30) {
2612
- return _CreateContentLibrary.apply(this, arguments);
2613
- }
2614
-
2615
- return CreateContentLibrary;
2616
- }()
2364
+ }
2365
+ }, null, this);
2366
+ }
2617
2367
  }, {
2618
2368
  key: "CreateContentObject",
2619
- value: function () {
2620
- var _CreateContentObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref31) {
2621
- var libraryId, typeId, _yield$this$client$et4, contractAddress, transactionHash;
2622
-
2623
- return _regeneratorRuntime.wrap(function _callee33$(_context33) {
2624
- while (1) {
2625
- switch (_context33.prev = _context33.next) {
2626
- case 0:
2627
- libraryId = _ref31.libraryId, typeId = _ref31.typeId;
2628
- _context33.next = 3;
2629
- return this.client.ethClient.DeployContentContract({
2630
- contentLibraryAddress: Utils.HashToAddress(libraryId),
2631
- typeAddress: typeId ? Utils.HashToAddress(typeId) : Utils.nullAddress,
2632
- signer: this.client.signer
2633
- });
2634
-
2635
- case 3:
2636
- _yield$this$client$et4 = _context33.sent;
2637
- contractAddress = _yield$this$client$et4.contractAddress;
2638
- transactionHash = _yield$this$client$et4.transactionHash;
2639
- return _context33.abrupt("return", {
2640
- contractAddress: contractAddress,
2641
- transactionHash: transactionHash
2642
- });
2643
-
2644
- case 7:
2645
- case "end":
2646
- return _context33.stop();
2647
- }
2369
+ value: function CreateContentObject(_ref45) {
2370
+ var libraryId, typeId, _ref46, contractAddress, transactionHash;
2371
+
2372
+ return _regeneratorRuntime.async(function CreateContentObject$(_context33) {
2373
+ while (1) {
2374
+ switch (_context33.prev = _context33.next) {
2375
+ case 0:
2376
+ libraryId = _ref45.libraryId, typeId = _ref45.typeId;
2377
+ _context33.next = 3;
2378
+ return _regeneratorRuntime.awrap(this.client.ethClient.DeployContentContract({
2379
+ contentLibraryAddress: Utils.HashToAddress(libraryId),
2380
+ typeAddress: typeId ? Utils.HashToAddress(typeId) : Utils.nullAddress,
2381
+ signer: this.client.signer
2382
+ }));
2383
+
2384
+ case 3:
2385
+ _ref46 = _context33.sent;
2386
+ contractAddress = _ref46.contractAddress;
2387
+ transactionHash = _ref46.transactionHash;
2388
+ return _context33.abrupt("return", {
2389
+ contractAddress: contractAddress,
2390
+ transactionHash: transactionHash
2391
+ });
2392
+
2393
+ case 7:
2394
+ case "end":
2395
+ return _context33.stop();
2648
2396
  }
2649
- }, _callee33, this);
2650
- }));
2651
-
2652
- function CreateContentObject(_x31) {
2653
- return _CreateContentObject.apply(this, arguments);
2654
- }
2655
-
2656
- return CreateContentObject;
2657
- }() // Clear cached access transaction IDs and state channel tokens
2397
+ }
2398
+ }, null, this);
2399
+ } // Clear cached access transaction IDs and state channel tokens
2658
2400
 
2659
2401
  }, {
2660
2402
  key: "ClearCache",