diff --git a/packages/common/package.json b/packages/common/package.json index 16b215423c..42e97a6157 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "@quiet/types": "^1.8.1", - "@peculiar/webcrypto": "1.4.3", "cross-env": "^5.2.0", "debug": "^4.3.1" }, diff --git a/packages/common/src/auth.test.ts b/packages/common/src/auth.test.ts index 72a9d5f3fc..3d00770d7b 100644 --- a/packages/common/src/auth.test.ts +++ b/packages/common/src/auth.test.ts @@ -1,8 +1,8 @@ -import { encodeSecret, generateSecret, verifyToken } from './auth' +import { encodeSecret, verifyToken } from './auth' describe('Auth', () => { it('correctly create secret, encode and decode', () => { - const secret = generateSecret() + const secret = 'secret' const token = encodeSecret(secret) const decodedSecret = verifyToken(secret, token) @@ -10,7 +10,7 @@ describe('Auth', () => { }) it('create token with wrong secret', () => { - const secret = generateSecret() + const secret = 'secret' const token = encodeSecret('test') const decodedSecret = verifyToken(secret, token) diff --git a/packages/common/src/auth.ts b/packages/common/src/auth.ts index 3a55525746..41bd90449e 100644 --- a/packages/common/src/auth.ts +++ b/packages/common/src/auth.ts @@ -1,11 +1,3 @@ -import { Crypto } from '@peculiar/webcrypto' - -const webcrypto = new Crypto() - -const array = new Uint32Array(5) - -export const generateSecret = () => webcrypto.getRandomValues(array).join('') - export const encodeSecret = (secret: string) => Buffer.from(secret).toString('base64') export const verifyToken = (secret: string, token: string): boolean => { diff --git a/packages/desktop/src/main/main.ts b/packages/desktop/src/main/main.ts index bcd0e5e9a9..ff8bfe6ad4 100644 --- a/packages/desktop/src/main/main.ts +++ b/packages/desktop/src/main/main.ts @@ -11,7 +11,7 @@ import { Crypto } from '@peculiar/webcrypto' import logger from './logger' import { DATA_DIR, DEV_DATA_DIR } from '../shared/static' import { fork, ChildProcess } from 'child_process' -import { generateSecret, getFilesData } from '@quiet/common' +import { getFilesData } from '@quiet/common' import { updateDesktopFile, processInvitationCode } from './invitation' import { argvInvitationCode, retrieveInvitationCode } from '@quiet/common' const ElectronStore = require('electron-store') @@ -103,7 +103,7 @@ setEngine( }) ) -const SOCKET_IO_SECRET = generateSecret() +const SOCKET_IO_SECRET = webcrypto.getRandomValues(new Uint32Array(5)).join('') export const isBrowserWindow = (window: BrowserWindow | null): window is BrowserWindow => { return window instanceof BrowserWindow