@zauru-sdk/utils 6.29.0 → 6.30.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { redirect } from "@remix-run/node";
|
|
2
|
-
import { isOauthUserinfoUnauthorizedError } from "@zauru-sdk/common";
|
|
2
|
+
import { ZAURU_OAUTH_REAUTH_COOKIE, hasZauruOauthReauthCookie, isOauthUserinfoUnauthorizedError, } from "@zauru-sdk/common";
|
|
3
3
|
import { config } from "@zauru-sdk/config";
|
|
4
4
|
import { commitSession, destroySession, getHeaders, getRefreshSession, getSession, loginWebApp, } from "@zauru-sdk/services";
|
|
5
5
|
const loginErrorPayload = (description, title) => ({
|
|
@@ -27,16 +27,12 @@ const evaluateLoginAccess = async (extras, session, headers) => {
|
|
|
27
27
|
return Response.json(loginErrorPayload(description));
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
const OAUTH_REAUTH_COOKIE = "zauru_oauth_reauth";
|
|
31
30
|
const authorizeUrl = (request) => {
|
|
32
31
|
const url = new URL(request.url);
|
|
33
32
|
const hostname = `${url.port ? "http://" : "https://"}${url.hostname}${url.port ? `:${url.port}` : ""}`;
|
|
34
33
|
return `${config.oauthBaseURL}/dialog/authorize?client_id=${config.oauthClientID}&response_type=code&redirect_uri=${hostname}/login`;
|
|
35
34
|
};
|
|
36
|
-
const
|
|
37
|
-
.split(";")
|
|
38
|
-
.some((part) => part.trim() === `${OAUTH_REAUTH_COOKIE}=1`);
|
|
39
|
-
const oauthReauthSetCookie = () => `${OAUTH_REAUTH_COOKIE}=1; Path=/; Max-Age=120; SameSite=Lax`;
|
|
35
|
+
const oauthReauthSetCookie = () => `${ZAURU_OAUTH_REAUTH_COOKIE}=1; Path=/; Max-Age=120; SameSite=Lax`;
|
|
40
36
|
const redirectOauthReauth = async (session) => {
|
|
41
37
|
const headers = new Headers();
|
|
42
38
|
headers.append("Set-Cookie", await destroySession(session));
|
|
@@ -92,7 +88,7 @@ export function createLoginAction(extras) {
|
|
|
92
88
|
if (loginResponse.error || !loginResponse.data) {
|
|
93
89
|
const userMsg = loginResponse.userMsg?.toString() ?? "";
|
|
94
90
|
if (isOauthUserinfoUnauthorizedError(userMsg) &&
|
|
95
|
-
!
|
|
91
|
+
!hasZauruOauthReauthCookie(request.headers.get("Cookie"))) {
|
|
96
92
|
return redirectOauthReauth(session);
|
|
97
93
|
}
|
|
98
94
|
return Response.json(loginErrorPayload(userMsg));
|
|
@@ -139,11 +135,10 @@ export function createLogoutLoader(extras) {
|
|
|
139
135
|
const url = new URL(args.request.url);
|
|
140
136
|
if (url.searchParams.get("reauth") === "1") {
|
|
141
137
|
const session = await getSession(args.request.headers.get("Cookie"));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
138
|
+
const headers = new Headers();
|
|
139
|
+
headers.append("Set-Cookie", await destroySession(session));
|
|
140
|
+
headers.append("Set-Cookie", oauthReauthSetCookie());
|
|
141
|
+
return redirect("/login", { headers });
|
|
147
142
|
}
|
|
148
143
|
return guard(args);
|
|
149
144
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.30.1",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@aws-sdk/client-cloudwatch-logs": "^3.1123.0",
|
|
73
73
|
"@remix-run/node": "^2.8.1",
|
|
74
|
-
"@zauru-sdk/common": "^6.
|
|
74
|
+
"@zauru-sdk/common": "^6.14.1",
|
|
75
75
|
"@zauru-sdk/config": "^6.0.0",
|
|
76
76
|
"@zauru-sdk/graphql": "^6.9.1",
|
|
77
|
-
"@zauru-sdk/services": "^6.
|
|
78
|
-
"@zauru-sdk/types": "^6.
|
|
77
|
+
"@zauru-sdk/services": "^6.18.0",
|
|
78
|
+
"@zauru-sdk/types": "^6.30.0",
|
|
79
79
|
"moment": "^2.30.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "dc5f6e04a2c4254710cbd86cb7016beefd84b9be"
|
|
82
82
|
}
|