mirror of
https://github.com/aljazceru/react-native-pubky.git
synced 2026-01-26 10:14:35 +01:00
refactor: add getHomeserver
Adds getHomeserver method. Updates example app. Bumps version to 0.10.2. Updates README.md.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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<String> {
|
||||
}
|
||||
|
||||
|
||||
fun `getHomeserver`(`pubky`: String): List<String> {
|
||||
return FfiConverterSequenceString.lift(
|
||||
rustCall() { _status ->
|
||||
_UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_get_homeserver(FfiConverterString.lower(`pubky`),_status)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun `getPublicKeyFromSecretKey`(`secretKey`: String): List<String> {
|
||||
return FfiConverterSequenceString.lift(
|
||||
rustCall() { _status ->
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user