Skip to content

Commit

Permalink
Merge pull request #279 from gouravmore/all-1.4.0
Browse files Browse the repository at this point in the history
Issue #235359 fix: Missing Content Security Policy for learner ai app
  • Loading branch information
gouravmore authored Feb 19, 2025
2 parents 78dcc83 + c38146d commit 7444ccb
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 33 deletions.
3 changes: 1 addition & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ const App = () => {
window.parent.postMessage(
{
message: "Unauthorized",
},
"*"
}
);
} else {
localStorage.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export const ProfileHeader = ({
const handleProfileBack = () => {
try {
if (process.env.REACT_APP_IS_APP_IFRAME === "true") {
window.parent.postMessage({ type: "restore-iframe-content" }, "*");
window.parent.postMessage({ type: "restore-iframe-content" });
navigate("/");
} else {
navigate("/discover-start");
Expand Down
8 changes: 3 additions & 5 deletions src/components/DiscoverSentance/DiscoverSentance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ const SpeakSentenceComponent = () => {
{
score: score,
message: "all-test-rig-score",
},
"*"
}
);
}
};
Expand Down Expand Up @@ -251,7 +250,7 @@ const SpeakSentenceComponent = () => {
}
}
} catch (error) {
console.log(error);
console.error(error);
}
};

Expand Down Expand Up @@ -282,10 +281,9 @@ const SpeakSentenceComponent = () => {
setAssessmentResponse(resAssessment);
localStorage.setItem("storyTitle", sentences?.name);
quesArr = [...quesArr, ...(resPagination?.data || [])];
console.log("quesArr", quesArr);
setQuestions(quesArr);
} catch (error) {
console.log("Error fetching data:", error);
console.error("Error fetching data:", error);
}
})();
}, []);
Expand Down
2 changes: 2 additions & 0 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ let virtualId;
if (TOKEN) {
const tokenDetails = jwtDecode(TOKEN);
virtualId = JSON.stringify(tokenDetails?.virtual_id);
}else{
virtualId = null;
}
const isLogin = process.env.REACT_APP_IS_IN_APP_AUTHORISATION === "true";

Expand Down
5 changes: 4 additions & 1 deletion src/services/content/contentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const getHeaders = () => {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
"Cache-Control": "no-cache",
Pragma: "no-cache",
"Content-Security-Policy": "default-src 'self'"
}
};
};

Expand Down
3 changes: 3 additions & 0 deletions src/services/learnerAi/learnerAiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const getHeaders = () => {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Cache-Control": "no-cache",
Pragma: "no-cache",
"Content-Security-Policy": "default-src 'self'"
},
};
};
Expand Down
3 changes: 3 additions & 0 deletions src/services/orchestration/orchestrationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const getHeaders = () => {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Cache-Control": "no-cache",
Pragma: "no-cache",
"Content-Security-Policy": "default-src 'self'"
},
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/services/telementryService.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const initialize = async ({ context, config, metadata }) => {
telemetryConfig
);
} catch (error) {
console.log(":e", error);
console.error(":e", error);
}
}
};
Expand All @@ -81,7 +81,7 @@ export const start = (duration) => {
},
});
} catch (error) {
console.log("err", error);
console.error("err", error);
}
};

Expand Down
22 changes: 11 additions & 11 deletions src/store/sagas/handlers/user.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { requestSignin, generateOtp, verifyOtp } from '../requests/user.request'

export function* handleSignin(action) {
try {
console.log(action.payload);
//console.log(action.payload);
const response = yield retry(0, 0, requestSignin, action.payload);
const { data } = response;

Expand All @@ -18,47 +18,47 @@ export function* handleSignin(action) {
localStorage.setItem('refreshToken', refresh);

yield put(setUser({ userData }));
console.log(userData);
//console.log(userData);
} catch (error) {
console.log(error);
console.error(error);
}
}

export function* fetchOTP(action) {
try {
console.log(action.payload);
//console.log(action.payload);
const accessTokenObj = JSON.parse(localStorage.getItem('accessToken'));
console.log(accessTokenObj);
//console.log(accessTokenObj);
const response = yield retry(0, 0, generateOtp, accessTokenObj.token);

const { data } = response;

console.log(data.tokens.otp);
//console.log(data.tokens.otp);
// Otp Token Save to local Storage

const otp = JSON.stringify(data.tokens.otp);
localStorage.setItem('otpToken', otp);

yield put(setOTPSent({ otpSent: true }));
} catch (error) {
console.log(error);
console.error(error);
}
}

export function* handleVerifyOtp(action) {
try {
console.log(`handleVerifyOtp:: `, action.payload);
//console.log(`handleVerifyOtp:: `, action.payload);
const accessTokenObj = JSON.parse(localStorage.getItem('accessToken'));
const otpTokenObj = JSON.parse(localStorage.getItem('otpToken'));
action.payload.accessToken = accessTokenObj.token;
action.payload.otpToken = otpTokenObj.token;
console.log('access:', action.payload.accessToken);
console.log('otpToken:', action.payload.otpToken);
//console.log('access:', action.payload.accessToken);
//console.log('otpToken:', action.payload.otpToken);
yield retry(0, 0, verifyOtp, action.payload);

yield put(setOtpVerified({ isOtpVerified: true }));
} catch (error) {
yield put(setOtpVerified({ isOtpVerified: false }));
console.log(error);
console.error(error);
}
}
2 changes: 1 addition & 1 deletion src/store/sagas/requests/user.request.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function generateOtp(accessToken) {
}

export function verifyOtp(data) {
console.log(`otp data:: `, data);
//console.log(`otp data:: `, data);
return axios.post(
`${API_URL}v1/auth/verify-otp?token=${data.otpToken}`,
{
Expand Down
8 changes: 4 additions & 4 deletions src/utils/VoiceAnalyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function VoiceAnalyser(props) {
alert("Failed to load the audio. Please try again.");
});
} catch (err) {
console.log(err);
console.error(err);
}
};

Expand Down Expand Up @@ -544,7 +544,7 @@ function VoiceAnalyser(props) {
}
setRecordedAudioBase64("");
setApiResponse("error");
console.log("err", error);
console.error("err", error);
}
};

Expand Down Expand Up @@ -635,7 +635,7 @@ function VoiceAnalyser(props) {
setLivesData(newLivesData);
}
} catch (e) {
console.log("error", e);
console.error("error", e);
}
};

Expand Down Expand Up @@ -665,7 +665,7 @@ function VoiceAnalyser(props) {
setAudioPermission(true);
})
.catch((error) => {
console.log("Permission Denied");
console.error("Permission Denied");
setAudioPermission(false);
//alert("Microphone Permission Denied");
});
Expand Down
1 change: 1 addition & 0 deletions src/views/LoginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const LoginPage = () => {
alert("Enter correct username and password");
}
} catch (error) {
console.error(error)
alert("An error occurred. Please try again later.");
}
};
Expand Down
9 changes: 4 additions & 5 deletions src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ const Practice = () => {
{
score: score,
message: "all-test-rig-score",
},
"*"
}
);
}
};
Expand Down Expand Up @@ -345,7 +344,7 @@ const Practice = () => {
setProgressData(practiceProgress[virtualId]);
}
} catch (error) {
console.log(error);
console.error(error);
}
};

Expand Down Expand Up @@ -493,7 +492,7 @@ const Practice = () => {
setLoading(false);
} catch (error) {
setLoading(false);
console.log("err", error);
console.error("err", error);
}
};

Expand Down Expand Up @@ -714,7 +713,7 @@ const Practice = () => {
"mechanic_1")
? 500
: stringLengths[0];
window.parent.postMessage({ type: "stringLengths", length }, "*");
window.parent.postMessage({ type: "stringLengths", length });
}
}
}, [questions[currentQuestion]]);
Expand Down
2 changes: 1 addition & 1 deletion src/views/Snackbar/CustomSnackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function CustomizedSnackbars() {
dispatch(hideSnackBar());
};

console.log('here', virtulId);
// console.log('here', virtulId);
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Snackbar open={open} autoHideDuration={3000} onClose={handleClose}>
Expand Down

0 comments on commit 7444ccb

Please sign in to comment.