fix secure random

This commit is contained in:
Timo
2025-01-23 16:26:55 +01:00
parent 879de54001
commit 892c4a33a5
5 changed files with 10 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/ */
import { useEffect, useCallback, useRef, useState } from "react"; import { useEffect, useCallback, useRef, useState } from "react";
import { randomString } from "matrix-js-sdk/src/randomstring"; import { secureRandomString } from "matrix-js-sdk/src/randomstring";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
@@ -31,7 +31,7 @@ export function useRecaptcha(sitekey?: string): {
recaptchaId: string; recaptchaId: string;
} { } {
const { t } = useTranslation(); const { t } = useTranslation();
const [recaptchaId] = useState(() => randomString(16)); const [recaptchaId] = useState(() => secureRandomString(16));
const promiseRef = useRef<RecaptchaPromiseRef | undefined>(undefined); const promiseRef = useRef<RecaptchaPromiseRef | undefined>(undefined);
useEffect(() => { useEffect(() => {

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/ */
import { useCallback } from "react"; import { useCallback } from "react";
import { randomString } from "matrix-js-sdk/src/randomstring"; import { secureRandomString } from "matrix-js-sdk/src/randomstring";
import { useClient } from "../ClientContext"; import { useClient } from "../ClientContext";
import { useInteractiveRegistration } from "../auth/useInteractiveRegistration"; import { useInteractiveRegistration } from "../auth/useInteractiveRegistration";
@@ -42,7 +42,7 @@ export function useRegisterPasswordlessUser(): UseRegisterPasswordlessUserType {
const userName = generateRandomName(); const userName = generateRandomName();
const [client, session] = await register( const [client, session] = await register(
userName, userName,
randomString(16), secureRandomString(16),
displayName, displayName,
recaptchaResponse, recaptchaResponse,
true, true,

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/ */
import { type FC, useCallback, useState, type FormEventHandler } from "react"; import { type FC, useCallback, useState, type FormEventHandler } from "react";
import { randomString } from "matrix-js-sdk/src/randomstring"; import { secureRandomString } from "matrix-js-sdk/src/randomstring";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { Button, Heading, Text } from "@vector-im/compound-web"; import { Button, Heading, Text } from "@vector-im/compound-web";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
@@ -67,7 +67,7 @@ export const UnauthenticatedView: FC = () => {
const userName = generateRandomName(); const userName = generateRandomName();
const [client, session] = await register( const [client, session] = await register(
userName, userName,
randomString(16), secureRandomString(16),
displayName, displayName,
recaptchaResponse, recaptchaResponse,
true, true,

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/ */
import { type ChangeEvent, type FC, useCallback } from "react"; import { type ChangeEvent, type FC, useCallback } from "react";
import { randomString } from "matrix-js-sdk/src/randomstring"; import { secureRandomString } from "matrix-js-sdk/src/randomstring";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { Button, Text } from "@vector-im/compound-web"; import { Button, Text } from "@vector-im/compound-web";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
@@ -36,7 +36,7 @@ export const FeedbackSettingsTab: FC<Props> = ({ roomId }) => {
const description = const description =
typeof descriptionData === "string" ? descriptionData : ""; typeof descriptionData === "string" ? descriptionData : "";
const sendLogs = Boolean(data.get("sendLogs")); const sendLogs = Boolean(data.get("sendLogs"));
const rageshakeRequestId = randomString(16); const rageshakeRequestId = secureRandomString(16);
submitRageshake({ submitRageshake({
description, description,

View File

@@ -30,7 +30,7 @@ Please see LICENSE in the repository root for full details.
import EventEmitter from "events"; import EventEmitter from "events";
import { throttle } from "lodash-es"; import { throttle } from "lodash-es";
import { type Logger, logger } from "matrix-js-sdk/src/logger"; import { type Logger, logger } from "matrix-js-sdk/src/logger";
import { randomString } from "matrix-js-sdk/src/randomstring"; import { secureRandomString } from "matrix-js-sdk/src/randomstring";
import { type LoggingMethod } from "loglevel"; import { type LoggingMethod } from "loglevel";
import type loglevel from "loglevel"; import type loglevel from "loglevel";
@@ -128,7 +128,7 @@ class IndexedDBLogStore {
private indexedDB: IDBFactory, private indexedDB: IDBFactory,
private loggerInstance: ConsoleLogger, private loggerInstance: ConsoleLogger,
) { ) {
this.id = "instance-" + randomString(16); this.id = "instance-" + secureRandomString(16);
loggerInstance.on(ConsoleLoggerEvent.Log, this.onLoggerLog); loggerInstance.on(ConsoleLoggerEvent.Log, this.onLoggerLog);
window.addEventListener("beforeunload", () => { window.addEventListener("beforeunload", () => {