diff --git a/android/build.gradle b/android/build.gradle index 9a50a442e..ff3fe7eb6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -98,7 +98,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.14.6" + implementation "org.xmtp:android:0.14.7" implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.facebook.react:react-native:0.71.3' implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1" diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a9dcd42cb..a5aa4f20e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -449,7 +449,7 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.13.5): + - XMTP (0.13.6): - Connect-Swift (= 0.12.0) - GzipSwift - LibXMTP (= 0.5.4-beta4) @@ -458,7 +458,7 @@ PODS: - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.13.5) + - XMTP (= 0.13.6) - Yoga (1.14.0) DEPENDENCIES: @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 476b406c10c2c19183794b670790912545cc7699 - XMTPReactNative: d172e052907d373f40348ed091cdbf7c6da4a331 + XMTP: aeeff5ecac80f7ec9a2ba4f732d439ab600545ed + XMTPReactNative: 7a5fb82f5e8392ea53b5231edceb87ed07761e0b Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 09bafb78b..8dd1513b9 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -27,10 +27,15 @@ function test(name: string, perform: () => Promise) { test('can make a MLS V3 client', async () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars + const keyBytes = 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, 145, + ]) const client = await Client.createRandom({ env: 'local', appVersion: 'Testing/0.0.0', enableV3: true, + dbEncryptionKey: keyBytes, }) return true @@ -591,6 +596,8 @@ test('unpublished messages handling', async () => { if (preparedMessageId !== messages[0].id) { throw new Error(`Message ID should match the prepared message ID`) } + + return true }) test('can add members to a group', async () => { diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 8c63e8189..000df1533 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.13.5" + s.dependency "XMTP", "= 0.13.6" end diff --git a/src/hooks/useClient.ts b/src/hooks/useClient.ts index df6390773..26c0495a4 100644 --- a/src/hooks/useClient.ts +++ b/src/hooks/useClient.ts @@ -7,7 +7,7 @@ import { DefaultContentTypes } from '../lib/types/DefaultContentType' interface InitializeClientOptions { signer: Signer | null - options?: ClientOptions + options: ClientOptions } export const useClient = < diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 864baea88..4cc9373b9 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -52,10 +52,14 @@ export class Client< ContentCodecs extends DefaultContentTypes = DefaultContentTypes, >( wallet: Signer | WalletClient | null, - opts?: Partial & { codecs?: ContentCodecs } + options: ClientOptions & { codecs?: ContentCodecs } ): Promise> { - const options = defaultOptions(opts) - + if ( + options.dbEncryptionKey === undefined || + options.dbEncryptionKey.length !== 32 + ) { + throw new Error('Must pass an encryption key that is exactly 32 bytes.') + } const { enableSubscription, createSubscription } = this.setupSubscriptions(options) const signer = getSigner(wallet) @@ -109,7 +113,7 @@ export class Client< message.address, message.inboxId as InboxId, message.installationId, - opts?.codecs || [] + options.codecs || [] ) ) } @@ -152,9 +156,14 @@ export class Client< * @returns {Promise} A Promise that resolves to a new Client instance with a random address. */ static async createRandom( - opts?: Partial & { codecs?: ContentTypes } + options: ClientOptions & { codecs?: ContentTypes } ): Promise> { - const options = defaultOptions(opts) + if ( + options.dbEncryptionKey === undefined || + options.dbEncryptionKey.length !== 32 + ) { + throw new Error('Must pass an encryption key that is exactly 32 bytes.') + } const { enableSubscription, createSubscription } = this.setupSubscriptions(options) const client = await XMTPModule.createRandom( @@ -174,7 +183,7 @@ export class Client< client['address'], client['inboxId'], client['installationId'], - opts?.codecs || [] + options?.codecs || [] ) } @@ -192,9 +201,14 @@ export class Client< ContentCodecs extends DefaultContentTypes = [], >( keyBundle: string, - opts?: Partial & { codecs?: ContentCodecs } + options: ClientOptions & { codecs?: ContentCodecs } ): Promise> { - const options = defaultOptions(opts) + if ( + options.dbEncryptionKey === undefined || + options.dbEncryptionKey.length !== 32 + ) { + throw new Error('Must pass an encryption key that is exactly 32 bytes.') + } const client = await XMTPModule.createFromKeyBundle( keyBundle, options.env, @@ -209,7 +223,7 @@ export class Client< client['address'], client['inboxId'], client['installationId'], - opts?.codecs || [] + options.codecs || [] ) } @@ -507,7 +521,7 @@ export type ClientOptions = { */ enableV3?: boolean /** - * OPTIONAL specify the encryption key for the database. The encryption key must be exactly 32 bytes. + * REQUIRED specify the encryption key for the database. The encryption key must be exactly 32 bytes. */ dbEncryptionKey?: Uint8Array /**