forked from mystiq/hydrogen-web
Only try to use window.crypto.subtle in secure contexts to avoid it throwing and stopping all JavaScript
Related to https://github.com/vector-im/hydrogen-web/issues/579 ``` Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'deriveBits') at new Crypto at new Platform at mountHydrogen ```
This commit is contained in:
parent
fc89bfdd53
commit
082d997eed
1 changed files with 4 additions and 1 deletions
|
@ -143,7 +143,10 @@ export class Platform {
|
|||
this._serviceWorkerHandler.registerAndStart(assetPaths.serviceWorker);
|
||||
}
|
||||
this.notificationService = new NotificationService(this._serviceWorkerHandler, config.push);
|
||||
this.crypto = new Crypto(cryptoExtras);
|
||||
// `window.crypto.subtle` is only available in a secure context
|
||||
if(window.isSecureContext) {
|
||||
this.crypto = new Crypto(cryptoExtras);
|
||||
}
|
||||
this.storageFactory = new StorageFactory(this._serviceWorkerHandler);
|
||||
this.sessionInfoStorage = new SessionInfoStorage("hydrogen_sessions_v1");
|
||||
this.estimateStorageUsage = estimateStorageUsage;
|
||||
|
|
Loading…
Reference in a new issue