@requestnetwork/utils 0.36.1-next.1855 → 0.36.1-next.1857
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 +2 -20
- package/dist/amount.d.ts +4 -9
- package/dist/amount.d.ts.map +1 -1
- package/dist/amount.js +13 -17
- package/dist/amount.js.map +1 -1
- package/dist/bignumber.d.ts +5 -5
- package/dist/bignumber.d.ts.map +1 -1
- package/dist/bignumber.js +5 -3
- package/dist/bignumber.js.map +1 -1
- package/dist/cached-throttle.d.ts +2 -2
- package/dist/cached-throttle.d.ts.map +1 -1
- package/dist/cached-throttle.js +0 -1
- package/dist/cached-throttle.js.map +1 -1
- package/dist/crypto/crypto-wrapper.d.ts +1 -8
- package/dist/crypto/crypto-wrapper.d.ts.map +1 -1
- package/dist/crypto/crypto-wrapper.js +6 -10
- package/dist/crypto/crypto-wrapper.js.map +1 -1
- package/dist/crypto/ec-utils.d.ts +6 -14
- package/dist/crypto/ec-utils.d.ts.map +1 -1
- package/dist/crypto/ec-utils.js +15 -19
- package/dist/crypto/ec-utils.js.map +1 -1
- package/dist/crypto.d.ts +3 -27
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +22 -17
- package/dist/crypto.js.map +1 -1
- package/dist/encryption.d.ts +1 -6
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +12 -16
- package/dist/encryption.js.map +1 -1
- package/dist/estimate-gas-fees.d.ts +1 -1
- package/dist/estimate-gas-fees.d.ts.map +1 -1
- package/dist/estimate-gas-fees.js +4 -3
- package/dist/estimate-gas-fees.js.map +1 -1
- package/dist/identity.d.ts +4 -9
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +7 -11
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +12 -80
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -21
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +26 -8
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +6 -7
- package/dist/providers.js.map +1 -1
- package/dist/retry.d.ts +2 -2
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +0 -1
- package/dist/retry.js.map +1 -1
- package/dist/signature.d.ts +2 -7
- package/dist/signature.d.ts.map +1 -1
- package/dist/signature.js +12 -16
- package/dist/signature.js.map +1 -1
- package/dist/simple-logger.d.ts +1 -1
- package/dist/simple-logger.d.ts.map +1 -1
- package/dist/simple-logger.js +2 -1
- package/dist/simple-logger.js.map +1 -1
- package/dist/utils.d.ts +1 -12
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +12 -16
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/crypto.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeKeccak256Hash = exports.normalize = exports.last20bytesOfNormalizedKeccak256Hash = exports.keccak256Hash = exports.generate8randomBytes = exports.generate32BufferKey = exports.ecSign = exports.ecRecover = exports.getAddressFromPublicKey = exports.getAddressFromPrivateKey = exports.ecEncrypt = exports.ecDecrypt = exports.random32Bytes = exports.encryptWithAes256gcm = exports.encryptWithAes256cbc = exports.decryptWithAes256gcm = exports.decryptWithAes256cbc = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const types_1 = require("@requestnetwork/types");
|
|
5
6
|
const ethers_1 = require("ethers");
|
|
6
7
|
const crypto_wrapper_1 = require("./crypto/crypto-wrapper");
|
|
8
|
+
Object.defineProperty(exports, "decryptWithAes256cbc", { enumerable: true, get: function () { return crypto_wrapper_1.decryptWithAes256cbc; } });
|
|
9
|
+
Object.defineProperty(exports, "decryptWithAes256gcm", { enumerable: true, get: function () { return crypto_wrapper_1.decryptWithAes256gcm; } });
|
|
10
|
+
Object.defineProperty(exports, "encryptWithAes256cbc", { enumerable: true, get: function () { return crypto_wrapper_1.encryptWithAes256cbc; } });
|
|
11
|
+
Object.defineProperty(exports, "encryptWithAes256gcm", { enumerable: true, get: function () { return crypto_wrapper_1.encryptWithAes256gcm; } });
|
|
12
|
+
Object.defineProperty(exports, "random32Bytes", { enumerable: true, get: function () { return crypto_wrapper_1.random32Bytes; } });
|
|
7
13
|
const ec_utils_1 = require("./crypto/ec-utils");
|
|
14
|
+
Object.defineProperty(exports, "ecDecrypt", { enumerable: true, get: function () { return ec_utils_1.ecDecrypt; } });
|
|
15
|
+
Object.defineProperty(exports, "ecEncrypt", { enumerable: true, get: function () { return ec_utils_1.ecEncrypt; } });
|
|
16
|
+
Object.defineProperty(exports, "getAddressFromPrivateKey", { enumerable: true, get: function () { return ec_utils_1.getAddressFromPrivateKey; } });
|
|
17
|
+
Object.defineProperty(exports, "getAddressFromPublicKey", { enumerable: true, get: function () { return ec_utils_1.getAddressFromPublicKey; } });
|
|
18
|
+
Object.defineProperty(exports, "ecRecover", { enumerable: true, get: function () { return ec_utils_1.ecRecover; } });
|
|
19
|
+
Object.defineProperty(exports, "ecSign", { enumerable: true, get: function () { return ec_utils_1.ecSign; } });
|
|
8
20
|
const utils_1 = require("./utils");
|
|
9
|
-
/**
|
|
10
|
-
* manages crypto functions
|
|
11
|
-
*/
|
|
12
|
-
exports.default = {
|
|
13
|
-
CryptoWrapper: crypto_wrapper_1.default,
|
|
14
|
-
EcUtils: ec_utils_1.default,
|
|
15
|
-
generate32BufferKey,
|
|
16
|
-
generate8randomBytes,
|
|
17
|
-
keccak256Hash,
|
|
18
|
-
last20bytesOfNormalizedKeccak256Hash,
|
|
19
|
-
normalize,
|
|
20
|
-
normalizeKeccak256Hash,
|
|
21
|
-
};
|
|
22
21
|
/**
|
|
23
22
|
* Hashes with the keccak256 algorithm with a normalization before and formats it
|
|
24
23
|
*
|
|
@@ -33,6 +32,7 @@ function normalizeKeccak256Hash(data) {
|
|
|
33
32
|
value: keccak256Hash(normalize(data)),
|
|
34
33
|
};
|
|
35
34
|
}
|
|
35
|
+
exports.normalizeKeccak256Hash = normalizeKeccak256Hash;
|
|
36
36
|
/**
|
|
37
37
|
* Normalizes data: sorts the object by keys and convert it in string
|
|
38
38
|
*
|
|
@@ -44,10 +44,11 @@ function normalize(data) {
|
|
|
44
44
|
return 'undefined';
|
|
45
45
|
}
|
|
46
46
|
// deeply sort data keys
|
|
47
|
-
const sortedData = utils_1.
|
|
47
|
+
const sortedData = (0, utils_1.deepSort)(data);
|
|
48
48
|
// convert to string and lowerCase it, to be case insensitive (e.g: avoid ethereum address casing checksum)
|
|
49
49
|
return JSON.stringify(sortedData).toLowerCase();
|
|
50
50
|
}
|
|
51
|
+
exports.normalize = normalize;
|
|
51
52
|
/**
|
|
52
53
|
* Hashes with the keccak256 algorithm
|
|
53
54
|
*
|
|
@@ -57,6 +58,7 @@ function normalize(data) {
|
|
|
57
58
|
function keccak256Hash(data) {
|
|
58
59
|
return ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(data));
|
|
59
60
|
}
|
|
61
|
+
exports.keccak256Hash = keccak256Hash;
|
|
60
62
|
/**
|
|
61
63
|
* Hashes with the keccak256 algorithm with a normalization before and formats it
|
|
62
64
|
*
|
|
@@ -70,6 +72,7 @@ function last20bytesOfNormalizedKeccak256Hash(data) {
|
|
|
70
72
|
// eslint-disable-next-line no-magic-numbers
|
|
71
73
|
return `0x${hash.slice(-40)}`;
|
|
72
74
|
}
|
|
75
|
+
exports.last20bytesOfNormalizedKeccak256Hash = last20bytesOfNormalizedKeccak256Hash;
|
|
73
76
|
/**
|
|
74
77
|
* Generates a 32 bytes key in a base64 string
|
|
75
78
|
*
|
|
@@ -77,9 +80,10 @@ function last20bytesOfNormalizedKeccak256Hash(data) {
|
|
|
77
80
|
*/
|
|
78
81
|
function generate32BufferKey() {
|
|
79
82
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
80
|
-
return (yield crypto_wrapper_1.
|
|
83
|
+
return (yield (0, crypto_wrapper_1.random32Bytes)()).toString('base64');
|
|
81
84
|
});
|
|
82
85
|
}
|
|
86
|
+
exports.generate32BufferKey = generate32BufferKey;
|
|
83
87
|
/**
|
|
84
88
|
* Generate 8 random bytes and return as a hexadecimal string.
|
|
85
89
|
* Used for salt in ETH input data.
|
|
@@ -89,8 +93,9 @@ function generate32BufferKey() {
|
|
|
89
93
|
*/
|
|
90
94
|
function generate8randomBytes() {
|
|
91
95
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
92
|
-
const
|
|
93
|
-
return
|
|
96
|
+
const random32BytesHex = yield (0, crypto_wrapper_1.random32Bytes)();
|
|
97
|
+
return random32BytesHex.slice(0, 8).toString('hex');
|
|
94
98
|
});
|
|
95
99
|
}
|
|
100
|
+
exports.generate8randomBytes = generate8randomBytes;
|
|
96
101
|
//# sourceMappingURL=crypto.js.map
|
package/dist/crypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":";;;;AAAA,iDAAyD;AACzD,mCAAgC;AAChC,4DAMiC;AAe/B,qGApBA,qCAAoB,OAoBA;AACpB,qGApBA,qCAAoB,OAoBA;AACpB,qGApBA,qCAAoB,OAoBA;AACpB,qGApBA,qCAAoB,OAoBA;AACpB,8FApBA,8BAAa,OAoBA;AAlBf,gDAO2B;AAYzB,0FAlBA,oBAAS,OAkBA;AACT,0FAlBA,oBAAS,OAkBA;AACT,yGAlBA,mCAAwB,OAkBA;AACxB,wGAlBA,kCAAuB,OAkBA;AACvB,0FAlBA,oBAAS,OAkBA;AACT,uFAlBA,iBAAM,OAkBA;AAhBR,mCAAmC;AAyBnC;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,IAAa;IAC3C,OAAO;QACL,IAAI,EAAE,wBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS;QAC/C,KAAK,E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ANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { EncryptionTypes, IdentityTypes } from '@requestnetwork/types';
|
|
2
|
-
declare const _default: {
|
|
3
|
-
decrypt: typeof decrypt;
|
|
4
|
-
encrypt: typeof encrypt;
|
|
5
|
-
getIdentityFromEncryptionParams: typeof getIdentityFromEncryptionParams;
|
|
6
|
-
};
|
|
7
2
|
/**
|
|
8
3
|
* Functions to manage encryption
|
|
9
4
|
*/
|
|
10
|
-
export
|
|
5
|
+
export { decrypt, encrypt, getIdentityFromEncryptionParams };
|
|
11
6
|
/**
|
|
12
7
|
* Function to get the identity from the encryption parameters
|
|
13
8
|
*
|
package/dist/encryption.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWvE;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;AAE7D;;;;;;GAMG;AACH,iBAAS,+BAA+B,CACtC,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,GACtD,aAAa,CAAC,SAAS,CASzB;AAED;;;;;;GAMG;AACH,iBAAe,OAAO,CACpB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,GACtD,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAgCzC;AAED;;;;;;;;GAQG;AACH,iBAAe,OAAO,CACpB,aAAa,EAAE,eAAe,CAAC,cAAc,EAC7C,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,GACtD,OAAO,CAAC,MAAM,CAAC,CAkCjB"}
|
package/dist/encryption.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIdentityFromEncryptionParams = exports.encrypt = exports.decrypt = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const types_1 = require("@requestnetwork/types");
|
|
5
|
-
const
|
|
6
|
-
/**
|
|
7
|
-
* Functions to manage encryption
|
|
8
|
-
*/
|
|
9
|
-
exports.default = {
|
|
10
|
-
decrypt,
|
|
11
|
-
encrypt,
|
|
12
|
-
getIdentityFromEncryptionParams,
|
|
13
|
-
};
|
|
6
|
+
const index_1 = require("./index");
|
|
14
7
|
/**
|
|
15
8
|
* Function to get the identity from the encryption parameters
|
|
16
9
|
*
|
|
@@ -22,11 +15,12 @@ function getIdentityFromEncryptionParams(encryptionParams) {
|
|
|
22
15
|
if (encryptionParams.method === types_1.EncryptionTypes.METHOD.ECIES) {
|
|
23
16
|
return {
|
|
24
17
|
type: types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS,
|
|
25
|
-
value:
|
|
18
|
+
value: (0, index_1.getAddressFromPublicKey)(encryptionParams.key),
|
|
26
19
|
};
|
|
27
20
|
}
|
|
28
21
|
throw new Error('encryptionParams.method not supported');
|
|
29
22
|
}
|
|
23
|
+
exports.getIdentityFromEncryptionParams = getIdentityFromEncryptionParams;
|
|
30
24
|
/**
|
|
31
25
|
* Encrypts data using encryption parameters
|
|
32
26
|
*
|
|
@@ -37,21 +31,21 @@ function getIdentityFromEncryptionParams(encryptionParams) {
|
|
|
37
31
|
function encrypt(data, encryptionParams) {
|
|
38
32
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
39
33
|
if (encryptionParams.method === types_1.EncryptionTypes.METHOD.ECIES) {
|
|
40
|
-
const encryptedData = yield
|
|
34
|
+
const encryptedData = yield (0, index_1.ecEncrypt)(encryptionParams.key, data);
|
|
41
35
|
return {
|
|
42
36
|
type: types_1.EncryptionTypes.METHOD.ECIES,
|
|
43
37
|
value: encryptedData,
|
|
44
38
|
};
|
|
45
39
|
}
|
|
46
40
|
if (encryptionParams.method === types_1.EncryptionTypes.METHOD.AES256_CBC) {
|
|
47
|
-
const encryptedDataBuffer = yield
|
|
41
|
+
const encryptedDataBuffer = yield (0, index_1.encryptWithAes256cbc)(Buffer.from(data, 'utf-8'), Buffer.from(encryptionParams.key, 'base64'));
|
|
48
42
|
return {
|
|
49
43
|
type: types_1.EncryptionTypes.METHOD.AES256_CBC,
|
|
50
44
|
value: encryptedDataBuffer.toString('base64'),
|
|
51
45
|
};
|
|
52
46
|
}
|
|
53
47
|
if (encryptionParams.method === types_1.EncryptionTypes.METHOD.AES256_GCM) {
|
|
54
|
-
const encryptedDataBuffer = yield
|
|
48
|
+
const encryptedDataBuffer = yield (0, index_1.encryptWithAes256gcm)(Buffer.from(data, 'utf-8'), Buffer.from(encryptionParams.key, 'base64'));
|
|
55
49
|
return {
|
|
56
50
|
type: types_1.EncryptionTypes.METHOD.AES256_GCM,
|
|
57
51
|
value: encryptedDataBuffer.toString('base64'),
|
|
@@ -60,6 +54,7 @@ function encrypt(data, encryptionParams) {
|
|
|
60
54
|
throw new Error('encryptionParams.method not supported');
|
|
61
55
|
});
|
|
62
56
|
}
|
|
57
|
+
exports.encrypt = encrypt;
|
|
63
58
|
/**
|
|
64
59
|
* Decrypt data using decryption parameters
|
|
65
60
|
*
|
|
@@ -75,13 +70,13 @@ function decrypt(encryptedData, decryptionParams) {
|
|
|
75
70
|
if (decryptionParams.method !== types_1.EncryptionTypes.METHOD.ECIES) {
|
|
76
71
|
throw new Error(`decryptionParams.method should be ${types_1.EncryptionTypes.METHOD.ECIES}`);
|
|
77
72
|
}
|
|
78
|
-
return
|
|
73
|
+
return (0, index_1.ecDecrypt)(decryptionParams.key, encryptedData.value);
|
|
79
74
|
}
|
|
80
75
|
if (encryptedData.type === types_1.EncryptionTypes.METHOD.AES256_CBC) {
|
|
81
76
|
if (decryptionParams.method !== types_1.EncryptionTypes.METHOD.AES256_CBC) {
|
|
82
77
|
throw new Error(`decryptionParams.method should be ${types_1.EncryptionTypes.METHOD.AES256_CBC}`);
|
|
83
78
|
}
|
|
84
|
-
const dataBuffer = yield
|
|
79
|
+
const dataBuffer = yield (0, index_1.decryptWithAes256cbc)(
|
|
85
80
|
// remove the multi-format padding and decode from the base64 to a buffer
|
|
86
81
|
Buffer.from(encryptedData.value, 'base64'), Buffer.from(decryptionParams.key, 'base64'));
|
|
87
82
|
return dataBuffer.toString();
|
|
@@ -90,7 +85,7 @@ function decrypt(encryptedData, decryptionParams) {
|
|
|
90
85
|
if (decryptionParams.method !== types_1.EncryptionTypes.METHOD.AES256_GCM) {
|
|
91
86
|
throw new Error(`decryptionParams.method should be ${types_1.EncryptionTypes.METHOD.AES256_GCM}`);
|
|
92
87
|
}
|
|
93
|
-
const dataBuffer = yield
|
|
88
|
+
const dataBuffer = yield (0, index_1.decryptWithAes256gcm)(
|
|
94
89
|
// remove the multi-format padding and decode from the base64 to a buffer
|
|
95
90
|
Buffer.from(encryptedData.value, 'base64'), Buffer.from(decryptionParams.key, 'base64'));
|
|
96
91
|
return dataBuffer.toString();
|
|
@@ -98,4 +93,5 @@ function decrypt(encryptedData, decryptionParams) {
|
|
|
98
93
|
throw new Error('encryptedData method not supported');
|
|
99
94
|
});
|
|
100
95
|
}
|
|
96
|
+
exports.decrypt = decrypt;
|
|
101
97
|
//# sourceMappingURL=encryption.js.map
|
package/dist/encryption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":";;;;AAAA,iDAAuE;AACvE,mCAQiB;AAOjB;;;;;;GAMG;AACH,SAAS,+BAA+B,CACtC,gBAAuD;IAEvD,IAAI,gBAAgB,CAAC,MAAM,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UAAU,EAAE;YAC5D,IAAI,gBAAgB,CAAC,MAAM,KAAK,uBAAe,CAAC,MAAM,CAAC,UAAU,EAAE;gBACjE,MAAM,IAAI,KAAK,CAAC,qCAAqC,uBAAe,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;aAC3F;YAED,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAoB;YAC3C,yEAAyE;YACzE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,EAC1C,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAC5C,CAAC;YACF,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;SAC9B;QAED,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;CAAA;AAhHQ,0BAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimate-gas-fees.d.ts","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIzD;;;;;;;;;;GAUG;AACH,iBAAe,eAAe,CAAC,EAC7B,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,oBAAoB,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC,CAmBD;AAED,
|
|
1
|
+
{"version":3,"file":"estimate-gas-fees.d.ts","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIzD;;;;;;;;;;GAUG;AACH,iBAAe,eAAe,CAAC,EAC7B,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,oBAAoB,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC,CAmBD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateGasFees = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const ethers_1 = require("ethers");
|
|
5
6
|
const eip1559_fee_suggestions_ethers_1 = require("eip1559-fee-suggestions-ethers");
|
|
@@ -18,8 +19,8 @@ const index_1 = require("./index");
|
|
|
18
19
|
function estimateGasFees({ provider, gasPriceMin, }) {
|
|
19
20
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
20
21
|
const suggestedFee = yield (0, eip1559_fee_suggestions_ethers_1.suggestFees)(provider);
|
|
21
|
-
const baseFee = index_1.
|
|
22
|
-
const maxPriorityFeePerGas = index_1.
|
|
22
|
+
const baseFee = (0, index_1.maxBigNumber)(suggestedFee.baseFeeSuggestion, gasPriceMin || ethers_1.constants.Zero);
|
|
23
|
+
const maxPriorityFeePerGas = (0, index_1.maxBigNumber)(suggestedFee.maxPriorityFeeSuggestions.urgent, gasPriceMin || ethers_1.constants.Zero);
|
|
23
24
|
const maxFeePerGas = baseFee.add(maxPriorityFeePerGas);
|
|
24
25
|
if (maxPriorityFeePerGas.eq(0) || maxFeePerGas.eq(0)) {
|
|
25
26
|
return {};
|
|
@@ -30,5 +31,5 @@ function estimateGasFees({ provider, gasPriceMin, }) {
|
|
|
30
31
|
};
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
exports.
|
|
34
|
+
exports.estimateGasFees = estimateGasFees;
|
|
34
35
|
//# sourceMappingURL=estimate-gas-fees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimate-gas-fees.js","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimate-gas-fees.js","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":";;;;AAAA,mCAAyD;AACzD,mFAA6D;AAC7D,mCAAuC;AAEvC;;;;;;;;;;GAUG;AACH,SAAe,eAAe,CAAC,EAC7B,QAAQ,EACR,WAAW,GAIZ;;QAIC,MAAM,YAAY,GAAG,MAAM,IAAA,4CAAW,EAAC,QAAqC,CAAC,CAAC;QAE9E,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,YAAY,CAAC,iBAAiB,EAAE,WAAW,IAAI,kBAAS,CAAC,IAAI,CAAC,CAAC;QAE5F,MAAM,oBAAoB,GAAG,IAAA,oBAAY,EACvC,YAAY,CAAC,yBAAyB,CAAC,MAAM,EAC7C,WAAW,IAAI,kBAAS,CAAC,IAAI,CAC9B,CAAC;QACF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAEvD,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACpD,OAAO,EAAE,CAAC;SACX;QAED,OAAO;YACL,oBAAoB;YACpB,YAAY;SACb,CAAC;IACJ,CAAC;CAAA;AAEQ,0CAAe"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { IdentityTypes } from '@requestnetwork/types';
|
|
2
|
-
declare const
|
|
3
|
-
areEqual: typeof areEqual;
|
|
4
|
-
hasError: typeof hasError;
|
|
5
|
-
normalizeIdentityValue: typeof normalizeIdentityValue;
|
|
6
|
-
supportedIdentities: IdentityTypes.TYPE[];
|
|
7
|
-
};
|
|
2
|
+
declare const supportedIdentities: IdentityTypes.TYPE[];
|
|
8
3
|
/**
|
|
9
4
|
* Module to manage Request Logic Identity
|
|
10
5
|
*/
|
|
11
|
-
export
|
|
6
|
+
export { areEqualIdentities, identityHasError, normalizeIdentityValue, supportedIdentities };
|
|
12
7
|
/**
|
|
13
8
|
* Checks if two identities are equals
|
|
14
9
|
*
|
|
@@ -16,7 +11,7 @@ export default _default;
|
|
|
16
11
|
* @param IIdentity id2 second identity
|
|
17
12
|
* @returns boolean
|
|
18
13
|
*/
|
|
19
|
-
declare function
|
|
14
|
+
declare function areEqualIdentities(id1?: IdentityTypes.IIdentity, id2?: IdentityTypes.IIdentity): boolean;
|
|
20
15
|
/**
|
|
21
16
|
* Normalizes identity values
|
|
22
17
|
*
|
|
@@ -30,5 +25,5 @@ declare function normalizeIdentityValue(value: string): string;
|
|
|
30
25
|
* @param id identity to check
|
|
31
26
|
* @returns the error or null if valid
|
|
32
27
|
*/
|
|
33
|
-
declare function
|
|
28
|
+
declare function identityHasError(id: IdentityTypes.IIdentity): string | null;
|
|
34
29
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,QAAA,MAAM,mBAAmB,EAAE,aAAa,CAAC,IAAI,EAG5C,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;AAE7F;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,aAAa,CAAC,SAAS,GAAG,OAAO,CAOjG;AAED;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;GAKG;AACH,iBAAS,gBAAgB,CAAC,EAAE,EAAE,aAAa,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,CAQpE"}
|
package/dist/identity.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supportedIdentities = exports.normalizeIdentityValue = exports.identityHasError = exports.areEqualIdentities = void 0;
|
|
3
4
|
const types_1 = require("@requestnetwork/types");
|
|
4
5
|
const supportedIdentities = [
|
|
5
6
|
types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS,
|
|
6
7
|
types_1.IdentityTypes.TYPE.ETHEREUM_SMART_CONTRACT,
|
|
7
8
|
];
|
|
8
|
-
|
|
9
|
-
* Module to manage Request Logic Identity
|
|
10
|
-
*/
|
|
11
|
-
exports.default = {
|
|
12
|
-
areEqual,
|
|
13
|
-
hasError,
|
|
14
|
-
normalizeIdentityValue,
|
|
15
|
-
supportedIdentities,
|
|
16
|
-
};
|
|
9
|
+
exports.supportedIdentities = supportedIdentities;
|
|
17
10
|
/**
|
|
18
11
|
* Checks if two identities are equals
|
|
19
12
|
*
|
|
@@ -21,12 +14,13 @@ exports.default = {
|
|
|
21
14
|
* @param IIdentity id2 second identity
|
|
22
15
|
* @returns boolean
|
|
23
16
|
*/
|
|
24
|
-
function
|
|
17
|
+
function areEqualIdentities(id1, id2) {
|
|
25
18
|
return (!!id1 &&
|
|
26
19
|
!!id2 &&
|
|
27
20
|
id1.type === id2.type &&
|
|
28
21
|
normalizeIdentityValue(id1.value) === normalizeIdentityValue(id2.value));
|
|
29
22
|
}
|
|
23
|
+
exports.areEqualIdentities = areEqualIdentities;
|
|
30
24
|
/**
|
|
31
25
|
* Normalizes identity values
|
|
32
26
|
*
|
|
@@ -36,13 +30,14 @@ function areEqual(id1, id2) {
|
|
|
36
30
|
function normalizeIdentityValue(value) {
|
|
37
31
|
return value.toLowerCase();
|
|
38
32
|
}
|
|
33
|
+
exports.normalizeIdentityValue = normalizeIdentityValue;
|
|
39
34
|
/**
|
|
40
35
|
* Checks if the identity has an error
|
|
41
36
|
*
|
|
42
37
|
* @param id identity to check
|
|
43
38
|
* @returns the error or null if valid
|
|
44
39
|
*/
|
|
45
|
-
function
|
|
40
|
+
function identityHasError(id) {
|
|
46
41
|
if (!supportedIdentities.includes(id.type)) {
|
|
47
42
|
return 'identity type not supported';
|
|
48
43
|
}
|
|
@@ -51,4 +46,5 @@ function hasError(id) {
|
|
|
51
46
|
}
|
|
52
47
|
return null;
|
|
53
48
|
}
|
|
49
|
+
exports.identityHasError = identityHasError;
|
|
54
50
|
//# sourceMappingURL=identity.js.map
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":";;;AAAA,iDAAsD;AAEtD,MAAM,mBAAmB,GAAyB;IAChD,qBAAa,CAAC,IAAI,CAAC,gBAAgB;IACnC,qBAAa,CAAC,IAAI,CAAC,uBAAuB;CAC3C,CAAC;AAKqE,kDAAmB;AAE1F;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,GAA6B,EAAE,GAA6B;IACtF,OAAO,CACL,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,GAAG;QACL,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI;QACrB,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CACxE,CAAC;AACJ,CAAC;AAhBQ,gDAAkB;AAkB3B;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,KAAa;IAC3C,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC;AA1B8C,wDAAsB;AA4BrE;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,EAA2B;IACnD,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;QAC1C,OAAO,6BAA6B,CAAC;KACtC;IACD,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,KAAK,IAAI,EAAE;QAClD,OAAO,4CAA4C,CAAC;KACrD;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA1C4B,4CAAgB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,84 +1,16 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import SimpleLogger from './simple-logger';
|
|
3
|
-
import estimateGasFees from './estimate-gas-fees';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
estimateGasFees: typeof estimateGasFees;
|
|
6
|
-
min: (a: import("ethers").BigNumberish, b: import("ethers").BigNumberish) => import("ethers").BigNumber;
|
|
7
|
-
max: (a: import("ethers").BigNumberish, b: import("ethers").BigNumberish) => import("ethers").BigNumber;
|
|
8
|
-
deepCopy: <T>(variable: T) => T;
|
|
9
|
-
deepSort: (nestedObject: any) => any;
|
|
10
|
-
flatten2DimensionsArray: <T_1>(twoDimensionsArray: T_1[][]) => T_1[];
|
|
11
|
-
getCurrentTimestampInSecond: () => number;
|
|
12
|
-
isString: (variable: any) => boolean;
|
|
13
|
-
timeoutPromise: <T_2>(promise: Promise<T_2>, timeout: number, message: string) => Promise<T_2>;
|
|
14
|
-
unique: <T_3>(array: T_3[]) => {
|
|
15
|
-
uniqueItems: T_3[];
|
|
16
|
-
duplicates: T_3[];
|
|
17
|
-
};
|
|
18
|
-
uniqueByProperty: <T_4>(array: T_4[], property: keyof T_4) => {
|
|
19
|
-
uniqueItems: T_4[];
|
|
20
|
-
duplicates: T_4[];
|
|
21
|
-
};
|
|
22
|
-
notNull: <T_5>(x: T_5 | null | undefined) => x is T_5;
|
|
23
|
-
setProviderFactory: (providerFactory?: ((network: string | undefined, defaultFactory: (network: string | undefined) => string | import("@ethersproject/abstract-provider").Provider) => string | import("@ethersproject/abstract-provider").Provider) | undefined) => void;
|
|
24
|
-
initPaymentDetectionApiKeys: (defaultProviderOptions?: Record<string, string | (() => string)> | undefined) => void;
|
|
25
|
-
getDefaultProvider: (network?: string | undefined) => import("@ethersproject/abstract-provider").Provider;
|
|
26
|
-
getCeloProvider: () => import("@ethersproject/abstract-provider").Provider;
|
|
27
|
-
networkRpcs: Record<string, string>;
|
|
28
|
-
SimpleLogger: typeof SimpleLogger;
|
|
29
|
-
amount: {
|
|
30
|
-
add: (amount: import("types/dist/request-logic-types").Amount, delta: import("types/dist/request-logic-types").Amount) => string;
|
|
31
|
-
isValid: (amount: import("types/dist/request-logic-types").Amount | import("ethers").BigNumber) => boolean;
|
|
32
|
-
reduce: (amount: import("types/dist/request-logic-types").Amount, delta: import("types/dist/request-logic-types").Amount) => string;
|
|
33
|
-
};
|
|
34
|
-
cachedThrottle: <TParams extends unknown[], TReturn>(target: (...params: TParams) => Promise<TReturn>, minimumDelay: number) => (...params: TParams) => Promise<TReturn>;
|
|
35
|
-
crypto: {
|
|
36
|
-
CryptoWrapper: {
|
|
37
|
-
decryptWithAes256cbc: (encryptedAndIv: Buffer, key: Buffer) => Promise<Buffer>;
|
|
38
|
-
decryptWithAes256gcm: (encryptedAndIv: Buffer, key: Buffer) => Promise<Buffer>;
|
|
39
|
-
encryptWithAes256cbc: (data: Buffer, key: Buffer) => Promise<Buffer>;
|
|
40
|
-
encryptWithAes256gcm: (data: Buffer, key: Buffer) => Promise<Buffer>;
|
|
41
|
-
random32Bytes: () => Promise<Buffer>;
|
|
42
|
-
};
|
|
43
|
-
EcUtils: {
|
|
44
|
-
decrypt: (privateKey: string, encrypted: string) => Promise<string>;
|
|
45
|
-
encrypt: (publicKey: string, data: string) => Promise<string>;
|
|
46
|
-
getAddressFromPrivateKey: (privateKey: string) => string;
|
|
47
|
-
getAddressFromPublicKey: (publicKey: string) => string;
|
|
48
|
-
recover: (signature: string, data: string) => string;
|
|
49
|
-
sign: (privateKey: string, data: string) => string;
|
|
50
|
-
};
|
|
51
|
-
generate32BufferKey: () => Promise<string>;
|
|
52
|
-
generate8randomBytes: () => Promise<string>;
|
|
53
|
-
keccak256Hash: (data: string) => string;
|
|
54
|
-
last20bytesOfNormalizedKeccak256Hash: (data: unknown) => string;
|
|
55
|
-
normalize: (data: unknown) => string;
|
|
56
|
-
normalizeKeccak256Hash: (data: unknown) => import("types/dist/multi-format/hash-types").IHash;
|
|
57
|
-
};
|
|
58
|
-
encryption: {
|
|
59
|
-
decrypt: (encryptedData: import("types/dist/encryption-types").IEncryptedData, decryptionParams: import("types/dist/encryption-types").IDecryptionParameters) => Promise<string>;
|
|
60
|
-
encrypt: (data: string, encryptionParams: import("types/dist/encryption-types").IEncryptionParameters) => Promise<import("types/dist/encryption-types").IEncryptedData>;
|
|
61
|
-
getIdentityFromEncryptionParams: (encryptionParams: import("types/dist/encryption-types").IEncryptionParameters) => import("types/dist/identity-types").IIdentity;
|
|
62
|
-
};
|
|
63
|
-
identity: {
|
|
64
|
-
areEqual: (id1?: import("types/dist/identity-types").IIdentity | undefined, id2?: import("types/dist/identity-types").IIdentity | undefined) => boolean;
|
|
65
|
-
hasError: (id: import("types/dist/identity-types").IIdentity) => string | null;
|
|
66
|
-
normalizeIdentityValue: (value: string) => string;
|
|
67
|
-
supportedIdentities: import("types/dist/identity-types").TYPE[];
|
|
68
|
-
};
|
|
69
|
-
retry: <TParams_1 extends unknown[], TReturn_1>(target: (...params: TParams_1) => TReturn_1 | Promise<TReturn_1>, { context, maxRetries, retryDelay, }?: {
|
|
70
|
-
context?: ThisParameterType<(...params: TParams_1) => Promise<TReturn_1>> | undefined;
|
|
71
|
-
maxRetries?: number | undefined;
|
|
72
|
-
retryDelay?: number | undefined;
|
|
73
|
-
}) => (...params: TParams_1) => Promise<TReturn_1>;
|
|
74
|
-
signature: {
|
|
75
|
-
getIdentityFromSignatureParams: (signatureParams: import("types/dist/signature-types").ISignatureParameters) => import("types/dist/identity-types").IIdentity;
|
|
76
|
-
recover: (signedData: import("types/dist/signature-types").ISignedData) => import("types/dist/identity-types").IIdentity;
|
|
77
|
-
sign: (data: unknown, signatureParams: import("types/dist/signature-types").ISignatureParameters) => import("types/dist/signature-types").ISignedData;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
1
|
/**
|
|
81
2
|
* Collection of general purpose utility function
|
|
82
3
|
*/
|
|
83
|
-
export
|
|
4
|
+
export { addAmount, isValidAmount, reduceAmount } from './amount';
|
|
5
|
+
export { minBigNumber, maxBigNumber } from './bignumber';
|
|
6
|
+
export { cachedThrottle } from './cached-throttle';
|
|
7
|
+
export { decryptWithAes256cbc, decryptWithAes256gcm, encryptWithAes256cbc, encryptWithAes256gcm, random32Bytes, ecDecrypt, ecEncrypt, getAddressFromPrivateKey, getAddressFromPublicKey, ecRecover, ecSign, generate32BufferKey, generate8randomBytes, keccak256Hash, last20bytesOfNormalizedKeccak256Hash, normalize, normalizeKeccak256Hash, } from './crypto';
|
|
8
|
+
export { decrypt, encrypt, getIdentityFromEncryptionParams } from './encryption';
|
|
9
|
+
export { estimateGasFees } from './estimate-gas-fees';
|
|
10
|
+
export { areEqualIdentities, identityHasError, normalizeIdentityValue, supportedIdentities, } from './identity';
|
|
11
|
+
export { setProviderFactory, initPaymentDetectionApiKeys, getDefaultProvider, getCeloProvider, networkRpcs, } from './providers';
|
|
12
|
+
export { retry } from './retry';
|
|
13
|
+
export { getIdentityFromSignatureParams, recoverSigner, sign } from './signature';
|
|
14
|
+
export { SimpleLogger } from './simple-logger';
|
|
15
|
+
export { deepCopy, deepSort, flatten2DimensionsArray, getCurrentTimestampInSecond, isString, timeoutPromise, unique, uniqueByProperty, notNull, } from './utils';
|
|
84
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,SAAS,EACT,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACT,MAAM,EACN,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,oCAAoC,EACpC,SAAS,EACT,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,8BAA8B,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,2BAA2B,EAC3B,QAAQ,EACR,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,OAAO,GACR,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const amount_1 = require("./amount");
|
|
4
|
-
const cached_throttle_1 = require("./cached-throttle");
|
|
5
|
-
const crypto_1 = require("./crypto");
|
|
6
|
-
const encryption_1 = require("./encryption");
|
|
7
|
-
const identity_1 = require("./identity");
|
|
8
|
-
const retry_1 = require("./retry");
|
|
9
|
-
const signature_1 = require("./signature");
|
|
10
|
-
const simple_logger_1 = require("./simple-logger");
|
|
11
|
-
const utils_1 = require("./utils");
|
|
12
|
-
const providers_1 = require("./providers");
|
|
13
|
-
const bignumber_1 = require("./bignumber");
|
|
14
|
-
const estimate_gas_fees_1 = require("./estimate-gas-fees");
|
|
15
2
|
/**
|
|
16
3
|
* Collection of general purpose utility function
|
|
17
4
|
*/
|
|
18
|
-
exports
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.notNull = exports.uniqueByProperty = exports.unique = exports.timeoutPromise = exports.isString = exports.getCurrentTimestampInSecond = exports.flatten2DimensionsArray = exports.deepSort = exports.deepCopy = exports.SimpleLogger = exports.sign = exports.recoverSigner = exports.getIdentityFromSignatureParams = exports.retry = exports.networkRpcs = exports.getCeloProvider = exports.getDefaultProvider = exports.initPaymentDetectionApiKeys = exports.setProviderFactory = exports.supportedIdentities = exports.normalizeIdentityValue = exports.identityHasError = exports.areEqualIdentities = exports.estimateGasFees = exports.getIdentityFromEncryptionParams = exports.encrypt = exports.decrypt = exports.normalizeKeccak256Hash = exports.normalize = exports.last20bytesOfNormalizedKeccak256Hash = exports.keccak256Hash = exports.generate8randomBytes = exports.generate32BufferKey = exports.ecSign = exports.ecRecover = exports.getAddressFromPublicKey = exports.getAddressFromPrivateKey = exports.ecEncrypt = exports.ecDecrypt = exports.random32Bytes = exports.encryptWithAes256gcm = exports.encryptWithAes256cbc = exports.decryptWithAes256gcm = exports.decryptWithAes256cbc = exports.cachedThrottle = exports.maxBigNumber = exports.minBigNumber = exports.reduceAmount = exports.isValidAmount = exports.addAmount = void 0;
|
|
7
|
+
var amount_1 = require("./amount");
|
|
8
|
+
Object.defineProperty(exports, "addAmount", { enumerable: true, get: function () { return amount_1.addAmount; } });
|
|
9
|
+
Object.defineProperty(exports, "isValidAmount", { enumerable: true, get: function () { return amount_1.isValidAmount; } });
|
|
10
|
+
Object.defineProperty(exports, "reduceAmount", { enumerable: true, get: function () { return amount_1.reduceAmount; } });
|
|
11
|
+
var bignumber_1 = require("./bignumber");
|
|
12
|
+
Object.defineProperty(exports, "minBigNumber", { enumerable: true, get: function () { return bignumber_1.minBigNumber; } });
|
|
13
|
+
Object.defineProperty(exports, "maxBigNumber", { enumerable: true, get: function () { return bignumber_1.maxBigNumber; } });
|
|
14
|
+
var cached_throttle_1 = require("./cached-throttle");
|
|
15
|
+
Object.defineProperty(exports, "cachedThrottle", { enumerable: true, get: function () { return cached_throttle_1.cachedThrottle; } });
|
|
16
|
+
var crypto_1 = require("./crypto");
|
|
17
|
+
Object.defineProperty(exports, "decryptWithAes256cbc", { enumerable: true, get: function () { return crypto_1.decryptWithAes256cbc; } });
|
|
18
|
+
Object.defineProperty(exports, "decryptWithAes256gcm", { enumerable: true, get: function () { return crypto_1.decryptWithAes256gcm; } });
|
|
19
|
+
Object.defineProperty(exports, "encryptWithAes256cbc", { enumerable: true, get: function () { return crypto_1.encryptWithAes256cbc; } });
|
|
20
|
+
Object.defineProperty(exports, "encryptWithAes256gcm", { enumerable: true, get: function () { return crypto_1.encryptWithAes256gcm; } });
|
|
21
|
+
Object.defineProperty(exports, "random32Bytes", { enumerable: true, get: function () { return crypto_1.random32Bytes; } });
|
|
22
|
+
Object.defineProperty(exports, "ecDecrypt", { enumerable: true, get: function () { return crypto_1.ecDecrypt; } });
|
|
23
|
+
Object.defineProperty(exports, "ecEncrypt", { enumerable: true, get: function () { return crypto_1.ecEncrypt; } });
|
|
24
|
+
Object.defineProperty(exports, "getAddressFromPrivateKey", { enumerable: true, get: function () { return crypto_1.getAddressFromPrivateKey; } });
|
|
25
|
+
Object.defineProperty(exports, "getAddressFromPublicKey", { enumerable: true, get: function () { return crypto_1.getAddressFromPublicKey; } });
|
|
26
|
+
Object.defineProperty(exports, "ecRecover", { enumerable: true, get: function () { return crypto_1.ecRecover; } });
|
|
27
|
+
Object.defineProperty(exports, "ecSign", { enumerable: true, get: function () { return crypto_1.ecSign; } });
|
|
28
|
+
Object.defineProperty(exports, "generate32BufferKey", { enumerable: true, get: function () { return crypto_1.generate32BufferKey; } });
|
|
29
|
+
Object.defineProperty(exports, "generate8randomBytes", { enumerable: true, get: function () { return crypto_1.generate8randomBytes; } });
|
|
30
|
+
Object.defineProperty(exports, "keccak256Hash", { enumerable: true, get: function () { return crypto_1.keccak256Hash; } });
|
|
31
|
+
Object.defineProperty(exports, "last20bytesOfNormalizedKeccak256Hash", { enumerable: true, get: function () { return crypto_1.last20bytesOfNormalizedKeccak256Hash; } });
|
|
32
|
+
Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return crypto_1.normalize; } });
|
|
33
|
+
Object.defineProperty(exports, "normalizeKeccak256Hash", { enumerable: true, get: function () { return crypto_1.normalizeKeccak256Hash; } });
|
|
34
|
+
var encryption_1 = require("./encryption");
|
|
35
|
+
Object.defineProperty(exports, "decrypt", { enumerable: true, get: function () { return encryption_1.decrypt; } });
|
|
36
|
+
Object.defineProperty(exports, "encrypt", { enumerable: true, get: function () { return encryption_1.encrypt; } });
|
|
37
|
+
Object.defineProperty(exports, "getIdentityFromEncryptionParams", { enumerable: true, get: function () { return encryption_1.getIdentityFromEncryptionParams; } });
|
|
38
|
+
var estimate_gas_fees_1 = require("./estimate-gas-fees");
|
|
39
|
+
Object.defineProperty(exports, "estimateGasFees", { enumerable: true, get: function () { return estimate_gas_fees_1.estimateGasFees; } });
|
|
40
|
+
var identity_1 = require("./identity");
|
|
41
|
+
Object.defineProperty(exports, "areEqualIdentities", { enumerable: true, get: function () { return identity_1.areEqualIdentities; } });
|
|
42
|
+
Object.defineProperty(exports, "identityHasError", { enumerable: true, get: function () { return identity_1.identityHasError; } });
|
|
43
|
+
Object.defineProperty(exports, "normalizeIdentityValue", { enumerable: true, get: function () { return identity_1.normalizeIdentityValue; } });
|
|
44
|
+
Object.defineProperty(exports, "supportedIdentities", { enumerable: true, get: function () { return identity_1.supportedIdentities; } });
|
|
45
|
+
var providers_1 = require("./providers");
|
|
46
|
+
Object.defineProperty(exports, "setProviderFactory", { enumerable: true, get: function () { return providers_1.setProviderFactory; } });
|
|
47
|
+
Object.defineProperty(exports, "initPaymentDetectionApiKeys", { enumerable: true, get: function () { return providers_1.initPaymentDetectionApiKeys; } });
|
|
48
|
+
Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return providers_1.getDefaultProvider; } });
|
|
49
|
+
Object.defineProperty(exports, "getCeloProvider", { enumerable: true, get: function () { return providers_1.getCeloProvider; } });
|
|
50
|
+
Object.defineProperty(exports, "networkRpcs", { enumerable: true, get: function () { return providers_1.networkRpcs; } });
|
|
51
|
+
var retry_1 = require("./retry");
|
|
52
|
+
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return retry_1.retry; } });
|
|
53
|
+
var signature_1 = require("./signature");
|
|
54
|
+
Object.defineProperty(exports, "getIdentityFromSignatureParams", { enumerable: true, get: function () { return signature_1.getIdentityFromSignatureParams; } });
|
|
55
|
+
Object.defineProperty(exports, "recoverSigner", { enumerable: true, get: function () { return signature_1.recoverSigner; } });
|
|
56
|
+
Object.defineProperty(exports, "sign", { enumerable: true, get: function () { return signature_1.sign; } });
|
|
57
|
+
var simple_logger_1 = require("./simple-logger");
|
|
58
|
+
Object.defineProperty(exports, "SimpleLogger", { enumerable: true, get: function () { return simple_logger_1.SimpleLogger; } });
|
|
59
|
+
var utils_1 = require("./utils");
|
|
60
|
+
Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return utils_1.deepCopy; } });
|
|
61
|
+
Object.defineProperty(exports, "deepSort", { enumerable: true, get: function () { return utils_1.deepSort; } });
|
|
62
|
+
Object.defineProperty(exports, "flatten2DimensionsArray", { enumerable: true, get: function () { return utils_1.flatten2DimensionsArray; } });
|
|
63
|
+
Object.defineProperty(exports, "getCurrentTimestampInSecond", { enumerable: true, get: function () { return utils_1.getCurrentTimestampInSecond; } });
|
|
64
|
+
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return utils_1.isString; } });
|
|
65
|
+
Object.defineProperty(exports, "timeoutPromise", { enumerable: true, get: function () { return utils_1.timeoutPromise; } });
|
|
66
|
+
Object.defineProperty(exports, "unique", { enumerable: true, get: function () { return utils_1.unique; } });
|
|
67
|
+
Object.defineProperty(exports, "uniqueByProperty", { enumerable: true, get: function () { return utils_1.uniqueByProperty; } });
|
|
68
|
+
Object.defineProperty(exports, "notNull", { enumerable: true, get: function () { return utils_1.notNull; } });
|
|
26
69
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mCAAkE;AAAzD,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AAE/C,yCAAyD;AAAhD,yGAAA,YAAY,OAAA;AAAE,yGAAA,YAAY,OAAA;AAEnC,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAEvB,mCAkBkB;AAjBhB,8GAAA,oBAAoB,OAAA;AACpB,8GAAA,oBAAoB,OA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