(refresh_token: string)
| 162 | } |
| 163 | |
| 164 | private async tryRefresh(refresh_token: string): Promise<OAuthTokens | null> { |
| 165 | if (!this.onRefresh) return null; |
| 166 | try { |
| 167 | return await this.onRefresh(refresh_token); |
| 168 | } catch (err) { |
| 169 | // Refresh failure should be surfaced upstream by the caller via |
| 170 | // the retry's 401, not by throwing here — so callers consistently |
| 171 | // see "please log in again" rather than mixed error types. |
| 172 | if (isAuthError(err) && err.code === "REFRESH_FAILED") return null; |
| 173 | throw err; |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | export function buildAuthHeaders(credential: ResolvedCredential): Record<string, string> { |
no test coverage detected