Browse Source

Handle falsy values in keytarSecureStorageService (#286)

pull/287/head
Thomas Rittson 3 years ago committed by GitHub
parent
commit
f1b533f7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .github/workflows/build.yml
  2. 6
      src/services/keytarSecureStorage.service.ts

1
.github/workflows/build.yml

@ -101,6 +101,7 @@ jobs: @@ -101,6 +101,7 @@ jobs:
- name: Version Test
run: |
sudo apt-get update
sudo apt install libsecret-1-0 dbus-x11 gnome-keyring
eval $(dbus-launch --sh-syntax)

6
src/services/keytarSecureStorage.service.ts

@ -16,6 +16,12 @@ export class KeytarSecureStorageService implements StorageService { @@ -16,6 +16,12 @@ export class KeytarSecureStorageService implements StorageService {
}
save(key: string, obj: any): Promise<any> {
// keytar throws if you try to save a falsy value: https://github.com/atom/node-keytar/issues/86
// handle this by removing the key instead
if (!obj) {
return this.remove(key);
}
return setPassword(this.serviceName, key, JSON.stringify(obj));
}

Loading…
Cancel
Save