@hyper.authio/client 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -126,8 +126,9 @@ client's front-channel logout URI in an iframe; `validateFrontChannelLogout(requ
126
126
 
127
127
  ### Step-up
128
128
 
129
- When an API answers `403` with `WWW-Authenticate: Bearer error="insufficient_user_authentication", acr_values="2",
130
- max_age=300` (RFC 9470):
129
+ When an API answers `401` with `WWW-Authenticate: Bearer error="insufficient_user_authentication", acr_values="2",
130
+ max_age=300` (RFC 9470 §3; servers before `@hyper.authio/server` 0.8.1 and `@hyper.authio/mcp` 0.4.1 answer `403`, and
131
+ the challenge reads the same):
131
132
 
132
133
  ```ts
133
134
  const challenge = parseAuthioBearerChallenge(response.headers.get("www-authenticate"));
package/dist/index.cjs CHANGED
@@ -1339,13 +1339,16 @@ function createAuthioClient(options) {
1339
1339
  };
1340
1340
  const token = await clientCredentials.getToken({ ...key, signal: request.signal });
1341
1341
  const response = await attempt(token);
1342
- if (response.status !== 401) return response;
1342
+ if (response.status !== 401 || isStepUpChallenge(response)) return response;
1343
1343
  clientCredentials.invalidate({ ...key, accessToken: token.accessToken });
1344
1344
  return attempt(await clientCredentials.getToken({ ...key, signal: request.signal }));
1345
1345
  };
1346
1346
  }
1347
1347
  };
1348
1348
  }
1349
+ function isStepUpChallenge(response) {
1350
+ return parseAuthioBearerChallenge(response.headers.get("www-authenticate"))?.error === AuthioOAuthErrors.InsufficientUserAuthentication;
1351
+ }
1349
1352
  function createTokenClient(connection, discovery, authenticator) {
1350
1353
  const requestToken = async (parameters, signal, authenticate = true) => {
1351
1354
  const response = await postForm(connection, discovery, authenticate ? authenticator : void 0, "token_endpoint", parameters, signal);