@absolutejs/auth 0.51.0 → 0.52.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/dist/index.js +29 -3
- package/dist/index.js.map +4 -4
- package/dist/oidc/config.d.ts +9 -0
- package/dist/oidc/routes.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6435,6 +6435,17 @@ var jsonResponse = (value, status) => new Response(JSON.stringify(value), {
|
|
|
6435
6435
|
});
|
|
6436
6436
|
var oauthError2 = (status, error) => jsonResponse({ error }, status);
|
|
6437
6437
|
var tokenResponse = (tokens) => jsonResponse(tokens, HTTP_OK2);
|
|
6438
|
+
var canonicalizeRequestUrl = (requestUrl, issuer) => {
|
|
6439
|
+
try {
|
|
6440
|
+
const url = new URL(requestUrl);
|
|
6441
|
+
const base = new URL(issuer);
|
|
6442
|
+
url.protocol = base.protocol;
|
|
6443
|
+
url.host = base.host;
|
|
6444
|
+
return url.toString();
|
|
6445
|
+
} catch {
|
|
6446
|
+
return requestUrl;
|
|
6447
|
+
}
|
|
6448
|
+
};
|
|
6438
6449
|
var redirectTo = (url) => new Response(null, { headers: { location: url }, status: HTTP_FOUND });
|
|
6439
6450
|
var escapeHtmlAttr = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
6440
6451
|
var formPostResponse = (redirectUri, params) => {
|
|
@@ -6948,9 +6959,24 @@ var oidcProviderRoutes = (config) => {
|
|
|
6948
6959
|
if (wantsSilent) {
|
|
6949
6960
|
return errorRedirect(userSession === undefined ? "login_required" : "interaction_required");
|
|
6950
6961
|
}
|
|
6951
|
-
return loginUrl === undefined ? jsonResponse({ error: "login_required" }, HTTP_UNAUTHORIZED2) : redirectTo(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
|
|
6962
|
+
return loginUrl === undefined ? jsonResponse({ error: "login_required" }, HTTP_UNAUTHORIZED2) : redirectTo(`${loginUrl}?return_to=${encodeURIComponent(canonicalizeRequestUrl(request.url, issuer))}`);
|
|
6952
6963
|
}
|
|
6953
6964
|
const requested = scope === undefined || scope.length === 0 ? client.scopes : scope.split(" ").filter((entry) => client.scopes.includes(entry));
|
|
6965
|
+
if (config.consentUrl !== undefined && await config.needsConsent?.({
|
|
6966
|
+
client: {
|
|
6967
|
+
clientId: client.clientId,
|
|
6968
|
+
name: client.name
|
|
6969
|
+
},
|
|
6970
|
+
requestedScopes: requested,
|
|
6971
|
+
user: userSession.user
|
|
6972
|
+
}) === true) {
|
|
6973
|
+
const consentTarget = new URL(config.consentUrl, issuer);
|
|
6974
|
+
consentTarget.searchParams.set("return_to", canonicalizeRequestUrl(request.url, issuer));
|
|
6975
|
+
consentTarget.searchParams.set("client_id", client.clientId);
|
|
6976
|
+
consentTarget.searchParams.set("client_name", client.name);
|
|
6977
|
+
consentTarget.searchParams.set("scope", requested.join(" "));
|
|
6978
|
+
return redirectTo(consentTarget.toString());
|
|
6979
|
+
}
|
|
6954
6980
|
const granted = getGrantedScopes === undefined ? requested : await getGrantedScopes({
|
|
6955
6981
|
client: {
|
|
6956
6982
|
clientId: client.clientId,
|
|
@@ -7449,7 +7475,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7449
7475
|
headers: t13.Object({
|
|
7450
7476
|
authorization: t13.Optional(t13.String())
|
|
7451
7477
|
})
|
|
7452
|
-
}).get(jwksRoute, () => ({ keys: [toPublicJwk(signingKey)] })).get("/.well-known/openid-configuration", () => discovery);
|
|
7478
|
+
}).get(jwksRoute, () => ({ keys: [toPublicJwk(signingKey)] })).get("/.well-known/openid-configuration", () => discovery).get("/.well-known/oauth-authorization-server", () => discovery);
|
|
7453
7479
|
};
|
|
7454
7480
|
|
|
7455
7481
|
// src/organizations/routes.ts
|
|
@@ -28028,5 +28054,5 @@ export {
|
|
|
28028
28054
|
AuthIdentityConflictError
|
|
28029
28055
|
};
|
|
28030
28056
|
|
|
28031
|
-
//# debugId=
|
|
28057
|
+
//# debugId=9E1C46257073267B64756E2164756E21
|
|
28032
28058
|
//# sourceMappingURL=index.js.map
|