-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Conversation
There was a problem hiding this 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
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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` . |
There was a problem hiding this comment.
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
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`. |
There was a problem hiding this comment.
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(),
});
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)` |
There was a problem hiding this comment.
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.
For `cryptoStore`, you need to instantiate it with `IndexedDBCryptoStore`, `LocalStorageCryptoStore ` or `MemoryCryptoStore`. (choose according to your environment). | ||
|
||
- `cryptoStore: new sdk.MemoryCryptoStore()` |
There was a problem hiding this comment.
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
```javascript | ||
const matrixClient = sdk.createClient({ | ||
baseUrl: "http://localhost:8008", | ||
accessToken: myAccessToken, | ||
userId: myUserId, | ||
sessionStore: new sdk.WebStorageSessionStore(localStorage), | ||
cryptoStore: new sdk.MemoryCryptoStore(), | ||
deviceId: myDeviceId, | ||
}); | ||
``` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
Closing as abandoned |
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 addType: [enhancement/defect/task]
to the description and I'll add them for you.