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

Update E2E encryption support docs #2275

Closed

Conversation

Alendia
Copy link

@Alendia Alendia commented Apr 4, 2022

This PR updates the e2e encryption part in README. Issues #731, #1767 and #2205 describe problems when adding e2e encryption support. This change provides the detailed and latest information referred by SDK specification and Olm repository.


This PR currently has no changelog labels, so will not be included in changelogs.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

@Alendia Alendia requested a review from a team as a code owner April 4, 2022 14:04
Copy link

@kaddour-youcef kaddour-youcef left a comment

Choose a reason for hiding this comment

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

This is good, too bad i did not see it before passing a night to figure it out my self

Comment on lines -337 to +335
If you want to package Olm as dependency for your node.js application, you can
use ``yarn add https://packages.matrix.org/npm/olm/olm-3.1.4.tgz``. If your
application also works without e2e crypto enabled, add ``--optional`` to mark it
If your application also works without e2e crypto enabled, add ``--optional`` to mark it
Copy link
Member

Choose a reason for hiding this comment

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

Keeping the detail about nodejs would be appreciated, as it's not really practical to have optional dependencies in web apps.

Copy link
Author

Choose a reason for hiding this comment

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

It seems that I misunderstand the original text's meaning. I will fix it later.

as an optional dependency.

Besides Olm, you need to configure some options when `createClient()` . These three options are required for enabling e2e crypto: `sessionStore` , `cryptoStore` and `deviceId` .
Copy link
Member

Choose a reason for hiding this comment

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

Not really sure what's going on with the punctuation here

Suggested change
Besides Olm, you need to configure some options when `createClient()` . These three options are required for enabling e2e crypto: `sessionStore` , `cryptoStore` and `deviceId` .
Besides Olm, you need to configure some options when `createClient()`. These three options are required for enabling e2e crypto: `sessionStore` , `cryptoStore` and `deviceId`.

Copy link
Member

Choose a reason for hiding this comment

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

this could also be put into the example later on as a comment. For example:

const matrixClient = sdk.createClient({
    // Example construction of the client
    baseUrl: "http://localhost:8008",
    accessToken: myAccessToken,
    sessionStore: new sdk.WebStorageSessionStore(localStorage),

    // Values required for crypto to work
    userId: myUserId,
    deviceId: myDeviceId,
    cryptoStore: new sdk.MemoryCryptoStore(),
});

Comment on lines +340 to +354
For `sessionStore`, you need to provide a `WebStorageSessionStore` instance.

To instantiate `WebStorageSessionStore` in a browser application:

Choose from `window.sessionStorage` and `window.localStorage` to instantiate `WebStorageSessionStore`:

- `sessionStore: new sdk.WebStorageSessionStore(localStorage)`

To instantiate `WebStorageSessionStore` in a node.js application:

The SDK does not provide an alternative solution for node.js application to store encrypted information with `WebStorageSessionStore`, but you can import a third-party npm package to mimic Web Storage API that runs on node.js like `node-localstorage` or implement your own`Storage` Object. The SDK specification requires a `Storage` implementation with `key`,`getItem`,`setItem`,`removeItem` and `length` method. The `Storage` Object can store data as a file or a local database.

If you are still confused about mimicking Web Storage API, check out the `node-localstorage` solution provided by [this issue](https://github.com/matrix-org/matrix-js-sdk/issues/731#issuecomment-745344192).

- `sessionStore: new sdk.WebStorageSessionStore(yourStorage)`
Copy link
Member

Choose a reason for hiding this comment

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

I think all of this about WebStorageSessionStore should be moved into the jsdoc for the class/property where it should be more discoverable for people.

Comment on lines +356 to +358
For `cryptoStore`, you need to instantiate it with `IndexedDBCryptoStore`, `LocalStorageCryptoStore ` or `MemoryCryptoStore`. (choose according to your environment).

- `cryptoStore: new sdk.MemoryCryptoStore()`
Copy link
Member

Choose a reason for hiding this comment

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

This is also best as jsdoc

Comment on lines +362 to +371
```javascript
const matrixClient = sdk.createClient({
baseUrl: "http://localhost:8008",
accessToken: myAccessToken,
userId: myUserId,
sessionStore: new sdk.WebStorageSessionStore(localStorage),
cryptoStore: new sdk.MemoryCryptoStore(),
deviceId: myDeviceId,
});
```
Copy link
Member

Choose a reason for hiding this comment

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

not sure what the spacing is on this, but the const level should be at zero spaces indent and the properties of the supplied object be at 4 spaces please.

Copy link
Author

Choose a reason for hiding this comment

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

It is because the code above in README uses 4 spaces. This code snippet is a part of that uses 4 spaces, so I use 4 spaces here.


To instantiate `WebStorageSessionStore` in a node.js application:

The SDK does not provide an alternative solution for node.js application to store encrypted information with `WebStorageSessionStore`, but you can import a third-party npm package to mimic Web Storage API that runs on node.js like `node-localstorage` or implement your own`Storage` Object. The SDK specification requires a `Storage` implementation with `key`,`getItem`,`setItem`,`removeItem` and `length` method. The `Storage` Object can store data as a file or a local database.
Copy link
Member

Choose a reason for hiding this comment

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

Please match the column limit for the existing file as close as possible.

@MadLittleMods MadLittleMods added the Z-Community-PR Issue is solved by a community member's PR label Jun 2, 2022
@t3chguy
Copy link
Member

t3chguy commented Jul 20, 2023

Closing as abandoned

@t3chguy t3chguy closed this Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants