Skip to content

Commit

Permalink
Merge branch 'develop' into feat/dark-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-kiss authored May 16, 2024
2 parents 3d50808 + 613e5e6 commit 8c11e48
Show file tree
Hide file tree
Showing 224 changed files with 5,508 additions and 3,484 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: FILE_NAME env
working-directory: ./packages/desktop/dist
run: echo "FILE_NAME="Quiet-$VERSION-arm64.dmg"" >> $GITHUB_ENV
run: echo "FILE_NAME="Quiet-$VERSION.dmg"" >> $GITHUB_ENV

- name: List dist dir content
working-directory: ./packages/desktop/dist
Expand All @@ -50,7 +50,7 @@ jobs:
run: hdiutil mount $FILE_NAME

- name: Add App file to applications
run: cd ~ && cp -R "/Volumes/Quiet $VERSION-arm64/Quiet.app" /Applications
run: cd ~ && cp -R "/Volumes/Quiet $VERSION/Quiet.app" /Applications

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ c4/workspace.json
.DS_Store
.vscode
packages/.DS_Store
.idea
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# Chores

* Cleanup data directory at end of e2e tests
* Update mobile development README ([#2483](https://github.com/TryQuiet/quiet/issues/2483))
* Update github workflows for PR gating ([#2487](https://github.com/TryQuiet/quiet/issues/2487))
* Don't create duplicate CSRs when joining a community under certain circumstances ([#2321](https://github.com/TryQuiet/quiet/issues/2321))
* Add abstract base classes for stores ([#2407](https://github.com/TryQuiet/quiet/issues/2407))

[2.2.0]

Expand Down
26 changes: 16 additions & 10 deletions packages/backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint:no-fix": "eslint --ext .jsx,.js,.ts,.tsx ./src/",
"lint": "npm run lint:no-fix -- --fix",
"lint-ci": "npm run lint:no-fix",
"lint-staged": "lint-staged",
"lint-staged": "lint-staged --no-stash",
"test-nest": "cross-env NODE_OPTIONS=--experimental-vm-modules DEBUG=ipfs:*,backend:* node_modules/jest/bin/jest.js --detectOpenHandles --forceExit ./src/nest/**/*.spec.ts",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules DEBUG=ipfs:*,backend:* jest --runInBand --verbose --testPathIgnorePatterns=\".src/(!?nodeTest*)|(.node_modules*)\" --",
"test-ci": "cross-env NODE_OPTIONS=--experimental-vm-modules jest ./src/**/* --runInBand --colors --ci --silent --verbose --testPathIgnorePatterns=\".src/nest/(!?nodeTest*)|(.node_modules*)|src/nest/.*\\.tor.spec\\.(t|j)s|src/nest/ipfs-file-manager/big-files.long.spec.ts$\"",
Expand Down Expand Up @@ -61,7 +61,7 @@
"@types/crypto-js": "^4.0.2",
"@types/express": "^4.17.9",
"@types/jest": "28.1.8",
"@types/luxon": "^3.3.0",
"@types/luxon": "^3.4.2",
"@types/mock-fs": "^4.13.1",
"@types/node": "18.11.9",
"@types/node-fetch": "^2.5.11",
Expand Down Expand Up @@ -108,9 +108,8 @@
"dotenv": "8.2.0",
"events": "^3.2.0",
"express": "^4.17.1",
"fetch-retry": "^6.0.0",
"node-fetch": "^3.3.0",
"fastq": "^1.17.1",
"fetch-retry": "^6.0.0",
"get-port": "^5.1.1",
"go-ipfs": "npm:[email protected]",
"http-server": "^0.12.3",
Expand All @@ -122,8 +121,9 @@
"joi": "^17.8.1",
"level": "8.0.0",
"libp2p": "0.42.2",
"luxon": "^1.11.4",
"luxon": "^3.4.4",
"multiaddr": "^10.0.1",
"node-fetch": "^3.3.0",
"orbit-db": "0.29.0",
"orbit-db-access-controllers": "^0.4.0",
"orbit-db-identity-provider": "0.5.0",
Expand Down Expand Up @@ -152,6 +152,6 @@
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": "npm run lint:no-fix"
"src/**/*.{js,jsx,ts,tsx}": "npm run lint:no-fix"
}
}
18 changes: 11 additions & 7 deletions packages/backend/src/backendManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { TorControl } from './nest/tor/tor-control.service'
import { torBinForPlatform, torDirForPlatform } from './nest/common/utils'
import initRnBridge from './rn-bridge'
import { INestApplicationContext } from '@nestjs/common'
import logger from './nest/common/logger'
import { OpenServices, validateOptions } from './options'
import { SOCKS_PROXY_AGENT } from './nest/const'
import { createLogger } from './nest/common/logger'

const log = logger('backendManager')
const logger = createLogger('backendManager')

const program = new Command()

Expand All @@ -33,9 +33,11 @@ program
program.parse(process.argv)
const options = program.opts()

console.log('options', options)
logger.info('options', options)

export const runBackendDesktop = async () => {
logger.info('Running backend manager desktop')

const isDev = process.env.NODE_ENV === 'development'

const webcrypto = new Crypto()
Expand Down Expand Up @@ -69,22 +71,24 @@ export const runBackendDesktop = async () => {
try {
await connectionsManager.closeAllServices()
} catch (e) {
log.error('Error occurred while closing backend services', e)
logger.error('Error occurred while closing backend services', e)
}
if (process.send) process.send('closed-services')
}
if (message === 'leaveCommunity') {
try {
await connectionsManager.leaveCommunity()
} catch (e) {
log.error('Error occurred while leaving community', e)
logger.error('Error occurred while leaving community', e)
}
if (process.send) process.send('leftCommunity')
}
})
}

export const runBackendMobile = async () => {
logger.info('Running backend manager mobile')

// Enable triggering push notifications
process.env['BACKEND'] = 'mobile'
process.env['CONNECTION_TIME'] = (new Date().getTime() / 1000).toString() // Get time in seconds
Expand Down Expand Up @@ -131,12 +135,12 @@ const platform = options.platform

if (platform === 'desktop') {
runBackendDesktop().catch(error => {
log.error('Error occurred while initializing backend', error)
logger.error('Error occurred while initializing backend', error)
throw error
})
} else if (platform === 'mobile') {
runBackendMobile().catch(async error => {
log.error('Error occurred while initializing backend', error)
logger.error('Error occurred while initializing backend', error)
// Prevent stopping process before getting output
await new Promise<void>(resolve => {
setTimeout(() => {
Expand Down
13 changes: 8 additions & 5 deletions packages/backend/src/nest/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import { StorageModule } from './storage/storage.module'
import { IpfsModule } from './ipfs/ipfs.module'
import { Level } from 'level'
import { verifyToken } from '@quiet/common'
import { createLogger } from './common/logger'

const logger = createLogger('appModule')

@Global()
@Module({
Expand All @@ -58,7 +61,7 @@ import { verifyToken } from '@quiet/common'
export class AppModule {
static forOptions(options: ConnectionsManagerTypes) {
const configOptions: ConfigOptions = { ...options, ...new ConnectionsManagerOptions() }
console.log('configOptions', configOptions)
logger.info('configOptions', configOptions)
return {
module: AppModule,
providers: [
Expand Down Expand Up @@ -105,15 +108,15 @@ export class AppModule {
io.engine.use((req, res, next) => {
const authHeader = req.headers['authorization']
if (!authHeader) {
console.error('Backend server: No authorization header')
logger.error('Backend server: No authorization header')
res.writeHead(401, 'No authorization header')
res.end()
return
}

const token = authHeader && authHeader.split(' ')[1]
if (!token) {
console.error('Backend server: No auth token')
logger.error('Backend server: No auth token')
res.writeHead(401, 'No authorization token')
res.end()
return
Expand All @@ -122,12 +125,12 @@ export class AppModule {
if (verifyToken(options.socketIOSecret, token)) {
next()
} else {
console.error('Backend server: Unauthorized')
logger.error('Backend server: Unauthorized')
res.writeHead(401, 'Unauthorized')
res.end()
}
})
console.log('ok')
logger.info('ok')
return { server, io }
},
inject: [EXPRESS_PROVIDER],
Expand Down
8 changes: 2 additions & 6 deletions packages/backend/src/nest/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { logger } from '@quiet/logger'
import { createQuietLogger } from '@quiet/logger'

const createLogger = (name: string) => {
return logger('backend')(name)
}

export default createLogger
export const createLogger = createQuietLogger('backend')
5 changes: 0 additions & 5 deletions packages/backend/src/nest/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ export interface PublicChannelsRepo {
eventsAttached: boolean
}

export interface DirectMessagesRepo {
db: EventStore<string>
eventsAttached: boolean
}

export type ChannelInfoResponse = Record<string, PublicChannel>

export class StorageOptions {
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/nest/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import tmp from 'tmp'
import crypto, { sign } from 'crypto'
import { type PermsData } from '@quiet/types'
import { TestConfig } from '../const'
import logger from './logger'
import { Libp2pNodeParams } from '../libp2p/libp2p.types'
import { createLibp2pAddress, createLibp2pListenAddress, isDefined } from '@quiet/common'
import { Libp2pService } from '../libp2p/libp2p.service'
import { CertFieldsTypes, getReqFieldValue, loadCSR } from '@quiet/identity'
import { execFile } from 'child_process'
import { createLogger } from './logger'

const log = logger('test')
const logger = createLogger('utils')

export interface Ports {
socksPort: number
Expand All @@ -27,7 +27,7 @@ export interface Ports {
}

export function createPaths(paths: string[]) {
console.log('creating paths in fn - utils')
logger.info('creating paths in fn - utils')
for (const path of paths) {
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true })
Expand All @@ -37,7 +37,7 @@ export function createPaths(paths: string[]) {

export function removeFilesFromDir(dirPath: string) {
if (fs.existsSync(dirPath)) {
log(`Removing ${dirPath}`)
logger.info(`Removing ${dirPath}`)
fs.rmdirSync(dirPath, { recursive: true })
}
}
Expand Down Expand Up @@ -114,12 +114,12 @@ export const getPorts = async (): Promise<Ports> => {

export class DummyIOServer extends Server {
emit(event: string, ...args: any[]): boolean {
log(`Emitting ${event} with args:`, args)
logger.info(`Emitting ${event} with args:`, args)
return true
}

close() {
log('Closing DummyIOServer')
logger.info('Closing DummyIOServer')
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import { Libp2pEvents } from '../libp2p/libp2p.types'
import { sleep } from '../common/sleep'
import { createLibp2pAddress } from '@quiet/common'
import { lib } from 'crypto-js'
import { createLogger } from '../common/logger'

const logger = createLogger('connectionsManager:test')

jest.setTimeout(100_000)

Expand Down Expand Up @@ -200,7 +203,7 @@ describe('Connections manager', () => {
const peerList: string[] = []
const peersCount = 7
for (let pCount = 0; pCount < peersCount; pCount++) {
console.log('pushing peer ', pCount)
logger.info('pushing peer ', pCount)
peerList.push(
createLibp2pAddress(`${Math.random().toString(36).substring(2, 13)}.onion`, (await createPeerId()).toString())
)
Expand Down
Loading

0 comments on commit 8c11e48

Please sign in to comment.