Skip to content

Commit

Permalink
fix: expand header message out of the function
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanjassal committed Dec 6, 2024
1 parent 9ff1390 commit 2f0c2be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/client/handlers/VaultsSecretsCat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VaultsSecretsCat extends DuplexHandler<
ClientRPCResponseResult<ContentOrErrorMessage>
> {
public handle = async function* (
input: AsyncIterable<ClientRPCRequestParams<SecretIdentifierMessage>>,
input: AsyncIterableIterator<ClientRPCRequestParams<SecretIdentifierMessage>>,
): AsyncGenerator<ClientRPCResponseResult<ContentOrErrorMessage>> {
const { db, vaultManager }: { db: DB; vaultManager: VaultManager } =
this.container;
Expand Down
4 changes: 2 additions & 2 deletions src/client/handlers/VaultsSecretsEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DuplexHandler } from '@matrixai/rpc';
import * as vaultsUtils from '../../vaults/utils';
import * as vaultsErrors from '../../vaults/errors';

class VaultsSecretsList extends DuplexHandler<
class VaultsSecretsEnv extends DuplexHandler<
{
db: DB;
vaultManager: VaultManager;
Expand Down Expand Up @@ -86,4 +86,4 @@ class VaultsSecretsList extends DuplexHandler<
};
}

export default VaultsSecretsList;
export default VaultsSecretsEnv;
2 changes: 1 addition & 1 deletion src/client/handlers/VaultsSecretsMkdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VaultsSecretsMkdir extends DuplexHandler<
ClientRPCResponseResult<SuccessOrErrorMessage>
> {
public handle = async function* (
input: AsyncIterable<ClientRPCRequestParams<SecretDirMessage>>,
input: AsyncIterableIterator<ClientRPCRequestParams<SecretDirMessage>>,
): AsyncGenerator<ClientRPCResponseResult<SuccessOrErrorMessage>> {
const { db, vaultManager }: { db: DB; vaultManager: VaultManager } =
this.container;
Expand Down
21 changes: 11 additions & 10 deletions src/client/handlers/VaultsSecretsRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ class VaultsSecretsRemove extends DuplexHandler<
): AsyncGenerator<ClientRPCResponseResult<SuccessOrErrorMessage>> {
const { db, vaultManager }: { db: DB; vaultManager: VaultManager } =
this.container;
// Extracts the header message from the iterator
const headerMessage = await (async () => {
const header: SecretsRemoveHeaderMessage | SecretIdentifierMessageTagged =
(await input.next()).value;
if (header == null || header.type !== 'VaultNamesHeaderMessage') {
throw new clientErrors.ErrorClientInvalidHeader();
}
return header;
})();
// Extract the header message from the iterator
const headerMessage:
| SecretsRemoveHeaderMessage
| SecretIdentifierMessageTagged = (await input.next()).value;
if (
headerMessage == null ||
headerMessage.type !== 'VaultNamesHeaderMessage'
) {
throw new clientErrors.ErrorClientInvalidHeader();
}
// Create an array of write acquires
const vaultAcquires = await db.withTransactionF(async (tran) => {
const vaultAcquires: Array<ResourceAcquire<FileSystemWritable>> = [];
Expand Down Expand Up @@ -103,7 +104,7 @@ class VaultsSecretsRemove extends DuplexHandler<
e.code === 'ENOTEMPTY' ||
e.code === 'EINVAL'
) {
// INVAL can be triggered if removing the root of the
// EINVAL can be triggered if removing the root of the
// vault is attempted.
yield {
type: 'error',
Expand Down

0 comments on commit 2f0c2be

Please sign in to comment.