(
authorizationServerUrl: string | URL,
{
metadata,
clientInformation,
refreshToken,
resource,
addClientAuthentication,
fetchFn
}: {
metadata?: AuthorizationServerMetadata;
clientInformation: OAuthClientInformationMixed;
refreshToken: string;
resource?: URL;
addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
fetchFn?: FetchLike;
}
)
| 1317 | * @throws {Error} When token refresh fails or authentication is invalid |
| 1318 | */ |
| 1319 | export async function refreshAuthorization( |
| 1320 | authorizationServerUrl: string | URL, |
| 1321 | { |
| 1322 | metadata, |
| 1323 | clientInformation, |
| 1324 | refreshToken, |
| 1325 | resource, |
| 1326 | addClientAuthentication, |
| 1327 | fetchFn |
| 1328 | }: { |
| 1329 | metadata?: AuthorizationServerMetadata; |
| 1330 | clientInformation: OAuthClientInformationMixed; |
| 1331 | refreshToken: string; |
| 1332 | resource?: URL; |
| 1333 | addClientAuthentication?: OAuthClientProvider['addClientAuthentication']; |
| 1334 | fetchFn?: FetchLike; |
| 1335 | } |
| 1336 | ): Promise<OAuthTokens> { |
| 1337 | const tokenRequestParams = new URLSearchParams({ |
| 1338 | grant_type: 'refresh_token', |
| 1339 | refresh_token: refreshToken |
| 1340 | }); |
| 1341 | |
| 1342 | const tokens = await executeTokenRequest(authorizationServerUrl, { |
| 1343 | metadata, |
| 1344 | tokenRequestParams, |
| 1345 | clientInformation, |
| 1346 | addClientAuthentication, |
| 1347 | resource, |
| 1348 | fetchFn |
| 1349 | }); |
| 1350 | |
| 1351 | // Preserve original refresh token if server didn't return a new one |
| 1352 | return { refresh_token: refreshToken, ...tokens }; |
| 1353 | } |
| 1354 | |
| 1355 | /** |
| 1356 | * Unified token fetching that works with any grant type via provider.prepareTokenRequest(). |
no test coverage detected
searching dependent graphs…