@agrada_digital/pbm 0.0.108 → 0.0.109
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 +16 -18
- package/dist/vanilla.js +26 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1057,41 +1057,39 @@ import Cookies3 from "js-cookie";
|
|
|
1057
1057
|
// src/services/clients-config.ts
|
|
1058
1058
|
var CLIENTS_CONFIG = {
|
|
1059
1059
|
santo_remedio: {
|
|
1060
|
-
|
|
1061
|
-
client_secret: getEnv("VITE_KEYCLOAK_SECRET_SANTOREMEDIO"),
|
|
1062
|
-
client_realm: getEnv("VITE_KEYCLOAK_REALM_SANTOREMEDIO")
|
|
1060
|
+
access_token: getEnv("VITE_KEYCLOAK_ACCESSTOKEN_SANTOREMEDIO") || ""
|
|
1063
1061
|
}
|
|
1064
1062
|
};
|
|
1065
1063
|
|
|
1066
1064
|
// src/services/authorization.ts
|
|
1067
1065
|
var GetAuthorization = async ({ tenant_id }) => {
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
scope: getEnv("VITE_KEYCLOAK_SCOPE") || "",
|
|
1073
|
-
accessToken: getEnv("VITE_KEYCLOAK_ACCESSTOKEN") || ""
|
|
1074
|
-
});
|
|
1066
|
+
const client = CLIENTS_CONFIG[tenant_id];
|
|
1067
|
+
if (!client || !client.access_token) {
|
|
1068
|
+
throw new Error(`No configuration found for tenant: ${tenant_id}`);
|
|
1069
|
+
}
|
|
1075
1070
|
const response = await fetch(
|
|
1076
|
-
`${getEnv("
|
|
1071
|
+
`${getEnv("VITE_API_URL")}/auth`,
|
|
1077
1072
|
{
|
|
1078
1073
|
method: "POST",
|
|
1079
1074
|
headers: {
|
|
1080
|
-
"Content-Type": "application/
|
|
1075
|
+
"Content-Type": "application/json",
|
|
1076
|
+
"Accept-Encoding": "gzip, deflate, br"
|
|
1081
1077
|
},
|
|
1082
1078
|
credentials: "include",
|
|
1083
|
-
body:
|
|
1079
|
+
body: JSON.stringify({
|
|
1080
|
+
accessToken: client.access_token
|
|
1081
|
+
})
|
|
1084
1082
|
}
|
|
1085
1083
|
);
|
|
1086
1084
|
const data = await response.json();
|
|
1087
|
-
if (!data.
|
|
1085
|
+
if (!data.success) {
|
|
1088
1086
|
throw new Error("Authorization failed");
|
|
1089
1087
|
}
|
|
1090
1088
|
const SECONDS_IN_A_DAY = 86400;
|
|
1091
|
-
Cookies3.set("pbm-token", data.access_token, {
|
|
1089
|
+
Cookies3.set("pbm-token", data.data.access_token, {
|
|
1092
1090
|
secure: true,
|
|
1093
1091
|
sameSite: "Strict",
|
|
1094
|
-
expires: data.expires_in / SECONDS_IN_A_DAY
|
|
1092
|
+
expires: data.data.expires_in / SECONDS_IN_A_DAY
|
|
1095
1093
|
});
|
|
1096
1094
|
return data;
|
|
1097
1095
|
};
|
|
@@ -1180,10 +1178,10 @@ var useAppStartup = (props) => {
|
|
|
1180
1178
|
const fetchAuthorizationRequest = async () => {
|
|
1181
1179
|
try {
|
|
1182
1180
|
const response = await GetAuthorization({ tenant_id: props.tenant_id });
|
|
1183
|
-
if (!response.
|
|
1181
|
+
if (!response.success) {
|
|
1184
1182
|
console.error("PBMLOG: Authorization failed!");
|
|
1185
1183
|
}
|
|
1186
|
-
return response.
|
|
1184
|
+
return response.success;
|
|
1187
1185
|
} catch (error) {
|
|
1188
1186
|
console.error("Error fetching authorization:", error);
|
|
1189
1187
|
return false;
|