Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Quiet client to detect a v2 invite link format #2330

Merged
merged 31 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
28dc343
refactor: adjust customProtocolSaga code to be similar to deepLinkSag…
EmiM Mar 5, 2024
b8aa768
fix: customProtocolSaga tests
EmiM Mar 5, 2024
928a412
Merge branch 'develop' into feature/2310
EmiM Mar 5, 2024
1460d57
fix: tests; add missing file
EmiM Mar 5, 2024
b4e8f45
fix: main.ts test
EmiM Mar 6, 2024
7d0b19a
feat: handle old (psk, orbitdbIdentity, addresses) and new (cid, toke…
EmiM Mar 7, 2024
d386067
chore: adjust types
EmiM Mar 11, 2024
d5f7b66
chore: add joinNetwork saga that gathers data for createNetwork; mock…
EmiM Mar 11, 2024
67268d2
Merge branch 'develop' into feature/2310
EmiM Mar 11, 2024
a4d674b
refactor: invitation link parsers
EmiM Mar 14, 2024
8cc6fd3
fix: deepLink saga tests
EmiM Mar 14, 2024
b8203f9
refactor: simplify deepLink and customProtocol sagas
EmiM Mar 15, 2024
7d75c3a
fix: invitation code utils tests
EmiM Mar 15, 2024
d333cfe
chore: add missing github workflow for running common package tests
EmiM Mar 15, 2024
de8533c
refactor: invitation code tests
EmiM Mar 18, 2024
4895b29
fix: unit tests
EmiM Mar 18, 2024
3b5cf43
Merge branch 'develop' into feature/2310
EmiM Mar 18, 2024
54b925c
Merge branch 'develop' into feature/2310
EmiM Mar 19, 2024
6e82f71
feat: add one script for preparing AppImage for e2e tests
EmiM Mar 19, 2024
5f80ac1
fix: 'copy app image for e2e' script
EmiM Mar 19, 2024
7471a24
fix: getting env file name in e2e tests
EmiM Mar 19, 2024
967665d
chore: remove unused code responsible for locking invitation link for…
EmiM Mar 20, 2024
9f84ffe
chore: update changelog
EmiM Mar 20, 2024
bc2430d
Merge branch 'develop' into feature/2310
EmiM Mar 21, 2024
066a201
Merge branch 'develop' into feature/2310
EmiM Mar 25, 2024
beaec60
Merge branch 'develop' into feature/2310
EmiM Apr 4, 2024
cd863db
Merge branch 'develop' into feature/2310
EmiM Apr 9, 2024
a529c7f
fix: mobile tests
EmiM Apr 9, 2024
fcd8b2b
fix: long failing backend test
EmiM Apr 10, 2024
7b5b688
Merge branch 'develop' into feature/2310
EmiM Apr 10, 2024
8ac27e3
Merge branch 'develop' into feature/2310
EmiM Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/utils-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Common package tests

on:
pull_request:
paths:
- packages/common/**

jobs:
utils-tests:
timeout-minutes: 25
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-2019]

steps:
- name: "Print OS"
run: echo ${{ matrix.os }}

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: "Setup environment"
uses: ./.github/actions/setup-env
with:
bootstrap-packages: "@quiet/eslint-config,@quiet/logger,@quiet/types,@quiet/common"

- name: "Unit tests"
run: lerna run test --scope @quiet/common --stream
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

# New features:

* Add support for new format of invitation link: `c=<cid>&t=<token>&s=<serverAddress>&i=<inviterAddress>` ([#2310](https://github.com/TryQuiet/quiet/issues/2310))

# Refactorings:

# Fixes:
# Fixes

# Chores

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"start:desktop": "lerna run --scope @quiet/desktop start",
"lint:all": "lerna run lint",
"distAndRunE2ETests:mac:local": "lerna run --scope @quiet/desktop distMac:local && lerna run --scope e2e-tests test:localBinary --",
"e2e:linux:build": "lerna run --scope @quiet/backend webpack:prod && lerna run --scope @quiet/desktop distUbuntu && lerna run --scope e2e-tests linux:copy",
"e2e:linux:run": "lerna run --scope e2e-tests test --",
"prepare": "husky",
"lint-staged": "lerna run lint-staged"
},
Expand Down
13 changes: 8 additions & 5 deletions packages/backend/jestSetup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { setEngine, CryptoEngine } from'pkijs'
import { setEngine, CryptoEngine } from 'pkijs'
import { Crypto } from '@peculiar/webcrypto'

const crypto = new Crypto();
global.crypto = crypto;
const crypto = new Crypto()
global.crypto = crypto

setEngine('newEngine', new CryptoEngine({
setEngine(
'newEngine',
new CryptoEngine({
name: 'newEngine',
// @ts-ignore
crypto: crypto,
}))
})
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { CustomEvent } from '@libp2p/interfaces/events'
import { jest, beforeEach, describe, it, expect, afterEach } from '@jest/globals'
import { communities, getFactory, identity, prepareStore, Store } from '@quiet/state-manager'
import { createPeerId, createTmpDir, libp2pInstanceParams, removeFilesFromDir, tmpQuietDirPath } from '../common/utils'

import { NetworkStats, type Community, type Identity, type InitCommunityPayload } from '@quiet/types'
import { NetworkStats, type Community, type Identity } from '@quiet/types'
import { LazyModuleLoader } from '@nestjs/core'
import { TestingModule, Test } from '@nestjs/testing'
import { FactoryGirl } from 'factory-girl'
Expand Down Expand Up @@ -114,7 +113,6 @@ beforeEach(async () => {
})

afterEach(async () => {
await libp2pService?.libp2pInstance?.stop()
if (connectionsManagerService) {
await connectionsManagerService.closeAllServices()
}
Expand All @@ -123,6 +121,10 @@ afterEach(async () => {

describe('Connections manager', () => {
it('saves peer stats when peer has been disconnected', async () => {
// @ts-expect-error
libp2pService.processInChunksService.init = jest.fn()
// @ts-expect-error
libp2pService.processInChunksService.process = jest.fn()
class RemotePeerEventDetail {
peerId: string

Expand All @@ -138,6 +140,10 @@ describe('Connections manager', () => {

// Peer connected
await connectionsManagerService.init()
await connectionsManagerService.launchCommunity({
community,
network: { peerId: userIdentity.peerId, hiddenService: userIdentity.hiddenService },
})
libp2pService.connectedPeers.set(peerId.toString(), DateTime.utc().valueOf())

// Peer disconnected
Expand All @@ -146,11 +152,16 @@ describe('Connections manager', () => {
remotePeer: new RemotePeerEventDetail(peerId.toString()),
remoteAddr: new RemotePeerEventDetail(remoteAddr),
}
await waitForExpect(async () => {
expect(libp2pService.libp2pInstance).not.toBeUndefined()
}, 2_000)
libp2pService.libp2pInstance?.dispatchEvent(
new CustomEvent('peer:disconnect', { detail: peerDisconectEventDetail })
)
await waitForExpect(async () => {
expect(libp2pService.connectedPeers.size).toEqual(0)
}, 2000)

expect(libp2pService.connectedPeers.size).toEqual(0)
await waitForExpect(async () => {
expect(await localDbService.get(LocalDBKeys.PEERS)).not.toBeNull()
}, 2000)
Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/nest/socket/socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
type DeleteChannelResponse,
type MessagesLoadedPayload,
type NetworkInfo,
CreateNetworkPayload,
CommunityOwnership,
} from '@quiet/types'
import EventEmitter from 'events'
import { CONFIG_OPTIONS, SERVER_IO_PROVIDER } from '../const'
Expand Down Expand Up @@ -169,6 +171,21 @@ export class SocketService extends EventEmitter implements OnModuleInit {
}
)

socket.on(
SocketActionTypes.DOWNLOAD_INVITE_DATA,
async (payload: { serverAddress: string; cid: string }, callback: (response: CreateNetworkPayload) => void) => {
// this.emit(SocketActionTypes.DOWNLOAD_INVITE_DATA, payload, callback)
console.log('download invite data', payload)
// Mock it for now
callback({
ownership: CommunityOwnership.User,
peers: [],
psk: '',
ownerOrbitDbIdentity: '',
})
}
)

socket.on(SocketActionTypes.LEAVE_COMMUNITY, async () => {
this.logger('Leaving community')
this.emit(SocketActionTypes.LEAVE_COMMUNITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const areObjectsEqual = (obj1: any, obj2: any): boolean => {
// Using this only makes sense for small objects whose properties are in the same order
return JSON.stringify(obj1) === JSON.stringify(obj2)
}
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export * from './libp2p'
export * from './tests'
export * from './auth'
export * from './messages'
export * from './compare'
export * from './dir'
Loading
Loading