From a6a602938eb2df231143502383d0dd31746b1181 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Tue, 16 Feb 2021 16:30:02 +0300 Subject: [PATCH] Add method for removing keys from keyring. --- src/app/_helpers/pgp-key-store.ts | 10 ++++++++-- src/app/_services/auth.service.ts | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/_helpers/pgp-key-store.ts b/src/app/_helpers/pgp-key-store.ts index 14d2534..d69d9b7 100644 --- a/src/app/_helpers/pgp-key-store.ts +++ b/src/app/_helpers/pgp-key-store.ts @@ -19,7 +19,8 @@ interface MutableKeyStore{ getPublicKeyForSubkeyId: (subkeyId: string) => any; getPublicKeysForAddress: (address: string) => Array; removeKeysForId: (keyId: string) => Array; - removePublicKeysForId: (keyId: string) => any; + removePublicKeyForId: (keyId: string) => any; + removePublicKey: (publicKey: any) => any; clearKeysInKeyring: () => void; // revokeKey: (publicKey) => void; } @@ -105,7 +106,12 @@ class MutablePgpKeyStore implements MutableKeyStore{ return keyring.removeKeysForId(keyId); } - removePublicKeysForId(keyId): any { + removePublicKeyForId(keyId): any { + return keyring.publicKeys.removeForId(keyId); + } + + removePublicKey(publicKey: any): any { + const keyId = publicKey.getKeyId().toHex(); return keyring.publicKeys.removeForId(keyId); } diff --git a/src/app/_services/auth.service.ts b/src/app/_services/auth.service.ts index 8373611..bbcf42f 100644 --- a/src/app/_services/auth.service.ts +++ b/src/app/_services/auth.service.ts @@ -4,7 +4,6 @@ import { hobaParseChallengeHeader } from '@src/assets/js/hoba.js'; import { signChallenge } from '@src/assets/js/hoba-pgp.js'; import {environment} from '@src/environments/environment'; import {HttpClient} from '@angular/common/http'; -const openpgp = require('openpgp'); const origin = 'http://localhost:4444'; const pgpKeyStore = new UnsafeKeyStore();