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

feat: permit creating client from exported key bundle #58

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

dmccartney
Copy link
Contributor

This adds createFromKeyBundle and exportKeyBundle to the Client.

This is part of the solution for #35

@dmccartney dmccartney requested a review from a team as a code owner June 21, 2023 19:29
@@ -2,164 +2,181 @@ import ExpoModulesCore
import XMTP

class ReactNativeSigner: NSObject, XMTP.SigningKey {
enum Error: Swift.Error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of the changes in this file are just replacing \t with 4 spaces

Comment on lines +135 to +151
// Create a client using its serialized key bundle.
AsyncFunction("createFromKeyBundle") { (keyBundle: String, environment: String) -> String in
let bundle = try PrivateKeyBundle(serializedData: Data(base64Encoded: Data(keyBundle.utf8))!)
let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!)
let client = try await Client.from(bundle: bundle, options: options)
self.clients[client.address] = client
return client.address
}

// Export the client's serialized key bundle.
AsyncFunction("exportKeyBundle") { (clientAddress: String) -> String in
guard let client = clients[clientAddress] else {
throw Error.noClient
}
let bundle = try client.privateKeyBundle.serializedData().base64EncodedString()
return bundle
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the substantive changes.

@dmccartney dmccartney force-pushed the daniel-create-export-keybundle branch from 3b82e5d to 7ebfec8 Compare June 21, 2023 21:08
@dmccartney dmccartney merged commit 2bafc64 into main Jun 21, 2023
@dmccartney dmccartney deleted the daniel-create-export-keybundle branch June 21, 2023 21:52
@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants