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