Skip to content

Commit

Permalink
chore: merged develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkabuki committed Nov 28, 2023
2 parents da67618 + c3faf4f commit 81708ec
Show file tree
Hide file tree
Showing 133 changed files with 2,480 additions and 538 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/desktop-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
TEST_MODE: ${{ github.event.action == 'prereleased' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet' || 'test.quiet' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet.2.x' || 'test.quiet' }}
CHECKSUM_PATH: ${{ github.event.action == 'released' && 'packages/desktop/dist/latest-linux.yml' || 'packages/desktop/dist/alpha-linux.yml' }}

steps:
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
env:
TEST_MODE: ${{ github.event.action == 'prereleased' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet' || 'test.quiet' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet.2.x' || 'test.quiet' }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -138,8 +138,9 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.MAC_CSC_LINK }}
APPLEID: ${{ secrets.APPLE_ID }}
APPLEIDPASS: ${{ secrets.APPLE_ID_PASS }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASS: ${{ secrets.APPLE_ID_PASS }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
USE_HARD_LINKS: false
Expand Down Expand Up @@ -175,7 +176,7 @@ jobs:
env:
TEST_MODE: ${{ github.event.action == 'prereleased' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet' || 'test.quiet' }}
S3_BUCKET: ${{ github.event.action == 'released' && 'quiet.2.x' || 'test.quiet' }}

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest-m]
os: [ubuntu-20.04, ubuntu-22.04]

timeout-minutes: 180

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: E2E Windows
on: [workflow_call]
jobs:
windows:
runs-on: windows-latest-l
runs-on: windows-2019

timeout-minutes: 180

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
run: Start-Process "Quiet Setup ${{ steps.extract_version.outputs.version }}.exe" -Wait
working-directory: ./packages/desktop/dist
shell: powershell

- name: Check if Quiet installed properly
run: Get-ChildItem -Path C:\Users\runneradmin\AppData\Local\Programs\@quietdesktop
shell: powershell
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[unreleased]

* Fix saveUserCsr saga to trigger only if user csr is absent in user slice.

* Send an info message immediately after a user joins the community

* Feature: add functionality to export chat to text document in desktop version

[2.0.3-alpha.6]

* Fix: filter out invalid peer addresses in peer list. Update peer list in localdb.

* Fix: dial new peers on CSRs replication

[2.0.3-alpha.5]

* Fix network data proceeding when using custom protocol multiple times #1847
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Encrypted p2p team chat with no servers, just Tor.
<br />
<!-- <a href="https://tryquiet.org"><strong>tryquiet.org »</strong></a> -->
<a href="https://github.com/TryQuiet/quiet/releases/tag/quiet%401.9.6"><strong>Downloads</strong></a> |
<a href="https://github.com/TryQuiet/quiet/releases/tag/quiet%401.9.7"><strong>Downloads</strong></a> |
<a href="#how-it-works"><strong>How it Works</strong></a> |
<a href="#features"><strong>Features</strong></a> |
<a href="https://github.com/TryQuiet/monorepo/wiki/Threat-Model"><strong>Threat Model</strong></a> |
Expand Down Expand Up @@ -52,7 +52,7 @@ See our [FAQ](https://github.com/TryQuiet/monorepo/wiki/Quiet-FAQ) for answers t

## Getting started

To try Quiet, download the [latest release](https://github.com/TryQuiet/quiet/releases/tag/quiet%401.9.6) for your platform (.dmg for macOS, .exe for Windows, etc.) and install it in the normal way. Then create a community and open the community's settings to invite members.
To try Quiet, download the [latest release](https://github.com/TryQuiet/quiet/releases/tag/quiet%401.9.7) for your platform (.dmg for macOS, .exe for Windows, etc.) and install it in the normal way. Then create a community and open the community's settings to invite members.

If you'd like to help develop Quiet, see [Contributing to Quiet](#contributing-to-quiet).

Expand Down
1 change: 1 addition & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline


# [1.10.0-alpha.0](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-08-29)
## [1.9.5](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-11-09)

**Note:** Version bump only for package @quiet/backend

Expand Down
20 changes: 9 additions & 11 deletions packages/backend/src/backendManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { ConnectionsManagerService } from './nest/connections-manager/connection
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'

const log = logger('backendManager')

const program = new Command()
Expand All @@ -25,21 +27,13 @@ program
.option('-a, --appDataPath <string>', 'Path of application data directory')
.option('-d, --socketIOPort <number>', 'Socket io data server port')
.option('-r, --resourcesPath <string>', 'Application resources path')
.option('-scrt, --socketIOSecret <string>', 'socketIO secret')

program.parse(process.argv)
const options = program.opts()

console.log('options', options)

interface OpenServices {
torControlPort?: any
socketIOPort?: any
httpTunnelPort?: any
authCookie?: any
}

import { INestApplicationContext } from '@nestjs/common'

export const runBackendDesktop = async () => {
const isDev = process.env.NODE_ENV === 'development'

Expand All @@ -48,11 +42,14 @@ export const runBackendDesktop = async () => {
// @ts-ignore
global.crypto = webcrypto

validateOptions(options)

const resourcesPath = isDev ? null : options.resourcesPath.trim()

const app = await NestFactory.createApplicationContext(
AppModule.forOptions({
socketIOPort: options.socketIOPort,
socketIOSecret: options.socketIOSecret,
torBinaryPath: torBinForPlatform(resourcesPath),
torResourcesPath: torDirForPlatform(resourcesPath),
torControlPort: await getPort(),
Expand Down Expand Up @@ -87,7 +84,7 @@ export const runBackendDesktop = async () => {
})
}

export const runBackendMobile = async (): Promise<any> => {
export const runBackendMobile = async () => {
// Enable triggering push notifications
process.env['BACKEND'] = 'mobile'
process.env['CONNECTION_TIME'] = (new Date().getTime() / 1000).toString() // Get time in seconds
Expand All @@ -97,6 +94,7 @@ export const runBackendMobile = async (): Promise<any> => {
const app: INestApplicationContext = await NestFactory.createApplicationContext(
AppModule.forOptions({
socketIOPort: options.dataPort,
socketIOSecret: options.socketIOSecret,
httpTunnelPort: options.httpTunnelPort ? options.httpTunnelPort : null,
torAuthCookie: options.authCookie ? options.authCookie : null,
torControlPort: options.controlPort ? options.controlPort : await getPort(),
Expand Down
36 changes: 33 additions & 3 deletions packages/backend/src/nest/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Server as SocketIO } from 'socket.io'
import { StorageModule } from './storage/storage.module'
import { IpfsModule } from './ipfs/ipfs.module'
import { Level } from 'level'
import { getCors } from './common/utils'
import { verifyToken } from '@quiet/common'

@Global()
@Module({
Expand Down Expand Up @@ -94,10 +94,40 @@ export class AppModule {
_app.use(cors())
const server = createServer(_app)
const io = new SocketIO(server, {
cors: getCors(),
cors: {
origin: '127.0.0.1',
allowedHeaders: ['authorization'],
credentials: true,
},
pingInterval: 1000_000,
pingTimeout: 1000_000,
})
io.engine.use((req, res, next) => {
const authHeader = req.headers['authorization']
if (!authHeader) {
console.error('No authorization header')
res.writeHead(401, 'No authorization header')
res.end()
return
}

const token = authHeader && authHeader.split(' ')[1]
if (!token) {
console.error('No auth token')
res.writeHead(401, 'No authorization token')
res.end()
return
}

if (verifyToken(options.socketIOSecret, token)) {
next()
} else {
console.error('Wrong basic token')
res.writeHead(401, 'Unauthorized')
res.end()
}
})

return { server, io }
},
inject: [EXPRESS_PROVIDER],
Expand All @@ -122,7 +152,7 @@ export class AppModule {
},
{
provide: LEVEL_DB,
useFactory: (dbPath: string) => new Level<string, any>(dbPath, { valueEncoding: 'json' }),
useFactory: (dbPath: string) => new Level<string, unknown>(dbPath, { valueEncoding: 'json' }),
inject: [DB_PATH],
},
],
Expand Down
17 changes: 16 additions & 1 deletion packages/backend/src/nest/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { type PermsData } from '@quiet/types'
import { TestConfig } from '../const'
import logger from './logger'
import { Libp2pNodeParams } from '../libp2p/libp2p.types'
import { createLibp2pAddress, createLibp2pListenAddress } from '@quiet/common'
import { createLibp2pAddress, createLibp2pListenAddress, isDefined } from '@quiet/common'
import { Libp2pService } from '../libp2p/libp2p.service'
import { CertFieldsTypes, getReqFieldValue, loadCSR } from '@quiet/identity'

const log = logger('test')

Expand Down Expand Up @@ -153,6 +154,20 @@ export const getUsersAddresses = async (users: UserData[]): Promise<string[]> =>
return await Promise.all(peers)
}

export const getLibp2pAddressesFromCsrs = async (csrs: string[]): Promise<string[]> => {
const addresses = await Promise.all(
csrs.map(async csr => {
const parsedCsr = await loadCSR(csr)
const peerId = getReqFieldValue(parsedCsr, CertFieldsTypes.peerId)
const onionAddress = getReqFieldValue(parsedCsr, CertFieldsTypes.commonName)
if (!peerId || !onionAddress) return

return createLibp2pAddress(onionAddress, peerId)
})
)
return addresses.filter(isDefined)
}

/**
* Compares given numbers
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RegistrationService } from '../registration/registration.service'
import { SocketModule } from '../socket/socket.module'
import { ConnectionsManagerModule } from './connections-manager.module'
import { ConnectionsManagerService } from './connections-manager.service'
import { createLibp2pAddress } from '@quiet/common'

describe('ConnectionsManagerService', () => {
let module: TestingModule
Expand Down Expand Up @@ -101,7 +102,12 @@ describe('ConnectionsManagerService', () => {
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
},
peers: community.peerList,
peers: [
createLibp2pAddress(
'y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd',
'QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE'
),
],
}

await localDbService.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)
Expand All @@ -113,41 +119,6 @@ describe('ConnectionsManagerService', () => {
expect(launchCommunitySpy).toHaveBeenCalledWith(launchCommunityPayload)
})

it('launches community on init if their data exists in local db', async () => {
const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
// @ts-expect-error
certificate: userIdentity.userCertificate,
// @ts-expect-error
key: userIdentity.userCsr?.userKey,
CA: [communityRootCa],
},
peers: community.peerList,
}

await localDbService.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)

const peerAddress = '/dns4/test.onion/tcp/80/ws/p2p/peerid'
await localDbService.put(LocalDBKeys.PEERS, {
[peerAddress]: {
peerId: 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix',
connectionTime: 50,
lastSeen: 1000,
},
})

await connectionsManagerService.closeAllServices()

const launchCommunitySpy = jest.spyOn(connectionsManagerService, 'launchCommunity').mockResolvedValue()

await connectionsManagerService.init()

expect(launchCommunitySpy).toHaveBeenCalledWith(Object.assign(launchCommunityPayload, { peers: [peerAddress] }))
})

it('does not launch community on init if its data does not exist in local db', async () => {
await connectionsManagerService.closeAllServices()
await connectionsManagerService.init()
Expand Down Expand Up @@ -200,10 +171,10 @@ describe('ConnectionsManagerService', () => {
// await connectionsManager.init()
await localDbService.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)

const peerAddress = '/dns4/test.onion/tcp/80/ws/p2p/peerid'
const peerid = 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix'
await localDbService.put(LocalDBKeys.PEERS, {
[peerAddress]: {
peerId: 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix',
[peerid]: {
peerId: peerid,
connectionTime: 50,
lastSeen: 1000,
},
Expand Down
Loading

0 comments on commit 81708ec

Please sign in to comment.