-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix PKCE tests * Fix the storage tests * Fix the login tests * Refactor tests setup, utils/operations * Fix postMessage tests * Fix register tests * Fix fetch and interceptor * Fix remaining tests, refactor state persistance * Add some missing tests * Streamline the idb layer * Add missing state tests * Add interceptor tests * Fix some code smells * Resolve deprecation warnings
- Loading branch information
1 parent
101526c
commit 61eba68
Showing
29 changed files
with
807 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
let secret: string | null = null; | ||
const data = new Map<string, string>(); | ||
|
||
export const SECURE_KEY = 'auth-worker-state'; | ||
|
||
export function setSecret(secretPhrase: string | undefined) { | ||
secret = secretPhrase ?? null; | ||
} | ||
|
||
export function isPersistable(): boolean { | ||
return Boolean(secret); | ||
} | ||
|
||
export function setMockData(key: string, value: string): void; | ||
export function setMockData(value: string): void; | ||
export function setMockData(key: string, value?: string) { | ||
if (value === undefined) { | ||
data.set(SECURE_KEY, key); | ||
} else { | ||
data.set(key, value); | ||
} | ||
} | ||
|
||
export function clearMockData() { | ||
data.clear(); | ||
} | ||
|
||
export async function getData(key: string): Promise<string | null> { | ||
return data.get(key) ?? null; | ||
} | ||
|
||
export async function saveData(key: string, value: string) { | ||
data.set(key, value); | ||
} | ||
|
||
export async function deleteData(keys: Array<string>): Promise<void> { | ||
keys.forEach((key) => data.delete(key)); | ||
} | ||
|
||
export async function getKeys(): Promise<Array<string>> { | ||
return Array.from(data.keys()); | ||
} |
Oops, something went wrong.