From 8fe57a323e848f2a11a52784e8095c395cdc6f4a Mon Sep 17 00:00:00 2001 From: Aryan Jassal Date: Tue, 10 Sep 2024 14:44:19 +1000 Subject: [PATCH] feat: deleted old secrets delete handlers --- src/client/callers/index.ts | 3 -- src/client/callers/vaultsSecretsDelete.ts | 12 ------ src/client/handlers/VaultsSecretsDelete.ts | 50 ---------------------- src/client/handlers/index.ts | 3 -- 4 files changed, 68 deletions(-) delete mode 100644 src/client/callers/vaultsSecretsDelete.ts delete mode 100644 src/client/handlers/VaultsSecretsDelete.ts diff --git a/src/client/callers/index.ts b/src/client/callers/index.ts index b04b29a44..c38418c2c 100644 --- a/src/client/callers/index.ts +++ b/src/client/callers/index.ts @@ -63,7 +63,6 @@ import vaultsPermissionUnset from './vaultsPermissionUnset'; import vaultsPull from './vaultsPull'; import vaultsRename from './vaultsRename'; import vaultsScan from './vaultsScan'; -import vaultsSecretsDelete from './vaultsSecretsDelete'; import vaultsSecretsEdit from './vaultsSecretsEdit'; import vaultsSecretsEnv from './vaultsSecretsEnv'; import vaultsSecretsGet from './vaultsSecretsGet'; @@ -145,7 +144,6 @@ const clientManifest = { vaultsPull, vaultsRename, vaultsScan, - vaultsSecretsDelete, vaultsSecretsEdit, vaultsSecretsEnv, vaultsSecretsGet, @@ -226,7 +224,6 @@ export { vaultsPull, vaultsRename, vaultsScan, - vaultsSecretsDelete, vaultsSecretsEdit, vaultsSecretsEnv, vaultsSecretsGet, diff --git a/src/client/callers/vaultsSecretsDelete.ts b/src/client/callers/vaultsSecretsDelete.ts deleted file mode 100644 index e6c48f188..000000000 --- a/src/client/callers/vaultsSecretsDelete.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsDelete from '../handlers/VaultsSecretsDelete'; -import { UnaryCaller } from '@matrixai/rpc'; - -type CallerTypes = HandlerTypes; - -const vaultsSecretsDelete = new UnaryCaller< - CallerTypes['input'], - CallerTypes['output'] ->(); - -export default vaultsSecretsDelete; diff --git a/src/client/handlers/VaultsSecretsDelete.ts b/src/client/handlers/VaultsSecretsDelete.ts deleted file mode 100644 index f42872a79..000000000 --- a/src/client/handlers/VaultsSecretsDelete.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { DB } from '@matrixai/db'; -import type { - ClientRPCRequestParams, - ClientRPCResponseResult, - SecretIdentifierMessage, - SuccessMessage, -} from '../types'; -import type VaultManager from '../../vaults/VaultManager'; -import { UnaryHandler } from '@matrixai/rpc'; -import * as vaultsUtils from '../../vaults/utils'; -import * as vaultsErrors from '../../vaults/errors'; -import * as vaultOps from '../../vaults/VaultOps'; - -class VaultsSecretsDelete extends UnaryHandler< - { - vaultManager: VaultManager; - db: DB; - }, - ClientRPCRequestParams, - ClientRPCResponseResult -> { - public handle = async ( - input: ClientRPCRequestParams, - ): Promise> => { - const { vaultManager, db } = this.container; - await db.withTransactionF(async (tran) => { - const vaultIdFromName = await vaultManager.getVaultId( - input.nameOrId, - tran, - ); - const vaultId = - vaultIdFromName ?? vaultsUtils.decodeVaultId(input.nameOrId); - if (vaultId == null) { - throw new vaultsErrors.ErrorVaultsVaultUndefined(); - } - await vaultManager.withVaults( - [vaultId], - async (vault) => { - await vaultOps.deleteSecret(vault, input.secretName); - }, - tran, - ); - }); - return { - success: true, - }; - }; -} - -export default VaultsSecretsDelete; diff --git a/src/client/handlers/index.ts b/src/client/handlers/index.ts index 207c2c804..43c613a7f 100644 --- a/src/client/handlers/index.ts +++ b/src/client/handlers/index.ts @@ -80,7 +80,6 @@ import VaultsPermissionUnset from './VaultsPermissionUnset'; import VaultsPull from './VaultsPull'; import VaultsRename from './VaultsRename'; import VaultsScan from './VaultsScan'; -import VaultsSecretsDelete from './VaultsSecretsDelete'; import VaultsSecretsEdit from './VaultsSecretsEdit'; import VaultsSecretsEnv from './VaultsSecretsEnv'; import VaultsSecretsGet from './VaultsSecretsGet'; @@ -185,7 +184,6 @@ const serverManifest = (container: { vaultsPull: new VaultsPull(container), vaultsRename: new VaultsRename(container), vaultsScan: new VaultsScan(container), - vaultsSecretsDelete: new VaultsSecretsDelete(container), vaultsSecretsEdit: new VaultsSecretsEdit(container), vaultsSecretsEnv: new VaultsSecretsEnv(container), vaultsSecretsGet: new VaultsSecretsGet(container), @@ -268,7 +266,6 @@ export { VaultsPull, VaultsRename, VaultsScan, - VaultsSecretsDelete, VaultsSecretsEdit, VaultsSecretsEnv, VaultsSecretsGet,