mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 04:06:44 +02:00
Fix types
This commit is contained in:
parent
4b56f3b1ca
commit
c9a53ba25d
@ -6,7 +6,7 @@
|
||||
[](https://sonarcloud.io/summary/new_code?id=element-desktop)
|
||||
|
||||
# Element Desktop
|
||||
|
||||
x
|
||||
Element Desktop is a Matrix client for desktop platforms with Element Web at its core.
|
||||
|
||||
# First Steps
|
||||
|
||||
@ -43,7 +43,7 @@ const seshatDefaultPassphrase = "DEFAULT_PASSPHRASE";
|
||||
async function getOrCreatePassphrase(store: Store, key: string): Promise<string> {
|
||||
try {
|
||||
const storedPassphrase = await store.getSecret(key);
|
||||
if (storedPassphrase !== null) {
|
||||
if (storedPassphrase !== undefined) {
|
||||
return storedPassphrase;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
12
src/store.ts
12
src/store.ts
@ -105,7 +105,7 @@ class StorageWriter {
|
||||
this.store.set(this.getKey(key), secret);
|
||||
}
|
||||
|
||||
public get(key: string): string | null {
|
||||
public get(key: string): string | undefined {
|
||||
return this.store.get(this.getKey(key));
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class SafeStorageWriter extends StorageWriter {
|
||||
this.store.set(this.getKey(key), safeStorage.encryptString(secret).toString("base64"));
|
||||
}
|
||||
|
||||
public get(key: string): string | null {
|
||||
public get(key: string): string | undefined {
|
||||
const ciphertext = this.store.get<string, string | undefined>(this.getKey(key));
|
||||
if (ciphertext) {
|
||||
try {
|
||||
@ -132,7 +132,7 @@ class SafeStorageWriter extends StorageWriter {
|
||||
console.error("...ciphertext:", JSON.stringify(ciphertext));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ class Store extends ElectronStore<StoreData> {
|
||||
*
|
||||
* @returns A promise for the secret string.
|
||||
*/
|
||||
public async getSecret(key: string): Promise<string | null> {
|
||||
public async getSecret(key: string): Promise<string | undefined> {
|
||||
await this.safeStorageReady();
|
||||
let secret = this.secrets!.get(key);
|
||||
if (secret) return secret;
|
||||
@ -518,9 +518,9 @@ class Store extends ElectronStore<StoreData> {
|
||||
/**
|
||||
* @deprecated will be removed in the near future
|
||||
*/
|
||||
private async getSecretKeytar(key: string): Promise<string | null> {
|
||||
private async getSecretKeytar(key: string): Promise<string | undefined> {
|
||||
return (
|
||||
(await keytar.getPassword(KEYTAR_SERVICE, key)) ?? (await keytar.getPassword(LEGACY_KEYTAR_SERVICE, key))
|
||||
(await keytar.getPassword(KEYTAR_SERVICE, key)) ?? (await keytar.getPassword(LEGACY_KEYTAR_SERVICE, key) ?? undefined)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user