diff --git a/lib/handlers/peer-to-peer-message-handler.js b/lib/handlers/peer-to-peer-message-handler.js --- a/lib/handlers/peer-to-peer-message-handler.js +++ b/lib/handlers/peer-to-peer-message-handler.js @@ -92,7 +92,7 @@ } else if (message.type === peerToPeerMessageTypes.ENCRYPTED_MESSAGE) { try { await olmAPI.initializeCryptoAccount(); - const decrypted = await olmAPI.decryptSequential( + const decrypted = await olmAPI.decryptSequentialAndPersist( message.encryptedData, message.senderInfo.deviceID, messageID, diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js --- a/lib/types/crypto-types.js +++ b/lib/types/crypto-types.js @@ -147,7 +147,7 @@ +getUserPublicKey: () => Promise, +encrypt: (content: string, deviceID: string) => Promise, +decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise, - +decryptSequential: ( + +decryptSequentialAndPersist: ( encryptedData: EncryptedData, deviceID: string, messageID: string, diff --git a/lib/utils/__mocks__/config.js b/lib/utils/__mocks__/config.js --- a/lib/utils/__mocks__/config.js +++ b/lib/utils/__mocks__/config.js @@ -17,7 +17,7 @@ getUserPublicKey: jest.fn(), encrypt: jest.fn(), decrypt: jest.fn(), - decryptSequential: jest.fn(), + decryptSequentialAndPersist: jest.fn(), contentInboundSessionCreator: jest.fn(), contentOutboundSessionCreator: jest.fn(), notificationsSessionCreator: jest.fn(), 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 @@ -146,7 +146,7 @@ jsi::Runtime &rt, jsi::Object encryptedDataJSI, jsi::String deviceID) override; - virtual jsi::Value decryptSequential( + virtual jsi::Value decryptSequentialAndPersist( jsi::Runtime &rt, jsi::Object encryptedDataJSI, jsi::String deviceID, 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 @@ -1367,7 +1367,7 @@ }); } -jsi::Value CommCoreModule::decryptSequential( +jsi::Value CommCoreModule::decryptSequentialAndPersist( jsi::Runtime &rt, jsi::Object encryptedDataJSI, jsi::String deviceID, 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 @@ -120,8 +120,8 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decrypt(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->decrypt(rt, args[0].asObject(rt), args[1].asString(rt)); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequential(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->decryptSequential(rt, args[0].asObject(rt), args[1].asString(rt), args[2].asString(rt)); +static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequentialAndPersist(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->decryptSequentialAndPersist(rt, args[0].asObject(rt), args[1].asString(rt), args[2].asString(rt)); } static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_signMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->signMessage(rt, args[0].asString(rt)); @@ -246,7 +246,7 @@ methodMap_["initializeContentInboundSession"] = MethodMetadata {5, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeContentInboundSession}; methodMap_["encrypt"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_encrypt}; methodMap_["decrypt"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decrypt}; - methodMap_["decryptSequential"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequential}; + methodMap_["decryptSequentialAndPersist"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequentialAndPersist}; methodMap_["signMessage"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_signMessage}; methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion}; methodMap_["terminate"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_terminate}; 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 @@ -55,7 +55,7 @@ virtual jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::Object encryptedContent, jsi::String deviceID, double sessionVersion, bool overwrite) = 0; virtual jsi::Value encrypt(jsi::Runtime &rt, jsi::String message, jsi::String deviceID) = 0; virtual jsi::Value decrypt(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID) = 0; - virtual jsi::Value decryptSequential(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) = 0; + virtual jsi::Value decryptSequentialAndPersist(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) = 0; virtual jsi::Value signMessage(jsi::Runtime &rt, jsi::String message) = 0; virtual double getCodeVersion(jsi::Runtime &rt) = 0; virtual void terminate(jsi::Runtime &rt) = 0; @@ -384,13 +384,13 @@ return bridging::callFromJs( rt, &T::decrypt, jsInvoker_, instance_, std::move(encryptedData), std::move(deviceID)); } - jsi::Value decryptSequential(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) override { + jsi::Value decryptSequentialAndPersist(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) override { static_assert( - bridging::getParameterCount(&T::decryptSequential) == 4, - "Expected decryptSequential(...) to have 4 parameters"); + bridging::getParameterCount(&T::decryptSequentialAndPersist) == 4, + "Expected decryptSequentialAndPersist(...) to have 4 parameters"); return bridging::callFromJs( - rt, &T::decryptSequential, jsInvoker_, instance_, std::move(encryptedData), std::move(deviceID), std::move(messageID)); + rt, &T::decryptSequentialAndPersist, jsInvoker_, instance_, std::move(encryptedData), std::move(deviceID), std::move(messageID)); } jsi::Value signMessage(jsi::Runtime &rt, jsi::String message) override { static_assert( diff --git a/native/crypto/olm-api.js b/native/crypto/olm-api.js --- a/native/crypto/olm-api.js +++ b/native/crypto/olm-api.js @@ -20,7 +20,7 @@ getUserPublicKey: commCoreModule.getUserPublicKey, encrypt: commCoreModule.encrypt, decrypt: commCoreModule.decrypt, - decryptSequential: commCoreModule.decryptSequential, + decryptSequentialAndPersist: commCoreModule.decryptSequentialAndPersist, async contentInboundSessionCreator( contentIdentityKeys: OLMIdentityKeys, initialEncryptedData: EncryptedData, diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -127,7 +127,7 @@ ) => Promise; +encrypt: (message: string, deviceID: string) => Promise; +decrypt: (encryptedData: Object, deviceID: string) => Promise; - +decryptSequential: ( + +decryptSequentialAndPersist: ( encryptedData: Object, deviceID: string, messageID: string, @@ -177,7 +177,7 @@ backupID: string, ) => Promise; +decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise; - +decryptSequential: ( + +decryptSequentialAndPersist: ( encryptedData: EncryptedData, deviceID: string, messageID: string, diff --git a/web/crypto/olm-api.js b/web/crypto/olm-api.js --- a/web/crypto/olm-api.js +++ b/web/crypto/olm-api.js @@ -46,7 +46,7 @@ getUserPublicKey: proxyToWorker('getUserPublicKey'), encrypt: proxyToWorker('encrypt'), decrypt: proxyToWorker('decrypt'), - decryptSequential: proxyToWorker('decryptSequential'), + decryptSequentialAndPersist: proxyToWorker('decryptSequentialAndPersist'), contentInboundSessionCreator: proxyToWorker('contentInboundSessionCreator'), contentOutboundSessionCreator: proxyToWorker('contentOutboundSessionCreator'), notificationsSessionCreator: proxyToWorker('notificationsSessionCreator'), diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js --- a/web/shared-worker/worker/worker-crypto.js +++ b/web/shared-worker/worker/worker-crypto.js @@ -462,7 +462,7 @@ return result; }, - async decryptSequential( + async decryptSequentialAndPersist( encryptedData: EncryptedData, deviceID: string, messageID: string,