Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32904570
D7215.1768194954.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D7215.1768194954.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -63,6 +63,7 @@
virtual jsi::Value clearSensitiveData(jsi::Runtime &rt) override;
virtual bool checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) override;
virtual void reportDBOperationsFailure(jsi::Runtime &rt) override;
+ virtual jsi::Value generateNonce(jsi::Runtime &rt) override;
public:
CommCoreModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -1168,4 +1168,18 @@
DatabaseManager::reportDBOperationsFailure();
}
+jsi::Value CommCoreModule::generateNonce(jsi::Runtime &rt) {
+ return createPromiseAsJSIValue(
+ rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ std::string error;
+ try {
+ auto currentID = RustPromiseManager::instance.addPromise(
+ promise, this->jsInvoker_, innerRt);
+ identityGenerateNonce(currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ });
+}
+
} // namespace comm
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -94,6 +94,9 @@
static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->reportDBOperationsFailure(rt);
return jsi::Value::undefined();
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_generateNonce(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->generateNonce(rt);
+}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommTurboModule", jsInvoker) {
@@ -123,6 +126,7 @@
methodMap_["clearSensitiveData"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearSensitiveData};
methodMap_["checkIfDatabaseNeedsDeletion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_checkIfDatabaseNeedsDeletion};
methodMap_["reportDBOperationsFailure"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_reportDBOperationsFailure};
+ methodMap_["generateNonce"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_generateNonce};
}
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -46,6 +46,7 @@
virtual jsi::Value clearSensitiveData(jsi::Runtime &rt) = 0;
virtual bool checkIfDatabaseNeedsDeletion(jsi::Runtime &rt) = 0;
virtual void reportDBOperationsFailure(jsi::Runtime &rt) = 0;
+ virtual jsi::Value generateNonce(jsi::Runtime &rt) = 0;
};
@@ -275,6 +276,14 @@
return bridging::callFromJs<void>(
rt, &T::reportDBOperationsFailure, jsInvoker_, instance_);
}
+ jsi::Value generateNonce(jsi::Runtime &rt) override {
+ static_assert(
+ bridging::getParameterCount(&T::generateNonce) == 1,
+ "Expected generateNonce(...) to have 1 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::generateNonce, jsInvoker_, instance_);
+ }
private:
T *instance_;
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -91,6 +91,9 @@
notif_onetime_keys: Vec<String>,
) -> Result<String>;
+ #[cxx_name = "identityGenerateNonce"]
+ fn generate_nonce(promise_id: u32);
+
// Tunnelbroker Service Client
type TunnelbrokerClient;
@@ -121,6 +124,24 @@
}
}
+fn generate_nonce(promise_id: u32) {
+ RUNTIME.spawn(async move {
+ let result = fetch_nonce().await;
+ handle_string_result_as_callback(result, promise_id);
+ });
+}
+
+async fn fetch_nonce() -> Result<String, Error> {
+ let mut identity_client =
+ IdentityClientServiceClient::connect("http://127.0.0.1:50054").await?;
+ let nonce = identity_client
+ .generate_nonce(Empty {})
+ .await?
+ .into_inner()
+ .nonce;
+ Ok(nonce)
+}
+
#[derive(Debug)]
pub struct IdentityClient {
identity_client: IdentityClientServiceClient<Channel>,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -74,6 +74,7 @@
+clearSensitiveData: () => Promise<void>;
+checkIfDatabaseNeedsDeletion: () => boolean;
+reportDBOperationsFailure: () => void;
+ +generateNonce: () => Promise<string>;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 12, 5:15 AM (15 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5921833
Default Alt Text
D7215.1768194954.diff (5 KB)
Attached To
Mode
D7215: [native] make generateNonce callable from js
Attached
Detach File
Event Timeline
Log In to Comment