Skip to content

Commit

Permalink
[lib][web][native] rename SESSION_DOES_NOT_EXISTS -> `SESSION_DOES_…
Browse files Browse the repository at this point in the history
…NOT_EXIST`

Summary: https://phab.comm.dev/D13025#inline-75566

Test Plan: Build app, Flow, search for usage of `SESSION_DOES_NOT_EXISTS` and `sessionDoesNotExists` to make sure all are removed

Reviewers: tomek, marcin

Reviewed By: tomek

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D13171
  • Loading branch information
xsanm committed Sep 6, 2024
1 parent 38e054c commit 309ecba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/tunnelbroker/peer-to-peer-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async function processOutboundP2PMessages(
};
await sendMessageToPeer(encryptedMessage);
} catch (e) {
if (!e.message?.includes(olmSessionErrors.sessionDoesNotExists)) {
if (!e.message?.includes(olmSessionErrors.sessionDoesNotExist)) {
console.log(`Error sending messages to peer ${peerDeviceID}`, e);
break;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ function PeerToPeerProvider(props: Props): React.Node {
payload: JSON.stringify(encryptedMessage),
});
} catch (e) {
if (!e.message?.includes(olmSessionErrors.sessionDoesNotExists)) {
if (!e.message?.includes(olmSessionErrors.sessionDoesNotExist)) {
console.log(
`Error sending messages to peer ${recipient.deviceID}`,
e,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/olm-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const olmSessionErrors = Object.freeze({
// This definition should remain in sync with the value defined in
// the corresponding .cpp file
// at `native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp`.
sessionDoesNotExists: 'SESSION_DOES_NOT_EXISTS',
sessionDoesNotExist: 'SESSION_DOES_NOT_EXIST',
// Error thrown when attempting to decrypt a message encrypted
// with an already replaced old session.
// This definition should remain in sync with the value defined in
Expand Down
6 changes: 3 additions & 3 deletions native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace crypto {

// This definition should remain in sync with the value defined in
// the corresponding JavaScript file at `lib/utils/olm-utils.js`.
const std::string SESSION_DOES_NOT_EXISTS_ERROR{"SESSION_DOES_NOT_EXISTS"};
const std::string SESSION_DOES_NOT_EXIST_ERROR{"SESSION_DOES_NOT_EXIST"};
const std::string INVALID_SESSION_VERSION_ERROR{"INVALID_SESSION_VERSION"};

CryptoModule::CryptoModule(std::string id) : id{id} {
Expand Down Expand Up @@ -386,7 +386,7 @@ EncryptedData CryptoModule::encrypt(
const std::string &targetDeviceId,
const std::string &content) {
if (!this->hasSessionFor(targetDeviceId)) {
throw std::runtime_error{SESSION_DOES_NOT_EXISTS_ERROR};
throw std::runtime_error{SESSION_DOES_NOT_EXIST_ERROR};
}
return this->sessions.at(targetDeviceId)->encrypt(content);
}
Expand All @@ -395,7 +395,7 @@ std::string CryptoModule::decrypt(
const std::string &targetDeviceId,
EncryptedData &encryptedData) {
if (!this->hasSessionFor(targetDeviceId)) {
throw std::runtime_error{SESSION_DOES_NOT_EXISTS_ERROR};
throw std::runtime_error{SESSION_DOES_NOT_EXIST_ERROR};
}
auto session = this->sessions.at(targetDeviceId);
if (encryptedData.sessionVersion.has_value() &&
Expand Down
8 changes: 4 additions & 4 deletions web/shared-worker/worker/worker-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ const olmAPI: OlmAPI = {
}
const olmSession = cryptoStore.contentSessions[deviceID];
if (!olmSession) {
throw new Error(olmSessionErrors.sessionDoesNotExists);
throw new Error(olmSessionErrors.sessionDoesNotExist);
}
const encryptedContent = olmSession.session.encrypt(content);

Expand All @@ -577,7 +577,7 @@ const olmAPI: OlmAPI = {
}
const olmSession = cryptoStore.contentSessions[deviceID];
if (!olmSession) {
throw new Error(olmSessionErrors.sessionDoesNotExists);
throw new Error(olmSessionErrors.sessionDoesNotExist);
}

const encryptedContent = olmSession.session.encrypt(content);
Expand Down Expand Up @@ -632,7 +632,7 @@ const olmAPI: OlmAPI = {

const olmSession = cryptoStore.contentSessions[deviceID];
if (!olmSession) {
throw new Error(olmSessionErrors.sessionDoesNotExists);
throw new Error(olmSessionErrors.sessionDoesNotExist);
}

if (
Expand Down Expand Up @@ -663,7 +663,7 @@ const olmAPI: OlmAPI = {

const olmSession = cryptoStore.contentSessions[deviceID];
if (!olmSession) {
throw new Error(olmSessionErrors.sessionDoesNotExists);
throw new Error(olmSessionErrors.sessionDoesNotExist);
}

if (
Expand Down

0 comments on commit 309ecba

Please sign in to comment.