mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-30 13:03:53 +01:00
Resolve safari not checking vault timeout every 10s (#1615)
This commit is contained in:
parent
ca6078e6e8
commit
2ac9f92267
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 0951424de77fbb61a38616d13d6c67f74ee19775
|
||||
Subproject commit b0ae1bfa4cb3bc2642e1ecb14c6c1f0eceb06cb6
|
@ -19,7 +19,6 @@ import {
|
||||
TokenService,
|
||||
TotpService,
|
||||
UserService,
|
||||
VaultTimeoutService,
|
||||
} from 'jslib/services';
|
||||
import { ConsoleLogService } from 'jslib/services/consoleLog.service';
|
||||
import { EventService } from 'jslib/services/event.service';
|
||||
@ -84,6 +83,7 @@ import BrowserMessagingService from '../services/browserMessaging.service';
|
||||
import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service';
|
||||
import BrowserStorageService from '../services/browserStorage.service';
|
||||
import I18nService from '../services/i18n.service';
|
||||
import VaultTimeoutService from '../services/vaultTimeout.service';
|
||||
|
||||
import { AutofillService as AutofillServiceAbstraction } from '../services/abstractions/autofill.service';
|
||||
|
||||
|
@ -73,6 +73,11 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
|
||||
}
|
||||
}
|
||||
break
|
||||
case "sleep":
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
|
||||
context.completeRequest(returningItems: [response], completionHandler: nil)
|
||||
}
|
||||
return
|
||||
|
||||
default:
|
||||
return
|
||||
|
28
src/services/vaultTimeout.service.ts
Normal file
28
src/services/vaultTimeout.service.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { VaultTimeoutService as BaseVaultTimeoutService } from 'jslib/services/vaultTimeout.service';
|
||||
import { SafariApp } from '../browser/safariApp';
|
||||
|
||||
export default class VaultTimeoutService extends BaseVaultTimeoutService {
|
||||
|
||||
startCheck() {
|
||||
this.checkVaultTimeout();
|
||||
if (this.platformUtilsService.isSafari()) {
|
||||
this.checkSafari();
|
||||
} else {
|
||||
setInterval(() => this.checkVaultTimeout(), 10 * 1000); // check every 10 seconds
|
||||
}
|
||||
}
|
||||
|
||||
// This is a work-around to safari adding an arbitary delay to setTimeout and
|
||||
// setIntervals. It works by calling the native extension which sleeps for 10s,
|
||||
// efficiently replicating setInterval.
|
||||
async checkSafari() {
|
||||
while(true) {
|
||||
try {
|
||||
await SafariApp.sendMessageToApp('sleep');
|
||||
this.checkVaultTimeout();
|
||||
} catch(e) {
|
||||
console.log("Exception Safari VaultTimeout", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user