@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 +3 -2
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -853,7 +853,9 @@ interface AuthioFrontChannelLogout {
|
|
|
853
853
|
*/
|
|
854
854
|
declare function readAuthioFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>, issuer: string): AuthioFrontChannelLogout;
|
|
855
855
|
/**
|
|
856
|
-
* Parses a `WWW-Authenticate` bearer challenge, or `undefined` when the header holds none.
|
|
856
|
+
* Parses a `WWW-Authenticate` bearer challenge, or `undefined` when the header holds none. It reads the header only,
|
|
857
|
+
* whatever the status: a step-up challenge (`insufficient_user_authentication`) comes with `401` (RFC 9470 §3), or
|
|
858
|
+
* with `403` from servers before `@hyper.authio/server` 0.8.1 and `@hyper.authio/mcp` 0.4.1.
|
|
857
859
|
*/
|
|
858
860
|
declare function parseAuthioBearerChallenge(header: string | null | undefined): AuthioBearerChallenge | undefined;
|
|
859
861
|
|
package/dist/index.d.ts
CHANGED
|
@@ -853,7 +853,9 @@ interface AuthioFrontChannelLogout {
|
|
|
853
853
|
*/
|
|
854
854
|
declare function readAuthioFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>, issuer: string): AuthioFrontChannelLogout;
|
|
855
855
|
/**
|
|
856
|
-
* Parses a `WWW-Authenticate` bearer challenge, or `undefined` when the header holds none.
|
|
856
|
+
* Parses a `WWW-Authenticate` bearer challenge, or `undefined` when the header holds none. It reads the header only,
|
|
857
|
+
* whatever the status: a step-up challenge (`insufficient_user_authentication`) comes with `401` (RFC 9470 §3), or
|
|
858
|
+
* with `403` from servers before `@hyper.authio/server` 0.8.1 and `@hyper.authio/mcp` 0.4.1.
|
|
857
859
|
*/
|
|
858
860
|
declare function parseAuthioBearerChallenge(header: string | null | undefined): AuthioBearerChallenge | undefined;
|
|
859
861
|
|
package/dist/index.js
CHANGED
|
@@ -1337,13 +1337,16 @@ function createAuthioClient(options) {
|
|
|
1337
1337
|
};
|
|
1338
1338
|
const token = await clientCredentials.getToken({ ...key, signal: request.signal });
|
|
1339
1339
|
const response = await attempt(token);
|
|
1340
|
-
if (response.status !== 401) return response;
|
|
1340
|
+
if (response.status !== 401 || isStepUpChallenge(response)) return response;
|
|
1341
1341
|
clientCredentials.invalidate({ ...key, accessToken: token.accessToken });
|
|
1342
1342
|
return attempt(await clientCredentials.getToken({ ...key, signal: request.signal }));
|
|
1343
1343
|
};
|
|
1344
1344
|
}
|
|
1345
1345
|
};
|
|
1346
1346
|
}
|
|
1347
|
+
function isStepUpChallenge(response) {
|
|
1348
|
+
return parseAuthioBearerChallenge(response.headers.get("www-authenticate"))?.error === AuthioOAuthErrors.InsufficientUserAuthentication;
|
|
1349
|
+
}
|
|
1347
1350
|
function createTokenClient(connection, discovery, authenticator) {
|
|
1348
1351
|
const requestToken = async (parameters, signal, authenticate = true) => {
|
|
1349
1352
|
const response = await postForm(connection, discovery, authenticate ? authenticator : void 0, "token_endpoint", parameters, signal);
|