refactor: add getHomeserver

Adds getHomeserver method.
Updates example app.
Bumps version to 0.10.2.
Updates README.md.
This commit is contained in:
coreyphillips
2025-03-22 12:41:30 -04:00
parent 45190e6a29
commit 989b7252a0
19 changed files with 1860 additions and 1644 deletions

View File

@@ -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"
}

View File

@@ -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 ->