Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@
}
}

#apiresponse {
margin-top: 20px;
padding: 15px;
border: 1px solid #ccc;
background-color: #f5f5f5;
font-family: monospace;
white-space: pre-wrap;
text-align: left;
max-width: 800px;
margin-left: auto;
margin-right: auto;
overflow-wrap: break-word;
}

#apiresponse:empty {
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const parseJwtToken = (tokenType) => {
};

const generateSessionId = () => {
const newSessionId = Math.random().toString(36).substring(2, 15); // Generate a new session ID
// Use cryptographically secure random UUID instead of Math.random()
const newSessionId = crypto.randomUUID();
setSessionId(newSessionId);
};

Expand Down Expand Up @@ -121,8 +122,9 @@ function callAPIGW(accessToken, idToken, inputPrompt, setIsLoading, sessionId) {
.get(apiGatewayUrl, { headers: headers })
.then((response) => {
console.log(response.data);
document.getElementById('apiresponse').innerHTML =
'<b>Response</b><br>' + JSON.stringify(response.data, null, 2);
// Use textContent instead of innerHTML to prevent XSS attacks
const apiResponseElement = document.getElementById('apiresponse');
apiResponseElement.textContent = 'Response\n' + JSON.stringify(response.data, null, 2);
setIsLoading(false); // Set isLoading to false after receiving the response

})
Expand Down