( tokenParams: VantaTokenParams, doFetch: (accessToken: string) => Promise<Response> )
| 251 | * revoked the cached token — it retries once with a freshly exchanged token. |
| 252 | */ |
| 253 | export async function fetchVantaWithAuth( |
| 254 | tokenParams: VantaTokenParams, |
| 255 | doFetch: (accessToken: string) => Promise<Response> |
| 256 | ): Promise<Response> { |
| 257 | const accessToken = await getVantaAccessToken(tokenParams) |
| 258 | const response = await doFetch(accessToken) |
| 259 | if (response.status !== 401) { |
| 260 | return response |
| 261 | } |
| 262 | |
| 263 | const freshToken = await getVantaAccessToken(tokenParams, { forceRefresh: true }) |
| 264 | return doFetch(freshToken) |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Builds a Vanta v1 API URL, appending only query parameters that have a |
no test coverage detected