|
@@ -5,7 +5,9 @@ export default function getUuid(prefix: string) {
|
|
|
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
|
|
|
function getUuidv4() {
|
|
|
try {
|
|
|
- return crypto.randomUUID();
|
|
|
+ return crypto?.randomUUID?.() ?? (String(1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
|
+ (Number(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (Number(c) / 4)))).toString(16)
|
|
|
+ ));
|
|
|
} catch (err) {
|
|
|
return getUuid('semi');
|
|
|
}
|