postchain-client 2.0.4 → 2.1.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 +9 -7
- package/built/cjs/index.js +235 -118
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +19045 -17598
- package/built/esm/index.js.map +1 -1
- package/built/mocks/handlers.d.ts +8 -8
- package/built/mocks/handlers.js +4 -2
- package/built/mocks/handlers.js.map +1 -1
- package/built/mocks/servers.d.ts +1 -1
- package/built/resources/testData.d.ts +1 -2
- package/built/src/ICCF/IccfProofTxMaterialBuilder.d.ts +0 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js +3 -2
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/ICCF/error.d.ts +0 -1
- package/built/src/ICCF/interfaces.d.ts +0 -1
- package/built/src/ICCF/types.d.ts +0 -1
- package/built/src/ICCF/utils.d.ts +0 -1
- package/built/src/ICCF/utils.js +3 -1
- package/built/src/ICCF/utils.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +10 -10
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/errors.d.ts +0 -1
- package/built/src/blockchainClient/failoverStrategies.d.ts +5 -4
- package/built/src/blockchainClient/failoverStrategies.js +93 -55
- package/built/src/blockchainClient/failoverStrategies.js.map +1 -1
- package/built/src/blockchainClient/httpUtil.d.ts +0 -1
- package/built/src/blockchainClient/httpUtil.js +7 -2
- package/built/src/blockchainClient/httpUtil.js.map +1 -1
- package/built/src/blockchainClient/interface.d.ts +0 -1
- package/built/src/blockchainClient/nodeManager.d.ts +10 -7
- package/built/src/blockchainClient/nodeManager.js +47 -20
- package/built/src/blockchainClient/nodeManager.js.map +1 -1
- package/built/src/blockchainClient/requestWithFailoverStrategy.d.ts +0 -1
- package/built/src/blockchainClient/requestWithFailoverStrategy.js +2 -2
- package/built/src/blockchainClient/requestWithFailoverStrategy.js.map +1 -1
- package/built/src/blockchainClient/types.d.ts +2 -1
- package/built/src/blockchainClient/utils.d.ts +1 -2
- package/built/src/blockchainClient/utils.js +20 -15
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/src/blockchainClient/validation/anchoringTransaction.d.ts +6 -7
- package/built/src/blockchainClient/validation/blockIdentifier.d.ts +2 -2
- package/built/src/blockchainClient/validation/blockIdentifier.js +4 -4
- package/built/src/blockchainClient/validation/blockIdentifier.js.map +1 -1
- package/built/src/blockchainClient/validation/bufferSchema.d.ts +1 -2
- package/built/src/blockchainClient/validation/networkSettings.d.ts +2 -2
- package/built/src/blockchainClient/validation/networkSettings.js +2 -2
- package/built/src/blockchainClient/validation/networkSettings.js.map +1 -1
- package/built/src/blockchainClient/validation/signMethod.d.ts +12 -13
- package/built/src/blockchainClient/validation/txRid.d.ts +1 -2
- package/built/src/encryption/encryption.d.ts +0 -1
- package/built/src/encryption/errors.d.ts +0 -1
- package/built/src/encryption/types.d.ts +0 -1
- package/built/src/formatter.d.ts +1 -2
- package/built/src/formatter.js +3 -4
- package/built/src/formatter.js.map +1 -1
- package/built/src/gtv/index.d.ts +1 -2
- package/built/src/gtv/types.d.ts +0 -1
- package/built/src/gtx/gtx.d.ts +0 -1
- package/built/src/gtx/gtx.js +2 -1
- package/built/src/gtx/gtx.js.map +1 -1
- package/built/src/gtx/serialization.d.ts +0 -1
- package/built/src/gtx/types.d.ts +0 -1
- package/built/src/utils/bufferUtils.d.ts +6 -0
- package/built/src/utils/bufferUtils.js +9 -0
- package/built/src/utils/bufferUtils.js.map +1 -0
- package/built/src/utils/calculateTransactionRid.d.ts +0 -1
- package/built/src/utils/decodeTransactionToGtx.d.ts +0 -1
- package/built/src/utils/encodeTransaction.d.ts +0 -1
- package/built/src/utils/http-utils.d.ts +19 -0
- package/built/src/utils/http-utils.js +36 -0
- package/built/src/utils/http-utils.js.map +1 -0
- package/built/test/common/mocks.d.ts +23 -24
- package/built/test/common/setups.d.ts +3 -4
- package/built/test/common/signatures.d.ts +9 -10
- package/built/test/common/validationMocks.d.ts +2 -3
- package/built/test/integration/clientQuery.test.js.map +1 -1
- package/built/test/integration/clientSendTransaction.test.js +1 -1
- package/built/test/integration/clientSendTransaction.test.js.map +1 -1
- package/built/test/integration/createClientIntegration.test.js +5 -21
- package/built/test/integration/createClientIntegration.test.js.map +1 -1
- package/built/test/integration/failoverStrategiesWithSmartTimeouts.test.d.ts +1 -0
- package/built/test/integration/failoverStrategiesWithSmartTimeouts.test.js +140 -0
- package/built/test/integration/failoverStrategiesWithSmartTimeouts.test.js.map +1 -0
- package/built/test/manual/iccfManually.test.js +2 -2
- package/built/test/manual/iccfManually.test.js.map +1 -1
- package/built/test/pcctf/helpers.js +2 -2
- package/built/test/pcctf/helpers.js.map +1 -1
- package/built/test/unit/ICCF/iccf.test.js +7 -4
- package/built/test/unit/ICCF/iccf.test.js.map +1 -1
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js +2 -2
- package/built/test/unit/failoverStrategies.test.js +36 -15
- package/built/test/unit/failoverStrategies.test.js.map +1 -1
- package/built/test/unit/networkErrorDetection.test.d.ts +1 -0
- package/built/test/unit/networkErrorDetection.test.js +433 -0
- package/built/test/unit/networkErrorDetection.test.js.map +1 -0
- package/built/test/unit/nodeMananger.test.js +3 -2
- package/built/test/unit/nodeMananger.test.js.map +1 -1
- package/built/test/unit/smartTimeouts.test.d.ts +1 -0
- package/built/test/unit/smartTimeouts.test.js +296 -0
- package/built/test/unit/smartTimeouts.test.js.map +1 -0
- package/built/test/unit/stickyNode.test.js +13 -13
- package/built/test/unit/stickyNode.test.js.map +1 -1
- package/built/test/unit/universalNodeRecovery.test.d.ts +1 -0
- package/built/test/unit/universalNodeRecovery.test.js +283 -0
- package/built/test/unit/universalNodeRecovery.test.js.map +1 -0
- package/built/umd/index.js +19070 -17625
- package/built/umd/index.js.map +1 -1
- package/changelog.md +31 -1
- package/package.json +11 -8
package/changelog.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Version 2.0
|
|
1
|
+
Version 2.1.0
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
@@ -11,11 +11,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
### Fixed
|
|
13
13
|
|
|
14
|
+
- browser network errors now default to 502 status code for consistent timeout logic
|
|
15
|
+
- failover loop logic by replacing 'continue' with 'break' to prevent infinite loops
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Universal Node Recovery**: All failover strategies (AbortOnError, TryNextOnError, SingleEndpoint) now automatically recover when available nodes drop below threshold (previously only QueryMajority had recovery)
|
|
20
|
+
- **Smart Error-Specific Timeouts**: Replaced fixed 5-second timeouts with intelligent, error-specific durations:
|
|
21
|
+
- DNS failures (ENOTFOUND): 5 minutes
|
|
22
|
+
- Connection refused (ECONNREFUSED): 5 minutes
|
|
23
|
+
- 500 errors: 10 seconds (server restart)
|
|
24
|
+
- 502 errors: 30 seconds (gateway issues)
|
|
25
|
+
- 503 errors: 2 seconds (load balancer)
|
|
26
|
+
- 504 errors: 60 seconds (upstream timeout)
|
|
27
|
+
- **Enhanced Client Error Handling**: Added detection for non-retriable client errors (e.g., "Unknown query:") to prevent wasteful retries across nodes
|
|
28
|
+
- Optional `recoveryThreshold` parameter in `ClientConfig` and `FailOverConfig` types to customize auto-recovery behavior
|
|
29
|
+
- Network error detection utilities in `http-utils.ts` for better error classification
|
|
30
|
+
- Comprehensive test coverage for universal recovery logic, smart timeouts, and network error scenarios
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- **Node Recovery Logic**: Universal auto-recovery using 2x BFT formula (nodes - floor(2*(nodes-1)/3)) as default threshold for all strategies with 3+ nodes
|
|
35
|
+
- **Error Handling**: Centralized and simplified error classification logic across all failover strategies
|
|
36
|
+
- **Sticky Node Behavior**: Enhanced sticky node preservation during recovery and improved error handling
|
|
37
|
+
- **TryNextOnError Strategy**: Now avoids retrying non-retriable client errors for better efficiency
|
|
38
|
+
- Node availability management with `NetworkNode` class providing better state management
|
|
39
|
+
- Improved error propagation and handling in `retryRequest()` function
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
14
43
|
- importing Buffer to ensure seamless functionality in web browsers
|
|
15
44
|
|
|
16
45
|
### Added
|
|
17
46
|
|
|
18
47
|
- possibility to work with postchain-client in web browsers through cdn
|
|
48
|
+
- migrated npm to pnpm
|
|
19
49
|
|
|
20
50
|
### Changed
|
|
21
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postchain-client",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"main": "built/cjs/index.js",
|
|
5
5
|
"browser": "built/esm/index.js",
|
|
6
6
|
"types": "built/index.d.ts",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test:integration:coverage": "jest test/integration/**/*.test.ts' --coverage",
|
|
36
36
|
"test:chromiaNetwork:coverage": "jest test/integrationChromiaNetwork/**/*.test.ts --coverage",
|
|
37
37
|
"setup:chromiaNetwork": "bash scripts/setup-chromia-network-and-deploy-dapps.sh",
|
|
38
|
-
"build": "
|
|
38
|
+
"build": "pnpm run clean && tsc && rollup -c rollup.config.mjs && echo '{\"type\": \"module\"}' > built/esm/package.json",
|
|
39
39
|
"clean": "rimraf built",
|
|
40
|
-
"prepack": "
|
|
41
|
-
"publish": "
|
|
40
|
+
"prepack": "pnpm run build",
|
|
41
|
+
"publish": "pnpm run prepack && pnpm publish --access public",
|
|
42
42
|
"prepare": "husky install",
|
|
43
43
|
"lint": "eslint . --ext .ts --fix",
|
|
44
44
|
"format": "prettier --write ."
|
|
@@ -57,13 +57,15 @@
|
|
|
57
57
|
"axios": "^1.9.0",
|
|
58
58
|
"crypto-browserify": "^3.12.0",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
|
+
"merklehashts": "^1.0.5",
|
|
60
61
|
"secp256k1": "^4.0.4",
|
|
61
62
|
"stream-browserify": "^3.0.0",
|
|
62
63
|
"uuid": "^11.1.0",
|
|
63
|
-
"zod": "^3.22.4"
|
|
64
|
-
"merklehashts": "^1.0.5"
|
|
64
|
+
"zod": "^3.22.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
+
"@babel/core": "^7.28.5",
|
|
68
|
+
"@babel/preset-env": "^7.28.5",
|
|
67
69
|
"@rollup/plugin-alias": "^4.0.3",
|
|
68
70
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
69
71
|
"@rollup/plugin-inject": "^5.0.3",
|
|
@@ -79,7 +81,7 @@
|
|
|
79
81
|
"@types/secp256k1": "^4.0.3",
|
|
80
82
|
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
|
81
83
|
"@typescript-eslint/parser": "^5.46.0",
|
|
82
|
-
"babel-
|
|
84
|
+
"babel-jest": "^30.2.0",
|
|
83
85
|
"body-parser": "^1.17.1",
|
|
84
86
|
"dotenv": "^16.4.7",
|
|
85
87
|
"eslint": "^8.29.0",
|
|
@@ -100,5 +102,6 @@
|
|
|
100
102
|
"peerDependencies": {
|
|
101
103
|
"buffer": "^5.x || ^6.x",
|
|
102
104
|
"events": "^3.3.0"
|
|
103
|
-
}
|
|
105
|
+
},
|
|
106
|
+
"packageManager": "pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c"
|
|
104
107
|
}
|