diff --git a/apps/meteor/client/lib/utils/createToken.ts b/apps/meteor/client/lib/utils/createToken.ts deleted file mode 100644 index 25360b773ba..00000000000 --- a/apps/meteor/client/lib/utils/createToken.ts +++ /dev/null @@ -1,14 +0,0 @@ -export const createToken = (): string => { - const array = new Uint8Array(16); - if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) { - window.crypto.getRandomValues(array); - } else { - // Use Node.js crypto - const { randomBytes } = require('crypto'); // eslint-disable-line @typescript-eslint/no-var-requires - const buffer = randomBytes(16); - array.set(buffer); - } - return Array.from(array) - .map((byte) => byte.toString(16).padStart(2, '0')) - .join(''); -}; diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center.spec.ts index f772fae53ab..5e472023972 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center.spec.ts @@ -1,11 +1,23 @@ +import { randomBytes } from 'crypto'; + import { faker } from '@faker-js/faker'; -import { createToken } from '../../../client/lib/utils/createToken'; import { Users } from '../fixtures/userStates'; import { OmnichannelContacts } from '../page-objects/omnichannel-contacts-list'; import { OmnichannelSection } from '../page-objects/omnichannel-section'; import { test, expect } from '../utils/test'; +const createToken = (): string => { + const array = new Uint8Array(16); + + const buffer = randomBytes(16); + array.set(buffer); + + return Array.from(array) + .map((byte) => byte.toString(16).padStart(2, '0')) + .join(''); +}; + const createContact = (generateToken = false) => ({ id: null, name: `${faker.person.firstName()} ${faker.person.lastName()}`,