diff --git a/README.md b/README.md
index 80b5f27..a5cfead 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ npm install @synonymdev/react-native-pubky
- [x] [getPublicKeyFromSecretKey](#getPublicKeyFromSecretKey): Get the public key string and uri from a secret key.
- [x] [create_recovery_file](#createRecoveryFile): Create a recovery file.
- [x] [decrypt_recovery_file](#decryptRecoveryFile): Decrypt a recovery file.
+- [x] [getHomeserver](#getHomeserver): Get homeserver URL from a public key.
## Usage
### Auth
```js
@@ -283,6 +284,20 @@ if (sessionRes.isErr()) {
console.log(sessionRes.value);
```
+### getHomeserver
+```js
+import { getHomeserver } from '@synonymdev/react-native-pubky';
+
+const getHomeserverRes = await getHomeserver(
+ 'z4e8s17cou9qmuwen8p1556jzhf1wktmzo6ijsfnri9c4hnrdfty' // Public Key
+);
+if (getHomeserverRes.isErr()) {
+ console.log(getHomeserverRes.error.message);
+ return;
+}
+console.log(getHomeserverRes.value);
+```
+
### signIn
```js
import { signOut } from '@synonymdev/react-native-pubky';
@@ -378,4 +393,3 @@ MIT
- Project created with: [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
- [Building an Android App with Rust Using UniFFI](https://forgen.tech/en/blog/post/building-an-android-app-with-rust-using-uniffi)
- [Building an iOS App with Rust Using UniFFI](https://forgen.tech/en/blog/post/building-an-ios-app-with-rust-using-uniffi)
-
diff --git a/android/src/main/java/com/pubky/PubkyModule.kt b/android/src/main/java/com/pubky/PubkyModule.kt
index 2b13276..e4634fc 100644
--- a/android/src/main/java/com/pubky/PubkyModule.kt
+++ b/android/src/main/java/com/pubky/PubkyModule.kt
@@ -433,6 +433,25 @@ class PubkyModule(reactContext: ReactApplicationContext) :
}
}
+ @ReactMethod
+ fun getHomeserver(pubky: String, promise: Promise) {
+ CoroutineScope(Dispatchers.IO).launch {
+ try {
+ val result = getHomeserver(pubky)
+ val array = Arguments.createArray().apply {
+ result.forEach { pushString(it) }
+ }
+ withContext(Dispatchers.Main) {
+ promise.resolve(array)
+ }
+ } catch (e: Exception) {
+ withContext(Dispatchers.Main) {
+ promise.reject("Error", e.message)
+ }
+ }
+ }
+ }
+
companion object {
const val NAME = "Pubky"
}
diff --git a/android/src/main/java/uniffi/pubkycore/pubkycore.kt b/android/src/main/java/uniffi/pubkycore/pubkycore.kt
index 8256880..fec8468 100644
--- a/android/src/main/java/uniffi/pubkycore/pubkycore.kt
+++ b/android/src/main/java/uniffi/pubkycore/pubkycore.kt
@@ -402,6 +402,8 @@ internal interface _UniFFILib : Library {
): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_get(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
+ fun uniffi_pubkycore_fn_func_get_homeserver(`pubky`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
+ ): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_get_public_key_from_secret_key(`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_get_signup_token(`homeserverPubky`: RustBuffer.ByValue,`adminPassword`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
@@ -562,6 +564,8 @@ internal interface _UniFFILib : Library {
): Short
fun uniffi_pubkycore_checksum_func_get(
): Short
+ fun uniffi_pubkycore_checksum_func_get_homeserver(
+ ): Short
fun uniffi_pubkycore_checksum_func_get_public_key_from_secret_key(
): Short
fun uniffi_pubkycore_checksum_func_get_signup_token(
@@ -633,6 +637,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_pubkycore_checksum_func_get() != 6591.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
+ if (lib.uniffi_pubkycore_checksum_func_get_homeserver() != 40658.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
if (lib.uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 40316.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -1248,6 +1255,14 @@ fun `get`(`url`: String): List {
}
+fun `getHomeserver`(`pubky`: String): List {
+ return FfiConverterSequenceString.lift(
+ rustCall() { _status ->
+ _UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_get_homeserver(FfiConverterString.lower(`pubky`),_status)
+})
+}
+
+
fun `getPublicKeyFromSecretKey`(`secretKey`: String): List {
return FfiConverterSequenceString.lift(
rustCall() { _status ->
diff --git a/android/src/main/jniLibs/arm64-v8a/libpubkycore.so b/android/src/main/jniLibs/arm64-v8a/libpubkycore.so
index 141e80c..b980ab6 100755
Binary files a/android/src/main/jniLibs/arm64-v8a/libpubkycore.so and b/android/src/main/jniLibs/arm64-v8a/libpubkycore.so differ
diff --git a/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so b/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so
index 5f9eb3b..832e7d7 100755
Binary files a/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so and b/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so differ
diff --git a/android/src/main/jniLibs/x86/libpubkycore.so b/android/src/main/jniLibs/x86/libpubkycore.so
index 98ce76d..ab31b7d 100755
Binary files a/android/src/main/jniLibs/x86/libpubkycore.so and b/android/src/main/jniLibs/x86/libpubkycore.so differ
diff --git a/android/src/main/jniLibs/x86_64/libpubkycore.so b/android/src/main/jniLibs/x86_64/libpubkycore.so
index 3e52851..26a9254 100755
Binary files a/android/src/main/jniLibs/x86_64/libpubkycore.so and b/android/src/main/jniLibs/x86_64/libpubkycore.so differ
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 0796a1f..add0da4 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -1237,7 +1237,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- - react-native-pubky (0.10.1):
+ - react-native-pubky (0.10.2):
- DoubleConversion
- glog
- hermes-engine
@@ -1757,7 +1757,7 @@ SPEC CHECKSUMS:
React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404
React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4
React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e
- react-native-pubky: 223d9be8cf0ca3f97fc4202779dc6629bc0bf8a2
+ react-native-pubky: b75611d5a4e02c66967555b7be2f837fc3628b8e
React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9
React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27
React-perflogger: 3bbb82f18e9ac29a1a6931568e99d6305ef4403b
diff --git a/example/src/App.tsx b/example/src/App.tsx
index 5892ff5..b00fdc0 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -22,6 +22,7 @@ import {
session,
deleteFile,
getSignupToken,
+ getHomeserver,
} from '@synonymdev/react-native-pubky';
const HOMESERVER = '8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo';
@@ -190,6 +191,23 @@ export default function App() {
}
}}
/>
+