File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -250,7 +250,16 @@ export class GeminiClient {
250250 }
251251
252252 // Generate a temporary session ID for legacy calls
253- const tempSessionId = `legacy-${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) } ` ;
253+ const randomArray = new Uint32Array ( 2 ) ;
254+ ( typeof window !== 'undefined' && window . crypto
255+ ? window . crypto . getRandomValues ( randomArray )
256+ : ( typeof crypto !== 'undefined' && typeof crypto . getRandomValues === 'function'
257+ ? crypto . getRandomValues ( randomArray )
258+ : ( ( ) => { throw new Error ( 'No secure random generator available' ) ; } ) ( )
259+ )
260+ ) ;
261+ const randomString = Array . from ( randomArray ) . map ( n => n . toString ( 36 ) ) . join ( '' ) . substr ( 0 , 9 ) ;
262+ const tempSessionId = `legacy-${ Date . now ( ) } -${ randomString } ` ;
254263 const userMessage = messages [ messages . length - 1 ] . content ;
255264 const conversationHistory = messages . slice ( 0 , - 1 ) ;
256265
You can’t perform that action at this time.
0 commit comments