Extract functions for service worker usage, and add initial MSC3916 playwright test (when supported) (#12414)
* Send user credentials to service worker for MSC3916 authentication * appease linter * Add initial test The test fails, seemingly because the service worker isn't being installed or because the network mock can't reach that far. * Remove unsafe access token code * Split out base IDB operations to avoid importing `document` in serviceworkers * Use safe crypto access for service workers * Fix tests/unsafe access * Remove backwards compatibility layer & appease linter * Add docs * Fix tests * Appease the linter * Iterate tests * Factor out pickle key handling for service workers * Enable everything we can about service workers * Appease the linter * Add docs * Rename win32 image to linux in hopes of it just working * Use actual image * Apply suggestions from code review Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Improve documentation * Document `??` not working * Try to appease the tests * Add some notes --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
parent
374cee9080
commit
d25d529e86
12 changed files with 435 additions and 176 deletions
|
@ -37,6 +37,7 @@ import ActiveWidgetStore from "./stores/ActiveWidgetStore";
|
|||
import PlatformPeg from "./PlatformPeg";
|
||||
import { sendLoginRequest } from "./Login";
|
||||
import * as StorageManager from "./utils/StorageManager";
|
||||
import * as StorageAccess from "./utils/StorageAccess";
|
||||
import SettingsStore from "./settings/SettingsStore";
|
||||
import { SettingLevel } from "./settings/SettingLevel";
|
||||
import ToastStore from "./stores/ToastStore";
|
||||
|
@ -493,7 +494,7 @@ export interface IStoredSession {
|
|||
async function getStoredToken(storageKey: string): Promise<string | undefined> {
|
||||
let token: string | undefined;
|
||||
try {
|
||||
token = await StorageManager.idbLoad("account", storageKey);
|
||||
token = await StorageAccess.idbLoad("account", storageKey);
|
||||
} catch (e) {
|
||||
logger.error(`StorageManager.idbLoad failed for account:${storageKey}`, e);
|
||||
}
|
||||
|
@ -502,7 +503,7 @@ async function getStoredToken(storageKey: string): Promise<string | undefined> {
|
|||
if (token) {
|
||||
try {
|
||||
// try to migrate access token to IndexedDB if we can
|
||||
await StorageManager.idbSave("account", storageKey, token);
|
||||
await StorageAccess.idbSave("account", storageKey, token);
|
||||
localStorage.removeItem(storageKey);
|
||||
} catch (e) {
|
||||
logger.error(`migration of token ${storageKey} to IndexedDB failed`, e);
|
||||
|
@ -1064,7 +1065,7 @@ async function clearStorage(opts?: { deleteEverything?: boolean }): Promise<void
|
|||
AbstractLocalStorageSettingsHandler.clear();
|
||||
|
||||
try {
|
||||
await StorageManager.idbDelete("account", ACCESS_TOKEN_STORAGE_KEY);
|
||||
await StorageAccess.idbDelete("account", ACCESS_TOKEN_STORAGE_KEY);
|
||||
} catch (e) {
|
||||
logger.error("idbDelete failed for account:mx_access_token", e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue