@requestnetwork/transaction-manager 0.27.1-next.1862 → 0.27.1-next.1863
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/channel-parser.js
CHANGED
|
@@ -18,12 +18,12 @@ class ChannelParser {
|
|
|
18
18
|
* @returns Promise resolving the kept transactions and the ignored ones with the reason
|
|
19
19
|
*/
|
|
20
20
|
decryptAndCleanChannel(channelId, transactions) {
|
|
21
|
-
return
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
let channelType = types_1.TransactionTypes.ChannelType.UNKNOWN;
|
|
23
23
|
let channelKey;
|
|
24
24
|
let encryptionMethod;
|
|
25
25
|
// use of .reduce instead of .map to keep a sequential execution
|
|
26
|
-
const validAndIgnoredTransactions = yield transactions.reduce((accumulatorPromise, timestampedTransaction) =>
|
|
26
|
+
const validAndIgnoredTransactions = yield transactions.reduce((accumulatorPromise, timestampedTransaction) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const result = yield accumulatorPromise;
|
|
28
28
|
let parsedData;
|
|
29
29
|
try {
|
|
@@ -108,9 +108,9 @@ class ChannelParser {
|
|
|
108
108
|
* @returns Promise resolving the channel type and the channel key (if applicable)
|
|
109
109
|
*/
|
|
110
110
|
getChannelTypeAndChannelKey(channelId, transactions) {
|
|
111
|
-
return
|
|
111
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
112
112
|
// use of .reduce instead of .map to keep a sequential execution
|
|
113
|
-
const channelTypeAndKey = yield transactions.reduce((accumulatorPromise, timestampedTransaction) =>
|
|
113
|
+
const channelTypeAndKey = yield transactions.reduce((accumulatorPromise, timestampedTransaction) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
const result = yield accumulatorPromise;
|
|
115
115
|
// if we know the channel type, we skip the remaining transactions
|
|
116
116
|
if (result.channelType !== types_1.TransactionTypes.ChannelType.UNKNOWN) {
|
|
@@ -16,7 +16,7 @@ class ClearTransaction {
|
|
|
16
16
|
* @returns a promise resolving the transaction data
|
|
17
17
|
*/
|
|
18
18
|
getData() {
|
|
19
|
-
return
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
return this.data;
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -26,7 +26,7 @@ class ClearTransaction {
|
|
|
26
26
|
* @returns a promise resolving the transaction data hash
|
|
27
27
|
*/
|
|
28
28
|
getHash() {
|
|
29
|
-
return
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
return multi_format_1.default.serialize((0, utils_1.normalizeKeccak256Hash)(JSON.parse(this.data)));
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -36,7 +36,7 @@ class ClearTransaction {
|
|
|
36
36
|
* @returns a promise resolving a string of the error if any, otherwise an empty string
|
|
37
37
|
*/
|
|
38
38
|
getError() {
|
|
39
|
-
return
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
try {
|
|
41
41
|
JSON.parse(this.data);
|
|
42
42
|
return '';
|
|
@@ -26,7 +26,7 @@ class EncryptedTransaction {
|
|
|
26
26
|
* @returns a promise resolving the transaction data
|
|
27
27
|
*/
|
|
28
28
|
getData() {
|
|
29
|
-
return
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
if (this.data === '') {
|
|
31
31
|
try {
|
|
32
32
|
const encryptedData = multi_format_1.default.deserialize(this.persistedData);
|
|
@@ -45,7 +45,7 @@ class EncryptedTransaction {
|
|
|
45
45
|
* @returns a promise resolving the transaction data hash
|
|
46
46
|
*/
|
|
47
47
|
getHash() {
|
|
48
|
-
return
|
|
48
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
if (this.dataHashSerialized === '') {
|
|
50
50
|
const data = yield this.getData();
|
|
51
51
|
try {
|
|
@@ -65,7 +65,7 @@ class EncryptedTransaction {
|
|
|
65
65
|
* @returns a promise resolving a string of the error if any, otherwise an empty string
|
|
66
66
|
*/
|
|
67
67
|
getError() {
|
|
68
|
-
return
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
let data = '';
|
|
70
70
|
try {
|
|
71
71
|
data = yield this.getData();
|
|
@@ -26,7 +26,7 @@ class TransactionManager {
|
|
|
26
26
|
* @returns object containing the meta-data of the persist
|
|
27
27
|
*/
|
|
28
28
|
persistTransaction(transactionData, channelId, topics = [], encryptionParams = []) {
|
|
29
|
-
return
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
let transaction = {};
|
|
31
31
|
let channelEncryptionMethod;
|
|
32
32
|
// compute hash to add it to the topics
|
|
@@ -106,7 +106,7 @@ class TransactionManager {
|
|
|
106
106
|
* @returns list of transactions of the channel
|
|
107
107
|
*/
|
|
108
108
|
getTransactionsByChannelId(channelId, timestampBoundaries) {
|
|
109
|
-
return
|
|
109
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
110
110
|
const resultGetTx = yield this.dataAccess.getTransactionsByChannelId(channelId, timestampBoundaries);
|
|
111
111
|
// Decrypts and cleans the channel from the data-access layers
|
|
112
112
|
const { transactions, ignoredTransactions, encryptionMethod } = yield this.channelParser.decryptAndCleanChannel(channelId, resultGetTx.result.transactions);
|
|
@@ -134,7 +134,7 @@ class TransactionManager {
|
|
|
134
134
|
* @returns list of channels indexed by topic
|
|
135
135
|
*/
|
|
136
136
|
getChannelsByTopic(topic, updatedBetween) {
|
|
137
|
-
return
|
|
137
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
138
138
|
const resultGetTx = yield this.dataAccess.getChannelsByTopic(topic, updatedBetween);
|
|
139
139
|
return this.parseMultipleChannels(resultGetTx);
|
|
140
140
|
});
|
|
@@ -147,7 +147,7 @@ class TransactionManager {
|
|
|
147
147
|
* @returns list of channels indexed by topics
|
|
148
148
|
*/
|
|
149
149
|
getChannelsByMultipleTopics(topics, updatedBetween) {
|
|
150
|
-
return
|
|
150
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
151
151
|
const resultGetTx = yield this.dataAccess.getChannelsByMultipleTopics(topics, updatedBetween);
|
|
152
152
|
return this.parseMultipleChannels(resultGetTx);
|
|
153
153
|
});
|
|
@@ -159,9 +159,9 @@ class TransactionManager {
|
|
|
159
159
|
* @returns decrypted and cleaned channels in the right format
|
|
160
160
|
*/
|
|
161
161
|
parseMultipleChannels(resultGetTx) {
|
|
162
|
-
return
|
|
162
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
163
163
|
// Get the channels from the data-access layers to decrypt and clean them one by one
|
|
164
|
-
const result = yield Object.keys(resultGetTx.result.transactions).reduce((accumulatorPromise, channelId) =>
|
|
164
|
+
const result = yield Object.keys(resultGetTx.result.transactions).reduce((accumulatorPromise, channelId) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
165
165
|
const cleaned = yield this.channelParser.decryptAndCleanChannel(channelId, resultGetTx.result.transactions[channelId]);
|
|
166
166
|
// await for the accumulator promise at the end to parallelize the calls to decryptAndCleanChannel()
|
|
167
167
|
const accumulator = yield accumulatorPromise;
|
|
@@ -15,7 +15,7 @@ class TransactionsFactory {
|
|
|
15
15
|
* @returns the transaction
|
|
16
16
|
*/
|
|
17
17
|
static createClearTransaction(data) {
|
|
18
|
-
return
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
try {
|
|
20
20
|
JSON.parse(data);
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ class TransactionsFactory {
|
|
|
33
33
|
* @returns the encrypted transaction
|
|
34
34
|
*/
|
|
35
35
|
static createEncryptedTransactionInNewChannel(data, encryptionParams) {
|
|
36
|
-
return
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
// format encryption method property
|
|
38
38
|
const encryptionMethod = `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`;
|
|
39
39
|
// Generate a key for the AES encryption
|
|
@@ -54,7 +54,7 @@ class TransactionsFactory {
|
|
|
54
54
|
throw new Error(`encryptionParams method must be all: ${types_1.EncryptionTypes.METHOD.ECIES}`);
|
|
55
55
|
}
|
|
56
56
|
// Compute key encryption and identity hash for every encryption parameters given
|
|
57
|
-
const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) =>
|
|
57
|
+
const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
58
|
const encryptedKey = yield (0, utils_1.encrypt)(symmetricKey, encryptionParam);
|
|
59
59
|
const identityEncryption = (0, utils_1.getIdentityFromEncryptionParams)(encryptionParam);
|
|
60
60
|
const multiFormattedIdentity = multi_format_1.default.serialize(identityEncryption);
|
|
@@ -79,7 +79,7 @@ class TransactionsFactory {
|
|
|
79
79
|
* @returns the encrypted transaction
|
|
80
80
|
*/
|
|
81
81
|
static createEncryptedTransaction(data, channelKey) {
|
|
82
|
-
return
|
|
82
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
// check if the encryption method is the good one
|
|
84
84
|
if (channelKey.method !== types_1.EncryptionTypes.METHOD.AES256_GCM) {
|
|
85
85
|
throw new Error(`encryption method not supported for the channel key: ${channelKey.method}`);
|
|
@@ -21,7 +21,7 @@ class TransactionsParser {
|
|
|
21
21
|
* @returns the transaction object and the channel key (if applicable)
|
|
22
22
|
*/
|
|
23
23
|
parsePersistedTransaction(persistedTransaction, channelType, channelKey) {
|
|
24
|
-
return
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
// looks like a clear transaction
|
|
26
26
|
if (persistedTransaction.data) {
|
|
27
27
|
if (channelType === types_1.TransactionTypes.ChannelType.ENCRYPTED) {
|
|
@@ -68,7 +68,7 @@ class TransactionsParser {
|
|
|
68
68
|
* @returns the channel key
|
|
69
69
|
*/
|
|
70
70
|
decryptChannelKey(keys, encryptionMethod) {
|
|
71
|
-
return
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
72
|
// Check if the decryption provider is given
|
|
73
73
|
if (!this.decryptionProvider) {
|
|
74
74
|
throw new Error(`No decryption provider given`);
|
|
@@ -86,7 +86,7 @@ class TransactionsParser {
|
|
|
86
86
|
}
|
|
87
87
|
let errorReason = '';
|
|
88
88
|
// Try to decrypt the channelKey
|
|
89
|
-
const channelKey = yield Object.keys(keys || {}).reduce((decryptedChannelKeyPromise, identityMultiFormatted) =>
|
|
89
|
+
const channelKey = yield Object.keys(keys || {}).reduce((decryptedChannelKeyPromise, identityMultiFormatted) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
let decryptedChannelKey = yield decryptedChannelKeyPromise;
|
|
91
91
|
if (keys && decryptedChannelKey === '') {
|
|
92
92
|
let identity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestnetwork/transaction-manager",
|
|
3
|
-
"version": "0.27.1-next.
|
|
3
|
+
"version": "0.27.1-next.1863+e30fe104",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"test:watch": "yarn test --watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@requestnetwork/multi-format": "0.15.11-next.
|
|
43
|
-
"@requestnetwork/types": "0.36.1-next.
|
|
44
|
-
"@requestnetwork/utils": "0.36.1-next.
|
|
45
|
-
"tslib": "2.
|
|
42
|
+
"@requestnetwork/multi-format": "0.15.11-next.1863+e30fe104",
|
|
43
|
+
"@requestnetwork/types": "0.36.1-next.1863+e30fe104",
|
|
44
|
+
"@requestnetwork/utils": "0.36.1-next.1863+e30fe104",
|
|
45
|
+
"tslib": "2.5.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "26.0.13",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"shx": "0.3.2",
|
|
52
52
|
"source-map-support": "0.5.19",
|
|
53
53
|
"ts-jest": "26.3.0",
|
|
54
|
-
"ts-node": "9.
|
|
55
|
-
"typescript": "4.
|
|
54
|
+
"ts-node": "10.9.1",
|
|
55
|
+
"typescript": "4.9.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "e30fe104aa6f79d5f8a897ee75dcd99c7df0902c"
|
|
58
58
|
}
|