@requestnetwork/transaction-manager 0.36.1 → 0.37.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/README.md CHANGED
@@ -17,10 +17,10 @@ npm install @requestnetwork/transaction-manager
17
17
  In order to decrypt encrypted transactions, you must provide a decryption provider.
18
18
  You can see the specification of decryption provider [here](./specs/decryption-provider.md).
19
19
 
20
- An example of implementation of a decryption provider is available in the package: [epk-decryption](../epk-decryption/)
20
+ An example of implementation of a decryption provider is available in the package: [epk-cipher](../epk-cipher/)
21
21
 
22
22
  ```javascript
23
- import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
23
+ import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-cipher';
24
24
  import { TransactionManager } from '@requestnetwork/transaction-manager';
25
25
 
26
26
  // Decryption provider setup
@@ -87,7 +87,7 @@ const { result } = await transactionManager.persistTransaction(data, channelId,
87
87
  ### Get Transactions from channel id
88
88
 
89
89
  ```javascript
90
- import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
90
+ import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-cipher';
91
91
  import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
92
92
  import { TransactionManager } from '@requestnetwork/transaction-manager';
93
93
 
@@ -111,7 +111,7 @@ const {
111
111
  ### Get Transactions from topic
112
112
 
113
113
  ```typescript
114
- import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
114
+ import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-cipher';
115
115
  import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
116
116
  import { TransactionManager } from '@requestnetwork/transaction-manager';
117
117
 
@@ -1,10 +1,11 @@
1
- import { DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
1
+ import { CipherProviderTypes, DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
2
2
  /**
3
3
  * Class to parse channels from a list of transactions and their channel id
4
4
  */
5
5
  export default class ChannelParser {
6
6
  private transactionParser;
7
- constructor(decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider);
7
+ private cipherProvider?;
8
+ constructor(decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider, cipherProvider?: CipherProviderTypes.ICipherProvider);
8
9
  /**
9
10
  * Decrypts and cleans a channel by removing the wrong transactions
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"channel-parser.d.ts","sourceRoot":"","sources":["../src/channel-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAInG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,iBAAiB,CAAqB;gBAE3B,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB;IAGnF;;;;;;OAMG;IACU,sBAAsB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,gBAAgB,CAAC,uBAAuB,EAAE,GACvD,OAAO,CAAC;QACT,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;QACrC,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;QACrE,mBAAmB,EAAE,KAAK,CAAC,gBAAgB,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;KACzE,CAAC;IA8GF;;;;;;OAMG;IACU,2BAA2B,CAEtC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,gBAAgB,CAAC,uBAAuB,EAAE,GACvD,OAAO,CAAC;QACT,WAAW,EAAE,gBAAgB,CAAC,WAAW,CAAC;QAC1C,UAAU,EAAE,eAAe,CAAC,qBAAqB,GAAG,SAAS,CAAC;QAC9D,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;KACtC,CAAC;CA8EH"}
1
+ {"version":3,"file":"channel-parser.d.ts","sourceRoot":"","sources":["../src/channel-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAI/B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,cAAc,CAAC,CAAsC;gBAG3D,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB,EAChE,cAAc,CAAC,EAAE,mBAAmB,CAAC,eAAe;IAKtD;;;;;;OAMG;IACU,sBAAsB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,gBAAgB,CAAC,uBAAuB,EAAE,GACvD,OAAO,CAAC;QACT,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;QACrC,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;QACrE,mBAAmB,EAAE,KAAK,CAAC,gBAAgB,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;KACzE,CAAC;IA8GF;;;;;;OAMG;IACU,2BAA2B,CAEtC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,gBAAgB,CAAC,uBAAuB,EAAE,GACvD,OAAO,CAAC;QACT,WAAW,EAAE,gBAAgB,CAAC,WAAW,CAAC;QAC1C,UAAU,EAAE,eAAe,CAAC,qBAAqB,GAAG,SAAS,CAAC;QAC9D,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;KACtC,CAAC;CA8EH"}
@@ -7,8 +7,9 @@ const transactions_parser_1 = require("./transactions-parser");
7
7
  * Class to parse channels from a list of transactions and their channel id
8
8
  */
9
9
  class ChannelParser {
10
- constructor(decryptionProvider) {
11
- this.transactionParser = new transactions_parser_1.default(decryptionProvider);
10
+ constructor(decryptionProvider, cipherProvider) {
11
+ this.transactionParser = new transactions_parser_1.default(decryptionProvider, cipherProvider);
12
+ this.cipherProvider = cipherProvider;
12
13
  }
13
14
  /**
14
15
  * Decrypts and cleans a channel by removing the wrong transactions
@@ -112,6 +113,7 @@ class ChannelParser {
112
113
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
113
114
  // use of .reduce instead of .map to keep a sequential execution
114
115
  const channelTypeAndKey = yield transactions.reduce((accumulatorPromise, timestampedTransaction) => tslib_1.__awaiter(this, void 0, void 0, function* () {
116
+ var _a;
115
117
  const result = yield accumulatorPromise;
116
118
  // Skip remaining transactions if channel is CLEAR or after channelKey is found
117
119
  if (result.channelType === types_1.TransactionTypes.ChannelType.CLEAR || result.channelKey) {
@@ -124,7 +126,7 @@ class ChannelParser {
124
126
  }
125
127
  catch (error) {
126
128
  // If the transaction is encrypted but the channel key is not found, save channelType and encryptionMethod
127
- if (error.message.startsWith('Impossible to decrypt the channel key from this transaction') &&
129
+ if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.startsWith('Impossible to decrypt the channel key from this transaction')) &&
128
130
  result.channelType === types_1.TransactionTypes.ChannelType.UNKNOWN) {
129
131
  result.channelType = types_1.TransactionTypes.ChannelType.ENCRYPTED;
130
132
  result.encryptionMethod = timestampedTransaction.transaction.encryptionMethod;
@@ -1 +1 @@
1
- {"version":3,"file":"channel-parser.js","sourceRoot":"","sources":["../src/channel-parser.ts"],"names":[],"mappings":";;;AAAA,iDAAmG;AAEnG,+DAAuD;AAEvD;;GAEG;AACH,MAAqB,aAAa;IAGhC,YAAmB,kBAAgE;QACjF,IAAI,CAAC,iBAAiB,GAAG,IAAI,6BAAkB,CAAC,kBAAkB,CAAC,CAAC;IACtE,CAAC;IACD;;;;;;OAMG;IACU,sBAAsB,CACjC,SAAiB,EACjB,YAAwD;;YAMxD,IAAI,WAAW,GAAiC,wBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC;YACrF,IAAI,gBAAoC,CAAC;YAMzC,yBAAyB;YACzB,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,2BA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AAC;KAAA;CACF;AApOD,gCAoOC"}
@@ -1,11 +1,12 @@
1
- import { DataAccessTypes, DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
1
+ import { CipherProviderTypes, DataAccessTypes, DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
2
2
  /**
3
3
  * Implementation of TransactionManager layer without encryption
4
4
  */
5
5
  export default class TransactionManager implements TransactionTypes.ITransactionManager {
6
6
  private dataAccess;
7
7
  private channelParser;
8
- constructor(dataAccess: DataAccessTypes.IDataAccess, decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider);
8
+ private cipherProvider?;
9
+ constructor(dataAccess: DataAccessTypes.IDataAccess, decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider, cipherProvider?: CipherProviderTypes.ICipherProvider);
9
10
  /**
10
11
  * Persists a transaction and topics in storage. If encryptionParams is given, the transaction will be encrypted
11
12
  *
@@ -34,7 +35,7 @@ export default class TransactionManager implements TransactionTypes.ITransaction
34
35
  * @param updatedBetween filter the channel whose received new data in the boundaries
35
36
  * @returns list of channels indexed by topic
36
37
  */
37
- getChannelsByTopic(topic: string, updatedBetween?: TransactionTypes.ITimestampBoundaries): Promise<TransactionTypes.IReturnGetTransactionsByChannels>;
38
+ getChannelsByTopic(topic: string, updatedBetween?: TransactionTypes.ITimestampBoundaries, page?: number, pageSize?: number): Promise<TransactionTypes.IReturnGetTransactionsByChannels>;
38
39
  /**
39
40
  * Gets a list of channels indexed by topics
40
41
  *
@@ -42,7 +43,7 @@ export default class TransactionManager implements TransactionTypes.ITransaction
42
43
  * @param updatedBetween filter the channel whose hasn't received new data in the boundaries
43
44
  * @returns list of channels indexed by topics
44
45
  */
45
- getChannelsByMultipleTopics(topics: string[], updatedBetween?: TransactionTypes.ITimestampBoundaries): Promise<TransactionTypes.IReturnGetTransactionsByChannels>;
46
+ getChannelsByMultipleTopics(topics: string[], updatedBetween?: TransactionTypes.ITimestampBoundaries, page?: number, pageSize?: number): Promise<TransactionTypes.IReturnGetTransactionsByChannels>;
46
47
  /**
47
48
  * Parses the return of getChannels function from data-access layer
48
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-manager.d.ts","sourceRoot":"","sources":["../src/transaction-manager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAQ/B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,gBAAgB,CAAC,mBAAmB;IACrF,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,aAAa,CAAgB;gBAGnC,UAAU,EAAE,eAAe,CAAC,WAAW,EACvC,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB;IAMlE;;;;;;;;;OASG;IACU,kBAAkB,CAC7B,eAAe,EAAE,gBAAgB,CAAC,gBAAgB,EAClD,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,EAAO,EACrB,gBAAgB,GAAE,eAAe,CAAC,qBAAqB,EAAO,GAC7D,OAAO,CAAC,gBAAgB,CAAC,yBAAyB,CAAC;IA8FtD;;;;;;;;OAQG;IACU,0BAA0B,CACrC,SAAS,EAAE,MAAM,EACjB,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,GAC1D,OAAO,CAAC,gBAAgB,CAAC,sBAAsB,CAAC;IA4BnD;;;;;;OAMG;IACU,kBAAkB,CAC7B,KAAK,EAAE,MAAM,EACb,cAAc,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,GACrD,OAAO,CAAC,gBAAgB,CAAC,gCAAgC,CAAC;IAM7D;;;;;;OAMG;IACU,2BAA2B,CACtC,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,GACrD,OAAO,CAAC,gBAAgB,CAAC,gCAAgC,CAAC;IAM7D;;;;;OAKG;YACW,qBAAqB;CA6BpC"}
1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AAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,gCAAgC,CAAC;IAW7D;;;;;OAKG;YACW,qBAAqB;CA6BpC"}
@@ -11,9 +11,10 @@ const transactions_factory_1 = require("./transactions-factory");
11
11
  * Implementation of TransactionManager layer without encryption
12
12
  */
13
13
  class TransactionManager {
14
- constructor(dataAccess, decryptionProvider) {
14
+ constructor(dataAccess, decryptionProvider, cipherProvider) {
15
15
  this.dataAccess = dataAccess;
16
- this.channelParser = new channel_parser_1.default(decryptionProvider);
16
+ this.channelParser = new channel_parser_1.default(decryptionProvider, cipherProvider);
17
+ this.cipherProvider = cipherProvider;
17
18
  }
18
19
  /**
19
20
  * Persists a transaction and topics in storage. If encryptionParams is given, the transaction will be encrypted
@@ -39,7 +40,7 @@ class TransactionManager {
39
40
  }
40
41
  else {
41
42
  // create an encrypted channel
42
- transaction = yield transactions_factory_1.default.createEncryptedTransactionInNewChannel(transactionData, encryptionParams);
43
+ transaction = yield transactions_factory_1.default.createEncryptedTransactionInNewChannel(transactionData, encryptionParams, this.cipherProvider);
43
44
  channelEncryptionMethod = transaction.encryptionMethod;
44
45
  }
45
46
  // Add the transaction to an existing channel
@@ -58,7 +59,7 @@ class TransactionManager {
58
59
  if (!channelKey) {
59
60
  throw new Error(`Impossible to decrypt the channel key of: ${channelId}`);
60
61
  }
61
- transaction = yield transactions_factory_1.default.createEncryptedTransaction(transactionData, channelKey, encryptionParams);
62
+ transaction = yield transactions_factory_1.default.createEncryptedTransaction(transactionData, channelKey, encryptionParams, this.cipherProvider);
62
63
  channelEncryptionMethod = encryptionMethod;
63
64
  }
64
65
  }
@@ -131,9 +132,9 @@ class TransactionManager {
131
132
  * @param updatedBetween filter the channel whose received new data in the boundaries
132
133
  * @returns list of channels indexed by topic
133
134
  */
134
- getChannelsByTopic(topic, updatedBetween) {
135
+ getChannelsByTopic(topic, updatedBetween, page, pageSize) {
135
136
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
136
- const resultGetTx = yield this.dataAccess.getChannelsByTopic(topic, updatedBetween);
137
+ const resultGetTx = yield this.dataAccess.getChannelsByTopic(topic, updatedBetween, page, pageSize);
137
138
  return this.parseMultipleChannels(resultGetTx);
138
139
  });
139
140
  }
@@ -144,9 +145,9 @@ class TransactionManager {
144
145
  * @param updatedBetween filter the channel whose hasn't received new data in the boundaries
145
146
  * @returns list of channels indexed by topics
146
147
  */
147
- getChannelsByMultipleTopics(topics, updatedBetween) {
148
+ getChannelsByMultipleTopics(topics, updatedBetween, page, pageSize) {
148
149
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
149
- const resultGetTx = yield this.dataAccess.getChannelsByMultipleTopics(topics, updatedBetween);
150
+ const resultGetTx = yield this.dataAccess.getChannelsByMultipleTopics(topics, updatedBetween, page, pageSize);
150
151
  return this.parseMultipleChannels(resultGetTx);
151
152
  });
152
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-manager.js","sourceRoot":"","sources":["../src/transaction-manager.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,iDAK+B;AAC/B,iDAA+D;AAE/D,mCAAsC;AAEtC,qDAA6C;AAC7C,iEAAyD;AAEzD;;GAEG;AACH,MAAqB,kBAAkB;IAIrC,YACE,UAAuC,EACvC,kBAAgE;QAEhE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAa,CAAC,kBAAkB,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACU,kBAAkB,CAC7B,eAAkD,EAClD,SAAiB,EACjB,SAAmB,EAAE,EACrB,mBAA4D,EAAE;;YAE9D,IAAI,WAAW,GAA2C,EAAE,CAAC;YAC7D,IAAI,uBAA2C,CAAC;YAEhD,uCAAuC;YACvC,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAA,8BAAsB,EAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YA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,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CACtE,CAAO,kBAAkB,EAAE,SAAS,EAAE,EAAE;gBACtC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAC7D,SAAS,EACT,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAC3C,CAAC;gBAEF,oGAAoG;gBACpG,MAAM,WAAW,GAAQ,MAAM,kBAAkB,CAAC;gBAElD,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;gBAC3D,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;gBACzE,OAAO,WAAW,CAAC;YACrB,CAAC,CAAA,EACD,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC,CAC/D,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE;oBACJ,cAAc,EAAE,WAAW,CAAC,IAAI;oBAChC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;iBAChD;gBACD,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE;aAC9C,CAAC;QACJ,CAAC;KAAA;CACF;AAvPD,qCAuPC"}
@@ -1,4 +1,4 @@
1
- import { EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
1
+ import { CipherProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
2
2
  /**
3
3
  * Class to create transactions (clear and encrypted)
4
4
  */
@@ -17,7 +17,7 @@ export default class TransactionsFactory {
17
17
  * @param encryptionParams Array of the encryption parameters to encrypt the key with
18
18
  * @returns the encrypted transaction
19
19
  */
20
- static createEncryptedTransactionInNewChannel(data: TransactionTypes.ITransactionData, encryptionParams: EncryptionTypes.IEncryptionParameters[]): Promise<TransactionTypes.IPersistedTransaction>;
20
+ static createEncryptedTransactionInNewChannel(data: TransactionTypes.ITransactionData, encryptionParams: EncryptionTypes.IEncryptionParameters[], cipherProvider?: CipherProviderTypes.ICipherProvider): Promise<TransactionTypes.IPersistedTransaction>;
21
21
  /**
22
22
  * Creates an encrypted transaction with a channel key
23
23
  *
@@ -27,6 +27,6 @@ export default class TransactionsFactory {
27
27
 
28
28
  * @returns the encrypted transaction
29
29
  */
30
- static createEncryptedTransaction(data: TransactionTypes.ITransactionData, channelKey: EncryptionTypes.IEncryptionParameters, encryptionParams?: EncryptionTypes.IEncryptionParameters[]): Promise<TransactionTypes.IPersistedTransaction>;
30
+ static createEncryptedTransaction(data: TransactionTypes.ITransactionData, channelKey: EncryptionTypes.IEncryptionParameters, encryptionParams?: EncryptionTypes.IEncryptionParameters[], cipherProvider?: CipherProviderTypes.ICipherProvider): Promise<TransactionTypes.IPersistedTransaction>;
31
31
  }
32
32
  //# sourceMappingURL=transactions-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactions-factory.d.ts","sourceRoot":"","sources":["../src/transactions-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO1E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC;;;;;OAKG;WACiB,sBAAsB,CACxC,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,GACtC,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;IAUlD;;;;;;OAMG;WACiB,sCAAsC,CACxD,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,EACvC,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,EAAE,GACxD,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;IAuElD;;;;;;;;OAQG;WACiB,0BAA0B,CAC5C,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,EACvC,UAAU,EAAE,eAAe,CAAC,qBAAqB,EACjD,gBAAgB,GAAE,eAAe,CAAC,qBAAqB,EAAO,GAC7D,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;CAyEnD"}
1
+ {"version":3,"file":"transactions-factory.d.ts","sourceRoot":"","sources":["../src/transactions-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO/F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC;;;;;OAKG;WACiB,sBAAsB,CACxC,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,GACtC,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;IAUlD;;;;;;OAMG;WACiB,sCAAsC,CACxD,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,EACvC,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,EAAE,EACzD,cAAc,CAAC,EAAE,mBAAmB,CAAC,eAAe,GACnD,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;IAsHlD;;;;;;;;OAQG;WACiB,0BAA0B,CAC5C,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,EACvC,UAAU,EAAE,eAAe,CAAC,qBAAqB,EACjD,gBAAgB,GAAE,eAAe,CAAC,qBAAqB,EAAO,EAC9D,cAAc,CAAC,EAAE,mBAAmB,CAAC,eAAe,GACnD,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;CAoHnD"}
@@ -32,10 +32,8 @@ class TransactionsFactory {
32
32
  * @param encryptionParams Array of the encryption parameters to encrypt the key with
33
33
  * @returns the encrypted transaction
34
34
  */
35
- static createEncryptedTransactionInNewChannel(data, encryptionParams) {
35
+ static createEncryptedTransactionInNewChannel(data, encryptionParams, cipherProvider) {
36
36
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- // format encryption method property
38
- const encryptionMethod = `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`;
39
37
  // Generate a key for the AES encryption
40
38
  const symmetricKey = yield (0, utils_1.generate32BufferKey)();
41
39
  // Encrypt the data with the key and the AES256-GCM algorithm
@@ -49,24 +47,59 @@ class TransactionsFactory {
49
47
  catch (error) {
50
48
  throw new Error('Data not parsable');
51
49
  }
52
- // Check that all the encryption parameters given are ECIES (the only encryption method supported for now)
53
- if (!encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.ECIES)) {
54
- throw new Error(`encryptionParams method must be all: ${types_1.EncryptionTypes.METHOD.ECIES}`);
50
+ let encryptionMethod = '';
51
+ let keys = {};
52
+ // TODO: refactor this part once the decryption provider is removed and the cipher provider is used
53
+ if (encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.ECIES)) {
54
+ encryptionMethod = `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`;
55
+ // Compute key encryption and identity hash for every encryption parameters given
56
+ const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) => tslib_1.__awaiter(this, void 0, void 0, function* () {
57
+ const identityEncryption = (0, utils_1.getIdentityFromEncryptionParams)(encryptionParam);
58
+ const multiFormattedIdentity = MultiFormat.serialize(identityEncryption);
59
+ if (cipherProvider &&
60
+ 'supportedMethods' in cipherProvider &&
61
+ 'supportedIdentityTypes' in cipherProvider &&
62
+ 'isIdentityRegistered' in cipherProvider) {
63
+ const encryptedKey = yield cipherProvider.encrypt(symmetricKey, { encryptionParams });
64
+ return { encryptedKey, multiFormattedIdentity };
65
+ }
66
+ else {
67
+ const encryptedKey = yield (0, utils_1.encrypt)(symmetricKey, encryptionParam);
68
+ return { encryptedKey, multiFormattedIdentity };
69
+ }
70
+ }));
71
+ const encryptedKeyAndIdentityHashes = yield Promise.all(encryptedKeyAndIdentityHashesPromises);
72
+ // Create the encrypted keys object - Encrypted keys indexed by identity multi-format
73
+ keys = encryptedKeyAndIdentityHashes.reduce((allKeys, keyAndHash) => {
74
+ const encryptedKeySerialized = MultiFormat.serialize(keyAndHash.encryptedKey);
75
+ allKeys[keyAndHash.multiFormattedIdentity] = encryptedKeySerialized;
76
+ return allKeys;
77
+ }, {});
78
+ }
79
+ else if (encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.KMS)) {
80
+ encryptionMethod = `${types_1.EncryptionTypes.METHOD.KMS}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`;
81
+ if (!cipherProvider) {
82
+ throw new Error('cipherProvider is required for KMS encryption');
83
+ }
84
+ const encryptResponse = yield cipherProvider.encrypt(symmetricKey, {
85
+ encryptionParams,
86
+ });
87
+ if (!encryptResponse) {
88
+ throw new Error('Invalid encryption response from cipher provider');
89
+ }
90
+ keys = Object.fromEntries(encryptionParams.map((encryptionParam) => {
91
+ return [
92
+ encryptionParam.key,
93
+ MultiFormat.serialize({
94
+ type: types_1.EncryptionTypes.METHOD.KMS,
95
+ value: JSON.stringify(encryptResponse),
96
+ }),
97
+ ];
98
+ }));
99
+ }
100
+ else {
101
+ throw new Error(`encryptionParams method must be all: ${types_1.EncryptionTypes.METHOD.ECIES} or ${types_1.EncryptionTypes.METHOD.KMS}`);
55
102
  }
56
- // Compute key encryption and identity hash for every encryption parameters given
57
- const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) => tslib_1.__awaiter(this, void 0, void 0, function* () {
58
- const encryptedKey = yield (0, utils_1.encrypt)(symmetricKey, encryptionParam);
59
- const identityEncryption = (0, utils_1.getIdentityFromEncryptionParams)(encryptionParam);
60
- const multiFormattedIdentity = MultiFormat.serialize(identityEncryption);
61
- return { encryptedKey, multiFormattedIdentity };
62
- }));
63
- const encryptedKeyAndIdentityHashes = yield Promise.all(encryptedKeyAndIdentityHashesPromises);
64
- // Create the encrypted keys object - Encrypted keys indexed by identity multi-format
65
- const keys = encryptedKeyAndIdentityHashes.reduce((allKeys, keyAndHash) => {
66
- const encryptedKeySerialized = MultiFormat.serialize(keyAndHash.encryptedKey);
67
- allKeys[keyAndHash.multiFormattedIdentity] = encryptedKeySerialized;
68
- return allKeys;
69
- }, {});
70
103
  const encryptedDataSerialized = MultiFormat.serialize(encryptedData);
71
104
  return { encryptedData: encryptedDataSerialized, keys, encryptionMethod };
72
105
  });
@@ -80,7 +113,7 @@ class TransactionsFactory {
80
113
 
81
114
  * @returns the encrypted transaction
82
115
  */
83
- static createEncryptedTransaction(data, channelKey, encryptionParams = []) {
116
+ static createEncryptedTransaction(data, channelKey, encryptionParams = [], cipherProvider) {
84
117
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
85
118
  // check if the encryption method is the good one
86
119
  if (channelKey.method !== types_1.EncryptionTypes.METHOD.AES256_GCM) {
@@ -95,29 +128,61 @@ class TransactionsFactory {
95
128
  throw new Error('Data not parsable');
96
129
  }
97
130
  const encryptedDataSerialized = MultiFormat.serialize(encryptedData);
131
+ let keys = {};
98
132
  if (encryptionParams.length === 0) {
99
133
  return { encryptedData: encryptedDataSerialized };
100
134
  }
101
135
  else {
102
136
  // FIXME: Refactor, duplicated from createEncryptedTransactionInNewChannel
103
137
  // Check that all the encryption parameters given are ECIES (the only encryption method supported for now)
104
- if (!encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.ECIES)) {
105
- throw new Error(`encryptionParams method must be all: ${types_1.EncryptionTypes.METHOD.ECIES}`);
138
+ if (encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.ECIES)) {
139
+ // Compute key encryption and identity hash for every encryption parameters given
140
+ const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) => tslib_1.__awaiter(this, void 0, void 0, function* () {
141
+ const identityEncryption = (0, utils_1.getIdentityFromEncryptionParams)(encryptionParam);
142
+ const multiFormattedIdentity = MultiFormat.serialize(identityEncryption);
143
+ if (cipherProvider &&
144
+ 'supportedMethods' in cipherProvider &&
145
+ 'supportedIdentityTypes' in cipherProvider &&
146
+ 'isIdentityRegistered' in cipherProvider) {
147
+ const encryptedKey = yield cipherProvider.encrypt(channelKey.key, { encryptionParams });
148
+ return { encryptedKey, multiFormattedIdentity };
149
+ }
150
+ else {
151
+ const encryptedKey = yield (0, utils_1.encrypt)(channelKey.key, encryptionParam);
152
+ return { encryptedKey, multiFormattedIdentity };
153
+ }
154
+ }));
155
+ const encryptedKeyAndIdentityHashes = yield Promise.all(encryptedKeyAndIdentityHashesPromises);
156
+ // Create the encrypted keys object - Encrypted keys indexed by identity multi-format
157
+ keys = encryptedKeyAndIdentityHashes.reduce((allKeys, keyAndHash) => {
158
+ const encryptedKeySerialized = MultiFormat.serialize(keyAndHash.encryptedKey);
159
+ allKeys[keyAndHash.multiFormattedIdentity] = encryptedKeySerialized;
160
+ return allKeys;
161
+ }, {});
162
+ }
163
+ else if (encryptionParams.every((encryptionParam) => encryptionParam.method === types_1.EncryptionTypes.METHOD.KMS)) {
164
+ if (!cipherProvider) {
165
+ throw new Error('cipherProvider is required for KMS encryption');
166
+ }
167
+ const encryptResponse = yield cipherProvider.encrypt(channelKey.key, {
168
+ encryptionParams,
169
+ });
170
+ if (!encryptResponse) {
171
+ throw new Error('Invalid encryption response from cipher provider');
172
+ }
173
+ keys = Object.fromEntries(encryptionParams.map((encryptionParam) => {
174
+ return [
175
+ encryptionParam.key,
176
+ MultiFormat.serialize({
177
+ type: types_1.EncryptionTypes.METHOD.KMS,
178
+ value: JSON.stringify(encryptResponse),
179
+ }),
180
+ ];
181
+ }));
182
+ }
183
+ else {
184
+ throw new Error(`encryptionParams method must be all: ${types_1.EncryptionTypes.METHOD.ECIES} or ${types_1.EncryptionTypes.METHOD.KMS}`);
106
185
  }
107
- // Compute key encryption and identity hash for every encryption parameters given
108
- const encryptedKeyAndIdentityHashesPromises = encryptionParams.map((encryptionParam) => tslib_1.__awaiter(this, void 0, void 0, function* () {
109
- const encryptedKey = yield (0, utils_1.encrypt)(channelKey.key, encryptionParam);
110
- const identityEncryption = (0, utils_1.getIdentityFromEncryptionParams)(encryptionParam);
111
- const multiFormattedIdentity = MultiFormat.serialize(identityEncryption);
112
- return { encryptedKey, multiFormattedIdentity };
113
- }));
114
- const encryptedKeyAndIdentityHashes = yield Promise.all(encryptedKeyAndIdentityHashesPromises);
115
- // Create the encrypted keys object - Encrypted keys indexed by identity multi-format
116
- const keys = encryptedKeyAndIdentityHashes.reduce((allKeys, keyAndHash) => {
117
- const encryptedKeySerialized = MultiFormat.serialize(keyAndHash.encryptedKey);
118
- allKeys[keyAndHash.multiFormattedIdentity] = encryptedKeySerialized;
119
- return allKeys;
120
- }, {});
121
186
  return { encryptedData: encryptedDataSerialized, keys };
122
187
  }
123
188
  });
@@ -1 +1 @@
1
- {"version":3,"file":"transactions-factory.js","sourceRoot":"","sources":["../src/transactions-factory.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,iDAA0E;AAC1E,iDAI+B;AAE/B;;GAEG;AACH,MAAqB,mBAAmB;IACtC;;;;;OAKG;IACI,MAAM,CAAO,sBAAsB,CACxC,IAAuC;;YAEvC,IAAI;gBACF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAClB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;aACtC;YAED,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,CAAC;KAAA;IAED;;;;;;OAMG;IACI,MAAM,CAAO,sCAAsC,CACxD,IAAuC,EACvC,gBAAyD;;YAEzD,oCAAoC;YACpC,MAAM,gBAAgB,GAAG,GAAG,uBAAe,CAAC,MAAM,CAAC,KAAK,IAAI,uBAAe,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAEhG,wCAAwC;YACxC,MAAM,YAAY,GAAW,MAAM,IAAA,2BAAmB,GAAE,CAAC;YAEzD,6DAA6D;YAC7D,MAAM,aAAa,GAAmC,MAAM,IAAA,eAAO,EAAC,IAAI,EAAE;gBACxE,GAAG,EAAE,YAAY;gBACjB,MAAM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AAM,YAAY,GAAmC,MAAM,IAAA,eAAO,EAChE,UAAU,CAAC,GAAG,EACd,eAAe,CAChB,CAAC;oBACF,MAAM,kBAAkB,GAAG,IAAA,uCAA+B,EAAC,eAAe,CAAC,CAAC;oBAC5E,MAAM,sBAAsB,GAAW,WAAW,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;oBAEjF,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC;gBAClD,CAAC,CAAA,CACF,CAAC;gBACF,MAAM,6BAA6B,GAAG,MAAM,OAAO,CAAC,GAAG,CACrD,qCAAqC,CACtC,CAAC;gBAEF,qFAAqF;gBACrF,MAAM,IAAI,GAAqC,6BAA6B,CAAC,MAAM,CACjF,CACE,OAAyC,EACzC,UAGC,EACiC,EAAE;oBACpC,MAAM,sBAAsB,GAAW,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;oBAEtF,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;oBACpE,OAAO,OAAO,CAAC;gBACjB,CAAC,EACD,EAAE,CACH,CAAC;gBAEF,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC;aACzD;QACH,CAAC;KAAA;CACF;AA1LD,sCA0LC"}
1
+ {"version":3,"file":"transactions-factory.js","sourceRoot":"","sources":["../src/transactions-factory.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,iDAA+F;AAC/F,iDAI+B;AAE/B;;GAEG;AACH,MAAqB,mBAAmB;IACtC;;;;;OAKG;IACI,MAAM,CAAO,sBAAsB,CACxC,IAAuC;;YAEvC,IAAI;gBACF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAClB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;aACtC;YAED,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,CAAC;KAAA;IAED;;;;;;OA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AAG,sBAAsB,CAAC;wBACpE,OAAO,OAAO,CAAC;oBACjB,CAAC,EACD,EAAE,CACH,CAAC;iBACH;qBAAM,IACL,gBAAgB,CAAC,KAAK,CACpB,CAAC,eAAsD,EAAE,EAAE,CACzD,eAAe,CAAC,MAAM,KAAK,uBAAe,CAAC,MAAM,CAAC,GAAG,CACxD,EACD;oBACA,IAAI,CAAC,cAAc,EAAE;wBACnB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;qBAClE;oBACD,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE;wBACnE,gBAAgB;qBACjB,CAAC,CAAC;oBAEH,IAAI,CAAC,eAAe,EAAE;wBACpB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;qBACrE;oBACD,IAAI,GAAG,MAAM,CAAC,WAAW,CACvB,gBAAgB,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE;wBACvC,OAAO;4BACL,eAAe,CAAC,GAAG;4BACnB,WAAW,CAAC,SAAS,CAAC;gCACpB,IAAI,EAAE,uBAAe,CAAC,MAAM,CAAC,GAAG;gCAChC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;6BACvC,CAAC;yBACH,CAAC;oBACJ,CAAC,CAAC,CACH,CAAC;iBACH;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,wCAAwC,uBAAe,CAAC,MAAM,CAAC,KAAK,OAAO,uBAAe,CAAC,MAAM,CAAC,GAAG,EAAE,CACxG,CAAC;iBACH;gBAED,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC;aACzD;QACH,CAAC;KAAA;CACF;AAtRD,sCAsRC"}
@@ -1,10 +1,11 @@
1
- import { DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
1
+ import { CipherProviderTypes, DecryptionProviderTypes, EncryptionTypes, TransactionTypes } from '@requestnetwork/types';
2
2
  /**
3
3
  * Class to parse transactions
4
4
  */
5
5
  export default class TransactionsParser {
6
6
  private decryptionProvider;
7
- constructor(decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider);
7
+ private cipherProvider;
8
+ constructor(decryptionProvider?: DecryptionProviderTypes.IDecryptionProvider, cipherProvider?: CipherProviderTypes.ICipherProvider);
8
9
  /**
9
10
  * Parses a persisted transaction into a ClearTransaction or EncryptedTransaction, and decrypts the channel key if needed
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"transactions-parser.d.ts","sourceRoot":"","sources":["../src/transactions-parser.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC,OAAO,CAAC,kBAAkB,CAA0D;gBAExE,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB;IAI5E;;;;;;;;OAQG;IACU,yBAAyB,CACpC,oBAAoB,EAAE,gBAAgB,CAAC,qBAAqB,EAC5D,WAAW,EAAE,gBAAgB,CAAC,WAAW,EACzC,UAAU,CAAC,EAAE,eAAe,CAAC,qBAAqB,EAClD,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;QACT,WAAW,EAAE,gBAAgB,CAAC,YAAY,CAAC;QAC3C,UAAU,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;QACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IA4EF;;;;;;OAMG;YACW,iBAAiB;CAkEhC"}
1
+ {"version":3,"file":"transactions-parser.d.ts","sourceRoot":"","sources":["../src/transactions-parser.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EAEf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC,OAAO,CAAC,kBAAkB,CAA0D;IACpF,OAAO,CAAC,cAAc,CAAkD;gBAGtE,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB,EAChE,cAAc,CAAC,EAAE,mBAAmB,CAAC,eAAe;IAMtD;;;;;;;;OAQG;IACU,yBAAyB,CACpC,oBAAoB,EAAE,gBAAgB,CAAC,qBAAqB,EAC5D,WAAW,EAAE,gBAAgB,CAAC,WAAW,EACzC,UAAU,CAAC,EAAE,eAAe,CAAC,qBAAqB,EAClD,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;QACT,WAAW,EAAE,gBAAgB,CAAC,YAAY,CAAC;QAC3C,UAAU,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;QACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IAmFF;;;;;;OAMG;YACW,iBAAiB;CAkHhC"}
@@ -9,8 +9,9 @@ const encrypted_transaction_1 = require("./encrypted-transaction");
9
9
  * Class to parse transactions
10
10
  */
11
11
  class TransactionsParser {
12
- constructor(decryptionProvider) {
12
+ constructor(decryptionProvider, cipherProvider) {
13
13
  this.decryptionProvider = decryptionProvider;
14
+ this.cipherProvider = cipherProvider;
14
15
  }
15
16
  /**
16
17
  * Parses a persisted transaction into a ClearTransaction or EncryptedTransaction, and decrypts the channel key if needed
@@ -37,45 +38,51 @@ class TransactionsParser {
37
38
  }
38
39
  // looks like an encrypted transaction
39
40
  if (persistedTransaction.encryptedData) {
40
- if (channelType === types_1.TransactionTypes.ChannelType.CLEAR) {
41
- throw new Error('Encrypted transactions are not allowed in clear channel');
42
- }
43
- // no channel key, try to decrypt it and validate encryption method
44
- if (!channelKey) {
45
- // no encryptionMethod, this is first tx, must contain encryptionMethod
46
- if (!encryptionMethod) {
47
- if (!persistedTransaction.encryptionMethod || !persistedTransaction.keys) {
48
- throw new Error('the properties "encryptionMethod" and "keys" are needed to compute the channel key');
41
+ if ((this.cipherProvider && this.cipherProvider.isDecryptionAvailable()) ||
42
+ !this.cipherProvider) {
43
+ if (channelType === types_1.TransactionTypes.ChannelType.CLEAR) {
44
+ throw new Error('Encrypted transactions are not allowed in clear channel');
45
+ }
46
+ // no channel key, try to decrypt it and validate encryption method
47
+ if (!channelKey) {
48
+ // no encryptionMethod, this is first tx, must contain encryptionMethod
49
+ if (!encryptionMethod) {
50
+ if (!persistedTransaction.encryptionMethod || !persistedTransaction.keys) {
51
+ throw new Error('the properties "encryptionMethod" and "keys" are needed to compute the channel key');
52
+ }
53
+ encryptionMethod = persistedTransaction.encryptionMethod;
54
+ channelKey = yield this.decryptChannelKey(persistedTransaction.keys, encryptionMethod);
55
+ }
56
+ // given encryptionMethod, this not first tx, must not contain encryptionMethod
57
+ else {
58
+ if (persistedTransaction.encryptionMethod) {
59
+ throw new Error('the "encryptionMethod" property has been already given for this channel');
60
+ }
61
+ if (!persistedTransaction.keys) {
62
+ throw new Error('the "keys" property is needed to compute the channel key');
63
+ }
64
+ channelKey = yield this.decryptChannelKey(persistedTransaction.keys, encryptionMethod);
49
65
  }
50
- encryptionMethod = persistedTransaction.encryptionMethod;
51
- channelKey = yield this.decryptChannelKey(persistedTransaction.keys, encryptionMethod);
52
66
  }
53
- // given encryptionMethod, this not first tx, must not contain encryptionMethod
67
+ // given channel key, validate encryption method
54
68
  else {
55
- if (persistedTransaction.encryptionMethod) {
56
- throw new Error('the "encryptionMethod" property has been already given for this channel');
69
+ // no encryptionMethod, this is first tx, must contain encryptionMethod
70
+ if (!encryptionMethod) {
71
+ if (!persistedTransaction.encryptionMethod) {
72
+ throw new Error('the "encryptionMethod" property is needed to use the channel key');
73
+ }
74
+ encryptionMethod = persistedTransaction.encryptionMethod;
57
75
  }
58
- if (!persistedTransaction.keys) {
59
- throw new Error('the "keys" property is needed to compute the channel key');
76
+ // given encryptionMethod, this not first tx, must not contain encryptionMethod
77
+ else {
78
+ if (persistedTransaction.encryptionMethod) {
79
+ throw new Error('the "encryptionMethod" property has been already given for this channel');
80
+ }
60
81
  }
61
- channelKey = yield this.decryptChannelKey(persistedTransaction.keys, encryptionMethod);
62
82
  }
63
83
  }
64
- // given channel key, validate encryption method
65
84
  else {
66
- // no encryptionMethod, this is first tx, must contain encryptionMethod
67
- if (!encryptionMethod) {
68
- if (!persistedTransaction.encryptionMethod) {
69
- throw new Error('the "encryptionMethod" property is needed to use the channel key');
70
- }
71
- encryptionMethod = persistedTransaction.encryptionMethod;
72
- }
73
- // given encryptionMethod, this not first tx, must not contain encryptionMethod
74
- else {
75
- if (persistedTransaction.encryptionMethod) {
76
- throw new Error('the "encryptionMethod" property has been already given for this channel');
77
- }
78
- }
85
+ throw new Error('Decryption is not available');
79
86
  }
80
87
  return {
81
88
  channelKey,
@@ -95,51 +102,91 @@ class TransactionsParser {
95
102
  */
96
103
  decryptChannelKey(keys, encryptionMethod) {
97
104
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
98
- // Check if the decryption provider is given
99
- if (!this.decryptionProvider) {
100
- throw new Error(`No decryption provider given`);
101
- }
105
+ let errorReason = '';
106
+ let channelKey = '';
102
107
  let channelKeyMethod;
103
- // Check the encryption method
104
- if (encryptionMethod === `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_CBC}`) {
105
- channelKeyMethod = types_1.EncryptionTypes.METHOD.AES256_CBC;
106
- }
107
- else if (encryptionMethod === `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`) {
108
- channelKeyMethod = types_1.EncryptionTypes.METHOD.AES256_GCM;
108
+ if (this.cipherProvider &&
109
+ encryptionMethod === `${types_1.EncryptionTypes.METHOD.KMS}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`) {
110
+ const entries = Object.entries(keys);
111
+ if (entries.length === 0) {
112
+ throw new Error('No encryption keys provided');
113
+ }
114
+ let encryptResponse;
115
+ try {
116
+ encryptResponse = JSON.parse(MultiFormat.deserialize(entries[0][1]).value);
117
+ }
118
+ catch (e) {
119
+ throw new Error('Invalid encryption response format');
120
+ }
121
+ const encryptionParams = entries.map((entry) => {
122
+ return {
123
+ method: types_1.EncryptionTypes.METHOD.KMS,
124
+ key: entry[0],
125
+ };
126
+ });
127
+ try {
128
+ channelKey = yield this.cipherProvider.decrypt(encryptResponse, {
129
+ encryptionParams,
130
+ });
131
+ channelKeyMethod = types_1.EncryptionTypes.METHOD.AES256_GCM;
132
+ }
133
+ catch (e) {
134
+ errorReason = e.message;
135
+ }
109
136
  }
110
137
  else {
111
- throw new Error(`Encryption method not supported: ${encryptionMethod}`);
112
- }
113
- let errorReason = '';
114
- // Try to decrypt the channelKey
115
- const channelKey = yield Object.keys(keys || {}).reduce((decryptedChannelKeyPromise, identityMultiFormatted) => tslib_1.__awaiter(this, void 0, void 0, function* () {
116
- let decryptedChannelKey = yield decryptedChannelKeyPromise;
117
- if (keys && decryptedChannelKey === '') {
118
- let identity;
119
- try {
120
- identity = MultiFormat.deserialize(identityMultiFormatted);
121
- }
122
- catch (e) {
123
- // if we cannot deserialize it, just ignore this identity
124
- }
125
- // Ignore what is not an identity Ethereum address
126
- if (identity && identity.type === types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS) {
127
- // Check if we can decrypt the key with this identity
128
- if (this.decryptionProvider &&
129
- (yield this.decryptionProvider.isIdentityRegistered(identity))) {
130
- try {
131
- const key = MultiFormat.deserialize(keys[identityMultiFormatted]);
132
- decryptedChannelKey = yield this.decryptionProvider.decrypt(key, identity);
133
- }
134
- catch (e) {
135
- errorReason = e.message;
138
+ // Check if the decryption provider is given
139
+ if (!this.decryptionProvider && !this.cipherProvider) {
140
+ throw new Error(`No decryption or cipher provider given`);
141
+ }
142
+ // Check the encryption method
143
+ if (encryptionMethod === `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_CBC}`) {
144
+ channelKeyMethod = types_1.EncryptionTypes.METHOD.AES256_CBC;
145
+ }
146
+ else if (encryptionMethod === `${types_1.EncryptionTypes.METHOD.ECIES}-${types_1.EncryptionTypes.METHOD.AES256_GCM}`) {
147
+ channelKeyMethod = types_1.EncryptionTypes.METHOD.AES256_GCM;
148
+ }
149
+ else {
150
+ throw new Error(`Encryption method not supported: ${encryptionMethod}`);
151
+ }
152
+ // Try to decrypt the channelKey
153
+ channelKey = yield Object.keys(keys || {}).reduce((decryptedChannelKeyPromise, identityMultiFormatted) => tslib_1.__awaiter(this, void 0, void 0, function* () {
154
+ var _a;
155
+ let decryptedChannelKey = yield decryptedChannelKeyPromise;
156
+ if (keys && decryptedChannelKey === '') {
157
+ let identity;
158
+ try {
159
+ identity = MultiFormat.deserialize(identityMultiFormatted);
160
+ }
161
+ catch (e) {
162
+ // if we cannot deserialize it, just ignore this identity
163
+ }
164
+ // Ignore what is not an identity Ethereum address
165
+ if (identity && identity.type === types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS) {
166
+ // Check if we can decrypt the key with this identity
167
+ if ((this.decryptionProvider &&
168
+ (yield this.decryptionProvider.isIdentityRegistered(identity))) ||
169
+ (this.cipherProvider &&
170
+ typeof this.cipherProvider.isIdentityRegistered === 'function' &&
171
+ (yield this.cipherProvider.isIdentityRegistered(identity)))) {
172
+ try {
173
+ const key = MultiFormat.deserialize(keys[identityMultiFormatted]);
174
+ decryptedChannelKey = this.cipherProvider
175
+ ? yield this.cipherProvider.decrypt(key, {
176
+ identity,
177
+ })
178
+ : yield ((_a = this.decryptionProvider) === null || _a === void 0 ? void 0 : _a.decrypt(key, identity));
179
+ }
180
+ catch (e) {
181
+ errorReason = e.message;
182
+ }
136
183
  }
137
184
  }
138
185
  }
139
- }
140
- return decryptedChannelKey;
141
- }), Promise.resolve(''));
142
- if (channelKey === '') {
186
+ return decryptedChannelKey;
187
+ }), Promise.resolve(''));
188
+ }
189
+ if (channelKey === '' || !channelKeyMethod) {
143
190
  throw new Error(`Impossible to decrypt the channel key from this transaction (${errorReason})`);
144
191
  }
145
192
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"transactions-parser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,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;6BAC5E;4BAAC,OAAO,CAAC,EAAE;gCACV,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC;6BACzB;yBACF;qBACF;iBACF;gBACD,OAAO,mBAAmB,CAAC;YAC7B,CAAC,CAAA,EACD,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CACpB,CAAC;YAEF,IAAI,UAAU,KAAK,EAAE,EAAE;gBACrB,MAAM,IAAI,KAAK,CACb,gEAAgE,WAAW,GAAG,CAC/E,CAAC;aACH;YACD,OAAO;gBACL,GAAG,EAAE,UAAU;gBACf,MAAM,EAAE,gBAAgB;aACzB,CAAC;QACJ,CAAC;KAAA;CACF;AA9KD,qCA8KC"}
1
+ {"version":3,"file":"transactions-parser.js","sourceRoot":"","sources":["../src/transactions-parser.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,iDAM+B;AAE/B,2DAAmD;AACnD,mEAA2D;AAE3D;;GAEG;AACH,MAAqB,kBAAkB;IAIrC,YACE,kBAAgE,EAChE,cAAoD;QAEpD,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;OAQG;IACU,yBAAyB,CACpC,oBAA4D,EAC5D,WAAyC,EACzC,UAAkD,EAClD,gBAAyB;;YAMzB,iCAAiC;YACjC,IAAI,oBAAoB,CAAC,IAAI,EAAE;gBAC7B,IAAI,WAAW,KAAK,wBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE;oBAC1D,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;iBAC5E;gBACD,IACE,oBAAoB,CAAC,aAAa;oBAClC,oBAAoB,CAAC,gBAAgB;oBACrC,oBAAoB,CAAC,IAAI,EACzB;oBACA,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;iBAC9E;gBACD,OAAO,EAA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,OAAO,CAAC,EAAE,CAAC,CACpB,CAAC;aACH;YAED,IAAI,UAAU,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE;gBAC1C,MAAM,IAAI,KAAK,CACb,gEAAgE,WAAW,GAAG,CAC/E,CAAC;aACH;YAED,OAAO;gBACL,GAAG,EAAE,UAAU;gBACf,MAAM,EAAE,gBAAgB;aACzB,CAAC;QACJ,CAAC;KAAA;CACF;AA1OD,qCA0OC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestnetwork/transaction-manager",
3
- "version": "0.36.1",
3
+ "version": "0.37.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,9 +39,9 @@
39
39
  "test:watch": "yarn test --watch"
40
40
  },
41
41
  "dependencies": {
42
- "@requestnetwork/multi-format": "0.19.1",
43
- "@requestnetwork/types": "0.45.1",
44
- "@requestnetwork/utils": "0.45.1",
42
+ "@requestnetwork/multi-format": "0.20.0",
43
+ "@requestnetwork/types": "0.46.0",
44
+ "@requestnetwork/utils": "0.46.0",
45
45
  "tslib": "2.5.0"
46
46
  },
47
47
  "devDependencies": {
@@ -53,5 +53,5 @@
53
53
  "ts-node": "10.9.1",
54
54
  "typescript": "5.1.3"
55
55
  },
56
- "gitHead": "1185e531595cbfa348dce8cf5f2e9d0535931d70"
56
+ "gitHead": "7884e8d54136ca26aae9be637d1d632a9f803487"
57
57
  }