-
-
Notifications
You must be signed in to change notification settings - Fork 585
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 to WebAssembly-powered Olm #743
Changes from 6 commits
c556ca4
63cc3fd
33ad65a
9504cbc
35d584c
5873db7
b9e198c
84b91d4
3a316de
d29ac08
4b9c6e6
59070c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
|
||
"use strict"; | ||
import 'source-map-support/register'; | ||
import Crypto from '../../lib/crypto'; | ||
import expect from 'expect'; | ||
|
||
const sdk = require("../.."); | ||
let Crypto; | ||
if (sdk.CRYPTO_ENABLED) { | ||
Crypto = require("../../lib/crypto"); | ||
} | ||
|
||
import expect from 'expect'; | ||
const Olm = global.Olm; | ||
|
||
describe("Crypto", function() { | ||
if (!sdk.CRYPTO_ENABLED) { | ||
return; | ||
} | ||
|
||
beforeEach(function(done) { | ||
Olm.init().then(done); | ||
}); | ||
|
||
it("Crypto exposes the correct olm library version", function() { | ||
console.log(Crypto); | ||
expect(Crypto.getOlmVersion()[0]).toEqual(2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will need to |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ const DeviceList = require('./DeviceList').default; | |
import OutgoingRoomKeyRequestManager from './OutgoingRoomKeyRequestManager'; | ||
import IndexedDBCryptoStore from './store/indexeddb-crypto-store'; | ||
|
||
export function isCryptoAvailable() { | ||
return Boolean(global.Olm); | ||
} | ||
|
||
/** | ||
* Cryptography bits | ||
* | ||
|
@@ -62,7 +66,7 @@ import IndexedDBCryptoStore from './store/indexeddb-crypto-store'; | |
* | ||
* @param {RoomList} roomList An initialised RoomList object | ||
*/ | ||
function Crypto(baseApis, sessionStore, userId, deviceId, | ||
export default function Crypto(baseApis, sessionStore, userId, deviceId, | ||
clientStore, cryptoStore, roomList) { | ||
this._baseApis = baseApis; | ||
this._sessionStore = sessionStore; | ||
|
@@ -124,6 +128,8 @@ utils.inherits(Crypto, EventEmitter); | |
* Returns a promise which resolves once the crypto module is ready for use. | ||
*/ | ||
Crypto.prototype.init = async function() { | ||
await global.Olm.init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we wrapped this in an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm - probably. Not sure whether or not its worth trying. |
||
|
||
const sessionStoreHasAccount = Boolean(this._sessionStore.getEndToEndAccount()); | ||
let cryptoStoreHasAccount; | ||
await this._cryptoStore.doTxn( | ||
|
@@ -1518,6 +1524,3 @@ class IncomingRoomKeyRequestCancellation { | |
* @event module:client~MatrixClient#"crypto.warning" | ||
* @param {string} type One of the strings listed above | ||
*/ | ||
|
||
/** */ | ||
module.exports = Crypto; |
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.
debugging line should be taken out