MCPcopy Create free account
hub / github.com/CommE2E/comm / setSIWEBackupSecrets

Method setSIWEBackupSecrets

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:2608–2640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2606}
2607
2608jsi::Value CommCoreModule::setSIWEBackupSecrets(
2609 jsi::Runtime &rt,
2610 jsi::Object siweBackupSecrets) {
2611 std::string message =
2612 siweBackupSecrets.getProperty(rt, "message").asString(rt).utf8(rt);
2613 std::string signature =
2614 siweBackupSecrets.getProperty(rt, "signature").asString(rt).utf8(rt);
2615 folly::dynamic backupSecretsJSON =
2616 folly::dynamic::object("message", message)("signature", signature);
2617 std::string backupSecrets = folly::toJson(backupSecretsJSON);
2618
2619 return createPromiseAsJSIValue(
2620 rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
2621 taskType job = [this, promise, backupSecrets]() {
2622 std::string error;
2623 try {
2624 DatabaseManager::getQueryExecutor().setMetadata(
2625 "siweBackupSecrets", backupSecrets);
2626 } catch (const std::exception &e) {
2627 error = e.what();
2628 }
2629 this->jsInvoker_->invokeAsync([error, promise]() {
2630 if (error.size()) {
2631 promise->reject(error);
2632 } else {
2633 promise->resolve(jsi::Value::undefined());
2634 }
2635 });
2636 };
2637 GlobalDBSingleton::instance.scheduleOrRunCancellable(
2638 job, promise, this->jsInvoker_);
2639 });
2640}
2641
2642jsi::Value CommCoreModule::getSIWEBackupSecrets(jsi::Runtime &rt) {
2643 return createPromiseAsJSIValue(

Callers

nothing calls this directly

Calls 4

rejectMethod · 0.80
resolveMethod · 0.80
setMetadataMethod · 0.45

Tested by

no test coverage detected