feat(core): Use WebCrypto to generate all random numbers and strings (#9786)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-06-19 13:33:57 +02:00
committed by GitHub
parent cfc4db00e3
commit 65c5609ab5
49 changed files with 254 additions and 214 deletions

View File

@@ -8,6 +8,7 @@ import type {
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { randomString } from 'n8n-workflow';
import * as mqtt from 'mqtt';
import { formatPrivateKey } from '@utils/utilities';
@@ -116,7 +117,7 @@ export class Mqtt implements INodeType {
const brokerUrl = `${protocol}://${host}`;
const port = (credentials.port as number) || 1883;
const clientId =
(credentials.clientId as string) || `mqttjs_${Math.random().toString(16).substr(2, 8)}`;
(credentials.clientId as string) || `mqttjs_${randomString(8).toLowerCase()}`;
const clean = credentials.clean as boolean;
const ssl = credentials.ssl as boolean;
const ca = formatPrivateKey(credentials.ca as string);
@@ -189,8 +190,7 @@ export class Mqtt implements INodeType {
const host = credentials.host as string;
const brokerUrl = `${protocol}://${host}`;
const port = (credentials.port as number) || 1883;
const clientId =
(credentials.clientId as string) || `mqttjs_${Math.random().toString(16).substr(2, 8)}`;
const clientId = (credentials.clientId as string) || `mqttjs_${randomString(8).toLowerCase()}`;
const clean = credentials.clean as boolean;
const ssl = credentials.ssl as boolean;
const ca = credentials.ca as string;