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 206c19740d..464700db5e 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.ts @@ -39,6 +39,7 @@ import { SaveCSRPayload, SendCertificatesResponse, SendMessagePayload, + ServerInvitationData, SocketActionTypes, UploadFilePayload, type DeleteChannelResponse, @@ -392,7 +393,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI return community } - public async downloadCommunityData(inviteData: any) { + public async downloadCommunityData(inviteData: ServerInvitationData) { this.logger('Downloading invite data', inviteData) this.storageServerProxyService.setServerAddress(inviteData.serverAddress) let downloadedData: ServerStoredCommunityMetadata @@ -422,7 +423,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI const downloadedData = await this.downloadCommunityData(inviteData) if (!downloadedData) { emitError(this.serverIoProvider.io, { - type: SocketActionTypes.DOWNLOAD_INVITE_DATA, + type: SocketActionTypes.LAUNCH_COMMUNITY, message: ErrorMessages.STORAGE_SERVER_CONNECTION_FAILED, }) return @@ -664,33 +665,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI await this.storageService?.saveCSR(payload) }) - this.socketService.on( - SocketActionTypes.DOWNLOAD_INVITE_DATA, - async (payload: { cid: string; serverAddress: string }, callback: (response: CreateNetworkPayload) => void) => { - this.logger(`socketService - ${SocketActionTypes.DOWNLOAD_INVITE_DATA}`) - this.storageServerProxyService.setServerAddress(payload.serverAddress) - let downloadedData: ServerStoredCommunityMetadata - try { - downloadedData = await this.storageServerProxyService.downloadData(payload.cid) - } catch (e) { - this.logger.error(`Downloading community data failed`, e) - emitError(this.serverIoProvider.io, { - type: SocketActionTypes.DOWNLOAD_INVITE_DATA, - message: ErrorMessages.STORAGE_SERVER_CONNECTION_FAILED, - }) - return - } - - const createNetworkPayload: CreateNetworkPayload = { - ownership: CommunityOwnership.User, - peers: p2pAddressesToPairs(downloadedData.peerList), - psk: downloadedData.psk, - ownerOrbitDbIdentity: downloadedData.ownerOrbitDbIdentity, - } - callback(createNetworkPayload) - } - ) - // Public Channels this.socketService.on( SocketActionTypes.CREATE_CHANNEL, diff --git a/packages/backend/src/nest/socket/socket.service.ts b/packages/backend/src/nest/socket/socket.service.ts index 1f61e201c3..124cef2d07 100644 --- a/packages/backend/src/nest/socket/socket.service.ts +++ b/packages/backend/src/nest/socket/socket.service.ts @@ -170,14 +170,6 @@ export class SocketService extends EventEmitter implements OnModuleInit { } ) - socket.on( - SocketActionTypes.DOWNLOAD_INVITE_DATA, - async (payload: { serverAddress: string; cid: string }, callback: (response: CreateNetworkPayload) => void) => { - console.log('SOCKET Downloading invite data', payload) - this.emit(SocketActionTypes.DOWNLOAD_INVITE_DATA, payload, callback) - } - ) - socket.on(SocketActionTypes.LEAVE_COMMUNITY, async () => { this.logger('Leaving community') this.emit(SocketActionTypes.LEAVE_COMMUNITY) diff --git a/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.test.ts b/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.test.ts index c97078e808..af07e61279 100644 --- a/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.test.ts +++ b/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.test.ts @@ -34,27 +34,34 @@ describe('Handle invitation code', () => { }) it('joins network if code is valid', async () => { + const createNetworkPayload: CreateNetworkPayload = { + ownership: CommunityOwnership.User, + inviteData: validInvitationData, + } await expectSaga(customProtocolSaga, communities.actions.customProtocol([validInvitationDeepUrl])) .withState(store.getState()) - .put(communities.actions.joinNetwork(validInvitationData)) + .put(communities.actions.createNetwork(createNetworkPayload)) .run() }) it('joins network if v2 code is valid', async () => { const validInvitationData = getValidInvitationUrlTestData(validInvitationDatav2[0]).data const validInvitationDeepUrl = getValidInvitationUrlTestData(validInvitationDatav2[0]).deepUrl() + const createNetworkPayload: CreateNetworkPayload = { + ownership: CommunityOwnership.User, + inviteData: validInvitationData, + } await expectSaga(customProtocolSaga, communities.actions.customProtocol([validInvitationDeepUrl])) .withState(store.getState()) - .put(communities.actions.joinNetwork(validInvitationData)) + .put(communities.actions.createNetwork(createNetworkPayload)) .run() }) it('does not try to create network if user is already in community', async () => { community = await factory.create['payload']>('Community') - const payload: CreateNetworkPayload = { + const createNetworkPayload: CreateNetworkPayload = { ownership: CommunityOwnership.User, - peers: validInvitationData.pairs, - psk: validInvitationData.psk, + inviteData: validInvitationData, } await expectSaga(customProtocolSaga, communities.actions.customProtocol([validInvitationDeepUrl])) @@ -68,14 +75,14 @@ describe('Handle invitation code', () => { }, }) ) - .not.put(communities.actions.createNetwork(payload)) + .not.put(communities.actions.createNetwork(createNetworkPayload)) .run() }) - it('does not try to create network if code is missing psk', async () => { - const payload: CreateNetworkPayload = { + it('does not try to create network if code is missing data', async () => { + const createNetworkPayload: CreateNetworkPayload = { ownership: CommunityOwnership.User, - peers: [], + inviteData: validInvitationData, } await expectSaga( @@ -93,34 +100,7 @@ describe('Handle invitation code', () => { }, }) ) - .not.put(communities.actions.createNetwork(payload)) - .run() - }) - - it('does not try to create network if code is missing psk', async () => { - const payload: CreateNetworkPayload = { - ownership: CommunityOwnership.User, - peers: [], - } - - await expectSaga( - customProtocolSaga, - communities.actions.customProtocol([ - 'quiet://?QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE=y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd', - ]) - ) - .withState(store.getState()) - .put(communities.actions.clearInvitationCodes()) - .put( - modalsActions.openModal({ - name: ModalName.warningModal, - args: { - title: 'Invalid link', - subtitle: 'The invite link you received is not valid. Please check it and try again.', - }, - }) - ) - .not.put(communities.actions.createNetwork(payload)) + .not.put(communities.actions.createNetwork(createNetworkPayload)) .run() }) }) diff --git a/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.ts b/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.ts index 5bbf2053c1..86790dca10 100644 --- a/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.ts +++ b/packages/desktop/src/renderer/sagas/invitation/customProtocol.saga.ts @@ -108,6 +108,4 @@ export function* customProtocolSaga( } yield* put(communities.actions.createNetwork(payload)) - - // yield* put(communities.actions.joinNetwork(data)) } diff --git a/packages/desktop/src/rtl-tests/deep.linking.test.tsx b/packages/desktop/src/rtl-tests/deep.linking.test.tsx index 983523353e..53dce50d59 100644 --- a/packages/desktop/src/rtl-tests/deep.linking.test.tsx +++ b/packages/desktop/src/rtl-tests/deep.linking.test.tsx @@ -54,11 +54,10 @@ describe('Deep linking', () => { expect(actions).toMatchInlineSnapshot(` Array [ "Communities/customProtocol", - "Communities/joinNetwork", "Communities/createNetwork", + "Communities/setInvitationCodes", "Communities/addNewCommunity", "Communities/setCurrentCommunity", - "Communities/setInvitationCodes", "Communities/customProtocol", ] `) diff --git a/packages/mobile/src/store/init/deepLink/deepLink.saga.test.ts b/packages/mobile/src/store/init/deepLink/deepLink.saga.test.ts index a74e6f8eb2..8ea6a65a18 100644 --- a/packages/mobile/src/store/init/deepLink/deepLink.saga.test.ts +++ b/packages/mobile/src/store/init/deepLink/deepLink.saga.test.ts @@ -8,7 +8,14 @@ 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, type Identity, InvitationData, InvitationDataVersion } from '@quiet/types' +import { + type Community, + CommunityOwnership, + type Identity, + InvitationData, + InvitationDataVersion, + CreateNetworkPayload, +} from '@quiet/types' import { composeInvitationShareUrl, validInvitationCodeTestData, @@ -58,17 +65,16 @@ describe('deepLinkSaga', () => { socketIOSecret: 'secret', }) ) + const createNetworkPayload: CreateNetworkPayload = { + ownership: CommunityOwnership.User, + inviteData: validData, + } const reducer = combineReducers(reducers) await expectSaga(deepLinkSaga, initActions.deepLink(validCode)) .withReducer(reducer) .withState(store.getState()) .put(initActions.resetDeepLink()) - .put( - communities.actions.joinNetwork({ - version: InvitationDataVersion.v1, - ...validData, - }) - ) + .put(communities.actions.createNetwork(createNetworkPayload)) .put( navigationActions.replaceScreen({ screen: ScreenNames.UsernameRegistrationScreen, @@ -109,9 +115,7 @@ describe('deepLinkSaga', () => { .not.put( communities.actions.createNetwork({ ownership: CommunityOwnership.User, - peers: validData.pairs, - psk: validData.psk, - ownerOrbitDbIdentity: validData.ownerOrbitDbIdentity, + inviteData: validData, }) ) .run() @@ -127,6 +131,11 @@ describe('deepLinkSaga', () => { community.psk = validData.psk + const createNetworkPayload: CreateNetworkPayload = { + ownership: CommunityOwnership.User, + inviteData: validData, + } + store.dispatch(communities.actions.addNewCommunity(community)) store.dispatch(communities.actions.setCurrentCommunity(community.id)) @@ -149,11 +158,8 @@ describe('deepLinkSaga', () => { }) .put.like({ action: { - type: communities.actions.joinNetwork.type, - payload: { - version: InvitationDataVersion.v1, - ...validData, - }, + type: communities.actions.createNetwork.type, + payload: createNetworkPayload, }, }) .run() @@ -170,6 +176,10 @@ describe('deepLinkSaga', () => { psk: 'BNlxfE=', ownerOrbitDbIdentity: 'testId', } + const createNetworkPayload: CreateNetworkPayload = { + ownership: CommunityOwnership.User, + inviteData: invalidData, + } const invalidCode = composeInvitationShareUrl(invalidData) store.dispatch( initActions.setWebsocketConnected({ @@ -193,12 +203,7 @@ describe('deepLinkSaga', () => { }, }, }) - .not.put( - communities.actions.joinNetwork({ - version: InvitationDataVersion.v1, - ...validData, - }) - ) + .not.put(communities.actions.createNetwork(createNetworkPayload)) .run() }) }) diff --git a/packages/state-manager/src/sagas/communities/communities.master.saga.ts b/packages/state-manager/src/sagas/communities/communities.master.saga.ts index e904dd16ad..c5e1e1a275 100644 --- a/packages/state-manager/src/sagas/communities/communities.master.saga.ts +++ b/packages/state-manager/src/sagas/communities/communities.master.saga.ts @@ -5,12 +5,10 @@ import { connectionActions } from '../appConnection/connection.slice' import { createCommunitySaga } from './createCommunity/createCommunity.saga' import { initCommunities, launchCommunitySaga } from './launchCommunity/launchCommunity.saga' import { createNetworkSaga } from './createNetwork/createNetwork.saga' -import { joinNetworkSaga } from './joinNetwork/joinNetwork.saga' export function* communitiesMasterSaga(socket: Socket): Generator { yield all([ takeEvery(communitiesActions.createNetwork.type, createNetworkSaga, socket), - takeEvery(communitiesActions.joinNetwork.type, joinNetworkSaga, socket), takeEvery(connectionActions.torBootstrapped.type, initCommunities), takeEvery(communitiesActions.createCommunity.type, createCommunitySaga, socket), takeEvery(communitiesActions.launchCommunity.type, launchCommunitySaga, socket), diff --git a/packages/state-manager/src/sagas/communities/communities.slice.ts b/packages/state-manager/src/sagas/communities/communities.slice.ts index 228ef912fb..1697270574 100644 --- a/packages/state-manager/src/sagas/communities/communities.slice.ts +++ b/packages/state-manager/src/sagas/communities/communities.slice.ts @@ -36,7 +36,6 @@ export const communitiesSlice = createSlice({ }) }, createNetwork: (state, _action: PayloadAction) => state, - joinNetwork: (state, _action: PayloadAction) => state, resetApp: (state, _action) => state, createCommunity: (state, _action: PayloadAction) => state, launchCommunity: (state, _action: PayloadAction) => state, diff --git a/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.test.ts b/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.test.ts index 301db9617c..6c4f4c2a26 100644 --- a/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.test.ts +++ b/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.test.ts @@ -8,11 +8,18 @@ import { createRootCA, setupCrypto } from '@quiet/identity' import { reducers } from '../../reducers' import { createNetworkSaga } from './createNetwork.saga' import { generateId } from '../../../utils/cryptography/cryptography' -import { type Community, CommunityOwnership } from '@quiet/types' +import { + type Community, + CommunityOwnership, + InvitationDataV1, + InvitationDataVersion, + InvitationDataV2, +} from '@quiet/types' import { Socket } from '../../../types' +import { validInvitationDatav1, validInvitationDatav2 } from '@quiet/common' describe('createNetwork', () => { - it('create network for joining user', async () => { + it('create network for joining user with v1 invitation link', async () => { setupCrypto() const socket = { @@ -32,14 +39,68 @@ describe('createNetwork', () => { rootCa: undefined, } + const inviteData: InvitationDataV1 = validInvitationDatav1[0] + inviteData.version = InvitationDataVersion.v1 + const savedCommunity: Community = { + ...community, + psk: inviteData.psk, + ownerOrbitDbIdentity: inviteData.ownerOrbitDbIdentity, + } + + const reducer = combineReducers(reducers) + await expectSaga( + createNetworkSaga, + socket, + communitiesActions.createNetwork({ + ownership: CommunityOwnership.User, + inviteData, + }) + ) + .withReducer(reducer) + .withState(store.getState()) + .provide([[call.fn(generateId), community.id]]) + .not.call(createRootCA) + .call(generateId) + .put(communitiesActions.setInvitationCodes(inviteData.pairs)) + .put(communitiesActions.addNewCommunity(savedCommunity)) + .put(communitiesActions.setCurrentCommunity(community.id)) + .run() + }) + + it('create network for joining user with v2 invitation link', async () => { + setupCrypto() + + const socket = { + emit: jest.fn(), + emitWithAck: jest.fn(() => { + return {} + }), + on: jest.fn(), + } as unknown as Socket + + const store = prepareStore().store + + const community: Community = { + id: '1', + name: undefined, + CA: null, + rootCa: undefined, + } + + const inviteData: InvitationDataV2 = validInvitationDatav2[0] + + const savedCommunity: Community = { + ...community, + inviteData, + } + const reducer = combineReducers(reducers) await expectSaga( createNetworkSaga, socket, communitiesActions.createNetwork({ ownership: CommunityOwnership.User, - peers: [{ peerId: 'peerId', onionAddress: 'address' }], - psk: '12345', + inviteData, }) ) .withReducer(reducer) @@ -47,6 +108,8 @@ describe('createNetwork', () => { .provide([[call.fn(generateId), community.id]]) .not.call(createRootCA) .call(generateId) + .put(communitiesActions.addNewCommunity(savedCommunity)) + .put(communitiesActions.setCurrentCommunity(community.id)) .run() }) @@ -82,7 +145,6 @@ describe('createNetwork', () => { communitiesActions.createNetwork({ ownership: CommunityOwnership.Owner, name: 'rockets', - psk: '12345', }) ) .withReducer(reducer) @@ -98,6 +160,8 @@ describe('createNetwork', () => { 'rockets' ) .call(generateId) + .put(communitiesActions.addNewCommunity(community)) + .put(communitiesActions.setCurrentCommunity(community.id)) .run() }) }) diff --git a/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.ts b/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.ts index 181c360eaa..6205ee573b 100644 --- a/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.ts +++ b/packages/state-manager/src/sagas/communities/createNetwork/createNetwork.saga.ts @@ -19,6 +19,7 @@ export function* createNetworkSaga( socket: Socket, action: PayloadAction['payload']> ) { + // TODO: remove psk and orbitDbIdentity from payload and leave invitationData? Remove redundancy const payload = action.payload console.log('create network saga', payload) // Community IDs are only local identifiers @@ -53,29 +54,29 @@ export function* createNetworkSaga( name: payload.name, CA, rootCa: CA?.rootCertString, - psk: payload.psk, - ownerOrbitDbIdentity: action.payload.ownerOrbitDbIdentity, } if (payload.inviteData) { switch (payload.inviteData.version) { - case InvitationDataVersion.v2: - community.inviteData = { - serverAddress: payload.inviteData.serverAddress, - cid: payload.inviteData.cid, - token: payload.inviteData.token, + case InvitationDataVersion.v1: + community.psk = payload.inviteData.psk + community.ownerOrbitDbIdentity = payload.inviteData.ownerOrbitDbIdentity + const invitationPeers = payload.inviteData.pairs + if (invitationPeers) { + yield* put(communitiesActions.setInvitationCodes(invitationPeers)) } + break + case InvitationDataVersion.v2: + community.inviteData = payload.inviteData + break } } + console.log('SETTING COMMUNITY', community) + yield* put(communitiesActions.addNewCommunity(community)) yield* put(communitiesActions.setCurrentCommunity(id)) - const invitationPeers = action.payload.peers - if (invitationPeers) { - yield* put(communitiesActions.setInvitationCodes(invitationPeers)) - } - // Identities are tied to communities for now const identity: Identity = { id: community.id, diff --git a/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.test.ts b/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.test.ts deleted file mode 100644 index 151d16cf0b..0000000000 --- a/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { getValidInvitationUrlTestData, validInvitationDatav1 } from '@quiet/common' -import { CommunityOwnership, CreateNetworkPayload, InvitationDataV1 } from '@quiet/types' -import { FactoryGirl } from 'factory-girl' -import { expectSaga } from 'redux-saga-test-plan' -import { Socket } from '../../../types' -import { getFactory } from '../../../utils/tests/factories' -import { prepareStore } from '../../../utils/tests/prepareStore' -import { Store } from '../../store.types' -import { communitiesActions } from '../communities.slice' -import { joinNetworkSaga } from './joinNetwork.saga' - -describe('Join network saga', () => { - let store: Store - let factory: FactoryGirl - let validInvitationData: InvitationDataV1 - let validInvitationDeepUrl: string - const socket = { - emit: jest.fn(), - emitWithAck: jest.fn(() => { - return {} - }), - on: jest.fn(), - } as unknown as Socket - - beforeEach(async () => { - store = prepareStore().store - factory = await getFactory(store) - - validInvitationData = getValidInvitationUrlTestData(validInvitationDatav1[0]).data - validInvitationDeepUrl = getValidInvitationUrlTestData(validInvitationDatav1[0]).deepUrl() - }) - - it('creates network for v1 invitation data', async () => { - const payload: CreateNetworkPayload = { - ownership: CommunityOwnership.User, - peers: validInvitationData.pairs, - psk: validInvitationData.psk, - ownerOrbitDbIdentity: validInvitationData.ownerOrbitDbIdentity, - } - await expectSaga(joinNetworkSaga, socket, communitiesActions.joinNetwork(validInvitationData)) - .withState(store.getState()) - .put(communitiesActions.createNetwork(payload)) - .run() - }) -}) diff --git a/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.ts b/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.ts deleted file mode 100644 index 53cb44b3b8..0000000000 --- a/packages/state-manager/src/sagas/communities/joinNetwork/joinNetwork.saga.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { CommunityOwnership, CreateNetworkPayload, InvitationDataVersion, SocketActionTypes } from '@quiet/types' -import { PayloadAction } from '@reduxjs/toolkit' -import { apply, put } from 'typed-redux-saga' -import { Socket, applyEmitParams } from '../../../types' -import { communitiesActions } from '../communities.slice' - -export function* joinNetworkSaga( - socket: Socket, - action: PayloadAction['payload']> -) { - console.log('join network saga', action.payload) - const data = action.payload - let payload: CreateNetworkPayload - - data.version = data.version || InvitationDataVersion.v1 - switch (data.version) { - case InvitationDataVersion.v1: - console.log('join network saga invitation data v1') - payload = { - ownership: CommunityOwnership.User, - peers: data.pairs, - psk: data.psk, - ownerOrbitDbIdentity: data.ownerOrbitDbIdentity, - } - break - case InvitationDataVersion.v2: - console.log('join network saga invitation data v2') - const response: CreateNetworkPayload = yield* apply( - socket, - socket.emitWithAck, - applyEmitParams(SocketActionTypes.DOWNLOAD_INVITE_DATA, { - serverAddress: data.serverAddress, - cid: data.cid, - }) - ) - payload = { - ownership: CommunityOwnership.User, - peers: response.peers, - psk: response.psk, - ownerOrbitDbIdentity: response.ownerOrbitDbIdentity, - } - break - } - - console.log('join network saga payload', payload) - yield* put(communitiesActions.createNetwork(payload)) -} diff --git a/packages/state-manager/src/sagas/communities/launchCommunity/launchCommunity.saga.ts b/packages/state-manager/src/sagas/communities/launchCommunity/launchCommunity.saga.ts index 9260ded78c..f1cc551089 100644 --- a/packages/state-manager/src/sagas/communities/launchCommunity/launchCommunity.saga.ts +++ b/packages/state-manager/src/sagas/communities/launchCommunity/launchCommunity.saga.ts @@ -46,6 +46,7 @@ export function* launchCommunitySaga( } const invitationCodes = yield* select(communitiesSelectors.invitationCodes) + console.log('!! ! ! !Current invitation codes', invitationCodes) let peerList: string[] = [] if (invitationCodes) { diff --git a/packages/types/src/community.ts b/packages/types/src/community.ts index 7c5441e951..bbe8e54481 100644 --- a/packages/types/src/community.ts +++ b/packages/types/src/community.ts @@ -1,5 +1,5 @@ import { type HiddenService, type PeerId, type Identity, type UserCsr } from './identity' -import { InvitationData, InvitationPair } from './network' +import { InvitationData, InvitationDataV2, InvitationPair } from './network' export interface Community { id: string @@ -13,11 +13,7 @@ export interface Community { onionAddress?: string ownerCertificate?: string psk?: string - inviteData?: { - serverAddress: string - cid: string - token?: string - } + inviteData?: InvitationDataV2 ownerOrbitDbIdentity?: string } @@ -29,12 +25,18 @@ export enum CommunityOwnership { export interface CreateNetworkPayload { ownership: CommunityOwnership name?: string - peers?: InvitationPair[] - psk?: string - ownerOrbitDbIdentity?: string + // peers?: InvitationPair[] + // psk?: string + // ownerOrbitDbIdentity?: string inviteData?: InvitationData } +export interface ServerInvitationData { + serverAddress: string + cid: string + token?: string +} + export interface NetworkInfo { hiddenService: HiddenService peerId: PeerId @@ -47,6 +49,8 @@ export interface Certificates { } export interface InitCommunityPayload { + // Used for both joining and creating community + // Remove redundancy and pass data in inviteData? id: string name?: string peerId: PeerId @@ -60,11 +64,7 @@ export interface InitCommunityPayload { psk?: string ownerOrbitDbIdentity?: string ownerCsr?: UserCsr - inviteData?: { - serverAddress: string - cid: string - token?: string - } + inviteData?: ServerInvitationData } export interface StorePeerListPayload {