From 6ca1f5c4310a2e398614802c5388dda589537be5 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Tue, 22 Aug 2023 22:00:09 +0300 Subject: [PATCH] use crypto if available --- ui/src/components/settings/TokenField.svelte | 4 +++- ui/src/utils/CommonHelper.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/src/components/settings/TokenField.svelte b/ui/src/components/settings/TokenField.svelte index 28136e37..ca33aeac 100644 --- a/ui/src/components/settings/TokenField.svelte +++ b/ui/src/components/settings/TokenField.svelte @@ -21,7 +21,9 @@ if (secret) { secret = undefined; } else { - secret = CommonHelper.randomString(50); + secret = crypto?.randomUUID + ? crypto.randomUUID() + CommonHelper.randomString(14) + : CommonHelper.randomString(50); } }} > diff --git a/ui/src/utils/CommonHelper.js b/ui/src/utils/CommonHelper.js index 261e8859..8d13525a 100644 --- a/ui/src/utils/CommonHelper.js +++ b/ui/src/utils/CommonHelper.js @@ -419,7 +419,7 @@ export default class CommonHelper { } /** - * Generates random string (suitable for elements id and keys). + * Generates pseudo-random string (suitable for elements id and keys). * * @param {Number} [length] Results string length (default 10) * @return {String}