Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back the requirement on encryption key #366

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ public final class Client {
let alias = "xmtp-\(options?.api.env.rawValue ?? "")-\(inboxId).db3"
let dbURL = directoryURL.appendingPathComponent(alias).path

let encryptionKey = options?.dbEncryptionKey
var encryptionKey = options?.dbEncryptionKey
if (encryptionKey == nil) {
throw ClientError.creationError("No encryption key passed for the database. Please store and provide a secure encryption key.")
}

let v3Client = try await LibXMTP.createClient(
logger: XMTPLogger(),
Expand Down
24 changes: 17 additions & 7 deletions Tests/XMTPTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,24 @@ class ClientTests: XCTestCase {
}

func testCanDeleteDatabase() async throws {
let key = try Crypto.secureRandomBytes(count: 32)
let bo = try PrivateKey.generate()
let alix = try PrivateKey.generate()
var boClient = try await Client.create(
account: bo,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

let alixClient = try await Client.create(
account: alix,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

Expand All @@ -124,7 +127,8 @@ class ClientTests: XCTestCase {
account: bo,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

Expand All @@ -134,21 +138,24 @@ class ClientTests: XCTestCase {
}

func testCanDropReconnectDatabase() async throws {
let key = try Crypto.secureRandomBytes(count: 32)
let bo = try PrivateKey.generate()
let alix = try PrivateKey.generate()
var boClient = try await Client.create(
account: bo,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

let alixClient = try await Client.create(
account: alix,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

Expand Down Expand Up @@ -340,21 +347,24 @@ class ClientTests: XCTestCase {
}

func testCanGetAnInboxIdFromAddress() async throws {
let key = try Crypto.secureRandomBytes(count: 32)
let bo = try PrivateKey.generate()
let alix = try PrivateKey.generate()
let boClient = try await Client.create(
account: bo,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)

let alixClient = try await Client.create(
account: alix,
options: .init(
api: .init(env: .local, isSecure: false),
enableV3: true
enableV3: true,
encryptionKey: key
)
)
let boInboxId = try await alixClient.inboxIdFromAddress(address: boClient.address)
Expand Down
2 changes: 1 addition & 1 deletion XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "0.13.5"
spec.version = "0.13.6"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down
Loading