-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
16,527 additions
and
15,475 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/sdks/core-js-sdk/src/httpClient/helpers/getClientSessionId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
let sessionId: string; | ||
|
||
export const getClientSessionId = (): string => { | ||
if (sessionId) { | ||
return sessionId; | ||
} | ||
const currentDate = new Date(); | ||
const utcString = `${currentDate.getUTCFullYear().toString()}-${( | ||
currentDate.getUTCMonth() + 1 | ||
) | ||
.toString() | ||
.padStart(2, '0')}-${currentDate | ||
.getUTCDate() | ||
.toString() | ||
.padStart(2, '0')}-${currentDate | ||
.getUTCHours() | ||
.toString() | ||
.padStart(2, '0')}:${currentDate | ||
.getUTCMinutes() | ||
.toString() | ||
.padStart(2, '0')}:${currentDate | ||
.getUTCSeconds() | ||
.toString() | ||
.padStart(2, '0')}:${currentDate.getUTCMilliseconds().toString()}`; | ||
const randomSuffix = Math.floor(1000 + Math.random() * 9000); | ||
sessionId = `${utcString}-${randomSuffix}`; | ||
Check failure Code scanning / CodeQL Insecure randomness High
This uses a cryptographically insecure random number generated at
Math.random() Error loading related location Loading |
||
return sessionId; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.