diff --git a/README.md b/README.md
index 4796a8a..561c479 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,8 @@ npm install @synonymdev/react-native-pubky
- [x] [resolve](#resolve): Functionality to resolve content.
- [x] [publishHttps](#publishHttps): Publish HTTPS records.
- [x] [resolveHttps](#resolveHttps): Resolve HTTPS records.
-- [x] [signUp](#signUp): Sign-up to a homeserver and update Pkarr accordingly.
+- [x] [getSignupToken](#getSignupToken): Get a signup token from a homeserver with admin credentials.
+- [x] [signUp](#signUp): Sign-up to a homeserver and update Pkarr accordingly, with optional signup token support.
- [x] [signIn](#signIn): Sign-in to a homeserver.
- [x] [session](#session): Check the current session for a given Pubky in its homeserver.
- [x] [signOut](#signOut): Sign-out from a homeserver.
@@ -28,7 +29,6 @@ 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.
-
## Usage
### Auth
```js
@@ -196,10 +196,26 @@ if (getPublicKeyFromSecretKeyRes.isErr()) {
console.log(getPublicKeyFromSecretKeyRes.value);
```
+### getSignupToken
+```js
+import { getSignupToken } from '@synonymdev/react-native-pubky';
+
+const getSignupTokenRes = await getSignupToken(
+ '8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo', // Homeserver pubky
+ 'admin_password' // Admin Password
+);
+if (getSignupTokenRes.isErr()) {
+ console.log(getSignupTokenRes.error.message);
+ return;
+}
+console.log('Signup Token:', getSignupTokenRes.value);
+```
+
### signUp
```js
import { signUp } from '@synonymdev/react-native-pubky';
+// Standard signup
const signUpRes = await signUp(
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', // Secret
'pubky://8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo', // Homeserver
@@ -209,6 +225,18 @@ if (signUpRes.isErr()) {
return;
}
console.log(signUpRes.value);
+
+// Signup with token
+const signUpWithTokenRes = await signUp(
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', // Secret
+ 'pubky://8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo', // Homeserver
+ 'your_signup_token' // Optional signup token
+);
+if (signUpWithTokenRes.isErr()) {
+ console.log(signUpWithTokenRes.error.message);
+ return;
+}
+console.log(signUpWithTokenRes.value);
```
### signIn
diff --git a/android/src/main/java/com/pubky/PubkyModule.kt b/android/src/main/java/com/pubky/PubkyModule.kt
index 41a3bf2..c3cbd9b 100644
--- a/android/src/main/java/com/pubky/PubkyModule.kt
+++ b/android/src/main/java/com/pubky/PubkyModule.kt
@@ -168,10 +168,29 @@ class PubkyModule(reactContext: ReactApplicationContext) :
}
@ReactMethod
- fun signUp(secretKey: String, homeserver: String, promise: Promise) {
+ fun getSignupToken(homeserverPubky: String, adminPassword: String, promise: Promise) {
CoroutineScope(Dispatchers.IO).launch {
try {
- val result = signUp(secretKey, homeserver)
+ val result = getSignupToken(homeserverPubky, adminPassword)
+ 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)
+ }
+ }
+ }
+ }
+
+ @ReactMethod
+ fun signUp(secretKey: String, homeserver: String, signupToken: String, promise: Promise) {
+ CoroutineScope(Dispatchers.IO).launch {
+ try {
+ val result = signUp(secretKey, homeserver, signupToken)
val array = Arguments.createArray().apply {
result.forEach { pushString(it) }
}
diff --git a/android/src/main/java/uniffi/pubkycore/pubkycore.kt b/android/src/main/java/uniffi/pubkycore/pubkycore.kt
index d4455aa..4f3a0f0 100644
--- a/android/src/main/java/uniffi/pubkycore/pubkycore.kt
+++ b/android/src/main/java/uniffi/pubkycore/pubkycore.kt
@@ -404,6 +404,8 @@ internal interface _UniFFILib : Library {
): 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,
+ ): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_list(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
@@ -428,7 +430,7 @@ internal interface _UniFFILib : Library {
): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_sign_out(`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
- fun uniffi_pubkycore_fn_func_sign_up(`secretKey`: RustBuffer.ByValue,`homeserver`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
+ fun uniffi_pubkycore_fn_func_sign_up(`secretKey`: RustBuffer.ByValue,`homeserver`: RustBuffer.ByValue,`signupToken`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_pubkycore_fn_func_switch_network(`useTestnet`: Byte,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
@@ -560,6 +562,8 @@ internal interface _UniFFILib : Library {
): Short
fun uniffi_pubkycore_checksum_func_get_public_key_from_secret_key(
): Short
+ fun uniffi_pubkycore_checksum_func_get_signup_token(
+ ): Short
fun uniffi_pubkycore_checksum_func_list(
): Short
fun uniffi_pubkycore_checksum_func_parse_auth_url(
@@ -628,6 +632,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
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")
}
+ if (lib.uniffi_pubkycore_checksum_func_get_signup_token() != 47927.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
if (lib.uniffi_pubkycore_checksum_func_list() != 43198.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -664,7 +671,7 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_pubkycore_checksum_func_sign_out() != 34903.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
- if (lib.uniffi_pubkycore_checksum_func_sign_up() != 37999.toShort()) {
+ if (lib.uniffi_pubkycore_checksum_func_sign_up() != 48789.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_pubkycore_checksum_func_switch_network() != 64215.toShort()) {
@@ -1135,6 +1142,35 @@ public object FfiConverterTypeEventListener: FfiConverterCallbackInterface {
+ override fun read(buf: ByteBuffer): String? {
+ if (buf.get().toInt() == 0) {
+ return null
+ }
+ return FfiConverterString.read(buf)
+ }
+
+ override fun allocationSize(value: String?): Int {
+ if (value == null) {
+ return 1
+ } else {
+ return 1 + FfiConverterString.allocationSize(value)
+ }
+ }
+
+ override fun write(value: String?, buf: ByteBuffer) {
+ if (value == null) {
+ buf.put(0)
+ } else {
+ buf.put(1)
+ FfiConverterString.write(value, buf)
+ }
+ }
+}
+
+
+
+
public object FfiConverterSequenceString: FfiConverterRustBuffer> {
override fun read(buf: ByteBuffer): List {
val len = buf.getInt()
@@ -1213,6 +1249,14 @@ fun `getPublicKeyFromSecretKey`(`secretKey`: String): List {
}
+fun `getSignupToken`(`homeserverPubky`: String, `adminPassword`: String): List {
+ return FfiConverterSequenceString.lift(
+ rustCall() { _status ->
+ _UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_get_signup_token(FfiConverterString.lower(`homeserverPubky`),FfiConverterString.lower(`adminPassword`),_status)
+})
+}
+
+
fun `list`(`url`: String): List {
return FfiConverterSequenceString.lift(
rustCall() { _status ->
@@ -1309,10 +1353,10 @@ fun `signOut`(`secretKey`: String): List {
}
-fun `signUp`(`secretKey`: String, `homeserver`: String): List {
+fun `signUp`(`secretKey`: String, `homeserver`: String, `signupToken`: String?): List {
return FfiConverterSequenceString.lift(
rustCall() { _status ->
- _UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_sign_up(FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`homeserver`),_status)
+ _UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_sign_up(FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`homeserver`),FfiConverterOptionalString.lower(`signupToken`),_status)
})
}
diff --git a/android/src/main/jniLibs/arm64-v8a/libpubkycore.so b/android/src/main/jniLibs/arm64-v8a/libpubkycore.so
index ff055a3..e903eef 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 3233aea..de05cec 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 e258da5..6741d1a 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 cf0ae10..b5edb74 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 fcba584..5b34024 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.9.5):
+ - react-native-pubky (0.10.0):
- DoubleConversion
- glog
- hermes-engine
@@ -1757,7 +1757,7 @@ SPEC CHECKSUMS:
React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404
React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4
React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e
- react-native-pubky: 7c1f0436da7e93cd17fc7aa22ff3f89c6cb3445d
+ react-native-pubky: f45bed8e9a6ccbb350c2e40131be2e92d394722c
React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9
React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27
React-perflogger: 3bbb82f18e9ac29a1a6931568e99d6305ef4403b
diff --git a/example/src/App.tsx b/example/src/App.tsx
index d77bc40..5892ff5 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -21,6 +21,7 @@ import {
removeEventListener,
session,
deleteFile,
+ getSignupToken,
} from '@synonymdev/react-native-pubky';
const HOMESERVER = '8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo';
@@ -131,13 +132,36 @@ export default function App() {
}
}}
/>
+
+