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 @@ -583,6 +583,20 @@ return jsiOneTimeKeys; } +jsi::String parseOLMPrekey(jsi::Runtime &rt, std::string prekeyBlob) { + folly::dynamic parsedPrekey = folly::parseJson(prekeyBlob); + + auto prekey = parsedPrekey["curve25519"].values().begin()->asString(); + return jsi::String::createFromUtf8(rt, prekey); +} + +rust::String parseOLMPrekey(std::string prekeyBlob) { + folly::dynamic parsedPrekey = folly::parseJson(prekeyBlob); + + auto prekey = parsedPrekey["curve25519"].values().begin()->asString(); + return rust::String(prekey); +} + jsi::Object parseOneTimeKeysResult( jsi::Runtime &rt, std::string contentOneTimeKeysBlob, @@ -710,9 +724,9 @@ authUserIDRust, authDeviceIDRust, authAccessTokenRust, - rust::string(prekeyToUpload), + parseOLMPrekey(prekeyToUpload), rust::string(prekeySignature), - rust::string(notificationsPrekey), + parseOLMPrekey(notificationsPrekey), rust::string(notificationsPrekeySignature), currentID); prekeyFuture.get(); @@ -783,11 +797,10 @@ return; } auto contentPrekeyJSI = - jsi::String::createFromUtf8(innerRt, contentPrekey.value()); + parseOLMPrekey(innerRt, contentPrekey.value()); auto contentPrekeySignatureJSI = jsi::String::createFromUtf8(innerRt, contentPrekeySignature); - auto notifPrekeyJSI = - jsi::String::createFromUtf8(innerRt, notifPrekey); + auto notifPrekeyJSI = parseOLMPrekey(innerRt, notifPrekey); auto notifPrekeySignatureJSI = jsi::String::createFromUtf8(innerRt, notifPrekeySignature);