Skip to content

Commit

Permalink
feat: enable V3 group chat in production
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jun 16, 2024
1 parent 29f843b commit 55f0a93
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
12 changes: 6 additions & 6 deletions example/src/LaunchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default function LaunchScreen(
console.log(
'Using network ' +
selectedNetwork +
' and enableAlphaMLS ' +
' and enableV3 ' +
enableGroups
)

Expand All @@ -224,7 +224,7 @@ export default function LaunchScreen(
appVersion,
preCreateIdentityCallback,
preEnableIdentityCallback,
enableAlphaMls: enableGroups === 'true',
enableV3: enableGroups === 'true',
dbEncryptionKey,
})
)
Expand All @@ -243,7 +243,7 @@ export default function LaunchScreen(
console.log(
'Using network ' +
selectedNetwork +
' and enableAlphaMLS ' +
' and enableV3 ' +
enableGroups
)
const dbEncryptionKey = await getDbEncryptionKey(
Expand All @@ -258,7 +258,7 @@ export default function LaunchScreen(
codecs: supportedCodecs,
preCreateIdentityCallback,
preEnableIdentityCallback,
enableAlphaMls: enableGroups === 'true',
enableV3: enableGroups === 'true',
dbEncryptionKey,
})
)
Expand All @@ -277,7 +277,7 @@ export default function LaunchScreen(
console.log(
'Using network ' +
selectedNetwork +
' and enableAlphaMLS ' +
' and enableV3 ' +
enableGroups
)
const dbEncryptionKey =
Expand All @@ -288,7 +288,7 @@ export default function LaunchScreen(
env: selectedNetwork,
appVersion,
codecs: supportedCodecs,
enableAlphaMls: enableGroups === 'true',
enableV3: enableGroups === 'true',
dbEncryptionKey,
})
)
Expand Down
26 changes: 13 additions & 13 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('can make a MLS V3 client', async () => {
const client = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
})

return true
Expand All @@ -52,7 +52,7 @@ test('can delete a local database', async () => {
client = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: new Uint8Array([
233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64,
166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135,
Expand Down Expand Up @@ -85,15 +85,15 @@ test('can make a MLS V3 client with encryption key and database directory', asyn
const client = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
dbDirectory: dbDirPath,
})

const anotherClient = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})

Expand All @@ -109,7 +109,7 @@ test('can make a MLS V3 client with encryption key and database directory', asyn
const clientFromBundle = await Client.createFromKeyBundle(bundle, {
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
dbDirectory: dbDirPath,
})
Expand Down Expand Up @@ -162,14 +162,14 @@ test('can make a MLS V3 client from bundle', async () => {
const client = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})

const anotherClient = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})

Expand All @@ -184,7 +184,7 @@ test('can make a MLS V3 client from bundle', async () => {
const client2 = await Client.createFromKeyBundle(bundle, {
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})

Expand All @@ -206,7 +206,7 @@ test('can make a MLS V3 client from bundle', async () => {
const randomClient = await Client.createRandom({
env: 'local',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})

Expand All @@ -230,7 +230,7 @@ test('production MLS V3 client creation throws error', async () => {
await Client.createRandom({
env: 'production',
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: key,
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -1661,11 +1661,11 @@ test('can read and update group name', async () => {

// Commenting this out so it doesn't block people, but nice to have?
// test('can stream messages for a long time', async () => {
// const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
// const bo = await Client.createRandom({ env: 'local', enableV3: true })
// await delayToPropogate()
// const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
// const alix = await Client.createRandom({ env: 'local', enableV3: true })
// await delayToPropogate()
// const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
// const caro = await Client.createRandom({ env: 'local', enableV3: true })
// await delayToPropogate()

// // Setup stream alls
Expand Down
2 changes: 1 addition & 1 deletion example/src/tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function createClients(
clients.push(
await Client.createRandom({
env: 'local',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: keyBytes,
})
)
Expand Down
4 changes: 2 additions & 2 deletions example/src/tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ test('canMessage', async () => {

const caro = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: keyBytes,
})
const chux = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
enableV3: true,
dbEncryptionKey: keyBytes,
})

Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function auth(
appVersion?: string | undefined,
hasCreateIdentityCallback?: boolean | undefined,
hasEnableIdentityCallback?: boolean | undefined,
enableAlphaMls?: boolean | undefined,
enableV3?: boolean | undefined,
dbEncryptionKey?: Uint8Array | undefined,
dbDirectory?: string | undefined
) {
Expand All @@ -74,7 +74,7 @@ export async function auth(
appVersion,
hasCreateIdentityCallback,
hasEnableIdentityCallback,
enableAlphaMls,
enableV3,
dbEncryptionKey ? Array.from(dbEncryptionKey) : undefined,
dbDirectory
)
Expand All @@ -89,7 +89,7 @@ export async function createRandom(
appVersion?: string | undefined,
hasCreateIdentityCallback?: boolean | undefined,
hasEnableIdentityCallback?: boolean | undefined,
enableAlphaMls?: boolean | undefined,
enableV3?: boolean | undefined,
dbEncryptionKey?: Uint8Array | undefined,
dbDirectory?: string | undefined
): Promise<string> {
Expand All @@ -98,7 +98,7 @@ export async function createRandom(
appVersion,
hasCreateIdentityCallback,
hasEnableIdentityCallback,
enableAlphaMls,
enableV3,
dbEncryptionKey ? Array.from(dbEncryptionKey) : undefined,
dbDirectory
)
Expand All @@ -108,15 +108,15 @@ export async function createFromKeyBundle(
keyBundle: string,
environment: 'local' | 'dev' | 'production',
appVersion?: string | undefined,
enableAlphaMls?: boolean | undefined,
enableV3?: boolean | undefined,
dbEncryptionKey?: Uint8Array | undefined,
dbDirectory?: string | undefined
): Promise<string> {
return await XMTPModule.createFromKeyBundle(
keyBundle,
environment,
appVersion,
enableAlphaMls,
enableV3,
dbEncryptionKey ? Array.from(dbEncryptionKey) : undefined,
dbDirectory
)
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Client<
options.appVersion,
Boolean(createSubscription),
Boolean(enableSubscription),
Boolean(options.enableAlphaMls),
Boolean(options.enableV3),
options.dbEncryptionKey,
options.dbDirectory
)
Expand Down Expand Up @@ -161,7 +161,7 @@ export class Client<
options.appVersion,
Boolean(createSubscription),
Boolean(enableSubscription),
Boolean(options.enableAlphaMls),
Boolean(options.enableV3),
options.dbEncryptionKey,
options.dbDirectory
)
Expand Down Expand Up @@ -197,7 +197,7 @@ export class Client<
keyBundle,
options.env,
options.appVersion,
Boolean(options.enableAlphaMls),
Boolean(options.enableV3),
options.dbEncryptionKey,
options.dbDirectory
)
Expand Down Expand Up @@ -483,7 +483,7 @@ export type ClientOptions = {
/**
* Specify whether to enable Alpha version of MLS (Group Chat)
*/
enableAlphaMls?: boolean
enableV3?: boolean
/**
* OPTIONAL specify the encryption key for the database. The encryption key must be exactly 32 bytes.
*/
Expand All @@ -507,7 +507,7 @@ export type KeyType = {
export function defaultOptions(opts?: Partial<ClientOptions>): ClientOptions {
const _defaultOptions: ClientOptions = {
env: 'dev',
enableAlphaMls: false,
enableV3: false,
dbEncryptionKey: undefined,
dbDirectory: undefined,
}
Expand Down

0 comments on commit 55f0a93

Please sign in to comment.