Skip to content

Commit

Permalink
make compilable
Browse files Browse the repository at this point in the history
  • Loading branch information
adrastaea committed Jan 8, 2025
1 parent 99ee95e commit 5a32f96
Show file tree
Hide file tree
Showing 14 changed files with 14,064 additions and 27,166 deletions.
41,115 changes: 13,995 additions & 27,120 deletions packages/backend/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@chainsafe/libp2p-noise": "file:../../3rd-party/js-libp2p-noise/dist/src",
"@chainsafe/libp2p-yamux": "7.0.1",
"@helia/block-brokers": "4.0.2",
"@helia/unixfs": "4.0.1",
"@helia/unixfs": "^4.0.1",
"@ipld/dag-cbor": "^9.2.1",
"@ipld/dag-pb": "^4.1.2",
"@libp2p/crypto": "^5.0.8",
Expand Down Expand Up @@ -127,6 +127,7 @@
"@quiet/logger": "^2.0.2-alpha.0",
"@quiet/types": "^2.0.2-alpha.1",
"abortable-iterator": "^3.0.0",
"base-x": "^5.0.0",
"blockstore-fs": "^2.0.2",
"blockstore-level": "^2.0.1",
"bs58": "^6.0.0",
Expand All @@ -146,7 +147,7 @@
"fetch-retry": "^6.0.0",
"get-port": "^5.1.1",
"go-ipfs": "npm:[email protected]",
"helia": "4.0.2",
"helia": "5.1.1",
"http-server": "^0.12.3",
"https-proxy-agent": "^7.0.5",
"image-size": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DownloadState, FileMetadata } from '@quiet/types'
import { DirResult } from 'tmp'
import waitForExpect from 'wait-for-expect'
import { TestModule } from '../common/test.module'
import { createTmpDir, libp2pInstanceParams } from '../common/utils'
import { createArbitraryFile, createTmpDir, libp2pInstanceParams } from '../common/utils'
import { IpfsModule } from '../ipfs/ipfs.module'
import { IpfsService } from '../ipfs/ipfs.service'
import { Libp2pModule } from '../libp2p/libp2p.module'
Expand All @@ -16,7 +16,6 @@ import { IpfsFileManagerModule } from './ipfs-file-manager.module'
import { IpfsFileManagerService } from './ipfs-file-manager.service'
import fs from 'fs'
import { createLogger } from '../common/logger'
import { createArbitraryFile } from '@quiet/common'

const logger = createLogger('bigFiles:test')
const BIG_FILE_SIZE = 2147483000
Expand Down
66 changes: 33 additions & 33 deletions packages/backend/src/nest/libp2p/libp2p.auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ISLA: This is what needs to be added to Quiet to make it work Libp2p and LFA work together
import { ComponentLogger, Connection, PeerId, PeerStore, Stream, Topology } from '@libp2p/interface'
import type { ConnectionManager, IncomingStreamData, Registrar } from '@libp2p/interface-internal'
// import type { ConnectionManager, IncomingStreamData, Registrar } from '@libp2p/interface-internal'
import * as Auth from '@localfirst/auth'
import { pushable, type Pushable } from 'it-pushable'
import { Uint8ArrayList } from 'uint8arraylist'
Expand All @@ -15,8 +15,8 @@ import { createQuietLogger } from '@quiet/logger'
export interface Libp2pAuthComponents {
peerId: PeerId
peerStore: PeerStore
registrar: Registrar
connectionManager: ConnectionManager
// registrar: Registrar
// connectionManager: ConnectionManager
logger: ComponentLogger
}

Expand All @@ -34,43 +34,43 @@ enum JoinStatus {
const createLFALogger = createQuietLogger('localfirst:')

export class Libp2pAuth {
private readonly protocol: string
private readonly components: Libp2pAuthComponents
private sigChainService: SigChainService
private authConnections: Record<string, Auth.Connection>
private outboundStreamQueue: Pushable<{ peerId: PeerId; connection: Connection }>
private outboundStreams: Record<string, PushableStream>
private inboundStreams: Record<string, Stream>
private restartableAuthConnections: Map<number, Auth.Connection>
private bufferedConnections: { peerId: PeerId; connection: Connection }[]
private events: QuietAuthEvents
private peerId: PeerId
private joining: boolean = false
private restartInterval: any
private unblockInterval: NodeJS.Timeout
private joinStatus: JoinStatus
private logger: ReturnType<typeof createLogger>
private authContext: Auth.Context
// private readonly protocol: string
// private readonly components: Libp2pAuthComponents
// private sigChainService: SigChainService
// private authConnections: Record<string, Auth.Connection>
// private outboundStreamQueue: Pushable<{ peerId: PeerId; connection: Connection }>
// private outboundStreams: Record<string, PushableStream>
// private inboundStreams: Record<string, Stream>
// private restartableAuthConnections: Map<number, Auth.Connection>
// private bufferedConnections: { peerId: PeerId; connection: Connection }[]
// private events: QuietAuthEvents
// private peerId: PeerId
// private joining: boolean = false
// private restartInterval: any
// private unblockInterval: NodeJS.Timeout
// private joinStatus: JoinStatus
// private logger: ReturnType<typeof createLogger>
// private authContext: Auth.Context

constructor(
peerId: PeerId,
sigChainService: SigChainService,
components: Libp2pAuthComponents,
events: QuietAuthEvents
) {
this.protocol = '/local-first-auth/1.0.0'
this.peerId = peerId
this.components = components
this.sigChainService = sigChainService
this.authConnections = {}
this.restartableAuthConnections = new Map()
this.outboundStreamQueue = pushable<{ peerId: PeerId; connection: Connection }>({ objectMode: true })
this.outboundStreams = {}
this.inboundStreams = {}
this.bufferedConnections = []
this.joinStatus = JoinStatus.PENDING
this.events = events
this.logger = createLogger(`libp2p:auth:${peerId}`)
// this.protocol = '/local-first-auth/1.0.0'
// this.peerId = peerId
// this.components = components
// this.sigChainService = sigChainService
// this.authConnections = {}
// this.restartableAuthConnections = new Map()
// this.outboundStreamQueue = pushable<{ peerId: PeerId; connection: Connection }>({ objectMode: true })
// this.outboundStreams = {}
// this.inboundStreams = {}
// this.bufferedConnections = []
// this.joinStatus = JoinStatus.PENDING
// this.events = events
// this.logger = createLogger(`libp2p:auth:${peerId}`)
}
}
// pipe(this.outboundStreamQueue, async source => {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/nest/libp2p/libp2p.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common'
import { Libp2pService } from './libp2p.service'
import { ProcessInChunksService } from './process-in-chunks.service'
import { SigChainService } from '../auth/sigchain.service'
import { SigChainModule } from '../auth/sigchain.service.module'

@Module({
imports: [SigChainService],
imports: [SigChainModule],
providers: [Libp2pService, ProcessInChunksService],
exports: [Libp2pService],
})
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/invitationLink/invitationLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ export const peerPairsToUrlParamString = (pairs: InvitationPair[]): string => {
const composeInvitationUrl = (baseUrl: string, data: InvitationDataV1 | InvitationDataV2): string => {
const url = new URL(baseUrl)

if (!data.version) data.version = InvitationDataVersion.v1

switch (data.version) {
case InvitationDataVersion.v1:
url.searchParams.append(PEER_ADDRESS_KEY, peerPairsToUrlParamString(data.pairs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { LeaveCommunityComponent } from './Tabs/LeaveCommunity/LeaveCommunityCom
import { Typography } from '@mui/material'
import { QRCodeComponent } from './Tabs/QRCode/QRCode.component'
import { composeInvitationShareUrl } from '@quiet/common'
import { InvitationDataVersion } from '@quiet/types'

const invitationLink = composeInvitationShareUrl({
version: InvitationDataVersion.v1,
pairs: [
{
peerId: '12D3KooWSZxWV6DmmTNf9sUgcTQqpN3CTuRiJFY4VthXr4yYxXxi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import React from 'react'
import { renderComponent } from '../../../../testUtils/renderComponent'
import { InviteComponent } from './Invite.component'
import { composeInvitationShareUrl } from '@quiet/common'
import { InvitationDataVersion } from '@quiet/types'

describe('CopyLink', () => {
it('renderComponent - hidden long link', () => {
const invitationLink = composeInvitationShareUrl({
version: InvitationDataVersion.v1,
pairs: [
{
peerId: '12D3KooWHgLdRMqkepNiYnrur21cyASUNk1f9NZ5tuGa9He8QXNa',
Expand Down Expand Up @@ -129,6 +131,7 @@ describe('CopyLink', () => {

it('renderComponent - revealed short link', () => {
const invitationLink = composeInvitationShareUrl({
version: InvitationDataVersion.v2,
pairs: [
{
peerId: '12D3KooWSYQf8zzr5rYnUdLxYyLzHruQHPaMssja1ADifGAcN3qY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'
import { withTheme } from '../../../../storybook/decorators'
import { InviteComponent, InviteComponentProps } from './Invite.component'
import { composeInvitationShareUrl } from '@quiet/common'
import { InvitationDataVersion } from '@quiet/types'

const Template: ComponentStory<typeof InviteComponent> = args => {
return <InviteComponent {...args} />
Expand All @@ -11,6 +12,7 @@ const Template: ComponentStory<typeof InviteComponent> = args => {
export const Component = Template.bind({})
let revealInputValue = true
const invitationLink = composeInvitationShareUrl({
version: InvitationDataVersion.v1,
pairs: [
{
peerId: '12D3KooWHgLdRMqkepNiYnrur21cyASUNk1f9NZ5tuGa9He8QXNa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'
import { withTheme } from '../../../../storybook/decorators'
import QRCodeComponent, { QRCodeProps } from './QRCode.component'
import { composeInvitationShareUrl } from '@quiet/common'
import { InvitationDataVersion } from '@quiet/types'

const invitationLink = composeInvitationShareUrl({
version: InvitationDataVersion.v1,
pairs: [
{
peerId: '12D3KooWHgLdRMqkepNiYnrur21cyASUNk1f9NZ5tuGa9He8QXNa',
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop/src/rtl-tests/community.join.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
InitUserCsrPayload,
PeerId,
UserCsr,
InvitationDataVersion,
} from '@quiet/types'
import { composeInvitationShareUrl } from '@quiet/common'

Expand All @@ -49,6 +50,7 @@ jest.setTimeout(20_000)
describe('User', () => {
let socket: MockedSocket
const validData: InvitationData = {
version: InvitationDataVersion.v1,
pairs: [
{
onionAddress: 'y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd',
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop/src/rtl-tests/customProtocol.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { modalsActions } from '../renderer/sagas/modals/modals.slice'
import { ModalName } from '../renderer/sagas/modals/modals.types'
import JoinCommunity from '../renderer/components/CreateJoinCommunity/JoinCommunity/JoinCommunity'
import CreateUsername from '../renderer/components/CreateUsername/CreateUsername'
import { type Community, type InvitationData } from '@quiet/types'
import { InvitationDataVersion, type Community, type InvitationData } from '@quiet/types'
import { composeInvitationDeepUrl } from '@quiet/common'

jest.setTimeout(20_000)
Expand Down Expand Up @@ -59,6 +59,7 @@ describe('Opening app through custom protocol', () => {
)

const invitationCodes: InvitationData = {
version: InvitationDataVersion.v1,
pairs: [{ peerId: 'abcdef', onionAddress: 'bidrmzr3ee6qa2vvrlcnqvvvsk2gmjktcqkunba326parszr44gibwyd' }],
psk: '12345',
ownerOrbitDbIdentity: 'testOwnerOrbitDbIdentity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { initActions } from '../init.slice'
import { navigationActions } from '../../navigation/navigation.slice'
import { ScreenNames } from '../../../const/ScreenNames.enum'
import { deepLinkSaga } from './deepLink.saga'
import { type Community, CommunityOwnership, InvitationData, CreateNetworkPayload } from '@quiet/types'
import {
type Community,
CommunityOwnership,
InvitationData,
CreateNetworkPayload,
InvitationDataVersion,
} from '@quiet/types'
import { composeInvitationShareUrl, getValidInvitationUrlTestData, validInvitationDatav1 } from '@quiet/common'
import { FactoryGirl } from 'factory-girl'

Expand Down Expand Up @@ -138,6 +144,7 @@ describe('deepLinkSaga', () => {

test('displays error if invitation code is invalid', async () => {
const invalidData: InvitationData = {
version: InvitationDataVersion.v1,
pairs: [
{
onionAddress: 'y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { all, takeEvery, fork, cancelled } from 'typed-redux-saga'
import { all, fork, cancelled, takeEvery } from 'typed-redux-saga'

import { uptimeSaga } from './uptime/uptime.saga'
import { type Socket } from '../../types'
import { createInviteSaga } from './invite/createInvite.saga'
import { connectionActions } from './connection.slice'
import { createLogger } from '../../utils/logger'
import { onConnectionProcessInfo } from './onConnectionProcessInfo/onConnectionProcessInfo.saga'
import { Socket } from '../../types'

const logger = createLogger('connectionMasterSaga')

export function* connectionMasterSaga(socket: Socket): Generator {
logger.info('connectionMasterSaga starting')
try {
yield all([fork(uptimeSaga), takeEvery(connectionActions.onConnectionProcessInfo.type, onConnectionProcessInfo)])
yield all([
fork(uptimeSaga),
takeEvery(connectionActions.onConnectionProcessInfo.type, onConnectionProcessInfo),
takeEvery(connectionActions.createInvite.type, createInviteSaga, socket),
])
} finally {
logger.info('connectionMasterSaga stopping')
if (yield cancelled()) {
Expand Down

0 comments on commit 5a32f96

Please sign in to comment.