@eluvio/elv-client-js 4.0.147 → 4.2.0
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 +2 -67
- package/dist/ElvClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvClient-node-min.js +2 -66
- package/dist/ElvClient-node-min.js.LICENSE.txt +72 -0
- package/dist/ElvFrameClient-min.js +2 -60
- package/dist/ElvFrameClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvPermissionsClient-min.js +2 -60
- package/dist/ElvPermissionsClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvWalletClient-min.js +2 -67
- package/dist/ElvWalletClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvWalletClient-node-min.js +2 -66
- package/dist/ElvWalletClient-node-min.js.LICENSE.txt +72 -0
- package/dist/src/AuthorizationClient.js +713 -715
- package/dist/src/ContentObjectAudit.js +59 -59
- package/dist/src/Crypto.js +85 -86
- package/dist/src/ElvClient.js +532 -501
- package/dist/src/ElvWallet.js +30 -28
- package/dist/src/EthClient.js +316 -316
- package/dist/src/FrameClient.js +70 -71
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +501 -489
- package/dist/src/RemoteSigner.js +83 -84
- package/dist/src/UserProfileClient.js +392 -374
- package/dist/src/Utils.js +67 -67
- package/dist/src/Validation.js +20 -12
- package/dist/src/client/ABRPublishing.js +412 -356
- package/dist/src/client/AccessGroups.js +479 -476
- package/dist/src/client/ContentAccess.js +1750 -1804
- package/dist/src/client/ContentManagement.js +874 -874
- package/dist/src/client/Contracts.js +586 -590
- package/dist/src/client/Files.js +702 -686
- package/dist/src/client/LiveConf.js +3 -5
- package/dist/src/client/LiveStream.js +659 -652
- package/dist/src/client/NFT.js +16 -16
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +51 -51
- package/dist/src/walletClient/ClientMethods.js +979 -953
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +68 -68
- package/dist/src/walletClient/Utils.js +17 -17
- package/dist/src/walletClient/index.js +574 -564
- package/package.json +17 -16
- package/src/client/AccessGroups.js +1 -1
- package/testScripts/Test.js +5 -1
- package/webpack.config.js +10 -13
- package/dist/src/ContentObjectVerification.js +0 -281
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
2
|
var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
|
|
3
3
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
function _createForOfIteratorHelper(
|
|
5
|
-
function _unsupportedIterableToArray(
|
|
6
|
-
function _arrayLikeToArray(
|
|
4
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
7
|
var UrlJoin = require("url-join");
|
|
8
8
|
var HttpClient = require("./HttpClient");
|
|
9
9
|
var UUID = require("uuid").v4;
|
|
@@ -11,9 +11,9 @@ var _require = require("./Validation"),
|
|
|
11
11
|
ValidateParameters = _require.ValidateParameters;
|
|
12
12
|
var ContentObjectAudit = {
|
|
13
13
|
AuditContentObject: function AuditContentObject(_ref) {
|
|
14
|
-
return _asyncToGenerator(
|
|
15
|
-
var client, libraryId, objectId, versionHash, salt, samples, _ref$live, live, authorizationToken, queryParams, uris, httpClient, path, responses, auditHash, verified, audits, _iterator, _step, response, url, audit, res;
|
|
16
|
-
return _regeneratorRuntime.wrap(function
|
|
14
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
15
|
+
var client, libraryId, objectId, versionHash, salt, samples, _ref$live, live, authorizationToken, queryParams, uris, httpClient, path, responses, auditHash, verified, audits, _iterator, _step, response, url, audit, res, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1;
|
|
16
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
19
19
|
client = _ref.client, libraryId = _ref.libraryId, objectId = _ref.objectId, versionHash = _ref.versionHash, salt = _ref.salt, samples = _ref.samples, _ref$live = _ref.live, live = _ref$live === void 0 ? false : _ref$live, authorizationToken = _ref.authorizationToken;
|
|
@@ -30,16 +30,16 @@ var ContentObjectAudit = {
|
|
|
30
30
|
objectId = client.utils.DecodeVersionHash(versionHash).objectId;
|
|
31
31
|
}
|
|
32
32
|
if (libraryId) {
|
|
33
|
-
_context.next =
|
|
33
|
+
_context.next = 2;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
|
-
_context.next =
|
|
36
|
+
_context.next = 1;
|
|
37
37
|
return client.ContentObjectLibraryId({
|
|
38
38
|
objectId: objectId
|
|
39
39
|
});
|
|
40
|
-
case
|
|
40
|
+
case 1:
|
|
41
41
|
libraryId = _context.sent;
|
|
42
|
-
case
|
|
42
|
+
case 2:
|
|
43
43
|
ValidateParameters({
|
|
44
44
|
libraryId: libraryId,
|
|
45
45
|
objectId: objectId,
|
|
@@ -54,64 +54,64 @@ var ContentObjectAudit = {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Test against the node the client is currently using, plus a batch of fresh nodes
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_context.next =
|
|
57
|
+
_t = [client.HttpClient.uris[client.HttpClient.uriIndex]];
|
|
58
|
+
_t2 = _toConsumableArray;
|
|
59
|
+
_context.next = 3;
|
|
60
60
|
return client.Configuration({
|
|
61
61
|
configUrl: client.configUrl,
|
|
62
62
|
clientIP: client.clientIP,
|
|
63
63
|
region: client.region
|
|
64
64
|
});
|
|
65
|
-
case
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
uris =
|
|
65
|
+
case 3:
|
|
66
|
+
_t3 = _context.sent.fabricURIs;
|
|
67
|
+
_t4 = _t2(_t3);
|
|
68
|
+
uris = _t.concat.call(_t, _t4).filter(function (v, i, s) {
|
|
69
69
|
return s.indexOf(v) === i;
|
|
70
70
|
});
|
|
71
71
|
httpClient = new HttpClient({
|
|
72
72
|
uris: uris
|
|
73
73
|
});
|
|
74
74
|
path = UrlJoin("qlibs", libraryId, "q", versionHash || objectId, live ? "call/live/audit" : "audit");
|
|
75
|
-
|
|
75
|
+
_t5 = httpClient;
|
|
76
76
|
if (!authorizationToken) {
|
|
77
|
-
_context.next =
|
|
77
|
+
_context.next = 4;
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
_t6 = {
|
|
81
81
|
Authorization: "Bearer ".concat(authorizationToken)
|
|
82
82
|
};
|
|
83
|
-
_context.next =
|
|
83
|
+
_context.next = 6;
|
|
84
84
|
break;
|
|
85
|
-
case
|
|
86
|
-
_context.next =
|
|
85
|
+
case 4:
|
|
86
|
+
_context.next = 5;
|
|
87
87
|
return client.authClient.AuthorizationHeader({
|
|
88
88
|
libraryId: libraryId,
|
|
89
89
|
objectId: objectId,
|
|
90
90
|
versionHash: versionHash
|
|
91
91
|
});
|
|
92
|
-
case
|
|
93
|
-
|
|
94
|
-
case
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
headers:
|
|
100
|
-
queryParams:
|
|
92
|
+
case 5:
|
|
93
|
+
_t6 = _context.sent;
|
|
94
|
+
case 6:
|
|
95
|
+
_t7 = _t6;
|
|
96
|
+
_t8 = queryParams;
|
|
97
|
+
_t9 = path;
|
|
98
|
+
_t0 = {
|
|
99
|
+
headers: _t7,
|
|
100
|
+
queryParams: _t8,
|
|
101
101
|
method: "GET",
|
|
102
|
-
path:
|
|
102
|
+
path: _t9
|
|
103
103
|
};
|
|
104
|
-
_context.next =
|
|
105
|
-
return
|
|
106
|
-
case
|
|
104
|
+
_context.next = 7;
|
|
105
|
+
return _t5.RequestAll.call(_t5, _t0);
|
|
106
|
+
case 7:
|
|
107
107
|
responses = _context.sent;
|
|
108
108
|
audits = [];
|
|
109
109
|
_iterator = _createForOfIteratorHelper(responses);
|
|
110
|
-
_context.prev =
|
|
110
|
+
_context.prev = 8;
|
|
111
111
|
_iterator.s();
|
|
112
|
-
case
|
|
112
|
+
case 9:
|
|
113
113
|
if ((_step = _iterator.n()).done) {
|
|
114
|
-
_context.next =
|
|
114
|
+
_context.next = 14;
|
|
115
115
|
break;
|
|
116
116
|
}
|
|
117
117
|
response = _step.value;
|
|
@@ -120,17 +120,17 @@ var ContentObjectAudit = {
|
|
|
120
120
|
host: url.hostname
|
|
121
121
|
};
|
|
122
122
|
if (response.ok) {
|
|
123
|
-
_context.next =
|
|
123
|
+
_context.next = 10;
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
audit.error = response;
|
|
127
127
|
audit.errorMessage = response.message || JSON.stringify(response);
|
|
128
|
-
_context.next =
|
|
128
|
+
_context.next = 12;
|
|
129
129
|
break;
|
|
130
|
-
case
|
|
131
|
-
_context.next =
|
|
130
|
+
case 10:
|
|
131
|
+
_context.next = 11;
|
|
132
132
|
return client.utils.ResponseToJson(response);
|
|
133
|
-
case
|
|
133
|
+
case 11:
|
|
134
134
|
res = _context.sent;
|
|
135
135
|
if (auditHash === undefined) {
|
|
136
136
|
auditHash = res.audit_hash;
|
|
@@ -140,23 +140,23 @@ var ContentObjectAudit = {
|
|
|
140
140
|
verified = true;
|
|
141
141
|
}
|
|
142
142
|
audit.audit_hash = res.audit_hash;
|
|
143
|
-
case
|
|
143
|
+
case 12:
|
|
144
144
|
audits.push(audit);
|
|
145
|
-
case
|
|
146
|
-
_context.next =
|
|
145
|
+
case 13:
|
|
146
|
+
_context.next = 9;
|
|
147
147
|
break;
|
|
148
|
-
case
|
|
149
|
-
_context.next =
|
|
148
|
+
case 14:
|
|
149
|
+
_context.next = 16;
|
|
150
150
|
break;
|
|
151
|
-
case
|
|
152
|
-
_context.prev =
|
|
153
|
-
|
|
154
|
-
_iterator.e(
|
|
155
|
-
case
|
|
156
|
-
_context.prev =
|
|
151
|
+
case 15:
|
|
152
|
+
_context.prev = 15;
|
|
153
|
+
_t1 = _context["catch"](8);
|
|
154
|
+
_iterator.e(_t1);
|
|
155
|
+
case 16:
|
|
156
|
+
_context.prev = 16;
|
|
157
157
|
_iterator.f();
|
|
158
|
-
return _context.finish(
|
|
159
|
-
case
|
|
158
|
+
return _context.finish(16);
|
|
159
|
+
case 17:
|
|
160
160
|
verified = verified || false;
|
|
161
161
|
return _context.abrupt("return", {
|
|
162
162
|
verified: verified,
|
|
@@ -164,11 +164,11 @@ var ContentObjectAudit = {
|
|
|
164
164
|
samples: samples,
|
|
165
165
|
audits: audits
|
|
166
166
|
});
|
|
167
|
-
case
|
|
167
|
+
case 18:
|
|
168
168
|
case "end":
|
|
169
169
|
return _context.stop();
|
|
170
170
|
}
|
|
171
|
-
}, _callee, null, [[
|
|
171
|
+
}, _callee, null, [[8, 15, 16, 17]]);
|
|
172
172
|
}))();
|
|
173
173
|
}
|
|
174
174
|
};
|
package/dist/src/Crypto.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
2
2
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
3
3
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
function
|
|
5
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
4
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
|
|
6
5
|
if (typeof globalThis.Buffer === "undefined") {
|
|
7
6
|
globalThis.Buffer = require("buffer/").Buffer;
|
|
8
7
|
}
|
|
@@ -27,40 +26,40 @@ if (typeof crypto === "undefined") {
|
|
|
27
26
|
*/
|
|
28
27
|
var Crypto = {
|
|
29
28
|
ElvCrypto: function () {
|
|
30
|
-
var _ElvCrypto = _asyncToGenerator(
|
|
31
|
-
var _ElvCrypto2;
|
|
32
|
-
return _regeneratorRuntime.wrap(function
|
|
29
|
+
var _ElvCrypto = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
30
|
+
var _ElvCrypto2, _t;
|
|
31
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
33
32
|
while (1) switch (_context.prev = _context.next) {
|
|
34
33
|
case 0:
|
|
35
34
|
_context.prev = 0;
|
|
36
35
|
if (Crypto.elvCrypto) {
|
|
37
|
-
_context.next =
|
|
36
|
+
_context.next = 3;
|
|
38
37
|
break;
|
|
39
38
|
}
|
|
40
|
-
_context.next =
|
|
39
|
+
_context.next = 1;
|
|
41
40
|
return Promise.resolve().then(function () {
|
|
42
41
|
return _interopRequireWildcard(require("@eluvio/crypto"));
|
|
43
42
|
});
|
|
44
|
-
case
|
|
43
|
+
case 1:
|
|
45
44
|
_ElvCrypto2 = _context.sent["default"];
|
|
46
|
-
_context.next =
|
|
45
|
+
_context.next = 2;
|
|
47
46
|
return new _ElvCrypto2().init();
|
|
48
|
-
case
|
|
47
|
+
case 2:
|
|
49
48
|
Crypto.elvCrypto = _context.sent;
|
|
50
|
-
case
|
|
49
|
+
case 3:
|
|
51
50
|
return _context.abrupt("return", Crypto.elvCrypto);
|
|
52
|
-
case
|
|
53
|
-
_context.prev =
|
|
54
|
-
|
|
51
|
+
case 4:
|
|
52
|
+
_context.prev = 4;
|
|
53
|
+
_t = _context["catch"](0);
|
|
55
54
|
// eslint-disable-next-line no-console
|
|
56
55
|
console.error("Error initializing ElvCrypto:");
|
|
57
56
|
// eslint-disable-next-line no-console
|
|
58
|
-
console.error(
|
|
59
|
-
case
|
|
57
|
+
console.error(_t);
|
|
58
|
+
case 5:
|
|
60
59
|
case "end":
|
|
61
60
|
return _context.stop();
|
|
62
61
|
}
|
|
63
|
-
}, _callee, null, [[0,
|
|
62
|
+
}, _callee, null, [[0, 4]]);
|
|
64
63
|
}));
|
|
65
64
|
function ElvCrypto() {
|
|
66
65
|
return _ElvCrypto.apply(this, arguments);
|
|
@@ -91,27 +90,27 @@ var Crypto = {
|
|
|
91
90
|
return reencrypt ? encryptedBlockSize + targetEncBlockOverhead : encryptedBlockSize + primaryEncBlockOverhead;
|
|
92
91
|
},
|
|
93
92
|
EncryptConk: function EncryptConk(conk, publicKey) {
|
|
94
|
-
return _asyncToGenerator(
|
|
93
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
95
94
|
var elvCrypto, _yield$elvCrypto$encr, data, ephemeralKey, tag, cap;
|
|
96
|
-
return _regeneratorRuntime.wrap(function
|
|
95
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
97
96
|
while (1) switch (_context2.prev = _context2.next) {
|
|
98
97
|
case 0:
|
|
99
|
-
_context2.next =
|
|
98
|
+
_context2.next = 1;
|
|
100
99
|
return Crypto.ElvCrypto();
|
|
101
|
-
case
|
|
100
|
+
case 1:
|
|
102
101
|
elvCrypto = _context2.sent;
|
|
103
102
|
publicKey = new Uint8Array(Buffer.from(publicKey.replace("0x", ""), "hex"));
|
|
104
103
|
conk = new Uint8Array(Buffer.from(JSON.stringify(conk)));
|
|
105
|
-
_context2.next =
|
|
104
|
+
_context2.next = 2;
|
|
106
105
|
return elvCrypto.encryptECIES(conk, publicKey);
|
|
107
|
-
case
|
|
106
|
+
case 2:
|
|
108
107
|
_yield$elvCrypto$encr = _context2.sent;
|
|
109
108
|
data = _yield$elvCrypto$encr.data;
|
|
110
109
|
ephemeralKey = _yield$elvCrypto$encr.ephemeralKey;
|
|
111
110
|
tag = _yield$elvCrypto$encr.tag;
|
|
112
111
|
cap = Buffer.concat([Buffer.from(ephemeralKey), Buffer.from(tag), Buffer.from(data)]);
|
|
113
112
|
return _context2.abrupt("return", Utils.B64(cap));
|
|
114
|
-
case
|
|
113
|
+
case 3:
|
|
115
114
|
case "end":
|
|
116
115
|
return _context2.stop();
|
|
117
116
|
}
|
|
@@ -119,14 +118,14 @@ var Crypto = {
|
|
|
119
118
|
}))();
|
|
120
119
|
},
|
|
121
120
|
DecryptCap: function DecryptCap(encryptedCap, privateKey) {
|
|
122
|
-
return _asyncToGenerator(
|
|
121
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
123
122
|
var elvCrypto, ephemeralKey, tag, data, cap;
|
|
124
|
-
return _regeneratorRuntime.wrap(function
|
|
123
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
125
124
|
while (1) switch (_context3.prev = _context3.next) {
|
|
126
125
|
case 0:
|
|
127
|
-
_context3.next =
|
|
126
|
+
_context3.next = 1;
|
|
128
127
|
return Crypto.ElvCrypto();
|
|
129
|
-
case
|
|
128
|
+
case 1:
|
|
130
129
|
elvCrypto = _context3.sent;
|
|
131
130
|
privateKey = new Uint8Array(Buffer.from(privateKey.replace("0x", ""), "hex"));
|
|
132
131
|
encryptedCap = Buffer.from(encryptedCap, "base64");
|
|
@@ -135,7 +134,7 @@ var Crypto = {
|
|
|
135
134
|
data = encryptedCap.slice(81);
|
|
136
135
|
cap = elvCrypto.decryptECIES(new Uint8Array(data), privateKey, new Uint8Array(ephemeralKey), new Uint8Array(tag));
|
|
137
136
|
return _context3.abrupt("return", JSON.parse(Buffer.from(cap).toString()));
|
|
138
|
-
case
|
|
137
|
+
case 2:
|
|
139
138
|
case "end":
|
|
140
139
|
return _context3.stop();
|
|
141
140
|
}
|
|
@@ -143,15 +142,15 @@ var Crypto = {
|
|
|
143
142
|
}))();
|
|
144
143
|
},
|
|
145
144
|
GeneratePrimaryConk: function GeneratePrimaryConk(_ref) {
|
|
146
|
-
return _asyncToGenerator(
|
|
145
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
147
146
|
var spaceId, objectId, elvCrypto, _elvCrypto$generatePr, secretKey, publicKey, symmetricKey;
|
|
148
|
-
return _regeneratorRuntime.wrap(function
|
|
147
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
149
148
|
while (1) switch (_context4.prev = _context4.next) {
|
|
150
149
|
case 0:
|
|
151
150
|
spaceId = _ref.spaceId, objectId = _ref.objectId;
|
|
152
|
-
_context4.next =
|
|
151
|
+
_context4.next = 1;
|
|
153
152
|
return Crypto.ElvCrypto();
|
|
154
|
-
case
|
|
153
|
+
case 1:
|
|
155
154
|
elvCrypto = _context4.sent;
|
|
156
155
|
_elvCrypto$generatePr = elvCrypto.generatePrimaryKeys(), secretKey = _elvCrypto$generatePr.secretKey, publicKey = _elvCrypto$generatePr.publicKey;
|
|
157
156
|
symmetricKey = elvCrypto.generateSymmetricKey().key;
|
|
@@ -162,7 +161,7 @@ var Crypto = {
|
|
|
162
161
|
sid: spaceId,
|
|
163
162
|
qid: objectId
|
|
164
163
|
});
|
|
165
|
-
case
|
|
164
|
+
case 2:
|
|
166
165
|
case "end":
|
|
167
166
|
return _context4.stop();
|
|
168
167
|
}
|
|
@@ -170,21 +169,21 @@ var Crypto = {
|
|
|
170
169
|
}))();
|
|
171
170
|
},
|
|
172
171
|
GenerateTargetConk: function GenerateTargetConk() {
|
|
173
|
-
return _asyncToGenerator(
|
|
172
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
174
173
|
var elvCrypto, _elvCrypto$generateTa, secretKey, publicKey;
|
|
175
|
-
return _regeneratorRuntime.wrap(function
|
|
174
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
176
175
|
while (1) switch (_context5.prev = _context5.next) {
|
|
177
176
|
case 0:
|
|
178
|
-
_context5.next =
|
|
177
|
+
_context5.next = 1;
|
|
179
178
|
return Crypto.ElvCrypto();
|
|
180
|
-
case
|
|
179
|
+
case 1:
|
|
181
180
|
elvCrypto = _context5.sent;
|
|
182
181
|
_elvCrypto$generateTa = elvCrypto.generateTargetKeys(), secretKey = _elvCrypto$generateTa.secretKey, publicKey = _elvCrypto$generateTa.publicKey;
|
|
183
182
|
return _context5.abrupt("return", {
|
|
184
183
|
secret_key: "kpsk".concat(bs58.encode(Buffer.from(secretKey))),
|
|
185
184
|
public_key: "ktpk".concat(bs58.encode(Buffer.from(publicKey)))
|
|
186
185
|
});
|
|
187
|
-
case
|
|
186
|
+
case 2:
|
|
188
187
|
case "end":
|
|
189
188
|
return _context5.stop();
|
|
190
189
|
}
|
|
@@ -202,14 +201,14 @@ var Crypto = {
|
|
|
202
201
|
};
|
|
203
202
|
},
|
|
204
203
|
EncryptionContext: function EncryptionContext(cap) {
|
|
205
|
-
return _asyncToGenerator(
|
|
204
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
206
205
|
var elvCrypto, _Crypto$CapToConk, symmetricKey, secretKey, publicKey, context, type;
|
|
207
|
-
return _regeneratorRuntime.wrap(function
|
|
206
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
208
207
|
while (1) switch (_context6.prev = _context6.next) {
|
|
209
208
|
case 0:
|
|
210
|
-
_context6.next =
|
|
209
|
+
_context6.next = 1;
|
|
211
210
|
return Crypto.ElvCrypto();
|
|
212
|
-
case
|
|
211
|
+
case 1:
|
|
213
212
|
elvCrypto = _context6.sent;
|
|
214
213
|
_Crypto$CapToConk = Crypto.CapToConk(cap), symmetricKey = _Crypto$CapToConk.symmetricKey, secretKey = _Crypto$CapToConk.secretKey, publicKey = _Crypto$CapToConk.publicKey;
|
|
215
214
|
if (publicKey.length === elvCrypto.PRIMARY_PK_KEY_SIZE) {
|
|
@@ -225,7 +224,7 @@ var Crypto = {
|
|
|
225
224
|
context: context,
|
|
226
225
|
type: type
|
|
227
226
|
});
|
|
228
|
-
case
|
|
227
|
+
case 2:
|
|
229
228
|
case "end":
|
|
230
229
|
return _context6.stop();
|
|
231
230
|
}
|
|
@@ -242,26 +241,26 @@ var Crypto = {
|
|
|
242
241
|
* @returns {Promise<Buffer>} - Decrypted data
|
|
243
242
|
*/
|
|
244
243
|
Encrypt: function () {
|
|
245
|
-
var _Encrypt = _asyncToGenerator(
|
|
246
|
-
var stream, dataArray, i, end, encryptedChunks;
|
|
247
|
-
return _regeneratorRuntime.wrap(function
|
|
244
|
+
var _Encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(cap, data) {
|
|
245
|
+
var stream, dataArray, i, end, encryptedChunks, _t2, _t3;
|
|
246
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
248
247
|
while (1) switch (_context7.prev = _context7.next) {
|
|
249
248
|
case 0:
|
|
250
|
-
_context7.next =
|
|
249
|
+
_context7.next = 1;
|
|
251
250
|
return Crypto.OpenEncryptionStream(cap);
|
|
252
|
-
case
|
|
251
|
+
case 1:
|
|
253
252
|
stream = _context7.sent;
|
|
254
253
|
if (!(!Buffer.isBuffer(data) && !(data instanceof ArrayBuffer))) {
|
|
255
|
-
_context7.next =
|
|
254
|
+
_context7.next = 3;
|
|
256
255
|
break;
|
|
257
256
|
}
|
|
258
|
-
|
|
259
|
-
_context7.next =
|
|
257
|
+
_t2 = Buffer;
|
|
258
|
+
_context7.next = 2;
|
|
260
259
|
return new Response(data).arrayBuffer();
|
|
261
|
-
case
|
|
262
|
-
|
|
263
|
-
data =
|
|
264
|
-
case
|
|
260
|
+
case 2:
|
|
261
|
+
_t3 = _context7.sent;
|
|
262
|
+
data = _t2.from.call(_t2, _t3);
|
|
263
|
+
case 3:
|
|
265
264
|
dataArray = new Uint8Array(data);
|
|
266
265
|
for (i = 0; i < dataArray.length; i += 1000000) {
|
|
267
266
|
end = Math.min(dataArray.length, i + 1000000);
|
|
@@ -269,7 +268,7 @@ var Crypto = {
|
|
|
269
268
|
}
|
|
270
269
|
stream.end();
|
|
271
270
|
encryptedChunks = [];
|
|
272
|
-
_context7.next =
|
|
271
|
+
_context7.next = 4;
|
|
273
272
|
return new Promise(function (resolve, reject) {
|
|
274
273
|
stream.on("data", function (chunk) {
|
|
275
274
|
encryptedChunks.push(chunk);
|
|
@@ -279,9 +278,9 @@ var Crypto = {
|
|
|
279
278
|
reject(e);
|
|
280
279
|
});
|
|
281
280
|
});
|
|
282
|
-
case
|
|
281
|
+
case 4:
|
|
283
282
|
return _context7.abrupt("return", Buffer.concat(encryptedChunks));
|
|
284
|
-
case
|
|
283
|
+
case 5:
|
|
285
284
|
case "end":
|
|
286
285
|
return _context7.stop();
|
|
287
286
|
}
|
|
@@ -293,18 +292,18 @@ var Crypto = {
|
|
|
293
292
|
return Encrypt;
|
|
294
293
|
}(),
|
|
295
294
|
OpenEncryptionStream: function () {
|
|
296
|
-
var _OpenEncryptionStream = _asyncToGenerator(
|
|
295
|
+
var _OpenEncryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(cap) {
|
|
297
296
|
var elvCrypto, _yield$Crypto$Encrypt, context, stream, cipher;
|
|
298
|
-
return _regeneratorRuntime.wrap(function
|
|
297
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
299
298
|
while (1) switch (_context8.prev = _context8.next) {
|
|
300
299
|
case 0:
|
|
301
|
-
_context8.next =
|
|
300
|
+
_context8.next = 1;
|
|
302
301
|
return Crypto.ElvCrypto();
|
|
303
|
-
case
|
|
302
|
+
case 1:
|
|
304
303
|
elvCrypto = _context8.sent;
|
|
305
|
-
_context8.next =
|
|
304
|
+
_context8.next = 2;
|
|
306
305
|
return Crypto.EncryptionContext(cap);
|
|
307
|
-
case
|
|
306
|
+
case 2:
|
|
308
307
|
_yield$Crypto$Encrypt = _context8.sent;
|
|
309
308
|
context = _yield$Crypto$Encrypt.context;
|
|
310
309
|
stream = new Stream.PassThrough();
|
|
@@ -314,7 +313,7 @@ var Crypto = {
|
|
|
314
313
|
}).on("error", function (e) {
|
|
315
314
|
throw Error(e);
|
|
316
315
|
}));
|
|
317
|
-
case
|
|
316
|
+
case 3:
|
|
318
317
|
case "end":
|
|
319
318
|
return _context8.stop();
|
|
320
319
|
}
|
|
@@ -335,14 +334,14 @@ var Crypto = {
|
|
|
335
334
|
* @returns {Promise<Buffer>} - Decrypted data
|
|
336
335
|
*/
|
|
337
336
|
Decrypt: function () {
|
|
338
|
-
var _Decrypt = _asyncToGenerator(
|
|
337
|
+
var _Decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(cap, encryptedData) {
|
|
339
338
|
var stream, dataArray, i, end, decryptedChunks;
|
|
340
|
-
return _regeneratorRuntime.wrap(function
|
|
339
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
341
340
|
while (1) switch (_context9.prev = _context9.next) {
|
|
342
341
|
case 0:
|
|
343
|
-
_context9.next =
|
|
342
|
+
_context9.next = 1;
|
|
344
343
|
return Crypto.OpenDecryptionStream(cap);
|
|
345
|
-
case
|
|
344
|
+
case 1:
|
|
346
345
|
stream = _context9.sent;
|
|
347
346
|
dataArray = new Uint8Array(encryptedData);
|
|
348
347
|
for (i = 0; i < dataArray.length; i += 1000000) {
|
|
@@ -351,7 +350,7 @@ var Crypto = {
|
|
|
351
350
|
}
|
|
352
351
|
stream.end();
|
|
353
352
|
decryptedChunks = [];
|
|
354
|
-
_context9.next =
|
|
353
|
+
_context9.next = 2;
|
|
355
354
|
return new Promise(function (resolve, reject) {
|
|
356
355
|
stream.on("data", function (chunk) {
|
|
357
356
|
decryptedChunks.push(chunk);
|
|
@@ -361,9 +360,9 @@ var Crypto = {
|
|
|
361
360
|
reject(e);
|
|
362
361
|
});
|
|
363
362
|
});
|
|
364
|
-
case
|
|
363
|
+
case 2:
|
|
365
364
|
return _context9.abrupt("return", Buffer.concat(decryptedChunks));
|
|
366
|
-
case
|
|
365
|
+
case 3:
|
|
367
366
|
case "end":
|
|
368
367
|
return _context9.stop();
|
|
369
368
|
}
|
|
@@ -375,33 +374,33 @@ var Crypto = {
|
|
|
375
374
|
return Decrypt;
|
|
376
375
|
}(),
|
|
377
376
|
OpenDecryptionStream: function () {
|
|
378
|
-
var _OpenDecryptionStream = _asyncToGenerator(
|
|
377
|
+
var _OpenDecryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(cap) {
|
|
379
378
|
var elvCrypto, _yield$Crypto$Encrypt2, context, type, stream, decipher;
|
|
380
|
-
return _regeneratorRuntime.wrap(function
|
|
381
|
-
while (1) switch (
|
|
379
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
380
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
382
381
|
case 0:
|
|
383
|
-
|
|
382
|
+
_context0.next = 1;
|
|
384
383
|
return Crypto.ElvCrypto();
|
|
385
|
-
case
|
|
386
|
-
elvCrypto =
|
|
387
|
-
|
|
384
|
+
case 1:
|
|
385
|
+
elvCrypto = _context0.sent;
|
|
386
|
+
_context0.next = 2;
|
|
388
387
|
return Crypto.EncryptionContext(cap);
|
|
389
|
-
case
|
|
390
|
-
_yield$Crypto$Encrypt2 =
|
|
388
|
+
case 2:
|
|
389
|
+
_yield$Crypto$Encrypt2 = _context0.sent;
|
|
391
390
|
context = _yield$Crypto$Encrypt2.context;
|
|
392
391
|
type = _yield$Crypto$Encrypt2.type;
|
|
393
392
|
stream = new Stream.PassThrough();
|
|
394
393
|
decipher = elvCrypto.createDecipher(type, context);
|
|
395
|
-
return
|
|
394
|
+
return _context0.abrupt("return", stream.pipe(decipher).on("finish", function () {
|
|
396
395
|
context.free();
|
|
397
396
|
}).on("error", function (e) {
|
|
398
397
|
throw Error(e);
|
|
399
398
|
}));
|
|
400
|
-
case
|
|
399
|
+
case 3:
|
|
401
400
|
case "end":
|
|
402
|
-
return
|
|
401
|
+
return _context0.stop();
|
|
403
402
|
}
|
|
404
|
-
},
|
|
403
|
+
}, _callee0);
|
|
405
404
|
}));
|
|
406
405
|
function OpenDecryptionStream(_x6) {
|
|
407
406
|
return _OpenDecryptionStream.apply(this, arguments);
|