feat: implement parseAuthUrl

Adds & Implements parseAuthUrl.
Updates README.md.
Bumps version to 0.2.0.
This commit is contained in:
coreyphillips
2024-09-15 21:17:10 -04:00
parent b5185fe7ba
commit c2a699d2d2
19 changed files with 221 additions and 41 deletions

View File

@@ -10,6 +10,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import uniffi.pubkymobile.auth
import uniffi.pubkymobile.parseAuthUrl
class PubkyModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
@@ -37,6 +38,19 @@ class PubkyModule(reactContext: ReactApplicationContext) :
}
}
@ReactMethod
fun parseAuthUrl(url: String, promise: Promise) {
try {
val result = parseAuthUrl(url)
val array = Arguments.createArray().apply {
result.forEach { pushString(it) }
}
promise.resolve(array)
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
companion object {
const val NAME = "Pubky"
}

View File

@@ -387,6 +387,8 @@ internal interface _UniFFILib : Library {
fun uniffi_pubkymobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,
): Pointer
fun uniffi_pubkymobile_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
@@ -503,6 +505,8 @@ internal interface _UniFFILib : Library {
): Unit
fun uniffi_pubkymobile_checksum_func_auth(
): Short
fun uniffi_pubkymobile_checksum_func_parse_auth_url(
): Short
fun ffi_pubkymobile_uniffi_contract_version(
): Int
@@ -523,6 +527,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_pubkymobile_checksum_func_auth() != 46918.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
}
// Async support
@@ -671,3 +678,11 @@ suspend fun `auth`(`url`: String, `secretKey`: String) : List<String> {
)
}
fun `parseAuthUrl`(`url`: String): List<String> {
return FfiConverterSequenceString.lift(
rustCall() { _status ->
_UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_parse_auth_url(FfiConverterString.lower(`url`),_status)
})
}