@agrada_digital/pbm 0.0.108 → 0.0.110
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 +17 -18
- package/dist/vanilla.js +26 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1057,41 +1057,40 @@ 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": "application/json",
|
|
1077
|
+
"Accept-Encoding": "gzip, deflate, br"
|
|
1081
1078
|
},
|
|
1082
1079
|
credentials: "include",
|
|
1083
|
-
body:
|
|
1080
|
+
body: JSON.stringify({
|
|
1081
|
+
accessToken: client.access_token
|
|
1082
|
+
})
|
|
1084
1083
|
}
|
|
1085
1084
|
);
|
|
1086
1085
|
const data = await response.json();
|
|
1087
|
-
if (!data.
|
|
1086
|
+
if (!data.success) {
|
|
1088
1087
|
throw new Error("Authorization failed");
|
|
1089
1088
|
}
|
|
1090
1089
|
const SECONDS_IN_A_DAY = 86400;
|
|
1091
|
-
Cookies3.set("pbm-token", data.access_token, {
|
|
1090
|
+
Cookies3.set("pbm-token", data.data.access_token, {
|
|
1092
1091
|
secure: true,
|
|
1093
1092
|
sameSite: "Strict",
|
|
1094
|
-
expires: data.expires_in / SECONDS_IN_A_DAY
|
|
1093
|
+
expires: data.data.expires_in / SECONDS_IN_A_DAY
|
|
1095
1094
|
});
|
|
1096
1095
|
return data;
|
|
1097
1096
|
};
|
|
@@ -1180,10 +1179,10 @@ var useAppStartup = (props) => {
|
|
|
1180
1179
|
const fetchAuthorizationRequest = async () => {
|
|
1181
1180
|
try {
|
|
1182
1181
|
const response = await GetAuthorization({ tenant_id: props.tenant_id });
|
|
1183
|
-
if (!response.
|
|
1182
|
+
if (!response.success) {
|
|
1184
1183
|
console.error("PBMLOG: Authorization failed!");
|
|
1185
1184
|
}
|
|
1186
|
-
return response.
|
|
1185
|
+
return response.success;
|
|
1187
1186
|
} catch (error) {
|
|
1188
1187
|
console.error("Error fetching authorization:", error);
|
|
1189
1188
|
return false;
|