Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: Replace cryptoMode with DeviceIsolationMode concept #4429

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Sep 24, 2024

Fixes #4428

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

*/
Transition,
public errorOnVerifiedUserProblems: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is not used yet in this PR. It is used for encrypting. Added here to showcase that IsolationMode is not just an enum but need more information

case CryptoMode.Transition:

switch (isolationMode.kind) {
case "OnlySignedIsolation":
trustRequirement = RustSdkCryptoJs.TrustRequirement.CrossSignedOrLegacy;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CrossSignedOrLegacy is the mode that we want. CrossSigned only would be for a more extreme mode that we don't have yet.

@richvdh

This comment was marked as resolved.

@richvdh richvdh self-requested a review September 24, 2024 15:53
src/crypto-api/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good in principle. I have a few thoughts on cleaning up the declaration -- hope they make sense.

src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
* Events are decrypted only if they come from a cross-signed device other events will result in a decryption
* failure. (To access the failure reason, see {@link MatrixEvent.decryptionFailureReason}.)
*/
export class OnlySignedIsolation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about calling this OnlySignedDeviceIsolationMode ? I know it's a bit of a long name but I feel it gives a better indication of what it does.

(And... NoIsolationDeviceIsolationMode ?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the name very long and strange (NoIsolationIsolationMode).
What about namespaces? First time I see that, but would allow to do new DeviceIsolationMode.OnlySigned() so it's a clear indication that these are DeviceIsolationMode without the need of bigger name, also easy to discover?

export namespace DeviceIsolationMode {
    export class None {..}
    export class OnlySigned {..}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my monologue in #element-dev:matrix.org, I'm not enthusiastic about namespaces, because they seem to be deprecated (and we have a lint rule that enforces that we don't use them).

Copy link
Member

@richvdh richvdh Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't find NoIsolationIsolationMode that bad, but I agree it's hardly elegant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnlySignedDevicesIsolationMode and AllDevicesIsolationMode ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed as per andy suggestion, also renamed the DeviceIsolationModeKind enum to still match classes names 20f5882

src/crypto-api/index.ts Outdated Show resolved Hide resolved
src/crypto-api/index.ts Show resolved Hide resolved
src/crypto-api/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BillCarsonFr BillCarsonFr added this pull request to the merge queue Sep 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 25, 2024
@BillCarsonFr BillCarsonFr added this pull request to the merge queue Sep 25, 2024
Merged via the queue into develop with commit 538717c Sep 25, 2024
26 checks passed
@BillCarsonFr BillCarsonFr deleted the valere/rename_crypto_mode branch September 25, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invisible crypto: revisit CryptoMode concept
4 participants