Skip to content

Commit 7ec1564

Browse files
committed
feat: [noci] add onTokenRefresh callback and automatic 401 retry with token refresh
- Add onTokenRefresh callback option to ClientOptions for custom token refresh handling - Implement automatic 401 error detection and token refresh retry for all public API methods - Enhance disconnect() and removeAllListeners() for better WebSocket cleanup - Add comprehensive test coverage for token refresh scenarios and disconnect functionality - Add package-lock.json for dependency locking
1 parent 03c293a commit 7ec1564

File tree

14 files changed

+8515
-45
lines changed

14 files changed

+8515
-45
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# @retconned/kickjs
22

3+
## 0.8.0
4+
5+
### Minor Changes
6+
7+
- feat: add `onTokenRefresh` callback option to ClientOptions
8+
- Allows custom handling of OAuth token refresh events
9+
- Receives new token object: `{ access_token, refresh_token?, expires_in, token_type }`
10+
- Falls back to legacy `updateEnvTokens` behavior when not provided
11+
- Supports both sync and async callbacks with error handling
12+
13+
- feat: add automatic 401 error handling with token refresh retry
14+
- All public API methods now automatically detect 401/unauthorized errors
15+
- Automatically refreshes OAuth tokens using refresh token when 401 occurs
16+
- Retries the original API call with the new token
17+
- Comprehensive error handling for refresh failures and missing credentials
18+
- Enhanced disconnect method with proper WebSocket state checking
19+
20+
- feat: improve token refresh reliability and user experience
21+
- Enhanced `removeAllListeners()` to properly clear all event listeners
22+
- Added comprehensive test coverage for disconnect functionality
23+
- Added extensive test coverage for 401 retry scenarios and token refresh callbacks
24+
- Fixed token refresh logic to handle edge cases and provide better error messages
25+
326
## 0.7.0
427

528
### Minor Changes

0 commit comments

Comments
 (0)