Improved
Node M2M Auth SDK Refactor/Deprecation
8 days ago by Jim Verducci
Initial release of @wristband/typescript-m2m-auth, a full rewrite and rename of the former
@wristband/node-m2m-auth package. The SDK has been redesigned to be runtime-agnostic,
async-only, and dependency-free. The @wristband/node-m2m-auth is now considered deprecated.
- SDK: https://github.com/wristband-dev/typescript-m2m-auth
- Demo App: https://github.com/wristband-dev/m2m-expressjs-demo-app
Breaking Changes
- Package renamed from
@wristband/node-m2m-authto@wristband/typescript-m2m-auth - Config key renamed:
appDomain→wristbandApplicationVanityDomain - Instantiation changed: direct class instantiation (
new WristbandM2MAuthClient()) replaced by factory function (createWristbandM2MClient()) - Sync client removed: SDK is now async-only — no synchronous variant
destroy()method removed: background refresh now uses recursivesetTimeoutwith.unref?.()— no manual cleanup required
Added
createWristbandM2MClient(config)factory function as the sole public instantiation APIWristbandM2MClientpublic TypeScript interface for consumersWristbandM2MAuthConfiginterface with optionaltokenExpirationBufferandbackgroundTokenRefreshIntervalfieldsTokenRequestErrorcustom error class for 5xx detection and retry logic- Automatic retry on 5xx errors — 3 attempts with 100ms delay between each
- Background token refresh via recursive
setTimeoutwith.unref?.()for Node.js, Deno, and Bun compatibility. clearToken()method to manually invalidate the cached token- ESM + CJS dual output; UMD is no longer supported
- Zero runtime dependencies
- Full test suite coverage
- npm audit vulnerabilities fixed
Changed
- Minimum Node.js version raised to 20
- TypeScript raised to ^5.x
- All token expiration logic uses
Date.now()throughout sleep()extracted as an exported utility for testability- Migrated build to Rollup
Deprecated
@wristband/node-m2m-auth: use@wristband/typescript-m2m-authgoing forward