Only initialize Crypto when olm is provided

See https://github.com/vector-im/hydrogen-web/pull/691#discussion_r816988082
This commit is contained in:
Eric Eastwood 2022-03-02 03:17:59 -06:00
parent 0935f2d23a
commit 2f4c639cef

View file

@ -143,8 +143,8 @@ export class Platform {
this._serviceWorkerHandler.registerAndStart(assetPaths.serviceWorker);
}
this.notificationService = new NotificationService(this._serviceWorkerHandler, config.push);
// `window.crypto.subtle` is only available in a secure context
if(window.isSecureContext) {
// Only try to use crypto when olm is provided
if(this._assetPaths.olm) {
this.crypto = new Crypto(cryptoExtras);
}
this.storageFactory = new StorageFactory(this._serviceWorkerHandler);