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

Method restoreUser

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:3416–3521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3414}
3415
3416jsi::Value CommCoreModule::restoreUser(
3417 jsi::Runtime &rt,
3418 jsi::String userID,
3419 std::optional<jsi::String> siweSocialProofMessage,
3420 std::optional<jsi::String> siweSocialProofSignature,
3421 jsi::String keyPayload,
3422 jsi::String keyPayloadSignature,
3423 jsi::String contentPrekey,
3424 jsi::String contentPrekeySignature,
3425 jsi::String notifPrekey,
3426 jsi::String notifPrekeySignature,
3427 jsi::Array contentOneTimeKeys,
3428 jsi::Array notifOneTimeKeys,
3429 jsi::String deviceList,
3430 jsi::String backupSecret) {
3431 rust::String siweSocialProofMessageRust = "";
3432 if (siweSocialProofMessage.has_value()) {
3433 siweSocialProofMessageRust =
3434 jsiStringToRustString(siweSocialProofMessage.value(), rt);
3435 }
3436 rust::String siweSocialProofSignatureRust = "";
3437 if (siweSocialProofSignature.has_value()) {
3438 siweSocialProofSignatureRust =
3439 jsiStringToRustString(siweSocialProofSignature.value(), rt);
3440 }
3441 auto userIDRust = jsiStringToRustString(userID, rt);
3442 auto keyPayloadRust = jsiStringToRustString(keyPayload, rt);
3443 auto keyPayloadSignatureRust = jsiStringToRustString(keyPayloadSignature, rt);
3444 auto contentPrekeyRust = jsiStringToRustString(contentPrekey, rt);
3445 auto contentPrekeySignatureRust =
3446 jsiStringToRustString(contentPrekeySignature, rt);
3447 auto notifPrekeyRust = jsiStringToRustString(notifPrekey, rt);
3448 auto notifPrekeySignatureRust =
3449 jsiStringToRustString(notifPrekeySignature, rt);
3450 auto contentOneTimeKeysRust = jsiStringArrayToRustVec(contentOneTimeKeys, rt);
3451 auto notifOneTimeKeysRust = jsiStringArrayToRustVec(notifOneTimeKeys, rt);
3452 auto deviceListRust = jsiStringToRustString(deviceList, rt);
3453 auto backupSecretRust = jsiStringToRustString(backupSecret, rt);
3454
3455 return createPromiseAsJSIValue(
3456 rt, [=, this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
3457 std::string backupMessage;
3458 try {
3459 backupMessage = getSIWEBackupMessage();
3460 } catch (std::system_error &e) {
3461 this->jsInvoker_->invokeAsync(
3462 [=, &innerRt]() { promise->reject(e.what()); });
3463 return;
3464 }
3465
3466 this->cryptoThread->scheduleTask([=, &innerRt]() {
3467 std::string error;
3468 std::string backupID;
3469 try {
3470 backupID = crypto::Tools::generateRandomURLSafeString(32);
3471 } catch (const std::exception &e) {
3472 error = "Failed to generate backupID";
3473 }

Callers

nothing calls this directly

Calls 8

jsiStringToRustStringFunction · 0.85
jsiStringArrayToRustVecFunction · 0.85
getSIWEBackupMessageFunction · 0.85
rejectMethod · 0.80
scheduleTaskMethod · 0.80
pickleAccountToStringMethod · 0.80
addPromiseMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected