| 2515 | } |
| 2516 | |
| 2517 | jsi::Value CommCoreModule::getQRAuthBackupData(jsi::Runtime &rt) { |
| 2518 | return createPromiseAsJSIValue( |
| 2519 | rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) { |
| 2520 | taskType job = [this, &innerRt, promise]() { |
| 2521 | std::string error; |
| 2522 | std::string backupID; |
| 2523 | std::string backupDataKey; |
| 2524 | std::string backupLogDataKey; |
| 2525 | try { |
| 2526 | backupID = |
| 2527 | DatabaseManager::getQueryExecutor().getMetadata("backupID"); |
| 2528 | folly::Optional<std::string> backupDataKeyOpt = |
| 2529 | CommSecureStore::get(CommSecureStore::backupDataKey); |
| 2530 | if (backupDataKeyOpt.hasValue()) { |
| 2531 | backupDataKey = backupDataKeyOpt.value(); |
| 2532 | } else { |
| 2533 | throw std::runtime_error("missing backupDataKey"); |
| 2534 | } |
| 2535 | folly::Optional<std::string> backupLogDataKeyOpt = |
| 2536 | CommSecureStore::get(CommSecureStore::backupLogDataKey); |
| 2537 | if (backupLogDataKeyOpt.hasValue()) { |
| 2538 | backupLogDataKey = backupLogDataKeyOpt.value(); |
| 2539 | } else { |
| 2540 | throw std::runtime_error("missing backupLogDataKey"); |
| 2541 | } |
| 2542 | } catch (const std::exception &e) { |
| 2543 | error = e.what(); |
| 2544 | } |
| 2545 | this->jsInvoker_->invokeAsync([&innerRt, |
| 2546 | error, |
| 2547 | backupID, |
| 2548 | backupDataKey, |
| 2549 | backupLogDataKey, |
| 2550 | promise]() { |
| 2551 | if (error.size()) { |
| 2552 | promise->reject(error); |
| 2553 | } else { |
| 2554 | auto backupKeys = jsi::Object(innerRt); |
| 2555 | backupKeys.setProperty( |
| 2556 | innerRt, |
| 2557 | "backupID", |
| 2558 | jsi::String::createFromUtf8(innerRt, backupID)); |
| 2559 | backupKeys.setProperty( |
| 2560 | innerRt, |
| 2561 | "backupDataKey", |
| 2562 | jsi::String::createFromUtf8(innerRt, backupDataKey)); |
| 2563 | backupKeys.setProperty( |
| 2564 | innerRt, |
| 2565 | "backupLogDataKey", |
| 2566 | jsi::String::createFromUtf8(innerRt, backupLogDataKey)); |
| 2567 | promise->resolve(std::move(backupKeys)); |
| 2568 | } |
| 2569 | }); |
| 2570 | }; |
| 2571 | GlobalDBSingleton::instance.scheduleOrRunCancellable( |
| 2572 | job, promise, this->jsInvoker_); |
| 2573 | }); |
| 2574 | } |
nothing calls this directly
no test coverage detected