diff --git a/README.md b/README.md
index 6e2c4a4..3d95119 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,8 @@ npm install @synonymdev/react-native-pubky
- [x] [put](#put): Upload a small payload to a given path.
- [x] [get](#get): Download a small payload from a given path relative to a pubky author.
- [x] [list](#list): Returns a list of Pubky URLs of the files in the path of the `url` provided.
+- [x] [generateSecretKey](#generateSecretKey): Generate a secret key.
+- [x] [getPublicKeyFromSecretKey](#getPublicKeyFromSecretKey): Get the public key string and uri from a secret key.
### Methods to be Implemented
- [ ] signIn: Sign-in to a homeserver.
- [ ] signUp: Sign-up to a homeserver and update Pkarr accordingly.
@@ -154,6 +156,30 @@ if (listRes.isErr()) {
console.log(listRes.value);
```
+### generateSecretKey
+```js
+import { generateSecretKey } from '@synonymdev/react-native-pubky';
+
+const generateSecretKeyRes = await generateSecretKey();
+if (generateSecretKeyRes.isErr()) {
+ console.log(generateSecretKeyRes.error.message);
+ return;
+}
+console.log(generateSecretKeyRes.value);
+```
+
+### getPublicKeyFromSecretKey
+```js
+import { getPublicKeyFromSecretKey } from '@synonymdev/react-native-pubky';
+
+const getPublicKeyFromSecretKeyRes = await getPublicKeyFromSecretKey('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+if (getPublicKeyFromSecretKeyRes.isErr()) {
+ console.log(getPublicKeyFromSecretKeyRes.error.message);
+ return;
+}
+console.log(getPublicKeyFromSecretKeyRes.value);
+```
+
## Local Installation
1. Clone & npm install:
diff --git a/android/src/main/java/com/pubky/PubkyModule.kt b/android/src/main/java/com/pubky/PubkyModule.kt
index f53b5f5..b9f9e51 100644
--- a/android/src/main/java/com/pubky/PubkyModule.kt
+++ b/android/src/main/java/com/pubky/PubkyModule.kt
@@ -9,17 +9,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import uniffi.pubkymobile.auth
-import uniffi.pubkymobile.parseAuthUrl
-import uniffi.pubkymobile.publish
-import uniffi.pubkymobile.resolve
-import uniffi.pubkymobile.signUp
-import uniffi.pubkymobile.signIn
-import uniffi.pubkymobile.signOut
-import uniffi.pubkymobile.put
-import uniffi.pubkymobile.get
-import uniffi.pubkymobile.publishHttps
-import uniffi.pubkymobile.resolveHttps
+import uniffi.pubkymobile.*
class PubkyModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
@@ -250,6 +240,44 @@ class PubkyModule(reactContext: ReactApplicationContext) :
}
}
+ @ReactMethod
+ fun generateSecretKey(promise: Promise) {
+ CoroutineScope(Dispatchers.IO).launch {
+ try {
+ val result = generate_secret_key()
+ 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 getPublicKeyFromSecretKey(secretKey: String, promise: Promise) {
+ CoroutineScope(Dispatchers.IO).launch {
+ try {
+ val result = getPublicKeyFromSecretKey(secretKey)
+ 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"
}
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index fb61410..c523763 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.6.0):
+ - react-native-pubky (0.7.0):
- DoubleConversion
- glog
- hermes-engine
@@ -1757,7 +1757,7 @@ SPEC CHECKSUMS:
React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404
React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4
React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e
- react-native-pubky: 0240de4239550981499983fa50a1aa6fc200823d
+ react-native-pubky: e296eaeb8422b0864f5807592eac144d7d9a6eae
React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9
React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27
React-perflogger: 3bbb82f18e9ac29a1a6931568e99d6305ef4403b
diff --git a/example/src/App.tsx b/example/src/App.tsx
index abca411..4cc7547 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -12,6 +12,8 @@ import {
resolveHttps,
publishHttps,
list,
+ generateSecretKey,
+ getPublicKeyFromSecretKey,
} from '@synonymdev/react-native-pubky';
export default function App() {
@@ -226,6 +228,39 @@ export default function App() {
}
}}
/>
+