Skip to content

Commit

Permalink
feat: VaultsSecretsMkdir now supports specifying multiple secret paths
Browse files Browse the repository at this point in the history
chore: undid changes to vaultOps.mkdir

chore: working on continuing on errors

chore: still trying to return errors

chore: properly checking errors throws it

feat: updated tests for VaultsSecretsMkdir

chore: merged makeDirectories into mkdir

chore: updated tests for vaultOps.mkdir

fix: removed redundant comments

chore: simplified RPC handler

chore: updated metadata types

chore: added error type for mkdir

chore: updated SuccessMessage type

chore: updated all handlers to be consistent with container deconstruction

fix: lint

chore: simplified mkdir vaultop

chore: using type narrowing instead of using 'as'

chore: updated metadata types
  • Loading branch information
aryanjassal committed Oct 14, 2024
1 parent ab66636 commit 37c1d36
Show file tree
Hide file tree
Showing 80 changed files with 563 additions and 332 deletions.
4 changes: 2 additions & 2 deletions src/client/callers/vaultsSecretsMkdir.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { HandlerTypes } from '@matrixai/rpc';
import type VaultsSecretsMkdir from '../handlers/VaultsSecretsMkdir';
import { UnaryCaller } from '@matrixai/rpc';
import { DuplexCaller } from '@matrixai/rpc';

type CallerTypes = HandlerTypes<VaultsSecretsMkdir>;

const vaultsSecretsMkdir = new UnaryCaller<
const vaultsSecretsMkdir = new DuplexCaller<
CallerTypes['input'],
CallerTypes['output']
>();
Expand Down
3 changes: 2 additions & 1 deletion src/client/handlers/AgentLockAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class AgentLockAll extends UnaryHandler<
ClientRPCResponseResult
> {
public handle = async (): Promise<ClientRPCResponseResult> => {
const { db, sessionManager } = this.container;
const { db, sessionManager }: { db: DB; sessionManager: SessionManager } =
this.container;
await db.withTransactionF((tran) => sessionManager.resetKey(tran));
return {};
};
Expand Down
2 changes: 1 addition & 1 deletion src/client/handlers/AgentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AgentStatus extends UnaryHandler<
public handle = async (): Promise<
ClientRPCResponseResult<StatusResultMessage>
> => {
const { polykeyAgent } = this.container;
const { polykeyAgent }: { polykeyAgent: PolykeyAgent } = this.container;
return {
pid: process.pid,
nodeIdEncoded: nodesUtils.encodeNodeId(polykeyAgent.keyRing.getNodeId()),
Expand Down
2 changes: 1 addition & 1 deletion src/client/handlers/AgentStop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AgentStop extends UnaryHandler<
ClientRPCResponseResult
> {
public handle = async (): Promise<ClientRPCResponseResult> => {
const { polykeyAgent } = this.container;
const { polykeyAgent }: { polykeyAgent: PolykeyAgent } = this.container;
// If not running or in stopping status, then respond successfully
if (!polykeyAgent[running] || polykeyAgent[status] === 'stopping') {
return {};
Expand Down
6 changes: 3 additions & 3 deletions src/client/handlers/AuditEventsGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AuditEventsGet extends ServerHandler<
}>,
ClientRPCResponseResult<AuditEventSerialized>
> {
public async *handle(
public handle = async function* (
{
paths,
seek,
Expand All @@ -46,7 +46,7 @@ class AuditEventsGet extends ServerHandler<
_meta,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<AuditEventSerialized>> {
const { audit } = this.container;
const { audit }: { audit: Audit } = this.container;
const iterators: Array<AsyncGenerator<AuditEvent>> = [];
let seek_: AuditEventId | number | undefined;
if (seek != null) {
Expand Down Expand Up @@ -109,7 +109,7 @@ class AuditEventsGet extends ServerHandler<
data: auditEvent.data,
};
}
}
};
}

export default AuditEventsGet;
2 changes: 1 addition & 1 deletion src/client/handlers/AuditMetricGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AuditMetricGet extends UnaryHandler<
_meta,
_ctx,
): Promise<ClientRPCResponseResult<MetricPathToAuditMetric<T>>> => {
const { audit } = this.container;
const { audit }: { audit: Audit } = this.container;
let seek_: AuditEventId | number | undefined;
if (seek != null) {
seek_ =
Expand Down
3 changes: 2 additions & 1 deletion src/client/handlers/GestaltsActionsGetByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class GestaltsActionsGetByIdentity extends UnaryHandler<
actionsList: Array<GestaltAction>;
}>
> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const {
providerId,
identityId,
Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsActionsGetByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsActionsGetByNode extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<NodeIdMessage>,
ClientRPCResponseResult<ActionsListMessage>
> {
public handle = async (
input: ClientRPCRequestParams<NodeIdMessage>,
): Promise<ClientRPCResponseResult<ActionsListMessage>> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const { nodeId }: { nodeId: NodeId } = validateSync(
(keyPath, value) => {
return matchSync(keyPath)(
Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsActionsSetByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsActionsSetByIdentityHandler extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<SetIdentityActionMessage>,
ClientRPCResponseResult
> {
public handle = async (
input: ClientRPCRequestParams<SetIdentityActionMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const {
action,
providerId,
Expand Down
3 changes: 2 additions & 1 deletion src/client/handlers/GestaltsActionsSetByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class GestaltsActionsSetByNode extends UnaryHandler<
public handle = async (
input: ClientRPCRequestParams<SetNodeActionMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const { nodeId, action }: { nodeId: NodeId; action: GestaltAction } =
validateSync(
(keyPath, value) => {
Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsActionsUnsetByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsActionsUnsetByIdentity extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<SetIdentityActionMessage>,
ClientRPCResponseResult
> {
public handle = async (
input: ClientRPCRequestParams<SetIdentityActionMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const {
action,
providerId,
Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsActionsUnsetByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsActionsUnsetByNode extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<SetNodeActionMessage>,
ClientRPCResponseResult
> {
public handle = async (
input: ClientRPCRequestParams<SetNodeActionMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const { nodeId, action }: { nodeId: NodeId; action: GestaltAction } =
validateSync(
(keyPath, value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/handlers/GestaltsDiscoveryByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GestaltsDiscoveryByIdentity extends UnaryHandler<
public handle = async (
input: ClientRPCRequestParams<IdentityMessage>,
): Promise<ClientRPCResponseResult> => {
const { discovery } = this.container;
const { discovery }: { discovery: Discovery } = this.container;
const {
providerId,
identityId,
Expand Down
2 changes: 1 addition & 1 deletion src/client/handlers/GestaltsDiscoveryByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GestaltsDiscoveryByNode extends UnaryHandler<
public handle = async (
input: ClientRPCRequestParams<NodeIdMessage>,
): Promise<ClientRPCResponseResult> => {
const { discovery } = this.container;
const { discovery }: { discovery: Discovery } = this.container;
const { nodeId }: { nodeId: NodeId } = validateSync(
(keyPath, value) => {
return matchSync(keyPath)(
Expand Down
6 changes: 3 additions & 3 deletions src/client/handlers/GestaltsDiscoveryQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ class GestaltsDiscoveryQueue extends ServerHandler<
ClientRPCRequestParams,
ClientRPCResponseResult<DiscoveryQueueInfo>
> {
public async *handle(
public handle = async function* (
_input: ClientRPCRequestParams,
_cancel,
_meta,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<DiscoveryQueueInfo>> {
const { discovery } = this.container;
const { discovery }: { discovery: Discovery } = this.container;
for await (const discoveryQueueInfo of discovery.getDiscoveryQueue()) {
ctx.signal.throwIfAborted();
yield discoveryQueueInfo;
}
}
};
}

export default GestaltsDiscoveryQueue;
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsGestaltGetByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsGestaltGetByIdentity extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<IdentityMessage>,
ClientRPCResponseResult<GestaltMessage>
> {
public handle = async (
input: ClientRPCRequestParams<IdentityMessage>,
): Promise<ClientRPCResponseResult<GestaltMessage>> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const {
providerId,
identityId,
Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/GestaltsGestaltGetByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import { matchSync } from '../../utils';

class GestaltsGestaltGetByNode extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams<NodeIdMessage>,
ClientRPCResponseResult<GestaltMessage>
> {
public handle = async (
input: ClientRPCRequestParams<NodeIdMessage>,
): Promise<ClientRPCResponseResult<GestaltMessage>> => {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
const { nodeId }: { nodeId: NodeId } = validateSync(
(keyPath, value) => {
return matchSync(keyPath)(
Expand Down
9 changes: 5 additions & 4 deletions src/client/handlers/GestaltsGestaltList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ import * as nodesUtils from '../../nodes/utils';

class GestaltsGestaltList extends ServerHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
},
ClientRPCRequestParams,
ClientRPCResponseResult<GestaltMessage>
> {
public async *handle(
public handle = async function* (
_input,
_cancel,
_meta,
ctx,
): AsyncGenerator<ClientRPCResponseResult<GestaltMessage>> {
const { db, gestaltGraph } = this.container;
const { db, gestaltGraph }: { db: DB; gestaltGraph: GestaltGraph } =
this.container;
yield* db.withTransactionG(async function* (tran): AsyncGenerator<
ClientRPCResponseResult<GestaltMessage>
> {
Expand Down Expand Up @@ -57,7 +58,7 @@ class GestaltsGestaltList extends ServerHandler<
yield gestaltMessage;
}
});
}
};
}

export default GestaltsGestaltList;
9 changes: 7 additions & 2 deletions src/client/handlers/GestaltsGestaltTrustByIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { matchSync } from '../../utils';

class GestaltsGestaltTrustByIdentity extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
discovery: Discovery;
},
ClientRPCRequestParams<IdentityMessage>,
Expand All @@ -24,7 +24,12 @@ class GestaltsGestaltTrustByIdentity extends UnaryHandler<
public handle = async (
input: ClientRPCRequestParams<IdentityMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph, discovery } = this.container;
const {
db,
gestaltGraph,
discovery,
}: { db: DB; gestaltGraph: GestaltGraph; discovery: Discovery } =
this.container;
const {
providerId,
identityId,
Expand Down
9 changes: 7 additions & 2 deletions src/client/handlers/GestaltsGestaltTrustByNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { matchSync } from '../../utils';

class GestaltsGestaltTrustByNode extends UnaryHandler<
{
gestaltGraph: GestaltGraph;
db: DB;
gestaltGraph: GestaltGraph;
discovery: Discovery;
},
ClientRPCRequestParams<NodeIdMessage>,
Expand All @@ -24,7 +24,12 @@ class GestaltsGestaltTrustByNode extends UnaryHandler<
public handle = async (
input: ClientRPCRequestParams<NodeIdMessage>,
): Promise<ClientRPCResponseResult> => {
const { db, gestaltGraph, discovery } = this.container;
const {
db,
gestaltGraph,
discovery,
}: { db: DB; gestaltGraph: GestaltGraph; discovery: Discovery } =
this.container;
const { nodeId }: { nodeId: NodeId } = validateSync(
(keyPath, value) => {
return matchSync(keyPath)(
Expand Down
15 changes: 6 additions & 9 deletions src/client/handlers/IdentitiesAuthenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@ class IdentitiesAuthenticate extends ServerHandler<
{
identitiesManager: IdentitiesManager;
},
ClientRPCRequestParams<{
providerId: string;
}>,
ClientRPCRequestParams<{ providerId: string }>,
ClientRPCResponseResult<AuthProcessMessage>
> {
public timeout = 120000; // 2 Minutes
public async *handle(
input: ClientRPCRequestParams<{
providerId: string;
}>,
public handle = async function* (
input: ClientRPCRequestParams<{ providerId: string }>,
_cancel,
_meta,
ctx,
): AsyncGenerator<ClientRPCResponseResult<AuthProcessMessage>> {
if (ctx.signal.aborted) throw ctx.signal.reason;
const { identitiesManager } = this.container;
const { identitiesManager }: { identitiesManager: IdentitiesManager } =
this.container;
const {
providerId,
}: {
Expand Down Expand Up @@ -72,7 +69,7 @@ class IdentitiesAuthenticate extends ServerHandler<
identityId: authFlowResult.value,
},
};
}
};
}

export default IdentitiesAuthenticate;
Loading

0 comments on commit 37c1d36

Please sign in to comment.