@requestnetwork/utils 0.28.0 → 0.28.1-next.709

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.
Files changed (63) hide show
  1. package/README.md +2 -20
  2. package/dist/amount.d.ts +5 -9
  3. package/dist/amount.d.ts.map +1 -1
  4. package/dist/amount.js +19 -23
  5. package/dist/amount.js.map +1 -1
  6. package/dist/bignumber.d.ts +7 -0
  7. package/dist/bignumber.d.ts.map +1 -0
  8. package/dist/bignumber.js +11 -0
  9. package/dist/bignumber.js.map +1 -0
  10. package/dist/cached-throttle.d.ts +2 -2
  11. package/dist/cached-throttle.d.ts.map +1 -1
  12. package/dist/cached-throttle.js +5 -3
  13. package/dist/cached-throttle.js.map +1 -1
  14. package/dist/crypto/crypto-wrapper.d.ts +1 -8
  15. package/dist/crypto/crypto-wrapper.d.ts.map +1 -1
  16. package/dist/crypto/crypto-wrapper.js +19 -31
  17. package/dist/crypto/crypto-wrapper.js.map +1 -1
  18. package/dist/crypto/ec-utils.d.ts +6 -14
  19. package/dist/crypto/ec-utils.d.ts.map +1 -1
  20. package/dist/crypto/ec-utils.js +77 -41
  21. package/dist/crypto/ec-utils.js.map +1 -1
  22. package/dist/crypto.d.ts +14 -26
  23. package/dist/crypto.d.ts.map +1 -1
  24. package/dist/crypto.js +40 -30
  25. package/dist/crypto.js.map +1 -1
  26. package/dist/encryption.d.ts +1 -6
  27. package/dist/encryption.d.ts.map +1 -1
  28. package/dist/encryption.js +15 -27
  29. package/dist/encryption.js.map +1 -1
  30. package/dist/identity.d.ts +4 -9
  31. package/dist/identity.d.ts.map +1 -1
  32. package/dist/identity.js +11 -12
  33. package/dist/identity.js.map +1 -1
  34. package/dist/index.d.ts +12 -69
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +66 -28
  37. package/dist/index.js.map +1 -1
  38. package/dist/normalize-gas-fees.d.ts +19 -0
  39. package/dist/normalize-gas-fees.d.ts.map +1 -0
  40. package/dist/normalize-gas-fees.js +44 -0
  41. package/dist/normalize-gas-fees.js.map +1 -0
  42. package/dist/providers.d.ts +40 -0
  43. package/dist/providers.d.ts.map +1 -0
  44. package/dist/providers.js +149 -0
  45. package/dist/providers.js.map +1 -0
  46. package/dist/retry.d.ts +10 -6
  47. package/dist/retry.d.ts.map +1 -1
  48. package/dist/retry.js +15 -16
  49. package/dist/retry.js.map +1 -1
  50. package/dist/signature.d.ts +3 -8
  51. package/dist/signature.d.ts.map +1 -1
  52. package/dist/signature.js +13 -19
  53. package/dist/signature.js.map +1 -1
  54. package/dist/simple-logger.d.ts +1 -1
  55. package/dist/simple-logger.d.ts.map +1 -1
  56. package/dist/simple-logger.js +4 -3
  57. package/dist/simple-logger.js.map +1 -1
  58. package/dist/utils.d.ts +11 -20
  59. package/dist/utils.d.ts.map +1 -1
  60. package/dist/utils.js +20 -21
  61. package/dist/utils.js.map +1 -1
  62. package/package.json +18 -26
  63. package/CHANGELOG.md +0 -1047
package/README.md CHANGED
@@ -3,24 +3,6 @@
3
3
  `@requestnetwork/utils` is a typescript library part of the [Request Network protocol](https://github.com/RequestNetwork/requestNetwork).
4
4
  It is a collection of tools shared between the @requestnetwork packages.
5
5
 
6
- - Elliptic curve crypto and signature
7
- - crypto.normalizeKeccak256Hash()
8
- - crypto.ecUtils.getAddressFromPrivateKey()
9
- - crypto.ecUtils.recover()
10
- - crypto.ecUtils.sign()
11
- - signature.getIdentityFromSignatureParams()
12
- - signature.recover()
13
- - signature.sign()
14
- - Identity
15
- - identity.areEqual()
16
- - identity.normalizeIdentityValue()
17
- - isString
18
- - Miscellaneous
19
- - deepCopy()
20
- - deepSort()
21
- - flatten2DimensionsArray()
22
- - getCurrentTimestampInSecond()
23
-
24
6
  ## Installation
25
7
 
26
8
  ```bash
@@ -30,9 +12,9 @@ npm install @requestnetwork/utils
30
12
  ## Usage
31
13
 
32
14
  ```javascript
33
- import Utils from '@requestnetwork/utils';
15
+ import { normalizeKeccak256Hash } from '@requestnetwork/utils';
34
16
 
35
- const hash = Utils.crypto.normalizeKeccak256Hash({ exampleData: true });
17
+ const hash = normalizeKeccak256Hash({ exampleData: true });
36
18
  ```
37
19
 
38
20
  ## Contributing
package/dist/amount.d.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  import { RequestLogicTypes } from '@requestnetwork/types';
2
- declare const _default: {
3
- add: typeof add;
4
- isValid: typeof isValid;
5
- reduce: typeof reduce;
6
- };
2
+ import { BigNumber } from 'ethers';
7
3
  /**
8
4
  * Function to manage amounts
9
5
  */
10
- export default _default;
6
+ export { addAmount, isValidAmount, reduceAmount };
11
7
  /**
12
8
  * Function to check if the amount is valid (representation of a positive integer)
13
9
  *
@@ -15,7 +11,7 @@ export default _default;
15
11
  *
16
12
  * @returns boolean true if amount is a valid amount
17
13
  */
18
- declare function isValid(amount: RequestLogicTypes.Amount): boolean;
14
+ declare function isValidAmount(amount: RequestLogicTypes.Amount | BigNumber): boolean;
19
15
  /**
20
16
  * Function to add an amount by another
21
17
  *
@@ -24,7 +20,7 @@ declare function isValid(amount: RequestLogicTypes.Amount): boolean;
24
20
  *
25
21
  * @returns string the new amount in a string format
26
22
  */
27
- declare function add(amount: RequestLogicTypes.Amount, delta: RequestLogicTypes.Amount): string;
23
+ declare function addAmount(amount: RequestLogicTypes.Amount, delta: RequestLogicTypes.Amount): string;
28
24
  /**
29
25
  * Function to reduce an amount by another
30
26
  *
@@ -35,5 +31,5 @@ declare function add(amount: RequestLogicTypes.Amount, delta: RequestLogicTypes.
35
31
  *
36
32
  * @returns string the new amount in a string format
37
33
  */
38
- declare function reduce(amount: RequestLogicTypes.Amount, delta: RequestLogicTypes.Amount): string;
34
+ declare function reduceAmount(amount: RequestLogicTypes.Amount, delta: RequestLogicTypes.Amount): string;
39
35
  //# sourceMappingURL=amount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;;;;;;AAK1D;;GAEG;AACH,wBAIE;AAIF;;;;;;GAMG;AACH,iBAAS,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,GAAG,OAAO,CAK1D;AAED;;;;;;;GAOG;AACH,iBAAS,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAWtF;AAED;;;;;;;;;GASG;AACH,iBAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAiBzF"}
1
+ {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AAIlD;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,GAAG,SAAS,GAAG,OAAO,CAK5E;AAED;;;;;;;GAOG;AACH,iBAAS,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAW5F;AAED;;;;;;;;;GASG;AACH,iBAAS,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAiB/F"}
package/dist/amount.js CHANGED
@@ -1,15 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduceAmount = exports.isValidAmount = exports.addAmount = void 0;
3
4
  const utils_1 = require("./utils");
4
- const bigNumber = require('bn.js');
5
- /**
6
- * Function to manage amounts
7
- */
8
- exports.default = {
9
- add,
10
- isValid,
11
- reduce,
12
- };
5
+ const ethers_1 = require("ethers");
13
6
  const regexInteger = RegExp(/^[\d]+$/);
14
7
  /**
15
8
  * Function to check if the amount is valid (representation of a positive integer)
@@ -18,10 +11,11 @@ const regexInteger = RegExp(/^[\d]+$/);
18
11
  *
19
12
  * @returns boolean true if amount is a valid amount
20
13
  */
21
- function isValid(amount) {
22
- return ((utils_1.default.isString(amount) && regexInteger.test(amount)) ||
23
- (typeof amount === 'number' && (Number.isSafeInteger(Number(amount)) && Number(amount) >= 0)));
14
+ function isValidAmount(amount) {
15
+ return (((0, utils_1.isString)(amount) && regexInteger.test(amount)) ||
16
+ (typeof amount === 'number' && Number.isSafeInteger(Number(amount)) && Number(amount) >= 0));
24
17
  }
18
+ exports.isValidAmount = isValidAmount;
25
19
  /**
26
20
  * Function to add an amount by another
27
21
  *
@@ -30,17 +24,18 @@ function isValid(amount) {
30
24
  *
31
25
  * @returns string the new amount in a string format
32
26
  */
33
- function add(amount, delta) {
34
- if (!isValid(amount)) {
27
+ function addAmount(amount, delta) {
28
+ if (!isValidAmount(amount)) {
35
29
  throw Error('amount must represent a positive integer');
36
30
  }
37
- if (!isValid(delta)) {
31
+ if (!isValidAmount(delta)) {
38
32
  throw Error('delta must represent a positive integer');
39
33
  }
40
- const amountBN = new bigNumber(amount);
41
- const deltaBN = new bigNumber(delta);
34
+ const amountBN = ethers_1.BigNumber.from(amount);
35
+ const deltaBN = ethers_1.BigNumber.from(delta);
42
36
  return amountBN.add(deltaBN).toString();
43
37
  }
38
+ exports.addAmount = addAmount;
44
39
  /**
45
40
  * Function to reduce an amount by another
46
41
  *
@@ -51,20 +46,21 @@ function add(amount, delta) {
51
46
  *
52
47
  * @returns string the new amount in a string format
53
48
  */
54
- function reduce(amount, delta) {
55
- if (!isValid(amount)) {
49
+ function reduceAmount(amount, delta) {
50
+ if (!isValidAmount(amount)) {
56
51
  throw Error('amount must represent a positive integer');
57
52
  }
58
- if (!isValid(delta)) {
53
+ if (!isValidAmount(delta)) {
59
54
  throw Error('delta must represent a positive integer');
60
55
  }
61
- const amountBN = new bigNumber(amount);
62
- const deltaBN = new bigNumber(delta);
56
+ const amountBN = ethers_1.BigNumber.from(amount);
57
+ const deltaBN = ethers_1.BigNumber.from(delta);
63
58
  const newAmount = amountBN.sub(deltaBN).toString();
64
59
  // Check if the new amount is valid (basically it is not negative)
65
- if (!isValid(newAmount)) {
60
+ if (!isValidAmount(newAmount)) {
66
61
  throw Error('result of reduce is not valid');
67
62
  }
68
63
  return newAmount;
69
64
  }
65
+ exports.reduceAmount = reduceAmount;
70
66
  //# sourceMappingURL=amount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"amount.js","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":";;AACA,mCAA4B;AAE5B,MAAM,SAAS,GAAQ,OAAO,CAAC,OAAO,CAAC,CAAC;AAExC;;GAEG;AACH,kBAAe;IACb,GAAG;IACH,OAAO;IACP,MAAM;CACP,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAEvC;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,MAAgC;IAC/C,OAAO,CACL,CAAC,eAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC;QAC/D,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9F,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,GAAG,CAAC,MAAgC,EAAE,KAA+B;IAC5E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACpB,MAAM,KAAK,CAAC,0CAA0C,CAAC,CAAC;KACzD;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,E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,CAAC;KAC9C;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAlEkC,oCAAY"}
@@ -0,0 +1,7 @@
1
+ import { BigNumber, BigNumberish } from 'ethers';
2
+ /** Returns the minimum of two big numbers */
3
+ declare const minBigNumber: (a: BigNumberish, b: BigNumberish) => BigNumber;
4
+ /** Returns the maximum of two big numbers */
5
+ declare const maxBigNumber: (a: BigNumberish, b: BigNumberish) => BigNumber;
6
+ export { minBigNumber, maxBigNumber };
7
+ //# sourceMappingURL=bignumber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bignumber.d.ts","sourceRoot":"","sources":["../src/bignumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEjD,6CAA6C;AAC7C,QAAA,MAAM,YAAY,MAAO,YAAY,KAAK,YAAY,KAAG,SACQ,CAAC;AAElE,6CAA6C;AAC7C,QAAA,MAAM,YAAY,MAAO,YAAY,KAAK,YAAY,KAAG,SACQ,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maxBigNumber = exports.minBigNumber = void 0;
4
+ const ethers_1 = require("ethers");
5
+ /** Returns the minimum of two big numbers */
6
+ const minBigNumber = (a, b) => ethers_1.BigNumber.from(a).lt(b) ? ethers_1.BigNumber.from(a) : ethers_1.BigNumber.from(b);
7
+ exports.minBigNumber = minBigNumber;
8
+ /** Returns the maximum of two big numbers */
9
+ const maxBigNumber = (a, b) => ethers_1.BigNumber.from(a).gt(b) ? ethers_1.BigNumber.from(a) : ethers_1.BigNumber.from(b);
10
+ exports.maxBigNumber = maxBigNumber;
11
+ //# sourceMappingURL=bignumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bignumber.js","sourceRoot":"","sources":["../src/bignumber.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AAEjD,6CAA6C;AAC7C,MAAM,YAAY,GAAG,CAAC,CAAe,EAAE,CAAe,EAAa,EAAE,CACnE,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAMzD,oCAAY;AAJrB,6CAA6C;AAC7C,MAAM,YAAY,GAAG,CAAC,CAAe,EAAE,CAAe,EAAa,EAAE,CACnE,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE3C,oCAAY"}
@@ -1,4 +1,3 @@
1
- declare const _default: (target: any, minimumDelay: number) => any;
2
1
  /**
3
2
  * A method that calls the target function at most once every `minimumDelay` milliseconds and
4
3
  * returns the cached return value in the meantime.
@@ -6,5 +5,6 @@ declare const _default: (target: any, minimumDelay: number) => any;
6
5
  * @param target The target function
7
6
  * @param minimumDelay The minimum delay between calls to the target function in milliseconds
8
7
  */
9
- export default _default;
8
+ declare const cachedThrottle: <TParams extends unknown[], TReturn>(target: (...params: TParams) => Promise<TReturn>, minimumDelay: number) => (...params: TParams) => Promise<TReturn>;
9
+ export { cachedThrottle };
10
10
  //# sourceMappingURL=cached-throttle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cached-throttle.d.ts","sourceRoot":"","sources":["../src/cached-throttle.ts"],"names":[],"mappings":"iCAOwB,GAAG,gBAAgB,MAAM,KAAG,GAAG;AAPvD;;;;;;GAMG;AACH,wBAmBE"}
1
+ {"version":3,"file":"cached-throttle.d.ts","sourceRoot":"","sources":["../src/cached-throttle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,uGAEJ,MAAM,6CAoBrB,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cachedThrottle = void 0;
3
4
  /**
4
5
  * A method that calls the target function at most once every `minimumDelay` milliseconds and
5
6
  * returns the cached return value in the meantime.
@@ -7,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
8
  * @param target The target function
8
9
  * @param minimumDelay The minimum delay between calls to the target function in milliseconds
9
10
  */
10
- exports.default = (target, minimumDelay) => {
11
+ const cachedThrottle = (target, minimumDelay) => {
11
12
  if (!(target instanceof Function)) {
12
13
  throw new Error('Target can only be a function');
13
14
  }
@@ -16,11 +17,12 @@ exports.default = (target, minimumDelay) => {
16
17
  // the last time the function was called
17
18
  let lastCall = Number.NEGATIVE_INFINITY;
18
19
  return (...args) => {
19
- if (Date.now() >= lastCall + minimumDelay) {
20
+ if (!cachedResponse || Date.now() >= lastCall + minimumDelay) {
20
21
  lastCall = Date.now();
21
- cachedResponse = target(args);
22
+ cachedResponse = target(...args);
22
23
  }
23
24
  return cachedResponse;
24
25
  };
25
26
  };
27
+ exports.cachedThrottle = cachedThrottle;
26
28
  //# sourceMappingURL=cached-throttle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cached-throttle.js","sourceRoot":"","sources":["../src/cached-throttle.ts"],"names":[],"mappings":";;AAAA;;;;;;GAMG;AACH,kBAAe,CAAC,MAAW,EAAE,YAAoB,EAAO,EAAE;IACxD,IAAI,CAAC,CAAC,MAAM,YAAY,QAAQ,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,2BAA2B;IAC3B,IAAI,cAAc,GAAQ,IAAI,CAAC;IAE/B,wCAAwC;IACxC,IAAI,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAExC,OAAO,CAAC,GAAG,IAAW,EAAO,EAAE;QAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,GAAG,YAAY,EAAE;YACzC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACtB,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;SAC/B;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"cached-throttle.js","sourceRoot":"","sources":["../src/cached-throttle.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,CACrB,MAAgD,EAChD,YAAoB,EACwB,EAAE;IAC9C,IAAI,CAAC,CAAC,MAAM,YAAY,QAAQ,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,2BAA2B;IAC3B,IAAI,cAAc,GAA4B,IAAI,CAAC;IAEnD,wCAAwC;IACxC,IAAI,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAExC,OAAO,CAAC,GAAG,IAAa,EAAoB,EAAE;QAC5C,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,GAAG,YAAY,EAAE;YAC5D,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACtB,cAAc,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;SAClC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEO,wCAAc"}
@@ -1,15 +1,8 @@
1
1
  /// <reference types="node" />
2
- declare const _default: {
3
- decryptWithAes256cbc: typeof decryptWithAes256cbc;
4
- decryptWithAes256gcm: typeof decryptWithAes256gcm;
5
- encryptWithAes256cbc: typeof encryptWithAes256cbc;
6
- encryptWithAes256gcm: typeof encryptWithAes256gcm;
7
- random32Bytes: typeof random32Bytes;
8
- };
9
2
  /**
10
3
  * Functions to manage native crypto functions of nodeJs
11
4
  */
12
- export default _default;
5
+ export { decryptWithAes256cbc, decryptWithAes256gcm, encryptWithAes256cbc, encryptWithAes256gcm, random32Bytes, };
13
6
  /**
14
7
  * Generates 32 cryptographically strong pseudo-random bytes
15
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-wrapper.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto-wrapper.ts"],"names":[],"mappings":";;;;;;;;AAEA;;GAEG;AACH,wBAME;AAWF;;;;GAIG;AACH,iBAAe,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAG9C;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9E;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9E;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxF;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBxF"}
1
+ {"version":3,"file":"crypto-wrapper.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto-wrapper.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,CAAC;AAWF;;;;GAIG;AACH,iBAAe,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAG9C;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9E;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9E;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxF;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBxF"}
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.random32Bytes = exports.encryptWithAes256gcm = exports.encryptWithAes256cbc = exports.decryptWithAes256gcm = exports.decryptWithAes256cbc = void 0;
4
+ const tslib_1 = require("tslib");
12
5
  const crypto_1 = require("crypto");
13
- /**
14
- * Functions to manage native crypto functions of nodeJs
15
- */
16
- exports.default = {
17
- decryptWithAes256cbc,
18
- decryptWithAes256gcm,
19
- encryptWithAes256cbc,
20
- encryptWithAes256gcm,
21
- random32Bytes,
22
- };
23
6
  // Algorithm name used for aes256-cbc encryption with the package 'crypto'
24
7
  const AES_256_CBC_ALGORITHM = 'aes-256-cbc';
25
8
  // Algorithm name used for aes256-gcm encryption with the package 'crypto'
@@ -33,11 +16,12 @@ const AUTH_TAG_LENGTH = 16;
33
16
  * @returns Promise resolving the 32 bytes generated
34
17
  */
35
18
  function random32Bytes() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- // tslint:disable-next-line:no-magic-numbers
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ // eslint-disable-next-line no-magic-numbers
38
21
  return randomBytes(32);
39
22
  });
40
23
  }
24
+ exports.random32Bytes = random32Bytes;
41
25
  /**
42
26
  * Encrypts a buffer using AES-256-cbc plus a random Initialization Vector (IV)
43
27
  *
@@ -47,17 +31,18 @@ function random32Bytes() {
47
31
  * @returns Promise resolving a buffer containing the IV and the encrypted data
48
32
  */
49
33
  function encryptWithAes256cbc(data, key) {
50
- return __awaiter(this, void 0, void 0, function* () {
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
35
  // Generate randomly the Initialization Vector
52
36
  const iv = yield randomBytes(INITIALIZATION_VECTOR_LENGTH);
53
37
  // Create the cipher object to encrypt data
54
- const cipher = crypto_1.createCipheriv(AES_256_CBC_ALGORITHM, key, iv);
38
+ const cipher = (0, crypto_1.createCipheriv)(AES_256_CBC_ALGORITHM, key, iv);
55
39
  // Encrypt data
56
40
  const encrypted = cipher.update(data);
57
41
  // Concat the IV and the encrypted data, the call of final() makes the cipher not usable and flush the buffer
58
42
  return Buffer.concat([iv, encrypted, cipher.final()]);
59
43
  });
60
44
  }
45
+ exports.encryptWithAes256cbc = encryptWithAes256cbc;
61
46
  /**
62
47
  * Encrypts a buffer using AES-256-gcm plus a random Initialization Vector (IV)
63
48
  *
@@ -67,11 +52,11 @@ function encryptWithAes256cbc(data, key) {
67
52
  * @returns Promise resolving a buffer containing the IV and the encrypted data
68
53
  */
69
54
  function encryptWithAes256gcm(data, key) {
70
- return __awaiter(this, void 0, void 0, function* () {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
56
  // Generate randomly the Initialization Vector
72
57
  const iv = yield randomBytes(INITIALIZATION_VECTOR_LENGTH);
73
58
  // Create the cipher object to encrypt data
74
- const cipher = crypto_1.createCipheriv(AES_256_GCM_ALGORITHM, key, iv);
59
+ const cipher = (0, crypto_1.createCipheriv)(AES_256_GCM_ALGORITHM, key, iv);
75
60
  const encrypted = cipher.update(data);
76
61
  const final = cipher.final();
77
62
  const authTag = cipher.getAuthTag();
@@ -79,6 +64,7 @@ function encryptWithAes256gcm(data, key) {
79
64
  return Buffer.concat([iv, authTag, encrypted, final]);
80
65
  });
81
66
  }
67
+ exports.encryptWithAes256gcm = encryptWithAes256gcm;
82
68
  /**
83
69
  * Decrypts an encrypted buffer using AES-256-cbc plus a random Initialization Vector (IV)
84
70
  *
@@ -88,18 +74,19 @@ function encryptWithAes256gcm(data, key) {
88
74
  * @returns Promise resolving a buffer containing the data decrypted
89
75
  */
90
76
  function decryptWithAes256cbc(encryptedAndIv, key) {
91
- return __awaiter(this, void 0, void 0, function* () {
77
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
92
78
  // Get the IV
93
79
  const iv = encryptedAndIv.slice(0, INITIALIZATION_VECTOR_LENGTH);
94
80
  // Get the encrypted data itself
95
81
  const encryptedData = encryptedAndIv.slice(INITIALIZATION_VECTOR_LENGTH);
96
82
  // Create the decipher object
97
- const decipher = crypto_1.createDecipheriv(AES_256_CBC_ALGORITHM, key, iv);
83
+ const decipher = (0, crypto_1.createDecipheriv)(AES_256_CBC_ALGORITHM, key, iv);
98
84
  // decipher.setAuthTag(authTag);
99
85
  // Return the buffer decrypted (the call of final() makes the decipher not usable and flush the buffer)
100
86
  return Buffer.concat([decipher.update(encryptedData), decipher.final()]);
101
87
  });
102
88
  }
89
+ exports.decryptWithAes256cbc = decryptWithAes256cbc;
103
90
  /**
104
91
  * Decrypts an encrypted buffer using AES-256-gcm plus a random Initialization Vector (IV)
105
92
  *
@@ -109,7 +96,7 @@ function decryptWithAes256cbc(encryptedAndIv, key) {
109
96
  * @returns Promise resolving a buffer containing the data decrypted
110
97
  */
111
98
  function decryptWithAes256gcm(encryptedAndIv, key) {
112
- return __awaiter(this, void 0, void 0, function* () {
99
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
113
100
  // Get the IV
114
101
  const iv = encryptedAndIv.slice(0, INITIALIZATION_VECTOR_LENGTH);
115
102
  // Get the Auth tag
@@ -117,12 +104,13 @@ function decryptWithAes256gcm(encryptedAndIv, key) {
117
104
  // Get the encrypted data itself
118
105
  const encryptedData = encryptedAndIv.slice(INITIALIZATION_VECTOR_LENGTH + AUTH_TAG_LENGTH);
119
106
  // Create the decipher object
120
- const decipher = crypto_1.createDecipheriv(AES_256_GCM_ALGORITHM, key, iv);
107
+ const decipher = (0, crypto_1.createDecipheriv)(AES_256_GCM_ALGORITHM, key, iv);
121
108
  decipher.setAuthTag(authTag);
122
109
  // Return the buffer decrypted (the call of final() makes the decipher not usable and flush the buffer)
123
110
  return Buffer.concat([decipher.update(encryptedData), decipher.final()]);
124
111
  });
125
112
  }
113
+ exports.decryptWithAes256gcm = decryptWithAes256gcm;
126
114
  /**
127
115
  * Generates N cryptographically strong pseudo-random bytes
128
116
  *
@@ -131,9 +119,9 @@ function decryptWithAes256gcm(encryptedAndIv, key) {
131
119
  * @returns Promise resolving the N bytes generated
132
120
  */
133
121
  function randomBytes(n) {
134
- return __awaiter(this, void 0, void 0, function* () {
122
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
135
123
  return new Promise((resolve, reject) => {
136
- crypto_1.randomBytes(n, (error, buffer) => {
124
+ (0, crypto_1.randomBytes)(n, (error, buffer) => {
137
125
  if (error) {
138
126
  return reject(`Error generating random bytes: ${error}`);
139
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-wrapper.js","sourceRoot":"","sources":["../../src/crypto/crypto-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAA4F;AAE5F;;GAEG;AACH,kBAAe;IACb,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,aAAa;CACd,CAAC;AAEF,0EAA0E;AAC1E,MAAM,qBAAq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;AACH,SAAe,oBAAoB,CAAC,cAAsB,EAAE,GAAW;;QACrE,aAAa;QACb,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,4BAA4B,CAAC,CAAC;QACjE,mBAAmB;QACnB,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAClC,4BAA4B,EAC5B,4BAA4B,GAAG,eAAe,CAC/C,CAAC;QAEF,gCAAgC;QAChC,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,4BAA4B,GAAG,eAAe,CAAC,CAAC;QAE3F,6BAA6B;QAC7B,MAAM,QAAQ,GAAG,IAAA,yBAAgB,EAAC,qBAAqB,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAClE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAE7B,uGAAuG;QACvG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;CAAA;AAtHC,oDAAoB;AAwHtB;;;;;;GAMG;AACH,SAAe,WAAW,CAAC,CAAS;;QAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAO,EAAE;YAC1C,IAAA,oBAAiB,EAAC,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACrC,IAAI,KAAK,EAAE;oBACT,OAAO,MAAM,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;iBAC1D;gBACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
@@ -1,15 +1,7 @@
1
- declare const _default: {
2
- decrypt: typeof decrypt;
3
- encrypt: typeof encrypt;
4
- getAddressFromPrivateKey: typeof getAddressFromPrivateKey;
5
- getAddressFromPublicKey: typeof getAddressFromPublicKey;
6
- recover: typeof recover;
7
- sign: typeof sign;
8
- };
9
1
  /**
10
2
  * Function to manage Elliptic-curve cryptography
11
3
  */
12
- export default _default;
4
+ export { ecDecrypt, ecEncrypt, getAddressFromPrivateKey, getAddressFromPublicKey, ecRecover, ecSign, };
13
5
  /**
14
6
  * Function to derive the address from an EC private key
15
7
  *
@@ -27,13 +19,13 @@ declare function getAddressFromPrivateKey(privateKey: string): string;
27
19
  */
28
20
  declare function getAddressFromPublicKey(publicKey: string): string;
29
21
  /**
30
- * Function sign data with ECDSA
22
+ * Function ecSigndata with ECDSA
31
23
  *
32
24
  * @param data the data to sign
33
25
  *
34
26
  * @returns the signature
35
27
  */
36
- declare function sign(privateKey: string, data: string): string;
28
+ declare function ecSign(privateKey: string, data: string): string;
37
29
  /**
38
30
  * Function to recover address from a signature
39
31
  *
@@ -42,7 +34,7 @@ declare function sign(privateKey: string, data: string): string;
42
34
  *
43
35
  * @returns the address
44
36
  */
45
- declare function recover(signature: string, data: string): string;
37
+ declare function ecRecover(signature: string, data: string): string;
46
38
  /**
47
39
  * Function to encrypt data with a public key
48
40
  *
@@ -51,7 +43,7 @@ declare function recover(signature: string, data: string): string;
51
43
  *
52
44
  * @returns the encrypted data
53
45
  */
54
- declare function encrypt(publicKey: string, data: string): Promise<string>;
46
+ declare function ecEncrypt(publicKey: string, data: string): Promise<string>;
55
47
  /**
56
48
  * Function to decrypt data with a public key
57
49
  *
@@ -60,5 +52,5 @@ declare function encrypt(publicKey: string, data: string): Promise<string>;
60
52
  *
61
53
  * @returns the decrypted data
62
54
  */
63
- declare function decrypt(privateKey: string, encrypted: string): Promise<string>;
55
+ declare function ecDecrypt(privateKey: string, data: string): Promise<string>;
64
56
  //# sourceMappingURL=ec-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ec-utils.d.ts","sourceRoot":"","sources":["../../src/crypto/ec-utils.ts"],"names":[],"mappings":";;;;;;;;AAEA;;GAEG;AACH,wBAOE;AAEF;;;;;;GAMG;AACH,iBAAS,w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