v3.0.0: Introduce WebSocket API, upgrade sign to use Web Crypto API, misc WebSocket upgrades, bump build to Node LTS
WebSocket API & Hybrid ESM/CJS
Introducing the next major release, finally bringing full support for OKX's WebSocket API in a convenient REST-like API wrapper.
Key Pull Requests
- feat(v3.0.0): introduce WebSocket API, upgrade sign to use Web Crypto API, misc WebSocket upgrades, bump build to Node LTS by @tiagosiebler in #123
- feat(): upgrade SDK to hybrid esm/cjs module. update import/export statements for new structure by @tiagosiebler in #126
- Update endpoint map & llms by @JJ-Cro in #127
Summary
- Upgraded SDK to hybrid ESM/CJS module (via #126). No breaking changes expected from this.
- Introduce full support for the OKX WebSocket API, including a new dedicated WebsocketAPIClient for a REST-like integration with OKX's WebSocket API. Check the examples folder for demonstrations!
- Bump node build version to LTS.
- Bump dependencies.
- Upgrade underlying BaseWSClient architecture, to catch up with upgrades from other SDKs.
- Transition to Web Crypto API for sign. This has better compatibility across browsers than node's native crypto module. For latency sensitive users, you can inject a custom sign method to continue using Node's native crypto for request sign. See the examples/auth/fasterHmacSign.ts example for a demonstration.
- Introduced customSignMessageFn parameter (REST & WS) to inject custom sign method
- This can be used by latency sensitive users to revert to Node's slightly faster createHmac sign method. See the fasterHmacSign example in examples/auth/ for a demonstration.
- Split CI tests to run separately (first public then private).
Breaking Changes
This upgrade introduces the following breaking changes:
- REST Client constructor options simplified, see #111 for more details.
- The
demomarket for REST & WS has been removed.- Demo trading is now accessed via a
demoTrading: trueparameter (for REST & WS). - Added hard error to prevent any accidental usage of "market: demo" for non-typescript users.
- Demo trading is now accessed via a
- WS Client options
- Type has been updated to point to RestClientOptions.
- To set a custom "agent" parameter, use wsOptions in the WSClientOptions instead.
- The injectable custom logger has been simplified to 3 basic logging levels, consistent with our other SDKs.
errorevent has been refactored toexception
- Not a breaking change but the underlying sign is now generated using Web Crypto API. More universal but slightly slower than node's native crypto module. Refer to fasterHmacSign above, if you're latency sensitive.
Full Changelog: v2.0.8...v3.0.0