This repository was archived by the owner on Sep 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,24 @@ const transport = createConnectTransport({
1717
1818const client = createPromiseClient ( LanguageServerService , transport ) ;
1919
20- /**
21- * Note that this won't be available in 'insecure contexts',
22- * websites served under HTTP not HTTPS, but those are rare.
23- * And it'll work in localhost for development.
24- */
25- const sessionId = crypto . randomUUID ( ) ;
20+ let sessionId : string ;
21+ try {
22+ /**
23+ * Note that this won't be available in 'insecure contexts',
24+ * websites served under HTTP not HTTPS, but those are rare.
25+ * And it'll work in localhost for development.
26+ */
27+ sessionId = crypto . randomUUID ( ) ;
28+ } catch {
29+ // When not in a secure context
30+ // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid
31+ function uuidv4 ( ) {
32+ return "10000000-1000-4000-8000-100000000000" . replace ( / [ 0 1 8 ] / g, c =>
33+ ( + c ^ ( crypto . getRandomValues ( new Uint8Array ( 1 ) ) [ 0 ] ?? 0 ) & 15 >> + c / 4 ) . toString ( 16 )
34+ ) ;
35+ }
36+ sessionId = uuidv4 ( ) ;
37+ }
2638
2739export async function getCodeiumCompletions ( {
2840 text,
You can’t perform that action at this time.
0 commit comments