Commit 6c4c717
fix(sdk): Add token expiry tracking and retry logic to OAuth (#14078)
## Summary
- Adds `getAccessTokenExpiry()` / `getRefreshTokenExpiry()` to
`OAuthTokenStore` interface and all three implementations (Memory,
LocalStorage, AsyncStorage)
- `isAuthenticated()` now checks token expiry — returns false when
refresh token is expired, attempts silent refresh when access token is
expired
- `getUser()` retries once with a refreshed token on 401 instead of
immediately throwing
- `setTokens()` now accepts optional `expiresIn` / `refreshExpiresIn`
(seconds), which are persisted as absolute epoch timestamps
**Note:** Companion API change to return `refresh_expires_in` in the
token response: AudiusProject/api#756
## Test plan
- [x] All existing OAuth tests pass (74/74)
- [ ] `isAuthenticated()` returns false when refresh token is expired
- [ ] `isAuthenticated()` silently refreshes when access token is
expired but refresh token is valid
- [ ] `getUser()` retries and succeeds after token refresh on 401
- [ ] `getUser()` throws when both initial request and refresh fail
- [ ] Token expiry survives page reload (localStorage) and app restart
(AsyncStorage)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>1 parent 9071973 commit 6c4c717
File tree
11 files changed
+501
-28
lines changed- .changeset
- packages/sdk/src/sdk/oauth
11 files changed
+501
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
497 | 501 | | |
498 | 502 | | |
499 | 503 | | |
500 | | - | |
| 504 | + | |
501 | 505 | | |
502 | 506 | | |
503 | 507 | | |
| |||
508 | 512 | | |
509 | 513 | | |
510 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
511 | 569 | | |
512 | 570 | | |
513 | 571 | | |
| |||
568 | 626 | | |
569 | 627 | | |
570 | 628 | | |
571 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
572 | 678 | | |
573 | 679 | | |
574 | 680 | | |
575 | | - | |
| 681 | + | |
576 | 682 | | |
577 | 683 | | |
578 | 684 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
302 | 325 | | |
303 | 326 | | |
304 | 327 | | |
| |||
315 | 338 | | |
316 | 339 | | |
317 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
318 | 344 | | |
319 | 345 | | |
320 | 346 | | |
321 | 347 | | |
322 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
323 | 364 | | |
324 | 365 | | |
325 | 366 | | |
326 | 367 | | |
327 | 368 | | |
328 | | - | |
329 | 369 | | |
330 | | - | |
| 370 | + | |
331 | 371 | | |
332 | 372 | | |
333 | 373 | | |
334 | 374 | | |
335 | 375 | | |
336 | 376 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | 377 | | |
343 | 378 | | |
344 | 379 | | |
| |||
369 | 404 | | |
370 | 405 | | |
371 | 406 | | |
372 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
373 | 410 | | |
374 | 411 | | |
375 | 412 | | |
| |||
433 | 470 | | |
434 | 471 | | |
435 | 472 | | |
436 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
437 | 476 | | |
438 | 477 | | |
439 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
19 | 40 | | |
20 | 41 | | |
21 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
22 | 64 | | |
23 | 65 | | |
24 | 66 | | |
25 | 67 | | |
26 | 68 | | |
27 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
28 | 72 | | |
29 | 73 | | |
30 | 74 | | |
0 commit comments