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