diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.ts index e3ee957167..267e55e55c 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.ts @@ -14,6 +14,7 @@ import { CertFieldsTypes, createRootCA, createUserCsr, + configCrypto, getCertFieldValue, getPubKey, loadCertificate, @@ -77,7 +78,6 @@ import { DateTime } from 'luxon' import { createLogger } from '../common/logger' import { createFromJSON } from '@libp2p/peer-id-factory' import { PeerId } from '@libp2p/interface' -import { config } from '@quiet/state-manager' @Injectable() export class ConnectionsManagerService extends EventEmitter implements OnModuleInit { @@ -446,7 +446,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI } const _pubKey = await pubKeyFromCsr(identity.userCsr.userCsr) const publicKey = await getPubKey(_pubKey) - const privateKey = await loadPrivateKey(identity.userCsr.userKey, config.signAlg) + const privateKey = await loadPrivateKey(identity.userCsr.userKey, configCrypto.signAlg) const existingKeyPair: CryptoKeyPair = { privateKey, publicKey } @@ -454,8 +454,8 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI nickname, commonName: identity.hiddenService.onionAddress, peerId: identity.peerId.id, - signAlg: config.signAlg, - hashAlg: config.hashAlg, + signAlg: configCrypto.signAlg, + hashAlg: configCrypto.hashAlg, existingKeyPair, } } else { @@ -464,8 +464,8 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI nickname, commonName: identity.hiddenService.onionAddress, peerId: identity.peerId.id, - signAlg: config.signAlg, - hashAlg: config.hashAlg, + signAlg: configCrypto.signAlg, + hashAlg: configCrypto.hashAlg, } } diff --git a/packages/backend/src/nest/libp2p/libp2p.service.ts b/packages/backend/src/nest/libp2p/libp2p.service.ts index ab74dac9d4..14a6ad6548 100644 --- a/packages/backend/src/nest/libp2p/libp2p.service.ts +++ b/packages/backend/src/nest/libp2p/libp2p.service.ts @@ -232,7 +232,7 @@ export class Libp2pService extends EventEmitter { this.logger.info(`Creating or opening existing level datastore for libp2p`) this.libp2pDatastore = new Libp2pDatastore({ - inMemory: true, + inMemory: false, datastorePath: this.datastorePath, }) diff --git a/packages/mobile/ios/Podfile.lock b/packages/mobile/ios/Podfile.lock index 77dbd77f7e..6eb1c42919 100644 --- a/packages/mobile/ios/Podfile.lock +++ b/packages/mobile/ios/Podfile.lock @@ -1398,4 +1398,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: eed49772dde039b0723324c813c83dd4c1af35f7 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/packages/state-manager/src/index.ts b/packages/state-manager/src/index.ts index d111024b4e..21809eecb6 100644 --- a/packages/state-manager/src/index.ts +++ b/packages/state-manager/src/index.ts @@ -89,8 +89,6 @@ export * from './sagas/communities/communities.types' export * from './sagas/users/users.types' -export * from './sagas/users/const/certFieldTypes' - export * from './sagas/publicChannels/publicChannels.types' export * from './sagas/messages/messages.types' diff --git a/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.test.ts b/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.test.ts index 549e6c37e0..dcdc424f36 100644 --- a/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.test.ts +++ b/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.test.ts @@ -1,15 +1,14 @@ import { combineReducers } from '@reduxjs/toolkit' import { expectSaga } from 'redux-saga-test-plan' import * as matchers from 'redux-saga-test-plan/matchers' -import { setupCrypto, createUserCsr, type UserCsr, getPubKey, loadPrivateKey, pubKeyFromCsr } from '@quiet/identity' +import { setupCrypto, type UserCsr } from '@quiet/identity' import { prepareStore } from '../../../utils/tests/prepareStore' import { getFactory } from '../../../utils/tests/factories' import { reducers } from '../../reducers' import { identityActions } from '../identity.slice' import { registerUsernameSaga } from './registerUsername.saga' import { communitiesActions } from '../../communities/communities.slice' -import { config } from '../../users/const/certFieldTypes' -import { CertData, CreateUserCsrPayload, InitUserCsrPayload, SocketActionTypes } from '@quiet/types' +import { CertData, InitUserCsrPayload, SocketActionTypes } from '@quiet/types' import { Socket } from '../../../types' import { communitiesSelectors } from '../../communities/communities.selectors' diff --git a/packages/state-manager/src/sagas/messages/sendMessage/sendMessage.saga.ts b/packages/state-manager/src/sagas/messages/sendMessage/sendMessage.saga.ts index f9ea5ee105..bc31722320 100644 --- a/packages/state-manager/src/sagas/messages/sendMessage/sendMessage.saga.ts +++ b/packages/state-manager/src/sagas/messages/sendMessage/sendMessage.saga.ts @@ -3,7 +3,6 @@ import { type PayloadAction } from '@reduxjs/toolkit' import { sign, loadPrivateKey, pubKeyFromCsr } from '@quiet/identity' import { call, select, apply, put, delay, take } from 'typed-redux-saga' import { arrayBufferToString } from 'pvutils' -import { config } from '../../users/const/certFieldTypes' import { identitySelectors } from '../../identity/identity.selectors' import { publicChannelsActions } from '../../publicChannels/publicChannels.slice' import { publicChannelsSelectors } from '../../publicChannels/publicChannels.selectors' @@ -11,6 +10,7 @@ import { messagesActions } from '../messages.slice' import { generateMessageId, getCurrentTime } from '../utils/message.utils' import { type ChannelMessage, MessageType, SendingStatus, SocketActionTypes } from '@quiet/types' import { createLogger } from '../../../utils/logger' +import { configCrypto } from '@quiet/identity' const logger = createLogger('sendMessageSaga') @@ -37,7 +37,7 @@ export function* sendMessageSaga( logger.info(`Sending message ${id} to channel ${channelId}`) const pubKey = yield* call(pubKeyFromCsr, identity.userCsr.userCsr) - const keyObject = yield* call(loadPrivateKey, identity.userCsr.userKey, config.signAlg) + const keyObject = yield* call(loadPrivateKey, identity.userCsr.userKey, configCrypto.signAlg) const signatureArrayBuffer = yield* call(sign, action.payload.message, keyObject) const signature = yield* call(arrayBufferToString, signatureArrayBuffer) const createdAt = yield* call(getCurrentTime) diff --git a/packages/state-manager/src/sagas/users/const/certFieldTypes.ts b/packages/state-manager/src/sagas/users/const/certFieldTypes.ts deleted file mode 100644 index da39a0c858..0000000000 --- a/packages/state-manager/src/sagas/users/const/certFieldTypes.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum CertFieldsTypes { - commonName = '2.5.4.3', - subjectAltName = '2.5.29.17', - nickName = '1.3.6.1.4.1.50715.2.1', - peerId = '1.3.6.1.2.1.15.3.1.1', -} - -export const config = { - signAlg: 'ECDSA', - hashAlg: 'sha-256', -} diff --git a/packages/state-manager/src/sagas/users/userProfile/saveUserProfile.saga.ts b/packages/state-manager/src/sagas/users/userProfile/saveUserProfile.saga.ts index b1669df26b..80d75c339f 100644 --- a/packages/state-manager/src/sagas/users/userProfile/saveUserProfile.saga.ts +++ b/packages/state-manager/src/sagas/users/userProfile/saveUserProfile.saga.ts @@ -5,13 +5,11 @@ import * as Block from 'multiformats/block' import * as dagCbor from '@ipld/dag-cbor' import { sha256 } from 'multiformats/hashes/sha2' -import { sign, loadPrivateKey, pubKeyFromCsr } from '@quiet/identity' +import { sign, loadPrivateKey, pubKeyFromCsr, configCrypto } from '@quiet/identity' import { UserProfile, UserProfileData, SocketActionTypes } from '@quiet/types' import { fileToBase64String } from '@quiet/common' -import { config } from '../../users/const/certFieldTypes' import { identitySelectors } from '../../identity/identity.selectors' -import { usersActions } from '../users.slice' import { type Socket, applyEmitParams } from '../../../types' import { createLogger } from '../../../utils/logger' @@ -36,7 +34,7 @@ export function* saveUserProfileSaga(socket: Socket, action: PayloadAction<{ pho const codec = dagCbor const hasher = sha256 const { bytes } = yield* call(Block.encode, { value: profile, codec: codec, hasher: hasher }) - const keyObject = yield* call(loadPrivateKey, identity.userCsr.userKey, config.signAlg) + const keyObject = yield* call(loadPrivateKey, identity.userCsr.userKey, configCrypto.signAlg) const signatureArrayBuffer = yield* call(sign, bytes, keyObject) const signature = yield* call(arrayBufferToString, signatureArrayBuffer) const pubKey = yield* call(pubKeyFromCsr, identity.userCsr.userCsr) diff --git a/packages/state-manager/src/sagas/users/users.selectors.ts b/packages/state-manager/src/sagas/users/users.selectors.ts index c3742ea5ae..436acb4899 100644 --- a/packages/state-manager/src/sagas/users/users.selectors.ts +++ b/packages/state-manager/src/sagas/users/users.selectors.ts @@ -1,6 +1,11 @@ import { createSelector } from '@reduxjs/toolkit' -import { getCertFieldValue, getReqFieldValue, keyFromCertificate, loadCertificate } from '@quiet/identity' -import { CertFieldsTypes } from './const/certFieldTypes' +import { + getCertFieldValue, + getReqFieldValue, + keyFromCertificate, + loadCertificate, + CertFieldsTypes, +} from '@quiet/identity' import { StoreKeys } from '../store.keys' import { certificatesAdapter } from './users.adapter' import { type Certificate } from 'pkijs' diff --git a/packages/state-manager/src/utils/tests/helpers.ts b/packages/state-manager/src/utils/tests/helpers.ts index 84c9cee33a..85d334c628 100644 --- a/packages/state-manager/src/utils/tests/helpers.ts +++ b/packages/state-manager/src/utils/tests/helpers.ts @@ -1,8 +1,7 @@ -import { keyFromCertificate, loadPrivateKey, parseCertificate, sign } from '@quiet/identity' +import { configCrypto, keyFromCertificate, loadPrivateKey, parseCertificate, sign } from '@quiet/identity' // import fs from 'fs' // import os from 'os' import { arrayBufferToString } from 'pvutils' -import { config } from '../../sagas/users/const/certFieldTypes' import { type PeerId } from '@quiet/types' import { createLogger } from '../../utils/logger' @@ -25,7 +24,7 @@ export const createMessageSignatureTestHelper = async ( userKey: string ): Promise<{ signature: string; pubKey: string }> => { const pubKey = keyFromCertificate(parseCertificate(certificate)) - const keyObject = await loadPrivateKey(userKey, config.signAlg) + const keyObject = await loadPrivateKey(userKey, configCrypto.signAlg) const signatureArrayBuffer = await sign(message, keyObject) const signature = arrayBufferToString(signatureArrayBuffer) return {