Update environment variables, add fingerprinting, and refactor API endpoints

- Changed server socket and REST API base URLs in .env file.
- Added FingerprintJS dependencies to package.json and package-lock.json.
- Implemented fingerprint generation in UserAuth component.
- Updated API endpoints from v1 to v2 in various service files.
- Refactored API calls to include authorization tokens.
- Commented out console log statements for cleaner production code.
This commit is contained in:
2025-05-26 17:58:46 +05:30
parent b99981a661
commit b76213f49f
22 changed files with 206 additions and 94 deletions

View File

@@ -1,25 +1,17 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
// let url_Backend_dwinzo = `http://192.168.0.110:5000`;
export const createProject = async (
projectUuid: string,
userId: string,
thumbnail: string,
organization: string
) => {
export const createProject = async (projectUuid: string, userId: string, thumbnail: string, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/upsertProject`, {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/upsertProject`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({
projectUuid,
userId,
thumbnail,
organization,
}),
body: JSON.stringify({ projectUuid, userId, thumbnail, organization, }),
});
if (!response.ok) {

View File

@@ -8,11 +8,14 @@ export const deleteProject = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1//Project/archive/${projectId}`,
`${url_Backend_dwinzo}/api/v2/Project/archive/${projectId}`,
{
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ userId, organization }),
}

View File

@@ -3,11 +3,14 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const getAllProjects = async (userId: string, organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Projects/${userId}/${organization}`,
`${url_Backend_dwinzo}/api/v2/Projects`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);

View File

@@ -6,11 +6,14 @@ export const getTrash = async (organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Trash/Lists?organization=${organization}`,
`${url_Backend_dwinzo}/api/v2/TrashItems`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
@@ -20,6 +23,7 @@ export const getTrash = async (organization: string) => {
}
const data = await response.json();
console.log('TrashItems: ', data);
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);

View File

@@ -9,7 +9,7 @@ export const projectTutorial = async () => {
},
});
console.log("response: ", response);
// console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to add project");

View File

@@ -3,11 +3,14 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const recentlyViewed = async (organization: string, userId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/RecentlyViewed/${userId}/${organization}`,
`${url_Backend_dwinzo}/api/v2/RecentlyViewed`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
@@ -15,6 +18,7 @@ export const recentlyViewed = async (organization: string, userId: string) => {
if (!response.ok) {
throw new Error("Failed to fetch project");
}
return await response.json();
} catch (error: any) {
@@ -22,4 +26,3 @@ export const recentlyViewed = async (organization: string, userId: string) => {
throw new Error(error.message);
}
};

View File

@@ -4,11 +4,14 @@ const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_
export const restoreTrash = async (organization: string, projectId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/restore?organization=${organization}&projectId=${projectId}`,
`${url_Backend_dwinzo}api/v2/Trash/restore?projectId=${projectId}`,
{
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
@@ -18,10 +21,10 @@ export const restoreTrash = async (organization: string, projectId: string) => {
}
const data = await response.json();
console.log('restore: ', data);
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
}
};

View File

@@ -7,11 +7,14 @@ export const searchProject = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/searchProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
`${url_Backend_dwinzo}/api/v2/searchProjects?searchName=${searchName}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
@@ -20,9 +23,9 @@ export const searchProject = async (
throw new Error("Failed to Search project");
}
console.log("response: ", response);
const result = await response.json();
console.log("result: ", result);
console.log("searchProjects: ", result);
return result;
} catch (error) {

View File

@@ -7,11 +7,14 @@ export const trashSearchProject = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/searchTrashProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
`${url_Backend_dwinzo}/api/v2/searchTrashProjects?searchName=${searchName}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
@@ -21,6 +24,7 @@ export const trashSearchProject = async (
}
const result = await response.json();
console.log('searchTrashProjects: ', result);
return result;
} catch (error) {
if (error instanceof Error) {

View File

@@ -19,11 +19,14 @@ export const updateProject = async (
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Project/modify`,
`${url_Backend_dwinzo}/api/v2/Project/${projectId}`,
{
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify(body),
}

View File

@@ -1,17 +1,15 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const viewProject = async (
organization: string,
projectId: string,
userId: string
) => {
export const viewProject = async (organization: string,projectId: string,userId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Project/view?organization=${organization}&projectId=${projectId}&userId=${userId}`,
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Project/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);

View File

@@ -3,9 +3,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}
export const getAssetImages = async (cursor?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${
cursor ? `&cursor=${cursor}` : ""
}`,
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${cursor ? `&cursor=${cursor}` : ""}`,
{
method: "GET",
headers: {

View File

@@ -1,23 +1,18 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signInApi = async (
email: string,
password: Object,
organization: Object
) => {
export const signInApi = async (Email: string,Password: Object,organization: Object,fingerprint:any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Auth/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password, organization }),
headers: {"Content-Type": "application/json",},
body: JSON.stringify({ Email, Password, organization,fingerprint}),
});
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-in");
echo.error("Failed to sign-in");
if (error instanceof Error) {
return { error: error.message };
} else {

View File

@@ -2,17 +2,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const signUpApi = async (
userName: string,
email: string,
password: Object,
Email: string,
Password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/signup`, {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Auth/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userName, email, password, organization }),
headers: { "Content-Type": "application/json", },
body: JSON.stringify({ userName, Email, Password, organization }),
});
if (!response.ok) {
@@ -20,7 +18,6 @@ export const signUpApi = async (
}
const result = await response.json();
console.log("result: ", result);
return result;
} catch (error) {
echo.error("Failed to sign-up");