@eluvio/elv-client-js 4.2.6 → 4.2.8
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 +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +709 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +529 -499
- package/dist/src/ElvWallet.js +30 -28
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +63 -64
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +499 -487
- package/dist/src/RemoteSigner.js +82 -83
- package/dist/src/UserProfileClient.js +392 -374
- package/dist/src/Utils.js +69 -66
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +477 -474
- package/dist/src/client/ContentAccess.js +1707 -1711
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +575 -578
- package/dist/src/client/Files.js +700 -684
- package/dist/src/client/LiveConf.js +1 -3
- package/dist/src/client/LiveStream.js +694 -693
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +53 -60
- package/dist/src/walletClient/ClientMethods.js +977 -951
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +572 -562
- package/package.json +1 -1
- package/src/AuthorizationClient.js +9 -3
- package/src/ElvClient.js +1 -1
- package/src/walletClient/index.js +6 -2
- package/dist/src/ContentObjectVerification.js +0 -281
|
@@ -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,7 +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 _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
|
|
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); }
|
|
5
5
|
if (typeof globalThis.Buffer === "undefined") {
|
|
6
6
|
globalThis.Buffer = require("buffer/").Buffer;
|
|
7
7
|
}
|
|
@@ -26,40 +26,40 @@ if (typeof crypto === "undefined") {
|
|
|
26
26
|
*/
|
|
27
27
|
var Crypto = {
|
|
28
28
|
ElvCrypto: function () {
|
|
29
|
-
var _ElvCrypto = _asyncToGenerator(
|
|
30
|
-
var _ElvCrypto2;
|
|
31
|
-
return _regeneratorRuntime.wrap(function
|
|
29
|
+
var _ElvCrypto = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
30
|
+
var _ElvCrypto2, _t;
|
|
31
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
32
32
|
while (1) switch (_context.prev = _context.next) {
|
|
33
33
|
case 0:
|
|
34
34
|
_context.prev = 0;
|
|
35
35
|
if (Crypto.elvCrypto) {
|
|
36
|
-
_context.next =
|
|
36
|
+
_context.next = 3;
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
|
-
_context.next =
|
|
39
|
+
_context.next = 1;
|
|
40
40
|
return Promise.resolve().then(function () {
|
|
41
41
|
return _interopRequireWildcard(require("@eluvio/crypto"));
|
|
42
42
|
});
|
|
43
|
-
case
|
|
43
|
+
case 1:
|
|
44
44
|
_ElvCrypto2 = _context.sent["default"];
|
|
45
|
-
_context.next =
|
|
45
|
+
_context.next = 2;
|
|
46
46
|
return new _ElvCrypto2().init();
|
|
47
|
-
case
|
|
47
|
+
case 2:
|
|
48
48
|
Crypto.elvCrypto = _context.sent;
|
|
49
|
-
case
|
|
49
|
+
case 3:
|
|
50
50
|
return _context.abrupt("return", Crypto.elvCrypto);
|
|
51
|
-
case
|
|
52
|
-
_context.prev =
|
|
53
|
-
|
|
51
|
+
case 4:
|
|
52
|
+
_context.prev = 4;
|
|
53
|
+
_t = _context["catch"](0);
|
|
54
54
|
// eslint-disable-next-line no-console
|
|
55
55
|
console.error("Error initializing ElvCrypto:");
|
|
56
56
|
// eslint-disable-next-line no-console
|
|
57
|
-
console.error(
|
|
58
|
-
case
|
|
57
|
+
console.error(_t);
|
|
58
|
+
case 5:
|
|
59
59
|
case "end":
|
|
60
60
|
return _context.stop();
|
|
61
61
|
}
|
|
62
|
-
}, _callee, null, [[0,
|
|
62
|
+
}, _callee, null, [[0, 4]]);
|
|
63
63
|
}));
|
|
64
64
|
function ElvCrypto() {
|
|
65
65
|
return _ElvCrypto.apply(this, arguments);
|
|
@@ -90,27 +90,27 @@ var Crypto = {
|
|
|
90
90
|
return reencrypt ? encryptedBlockSize + targetEncBlockOverhead : encryptedBlockSize + primaryEncBlockOverhead;
|
|
91
91
|
},
|
|
92
92
|
EncryptConk: function EncryptConk(conk, publicKey) {
|
|
93
|
-
return _asyncToGenerator(
|
|
93
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
94
94
|
var elvCrypto, _yield$elvCrypto$encr, data, ephemeralKey, tag, cap;
|
|
95
|
-
return _regeneratorRuntime.wrap(function
|
|
95
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
96
96
|
while (1) switch (_context2.prev = _context2.next) {
|
|
97
97
|
case 0:
|
|
98
|
-
_context2.next =
|
|
98
|
+
_context2.next = 1;
|
|
99
99
|
return Crypto.ElvCrypto();
|
|
100
|
-
case
|
|
100
|
+
case 1:
|
|
101
101
|
elvCrypto = _context2.sent;
|
|
102
102
|
publicKey = new Uint8Array(Buffer.from(publicKey.replace("0x", ""), "hex"));
|
|
103
103
|
conk = new Uint8Array(Buffer.from(JSON.stringify(conk)));
|
|
104
|
-
_context2.next =
|
|
104
|
+
_context2.next = 2;
|
|
105
105
|
return elvCrypto.encryptECIES(conk, publicKey);
|
|
106
|
-
case
|
|
106
|
+
case 2:
|
|
107
107
|
_yield$elvCrypto$encr = _context2.sent;
|
|
108
108
|
data = _yield$elvCrypto$encr.data;
|
|
109
109
|
ephemeralKey = _yield$elvCrypto$encr.ephemeralKey;
|
|
110
110
|
tag = _yield$elvCrypto$encr.tag;
|
|
111
111
|
cap = Buffer.concat([Buffer.from(ephemeralKey), Buffer.from(tag), Buffer.from(data)]);
|
|
112
112
|
return _context2.abrupt("return", Utils.B64(cap));
|
|
113
|
-
case
|
|
113
|
+
case 3:
|
|
114
114
|
case "end":
|
|
115
115
|
return _context2.stop();
|
|
116
116
|
}
|
|
@@ -118,14 +118,14 @@ var Crypto = {
|
|
|
118
118
|
}))();
|
|
119
119
|
},
|
|
120
120
|
DecryptCap: function DecryptCap(encryptedCap, privateKey) {
|
|
121
|
-
return _asyncToGenerator(
|
|
121
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
122
122
|
var elvCrypto, ephemeralKey, tag, data, cap;
|
|
123
|
-
return _regeneratorRuntime.wrap(function
|
|
123
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
124
124
|
while (1) switch (_context3.prev = _context3.next) {
|
|
125
125
|
case 0:
|
|
126
|
-
_context3.next =
|
|
126
|
+
_context3.next = 1;
|
|
127
127
|
return Crypto.ElvCrypto();
|
|
128
|
-
case
|
|
128
|
+
case 1:
|
|
129
129
|
elvCrypto = _context3.sent;
|
|
130
130
|
privateKey = new Uint8Array(Buffer.from(privateKey.replace("0x", ""), "hex"));
|
|
131
131
|
encryptedCap = Buffer.from(encryptedCap, "base64");
|
|
@@ -134,7 +134,7 @@ var Crypto = {
|
|
|
134
134
|
data = encryptedCap.slice(81);
|
|
135
135
|
cap = elvCrypto.decryptECIES(new Uint8Array(data), privateKey, new Uint8Array(ephemeralKey), new Uint8Array(tag));
|
|
136
136
|
return _context3.abrupt("return", JSON.parse(Buffer.from(cap).toString()));
|
|
137
|
-
case
|
|
137
|
+
case 2:
|
|
138
138
|
case "end":
|
|
139
139
|
return _context3.stop();
|
|
140
140
|
}
|
|
@@ -142,15 +142,15 @@ var Crypto = {
|
|
|
142
142
|
}))();
|
|
143
143
|
},
|
|
144
144
|
GeneratePrimaryConk: function GeneratePrimaryConk(_ref) {
|
|
145
|
-
return _asyncToGenerator(
|
|
145
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
146
146
|
var spaceId, objectId, elvCrypto, _elvCrypto$generatePr, secretKey, publicKey, symmetricKey;
|
|
147
|
-
return _regeneratorRuntime.wrap(function
|
|
147
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
148
148
|
while (1) switch (_context4.prev = _context4.next) {
|
|
149
149
|
case 0:
|
|
150
150
|
spaceId = _ref.spaceId, objectId = _ref.objectId;
|
|
151
|
-
_context4.next =
|
|
151
|
+
_context4.next = 1;
|
|
152
152
|
return Crypto.ElvCrypto();
|
|
153
|
-
case
|
|
153
|
+
case 1:
|
|
154
154
|
elvCrypto = _context4.sent;
|
|
155
155
|
_elvCrypto$generatePr = elvCrypto.generatePrimaryKeys(), secretKey = _elvCrypto$generatePr.secretKey, publicKey = _elvCrypto$generatePr.publicKey;
|
|
156
156
|
symmetricKey = elvCrypto.generateSymmetricKey().key;
|
|
@@ -161,7 +161,7 @@ var Crypto = {
|
|
|
161
161
|
sid: spaceId,
|
|
162
162
|
qid: objectId
|
|
163
163
|
});
|
|
164
|
-
case
|
|
164
|
+
case 2:
|
|
165
165
|
case "end":
|
|
166
166
|
return _context4.stop();
|
|
167
167
|
}
|
|
@@ -169,21 +169,21 @@ var Crypto = {
|
|
|
169
169
|
}))();
|
|
170
170
|
},
|
|
171
171
|
GenerateTargetConk: function GenerateTargetConk() {
|
|
172
|
-
return _asyncToGenerator(
|
|
172
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
173
173
|
var elvCrypto, _elvCrypto$generateTa, secretKey, publicKey;
|
|
174
|
-
return _regeneratorRuntime.wrap(function
|
|
174
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
175
175
|
while (1) switch (_context5.prev = _context5.next) {
|
|
176
176
|
case 0:
|
|
177
|
-
_context5.next =
|
|
177
|
+
_context5.next = 1;
|
|
178
178
|
return Crypto.ElvCrypto();
|
|
179
|
-
case
|
|
179
|
+
case 1:
|
|
180
180
|
elvCrypto = _context5.sent;
|
|
181
181
|
_elvCrypto$generateTa = elvCrypto.generateTargetKeys(), secretKey = _elvCrypto$generateTa.secretKey, publicKey = _elvCrypto$generateTa.publicKey;
|
|
182
182
|
return _context5.abrupt("return", {
|
|
183
183
|
secret_key: "kpsk".concat(bs58.encode(Buffer.from(secretKey))),
|
|
184
184
|
public_key: "ktpk".concat(bs58.encode(Buffer.from(publicKey)))
|
|
185
185
|
});
|
|
186
|
-
case
|
|
186
|
+
case 2:
|
|
187
187
|
case "end":
|
|
188
188
|
return _context5.stop();
|
|
189
189
|
}
|
|
@@ -201,14 +201,14 @@ var Crypto = {
|
|
|
201
201
|
};
|
|
202
202
|
},
|
|
203
203
|
EncryptionContext: function EncryptionContext(cap) {
|
|
204
|
-
return _asyncToGenerator(
|
|
204
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
205
205
|
var elvCrypto, _Crypto$CapToConk, symmetricKey, secretKey, publicKey, context, type;
|
|
206
|
-
return _regeneratorRuntime.wrap(function
|
|
206
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
207
207
|
while (1) switch (_context6.prev = _context6.next) {
|
|
208
208
|
case 0:
|
|
209
|
-
_context6.next =
|
|
209
|
+
_context6.next = 1;
|
|
210
210
|
return Crypto.ElvCrypto();
|
|
211
|
-
case
|
|
211
|
+
case 1:
|
|
212
212
|
elvCrypto = _context6.sent;
|
|
213
213
|
_Crypto$CapToConk = Crypto.CapToConk(cap), symmetricKey = _Crypto$CapToConk.symmetricKey, secretKey = _Crypto$CapToConk.secretKey, publicKey = _Crypto$CapToConk.publicKey;
|
|
214
214
|
if (publicKey.length === elvCrypto.PRIMARY_PK_KEY_SIZE) {
|
|
@@ -224,7 +224,7 @@ var Crypto = {
|
|
|
224
224
|
context: context,
|
|
225
225
|
type: type
|
|
226
226
|
});
|
|
227
|
-
case
|
|
227
|
+
case 2:
|
|
228
228
|
case "end":
|
|
229
229
|
return _context6.stop();
|
|
230
230
|
}
|
|
@@ -241,26 +241,26 @@ var Crypto = {
|
|
|
241
241
|
* @returns {Promise<Buffer>} - Decrypted data
|
|
242
242
|
*/
|
|
243
243
|
Encrypt: function () {
|
|
244
|
-
var _Encrypt = _asyncToGenerator(
|
|
245
|
-
var stream, dataArray, i, end, encryptedChunks;
|
|
246
|
-
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) {
|
|
247
247
|
while (1) switch (_context7.prev = _context7.next) {
|
|
248
248
|
case 0:
|
|
249
|
-
_context7.next =
|
|
249
|
+
_context7.next = 1;
|
|
250
250
|
return Crypto.OpenEncryptionStream(cap);
|
|
251
|
-
case
|
|
251
|
+
case 1:
|
|
252
252
|
stream = _context7.sent;
|
|
253
253
|
if (!(!Buffer.isBuffer(data) && !(data instanceof ArrayBuffer))) {
|
|
254
|
-
_context7.next =
|
|
254
|
+
_context7.next = 3;
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
_context7.next =
|
|
257
|
+
_t2 = Buffer;
|
|
258
|
+
_context7.next = 2;
|
|
259
259
|
return new Response(data).arrayBuffer();
|
|
260
|
-
case
|
|
261
|
-
|
|
262
|
-
data =
|
|
263
|
-
case
|
|
260
|
+
case 2:
|
|
261
|
+
_t3 = _context7.sent;
|
|
262
|
+
data = _t2.from.call(_t2, _t3);
|
|
263
|
+
case 3:
|
|
264
264
|
dataArray = new Uint8Array(data);
|
|
265
265
|
for (i = 0; i < dataArray.length; i += 1000000) {
|
|
266
266
|
end = Math.min(dataArray.length, i + 1000000);
|
|
@@ -268,7 +268,7 @@ var Crypto = {
|
|
|
268
268
|
}
|
|
269
269
|
stream.end();
|
|
270
270
|
encryptedChunks = [];
|
|
271
|
-
_context7.next =
|
|
271
|
+
_context7.next = 4;
|
|
272
272
|
return new Promise(function (resolve, reject) {
|
|
273
273
|
stream.on("data", function (chunk) {
|
|
274
274
|
encryptedChunks.push(chunk);
|
|
@@ -278,9 +278,9 @@ var Crypto = {
|
|
|
278
278
|
reject(e);
|
|
279
279
|
});
|
|
280
280
|
});
|
|
281
|
-
case
|
|
281
|
+
case 4:
|
|
282
282
|
return _context7.abrupt("return", Buffer.concat(encryptedChunks));
|
|
283
|
-
case
|
|
283
|
+
case 5:
|
|
284
284
|
case "end":
|
|
285
285
|
return _context7.stop();
|
|
286
286
|
}
|
|
@@ -292,18 +292,18 @@ var Crypto = {
|
|
|
292
292
|
return Encrypt;
|
|
293
293
|
}(),
|
|
294
294
|
OpenEncryptionStream: function () {
|
|
295
|
-
var _OpenEncryptionStream = _asyncToGenerator(
|
|
295
|
+
var _OpenEncryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(cap) {
|
|
296
296
|
var elvCrypto, _yield$Crypto$Encrypt, context, stream, cipher;
|
|
297
|
-
return _regeneratorRuntime.wrap(function
|
|
297
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
298
298
|
while (1) switch (_context8.prev = _context8.next) {
|
|
299
299
|
case 0:
|
|
300
|
-
_context8.next =
|
|
300
|
+
_context8.next = 1;
|
|
301
301
|
return Crypto.ElvCrypto();
|
|
302
|
-
case
|
|
302
|
+
case 1:
|
|
303
303
|
elvCrypto = _context8.sent;
|
|
304
|
-
_context8.next =
|
|
304
|
+
_context8.next = 2;
|
|
305
305
|
return Crypto.EncryptionContext(cap);
|
|
306
|
-
case
|
|
306
|
+
case 2:
|
|
307
307
|
_yield$Crypto$Encrypt = _context8.sent;
|
|
308
308
|
context = _yield$Crypto$Encrypt.context;
|
|
309
309
|
stream = new Stream.PassThrough();
|
|
@@ -313,7 +313,7 @@ var Crypto = {
|
|
|
313
313
|
}).on("error", function (e) {
|
|
314
314
|
throw Error(e);
|
|
315
315
|
}));
|
|
316
|
-
case
|
|
316
|
+
case 3:
|
|
317
317
|
case "end":
|
|
318
318
|
return _context8.stop();
|
|
319
319
|
}
|
|
@@ -334,14 +334,14 @@ var Crypto = {
|
|
|
334
334
|
* @returns {Promise<Buffer>} - Decrypted data
|
|
335
335
|
*/
|
|
336
336
|
Decrypt: function () {
|
|
337
|
-
var _Decrypt = _asyncToGenerator(
|
|
337
|
+
var _Decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(cap, encryptedData) {
|
|
338
338
|
var stream, dataArray, i, end, decryptedChunks;
|
|
339
|
-
return _regeneratorRuntime.wrap(function
|
|
339
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
340
340
|
while (1) switch (_context9.prev = _context9.next) {
|
|
341
341
|
case 0:
|
|
342
|
-
_context9.next =
|
|
342
|
+
_context9.next = 1;
|
|
343
343
|
return Crypto.OpenDecryptionStream(cap);
|
|
344
|
-
case
|
|
344
|
+
case 1:
|
|
345
345
|
stream = _context9.sent;
|
|
346
346
|
dataArray = new Uint8Array(encryptedData);
|
|
347
347
|
for (i = 0; i < dataArray.length; i += 1000000) {
|
|
@@ -350,7 +350,7 @@ var Crypto = {
|
|
|
350
350
|
}
|
|
351
351
|
stream.end();
|
|
352
352
|
decryptedChunks = [];
|
|
353
|
-
_context9.next =
|
|
353
|
+
_context9.next = 2;
|
|
354
354
|
return new Promise(function (resolve, reject) {
|
|
355
355
|
stream.on("data", function (chunk) {
|
|
356
356
|
decryptedChunks.push(chunk);
|
|
@@ -360,9 +360,9 @@ var Crypto = {
|
|
|
360
360
|
reject(e);
|
|
361
361
|
});
|
|
362
362
|
});
|
|
363
|
-
case
|
|
363
|
+
case 2:
|
|
364
364
|
return _context9.abrupt("return", Buffer.concat(decryptedChunks));
|
|
365
|
-
case
|
|
365
|
+
case 3:
|
|
366
366
|
case "end":
|
|
367
367
|
return _context9.stop();
|
|
368
368
|
}
|
|
@@ -374,33 +374,33 @@ var Crypto = {
|
|
|
374
374
|
return Decrypt;
|
|
375
375
|
}(),
|
|
376
376
|
OpenDecryptionStream: function () {
|
|
377
|
-
var _OpenDecryptionStream = _asyncToGenerator(
|
|
377
|
+
var _OpenDecryptionStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(cap) {
|
|
378
378
|
var elvCrypto, _yield$Crypto$Encrypt2, context, type, stream, decipher;
|
|
379
|
-
return _regeneratorRuntime.wrap(function
|
|
380
|
-
while (1) switch (
|
|
379
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
380
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
381
381
|
case 0:
|
|
382
|
-
|
|
382
|
+
_context0.next = 1;
|
|
383
383
|
return Crypto.ElvCrypto();
|
|
384
|
-
case
|
|
385
|
-
elvCrypto =
|
|
386
|
-
|
|
384
|
+
case 1:
|
|
385
|
+
elvCrypto = _context0.sent;
|
|
386
|
+
_context0.next = 2;
|
|
387
387
|
return Crypto.EncryptionContext(cap);
|
|
388
|
-
case
|
|
389
|
-
_yield$Crypto$Encrypt2 =
|
|
388
|
+
case 2:
|
|
389
|
+
_yield$Crypto$Encrypt2 = _context0.sent;
|
|
390
390
|
context = _yield$Crypto$Encrypt2.context;
|
|
391
391
|
type = _yield$Crypto$Encrypt2.type;
|
|
392
392
|
stream = new Stream.PassThrough();
|
|
393
393
|
decipher = elvCrypto.createDecipher(type, context);
|
|
394
|
-
return
|
|
394
|
+
return _context0.abrupt("return", stream.pipe(decipher).on("finish", function () {
|
|
395
395
|
context.free();
|
|
396
396
|
}).on("error", function (e) {
|
|
397
397
|
throw Error(e);
|
|
398
398
|
}));
|
|
399
|
-
case
|
|
399
|
+
case 3:
|
|
400
400
|
case "end":
|
|
401
|
-
return
|
|
401
|
+
return _context0.stop();
|
|
402
402
|
}
|
|
403
|
-
},
|
|
403
|
+
}, _callee0);
|
|
404
404
|
}));
|
|
405
405
|
function OpenDecryptionStream(_x6) {
|
|
406
406
|
return _OpenDecryptionStream.apply(this, arguments);
|