Repository navigation
Drop axios in favor of native fetch - #67
Merged
Merged
Conversation
- Replace axios with the platform's built-in fetch. No runtime dependencies left at all. - Errors now carry an isRateLimited flag (HTTP 429, or a GraphQL error body containing a known rate-limit marker such as AUT_00021) so callers can back off instead of hammering a throttled account. - Network-level failures (DNS, timeout, reset) surface their original message instead of a generic "fetch failed". - Constructor accepts an optional dispatcher for test injection (undici MockAgent), used by the rewritten test suite. - Bump minimum Node.js to 18, update dev tooling (eslint 8, eslint-config-airbnb-base 15, jest 29), update CI matrix. - Drop unused pre-GraphQL test fixtures.
Owner
Author
|
Manually verified against a real Verisure account (login, MFA, cookie output, and |
Owner
Author
|
Same story as over on homebridge-verisure: sorry for the long silence, I haven't forgotten about this project. Time to bring it back to life properly — starting with cleaning up this transport layer while I'm at it. |
ptz0n
added a commit
to ptz0n/homebridge-verisure
that referenced
this pull request
Sep 26, 2026
Switches from the local npm-linked checkout (used for manual testing during development) to the real published package now that ptz0n/node-verisure#67 is merged and released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the
axiosruntime dependency with the platform's nativefetch.verisurenow has zero runtime dependencies.Why
Node 18+ has had a built-in
fetchfor a while now, and this module's HTTP needs are simple enough (JSON bodies, Basic auth, readingSet-Cookie) that a full HTTP client dependency isn't earning its keep. This also happened while working on the homebridge-verisure TypeScript rewrite, which bumps its own minimum Node version, so it's a natural time to do this here too.Changes
index.js:fetchinstead ofaxios. Manual Basic-auth header construction, JSON body/content-type handling, and reading multipleSet-Cookieheaders viaResponse.headers.getSetCookie()(Node 18.14+/undici).errors.js: errors now carry anisRateLimitedflag when the response is an HTTP 429, or a GraphQL error body containing a marker Verisure is known to use for rate/quota limits (e.g.AUT_00021) - even when wrapped in an otherwise-200 GraphQL response. Lets callers (like homebridge-verisure) back off instead of retrying into an already-rate-limited account."fetch failed"(fetch wraps these in a genericTypeErrorwith the real cause nested under.cause).{ dispatcher }, purely for test injection (an undiciMockAgent) - production callers never need it.nocktoundici'sMockAgent, injected explicitly via the new constructor option rather than the ambient global-dispatcher trick (which doesn't reliably cross Jest's per-file VM realm boundary).Breaking
HttpErrorrather than an axios error object, though the sameerror.response.status/error.response.datashape is preserved for compatibility with existing callers.Full test suite passes locally (
npm test: eslint + jest, 100% statement coverage on the changed files).