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