diff --git a/example/src/tests.ts b/example/src/tests.ts index 1ce1864ea..5b5126991 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -102,9 +102,60 @@ test('can make a MLS V3 client', async () => { const client = await Client.createRandom({ env: 'local', appVersion: 'Testing/0.0.0', - enableAlphaMls: true + enableAlphaMls: true, + }) + + return true +}) + +test('can make a MLS V3 client from bundle', async () => { + const client = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, }) + const anotherClient = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + }) + + const group1 = await client.conversations.newGroup([anotherClient.address]) + + if (group1.clientAddress !== client.address) { + throw new Error( + `clients dont match ${client.address} and ${group1.clientAddress}` + ) + } + const bundle = await client.exportKeyBundle() + + const client2 = await Client.createFromKeyBundle(bundle, { + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + }) + + if (client.address !== client2.address) { + throw new Error( + `clients dont match ${client2.address} and ${client.address}` + ) + } + + const randomClient = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + }) + + const group = await client2.conversations.newGroup([randomClient.address]) + + if (group.clientAddress !== client2.address) { + throw new Error( + `clients dont match ${client2.address} and ${group.clientAddress}` + ) + } + return true }) diff --git a/src/index.ts b/src/index.ts index 9c2ae0691..c0914276a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,12 +71,14 @@ export async function createRandom( export async function createFromKeyBundle( keyBundle: string, environment: 'local' | 'dev' | 'production', - appVersion?: string | undefined + appVersion?: string | undefined, + enableAlphaMls?: boolean | undefined ): Promise { return await XMTPModule.createFromKeyBundle( keyBundle, environment, - appVersion + appVersion, + enableAlphaMls ) } diff --git a/src/lib/Client.ts b/src/lib/Client.ts index ce0d64ea7..8bba98221 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -186,7 +186,8 @@ export class Client { const address = await XMTPModule.createFromKeyBundle( keyBundle, options.env, - options.appVersion + options.appVersion, + Boolean(options.enableAlphaMls) ) return new Client(address, opts?.codecs || []) }