File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ref , watch , type Ref } from 'vue'
22import { defineStore } from 'pinia'
33import { useRoute } from 'vue-router' ;
4+ import { randomBrowserUUID } from '@/utils/browserUuid' ;
45
56
67
@@ -22,7 +23,7 @@ export const useToastStore = defineStore('toast', () => {
2223 buttons ?: { value : any ; label : string } [ ] ;
2324 onResolve ?: ( value ?: any ) => void ;
2425 } ) : string => {
25- const toastId = crypto . randomUUID ( ) ;
26+ const toastId = randomBrowserUUID ( ) ;
2627 toasts . value . push ( {
2728 ...toast ,
2829 id : toastId ,
@@ -45,4 +46,4 @@ export const useToastStore = defineStore('toast', () => {
4546 } ;
4647
4748 return { toasts, addToast, removeToast, resolveToast } ;
48- } ) ;
49+ } ) ;
Original file line number Diff line number Diff line change 1+ const UUID_BYTE_LENGTH = 16 ;
2+
3+ const UUID_HEX = Array . from (
4+ { length : 256 } ,
5+ ( _ , index ) => index . toString ( 16 ) . padStart ( 2 , '0' ) ,
6+ ) ;
7+
8+ export function randomBrowserUUID ( ) : string {
9+ if ( typeof crypto . randomUUID === 'function' ) {
10+ return crypto . randomUUID ( ) ;
11+ }
12+
13+ const bytes = crypto . getRandomValues (
14+ new Uint8Array ( UUID_BYTE_LENGTH ) ,
15+ ) ;
16+
17+ bytes [ 6 ] = ( bytes [ 6 ] & 0x0f ) | 0x40 ;
18+ bytes [ 8 ] = ( bytes [ 8 ] & 0x3f ) | 0x80 ;
19+
20+ return [
21+ UUID_HEX [ bytes [ 0 ] ] ,
22+ UUID_HEX [ bytes [ 1 ] ] ,
23+ UUID_HEX [ bytes [ 2 ] ] ,
24+ UUID_HEX [ bytes [ 3 ] ] ,
25+ '-' ,
26+ UUID_HEX [ bytes [ 4 ] ] ,
27+ UUID_HEX [ bytes [ 5 ] ] ,
28+ '-' ,
29+ UUID_HEX [ bytes [ 6 ] ] ,
30+ UUID_HEX [ bytes [ 7 ] ] ,
31+ '-' ,
32+ UUID_HEX [ bytes [ 8 ] ] ,
33+ UUID_HEX [ bytes [ 9 ] ] ,
34+ '-' ,
35+ UUID_HEX [ bytes [ 10 ] ] ,
36+ UUID_HEX [ bytes [ 11 ] ] ,
37+ UUID_HEX [ bytes [ 12 ] ] ,
38+ UUID_HEX [ bytes [ 13 ] ] ,
39+ UUID_HEX [ bytes [ 14 ] ] ,
40+ UUID_HEX [ bytes [ 15 ] ] ,
41+ ] . join ( '' ) ;
42+ }
Original file line number Diff line number Diff line change 1+ import { randomBrowserUUID } from './browserUuid' ;
2+
13const ADMINFORTH_CLIENT_ID_STORAGE_KEY = 'adminforthClientId' ;
24
35export const ADMINFORTH_CLIENT_ID_HEADER = 'x-adminforth-client-id' ;
@@ -8,7 +10,7 @@ export function getAdminForthClientId(): string {
810 return existingClientId ;
911 }
1012
11- const clientId = crypto . randomUUID ( ) ;
13+ const clientId = randomBrowserUUID ( ) ;
1214 sessionStorage . setItem ( ADMINFORTH_CLIENT_ID_STORAGE_KEY , clientId ) ;
1315 return clientId ;
1416}
You can’t perform that action at this time.
0 commit comments