diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index e4e42fa1..f74e6945 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -61,7 +61,8 @@ public struct ClientOptions { preEnableIdentityCallback: PreEventCallback? = nil, preCreateIdentityCallback: PreEventCallback? = nil, mlsAlpha: Bool = false, - mlsEncryptionKey: Data? = nil + mlsEncryptionKey: Data? = nil, + mlsDbPath: String? = nil ) { self.api = api self.codecs = codecs @@ -69,6 +70,7 @@ public struct ClientOptions { self.preCreateIdentityCallback = preCreateIdentityCallback self.mlsAlpha = mlsAlpha self.mlsEncryptionKey = mlsEncryptionKey + self.mlsDbPath = mlsDbPath } } diff --git a/Tests/XMTPTests/ClientTests.swift b/Tests/XMTPTests/ClientTests.swift index 6efea951..cff9a2c3 100644 --- a/Tests/XMTPTests/ClientTests.swift +++ b/Tests/XMTPTests/ClientTests.swift @@ -93,6 +93,59 @@ class ClientTests: XCTestCase { XCTAssert(true) } } + + func testPassingMLSEncryptionKeyAndDatabasePath() async throws { + let bo = try PrivateKey.generate() + let key = try Crypto.secureRandomBytes(count: 32) + let dbPath = URL.documentsDirectory.appendingPathComponent("xmtp-\(bo.walletAddress).db3").path + + let client = try await Client.create( + account: bo, + options: .init( + api: .init(env: .local, isSecure: false), + mlsAlpha: true, + mlsEncryptionKey: key, + mlsDbPath: dbPath + ) + ) + + let keys = client.privateKeyBundle + let bundleClient = try await Client.from( + bundle: keys, + options: .init( + api: .init(env: .local, isSecure: false), + mlsAlpha: true, + mlsEncryptionKey: key, + mlsDbPath: dbPath + ) + ) + + XCTAssertEqual(client.address, bundleClient.address) + + await assertThrowsAsyncError( + _ = try await Client.from( + bundle: keys, + options: .init( + api: .init(env: .local, isSecure: false), + mlsAlpha: true, + mlsEncryptionKey: nil, + mlsDbPath: dbPath + ) + ) + ) + + await assertThrowsAsyncError( + _ = try await Client.from( + bundle: keys, + options: .init( + api: .init(env: .local, isSecure: false), + mlsAlpha: true, + mlsEncryptionKey: key, + mlsDbPath: nil + ) + ) + ) + } func testCanMessage() async throws { let fixtures = await fixtures() diff --git a/XMTP.podspec b/XMTP.podspec index 609b0dd7..2ef64b0b 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.8.10" + spec.version = "0.8.11" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results.