-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
@@ -2,164 +2,181 @@ import ExpoModulesCore | |||
import XMTP | |||
|
|||
class ReactNativeSigner: NSObject, XMTP.SigningKey { | |||
enum Error: Swift.Error { |
There was a problem hiding this comment.
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
// 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 | ||
} |
There was a problem hiding this comment.
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.
3b82e5d
to
7ebfec8
Compare
🎉 This PR is included in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This adds
createFromKeyBundle
andexportKeyBundle
to theClient
.This is part of the solution for #35