mirror of
https://github.com/aljazceru/react-native-pubky.git
synced 2026-01-20 15:24:25 +01:00
feat: implement parseAuthUrl
Adds & Implements parseAuthUrl. Updates README.md. Bumps version to 0.2.0.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user