@eluvio/elv-client-js 3.2.2 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +15 -11
- package/dist/ElvClient-node-min.js +17 -13
- package/dist/ElvFrameClient-min.js +12 -8
- package/dist/ElvPermissionsClient-min.js +13 -9
- package/dist/ElvWalletClient-min.js +58 -0
- package/dist/ElvWalletClient-node-min.js +78 -0
- package/dist/src/AuthorizationClient.js +2248 -1990
- package/dist/src/ContentObjectVerification.js +164 -173
- package/dist/src/Crypto.js +376 -324
- package/dist/src/ElvClient.js +1182 -1019
- package/dist/src/ElvWallet.js +119 -95
- package/dist/src/EthClient.js +1040 -896
- package/dist/src/FrameClient.js +331 -300
- package/dist/src/HttpClient.js +153 -147
- package/dist/src/Id.js +1 -3
- package/dist/src/PermissionsClient.js +1294 -1168
- package/dist/src/RemoteSigner.js +263 -211
- package/dist/src/UserProfileClient.js +1164 -1023
- package/dist/src/Utils.js +209 -181
- package/dist/src/client/ABRPublishing.js +895 -858
- package/dist/src/client/AccessGroups.js +1102 -959
- package/dist/src/client/ContentAccess.js +3724 -3431
- package/dist/src/client/ContentManagement.js +2252 -2068
- package/dist/src/client/Contracts.js +647 -563
- package/dist/src/client/Files.js +1886 -1757
- package/dist/src/client/NFT.js +126 -112
- package/dist/src/client/NTP.js +478 -422
- package/dist/src/walletClient/ClientMethods.js +1029 -879
- package/dist/src/walletClient/Utils.js +84 -70
- package/dist/src/walletClient/index.js +1203 -1087
- package/package.json +4 -2
- package/src/Utils.js +0 -1
- package/src/walletClient/ClientMethods.js +34 -2
- package/src/walletClient/index.js +3 -3
- package/utilities/ProductionMasterCreate.js +2 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
2
|
|
|
3
|
+
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
+
|
|
3
5
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
4
6
|
|
|
5
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
@@ -8,9 +10,9 @@ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
|
8
10
|
|
|
9
11
|
var _v, _v2;
|
|
10
12
|
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
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; }
|
|
12
14
|
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
14
16
|
|
|
15
17
|
var HttpClient = require("./HttpClient");
|
|
16
18
|
|
|
@@ -52,19 +54,9 @@ var CONTRACTS = {
|
|
|
52
54
|
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)
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
var AuthorizationClient =
|
|
56
|
-
/*#__PURE__*/
|
|
57
|
-
function () {
|
|
57
|
+
var AuthorizationClient = /*#__PURE__*/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
|
-
|
|
68
60
|
function AuthorizationClient(_ref) {
|
|
69
61
|
var client = _ref.client,
|
|
70
62
|
contentSpaceId = _ref.contentSpaceId,
|
|
@@ -98,6 +90,12 @@ function () {
|
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
_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
|
+
}, {
|
|
101
99
|
key: "CreateStaticToken",
|
|
102
100
|
value: function CreateStaticToken(_ref2) {
|
|
103
101
|
var libraryId = _ref2.libraryId;
|
|
@@ -114,681 +112,729 @@ function () {
|
|
|
114
112
|
|
|
115
113
|
}, {
|
|
116
114
|
key: "AuthorizationHeader",
|
|
117
|
-
value: function
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
}
|
|
141
141
|
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
142
|
+
}, _callee, this);
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
function AuthorizationHeader(_x) {
|
|
146
|
+
return _AuthorizationHeader.apply(this, arguments);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return AuthorizationHeader;
|
|
150
|
+
}()
|
|
145
151
|
}, {
|
|
146
152
|
key: "AuthorizationToken",
|
|
147
|
-
value: function
|
|
148
|
-
var
|
|
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
|
+
}
|
|
149
166
|
|
|
150
|
-
|
|
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;
|
|
167
|
+
_context2.t0 = objectId && this.client.signer;
|
|
155
168
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
169
|
+
if (!_context2.t0) {
|
|
170
|
+
_context2.next = 10;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
159
173
|
|
|
160
|
-
|
|
174
|
+
_context2.t1 = this.client.utils;
|
|
175
|
+
_context2.next = 7;
|
|
176
|
+
return this.client.userProfileClient.WalletAddress(false);
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
_context2.
|
|
164
|
-
|
|
165
|
-
|
|
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);
|
|
166
182
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return _regeneratorRuntime.awrap(this.client.userProfileClient.WalletAddress(false));
|
|
183
|
+
case 10:
|
|
184
|
+
isWalletRequest = _context2.t0;
|
|
170
185
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
if (!(this.client.staticToken && !isWalletRequest)) {
|
|
187
|
+
_context2.next = 13;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
175
190
|
|
|
176
|
-
|
|
177
|
-
isWalletRequest = _context2.t0;
|
|
191
|
+
return _context2.abrupt("return", this.client.staticToken);
|
|
178
192
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
193
|
+
case 13:
|
|
194
|
+
initialNoCache = this.noCache;
|
|
195
|
+
_context2.prev = 14;
|
|
183
196
|
|
|
184
|
-
|
|
197
|
+
// noCache enabled for this call
|
|
198
|
+
if (noCache && !this.noCache) {
|
|
199
|
+
this.noCache = true;
|
|
200
|
+
}
|
|
185
201
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
207
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
208
|
+
if (!channelAuth) {
|
|
209
|
+
_context2.next = 23;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
194
212
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
213
|
+
_context2.next = 20;
|
|
214
|
+
return this.GenerateChannelContentToken({
|
|
215
|
+
objectId: objectId,
|
|
216
|
+
versionHash: versionHash,
|
|
217
|
+
audienceData: audienceData,
|
|
218
|
+
context: context,
|
|
219
|
+
oauthToken: oauthToken
|
|
220
|
+
});
|
|
200
221
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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;
|
|
222
|
+
case 20:
|
|
223
|
+
authorizationToken = _context2.sent;
|
|
224
|
+
_context2.next = 28;
|
|
223
225
|
break;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
226
|
+
|
|
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;
|
|
251
|
+
|
|
252
|
+
case 28:
|
|
253
|
+
return _context2.abrupt("return", authorizationToken);
|
|
254
|
+
|
|
255
|
+
case 31:
|
|
256
|
+
_context2.prev = 31;
|
|
257
|
+
_context2.t4 = _context2["catch"](14);
|
|
258
|
+
throw _context2.t4;
|
|
259
|
+
|
|
260
|
+
case 34:
|
|
261
|
+
_context2.prev = 34;
|
|
262
|
+
this.noCache = initialNoCache;
|
|
263
|
+
return _context2.finish(34);
|
|
264
|
+
|
|
265
|
+
case 37:
|
|
266
|
+
case "end":
|
|
267
|
+
return _context2.stop();
|
|
268
|
+
}
|
|
261
269
|
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
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
|
+
}()
|
|
265
279
|
}, {
|
|
266
280
|
key: "GenerateAuthorizationToken",
|
|
267
|
-
value: function
|
|
268
|
-
var
|
|
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;
|
|
269
284
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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;
|
|
275
290
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
291
|
+
if (versionHash) {
|
|
292
|
+
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
293
|
+
} // Generate AFGH public key if encryption is specified
|
|
279
294
|
|
|
280
295
|
|
|
281
|
-
|
|
296
|
+
_context3.t0 = encryption && encryption !== "none" && objectId;
|
|
282
297
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
298
|
+
if (!_context3.t0) {
|
|
299
|
+
_context3.next = 9;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
287
302
|
|
|
288
|
-
|
|
289
|
-
|
|
303
|
+
_context3.next = 6;
|
|
304
|
+
return this.AccessType(objectId);
|
|
290
305
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
306
|
+
case 6:
|
|
307
|
+
_context3.t1 = _context3.sent;
|
|
308
|
+
_context3.t2 = ACCESS_TYPES.OBJECT;
|
|
309
|
+
_context3.t0 = _context3.t1 === _context3.t2;
|
|
295
310
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
+
});
|
|
321
|
+
|
|
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
|
+
});
|
|
371
|
+
|
|
372
|
+
case 26:
|
|
373
|
+
_yield$this$MakeAcces = _context3.sent;
|
|
374
|
+
transactionHash = _yield$this$MakeAcces.transactionHash;
|
|
375
|
+
|
|
376
|
+
if (transactionHash) {
|
|
377
|
+
token.tx_id = transactionHash;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
case 29:
|
|
381
|
+
if (libraryId) {
|
|
382
|
+
token.qlib_id = libraryId;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (partHash) {
|
|
386
|
+
token.qphash = partHash;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (publicKey) {
|
|
390
|
+
token.afgh_pk = publicKey;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
token = Utils.B64(JSON.stringify(token));
|
|
394
|
+
_context3.next = 35;
|
|
395
|
+
return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(token)));
|
|
396
|
+
|
|
397
|
+
case 35:
|
|
398
|
+
signature = _context3.sent;
|
|
399
|
+
multiSig = Utils.FormatSignature(signature);
|
|
400
|
+
return _context3.abrupt("return", "".concat(token, ".").concat(Utils.B64(multiSig)));
|
|
401
|
+
|
|
402
|
+
case 38:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context3.stop();
|
|
405
|
+
}
|
|
390
406
|
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
407
|
+
}, _callee3, this);
|
|
408
|
+
}));
|
|
409
|
+
|
|
410
|
+
function GenerateAuthorizationToken(_x3) {
|
|
411
|
+
return _GenerateAuthorizationToken.apply(this, arguments);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return GenerateAuthorizationToken;
|
|
415
|
+
}()
|
|
394
416
|
}, {
|
|
395
417
|
key: "MakeAccessRequest",
|
|
396
|
-
value: function
|
|
397
|
-
var
|
|
418
|
+
value: function () {
|
|
419
|
+
var _MakeAccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
|
|
420
|
+
var _this = this;
|
|
398
421
|
|
|
399
|
-
|
|
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;
|
|
400
423
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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;
|
|
406
429
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
430
|
+
if (this.client.signer) {
|
|
431
|
+
_context4.next = 3;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return _context4.abrupt("return", {
|
|
436
|
+
transactionHash: ""
|
|
437
|
+
});
|
|
411
438
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
439
|
+
case 3:
|
|
440
|
+
_context4.next = 5;
|
|
441
|
+
return this.client.userProfileClient.UserWalletAddress({
|
|
442
|
+
address: this.client.signer.address
|
|
443
|
+
});
|
|
415
444
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return _regeneratorRuntime.awrap(this.client.userProfileClient.UserWalletAddress({
|
|
419
|
-
address: this.client.signer.address
|
|
420
|
-
}));
|
|
445
|
+
case 5:
|
|
446
|
+
walletContractAddress = _context4.sent;
|
|
421
447
|
|
|
422
|
-
|
|
423
|
-
|
|
448
|
+
if (walletContractAddress) {
|
|
449
|
+
_context4.next = 12;
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
424
452
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
453
|
+
_context4.next = 9;
|
|
454
|
+
return this.client.userProfileClient.WalletAddress();
|
|
429
455
|
|
|
430
|
-
|
|
431
|
-
|
|
456
|
+
case 9:
|
|
457
|
+
walletCreated = _context4.sent;
|
|
432
458
|
|
|
433
|
-
|
|
434
|
-
|
|
459
|
+
if (walletCreated) {
|
|
460
|
+
_context4.next = 12;
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
435
463
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
464
|
+
throw Error("User wallet contract is required to make access requests");
|
|
465
|
+
|
|
466
|
+
case 12:
|
|
467
|
+
if (versionHash) {
|
|
468
|
+
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
469
|
+
}
|
|
440
470
|
|
|
441
|
-
|
|
471
|
+
id = objectId || libraryId || this.contentSpaceId;
|
|
472
|
+
_context4.next = 16;
|
|
473
|
+
return this.ContractInfo({
|
|
474
|
+
id: id
|
|
475
|
+
});
|
|
442
476
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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;
|
|
447
482
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}));
|
|
483
|
+
if (!(typeof accessType === "undefined")) {
|
|
484
|
+
_context4.next = 22;
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
453
487
|
|
|
454
|
-
|
|
455
|
-
_ref7 = _context4.sent;
|
|
456
|
-
isV3 = _ref7.isV3;
|
|
457
|
-
accessType = _ref7.accessType;
|
|
458
|
-
abi = _ref7.abi;
|
|
488
|
+
throw Error("Unable to determine contract info for ".concat(id, " (").concat(this.client.utils.HashToAddress(id), ") - Wrong network?"));
|
|
459
489
|
|
|
460
|
-
|
|
461
|
-
_context4.next =
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
}
|
|
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
|
+
});
|
|
489
499
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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;
|
|
494
506
|
|
|
495
|
-
|
|
496
|
-
|
|
507
|
+
case 29:
|
|
508
|
+
if (!this.transactionLocks[id]) {
|
|
509
|
+
_context4.next = 36;
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
497
512
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
513
|
+
_context4.next = 32;
|
|
514
|
+
return new Promise(function (resolve) {
|
|
515
|
+
return setTimeout(resolve, 100);
|
|
516
|
+
});
|
|
502
517
|
|
|
503
|
-
|
|
504
|
-
|
|
518
|
+
case 32:
|
|
519
|
+
elapsed += 100;
|
|
505
520
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
521
|
+
if (elapsed > 15000) {
|
|
522
|
+
this.Log("Lock never released for ".concat(id, " - releasing lock"));
|
|
523
|
+
delete this.transactionLocks[id];
|
|
524
|
+
}
|
|
509
525
|
|
|
510
|
-
|
|
511
|
-
_context4.next = 46;
|
|
526
|
+
_context4.next = 29;
|
|
512
527
|
break;
|
|
513
|
-
}
|
|
514
528
|
|
|
515
|
-
|
|
529
|
+
case 36:
|
|
530
|
+
_context4.prev = 36;
|
|
531
|
+
this.transactionLocks[id] = true; // Check cache for existing transaction
|
|
516
532
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
533
|
+
if (!(!noCache && !skipCache)) {
|
|
534
|
+
_context4.next = 46;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
521
537
|
|
|
522
|
-
|
|
523
|
-
_context4.next = 45;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
538
|
+
_cache = update ? this.modifyTransactions : this.accessTransactions;
|
|
526
539
|
|
|
527
|
-
|
|
540
|
+
if (!_cache[address]) {
|
|
541
|
+
_context4.next = 46;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
528
544
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
545
|
+
if (!(_cache[address].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
546
|
+
_context4.next = 45;
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
532
549
|
|
|
533
|
-
|
|
534
|
-
if (!cacheOnly) {
|
|
535
|
-
_context4.next = 48;
|
|
536
|
-
break;
|
|
537
|
-
}
|
|
550
|
+
return _context4.abrupt("return", _cache[address]);
|
|
538
551
|
|
|
539
|
-
|
|
552
|
+
case 45:
|
|
553
|
+
// Token expired
|
|
554
|
+
delete _cache[address];
|
|
540
555
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
556
|
+
case 46:
|
|
557
|
+
if (!cacheOnly) {
|
|
558
|
+
_context4.next = 48;
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return _context4.abrupt("return");
|
|
563
|
+
|
|
564
|
+
case 48:
|
|
565
|
+
if (!update) {
|
|
566
|
+
_context4.next = 55;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
|
|
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
|
+
});
|
|
576
|
+
|
|
577
|
+
case 52:
|
|
578
|
+
accessRequest = _context4.sent;
|
|
579
|
+
_context4.next = 59;
|
|
544
580
|
break;
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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
|
-
}
|
|
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
|
|
586
589
|
});
|
|
587
|
-
}
|
|
588
590
|
|
|
589
|
-
|
|
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);
|
|
590
613
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
614
|
+
case 65:
|
|
615
|
+
_context4.prev = 65;
|
|
616
|
+
_context4.t0 = _context4["catch"](60);
|
|
594
617
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
618
|
+
if (!noCache) {
|
|
619
|
+
delete cache[address];
|
|
620
|
+
}
|
|
598
621
|
|
|
599
|
-
|
|
622
|
+
throw _context4.t0;
|
|
600
623
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
624
|
+
case 69:
|
|
625
|
+
_context4.prev = 69;
|
|
626
|
+
delete this.transactionLocks[id];
|
|
627
|
+
return _context4.finish(69);
|
|
605
628
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
629
|
+
case 72:
|
|
630
|
+
case "end":
|
|
631
|
+
return _context4.stop();
|
|
632
|
+
}
|
|
609
633
|
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
|
|
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
|
+
}()
|
|
613
643
|
}, {
|
|
614
644
|
key: "AccessRequest",
|
|
615
|
-
value: function
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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
|
+
});
|
|
640
677
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
id: id,
|
|
644
|
-
abi: abi
|
|
645
|
-
}));
|
|
678
|
+
case 11:
|
|
679
|
+
owner = _context5.sent;
|
|
646
680
|
|
|
647
|
-
|
|
648
|
-
|
|
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
|
+
});
|
|
649
696
|
|
|
650
|
-
|
|
697
|
+
case 18:
|
|
698
|
+
_context5.t1 = _context5.sent;
|
|
699
|
+
accessCharge = _context5.t0.WeiToEther.call(_context5.t0, _context5.t1);
|
|
651
700
|
_context5.next = 26;
|
|
652
701
|
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
|
-
}
|
|
727
702
|
|
|
728
|
-
|
|
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
|
+
});
|
|
750
|
+
|
|
751
|
+
case 36:
|
|
752
|
+
event = _context5.sent;
|
|
729
753
|
|
|
730
|
-
|
|
731
|
-
|
|
754
|
+
if (!(event.logs.length === 0)) {
|
|
755
|
+
_context5.next = 39;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
throw Error("Access denied (".concat(id, ")"));
|
|
732
760
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
761
|
+
case 39:
|
|
762
|
+
return _context5.abrupt("return", event);
|
|
763
|
+
|
|
764
|
+
case 40:
|
|
765
|
+
case "end":
|
|
766
|
+
return _context5.stop();
|
|
767
|
+
}
|
|
736
768
|
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
769
|
+
}, _callee5, this, [[13, 22]]);
|
|
770
|
+
}));
|
|
771
|
+
|
|
772
|
+
function AccessRequest(_x5) {
|
|
773
|
+
return _AccessRequest.apply(this, arguments);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return AccessRequest;
|
|
777
|
+
}()
|
|
740
778
|
}, {
|
|
741
779
|
key: "UpdateRequest",
|
|
742
|
-
value: function
|
|
743
|
-
var
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
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
|
+
}
|
|
769
808
|
|
|
770
|
-
|
|
809
|
+
throw Error("Update request denied for ".concat(id));
|
|
771
810
|
|
|
772
|
-
|
|
773
|
-
|
|
811
|
+
case 7:
|
|
812
|
+
return _context6.abrupt("return", event);
|
|
774
813
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
814
|
+
case 8:
|
|
815
|
+
case "end":
|
|
816
|
+
return _context6.stop();
|
|
817
|
+
}
|
|
778
818
|
}
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
819
|
+
}, _callee6, this);
|
|
820
|
+
}));
|
|
821
|
+
|
|
822
|
+
function UpdateRequest(_x6) {
|
|
823
|
+
return _UpdateRequest.apply(this, arguments);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
return UpdateRequest;
|
|
827
|
+
}()
|
|
782
828
|
}, {
|
|
783
829
|
key: "AudienceData",
|
|
784
|
-
value: function AudienceData(
|
|
785
|
-
var objectId =
|
|
786
|
-
versionHash =
|
|
787
|
-
|
|
788
|
-
protocols =
|
|
789
|
-
|
|
790
|
-
drms =
|
|
791
|
-
context =
|
|
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;
|
|
792
838
|
this.Log("Retrieving audience data: ".concat(objectId));
|
|
793
839
|
context = context || this.client.authContext || {};
|
|
794
840
|
|
|
@@ -818,1585 +864,1797 @@ function () {
|
|
|
818
864
|
}
|
|
819
865
|
}, {
|
|
820
866
|
key: "GenerateChannelContentToken",
|
|
821
|
-
value: function
|
|
822
|
-
var
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
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
|
+
}
|
|
834
881
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
882
|
+
_context7.next = 4;
|
|
883
|
+
return this.GenerateOauthChannelToken({
|
|
884
|
+
objectId: objectId,
|
|
885
|
+
token: oauthToken
|
|
886
|
+
});
|
|
840
887
|
|
|
841
|
-
|
|
842
|
-
|
|
888
|
+
case 4:
|
|
889
|
+
return _context7.abrupt("return", _context7.sent);
|
|
843
890
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
891
|
+
case 5:
|
|
892
|
+
if (!(!this.noCache && this.channelContentTokens[objectId])) {
|
|
893
|
+
_context7.next = 11;
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
849
896
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
897
|
+
if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
898
|
+
_context7.next = 10;
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
854
901
|
|
|
855
|
-
|
|
902
|
+
return _context7.abrupt("return", this.channelContentTokens[objectId].token);
|
|
856
903
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
904
|
+
case 10:
|
|
905
|
+
// Token expired
|
|
906
|
+
delete this.channelContentTokens[objectId];
|
|
860
907
|
|
|
861
|
-
|
|
862
|
-
|
|
908
|
+
case 11:
|
|
909
|
+
this.Log("Making state channel access request: ".concat(objectId));
|
|
863
910
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
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({
|
|
948
|
-
objectId: objectId,
|
|
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
|
-
}
|
|
911
|
+
if (!issuer) {
|
|
912
|
+
_context7.next = 43;
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
982
915
|
|
|
983
|
-
|
|
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
|
+
});
|
|
984
924
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
return _context7.stop();
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}, null, this, [[14, 22], [27, 33]]);
|
|
991
|
-
}
|
|
992
|
-
}, {
|
|
993
|
-
key: "ChannelContentFinalize",
|
|
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({
|
|
1010
|
-
objectId: objectId,
|
|
1011
|
-
versionHash: versionHash
|
|
1012
|
-
}))]
|
|
1013
|
-
}));
|
|
925
|
+
case 17:
|
|
926
|
+
kmsAddress = _context7.sent;
|
|
1014
927
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
928
|
+
if (kmsAddress) {
|
|
929
|
+
_context7.next = 20;
|
|
930
|
+
break;
|
|
931
|
+
}
|
|
1019
932
|
|
|
1020
|
-
|
|
1021
|
-
case "end":
|
|
1022
|
-
return _context8.stop();
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}, null, this);
|
|
1026
|
-
}
|
|
1027
|
-
}, {
|
|
1028
|
-
key: "GenerateOauthChannelToken",
|
|
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
|
-
}
|
|
933
|
+
throw "";
|
|
1045
934
|
|
|
1046
|
-
|
|
1047
|
-
|
|
935
|
+
case 20:
|
|
936
|
+
_context7.next = 27;
|
|
1048
937
|
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
|
-
}
|
|
1085
938
|
|
|
1086
|
-
|
|
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
|
+
}));
|
|
1087
960
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
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;
|
|
961
|
+
case 30:
|
|
962
|
+
token = _context7.sent;
|
|
963
|
+
_context7.next = 40;
|
|
1107
964
|
break;
|
|
1108
|
-
}
|
|
1109
965
|
|
|
1110
|
-
|
|
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;
|
|
1111
984
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
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;
|
|
1115
990
|
|
|
1116
|
-
|
|
1117
|
-
|
|
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
|
+
}
|
|
1118
1000
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1001
|
+
stateChannelApi = "elv_channelContentRequestContext";
|
|
1002
|
+
additionalParams = [JSON.stringify(audienceData)];
|
|
1003
|
+
_context7.next = 48;
|
|
1004
|
+
return this.MakeKMSCall({
|
|
1005
|
+
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
|
|
1124
1010
|
});
|
|
1125
|
-
}
|
|
1126
1011
|
|
|
1127
|
-
|
|
1128
|
-
|
|
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
|
+
}
|
|
1129
1029
|
|
|
1130
|
-
|
|
1131
|
-
return _context10.abrupt("return", _context10.sent);
|
|
1030
|
+
return _context7.abrupt("return", token);
|
|
1132
1031
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1032
|
+
case 56:
|
|
1033
|
+
case "end":
|
|
1034
|
+
return _context7.stop();
|
|
1035
|
+
}
|
|
1136
1036
|
}
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
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;
|
|
1037
|
+
}, _callee7, this, [[14, 22], [27, 33]]);
|
|
1038
|
+
}));
|
|
1153
1039
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
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
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1040
|
+
function GenerateChannelContentToken(_x7) {
|
|
1041
|
+
return _GenerateChannelContentToken.apply(this, arguments);
|
|
1042
|
+
}
|
|
1169
1043
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1044
|
+
return GenerateChannelContentToken;
|
|
1045
|
+
}()
|
|
1046
|
+
}, {
|
|
1047
|
+
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({
|
|
1060
|
+
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
|
+
});
|
|
1175
1069
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1070
|
+
case 4:
|
|
1071
|
+
result = _context8.sent;
|
|
1072
|
+
this.channelContentTokens[objectId] = undefined;
|
|
1073
|
+
return _context8.abrupt("return", result);
|
|
1180
1074
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1075
|
+
case 7:
|
|
1076
|
+
case "end":
|
|
1077
|
+
return _context8.stop();
|
|
1078
|
+
}
|
|
1184
1079
|
}
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1080
|
+
}, _callee8, this);
|
|
1081
|
+
}));
|
|
1082
|
+
|
|
1083
|
+
function ChannelContentFinalize(_x8) {
|
|
1084
|
+
return _ChannelContentFinalize.apply(this, arguments);
|
|
1085
|
+
}
|
|
1188
1086
|
|
|
1087
|
+
return ChannelContentFinalize;
|
|
1088
|
+
}()
|
|
1189
1089
|
}, {
|
|
1190
|
-
key: "
|
|
1191
|
-
value: function
|
|
1192
|
-
var
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
if (this.accessTypes[id]) {
|
|
1204
|
-
_context12.next = 23;
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1090
|
+
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
|
+
}
|
|
1207
1103
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1104
|
+
if (!(!this.noCache && this.channelContentTokens[objectId])) {
|
|
1105
|
+
_context9.next = 6;
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1211
1108
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1109
|
+
if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
1110
|
+
_context9.next = 5;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1215
1113
|
|
|
1216
|
-
|
|
1217
|
-
accessType = ACCESS_TYPES.LIBRARY;
|
|
1218
|
-
return _context12.abrupt("break", 22);
|
|
1114
|
+
return _context9.abrupt("return", this.channelContentTokens[objectId].token);
|
|
1219
1115
|
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1116
|
+
case 5:
|
|
1117
|
+
// Token expired
|
|
1118
|
+
this.channelContentTokens[objectId] = undefined;
|
|
1223
1119
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
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
|
+
}
|
|
1131
|
+
});
|
|
1227
1132
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1133
|
+
case 8:
|
|
1134
|
+
_context9.next = 10;
|
|
1135
|
+
return _context9.sent.text();
|
|
1231
1136
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
return _context12.abrupt("break", 22);
|
|
1137
|
+
case 10:
|
|
1138
|
+
fabricToken = _context9.sent;
|
|
1235
1139
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1140
|
+
if (!this.noCache) {
|
|
1141
|
+
this.channelContentTokens[objectId] = {
|
|
1142
|
+
token: fabricToken,
|
|
1143
|
+
issuedAt: Date.now()
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1239
1146
|
|
|
1240
|
-
|
|
1241
|
-
accessType = ACCESS_TYPES.OTHER;
|
|
1147
|
+
return _context9.abrupt("return", fabricToken);
|
|
1242
1148
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1149
|
+
case 13:
|
|
1150
|
+
case "end":
|
|
1151
|
+
return _context9.stop();
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}, _callee9, this);
|
|
1155
|
+
}));
|
|
1245
1156
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1157
|
+
function GenerateOauthChannelToken(_x9) {
|
|
1158
|
+
return _GenerateOauthChannelToken.apply(this, arguments);
|
|
1159
|
+
}
|
|
1248
1160
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return _context12.stop();
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}, null, this);
|
|
1255
|
-
}
|
|
1161
|
+
return GenerateOauthChannelToken;
|
|
1162
|
+
}()
|
|
1256
1163
|
}, {
|
|
1257
|
-
key: "
|
|
1258
|
-
value: function
|
|
1259
|
-
var
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
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;
|
|
1281
|
-
break;
|
|
1282
|
-
}
|
|
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
|
+
}
|
|
1283
1178
|
|
|
1284
|
-
|
|
1179
|
+
return _context10.abrupt("return", true);
|
|
1285
1180
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
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();
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
}, null, this);
|
|
1328
|
-
}
|
|
1329
|
-
/* Utility methods */
|
|
1181
|
+
case 3:
|
|
1182
|
+
_context10.next = 5;
|
|
1183
|
+
return this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
|
|
1184
|
+
|
|
1185
|
+
case 5:
|
|
1186
|
+
contractName = _context10.sent;
|
|
1187
|
+
|
|
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
|
+
}
|
|
1195
|
+
|
|
1196
|
+
_context10.next = 9;
|
|
1197
|
+
return this.accessVersions[contractName];
|
|
1198
|
+
|
|
1199
|
+
case 9:
|
|
1200
|
+
return _context10.abrupt("return", _context10.sent);
|
|
1201
|
+
|
|
1202
|
+
case 10:
|
|
1203
|
+
case "end":
|
|
1204
|
+
return _context10.stop();
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}, _callee10, this);
|
|
1208
|
+
}));
|
|
1209
|
+
|
|
1210
|
+
function IsV3(_x10) {
|
|
1211
|
+
return _IsV.apply(this, arguments);
|
|
1212
|
+
}
|
|
1330
1213
|
|
|
1214
|
+
return IsV3;
|
|
1215
|
+
}()
|
|
1331
1216
|
}, {
|
|
1332
|
-
key: "
|
|
1333
|
-
value: function
|
|
1334
|
-
var
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
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);
|
|
1308
|
+
|
|
1309
|
+
case 13:
|
|
1310
|
+
accessType = ACCESS_TYPES.WALLET;
|
|
1311
|
+
return _context12.abrupt("break", 22);
|
|
1312
|
+
|
|
1313
|
+
case 15:
|
|
1314
|
+
accessType = ACCESS_TYPES.GROUP;
|
|
1315
|
+
return _context12.abrupt("break", 22);
|
|
1316
|
+
|
|
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
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}, _callee12, this);
|
|
1340
|
+
}));
|
|
1341
|
+
|
|
1342
|
+
function AccessType(_x12) {
|
|
1343
|
+
return _AccessType.apply(this, arguments);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
return AccessType;
|
|
1347
|
+
}()
|
|
1348
|
+
}, {
|
|
1349
|
+
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;
|
|
1342
1369
|
address = Utils.HashToAddress(id);
|
|
1343
|
-
|
|
1370
|
+
requestId = this.requestIds[address];
|
|
1344
1371
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1372
|
+
if (requestId) {
|
|
1373
|
+
_context13.next = 11;
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1348
1376
|
|
|
1349
|
-
|
|
1350
|
-
return _regeneratorRuntime.awrap(this.IsV3({
|
|
1351
|
-
id: id
|
|
1352
|
-
}));
|
|
1377
|
+
throw Error("Unknown request ID for " + id);
|
|
1353
1378
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1379
|
+
case 11:
|
|
1380
|
+
if (!isV3) {
|
|
1381
|
+
_context13.next = 17;
|
|
1382
|
+
break;
|
|
1383
|
+
}
|
|
1359
1384
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1385
|
+
_context13.next = 14;
|
|
1386
|
+
return this.client.CallContractMethodAndWait({
|
|
1387
|
+
contractAddress: address,
|
|
1388
|
+
abi: abi,
|
|
1389
|
+
methodName: "accessCompleteV3",
|
|
1390
|
+
methodArgs: [requestId, [], []]
|
|
1391
|
+
});
|
|
1362
1392
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1393
|
+
case 14:
|
|
1394
|
+
event = _context13.sent;
|
|
1395
|
+
_context13.next = 20;
|
|
1365
1396
|
break;
|
|
1366
|
-
}
|
|
1367
1397
|
|
|
1368
|
-
|
|
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;
|
|
1369
1409
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
abi: this.CONTRACTS[version][accessType].abi
|
|
1375
|
-
});
|
|
1410
|
+
case 20:
|
|
1411
|
+
delete this.requestIds[address];
|
|
1412
|
+
delete this.accessTransactions[address];
|
|
1413
|
+
return _context13.abrupt("return", event);
|
|
1376
1414
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1415
|
+
case 23:
|
|
1416
|
+
case "end":
|
|
1417
|
+
return _context13.stop();
|
|
1418
|
+
}
|
|
1380
1419
|
}
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1420
|
+
}, _callee13, this);
|
|
1421
|
+
}));
|
|
1422
|
+
|
|
1423
|
+
function AccessComplete(_x13) {
|
|
1424
|
+
return _AccessComplete.apply(this, arguments);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
return AccessComplete;
|
|
1428
|
+
}()
|
|
1429
|
+
/* Utility methods */
|
|
1430
|
+
|
|
1431
|
+
}, {
|
|
1432
|
+
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
|
+
}
|
|
1445
|
+
|
|
1446
|
+
if (!id) {
|
|
1447
|
+
id = Utils.AddressToObjectId(address);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
_context14.next = 5;
|
|
1451
|
+
return this.IsV3({
|
|
1452
|
+
id: id
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
case 5:
|
|
1456
|
+
isV3 = _context14.sent;
|
|
1457
|
+
version = isV3 ? "v3" : "v2";
|
|
1458
|
+
_context14.next = 9;
|
|
1459
|
+
return this.AccessType(id);
|
|
1460
|
+
|
|
1461
|
+
case 9:
|
|
1462
|
+
accessType = _context14.sent;
|
|
1463
|
+
|
|
1464
|
+
if (!(accessType === this.ACCESS_TYPES.OTHER)) {
|
|
1465
|
+
_context14.next = 12;
|
|
1466
|
+
break;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
return _context14.abrupt("return", {});
|
|
1470
|
+
|
|
1471
|
+
case 12:
|
|
1472
|
+
return _context14.abrupt("return", {
|
|
1473
|
+
isV3: isV3,
|
|
1474
|
+
accessType: accessType,
|
|
1475
|
+
abi: this.CONTRACTS[version][accessType].abi
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
case 13:
|
|
1479
|
+
case "end":
|
|
1480
|
+
return _context14.stop();
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
}, _callee14, this);
|
|
1484
|
+
}));
|
|
1485
|
+
|
|
1486
|
+
function ContractInfo(_x14) {
|
|
1487
|
+
return _ContractInfo.apply(this, arguments);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
return ContractInfo;
|
|
1491
|
+
}()
|
|
1384
1492
|
}, {
|
|
1385
1493
|
key: "GetAccessCharge",
|
|
1386
|
-
value: function
|
|
1387
|
-
var
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
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
|
+
}
|
|
1417
1527
|
}
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1528
|
+
}, _callee15, this);
|
|
1529
|
+
}));
|
|
1530
|
+
|
|
1531
|
+
function GetAccessCharge(_x15) {
|
|
1532
|
+
return _GetAccessCharge.apply(this, arguments);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
return GetAccessCharge;
|
|
1536
|
+
}()
|
|
1421
1537
|
}, {
|
|
1422
1538
|
key: "Owner",
|
|
1423
|
-
value: function
|
|
1424
|
-
var
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
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
|
+
}
|
|
1435
1552
|
|
|
1436
|
-
|
|
1553
|
+
return _context16.abrupt("return", false);
|
|
1437
1554
|
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
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
|
+
});
|
|
1566
|
+
|
|
1567
|
+
case 6:
|
|
1568
|
+
ownerAddress = _context16.sent;
|
|
1569
|
+
return _context16.abrupt("return", Utils.FormatAddress(ownerAddress));
|
|
1570
|
+
|
|
1571
|
+
case 8:
|
|
1572
|
+
case "end":
|
|
1573
|
+
return _context16.stop();
|
|
1574
|
+
}
|
|
1457
1575
|
}
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1576
|
+
}, _callee16, this);
|
|
1577
|
+
}));
|
|
1578
|
+
|
|
1579
|
+
function Owner(_x16) {
|
|
1580
|
+
return _Owner.apply(this, arguments);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
return Owner;
|
|
1584
|
+
}()
|
|
1461
1585
|
}, {
|
|
1462
1586
|
key: "Sign",
|
|
1463
|
-
value: function
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
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
|
+
}
|
|
1475
1599
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1600
|
+
_context17.next = 4;
|
|
1601
|
+
return this.client.signer.signDigest(message);
|
|
1478
1602
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1603
|
+
case 4:
|
|
1604
|
+
_context17.t1 = _context17.sent;
|
|
1605
|
+
_context17.next = 10;
|
|
1606
|
+
break;
|
|
1483
1607
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1608
|
+
case 7:
|
|
1609
|
+
_context17.next = 9;
|
|
1610
|
+
return this.client.signer.signingKey.signDigest(message);
|
|
1487
1611
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1612
|
+
case 9:
|
|
1613
|
+
_context17.t1 = _context17.sent;
|
|
1490
1614
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
return _context17.t0.awrap.call(_context17.t0, _context17.t4);
|
|
1615
|
+
case 10:
|
|
1616
|
+
_context17.t2 = _context17.t1;
|
|
1617
|
+
_context17.next = 13;
|
|
1618
|
+
return _context17.t0.joinSignature.call(_context17.t0, _context17.t2);
|
|
1496
1619
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1620
|
+
case 13:
|
|
1621
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1499
1622
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1623
|
+
case 14:
|
|
1624
|
+
case "end":
|
|
1625
|
+
return _context17.stop();
|
|
1626
|
+
}
|
|
1503
1627
|
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1628
|
+
}, _callee17, this);
|
|
1629
|
+
}));
|
|
1630
|
+
|
|
1631
|
+
function Sign(_x17) {
|
|
1632
|
+
return _Sign.apply(this, arguments);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
return Sign;
|
|
1636
|
+
}()
|
|
1507
1637
|
}, {
|
|
1508
1638
|
key: "KMSAddress",
|
|
1509
|
-
value: function
|
|
1510
|
-
var
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
|
1535
1652
|
|
|
1536
|
-
|
|
1653
|
+
_context18.next = 4;
|
|
1654
|
+
return this.ContractInfo({
|
|
1655
|
+
id: objectId
|
|
1656
|
+
});
|
|
1537
1657
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
abi
|
|
1543
|
-
|
|
1544
|
-
|
|
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
|
+
}
|
|
1666
|
+
|
|
1667
|
+
throw Error("Unable to determine contract info for ".concat(objectId, " - wrong network?"));
|
|
1668
|
+
|
|
1669
|
+
case 8:
|
|
1670
|
+
_context18.next = 10;
|
|
1671
|
+
return this.client.CallContractMethod({
|
|
1672
|
+
contractAddress: Utils.HashToAddress(objectId),
|
|
1673
|
+
abi: abi,
|
|
1674
|
+
methodName: "addressKMS"
|
|
1675
|
+
});
|
|
1545
1676
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1677
|
+
case 10:
|
|
1678
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1548
1679
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1680
|
+
case 11:
|
|
1681
|
+
case "end":
|
|
1682
|
+
return _context18.stop();
|
|
1683
|
+
}
|
|
1552
1684
|
}
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1685
|
+
}, _callee18, this);
|
|
1686
|
+
}));
|
|
1687
|
+
|
|
1688
|
+
function KMSAddress(_x18) {
|
|
1689
|
+
return _KMSAddress.apply(this, arguments);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
return KMSAddress;
|
|
1693
|
+
}()
|
|
1556
1694
|
}, {
|
|
1557
1695
|
key: "KMSInfo",
|
|
1558
|
-
value: function
|
|
1559
|
-
var
|
|
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
|
+
}
|
|
1560
1710
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
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
|
+
});
|
|
1566
1727
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1728
|
+
case 8:
|
|
1729
|
+
KMSInfo = _context19.sent;
|
|
1730
|
+
_context19.next = 19;
|
|
1569
1731
|
break;
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
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();
|
|
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
|
+
}
|
|
1630
1770
|
}
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
|
|
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
|
|
1634
1780
|
|
|
1635
1781
|
}, {
|
|
1636
1782
|
key: "RetrieveConk",
|
|
1637
|
-
value: function
|
|
1638
|
-
var
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
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
|
+
}
|
|
1700
1848
|
}
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
|
|
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
|
|
1704
1858
|
|
|
1705
1859
|
}, {
|
|
1706
1860
|
key: "RetrieveReencryptionSymmetricKey",
|
|
1707
|
-
value: function
|
|
1708
|
-
var
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
|
1751
1874
|
|
|
1752
|
-
|
|
1875
|
+
_context21.next = 4;
|
|
1876
|
+
return this.client.ContentObjectLibraryId({
|
|
1877
|
+
objectId: objectId
|
|
1878
|
+
});
|
|
1753
1879
|
|
|
1754
|
-
|
|
1755
|
-
|
|
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
|
-
}));
|
|
1880
|
+
case 4:
|
|
1881
|
+
libraryId = _context21.sent;
|
|
1762
1882
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1883
|
+
case 5:
|
|
1884
|
+
_context21.next = 7;
|
|
1885
|
+
return this.KMSAddress({
|
|
1886
|
+
objectId: objectId
|
|
1887
|
+
});
|
|
1765
1888
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
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
|
+
}
|
|
1906
|
+
|
|
1907
|
+
throw Error("No KMS key set for this object");
|
|
1908
|
+
|
|
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
|
+
});
|
|
1917
|
+
|
|
1918
|
+
case 16:
|
|
1919
|
+
return _context21.abrupt("return", _context21.sent);
|
|
1920
|
+
|
|
1921
|
+
case 17:
|
|
1922
|
+
case "end":
|
|
1923
|
+
return _context21.stop();
|
|
1924
|
+
}
|
|
1769
1925
|
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
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
|
|
1773
1935
|
|
|
1774
1936
|
}, {
|
|
1775
1937
|
key: "MakeKMSCall",
|
|
1776
|
-
value: function
|
|
1777
|
-
var
|
|
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
|
+
}
|
|
1778
1951
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
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;
|
|
1952
|
+
if (objectId) {
|
|
1953
|
+
_context22.next = 10;
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1784
1956
|
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1957
|
+
_context22.t0 = "ikms";
|
|
1958
|
+
_context22.t1 = Utils;
|
|
1959
|
+
_context22.next = 7;
|
|
1960
|
+
return this.client.DefaultKMSAddress({
|
|
1961
|
+
tenantId: tenantId
|
|
1962
|
+
});
|
|
1788
1963
|
|
|
1789
|
-
|
|
1790
|
-
_context22.
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
|
1974
|
+
|
|
1975
|
+
packedHash = Ethers.utils.solidityKeccak256(paramTypes, params);
|
|
1976
|
+
_context22.t4 = params;
|
|
1977
|
+
_context22.next = 15;
|
|
1978
|
+
return this.Sign(packedHash);
|
|
1840
1979
|
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
kmsUrl = KMSUrls[i];
|
|
1980
|
+
case 15:
|
|
1981
|
+
_context22.t5 = _context22.sent;
|
|
1844
1982
|
|
|
1845
|
-
|
|
1846
|
-
this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
|
|
1847
|
-
}
|
|
1983
|
+
_context22.t4.push.call(_context22.t4, _context22.t5);
|
|
1848
1984
|
|
|
1849
|
-
|
|
1850
|
-
|
|
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
|
+
});
|
|
1851
1993
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1994
|
+
case 20:
|
|
1995
|
+
KMSUrls = _context22.sent.urls;
|
|
1996
|
+
i = 0;
|
|
1854
1997
|
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1998
|
+
case 22:
|
|
1999
|
+
if (!(i < KMSUrls.length)) {
|
|
2000
|
+
_context22.next = 40;
|
|
2001
|
+
break;
|
|
2002
|
+
}
|
|
1859
2003
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}
|
|
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];
|
|
1864
2007
|
|
|
1865
|
-
|
|
2008
|
+
if (!this.providers[kmsUrl]) {
|
|
2009
|
+
this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
_context22.next = 29;
|
|
2013
|
+
return this.providers[kmsUrl].send(methodName, params);
|
|
2014
|
+
|
|
2015
|
+
case 29:
|
|
2016
|
+
return _context22.abrupt("return", _context22.sent);
|
|
2017
|
+
|
|
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
|
|
2022
|
+
|
|
2023
|
+
if (!(i === KMSUrls.length - 1)) {
|
|
2024
|
+
_context22.next = 37;
|
|
2025
|
+
break;
|
|
2026
|
+
}
|
|
1866
2027
|
|
|
1867
|
-
|
|
1868
|
-
i++;
|
|
1869
|
-
_context22.next = 22;
|
|
1870
|
-
break;
|
|
2028
|
+
throw _context22.t6;
|
|
1871
2029
|
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
2030
|
+
case 37:
|
|
2031
|
+
i++;
|
|
2032
|
+
_context22.next = 22;
|
|
2033
|
+
break;
|
|
2034
|
+
|
|
2035
|
+
case 40:
|
|
2036
|
+
case "end":
|
|
2037
|
+
return _context22.stop();
|
|
2038
|
+
}
|
|
1875
2039
|
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
|
|
2040
|
+
}, _callee22, this, [[23, 32]]);
|
|
2041
|
+
}));
|
|
2042
|
+
|
|
2043
|
+
function MakeKMSCall(_x22) {
|
|
2044
|
+
return _MakeKMSCall.apply(this, arguments);
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
return MakeKMSCall;
|
|
2048
|
+
}() // Make an arbitrary HTTP call to an authority server
|
|
1879
2049
|
|
|
1880
2050
|
}, {
|
|
1881
2051
|
key: "MakeAuthServiceRequest",
|
|
1882
|
-
value: function
|
|
1883
|
-
var
|
|
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
|
+
}
|
|
1884
2066
|
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
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
|
+
});
|
|
1890
2079
|
|
|
1891
|
-
|
|
1892
|
-
_context23.
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
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();
|
|
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
|
+
});
|
|
2093
|
+
|
|
2094
|
+
case 7:
|
|
2095
|
+
return _context23.abrupt("return", _context23.sent);
|
|
2096
|
+
|
|
2097
|
+
case 8:
|
|
2098
|
+
case "end":
|
|
2099
|
+
return _context23.stop();
|
|
2100
|
+
}
|
|
1929
2101
|
}
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
|
|
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
|
|
1933
2111
|
|
|
1934
2112
|
}, {
|
|
1935
2113
|
key: "MakeKMSRequest",
|
|
1936
|
-
value: function
|
|
1937
|
-
var
|
|
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
|
+
}
|
|
1938
2127
|
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
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;
|
|
2128
|
+
if (!(!objectId && !kmsId)) {
|
|
2129
|
+
_context24.next = 10;
|
|
2130
|
+
break;
|
|
2131
|
+
}
|
|
1944
2132
|
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2133
|
+
_context24.t0 = "ikms";
|
|
2134
|
+
_context24.t1 = Utils;
|
|
2135
|
+
_context24.next = 7;
|
|
2136
|
+
return this.client.DefaultKMSAddress();
|
|
1948
2137
|
|
|
1949
|
-
|
|
1950
|
-
_context24.
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
_context24.next =
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
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();
|
|
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
|
+
}
|
|
2158
|
+
|
|
2159
|
+
throw Error("No KMS info set for ".concat(versionHash || objectId || "default KMS"));
|
|
2160
|
+
|
|
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
|
+
}
|
|
2002
2182
|
}
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2183
|
+
}, _callee24, this);
|
|
2184
|
+
}));
|
|
2185
|
+
|
|
2186
|
+
function MakeKMSRequest(_x24) {
|
|
2187
|
+
return _MakeKMSRequest.apply(this, arguments);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
return MakeKMSRequest;
|
|
2191
|
+
}()
|
|
2006
2192
|
}, {
|
|
2007
2193
|
key: "ContractHasMethod",
|
|
2008
|
-
value: function
|
|
2009
|
-
var
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
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
|
+
}
|
|
2022
2209
|
|
|
2023
|
-
|
|
2210
|
+
this.Log("Checking method availability: ".concat(contractAddress, " ").concat(methodName));
|
|
2024
2211
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2212
|
+
if (abi) {
|
|
2213
|
+
_context25.next = 9;
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2029
2216
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2217
|
+
_context25.next = 8;
|
|
2218
|
+
return this.ContractInfo({
|
|
2219
|
+
address: contractAddress
|
|
2220
|
+
});
|
|
2034
2221
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2222
|
+
case 8:
|
|
2223
|
+
abi = _context25.sent.abi;
|
|
2037
2224
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2225
|
+
case 9:
|
|
2226
|
+
if (abi) {
|
|
2227
|
+
_context25.next = 11;
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2043
2230
|
|
|
2044
|
-
|
|
2231
|
+
throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
|
|
2045
2232
|
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2233
|
+
case 11:
|
|
2234
|
+
method = abi.find(function (method) {
|
|
2235
|
+
return method.name === methodName;
|
|
2236
|
+
});
|
|
2050
2237
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
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
|
+
});
|
|
2255
|
+
|
|
2256
|
+
case 18:
|
|
2257
|
+
this.methodAvailability[key] = _context25.sent;
|
|
2258
|
+
|
|
2259
|
+
case 19:
|
|
2260
|
+
return _context25.abrupt("return", this.methodAvailability[key]);
|
|
2261
|
+
|
|
2262
|
+
case 20:
|
|
2263
|
+
case "end":
|
|
2264
|
+
return _context25.stop();
|
|
2265
|
+
}
|
|
2078
2266
|
}
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2267
|
+
}, _callee25, this);
|
|
2268
|
+
}));
|
|
2269
|
+
|
|
2270
|
+
function ContractHasMethod(_x25) {
|
|
2271
|
+
return _ContractHasMethod.apply(this, arguments);
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
return ContractHasMethod;
|
|
2275
|
+
}()
|
|
2082
2276
|
}, {
|
|
2083
2277
|
key: "MakeElvMasterCall",
|
|
2084
|
-
value: function
|
|
2085
|
-
var
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
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
|
+
}
|
|
2103
2299
|
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
|
|
2300
|
+
}, _callee26, this);
|
|
2301
|
+
}));
|
|
2302
|
+
|
|
2303
|
+
function MakeElvMasterCall(_x26) {
|
|
2304
|
+
return _MakeElvMasterCall.apply(this, arguments);
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
return MakeElvMasterCall;
|
|
2308
|
+
}()
|
|
2107
2309
|
}, {
|
|
2108
2310
|
key: "ReEncryptionConk",
|
|
2109
|
-
value: function
|
|
2110
|
-
var
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
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
|
+
}
|
|
2125
2328
|
|
|
2126
|
-
|
|
2127
|
-
|
|
2329
|
+
_context27.next = 5;
|
|
2330
|
+
return this.client.Crypto.GenerateTargetConk();
|
|
2128
2331
|
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2332
|
+
case 5:
|
|
2333
|
+
cap = _context27.sent;
|
|
2334
|
+
_context27.next = 8;
|
|
2335
|
+
return this.RetrieveReencryptionSymmetricKey({
|
|
2336
|
+
libraryId: libraryId,
|
|
2337
|
+
objectId: objectId
|
|
2338
|
+
});
|
|
2136
2339
|
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2340
|
+
case 8:
|
|
2341
|
+
cap.symm_key = _context27.sent;
|
|
2342
|
+
this.reencryptionKeys[objectId] = cap;
|
|
2140
2343
|
|
|
2141
|
-
|
|
2142
|
-
|
|
2344
|
+
case 10:
|
|
2345
|
+
return _context27.abrupt("return", this.reencryptionKeys[objectId]);
|
|
2143
2346
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2347
|
+
case 11:
|
|
2348
|
+
case "end":
|
|
2349
|
+
return _context27.stop();
|
|
2350
|
+
}
|
|
2147
2351
|
}
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2352
|
+
}, _callee27, this);
|
|
2353
|
+
}));
|
|
2354
|
+
|
|
2355
|
+
function ReEncryptionConk(_x27) {
|
|
2356
|
+
return _ReEncryptionConk.apply(this, arguments);
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
return ReEncryptionConk;
|
|
2360
|
+
}()
|
|
2151
2361
|
}, {
|
|
2152
2362
|
key: "EncryptionConk",
|
|
2153
|
-
value: function
|
|
2154
|
-
var
|
|
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
|
+
}
|
|
2155
2376
|
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
libraryId = _ref37.libraryId, objectId = _ref37.objectId, versionHash = _ref37.versionHash;
|
|
2377
|
+
if (libraryId) {
|
|
2378
|
+
_context28.next = 6;
|
|
2379
|
+
break;
|
|
2380
|
+
}
|
|
2161
2381
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2382
|
+
_context28.next = 5;
|
|
2383
|
+
return this.client.ContentObjectLibraryId({
|
|
2384
|
+
objectId: objectId
|
|
2385
|
+
});
|
|
2165
2386
|
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
break;
|
|
2169
|
-
}
|
|
2387
|
+
case 5:
|
|
2388
|
+
libraryId = _context28.sent;
|
|
2170
2389
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2390
|
+
case 6:
|
|
2391
|
+
if (this.encryptionKeys[objectId]) {
|
|
2392
|
+
_context28.next = 16;
|
|
2393
|
+
break;
|
|
2394
|
+
}
|
|
2175
2395
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2396
|
+
_context28.next = 9;
|
|
2397
|
+
return this.RetrieveConk({
|
|
2398
|
+
libraryId: libraryId,
|
|
2399
|
+
objectId: objectId
|
|
2400
|
+
});
|
|
2178
2401
|
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
_context28.next =
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
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();
|
|
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 }
|
|
2413
|
+
|
|
2414
|
+
this.encryptionKeys[objectId] = conk;
|
|
2415
|
+
|
|
2416
|
+
case 16:
|
|
2417
|
+
return _context28.abrupt("return", this.encryptionKeys[objectId]);
|
|
2418
|
+
|
|
2419
|
+
case 17:
|
|
2420
|
+
case "end":
|
|
2421
|
+
return _context28.stop();
|
|
2422
|
+
}
|
|
2211
2423
|
}
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2424
|
+
}, _callee28, this);
|
|
2425
|
+
}));
|
|
2426
|
+
|
|
2427
|
+
function EncryptionConk(_x28) {
|
|
2428
|
+
return _EncryptionConk.apply(this, arguments);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
return EncryptionConk;
|
|
2432
|
+
}()
|
|
2215
2433
|
}, {
|
|
2216
2434
|
key: "RecordTags",
|
|
2217
|
-
value: function
|
|
2218
|
-
var
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
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
|
+
}
|
|
2225
2449
|
|
|
2226
|
-
|
|
2227
|
-
_context29.next = 3;
|
|
2228
|
-
break;
|
|
2229
|
-
}
|
|
2450
|
+
return _context29.abrupt("return");
|
|
2230
2451
|
|
|
2231
|
-
|
|
2452
|
+
case 3:
|
|
2453
|
+
_context29.next = 5;
|
|
2454
|
+
return this.ContractInfo({
|
|
2455
|
+
id: objectId
|
|
2456
|
+
});
|
|
2232
2457
|
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
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
|
+
});
|
|
2238
2466
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
abi = _ref40.abi;
|
|
2242
|
-
_context29.next = 9;
|
|
2243
|
-
return _regeneratorRuntime.awrap(this.Owner({
|
|
2244
|
-
id: objectId,
|
|
2245
|
-
abi: abi
|
|
2246
|
-
}));
|
|
2467
|
+
case 9:
|
|
2468
|
+
owner = _context29.sent;
|
|
2247
2469
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2470
|
+
if (Utils.EqualAddress(owner, this.client.signer.address)) {
|
|
2471
|
+
_context29.next = 13;
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2250
2474
|
|
|
2251
|
-
if (Utils.EqualAddress(owner, this.client.signer.address)) {
|
|
2252
2475
|
_context29.next = 13;
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
case 13:
|
|
2264
|
-
case "end":
|
|
2265
|
-
return _context29.stop();
|
|
2476
|
+
return this.client.userProfileClient.RecordTags({
|
|
2477
|
+
libraryId: libraryId,
|
|
2478
|
+
objectId: objectId,
|
|
2479
|
+
versionHash: versionHash
|
|
2480
|
+
});
|
|
2481
|
+
|
|
2482
|
+
case 13:
|
|
2483
|
+
case "end":
|
|
2484
|
+
return _context29.stop();
|
|
2485
|
+
}
|
|
2266
2486
|
}
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2487
|
+
}, _callee29, this);
|
|
2488
|
+
}));
|
|
2489
|
+
|
|
2490
|
+
function RecordTags(_x29) {
|
|
2491
|
+
return _RecordTags.apply(this, arguments);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
return RecordTags;
|
|
2495
|
+
}()
|
|
2270
2496
|
/* Creation methods */
|
|
2271
2497
|
|
|
2272
2498
|
}, {
|
|
2273
2499
|
key: "CreateAccessGroup",
|
|
2274
|
-
value: function
|
|
2275
|
-
var
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
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
|
+
}
|
|
2299
2527
|
}
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2528
|
+
}, _callee30, this);
|
|
2529
|
+
}));
|
|
2530
|
+
|
|
2531
|
+
function CreateAccessGroup() {
|
|
2532
|
+
return _CreateAccessGroup.apply(this, arguments);
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
return CreateAccessGroup;
|
|
2536
|
+
}()
|
|
2303
2537
|
}, {
|
|
2304
2538
|
key: "CreateContentType",
|
|
2305
|
-
value: function
|
|
2306
|
-
var
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
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
|
+
}
|
|
2330
2566
|
}
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2567
|
+
}, _callee31, this);
|
|
2568
|
+
}));
|
|
2569
|
+
|
|
2570
|
+
function CreateContentType() {
|
|
2571
|
+
return _CreateContentType.apply(this, arguments);
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
return CreateContentType;
|
|
2575
|
+
}()
|
|
2334
2576
|
}, {
|
|
2335
2577
|
key: "CreateContentLibrary",
|
|
2336
|
-
value: function
|
|
2337
|
-
var
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
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
|
+
}
|
|
2363
2607
|
}
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2608
|
+
}, _callee32, this);
|
|
2609
|
+
}));
|
|
2610
|
+
|
|
2611
|
+
function CreateContentLibrary(_x30) {
|
|
2612
|
+
return _CreateContentLibrary.apply(this, arguments);
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
return CreateContentLibrary;
|
|
2616
|
+
}()
|
|
2367
2617
|
}, {
|
|
2368
2618
|
key: "CreateContentObject",
|
|
2369
|
-
value: function
|
|
2370
|
-
var
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
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
|
+
}
|
|
2396
2648
|
}
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
|
|
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
|
|
2400
2658
|
|
|
2401
2659
|
}, {
|
|
2402
2660
|
key: "ClearCache",
|