@eluvio/elv-client-js 4.0.114 → 4.0.116

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.
Files changed (129) hide show
  1. package/dist/ElvClient-min.js +68 -0
  2. package/dist/ElvClient-node-min.js +67 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +68 -0
  6. package/dist/ElvWalletClient-node-min.js +67 -0
  7. package/dist/src/AuthorizationClient.js +2166 -0
  8. package/dist/src/ContentObjectAudit.js +175 -0
  9. package/dist/src/ContentObjectVerification.js +281 -0
  10. package/dist/src/Crypto.js +412 -0
  11. package/dist/src/ElvClient.js +2063 -0
  12. package/dist/src/ElvWallet.js +247 -0
  13. package/dist/src/EthClient.js +1153 -0
  14. package/dist/src/FrameClient.js +484 -0
  15. package/dist/src/HttpClient.js +314 -0
  16. package/dist/src/Id.js +20 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1556 -0
  19. package/dist/src/RemoteSigner.js +383 -0
  20. package/dist/src/UserProfileClient.js +1465 -0
  21. package/dist/src/Utils.js +893 -0
  22. package/dist/src/Validation.js +121 -0
  23. package/dist/src/abr_profiles/abr_profile_live_drm.js +1661 -0
  24. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1606 -0
  25. package/dist/src/client/ABRPublishing.js +1018 -0
  26. package/dist/src/client/AccessGroups.js +1503 -0
  27. package/dist/src/client/ContentAccess.js +5202 -0
  28. package/dist/src/client/ContentManagement.js +2680 -0
  29. package/dist/src/client/Contracts.js +1520 -0
  30. package/dist/src/client/Files.js +2181 -0
  31. package/dist/src/client/LiveConf.js +567 -0
  32. package/dist/src/client/LiveStream.js +2638 -0
  33. package/dist/src/client/NFT.js +162 -0
  34. package/dist/src/client/NTP.js +581 -0
  35. package/dist/src/contracts/v2/AccessIndexor.js +831 -0
  36. package/dist/src/contracts/v2/Accessible.js +31 -0
  37. package/dist/src/contracts/v2/BaseAccessControlGroup.js +1263 -0
  38. package/dist/src/contracts/v2/BaseAccessWallet.js +1609 -0
  39. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +93 -0
  40. package/dist/src/contracts/v2/BaseContent.js +1076 -0
  41. package/dist/src/contracts/v2/BaseContentFactory.js +219 -0
  42. package/dist/src/contracts/v2/BaseContentSpace.js +1352 -0
  43. package/dist/src/contracts/v2/BaseContentType.js +364 -0
  44. package/dist/src/contracts/v2/BaseFactory.js +107 -0
  45. package/dist/src/contracts/v2/BaseGroupFactory.js +93 -0
  46. package/dist/src/contracts/v2/BaseLibrary.js +1041 -0
  47. package/dist/src/contracts/v2/BaseLibraryFactory.js +96 -0
  48. package/dist/src/contracts/v2/Certifyer.js +86 -0
  49. package/dist/src/contracts/v2/Container.js +540 -0
  50. package/dist/src/contracts/v2/Content.js +443 -0
  51. package/dist/src/contracts/v2/Editable.js +306 -0
  52. package/dist/src/contracts/v2/ExternalUserWallet.js +379 -0
  53. package/dist/src/contracts/v2/IFactorySpace.js +57 -0
  54. package/dist/src/contracts/v2/IKmsSpace.js +52 -0
  55. package/dist/src/contracts/v2/INodeSpace.js +18 -0
  56. package/dist/src/contracts/v2/IUserSpace.js +18 -0
  57. package/dist/src/contracts/v2/LvRecordableStream.js +1037 -0
  58. package/dist/src/contracts/v2/LvRecording.js +627 -0
  59. package/dist/src/contracts/v2/LvStreamRightsHolder.js +562 -0
  60. package/dist/src/contracts/v2/MetaObject.js +119 -0
  61. package/dist/src/contracts/v2/Node.js +167 -0
  62. package/dist/src/contracts/v2/NodeSpace.js +273 -0
  63. package/dist/src/contracts/v2/Ownable.js +87 -0
  64. package/dist/src/contracts/v2/PaymentService.js +627 -0
  65. package/dist/src/contracts/v2/Precompile.js +15 -0
  66. package/dist/src/contracts/v2/Transactable.js +82 -0
  67. package/dist/src/contracts/v2/UserSpace.js +29 -0
  68. package/dist/src/contracts/v2/Utils.js +18 -0
  69. package/dist/src/contracts/v2/Verifier.js +53 -0
  70. package/dist/src/contracts/v2/strings.js +4 -0
  71. package/dist/src/contracts/v3/AccessIndexor.js +774 -0
  72. package/dist/src/contracts/v3/Accessible.js +232 -0
  73. package/dist/src/contracts/v3/Adminable.js +107 -0
  74. package/dist/src/contracts/v3/AvailsDelivery.js +586 -0
  75. package/dist/src/contracts/v3/BaseAccessControlGroup.js +1603 -0
  76. package/dist/src/contracts/v3/BaseAccessWallet.js +1628 -0
  77. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +112 -0
  78. package/dist/src/contracts/v3/BaseContent.js +1312 -0
  79. package/dist/src/contracts/v3/BaseContentFactory.js +183 -0
  80. package/dist/src/contracts/v3/BaseContentFactoryExt.js +175 -0
  81. package/dist/src/contracts/v3/BaseContentSpace.js +1515 -0
  82. package/dist/src/contracts/v3/BaseContentType.js +527 -0
  83. package/dist/src/contracts/v3/BaseFactory.js +126 -0
  84. package/dist/src/contracts/v3/BaseGroupFactory.js +112 -0
  85. package/dist/src/contracts/v3/BaseLibrary.js +1204 -0
  86. package/dist/src/contracts/v3/BaseLibraryFactory.js +115 -0
  87. package/dist/src/contracts/v3/BaseTenantSpace.js +1587 -0
  88. package/dist/src/contracts/v3/Certifyer.js +86 -0
  89. package/dist/src/contracts/v3/Container.js +739 -0
  90. package/dist/src/contracts/v3/Content.js +438 -0
  91. package/dist/src/contracts/v3/CounterObject.js +243 -0
  92. package/dist/src/contracts/v3/Editable.js +519 -0
  93. package/dist/src/contracts/v3/EncToken.js +4 -0
  94. package/dist/src/contracts/v3/ExternalUserWallet.js +587 -0
  95. package/dist/src/contracts/v3/IAdmin.js +18 -0
  96. package/dist/src/contracts/v3/IFactorySpace.js +57 -0
  97. package/dist/src/contracts/v3/IKmsSpace.js +52 -0
  98. package/dist/src/contracts/v3/INodeSpace.js +18 -0
  99. package/dist/src/contracts/v3/IUserSpace.js +32 -0
  100. package/dist/src/contracts/v3/LvRecordableStream.js +1032 -0
  101. package/dist/src/contracts/v3/LvRecording.js +650 -0
  102. package/dist/src/contracts/v3/LvStreamRightsHolder.js +557 -0
  103. package/dist/src/contracts/v3/MetaObject.js +144 -0
  104. package/dist/src/contracts/v3/Node.js +178 -0
  105. package/dist/src/contracts/v3/NodeSpace.js +284 -0
  106. package/dist/src/contracts/v3/Ownable.js +98 -0
  107. package/dist/src/contracts/v3/PaymentService.js +622 -0
  108. package/dist/src/contracts/v3/Precompile.js +26 -0
  109. package/dist/src/contracts/v3/TenantFuncsBase.js +351 -0
  110. package/dist/src/contracts/v3/Transactable.js +82 -0
  111. package/dist/src/contracts/v3/UserSpace.js +43 -0
  112. package/dist/src/contracts/v3/Utils.js +18 -0
  113. package/dist/src/contracts/v3/Verifier.js +53 -0
  114. package/dist/src/contracts/v3/strings.js +4 -0
  115. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  116. package/dist/src/events/Topics.js +1793 -0
  117. package/dist/src/index.js +8 -0
  118. package/dist/src/walletClient/ClientMethods.js +3102 -0
  119. package/dist/src/walletClient/Configuration.js +38 -0
  120. package/dist/src/walletClient/Notifications.js +168 -0
  121. package/dist/src/walletClient/Profile.js +332 -0
  122. package/dist/src/walletClient/Utils.js +281 -0
  123. package/dist/src/walletClient/index.js +2109 -0
  124. package/package.json +1 -1
  125. package/src/AuthorizationClient.js +24 -16
  126. package/src/ElvClient.js +19 -0
  127. package/src/client/ContentAccess.js +20 -2
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,2166 @@
1
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
3
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
4
+ var _createClass = require("@babel/runtime/helpers/createClass");
5
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ var HttpClient = require("./HttpClient");
9
+ var Ethers = require("ethers");
10
+ var Utils = require("./Utils");
11
+ var UrlJoin = require("url-join");
12
+ var _require = require("./LogMessage"),
13
+ LogMessage = _require.LogMessage;
14
+
15
+ /*
16
+ // -- Contract javascript files built using build/BuildContracts.js
17
+ const SpaceContract = require("./contracts/BaseContentSpace");
18
+ const LibraryContract = require("./contracts/BaseLibrary");
19
+ const TypeContract = require("./contracts/BaseContentType");
20
+ const ContentContract = require("./contracts/BaseContent");
21
+ const AccessGroupContract = require("./contracts/BaseAccessControlGroup");
22
+ const WalletContract = require("./contracts/BaseAccessWallet");
23
+ const AccessibleContract = require("./contracts/Accessible");
24
+ const EditableContract = require("./contracts/Editable");
25
+ */
26
+
27
+ var ACCESS_TYPES = {
28
+ SPACE: "space",
29
+ LIBRARY: "library",
30
+ TYPE: "type",
31
+ OBJECT: "object",
32
+ WALLET: "wallet",
33
+ GROUP: "group",
34
+ ACCESSIBLE: "accessible",
35
+ EDITABLE: "editable",
36
+ TENANT: "tenant",
37
+ OTHER: "other"
38
+ };
39
+ var CONTRACTS = {
40
+ v2: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ACCESS_TYPES.SPACE, require("./contracts/v2/BaseContentSpace")), ACCESS_TYPES.LIBRARY, require("./contracts/v2/BaseLibrary")), ACCESS_TYPES.TYPE, require("./contracts/v2/BaseContentType")), ACCESS_TYPES.OBJECT, require("./contracts/v2/BaseContent")), ACCESS_TYPES.WALLET, require("./contracts/v2/BaseAccessWallet")), ACCESS_TYPES.GROUP, require("./contracts/v2/BaseAccessControlGroup")), ACCESS_TYPES.ACCESSIBLE, require("./contracts/v2/Accessible")), ACCESS_TYPES.EDITABLE, require("./contracts/v2/Editable")),
41
+ v3: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ACCESS_TYPES.SPACE, require("./contracts/v3/BaseContentSpace")), ACCESS_TYPES.LIBRARY, require("./contracts/v3/BaseLibrary")), ACCESS_TYPES.TYPE, require("./contracts/v3/BaseContentType")), ACCESS_TYPES.OBJECT, require("./contracts/v3/BaseContent")), ACCESS_TYPES.WALLET, require("./contracts/v3/BaseAccessWallet")), ACCESS_TYPES.GROUP, require("./contracts/v3/BaseAccessControlGroup")), ACCESS_TYPES.ACCESSIBLE, require("./contracts/v3/Accessible")), ACCESS_TYPES.EDITABLE, require("./contracts/v3/Editable")), ACCESS_TYPES.TENANT, require("./contracts/v3/BaseTenantSpace")),
42
+ v3b: _defineProperty({}, ACCESS_TYPES.GROUP, require("./contracts/v3b/BaseAccessControlGroup"))
43
+ };
44
+ var AuthorizationClient = /*#__PURE__*/function () {
45
+ "use strict";
46
+
47
+ function AuthorizationClient(_ref) {
48
+ var client = _ref.client,
49
+ contentSpaceId = _ref.contentSpaceId,
50
+ _ref$debug = _ref.debug,
51
+ debug = _ref$debug === void 0 ? false : _ref$debug,
52
+ _ref$noCache = _ref.noCache,
53
+ noCache = _ref$noCache === void 0 ? false : _ref$noCache,
54
+ _ref$noAuth = _ref.noAuth,
55
+ noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth;
56
+ _classCallCheck(this, AuthorizationClient);
57
+ this.ACCESS_TYPES = ACCESS_TYPES;
58
+ this.CONTRACTS = CONTRACTS;
59
+ this.client = client;
60
+ this.contentSpaceId = contentSpaceId;
61
+ this.noCache = noCache;
62
+ this.noAuth = noAuth;
63
+ this.debug = debug;
64
+ this.accessTransactions = {};
65
+ this.modifyTransactions = {};
66
+ this.transactionLocks = {};
67
+ this.methodAvailability = {};
68
+ this.accessVersions = {};
69
+ this.accessTypes = {};
70
+ this.channelContentTokens = {};
71
+ this.encryptionKeys = {};
72
+ this.reencryptionKeys = {};
73
+ this.requestIds = {};
74
+ this.providers = {};
75
+ this.CreateStaticToken = client.CreateStaticToken;
76
+ }
77
+
78
+ // Return authorization token in appropriate headers
79
+ return _createClass(AuthorizationClient, [{
80
+ key: "Log",
81
+ value: function Log(message) {
82
+ var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
83
+ LogMessage(this, message, error);
84
+ }
85
+ }, {
86
+ key: "AuthorizationHeader",
87
+ value: function () {
88
+ var _AuthorizationHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
89
+ var authorizationToken, headers;
90
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
91
+ while (1) switch (_context.prev = _context.next) {
92
+ case 0:
93
+ _context.next = 2;
94
+ return this.AuthorizationToken(params);
95
+ case 2:
96
+ authorizationToken = _context.sent;
97
+ headers = {
98
+ Authorization: "Bearer " + authorizationToken
99
+ };
100
+ if (params.encryption && params.encryption !== "none") {
101
+ headers["X-Content-Fabric-Encryption-Scheme"] = params.encryption;
102
+ }
103
+ return _context.abrupt("return", headers);
104
+ case 6:
105
+ case "end":
106
+ return _context.stop();
107
+ }
108
+ }, _callee, this);
109
+ }));
110
+ function AuthorizationHeader(_x) {
111
+ return _AuthorizationHeader.apply(this, arguments);
112
+ }
113
+ return AuthorizationHeader;
114
+ }()
115
+ }, {
116
+ key: "AuthorizationToken",
117
+ value: function () {
118
+ var _AuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
119
+ var libraryId, objectId, versionHash, partHash, encryption, audienceData, context, _ref2$update, update, _ref2$makeAccessReque, makeAccessRequest, _ref2$channelAuth, channelAuth, oauthToken, _ref2$noCache, noCache, _ref2$noAuth, noAuth, isWalletRequest, initialNoCache, authorizationToken;
120
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
121
+ while (1) switch (_context2.prev = _context2.next) {
122
+ case 0:
123
+ libraryId = _ref2.libraryId, objectId = _ref2.objectId, versionHash = _ref2.versionHash, partHash = _ref2.partHash, encryption = _ref2.encryption, audienceData = _ref2.audienceData, context = _ref2.context, _ref2$update = _ref2.update, update = _ref2$update === void 0 ? false : _ref2$update, _ref2$makeAccessReque = _ref2.makeAccessRequest, makeAccessRequest = _ref2$makeAccessReque === void 0 ? false : _ref2$makeAccessReque, _ref2$channelAuth = _ref2.channelAuth, channelAuth = _ref2$channelAuth === void 0 ? false : _ref2$channelAuth, oauthToken = _ref2.oauthToken, _ref2$noCache = _ref2.noCache, noCache = _ref2$noCache === void 0 ? false : _ref2$noCache, _ref2$noAuth = _ref2.noAuth, noAuth = _ref2$noAuth === void 0 ? false : _ref2$noAuth;
124
+ if (versionHash) {
125
+ objectId = this.client.utils.DecodeVersionHash(versionHash).objectId;
126
+ }
127
+ _context2.t0 = objectId && this.client.signer;
128
+ if (!_context2.t0) {
129
+ _context2.next = 10;
130
+ break;
131
+ }
132
+ _context2.t1 = this.client.utils;
133
+ _context2.next = 7;
134
+ return this.client.userProfileClient.WalletAddress(false);
135
+ case 7:
136
+ _context2.t2 = _context2.sent;
137
+ _context2.t3 = this.client.utils.HashToAddress(objectId);
138
+ _context2.t0 = _context2.t1.EqualAddress.call(_context2.t1, _context2.t2, _context2.t3);
139
+ case 10:
140
+ isWalletRequest = _context2.t0;
141
+ if (!(this.client.staticToken && !isWalletRequest && !update)) {
142
+ _context2.next = 13;
143
+ break;
144
+ }
145
+ return _context2.abrupt("return", this.client.staticToken);
146
+ case 13:
147
+ initialNoCache = this.noCache;
148
+ _context2.prev = 14;
149
+ // noCache enabled for this call
150
+ if (noCache && !this.noCache) {
151
+ this.noCache = true;
152
+ }
153
+ if (!(channelAuth && this.client.signer && this.client.signer.remoteSigner)) {
154
+ _context2.next = 18;
155
+ break;
156
+ }
157
+ return _context2.abrupt("return", this.client.CreateFabricToken({
158
+ context: context
159
+ }));
160
+ case 18:
161
+ if (!channelAuth) {
162
+ _context2.next = 24;
163
+ break;
164
+ }
165
+ _context2.next = 21;
166
+ return this.GenerateChannelContentToken({
167
+ objectId: objectId,
168
+ versionHash: versionHash,
169
+ audienceData: audienceData,
170
+ context: context,
171
+ oauthToken: oauthToken
172
+ });
173
+ case 21:
174
+ authorizationToken = _context2.sent;
175
+ _context2.next = 29;
176
+ break;
177
+ case 24:
178
+ if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
179
+ _context2.next = 26;
180
+ break;
181
+ }
182
+ return _context2.abrupt("return", this.client.CreateStaticToken({
183
+ libraryId: libraryId
184
+ }));
185
+ case 26:
186
+ _context2.next = 28;
187
+ return this.GenerateAuthorizationToken({
188
+ libraryId: libraryId,
189
+ objectId: objectId,
190
+ versionHash: versionHash,
191
+ partHash: partHash,
192
+ encryption: encryption,
193
+ update: update,
194
+ makeAccessRequest: makeAccessRequest
195
+ });
196
+ case 28:
197
+ authorizationToken = _context2.sent;
198
+ case 29:
199
+ return _context2.abrupt("return", authorizationToken);
200
+ case 32:
201
+ _context2.prev = 32;
202
+ _context2.t4 = _context2["catch"](14);
203
+ throw _context2.t4;
204
+ case 35:
205
+ _context2.prev = 35;
206
+ this.noCache = initialNoCache;
207
+ return _context2.finish(35);
208
+ case 38:
209
+ case "end":
210
+ return _context2.stop();
211
+ }
212
+ }, _callee2, this, [[14, 32, 35, 38]]);
213
+ }));
214
+ function AuthorizationToken(_x2) {
215
+ return _AuthorizationToken.apply(this, arguments);
216
+ }
217
+ return AuthorizationToken;
218
+ }()
219
+ }, {
220
+ key: "GenerateAuthorizationToken",
221
+ value: function () {
222
+ var _GenerateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
223
+ var libraryId, objectId, versionHash, partHash, encryption, _ref3$update, update, _ref3$makeAccessReque, makeAccessRequest, publicKey, owner, ownerCapKey, ownerCap, cap, token, _yield$this$MakeAcces, transactionHash, signature, multiSig;
224
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
225
+ while (1) switch (_context3.prev = _context3.next) {
226
+ case 0:
227
+ libraryId = _ref3.libraryId, objectId = _ref3.objectId, versionHash = _ref3.versionHash, partHash = _ref3.partHash, encryption = _ref3.encryption, _ref3$update = _ref3.update, update = _ref3$update === void 0 ? false : _ref3$update, _ref3$makeAccessReque = _ref3.makeAccessRequest, makeAccessRequest = _ref3$makeAccessReque === void 0 ? false : _ref3$makeAccessReque;
228
+ if (versionHash) {
229
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
230
+ }
231
+
232
+ // Generate AFGH public key if encryption is specified
233
+ _context3.t0 = encryption && encryption !== "none" && objectId;
234
+ if (!_context3.t0) {
235
+ _context3.next = 9;
236
+ break;
237
+ }
238
+ _context3.next = 6;
239
+ return this.AccessType(objectId);
240
+ case 6:
241
+ _context3.t1 = _context3.sent;
242
+ _context3.t2 = ACCESS_TYPES.OBJECT;
243
+ _context3.t0 = _context3.t1 === _context3.t2;
244
+ case 9:
245
+ if (!_context3.t0) {
246
+ _context3.next = 22;
247
+ break;
248
+ }
249
+ _context3.next = 12;
250
+ return this.Owner({
251
+ id: objectId
252
+ });
253
+ case 12:
254
+ owner = _context3.sent;
255
+ ownerCapKey = "eluv.caps.iusr".concat(Utils.AddressToHash(this.client.signer.address));
256
+ _context3.next = 16;
257
+ return this.client.ContentObjectMetadata({
258
+ libraryId: libraryId,
259
+ objectId: objectId,
260
+ versionHash: versionHash,
261
+ metadataSubtree: ownerCapKey
262
+ });
263
+ case 16:
264
+ ownerCap = _context3.sent;
265
+ if (!(!Utils.EqualAddress(owner, this.client.signer.address) && !ownerCap)) {
266
+ _context3.next = 22;
267
+ break;
268
+ }
269
+ _context3.next = 20;
270
+ return this.ReEncryptionConk({
271
+ libraryId: libraryId,
272
+ objectId: objectId
273
+ });
274
+ case 20:
275
+ cap = _context3.sent;
276
+ publicKey = cap.public_key;
277
+ case 22:
278
+ token = {
279
+ qspace_id: this.contentSpaceId,
280
+ addr: Utils.FormatAddress(this.client.signer && this.client.signer.address || "")
281
+ };
282
+ if (!(update || makeAccessRequest)) {
283
+ _context3.next = 29;
284
+ break;
285
+ }
286
+ _context3.next = 26;
287
+ return this.MakeAccessRequest({
288
+ libraryId: libraryId,
289
+ objectId: objectId,
290
+ versionHash: versionHash,
291
+ update: update,
292
+ publicKey: publicKey,
293
+ noCache: this.noCache
294
+ });
295
+ case 26:
296
+ _yield$this$MakeAcces = _context3.sent;
297
+ transactionHash = _yield$this$MakeAcces.transactionHash;
298
+ if (transactionHash) {
299
+ token.tx_id = transactionHash;
300
+ }
301
+ case 29:
302
+ if (libraryId) {
303
+ token.qlib_id = libraryId;
304
+ }
305
+ if (partHash) {
306
+ token.qphash = partHash;
307
+ }
308
+ if (publicKey) {
309
+ token.afgh_pk = publicKey;
310
+ }
311
+ token = Utils.B64(JSON.stringify(token));
312
+ _context3.next = 35;
313
+ return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(token)));
314
+ case 35:
315
+ signature = _context3.sent;
316
+ multiSig = Utils.FormatSignature(signature);
317
+ return _context3.abrupt("return", "".concat(token, ".").concat(Utils.B64(multiSig)));
318
+ case 38:
319
+ case "end":
320
+ return _context3.stop();
321
+ }
322
+ }, _callee3, this);
323
+ }));
324
+ function GenerateAuthorizationToken(_x3) {
325
+ return _GenerateAuthorizationToken.apply(this, arguments);
326
+ }
327
+ return GenerateAuthorizationToken;
328
+ }()
329
+ }, {
330
+ key: "MakeAccessRequest",
331
+ value: function () {
332
+ var _MakeAccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
333
+ var _this = this;
334
+ var libraryId, objectId, versionHash, _ref4$args, args, _ref4$publicKey, publicKey, _ref4$update, update, _ref4$skipCache, skipCache, _ref4$noCache, noCache, cacheOnly, walletContractAddress, walletCreated, id, _yield$this$ContractI, isV3, accessType, abi, _yield$this$AccessInf, accessArgs, checkAccessCharge, address, elapsed, _cache, accessRequest, cache;
335
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
336
+ while (1) switch (_context4.prev = _context4.next) {
337
+ case 0:
338
+ libraryId = _ref4.libraryId, objectId = _ref4.objectId, versionHash = _ref4.versionHash, _ref4$args = _ref4.args, args = _ref4$args === void 0 ? [] : _ref4$args, _ref4$publicKey = _ref4.publicKey, publicKey = _ref4$publicKey === void 0 ? "" : _ref4$publicKey, _ref4$update = _ref4.update, update = _ref4$update === void 0 ? false : _ref4$update, _ref4$skipCache = _ref4.skipCache, skipCache = _ref4$skipCache === void 0 ? false : _ref4$skipCache, _ref4$noCache = _ref4.noCache, noCache = _ref4$noCache === void 0 ? false : _ref4$noCache, cacheOnly = _ref4.cacheOnly;
339
+ if (this.client.signer) {
340
+ _context4.next = 3;
341
+ break;
342
+ }
343
+ return _context4.abrupt("return", {
344
+ transactionHash: ""
345
+ });
346
+ case 3:
347
+ _context4.next = 5;
348
+ return this.client.userProfileClient.UserWalletAddress({
349
+ address: this.client.signer.address
350
+ });
351
+ case 5:
352
+ walletContractAddress = _context4.sent;
353
+ if (walletContractAddress) {
354
+ _context4.next = 12;
355
+ break;
356
+ }
357
+ _context4.next = 9;
358
+ return this.client.userProfileClient.WalletAddress();
359
+ case 9:
360
+ walletCreated = _context4.sent;
361
+ if (walletCreated) {
362
+ _context4.next = 12;
363
+ break;
364
+ }
365
+ throw Error("User wallet contract is required to make access requests");
366
+ case 12:
367
+ if (versionHash) {
368
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
369
+ }
370
+ id = objectId || libraryId || this.contentSpaceId;
371
+ _context4.next = 16;
372
+ return this.ContractInfo({
373
+ id: id
374
+ });
375
+ case 16:
376
+ _yield$this$ContractI = _context4.sent;
377
+ isV3 = _yield$this$ContractI.isV3;
378
+ accessType = _yield$this$ContractI.accessType;
379
+ abi = _yield$this$ContractI.abi;
380
+ if (!(typeof accessType === "undefined")) {
381
+ _context4.next = 22;
382
+ break;
383
+ }
384
+ throw Error("Unable to determine contract info for ".concat(id, " (").concat(this.client.utils.HashToAddress(id), ") - Wrong network?"));
385
+ case 22:
386
+ _context4.next = 24;
387
+ return this.AccessInfo({
388
+ accessType: accessType,
389
+ publicKey: publicKey,
390
+ update: update,
391
+ args: args,
392
+ isV3: isV3
393
+ });
394
+ case 24:
395
+ _yield$this$AccessInf = _context4.sent;
396
+ accessArgs = _yield$this$AccessInf.accessArgs;
397
+ checkAccessCharge = _yield$this$AccessInf.checkAccessCharge;
398
+ address = Utils.HashToAddress(id);
399
+ elapsed = 0;
400
+ case 29:
401
+ if (!this.transactionLocks[id]) {
402
+ _context4.next = 36;
403
+ break;
404
+ }
405
+ _context4.next = 32;
406
+ return new Promise(function (resolve) {
407
+ return setTimeout(resolve, 100);
408
+ });
409
+ case 32:
410
+ elapsed += 100;
411
+ if (elapsed > 15000) {
412
+ this.Log("Lock never released for ".concat(id, " - releasing lock"));
413
+ delete this.transactionLocks[id];
414
+ }
415
+ _context4.next = 29;
416
+ break;
417
+ case 36:
418
+ _context4.prev = 36;
419
+ this.transactionLocks[id] = true;
420
+
421
+ // Check cache for existing transaction
422
+ if (!(!noCache && !skipCache)) {
423
+ _context4.next = 46;
424
+ break;
425
+ }
426
+ _cache = update ? this.modifyTransactions : this.accessTransactions;
427
+ if (!_cache[address]) {
428
+ _context4.next = 46;
429
+ break;
430
+ }
431
+ if (!(_cache[address].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
432
+ _context4.next = 45;
433
+ break;
434
+ }
435
+ return _context4.abrupt("return", _cache[address]);
436
+ case 45:
437
+ // Token expired
438
+ delete _cache[address];
439
+ case 46:
440
+ if (!cacheOnly) {
441
+ _context4.next = 48;
442
+ break;
443
+ }
444
+ return _context4.abrupt("return");
445
+ case 48:
446
+ _context4.prev = 48;
447
+ if (!update) {
448
+ _context4.next = 56;
449
+ break;
450
+ }
451
+ this.Log("Making update request on ".concat(accessType, " ").concat(id));
452
+ _context4.next = 53;
453
+ return this.UpdateRequest({
454
+ id: id,
455
+ abi: abi
456
+ });
457
+ case 53:
458
+ accessRequest = _context4.sent;
459
+ _context4.next = 60;
460
+ break;
461
+ case 56:
462
+ this.Log("Making access request on ".concat(accessType, " ").concat(id));
463
+ _context4.next = 59;
464
+ return this.AccessRequest({
465
+ id: id,
466
+ args: accessArgs,
467
+ checkAccessCharge: checkAccessCharge
468
+ });
469
+ case 59:
470
+ accessRequest = _context4.sent;
471
+ case 60:
472
+ _context4.next = 69;
473
+ break;
474
+ case 62:
475
+ _context4.prev = 62;
476
+ _context4.t0 = _context4["catch"](48);
477
+ if (!_context4.t0.message.includes("UNPREDICTABLE_GAS_LIMIT")) {
478
+ _context4.next = 67;
479
+ break;
480
+ }
481
+ this.Log("Permission denied for ".concat(id, ": ").concat(_context4.t0.message));
482
+ throw Error("Permission denied for ".concat(Utils.FormatAddress(this.client.signer.address), " on ").concat(id, " or \n ").concat(Utils.FormatAddress(this.client.signer.address), " have insufficient funds"));
483
+ case 67:
484
+ // Handle other unexpected errors
485
+ this.Log("Error during request for ".concat(id, ": ").concat(_context4.t0.message));
486
+ throw _context4.t0;
487
+ case 69:
488
+ cache = update ? this.modifyTransactions : this.accessTransactions;
489
+ _context4.prev = 70;
490
+ if (!noCache) {
491
+ cache[address] = {
492
+ issuedAt: Date.now(),
493
+ transactionHash: accessRequest.transactionHash
494
+ };
495
+
496
+ // Save request ID if present
497
+ accessRequest.logs.some(function (log) {
498
+ if (log.args && (log.args.requestID || log.args.requestNonce)) {
499
+ _this.requestIds[address] = (log.args.requestID || log.args.requestNonce || "").toString().replace(/^0x/, "");
500
+ return true;
501
+ }
502
+ });
503
+ }
504
+ return _context4.abrupt("return", accessRequest);
505
+ case 75:
506
+ _context4.prev = 75;
507
+ _context4.t1 = _context4["catch"](70);
508
+ if (!noCache) {
509
+ delete cache[address];
510
+ }
511
+ throw _context4.t1;
512
+ case 79:
513
+ _context4.prev = 79;
514
+ delete this.transactionLocks[id];
515
+ return _context4.finish(79);
516
+ case 82:
517
+ case "end":
518
+ return _context4.stop();
519
+ }
520
+ }, _callee4, this, [[36,, 79, 82], [48, 62], [70, 75]]);
521
+ }));
522
+ function MakeAccessRequest(_x4) {
523
+ return _MakeAccessRequest.apply(this, arguments);
524
+ }
525
+ return MakeAccessRequest;
526
+ }()
527
+ }, {
528
+ key: "AccessRequest",
529
+ value: function () {
530
+ var _AccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
531
+ var id, _ref5$args, args, _ref5$checkAccessChar, checkAccessCharge, _yield$this$ContractI2, isV3, accessType, abi, accessCharge, owner, accessChargeArgs, event, methodName, contractAddress;
532
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
533
+ while (1) switch (_context5.prev = _context5.next) {
534
+ case 0:
535
+ id = _ref5.id, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$checkAccessChar = _ref5.checkAccessCharge, checkAccessCharge = _ref5$checkAccessChar === void 0 ? false : _ref5$checkAccessChar;
536
+ _context5.next = 3;
537
+ return this.ContractInfo({
538
+ id: id
539
+ });
540
+ case 3:
541
+ _yield$this$ContractI2 = _context5.sent;
542
+ isV3 = _yield$this$ContractI2.isV3;
543
+ accessType = _yield$this$ContractI2.accessType;
544
+ abi = _yield$this$ContractI2.abi;
545
+ // Send some bux if access charge is required
546
+ accessCharge = 0;
547
+ if (!(checkAccessCharge && accessType === ACCESS_TYPES.OBJECT)) {
548
+ _context5.next = 27;
549
+ break;
550
+ }
551
+ _context5.next = 11;
552
+ return this.Owner({
553
+ id: id,
554
+ abi: abi
555
+ });
556
+ case 11:
557
+ owner = _context5.sent;
558
+ if (Utils.EqualAddress(this.client.signer.address, owner)) {
559
+ _context5.next = 27;
560
+ break;
561
+ }
562
+ _context5.prev = 13;
563
+ // Extract level, custom values and stakeholders from accessRequest arguments
564
+ accessChargeArgs = isV3 ? [0, [], []] : [args[0], args[3], args[4]]; // Access charge is in wei, but methods take ether - convert to charge to ether
565
+ _context5.t0 = Utils;
566
+ _context5.next = 18;
567
+ return this.GetAccessCharge({
568
+ objectId: id,
569
+ args: accessChargeArgs
570
+ });
571
+ case 18:
572
+ _context5.t1 = _context5.sent;
573
+ accessCharge = _context5.t0.WeiToEther.call(_context5.t0, _context5.t1);
574
+ if (isNaN(accessCharge) || !accessCharge) {
575
+ accessCharge = 0;
576
+ }
577
+ _context5.next = 27;
578
+ break;
579
+ case 23:
580
+ _context5.prev = 23;
581
+ _context5.t2 = _context5["catch"](13);
582
+ this.Log("Failed to get access charge for", id);
583
+ this.Log(_context5.t2);
584
+ case 27:
585
+ if (accessCharge > 0) {
586
+ this.Log("Access charge: ".concat(accessCharge));
587
+ }
588
+ contractAddress = Utils.HashToAddress(id);
589
+ if (isV3) {
590
+ methodName = "accessRequestV3";
591
+ } else {
592
+ methodName = "accessRequest";
593
+ }
594
+ _context5.next = 32;
595
+ return this.ContractHasMethod({
596
+ contractAddress: contractAddress,
597
+ abi: abi,
598
+ methodName: methodName
599
+ });
600
+ case 32:
601
+ if (_context5.sent) {
602
+ _context5.next = 35;
603
+ break;
604
+ }
605
+ this.Log("".concat(accessType, " ").concat(id, " has no ").concat(methodName, " method. Skipping"));
606
+ return _context5.abrupt("return", {
607
+ transactionHash: "",
608
+ logs: []
609
+ });
610
+ case 35:
611
+ _context5.next = 37;
612
+ return this.client.CallContractMethodAndWait({
613
+ contractAddress: contractAddress,
614
+ abi: abi,
615
+ methodName: methodName,
616
+ methodArgs: args,
617
+ value: accessCharge
618
+ });
619
+ case 37:
620
+ event = _context5.sent;
621
+ if (!(event.logs.length === 0)) {
622
+ _context5.next = 40;
623
+ break;
624
+ }
625
+ throw Error("Access denied (".concat(id, ")"));
626
+ case 40:
627
+ return _context5.abrupt("return", event);
628
+ case 41:
629
+ case "end":
630
+ return _context5.stop();
631
+ }
632
+ }, _callee5, this, [[13, 23]]);
633
+ }));
634
+ function AccessRequest(_x5) {
635
+ return _AccessRequest.apply(this, arguments);
636
+ }
637
+ return AccessRequest;
638
+ }()
639
+ }, {
640
+ key: "UpdateRequest",
641
+ value: function () {
642
+ var _UpdateRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref6) {
643
+ var id, abi, event, updateRequestEvent;
644
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
645
+ while (1) switch (_context6.prev = _context6.next) {
646
+ case 0:
647
+ id = _ref6.id, abi = _ref6.abi;
648
+ _context6.next = 3;
649
+ return this.client.CallContractMethodAndWait({
650
+ contractAddress: Utils.HashToAddress(id),
651
+ abi: abi,
652
+ methodName: "updateRequest",
653
+ methodArgs: []
654
+ });
655
+ case 3:
656
+ event = _context6.sent;
657
+ updateRequestEvent = this.client.ExtractEventFromLogs({
658
+ abi: abi,
659
+ event: event,
660
+ eventName: "UpdateRequest"
661
+ });
662
+ if (!(event.logs.length === 0 || !updateRequestEvent)) {
663
+ _context6.next = 7;
664
+ break;
665
+ }
666
+ throw Error("Update request denied for ".concat(id));
667
+ case 7:
668
+ return _context6.abrupt("return", event);
669
+ case 8:
670
+ case "end":
671
+ return _context6.stop();
672
+ }
673
+ }, _callee6, this);
674
+ }));
675
+ function UpdateRequest(_x6) {
676
+ return _UpdateRequest.apply(this, arguments);
677
+ }
678
+ return UpdateRequest;
679
+ }()
680
+ }, {
681
+ key: "AudienceData",
682
+ value: function AudienceData(_ref7) {
683
+ var objectId = _ref7.objectId,
684
+ versionHash = _ref7.versionHash,
685
+ _ref7$protocols = _ref7.protocols,
686
+ protocols = _ref7$protocols === void 0 ? [] : _ref7$protocols,
687
+ _ref7$drms = _ref7.drms,
688
+ drms = _ref7$drms === void 0 ? [] : _ref7$drms,
689
+ context = _ref7.context;
690
+ this.Log("Retrieving audience data: ".concat(objectId));
691
+ context = context || this.client.authContext || {};
692
+ if (Object.values(context).find(function (value) {
693
+ return typeof value !== "string";
694
+ })) {
695
+ throw Error("Context must be a map of string->string");
696
+ }
697
+ var data = _objectSpread({
698
+ user_address: Utils.FormatAddress(this.client.signer.address),
699
+ content_id: objectId || Utils.DecodeVersionHash(versionHash).id,
700
+ content_hash: versionHash,
701
+ hostname: this.client.HttpClient.BaseURI().hostname(),
702
+ access_time: Math.round(new Date().getTime()).toString(),
703
+ format: protocols.join(","),
704
+ drm: drms.join(",")
705
+ }, context);
706
+ if (typeof window !== "undefined" && window.navigator) {
707
+ data.user_string = window.navigator.userAgent;
708
+ data.language = window.navigator.language;
709
+ }
710
+ this.Log(data);
711
+ return data;
712
+ }
713
+ }, {
714
+ key: "GenerateChannelContentToken",
715
+ value: function () {
716
+ var _GenerateChannelContentToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
717
+ var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref8$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams, payload, signature, multiSig;
718
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
719
+ while (1) switch (_context7.prev = _context7.next) {
720
+ case 0:
721
+ objectId = _ref8.objectId, versionHash = _ref8.versionHash, issuer = _ref8.issuer, code = _ref8.code, email = _ref8.email, audienceData = _ref8.audienceData, context = _ref8.context, oauthToken = _ref8.oauthToken, _ref8$value = _ref8.value, value = _ref8$value === void 0 ? 0 : _ref8$value;
722
+ if (!oauthToken) {
723
+ _context7.next = 5;
724
+ break;
725
+ }
726
+ _context7.next = 4;
727
+ return this.GenerateOauthChannelToken({
728
+ objectId: objectId,
729
+ token: oauthToken
730
+ });
731
+ case 4:
732
+ return _context7.abrupt("return", _context7.sent);
733
+ case 5:
734
+ if (!(!this.noCache && this.channelContentTokens[objectId])) {
735
+ _context7.next = 11;
736
+ break;
737
+ }
738
+ if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
739
+ _context7.next = 10;
740
+ break;
741
+ }
742
+ return _context7.abrupt("return", this.channelContentTokens[objectId].token);
743
+ case 10:
744
+ // Token expired
745
+ delete this.channelContentTokens[objectId];
746
+ case 11:
747
+ this.Log("Making state channel access request: ".concat(objectId));
748
+ if (!issuer) {
749
+ _context7.next = 43;
750
+ break;
751
+ }
752
+ // Ticket API
753
+ tenantId = issuer.replace(/^\//, "").split("/")[2];
754
+ _context7.prev = 14;
755
+ _context7.next = 17;
756
+ return this.client.CallContractMethod({
757
+ contractAddress: Utils.HashToAddress(tenantId),
758
+ methodName: "addressKMS"
759
+ });
760
+ case 17:
761
+ kmsAddress = _context7.sent;
762
+ if (kmsAddress) {
763
+ _context7.next = 20;
764
+ break;
765
+ }
766
+ throw "";
767
+ case 20:
768
+ _context7.next = 27;
769
+ break;
770
+ case 22:
771
+ _context7.prev = 22;
772
+ _context7.t0 = _context7["catch"](14);
773
+ _context7.next = 26;
774
+ return this.client.DefaultKMSAddress();
775
+ case 26:
776
+ kmsAddress = _context7.sent;
777
+ case 27:
778
+ _context7.prev = 27;
779
+ _context7.next = 30;
780
+ return Utils.ResponseToFormat("text", this.MakeAuthServiceRequest({
781
+ kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
782
+ method: "POST",
783
+ path: UrlJoin("as", issuer),
784
+ body: {
785
+ "_PASSWORD": code,
786
+ "_EMAIL": email
787
+ }
788
+ }));
789
+ case 30:
790
+ token = _context7.sent;
791
+ _context7.next = 40;
792
+ break;
793
+ case 33:
794
+ _context7.prev = 33;
795
+ _context7.t1 = _context7["catch"](27);
796
+ this.Log("/as token redemption failed:", true);
797
+ this.Log(_context7.t1, true);
798
+ _context7.next = 39;
799
+ return Utils.ResponseToFormat("text", this.MakeKMSRequest({
800
+ kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
801
+ method: "POST",
802
+ path: UrlJoin("ks", issuer),
803
+ body: {
804
+ "_PASSWORD": code,
805
+ "_EMAIL": email
806
+ }
807
+ }));
808
+ case 39:
809
+ token = _context7.sent;
810
+ case 40:
811
+ // Pull target object from token so token can be cached
812
+ objectId = JSON.parse(Utils.FromB64(token)).qid;
813
+ _context7.next = 54;
814
+ break;
815
+ case 43:
816
+ // State channel API
817
+ if (!audienceData) {
818
+ audienceData = this.AudienceData({
819
+ objectId: objectId,
820
+ versionHash: versionHash,
821
+ context: context
822
+ });
823
+ }
824
+ stateChannelApi = "elv_channelContentRequestContext";
825
+ additionalParams = [JSON.stringify(audienceData)];
826
+ _context7.next = 48;
827
+ return this.MakeKMSCall({
828
+ objectId: objectId,
829
+ methodName: stateChannelApi,
830
+ paramTypes: ["address", "address", "uint", "uint"],
831
+ params: [this.client.signer.address, Utils.HashToAddress(objectId), value, Date.now()],
832
+ additionalParams: additionalParams
833
+ });
834
+ case 48:
835
+ payload = _context7.sent;
836
+ _context7.next = 51;
837
+ return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(payload)));
838
+ case 51:
839
+ signature = _context7.sent;
840
+ multiSig = Utils.FormatSignature(signature);
841
+ token = "".concat(payload, ".").concat(Utils.B64(multiSig));
842
+ case 54:
843
+ if (!this.noCache) {
844
+ this.channelContentTokens[objectId] = {
845
+ token: token,
846
+ issuedAt: Date.now()
847
+ };
848
+ }
849
+ return _context7.abrupt("return", token);
850
+ case 56:
851
+ case "end":
852
+ return _context7.stop();
853
+ }
854
+ }, _callee7, this, [[14, 22], [27, 33]]);
855
+ }));
856
+ function GenerateChannelContentToken(_x7) {
857
+ return _GenerateChannelContentToken.apply(this, arguments);
858
+ }
859
+ return GenerateChannelContentToken;
860
+ }()
861
+ }, {
862
+ key: "ChannelContentFinalize",
863
+ value: function () {
864
+ var _ChannelContentFinalize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref9) {
865
+ var objectId, versionHash, _ref9$percent, percent, result;
866
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
867
+ while (1) switch (_context8.prev = _context8.next) {
868
+ case 0:
869
+ objectId = _ref9.objectId, versionHash = _ref9.versionHash, _ref9$percent = _ref9.percent, percent = _ref9$percent === void 0 ? 0 : _ref9$percent;
870
+ this.Log("Making state channel finalize request: ".concat(objectId));
871
+ _context8.next = 4;
872
+ return this.MakeKMSCall({
873
+ objectId: objectId,
874
+ methodName: "elv_channelContentFinalizeContext",
875
+ paramTypes: ["address", "address", "uint", "uint"],
876
+ params: [this.client.signer.address, Utils.HashToAddress(objectId), percent, Date.now()],
877
+ additionalParams: [JSON.stringify(this.AudienceData({
878
+ objectId: objectId,
879
+ versionHash: versionHash
880
+ }))]
881
+ });
882
+ case 4:
883
+ result = _context8.sent;
884
+ this.channelContentTokens[objectId] = undefined;
885
+ return _context8.abrupt("return", result);
886
+ case 7:
887
+ case "end":
888
+ return _context8.stop();
889
+ }
890
+ }, _callee8, this);
891
+ }));
892
+ function ChannelContentFinalize(_x8) {
893
+ return _ChannelContentFinalize.apply(this, arguments);
894
+ }
895
+ return ChannelContentFinalize;
896
+ }()
897
+ }, {
898
+ key: "GenerateOauthChannelToken",
899
+ value: function () {
900
+ var _GenerateOauthChannelToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref10) {
901
+ var objectId, versionHash, token, fabricToken;
902
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
903
+ while (1) switch (_context9.prev = _context9.next) {
904
+ case 0:
905
+ objectId = _ref10.objectId, versionHash = _ref10.versionHash, token = _ref10.token;
906
+ if (versionHash) {
907
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
908
+ }
909
+ if (!(!this.noCache && this.channelContentTokens[objectId])) {
910
+ _context9.next = 6;
911
+ break;
912
+ }
913
+ if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
914
+ _context9.next = 5;
915
+ break;
916
+ }
917
+ return _context9.abrupt("return", this.channelContentTokens[objectId].token);
918
+ case 5:
919
+ // Token expired
920
+ this.channelContentTokens[objectId] = undefined;
921
+ case 6:
922
+ _context9.next = 8;
923
+ return this.MakeKMSRequest({
924
+ objectId: objectId,
925
+ versionHash: versionHash,
926
+ method: "GET",
927
+ path: UrlJoin("ks", "jwt", "q", objectId),
928
+ bodyType: "NONE",
929
+ headers: {
930
+ Authorization: "Bearer ".concat(token)
931
+ }
932
+ });
933
+ case 8:
934
+ _context9.next = 10;
935
+ return _context9.sent.text();
936
+ case 10:
937
+ fabricToken = _context9.sent;
938
+ if (!this.noCache) {
939
+ this.channelContentTokens[objectId] = {
940
+ token: fabricToken,
941
+ issuedAt: Date.now()
942
+ };
943
+ }
944
+ return _context9.abrupt("return", fabricToken);
945
+ case 13:
946
+ case "end":
947
+ return _context9.stop();
948
+ }
949
+ }, _callee9, this);
950
+ }));
951
+ function GenerateOauthChannelToken(_x9) {
952
+ return _GenerateOauthChannelToken.apply(this, arguments);
953
+ }
954
+ return GenerateOauthChannelToken;
955
+ }()
956
+ }, {
957
+ key: "IsV3",
958
+ value: function () {
959
+ var _IsV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref11) {
960
+ var id, contractName;
961
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
962
+ while (1) switch (_context10.prev = _context10.next) {
963
+ case 0:
964
+ id = _ref11.id;
965
+ if (!this.client.assumeV3) {
966
+ _context10.next = 3;
967
+ break;
968
+ }
969
+ return _context10.abrupt("return", true);
970
+ case 3:
971
+ _context10.next = 5;
972
+ return this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
973
+ case 5:
974
+ contractName = _context10.sent;
975
+ if (!this.accessVersions[contractName]) {
976
+ this.accessVersions[contractName] = this.ContractHasMethod({
977
+ contractAddress: this.client.utils.HashToAddress(id),
978
+ abi: this.CONTRACTS.v3[this.ACCESS_TYPES.ACCESSIBLE].abi,
979
+ methodName: "accessRequestV3"
980
+ });
981
+ }
982
+ _context10.next = 9;
983
+ return this.accessVersions[contractName];
984
+ case 9:
985
+ return _context10.abrupt("return", _context10.sent);
986
+ case 10:
987
+ case "end":
988
+ return _context10.stop();
989
+ }
990
+ }, _callee10, this);
991
+ }));
992
+ function IsV3(_x10) {
993
+ return _IsV.apply(this, arguments);
994
+ }
995
+ return IsV3;
996
+ }()
997
+ }, {
998
+ key: "AccessInfo",
999
+ value: function () {
1000
+ var _AccessInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref12) {
1001
+ var accessType, publicKey, args, isV3, checkAccessCharge;
1002
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
1003
+ while (1) switch (_context11.prev = _context11.next) {
1004
+ case 0:
1005
+ accessType = _ref12.accessType, publicKey = _ref12.publicKey, args = _ref12.args, isV3 = _ref12.isV3;
1006
+ checkAccessCharge = false;
1007
+ if (accessType === ACCESS_TYPES.OBJECT) {
1008
+ checkAccessCharge = true;
1009
+ if (!isV3) {
1010
+ if (args && args.length > 0) {
1011
+ // Inject public key of requester
1012
+ args[1] = this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "";
1013
+ } else {
1014
+ // Set default args
1015
+ args = [0,
1016
+ // Access level
1017
+ this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "",
1018
+ // Public key of requester
1019
+ publicKey,
1020
+ //cap.public_key,
1021
+ [],
1022
+ // Custom values
1023
+ [] // Stakeholders
1024
+ ];
1025
+ }
1026
+ }
1027
+ }
1028
+ if (isV3 && (!args || args.length === 0)) {
1029
+ args = [[],
1030
+ // customValues
1031
+ [] // stakeholders
1032
+ ];
1033
+ }
1034
+ return _context11.abrupt("return", {
1035
+ accessArgs: args,
1036
+ checkAccessCharge: checkAccessCharge
1037
+ });
1038
+ case 5:
1039
+ case "end":
1040
+ return _context11.stop();
1041
+ }
1042
+ }, _callee11, this);
1043
+ }));
1044
+ function AccessInfo(_x11) {
1045
+ return _AccessInfo.apply(this, arguments);
1046
+ }
1047
+ return AccessInfo;
1048
+ }() // Determine type of ID based on contract version string
1049
+ }, {
1050
+ key: "AccessType",
1051
+ value: function () {
1052
+ var _AccessType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id) {
1053
+ var contractName, accessType;
1054
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1055
+ while (1) switch (_context12.prev = _context12.next) {
1056
+ case 0:
1057
+ _context12.next = 2;
1058
+ return this.client.ethClient.ContractName(Utils.HashToAddress(id));
1059
+ case 2:
1060
+ contractName = _context12.sent;
1061
+ if (this.accessTypes[id]) {
1062
+ _context12.next = 23;
1063
+ break;
1064
+ }
1065
+ _context12.t0 = contractName;
1066
+ _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;
1067
+ break;
1068
+ case 7:
1069
+ accessType = ACCESS_TYPES.SPACE;
1070
+ return _context12.abrupt("break", 22);
1071
+ case 9:
1072
+ accessType = ACCESS_TYPES.LIBRARY;
1073
+ return _context12.abrupt("break", 22);
1074
+ case 11:
1075
+ accessType = ACCESS_TYPES.TYPE;
1076
+ return _context12.abrupt("break", 22);
1077
+ case 13:
1078
+ accessType = ACCESS_TYPES.WALLET;
1079
+ return _context12.abrupt("break", 22);
1080
+ case 15:
1081
+ accessType = ACCESS_TYPES.GROUP;
1082
+ return _context12.abrupt("break", 22);
1083
+ case 17:
1084
+ accessType = ACCESS_TYPES.OBJECT;
1085
+ return _context12.abrupt("break", 22);
1086
+ case 19:
1087
+ accessType = ACCESS_TYPES.TENANT;
1088
+ return _context12.abrupt("break", 22);
1089
+ case 21:
1090
+ accessType = ACCESS_TYPES.OTHER;
1091
+ case 22:
1092
+ this.accessTypes[id] = accessType;
1093
+ case 23:
1094
+ return _context12.abrupt("return", this.accessTypes[id]);
1095
+ case 24:
1096
+ case "end":
1097
+ return _context12.stop();
1098
+ }
1099
+ }, _callee12, this);
1100
+ }));
1101
+ function AccessType(_x12) {
1102
+ return _AccessType.apply(this, arguments);
1103
+ }
1104
+ return AccessType;
1105
+ }()
1106
+ }, {
1107
+ key: "AccessComplete",
1108
+ value: function () {
1109
+ var _AccessComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref13) {
1110
+ var id, score, _yield$this$ContractI3, abi, isV3, address, requestId, event;
1111
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1112
+ while (1) switch (_context13.prev = _context13.next) {
1113
+ case 0:
1114
+ id = _ref13.id, score = _ref13.score;
1115
+ this.Log("Calling access complete on ".concat(id, " with score ").concat(score));
1116
+ _context13.next = 4;
1117
+ return this.ContractInfo({
1118
+ id: id
1119
+ });
1120
+ case 4:
1121
+ _yield$this$ContractI3 = _context13.sent;
1122
+ abi = _yield$this$ContractI3.abi;
1123
+ isV3 = _yield$this$ContractI3.isV3;
1124
+ address = Utils.HashToAddress(id);
1125
+ requestId = this.requestIds[address];
1126
+ if (requestId) {
1127
+ _context13.next = 11;
1128
+ break;
1129
+ }
1130
+ throw Error("Unknown request ID for " + id);
1131
+ case 11:
1132
+ if (!isV3) {
1133
+ _context13.next = 17;
1134
+ break;
1135
+ }
1136
+ _context13.next = 14;
1137
+ return this.client.CallContractMethodAndWait({
1138
+ contractAddress: address,
1139
+ abi: abi,
1140
+ methodName: "accessCompleteV3",
1141
+ methodArgs: [requestId, [], []]
1142
+ });
1143
+ case 14:
1144
+ event = _context13.sent;
1145
+ _context13.next = 20;
1146
+ break;
1147
+ case 17:
1148
+ _context13.next = 19;
1149
+ return this.client.CallContractMethodAndWait({
1150
+ contractAddress: address,
1151
+ abi: abi,
1152
+ methodName: isV3 ? "accessCompleteV3" : "accessComplete",
1153
+ methodArgs: [requestId, score, ""]
1154
+ });
1155
+ case 19:
1156
+ event = _context13.sent;
1157
+ case 20:
1158
+ delete this.requestIds[address];
1159
+ delete this.accessTransactions[address];
1160
+ return _context13.abrupt("return", event);
1161
+ case 23:
1162
+ case "end":
1163
+ return _context13.stop();
1164
+ }
1165
+ }, _callee13, this);
1166
+ }));
1167
+ function AccessComplete(_x13) {
1168
+ return _AccessComplete.apply(this, arguments);
1169
+ }
1170
+ return AccessComplete;
1171
+ }() /* Utility methods */
1172
+ }, {
1173
+ key: "ContractInfo",
1174
+ value: (function () {
1175
+ var _ContractInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref14) {
1176
+ var id, address, isV3, contractName, accessType, v3Version, version;
1177
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1178
+ while (1) switch (_context14.prev = _context14.next) {
1179
+ case 0:
1180
+ id = _ref14.id, address = _ref14.address;
1181
+ if (!address) {
1182
+ address = Utils.HashToAddress(id);
1183
+ }
1184
+ if (!id) {
1185
+ id = Utils.AddressToObjectId(address);
1186
+ }
1187
+ _context14.next = 5;
1188
+ return this.IsV3({
1189
+ id: id
1190
+ });
1191
+ case 5:
1192
+ isV3 = _context14.sent;
1193
+ _context14.next = 8;
1194
+ return this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
1195
+ case 8:
1196
+ contractName = _context14.sent;
1197
+ _context14.next = 11;
1198
+ return this.AccessType(id);
1199
+ case 11:
1200
+ accessType = _context14.sent;
1201
+ // Contract BsAccessCtrlGrp20210809150000PO has an outdated isAdmin method that checks a managersList array instead of managersMap
1202
+ v3Version = contractName === "BsAccessCtrlGrp20210809150000PO" && accessType === this.ACCESS_TYPES.GROUP ? "v3b" : "v3";
1203
+ version = isV3 ? v3Version : "v2";
1204
+ if (!(accessType === this.ACCESS_TYPES.OTHER)) {
1205
+ _context14.next = 16;
1206
+ break;
1207
+ }
1208
+ return _context14.abrupt("return", {});
1209
+ case 16:
1210
+ return _context14.abrupt("return", {
1211
+ isV3: isV3,
1212
+ accessType: accessType,
1213
+ abi: this.CONTRACTS[version][accessType].abi
1214
+ });
1215
+ case 17:
1216
+ case "end":
1217
+ return _context14.stop();
1218
+ }
1219
+ }, _callee14, this);
1220
+ }));
1221
+ function ContractInfo(_x14) {
1222
+ return _ContractInfo.apply(this, arguments);
1223
+ }
1224
+ return ContractInfo;
1225
+ }())
1226
+ }, {
1227
+ key: "GetAccessCharge",
1228
+ value: function () {
1229
+ var _GetAccessCharge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref15) {
1230
+ var objectId, args, _yield$this$ContractI4, abi, info;
1231
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1232
+ while (1) switch (_context15.prev = _context15.next) {
1233
+ case 0:
1234
+ objectId = _ref15.objectId, args = _ref15.args;
1235
+ _context15.next = 3;
1236
+ return this.ContractInfo({
1237
+ id: objectId
1238
+ });
1239
+ case 3:
1240
+ _yield$this$ContractI4 = _context15.sent;
1241
+ abi = _yield$this$ContractI4.abi;
1242
+ _context15.next = 7;
1243
+ return this.client.CallContractMethod({
1244
+ contractAddress: Utils.HashToAddress(objectId),
1245
+ abi: abi,
1246
+ methodName: "getAccessInfo",
1247
+ methodArgs: args
1248
+ });
1249
+ case 7:
1250
+ info = _context15.sent;
1251
+ return _context15.abrupt("return", info[1] === 0 ? 0 : info[2]);
1252
+ case 9:
1253
+ case "end":
1254
+ return _context15.stop();
1255
+ }
1256
+ }, _callee15, this);
1257
+ }));
1258
+ function GetAccessCharge(_x15) {
1259
+ return _GetAccessCharge.apply(this, arguments);
1260
+ }
1261
+ return GetAccessCharge;
1262
+ }()
1263
+ }, {
1264
+ key: "Owner",
1265
+ value: function () {
1266
+ var _Owner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref16) {
1267
+ var id, address, ownerAddress;
1268
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1269
+ while (1) switch (_context16.prev = _context16.next) {
1270
+ case 0:
1271
+ id = _ref16.id, address = _ref16.address;
1272
+ if (this.client.signer) {
1273
+ _context16.next = 3;
1274
+ break;
1275
+ }
1276
+ return _context16.abrupt("return", false);
1277
+ case 3:
1278
+ if (id) {
1279
+ address = Utils.HashToAddress(id);
1280
+ }
1281
+ _context16.next = 6;
1282
+ return this.client.CallContractMethod({
1283
+ contractAddress: address,
1284
+ methodName: "owner",
1285
+ methodArgs: []
1286
+ });
1287
+ case 6:
1288
+ ownerAddress = _context16.sent;
1289
+ return _context16.abrupt("return", Utils.FormatAddress(ownerAddress));
1290
+ case 8:
1291
+ case "end":
1292
+ return _context16.stop();
1293
+ }
1294
+ }, _callee16, this);
1295
+ }));
1296
+ function Owner(_x16) {
1297
+ return _Owner.apply(this, arguments);
1298
+ }
1299
+ return Owner;
1300
+ }()
1301
+ }, {
1302
+ key: "Sign",
1303
+ value: function () {
1304
+ var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(message) {
1305
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1306
+ while (1) switch (_context17.prev = _context17.next) {
1307
+ case 0:
1308
+ _context17.t0 = Ethers.utils;
1309
+ if (!this.client.signer.signDigest) {
1310
+ _context17.next = 7;
1311
+ break;
1312
+ }
1313
+ _context17.next = 4;
1314
+ return this.client.signer.signDigest(message);
1315
+ case 4:
1316
+ _context17.t1 = _context17.sent;
1317
+ _context17.next = 10;
1318
+ break;
1319
+ case 7:
1320
+ _context17.next = 9;
1321
+ return this.client.signer._signingKey().signDigest(message);
1322
+ case 9:
1323
+ _context17.t1 = _context17.sent;
1324
+ case 10:
1325
+ _context17.t2 = _context17.t1;
1326
+ _context17.next = 13;
1327
+ return _context17.t0.joinSignature.call(_context17.t0, _context17.t2);
1328
+ case 13:
1329
+ return _context17.abrupt("return", _context17.sent);
1330
+ case 14:
1331
+ case "end":
1332
+ return _context17.stop();
1333
+ }
1334
+ }, _callee17, this);
1335
+ }));
1336
+ function Sign(_x17) {
1337
+ return _Sign.apply(this, arguments);
1338
+ }
1339
+ return Sign;
1340
+ }()
1341
+ }, {
1342
+ key: "KMSAddress",
1343
+ value: function () {
1344
+ var _KMSAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref17) {
1345
+ var objectId, versionHash, _yield$this$ContractI5, abi;
1346
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1347
+ while (1) switch (_context18.prev = _context18.next) {
1348
+ case 0:
1349
+ objectId = _ref17.objectId, versionHash = _ref17.versionHash;
1350
+ if (versionHash) {
1351
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1352
+ }
1353
+ _context18.next = 4;
1354
+ return this.ContractInfo({
1355
+ id: objectId
1356
+ });
1357
+ case 4:
1358
+ _yield$this$ContractI5 = _context18.sent;
1359
+ abi = _yield$this$ContractI5.abi;
1360
+ if (abi) {
1361
+ _context18.next = 8;
1362
+ break;
1363
+ }
1364
+ throw Error("Unable to determine contract info for ".concat(objectId, " - wrong network?"));
1365
+ case 8:
1366
+ _context18.next = 10;
1367
+ return this.client.CallContractMethod({
1368
+ contractAddress: Utils.HashToAddress(objectId),
1369
+ abi: abi,
1370
+ methodName: "addressKMS"
1371
+ });
1372
+ case 10:
1373
+ return _context18.abrupt("return", _context18.sent);
1374
+ case 11:
1375
+ case "end":
1376
+ return _context18.stop();
1377
+ }
1378
+ }, _callee18, this);
1379
+ }));
1380
+ function KMSAddress(_x18) {
1381
+ return _KMSAddress.apply(this, arguments);
1382
+ }
1383
+ return KMSAddress;
1384
+ }()
1385
+ }, {
1386
+ key: "KMSInfo",
1387
+ value: function () {
1388
+ var _KMSInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref18) {
1389
+ var objectId, versionHash, kmsId, KMSInfo, _yield$this$ContractI6, abi, _yield$this$ContractI7, _abi, publicKey;
1390
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1391
+ while (1) switch (_context19.prev = _context19.next) {
1392
+ case 0:
1393
+ objectId = _ref18.objectId, versionHash = _ref18.versionHash, kmsId = _ref18.kmsId;
1394
+ if (!kmsId) {
1395
+ _context19.next = 11;
1396
+ break;
1397
+ }
1398
+ _context19.next = 4;
1399
+ return this.ContractInfo({
1400
+ address: this.client.contentSpaceAddress
1401
+ });
1402
+ case 4:
1403
+ _yield$this$ContractI6 = _context19.sent;
1404
+ abi = _yield$this$ContractI6.abi;
1405
+ _context19.next = 8;
1406
+ return this.client.CallContractMethod({
1407
+ contractAddress: this.client.contentSpaceAddress,
1408
+ abi: abi,
1409
+ methodName: "getKMSInfo",
1410
+ methodArgs: [kmsId, []],
1411
+ formatArguments: false
1412
+ });
1413
+ case 8:
1414
+ KMSInfo = _context19.sent;
1415
+ _context19.next = 19;
1416
+ break;
1417
+ case 11:
1418
+ if (versionHash) {
1419
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1420
+ }
1421
+ _context19.next = 14;
1422
+ return this.ContractInfo({
1423
+ id: objectId
1424
+ });
1425
+ case 14:
1426
+ _yield$this$ContractI7 = _context19.sent;
1427
+ _abi = _yield$this$ContractI7.abi;
1428
+ _context19.next = 18;
1429
+ return this.client.CallContractMethod({
1430
+ contractAddress: Utils.HashToAddress(objectId),
1431
+ abi: _abi,
1432
+ methodName: "getKMSInfo",
1433
+ methodArgs: [[]],
1434
+ formatArguments: false
1435
+ });
1436
+ case 18:
1437
+ KMSInfo = _context19.sent;
1438
+ case 19:
1439
+ // Public key is compressed and hashed
1440
+ publicKey = Ethers.utils.computePublicKey(Utils.HashToAddress(KMSInfo[1]), false);
1441
+ return _context19.abrupt("return", {
1442
+ urls: KMSInfo[0].split(","),
1443
+ publicKey: publicKey
1444
+ });
1445
+ case 21:
1446
+ case "end":
1447
+ return _context19.stop();
1448
+ }
1449
+ }, _callee19, this);
1450
+ }));
1451
+ function KMSInfo(_x19) {
1452
+ return _KMSInfo.apply(this, arguments);
1453
+ }
1454
+ return KMSInfo;
1455
+ }() // Retrieve symmetric key for object
1456
+ }, {
1457
+ key: "RetrieveConk",
1458
+ value: function () {
1459
+ var _RetrieveConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref19) {
1460
+ var libraryId, objectId, kmsAddress, kmsCapId, kmsCap, cap;
1461
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1462
+ while (1) switch (_context20.prev = _context20.next) {
1463
+ case 0:
1464
+ libraryId = _ref19.libraryId, objectId = _ref19.objectId;
1465
+ if (libraryId) {
1466
+ _context20.next = 5;
1467
+ break;
1468
+ }
1469
+ _context20.next = 4;
1470
+ return this.client.ContentObjectLibraryId({
1471
+ objectId: objectId
1472
+ });
1473
+ case 4:
1474
+ libraryId = _context20.sent;
1475
+ case 5:
1476
+ _context20.next = 7;
1477
+ return this.KMSAddress({
1478
+ objectId: objectId
1479
+ });
1480
+ case 7:
1481
+ kmsAddress = _context20.sent;
1482
+ kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1483
+ _context20.next = 11;
1484
+ return this.client.ContentObjectMetadata({
1485
+ libraryId: libraryId,
1486
+ objectId: objectId,
1487
+ metadataSubtree: kmsCapId
1488
+ });
1489
+ case 11:
1490
+ kmsCap = _context20.sent;
1491
+ if (kmsCap) {
1492
+ _context20.next = 14;
1493
+ break;
1494
+ }
1495
+ throw Error("No KMS key set for this object");
1496
+ case 14:
1497
+ _context20.next = 16;
1498
+ return this.MakeKMSCall({
1499
+ objectId: objectId,
1500
+ methodName: "elv_getEncryptionKey",
1501
+ paramTypes: ["string", "string", "string", "string", "string"],
1502
+ params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1503
+ });
1504
+ case 16:
1505
+ cap = _context20.sent;
1506
+ return _context20.abrupt("return", JSON.parse(Utils.FromB58(cap.replace(/^kp__/, "")).toString("utf-8")));
1507
+ case 18:
1508
+ case "end":
1509
+ return _context20.stop();
1510
+ }
1511
+ }, _callee20, this);
1512
+ }));
1513
+ function RetrieveConk(_x20) {
1514
+ return _RetrieveConk.apply(this, arguments);
1515
+ }
1516
+ return RetrieveConk;
1517
+ }() // Retrieve symmetric key for object
1518
+ }, {
1519
+ key: "RetrieveReencryptionSymmetricKey",
1520
+ value: function () {
1521
+ var _RetrieveReencryptionSymmetricKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref20) {
1522
+ var libraryId, objectId, kmsAddress, kmsCapId, kmsCap;
1523
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1524
+ while (1) switch (_context21.prev = _context21.next) {
1525
+ case 0:
1526
+ libraryId = _ref20.libraryId, objectId = _ref20.objectId;
1527
+ if (libraryId) {
1528
+ _context21.next = 5;
1529
+ break;
1530
+ }
1531
+ _context21.next = 4;
1532
+ return this.client.ContentObjectLibraryId({
1533
+ objectId: objectId
1534
+ });
1535
+ case 4:
1536
+ libraryId = _context21.sent;
1537
+ case 5:
1538
+ _context21.next = 7;
1539
+ return this.KMSAddress({
1540
+ objectId: objectId
1541
+ });
1542
+ case 7:
1543
+ kmsAddress = _context21.sent;
1544
+ kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
1545
+ _context21.next = 11;
1546
+ return this.client.ContentObjectMetadata({
1547
+ libraryId: libraryId,
1548
+ objectId: objectId,
1549
+ metadataSubtree: kmsCapId
1550
+ });
1551
+ case 11:
1552
+ kmsCap = _context21.sent;
1553
+ if (kmsCap) {
1554
+ _context21.next = 14;
1555
+ break;
1556
+ }
1557
+ throw Error("No KMS key set for this object");
1558
+ case 14:
1559
+ _context21.next = 16;
1560
+ return this.MakeKMSCall({
1561
+ objectId: objectId,
1562
+ methodName: "elv_getSymmetricKeyAuth",
1563
+ paramTypes: ["string", "string", "string", "string", "string"],
1564
+ params: [this.client.contentSpaceId, libraryId, objectId, kmsCap || "", ""]
1565
+ });
1566
+ case 16:
1567
+ return _context21.abrupt("return", _context21.sent);
1568
+ case 17:
1569
+ case "end":
1570
+ return _context21.stop();
1571
+ }
1572
+ }, _callee21, this);
1573
+ }));
1574
+ function RetrieveReencryptionSymmetricKey(_x21) {
1575
+ return _RetrieveReencryptionSymmetricKey.apply(this, arguments);
1576
+ }
1577
+ return RetrieveReencryptionSymmetricKey;
1578
+ }() // Make an RPC call to the KMS with signed parameters
1579
+ }, {
1580
+ key: "MakeKMSCall",
1581
+ value: function () {
1582
+ var _MakeKMSCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref21) {
1583
+ var kmsId, tenantId, objectId, versionHash, methodName, params, paramTypes, _ref21$additionalPara, additionalParams, _ref21$signature, signature, packedHash, KMSUrls, i, kmsUrl;
1584
+ return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1585
+ while (1) switch (_context22.prev = _context22.next) {
1586
+ case 0:
1587
+ kmsId = _ref21.kmsId, tenantId = _ref21.tenantId, objectId = _ref21.objectId, versionHash = _ref21.versionHash, methodName = _ref21.methodName, params = _ref21.params, paramTypes = _ref21.paramTypes, _ref21$additionalPara = _ref21.additionalParams, additionalParams = _ref21$additionalPara === void 0 ? [] : _ref21$additionalPara, _ref21$signature = _ref21.signature, signature = _ref21$signature === void 0 ? true : _ref21$signature;
1588
+ if (versionHash) {
1589
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1590
+ }
1591
+ if (objectId) {
1592
+ _context22.next = 10;
1593
+ break;
1594
+ }
1595
+ _context22.t0 = "ikms";
1596
+ _context22.t1 = Utils;
1597
+ _context22.next = 7;
1598
+ return this.client.DefaultKMSAddress({
1599
+ tenantId: tenantId
1600
+ });
1601
+ case 7:
1602
+ _context22.t2 = _context22.sent;
1603
+ _context22.t3 = _context22.t1.AddressToHash.call(_context22.t1, _context22.t2);
1604
+ kmsId = _context22.t0.concat.call(_context22.t0, _context22.t3);
1605
+ case 10:
1606
+ if (!signature) {
1607
+ _context22.next = 17;
1608
+ break;
1609
+ }
1610
+ packedHash = Ethers.utils.solidityKeccak256(paramTypes, params);
1611
+ _context22.t4 = params;
1612
+ _context22.next = 15;
1613
+ return this.Sign(packedHash);
1614
+ case 15:
1615
+ _context22.t5 = _context22.sent;
1616
+ _context22.t4.push.call(_context22.t4, _context22.t5);
1617
+ case 17:
1618
+ params = params.concat(additionalParams);
1619
+ _context22.next = 20;
1620
+ return this.KMSInfo({
1621
+ kmsId: kmsId,
1622
+ objectId: objectId,
1623
+ versionHash: versionHash
1624
+ });
1625
+ case 20:
1626
+ KMSUrls = _context22.sent.urls;
1627
+ i = 0;
1628
+ case 22:
1629
+ if (!(i < KMSUrls.length)) {
1630
+ _context22.next = 40;
1631
+ break;
1632
+ }
1633
+ _context22.prev = 23;
1634
+ this.Log("Making KMS request:\n URL: ".concat(KMSUrls[i], "\n Method: ").concat(methodName, "\n Params: ").concat(params.join(", ")));
1635
+ kmsUrl = KMSUrls[i];
1636
+ if (!this.providers[kmsUrl]) {
1637
+ this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
1638
+ }
1639
+ _context22.next = 29;
1640
+ return this.providers[kmsUrl].send(methodName, params);
1641
+ case 29:
1642
+ return _context22.abrupt("return", _context22.sent);
1643
+ case 32:
1644
+ _context22.prev = 32;
1645
+ _context22.t6 = _context22["catch"](23);
1646
+ this.Log("KMS Call Error: ".concat(_context22.t6), true);
1647
+
1648
+ // If the request has been attempted on all KMS urls, throw the error
1649
+ if (!(i === KMSUrls.length - 1)) {
1650
+ _context22.next = 37;
1651
+ break;
1652
+ }
1653
+ throw _context22.t6;
1654
+ case 37:
1655
+ i++;
1656
+ _context22.next = 22;
1657
+ break;
1658
+ case 40:
1659
+ case "end":
1660
+ return _context22.stop();
1661
+ }
1662
+ }, _callee22, this, [[23, 32]]);
1663
+ }));
1664
+ function MakeKMSCall(_x22) {
1665
+ return _MakeKMSCall.apply(this, arguments);
1666
+ }
1667
+ return MakeKMSCall;
1668
+ }() // Make an arbitrary HTTP call to an authority server
1669
+ }, {
1670
+ key: "MakeAuthServiceRequest",
1671
+ value: function () {
1672
+ var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref22) {
1673
+ var kmsId, objectId, versionHash, _ref22$method, method, path, bodyType, _ref22$body, body, _ref22$queryParams, queryParams, headers;
1674
+ return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1675
+ while (1) switch (_context23.prev = _context23.next) {
1676
+ case 0:
1677
+ kmsId = _ref22.kmsId, objectId = _ref22.objectId, versionHash = _ref22.versionHash, _ref22$method = _ref22.method, method = _ref22$method === void 0 ? "GET" : _ref22$method, path = _ref22.path, bodyType = _ref22.bodyType, _ref22$body = _ref22.body, body = _ref22$body === void 0 ? {} : _ref22$body, _ref22$queryParams = _ref22.queryParams, queryParams = _ref22$queryParams === void 0 ? {} : _ref22$queryParams, headers = _ref22.headers;
1678
+ if (!(this.client.authServiceURIs.length === 0)) {
1679
+ _context23.next = 5;
1680
+ break;
1681
+ }
1682
+ _context23.next = 4;
1683
+ return this.MakeKMSRequest({
1684
+ kmsId: kmsId,
1685
+ objectId: objectId,
1686
+ versionHash: versionHash,
1687
+ method: method,
1688
+ path: path,
1689
+ bodyType: bodyType,
1690
+ body: body,
1691
+ queryParams: queryParams,
1692
+ headers: headers
1693
+ });
1694
+ case 4:
1695
+ return _context23.abrupt("return", _context23.sent);
1696
+ case 5:
1697
+ _context23.next = 7;
1698
+ return this.client.AuthHttpClient.Request({
1699
+ method: method,
1700
+ path: path,
1701
+ bodyType: bodyType,
1702
+ body: body,
1703
+ headers: headers,
1704
+ queryParams: queryParams
1705
+ });
1706
+ case 7:
1707
+ return _context23.abrupt("return", _context23.sent);
1708
+ case 8:
1709
+ case "end":
1710
+ return _context23.stop();
1711
+ }
1712
+ }, _callee23, this);
1713
+ }));
1714
+ function MakeAuthServiceRequest(_x23) {
1715
+ return _MakeAuthServiceRequest.apply(this, arguments);
1716
+ }
1717
+ return MakeAuthServiceRequest;
1718
+ }() // Make an arbitrary HTTP call to the KMS
1719
+ }, {
1720
+ key: "MakeKMSRequest",
1721
+ value: function () {
1722
+ var _MakeKMSRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref23) {
1723
+ var kmsId, objectId, versionHash, _ref23$method, method, path, bodyType, _ref23$body, body, _ref23$queryParams, queryParams, headers, kmsUrls, kmsHttpClient;
1724
+ return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1725
+ while (1) switch (_context24.prev = _context24.next) {
1726
+ case 0:
1727
+ 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;
1728
+ if (versionHash) {
1729
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1730
+ }
1731
+ if (!(!objectId && !kmsId)) {
1732
+ _context24.next = 10;
1733
+ break;
1734
+ }
1735
+ _context24.t0 = "ikms";
1736
+ _context24.t1 = Utils;
1737
+ _context24.next = 7;
1738
+ return this.client.DefaultKMSAddress();
1739
+ case 7:
1740
+ _context24.t2 = _context24.sent;
1741
+ _context24.t3 = _context24.t1.AddressToHash.call(_context24.t1, _context24.t2);
1742
+ kmsId = _context24.t0.concat.call(_context24.t0, _context24.t3);
1743
+ case 10:
1744
+ _context24.next = 12;
1745
+ return this.KMSInfo({
1746
+ kmsId: kmsId,
1747
+ objectId: objectId,
1748
+ versionHash: versionHash
1749
+ });
1750
+ case 12:
1751
+ kmsUrls = _context24.sent.urls;
1752
+ if (!(!kmsUrls || !kmsUrls[0])) {
1753
+ _context24.next = 15;
1754
+ break;
1755
+ }
1756
+ throw Error("No KMS info set for ".concat(versionHash || objectId || "default KMS"));
1757
+ case 15:
1758
+ kmsHttpClient = new HttpClient({
1759
+ uris: kmsUrls
1760
+ });
1761
+ _context24.next = 18;
1762
+ return kmsHttpClient.Request({
1763
+ method: method,
1764
+ path: path,
1765
+ bodyType: bodyType,
1766
+ body: body,
1767
+ headers: headers,
1768
+ queryParams: queryParams
1769
+ });
1770
+ case 18:
1771
+ return _context24.abrupt("return", _context24.sent);
1772
+ case 19:
1773
+ case "end":
1774
+ return _context24.stop();
1775
+ }
1776
+ }, _callee24, this);
1777
+ }));
1778
+ function MakeKMSRequest(_x24) {
1779
+ return _MakeKMSRequest.apply(this, arguments);
1780
+ }
1781
+ return MakeKMSRequest;
1782
+ }()
1783
+ }, {
1784
+ key: "ContractHasMethod",
1785
+ value: function () {
1786
+ var _ContractHasMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref24) {
1787
+ var contractAddress, abi, methodName, key, method, methodSignature, methodId;
1788
+ return _regeneratorRuntime.wrap(function _callee25$(_context25) {
1789
+ while (1) switch (_context25.prev = _context25.next) {
1790
+ case 0:
1791
+ contractAddress = _ref24.contractAddress, abi = _ref24.abi, methodName = _ref24.methodName;
1792
+ contractAddress = Utils.FormatAddress(contractAddress);
1793
+ key = "".concat(contractAddress, "-").concat(methodName);
1794
+ if (!(this.methodAvailability[key] === undefined)) {
1795
+ _context25.next = 19;
1796
+ break;
1797
+ }
1798
+ this.Log("Checking method availability: ".concat(contractAddress, " ").concat(methodName));
1799
+ if (abi) {
1800
+ _context25.next = 9;
1801
+ break;
1802
+ }
1803
+ _context25.next = 8;
1804
+ return this.ContractInfo({
1805
+ address: contractAddress
1806
+ });
1807
+ case 8:
1808
+ abi = _context25.sent.abi;
1809
+ case 9:
1810
+ if (abi) {
1811
+ _context25.next = 11;
1812
+ break;
1813
+ }
1814
+ throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
1815
+ case 11:
1816
+ method = abi.find(function (method) {
1817
+ return method.name === methodName;
1818
+ });
1819
+ if (method) {
1820
+ _context25.next = 14;
1821
+ break;
1822
+ }
1823
+ return _context25.abrupt("return", false);
1824
+ case 14:
1825
+ methodSignature = "".concat(method.name, "(").concat(method.inputs.map(function (i) {
1826
+ return i.type;
1827
+ }).join(","), ")");
1828
+ methodId = Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(methodSignature)).replace("0x", "").slice(0, 8);
1829
+ _context25.next = 18;
1830
+ return this.MakeElvMasterCall({
1831
+ methodName: "elv_deployedContractHasMethod",
1832
+ params: [contractAddress, methodId]
1833
+ });
1834
+ case 18:
1835
+ this.methodAvailability[key] = _context25.sent;
1836
+ case 19:
1837
+ return _context25.abrupt("return", this.methodAvailability[key]);
1838
+ case 20:
1839
+ case "end":
1840
+ return _context25.stop();
1841
+ }
1842
+ }, _callee25, this);
1843
+ }));
1844
+ function ContractHasMethod(_x25) {
1845
+ return _ContractHasMethod.apply(this, arguments);
1846
+ }
1847
+ return ContractHasMethod;
1848
+ }()
1849
+ }, {
1850
+ key: "MakeElvMasterCall",
1851
+ value: function () {
1852
+ var _MakeElvMasterCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref25) {
1853
+ var methodName, params;
1854
+ return _regeneratorRuntime.wrap(function _callee26$(_context26) {
1855
+ while (1) switch (_context26.prev = _context26.next) {
1856
+ case 0:
1857
+ methodName = _ref25.methodName, params = _ref25.params;
1858
+ _context26.next = 3;
1859
+ return this.client.ethClient.MakeProviderCall({
1860
+ methodName: "send",
1861
+ args: [methodName, params]
1862
+ });
1863
+ case 3:
1864
+ return _context26.abrupt("return", _context26.sent);
1865
+ case 4:
1866
+ case "end":
1867
+ return _context26.stop();
1868
+ }
1869
+ }, _callee26, this);
1870
+ }));
1871
+ function MakeElvMasterCall(_x26) {
1872
+ return _MakeElvMasterCall.apply(this, arguments);
1873
+ }
1874
+ return MakeElvMasterCall;
1875
+ }()
1876
+ }, {
1877
+ key: "ReEncryptionConk",
1878
+ value: function () {
1879
+ var _ReEncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref26) {
1880
+ var libraryId, objectId, versionHash, cap;
1881
+ return _regeneratorRuntime.wrap(function _callee27$(_context27) {
1882
+ while (1) switch (_context27.prev = _context27.next) {
1883
+ case 0:
1884
+ libraryId = _ref26.libraryId, objectId = _ref26.objectId, versionHash = _ref26.versionHash;
1885
+ if (versionHash) {
1886
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1887
+ }
1888
+ if (this.reencryptionKeys[objectId]) {
1889
+ _context27.next = 10;
1890
+ break;
1891
+ }
1892
+ _context27.next = 5;
1893
+ return this.client.Crypto.GenerateTargetConk();
1894
+ case 5:
1895
+ cap = _context27.sent;
1896
+ _context27.next = 8;
1897
+ return this.RetrieveReencryptionSymmetricKey({
1898
+ libraryId: libraryId,
1899
+ objectId: objectId
1900
+ });
1901
+ case 8:
1902
+ cap.symm_key = _context27.sent;
1903
+ this.reencryptionKeys[objectId] = cap;
1904
+ case 10:
1905
+ return _context27.abrupt("return", this.reencryptionKeys[objectId]);
1906
+ case 11:
1907
+ case "end":
1908
+ return _context27.stop();
1909
+ }
1910
+ }, _callee27, this);
1911
+ }));
1912
+ function ReEncryptionConk(_x27) {
1913
+ return _ReEncryptionConk.apply(this, arguments);
1914
+ }
1915
+ return ReEncryptionConk;
1916
+ }()
1917
+ }, {
1918
+ key: "EncryptionConk",
1919
+ value: function () {
1920
+ var _EncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref27) {
1921
+ var libraryId, objectId, versionHash, conk, _yield$this$client$Cr, secret_key;
1922
+ return _regeneratorRuntime.wrap(function _callee28$(_context28) {
1923
+ while (1) switch (_context28.prev = _context28.next) {
1924
+ case 0:
1925
+ libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash;
1926
+ if (versionHash) {
1927
+ objectId = Utils.DecodeVersionHash(versionHash).objectId;
1928
+ }
1929
+ if (libraryId) {
1930
+ _context28.next = 6;
1931
+ break;
1932
+ }
1933
+ _context28.next = 5;
1934
+ return this.client.ContentObjectLibraryId({
1935
+ objectId: objectId
1936
+ });
1937
+ case 5:
1938
+ libraryId = _context28.sent;
1939
+ case 6:
1940
+ if (this.encryptionKeys[objectId]) {
1941
+ _context28.next = 16;
1942
+ break;
1943
+ }
1944
+ _context28.next = 9;
1945
+ return this.RetrieveConk({
1946
+ libraryId: libraryId,
1947
+ objectId: objectId
1948
+ });
1949
+ case 9:
1950
+ conk = _context28.sent;
1951
+ _context28.next = 12;
1952
+ return this.client.Crypto.GeneratePrimaryConk({
1953
+ objectId: objectId
1954
+ });
1955
+ case 12:
1956
+ _yield$this$client$Cr = _context28.sent;
1957
+ secret_key = _yield$this$client$Cr.secret_key;
1958
+ conk.secret_key = secret_key;
1959
+
1960
+ // { secret_key, public_key, symm_key, block_size }
1961
+ this.encryptionKeys[objectId] = conk;
1962
+ case 16:
1963
+ return _context28.abrupt("return", this.encryptionKeys[objectId]);
1964
+ case 17:
1965
+ case "end":
1966
+ return _context28.stop();
1967
+ }
1968
+ }, _callee28, this);
1969
+ }));
1970
+ function EncryptionConk(_x28) {
1971
+ return _EncryptionConk.apply(this, arguments);
1972
+ }
1973
+ return EncryptionConk;
1974
+ }()
1975
+ }, {
1976
+ key: "RecordTags",
1977
+ value: function () {
1978
+ var _RecordTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref28) {
1979
+ var accessType, libraryId, objectId, versionHash, _yield$this$ContractI8, abi, owner;
1980
+ return _regeneratorRuntime.wrap(function _callee29$(_context29) {
1981
+ while (1) switch (_context29.prev = _context29.next) {
1982
+ case 0:
1983
+ accessType = _ref28.accessType, libraryId = _ref28.libraryId, objectId = _ref28.objectId, versionHash = _ref28.versionHash;
1984
+ if (!(accessType !== ACCESS_TYPES.OBJECT)) {
1985
+ _context29.next = 3;
1986
+ break;
1987
+ }
1988
+ return _context29.abrupt("return");
1989
+ case 3:
1990
+ _context29.next = 5;
1991
+ return this.ContractInfo({
1992
+ id: objectId
1993
+ });
1994
+ case 5:
1995
+ _yield$this$ContractI8 = _context29.sent;
1996
+ abi = _yield$this$ContractI8.abi;
1997
+ _context29.next = 9;
1998
+ return this.Owner({
1999
+ id: objectId,
2000
+ abi: abi
2001
+ });
2002
+ case 9:
2003
+ owner = _context29.sent;
2004
+ if (Utils.EqualAddress(owner, this.client.signer.address)) {
2005
+ _context29.next = 13;
2006
+ break;
2007
+ }
2008
+ _context29.next = 13;
2009
+ return this.client.userProfileClient.RecordTags({
2010
+ libraryId: libraryId,
2011
+ objectId: objectId,
2012
+ versionHash: versionHash
2013
+ });
2014
+ case 13:
2015
+ case "end":
2016
+ return _context29.stop();
2017
+ }
2018
+ }, _callee29, this);
2019
+ }));
2020
+ function RecordTags(_x29) {
2021
+ return _RecordTags.apply(this, arguments);
2022
+ }
2023
+ return RecordTags;
2024
+ }() /* Creation methods */
2025
+ }, {
2026
+ key: "CreateAccessGroup",
2027
+ value: (function () {
2028
+ var _CreateAccessGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
2029
+ var _yield$this$client$et, contractAddress, transactionHash;
2030
+ return _regeneratorRuntime.wrap(function _callee30$(_context30) {
2031
+ while (1) switch (_context30.prev = _context30.next) {
2032
+ case 0:
2033
+ _context30.next = 2;
2034
+ return this.client.ethClient.DeployAccessGroupContract({
2035
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2036
+ signer: this.client.signer
2037
+ });
2038
+ case 2:
2039
+ _yield$this$client$et = _context30.sent;
2040
+ contractAddress = _yield$this$client$et.contractAddress;
2041
+ transactionHash = _yield$this$client$et.transactionHash;
2042
+ return _context30.abrupt("return", {
2043
+ contractAddress: contractAddress,
2044
+ transactionHash: transactionHash
2045
+ });
2046
+ case 6:
2047
+ case "end":
2048
+ return _context30.stop();
2049
+ }
2050
+ }, _callee30, this);
2051
+ }));
2052
+ function CreateAccessGroup() {
2053
+ return _CreateAccessGroup.apply(this, arguments);
2054
+ }
2055
+ return CreateAccessGroup;
2056
+ }())
2057
+ }, {
2058
+ key: "CreateContentType",
2059
+ value: function () {
2060
+ var _CreateContentType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
2061
+ var _yield$this$client$et2, contractAddress, transactionHash;
2062
+ return _regeneratorRuntime.wrap(function _callee31$(_context31) {
2063
+ while (1) switch (_context31.prev = _context31.next) {
2064
+ case 0:
2065
+ _context31.next = 2;
2066
+ return this.client.ethClient.DeployTypeContract({
2067
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2068
+ signer: this.client.signer
2069
+ });
2070
+ case 2:
2071
+ _yield$this$client$et2 = _context31.sent;
2072
+ contractAddress = _yield$this$client$et2.contractAddress;
2073
+ transactionHash = _yield$this$client$et2.transactionHash;
2074
+ return _context31.abrupt("return", {
2075
+ contractAddress: contractAddress,
2076
+ transactionHash: transactionHash
2077
+ });
2078
+ case 6:
2079
+ case "end":
2080
+ return _context31.stop();
2081
+ }
2082
+ }, _callee31, this);
2083
+ }));
2084
+ function CreateContentType() {
2085
+ return _CreateContentType.apply(this, arguments);
2086
+ }
2087
+ return CreateContentType;
2088
+ }()
2089
+ }, {
2090
+ key: "CreateContentLibrary",
2091
+ value: function () {
2092
+ var _CreateContentLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref29) {
2093
+ var kmsId, _yield$this$client$et3, contractAddress, transactionHash;
2094
+ return _regeneratorRuntime.wrap(function _callee32$(_context32) {
2095
+ while (1) switch (_context32.prev = _context32.next) {
2096
+ case 0:
2097
+ kmsId = _ref29.kmsId;
2098
+ _context32.next = 3;
2099
+ return this.client.ethClient.DeployLibraryContract({
2100
+ contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
2101
+ kmsId: kmsId,
2102
+ signer: this.client.signer
2103
+ });
2104
+ case 3:
2105
+ _yield$this$client$et3 = _context32.sent;
2106
+ contractAddress = _yield$this$client$et3.contractAddress;
2107
+ transactionHash = _yield$this$client$et3.transactionHash;
2108
+ return _context32.abrupt("return", {
2109
+ contractAddress: contractAddress,
2110
+ transactionHash: transactionHash
2111
+ });
2112
+ case 7:
2113
+ case "end":
2114
+ return _context32.stop();
2115
+ }
2116
+ }, _callee32, this);
2117
+ }));
2118
+ function CreateContentLibrary(_x30) {
2119
+ return _CreateContentLibrary.apply(this, arguments);
2120
+ }
2121
+ return CreateContentLibrary;
2122
+ }()
2123
+ }, {
2124
+ key: "CreateContentObject",
2125
+ value: function () {
2126
+ var _CreateContentObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref30) {
2127
+ var libraryId, typeId, _yield$this$client$et4, contractAddress, transactionHash;
2128
+ return _regeneratorRuntime.wrap(function _callee33$(_context33) {
2129
+ while (1) switch (_context33.prev = _context33.next) {
2130
+ case 0:
2131
+ libraryId = _ref30.libraryId, typeId = _ref30.typeId;
2132
+ _context33.next = 3;
2133
+ return this.client.ethClient.DeployContentContract({
2134
+ contentLibraryAddress: Utils.HashToAddress(libraryId),
2135
+ typeAddress: typeId ? Utils.HashToAddress(typeId) : Utils.nullAddress,
2136
+ signer: this.client.signer
2137
+ });
2138
+ case 3:
2139
+ _yield$this$client$et4 = _context33.sent;
2140
+ contractAddress = _yield$this$client$et4.contractAddress;
2141
+ transactionHash = _yield$this$client$et4.transactionHash;
2142
+ return _context33.abrupt("return", {
2143
+ contractAddress: contractAddress,
2144
+ transactionHash: transactionHash
2145
+ });
2146
+ case 7:
2147
+ case "end":
2148
+ return _context33.stop();
2149
+ }
2150
+ }, _callee33, this);
2151
+ }));
2152
+ function CreateContentObject(_x31) {
2153
+ return _CreateContentObject.apply(this, arguments);
2154
+ }
2155
+ return CreateContentObject;
2156
+ }() // Clear cached access transaction IDs and state channel tokens
2157
+ }, {
2158
+ key: "ClearCache",
2159
+ value: function ClearCache() {
2160
+ this.accessTransactions = {};
2161
+ this.modifyTransactions = {};
2162
+ this.channelContentTokens = {};
2163
+ }
2164
+ }]);
2165
+ }();
2166
+ module.exports = AuthorizationClient;