From 90e6a19bd30721a1c2d176d3fcd8d64944a2833b Mon Sep 17 00:00:00 2001 From: Aditya Date: Wed, 11 Oct 2023 11:02:45 +1100 Subject: [PATCH 1/3] fix: aligned `client` domain to match `nodes/agent` * all client/handlers now default export + index now imports and exports default * server manifest in index.ts now * `client service handlers no longer need to use `Promise` due to changing to Start/Stop` * `ClientService` is changed to `StartStop` --- src/PolykeyAgent.ts | 86 ++- src/PolykeyClient.ts | 16 +- src/client/ClientService.ts | 204 +++---- .../{utils => }/authenticationMiddleware.ts | 16 +- src/client/callers/agentLockAll.ts | 12 + src/client/callers/agentStatus.ts | 12 + src/client/callers/agentStop.ts | 12 + src/client/callers/agentUnlock.ts | 12 + .../callers/gestaltsActionsGetByIdentity.ts | 12 + .../callers/gestaltsActionsGetByNode.ts | 12 + .../callers/gestaltsActionsSetByIdentity.ts | 12 + .../callers/gestaltsActionsSetByNode.ts | 12 + .../callers/gestaltsActionsUnsetByIdentity.ts | 12 + .../callers/gestaltsActionsUnsetByNode.ts | 12 + .../callers/gestaltsDiscoveryByIdentity.ts | 12 + src/client/callers/gestaltsDiscoveryByNode.ts | 12 + .../callers/gestaltsGestaltGetByIdentity.ts | 12 + .../callers/gestaltsGestaltGetByNode.ts | 12 + src/client/callers/gestaltsGestaltList.ts | 12 + .../callers/gestaltsGestaltTrustByIdentity.ts | 12 + .../callers/gestaltsGestaltTrustByNode.ts | 12 + src/client/callers/identitiesAuthenticate.ts | 12 + .../callers/identitiesAuthenticatedGet.ts | 12 + src/client/callers/identitiesClaim.ts | 12 + .../callers/identitiesInfoConnectedGet.ts | 12 + src/client/callers/identitiesInfoGet.ts | 12 + src/client/callers/identitiesInvite.ts | 12 + src/client/callers/identitiesProvidersList.ts | 12 + src/client/callers/identitiesTokenDelete.ts | 12 + src/client/callers/identitiesTokenGet.ts | 12 + src/client/callers/identitiesTokenPut.ts | 12 + src/client/callers/index.ts | 215 +++++++ src/client/callers/keysCertsChainGet.ts | 12 + src/client/callers/keysCertsGet.ts | 12 + src/client/callers/keysDecrypt.ts | 12 + src/client/callers/keysEncrypt.ts | 12 + src/client/callers/keysKeyPair.ts | 12 + src/client/callers/keysKeyPairRenew.ts | 12 + src/client/callers/keysKeyPairReset.ts | 12 + src/client/callers/keysPasswordChange.ts | 12 + src/client/callers/keysPublicKey.ts | 12 + src/client/callers/keysSign.ts | 9 + src/client/callers/keysVerify.ts | 12 + src/client/callers/nodesAdd.ts | 9 + src/client/callers/nodesClaim.ts | 12 + src/client/callers/nodesFind.ts | 12 + src/client/callers/nodesGetAll.ts | 12 + src/client/callers/nodesListConnections.ts | 12 + src/client/callers/nodesPing.ts | 12 + src/client/callers/notificationsClear.ts | 12 + src/client/callers/notificationsRead.ts | 12 + src/client/callers/notificationsSend.ts | 12 + src/client/callers/vaultsClone.ts | 12 + src/client/callers/vaultsCreate.ts | 12 + src/client/callers/vaultsDelete.ts | 12 + src/client/callers/vaultsList.ts | 12 + src/client/callers/vaultsLog.ts | 12 + src/client/callers/vaultsPermissionGet.ts | 12 + src/client/callers/vaultsPermissionSet.ts | 12 + src/client/callers/vaultsPermissionUnset.ts | 12 + src/client/callers/vaultsPull.ts | 12 + src/client/callers/vaultsRename.ts | 12 + src/client/callers/vaultsScan.ts | 12 + src/client/callers/vaultsSecretsDelete.ts | 12 + src/client/callers/vaultsSecretsEdit.ts | 12 + src/client/callers/vaultsSecretsGet.ts | 12 + src/client/callers/vaultsSecretsList.ts | 12 + src/client/callers/vaultsSecretsMkdir.ts | 12 + src/client/callers/vaultsSecretsNew.ts | 12 + src/client/callers/vaultsSecretsNewDir.ts | 12 + src/client/callers/vaultsSecretsRename.ts | 12 + src/client/callers/vaultsSecretsStat.ts | 12 + src/client/callers/vaultsVersion.ts | 12 + src/client/events.ts | 6 - src/client/handlers/agentLockAll.ts | 4 +- src/client/handlers/agentStatus.ts | 32 +- src/client/handlers/agentStop.ts | 13 +- src/client/handlers/agentUnlock.ts | 4 +- src/client/handlers/clientManifest.ts | 553 ------------------ .../handlers/gestaltsActionsGetByIdentity.ts | 11 +- .../handlers/gestaltsActionsGetByNode.ts | 12 +- .../handlers/gestaltsActionsSetByIdentity.ts | 9 +- .../handlers/gestaltsActionsSetByNode.ts | 11 +- .../gestaltsActionsUnsetByIdentity.ts | 11 +- .../handlers/gestaltsActionsUnsetByNode.ts | 11 +- .../handlers/gestaltsDiscoveryByIdentity.ts | 11 +- .../handlers/gestaltsDiscoveryByNode.ts | 11 +- .../handlers/gestaltsGestaltGetByIdentity.ts | 13 +- .../handlers/gestaltsGestaltGetByNode.ts | 12 +- src/client/handlers/gestaltsGestaltList.ts | 11 +- .../gestaltsGestaltTrustByIdentity.ts | 11 +- .../handlers/gestaltsGestaltTrustByNode.ts | 11 +- src/client/handlers/identitiesAuthenticate.ts | 11 +- .../handlers/identitiesAuthenticatedGet.ts | 11 +- src/client/handlers/identitiesClaim.ts | 12 +- .../handlers/identitiesInfoConnectedGet.ts | 12 +- src/client/handlers/identitiesInfoGet.ts | 12 +- src/client/handlers/identitiesInvite.ts | 11 +- .../handlers/identitiesProvidersList.ts | 4 +- src/client/handlers/identitiesTokenDelete.ts | 9 +- src/client/handlers/identitiesTokenGet.ts | 12 +- src/client/handlers/identitiesTokenPut.ts | 12 +- src/client/handlers/index.ts | 325 +++++++--- src/client/handlers/keysCertsChainGet.ts | 11 +- src/client/handlers/keysCertsGet.ts | 11 +- src/client/handlers/keysDecrypt.ts | 11 +- src/client/handlers/keysEncrypt.ts | 12 +- src/client/handlers/keysKeyPair.ts | 12 +- src/client/handlers/keysKeyPairRenew.ts | 11 +- src/client/handlers/keysKeyPairReset.ts | 11 +- src/client/handlers/keysPasswordChange.ts | 11 +- src/client/handlers/keysPublicKey.ts | 12 +- src/client/handlers/keysSign.ts | 12 +- src/client/handlers/keysVerify.ts | 12 +- src/client/handlers/nodesAdd.ts | 11 +- src/client/handlers/nodesClaim.ts | 12 +- src/client/handlers/nodesFind.ts | 12 +- src/client/handlers/nodesGetAll.ts | 11 +- src/client/handlers/nodesListConnections.ts | 11 +- src/client/handlers/nodesPing.ts | 12 +- src/client/handlers/notificationsClear.ts | 4 +- src/client/handlers/notificationsRead.ts | 12 +- src/client/handlers/notificationsSend.ts | 11 +- src/client/handlers/serverManifest.ts | 203 ------- src/client/handlers/types.ts | 281 --------- src/client/handlers/vaultsClone.ts | 12 +- src/client/handlers/vaultsCreate.ts | 12 +- src/client/handlers/vaultsDelete.ts | 12 +- src/client/handlers/vaultsList.ts | 11 +- src/client/handlers/vaultsLog.ts | 12 +- src/client/handlers/vaultsPermissionGet.ts | 12 +- src/client/handlers/vaultsPermissionSet.ts | 12 +- src/client/handlers/vaultsPermissionUnset.ts | 12 +- src/client/handlers/vaultsPull.ts | 12 +- src/client/handlers/vaultsRename.ts | 12 +- src/client/handlers/vaultsScan.ts | 12 +- src/client/handlers/vaultsSecretsDelete.ts | 12 +- src/client/handlers/vaultsSecretsEdit.ts | 12 +- src/client/handlers/vaultsSecretsGet.ts | 12 +- src/client/handlers/vaultsSecretsList.ts | 12 +- src/client/handlers/vaultsSecretsMkdir.ts | 12 +- src/client/handlers/vaultsSecretsNew.ts | 12 +- src/client/handlers/vaultsSecretsNewDir.ts | 12 +- src/client/handlers/vaultsSecretsRename.ts | 12 +- src/client/handlers/vaultsSecretsStat.ts | 12 +- src/client/handlers/vaultsVersion.ts | 12 +- src/client/index.ts | 10 +- src/client/{utils => }/middleware.ts | 8 +- src/client/{utils => }/timeoutMiddleware.ts | 2 +- src/client/types.ts | 348 ++++++++++- src/client/{utils => }/utils.ts | 16 +- src/client/utils/index.ts | 4 - src/nodes/agent/callers/nodesClaimsGet.ts | 4 +- .../callers/nodesClosestLocalNodesGet.ts | 4 +- .../agent/callers/nodesCrossSignClaim.ts | 4 +- .../callers/nodesHolePunchMessageSend.ts | 4 +- src/nodes/agent/callers/notificationsSend.ts | 4 +- src/nodes/agent/callers/vaultsScan.ts | 4 +- 158 files changed, 2290 insertions(+), 1614 deletions(-) rename src/client/{utils => }/authenticationMiddleware.ts (91%) create mode 100644 src/client/callers/agentLockAll.ts create mode 100644 src/client/callers/agentStatus.ts create mode 100644 src/client/callers/agentStop.ts create mode 100644 src/client/callers/agentUnlock.ts create mode 100644 src/client/callers/gestaltsActionsGetByIdentity.ts create mode 100644 src/client/callers/gestaltsActionsGetByNode.ts create mode 100644 src/client/callers/gestaltsActionsSetByIdentity.ts create mode 100644 src/client/callers/gestaltsActionsSetByNode.ts create mode 100644 src/client/callers/gestaltsActionsUnsetByIdentity.ts create mode 100644 src/client/callers/gestaltsActionsUnsetByNode.ts create mode 100644 src/client/callers/gestaltsDiscoveryByIdentity.ts create mode 100644 src/client/callers/gestaltsDiscoveryByNode.ts create mode 100644 src/client/callers/gestaltsGestaltGetByIdentity.ts create mode 100644 src/client/callers/gestaltsGestaltGetByNode.ts create mode 100644 src/client/callers/gestaltsGestaltList.ts create mode 100644 src/client/callers/gestaltsGestaltTrustByIdentity.ts create mode 100644 src/client/callers/gestaltsGestaltTrustByNode.ts create mode 100644 src/client/callers/identitiesAuthenticate.ts create mode 100644 src/client/callers/identitiesAuthenticatedGet.ts create mode 100644 src/client/callers/identitiesClaim.ts create mode 100644 src/client/callers/identitiesInfoConnectedGet.ts create mode 100644 src/client/callers/identitiesInfoGet.ts create mode 100644 src/client/callers/identitiesInvite.ts create mode 100644 src/client/callers/identitiesProvidersList.ts create mode 100644 src/client/callers/identitiesTokenDelete.ts create mode 100644 src/client/callers/identitiesTokenGet.ts create mode 100644 src/client/callers/identitiesTokenPut.ts create mode 100644 src/client/callers/index.ts create mode 100644 src/client/callers/keysCertsChainGet.ts create mode 100644 src/client/callers/keysCertsGet.ts create mode 100644 src/client/callers/keysDecrypt.ts create mode 100644 src/client/callers/keysEncrypt.ts create mode 100644 src/client/callers/keysKeyPair.ts create mode 100644 src/client/callers/keysKeyPairRenew.ts create mode 100644 src/client/callers/keysKeyPairReset.ts create mode 100644 src/client/callers/keysPasswordChange.ts create mode 100644 src/client/callers/keysPublicKey.ts create mode 100644 src/client/callers/keysSign.ts create mode 100644 src/client/callers/keysVerify.ts create mode 100644 src/client/callers/nodesAdd.ts create mode 100644 src/client/callers/nodesClaim.ts create mode 100644 src/client/callers/nodesFind.ts create mode 100644 src/client/callers/nodesGetAll.ts create mode 100644 src/client/callers/nodesListConnections.ts create mode 100644 src/client/callers/nodesPing.ts create mode 100644 src/client/callers/notificationsClear.ts create mode 100644 src/client/callers/notificationsRead.ts create mode 100644 src/client/callers/notificationsSend.ts create mode 100644 src/client/callers/vaultsClone.ts create mode 100644 src/client/callers/vaultsCreate.ts create mode 100644 src/client/callers/vaultsDelete.ts create mode 100644 src/client/callers/vaultsList.ts create mode 100644 src/client/callers/vaultsLog.ts create mode 100644 src/client/callers/vaultsPermissionGet.ts create mode 100644 src/client/callers/vaultsPermissionSet.ts create mode 100644 src/client/callers/vaultsPermissionUnset.ts create mode 100644 src/client/callers/vaultsPull.ts create mode 100644 src/client/callers/vaultsRename.ts create mode 100644 src/client/callers/vaultsScan.ts create mode 100644 src/client/callers/vaultsSecretsDelete.ts create mode 100644 src/client/callers/vaultsSecretsEdit.ts create mode 100644 src/client/callers/vaultsSecretsGet.ts create mode 100644 src/client/callers/vaultsSecretsList.ts create mode 100644 src/client/callers/vaultsSecretsMkdir.ts create mode 100644 src/client/callers/vaultsSecretsNew.ts create mode 100644 src/client/callers/vaultsSecretsNewDir.ts create mode 100644 src/client/callers/vaultsSecretsRename.ts create mode 100644 src/client/callers/vaultsSecretsStat.ts create mode 100644 src/client/callers/vaultsVersion.ts delete mode 100644 src/client/handlers/clientManifest.ts delete mode 100644 src/client/handlers/serverManifest.ts delete mode 100644 src/client/handlers/types.ts rename src/client/{utils => }/middleware.ts (93%) rename src/client/{utils => }/timeoutMiddleware.ts (99%) rename src/client/{utils => }/utils.ts (93%) delete mode 100644 src/client/utils/index.ts diff --git a/src/PolykeyAgent.ts b/src/PolykeyAgent.ts index 349473310..60635cbd1 100644 --- a/src/PolykeyAgent.ts +++ b/src/PolykeyAgent.ts @@ -1,4 +1,4 @@ -import type { DeepPartial, FileSystem, PromiseDeconstructed } from './types'; +import type { DeepPartial, FileSystem } from './types'; import type { PolykeyWorkerManagerInterface } from './workers/types'; import type { TLSConfig } from './network/types'; import type { SeedNodes, NodesOptions } from './nodes/types'; @@ -11,7 +11,6 @@ import { CreateDestroyStartStop, ready, } from '@matrixai/async-init/dist/CreateDestroyStartStop'; -import * as clientUtilsMiddleware from './client/utils/middleware'; import { WorkerManager } from './workers'; import KeyRing from './keys/KeyRing'; import CertManager from './keys/CertManager'; @@ -28,7 +27,9 @@ import Sigchain from './sigchain/Sigchain'; import Discovery from './discovery/Discovery'; import SessionManager from './sessions/SessionManager'; import IdentitiesManager from './identities/IdentitiesManager'; -import { providers } from './identities'; +import * as identityProviders from './identities/providers'; +import TaskManager from './tasks/TaskManager'; +import ClientService from './client/ClientService'; import config from './config'; import * as errors from './errors'; import * as events from './events'; @@ -37,10 +38,9 @@ import * as keysUtils from './keys/utils'; import * as keysEvents from './keys/events'; import * as nodesUtils from './nodes/utils'; import * as workersUtils from './workers/utils'; -import TaskManager from './tasks/TaskManager'; -import { serverManifest } from './client/handlers'; +import * as clientMiddleware from './client/middleware'; +import clientServerManifest from './client/handlers'; import agentServerManifest from './nodes/agent/handlers'; -import ClientService from './client/ClientService'; /** * Optional configuration for `PolykeyAgent`. @@ -181,7 +181,6 @@ class PolykeyAgent { const dbPath = path.join(statePath, config.paths.dbBase); const keysPath = path.join(statePath, config.paths.keysBase); const vaultsPath = path.join(statePath, config.paths.vaultsBase); - let pkAgentProm: PromiseDeconstructed | undefined; let status: Status | undefined; let schema: Schema | undefined; @@ -292,9 +291,9 @@ class PolykeyAgent { fresh, }); // Registering providers - const githubProvider = new providers.GithubProvider({ + const githubProvider = new identityProviders.GithubProvider({ clientId: config.providers['github.com'].clientId, - logger: logger.getChild(providers.GithubProvider.name), + logger: logger.getChild(identityProviders.GithubProvider.name), }); identitiesManager.registerProvider(githubProvider); nodeGraph = await NodeGraph.createNodeGraph({ @@ -380,44 +379,20 @@ class PolykeyAgent { if (optionsDefaulted.keys.recoveryCode != null) { await sessionManager.resetKey(); } - pkAgentProm = utils.promise(); - clientService = await ClientService.createClientService({ - manifest: serverManifest({ - acl: acl, - certManager: certManager, - db: db, - discovery: discovery, - fs: fs, - gestaltGraph: gestaltGraph, - identitiesManager: identitiesManager, - keyRing: keyRing, - logger: logger, - nodeConnectionManager: nodeConnectionManager, - nodeGraph: nodeGraph, - nodeManager: nodeManager, - notificationsManager: notificationsManager, - pkAgentProm: pkAgentProm.p, - sessionManager: sessionManager, - vaultManager: vaultManager, - }), + clientService = new ClientService({ tlsConfig, - options: { - middlewareFactory: clientUtilsMiddleware.middlewareServer( - sessionManager, - keyRing, - ), - host: optionsDefaulted.clientServiceHost, - port: optionsDefaulted.clientServicePort, - keepAliveTimeoutTime: optionsDefaulted.client.keepAliveTimeoutTime, - keepAliveIntervalTime: optionsDefaulted.client.keepAliveIntervalTime, - rpcCallTimeoutTime: optionsDefaulted.rpc.callTimeoutTime, - rpcParserBufferSize: optionsDefaulted.rpc.parserBufferSize, - }, + middlewareFactory: clientMiddleware.middlewareServer( + sessionManager, + keyRing, + ), + keepAliveTimeoutTime: optionsDefaulted.client.keepAliveTimeoutTime, + keepAliveIntervalTime: optionsDefaulted.client.keepAliveIntervalTime, + rpcCallTimeoutTime: optionsDefaulted.rpc.callTimeoutTime, + rpcParserBufferSize: optionsDefaulted.rpc.parserBufferSize, logger: logger.getChild(ClientService.name), }); } catch (e) { logger.warn(`Failed Creating ${this.name}`); - await clientService?.stop({ force: true }); await sessionManager?.stop(); await notificationsManager?.stop(); await vaultManager?.stop(); @@ -457,8 +432,6 @@ class PolykeyAgent { fs, logger, }); - pkAgentProm?.resolveP(pkAgent); - await pkAgent.start({ password, options: { @@ -670,10 +643,26 @@ class PolykeyAgent { await this.identitiesManager.start({ fresh }); // Client server await this.clientService.start({ - options: { - host: optionsDefaulted.clientServiceHost, - port: optionsDefaulted.clientServicePort, - }, + manifest: clientServerManifest({ + polykeyAgent: this, + acl: this.acl, + certManager: this.certManager, + db: this.db, + discovery: this.discovery, + fs: this.fs, + gestaltGraph: this.gestaltGraph, + identitiesManager: this.identitiesManager, + keyRing: this.keyRing, + logger: this.logger, + nodeConnectionManager: this.nodeConnectionManager, + nodeGraph: this.nodeGraph, + nodeManager: this.nodeManager, + notificationsManager: this.notificationsManager, + sessionManager: this.sessionManager, + vaultManager: this.vaultManager, + }), + host: optionsDefaulted.clientServiceHost, + port: optionsDefaulted.clientServicePort, }); await this.nodeManager.start(); await this.nodeConnectionManager.start({ @@ -824,7 +813,6 @@ class PolykeyAgent { await this.vaultManager.destroy(); await this.discovery.destroy(); await this.nodeGraph.destroy(); - await this.clientService.destroy(); await this.identitiesManager.destroy(); await this.gestaltGraph.destroy(); await this.acl.destroy(); diff --git a/src/PolykeyClient.ts b/src/PolykeyClient.ts index 6dcb75caf..571f43b31 100644 --- a/src/PolykeyClient.ts +++ b/src/PolykeyClient.ts @@ -4,15 +4,15 @@ import path from 'path'; import Logger from '@matrixai/logger'; import { CreateDestroyStartStop } from '@matrixai/async-init/dist/CreateDestroyStartStop'; import { RPCClient } from '@matrixai/rpc'; -import { middleware as rpcUtilsMiddleware } from '@matrixai/rpc'; -import * as clientUtilsMiddleware from './client/utils/middleware'; +import { middleware as rpcMiddleware } from '@matrixai/rpc'; +import * as clientMiddleware from './client/middleware'; import { Session } from './sessions'; import * as utils from './utils'; import * as errors from './errors'; import * as events from './events'; import config from './config'; -import { clientManifest } from './client/handlers/clientManifest'; import * as networkUtils from './network/utils'; +import clientClientManifest from './client/callers'; /** * This PolykeyClient would create a new PolykeyClient object that constructs @@ -62,10 +62,10 @@ class PolykeyClient { fresh, }); const rpcClientClient = new RPCClient({ - manifest: clientManifest, + manifest: clientClientManifest, streamFactory, - middlewareFactory: rpcUtilsMiddleware.defaultClientMiddlewareWrapper( - clientUtilsMiddleware.middlewareClient(session), + middlewareFactory: rpcMiddleware.defaultClientMiddlewareWrapper( + clientMiddleware.middlewareClient(session), parserBufferByteLimit, ), toError: networkUtils.toError, @@ -86,7 +86,7 @@ class PolykeyClient { public readonly nodePath: string; public readonly session: Session; - public readonly rpcClientClient: RPCClient; + public readonly rpcClientClient: RPCClient; protected fs: FileSystem; protected logger: Logger; @@ -99,7 +99,7 @@ class PolykeyClient { logger, }: { nodePath: string; - rpcClientClient: RPCClient; + rpcClientClient: RPCClient; session: Session; fs: FileSystem; logger: Logger; diff --git a/src/client/ClientService.ts b/src/client/ClientService.ts index 8df98a2e2..a193ac2c8 100644 --- a/src/client/ClientService.ts +++ b/src/client/ClientService.ts @@ -1,4 +1,5 @@ import type { + IdGen, JSONRPCRequest, JSONRPCResponse, MiddlewareFactory, @@ -6,129 +7,27 @@ import type { } from '@matrixai/rpc'; import type { TLSConfig } from '../network/types'; import Logger from '@matrixai/logger'; -import { CreateDestroyStartStop } from '@matrixai/async-init/dist/CreateDestroyStartStop'; +import { StartStop, ready } from '@matrixai/async-init/dist/StartStop'; import { running, status } from '@matrixai/async-init'; import { WebSocketServer, events as wsEvents } from '@matrixai/ws'; -import { RPCServer } from '@matrixai/rpc'; -import { middleware as rpcUtilsMiddleware } from '@matrixai/rpc'; +import { RPCServer, middleware as rpcMiddleware } from '@matrixai/rpc'; import * as events from './events'; import * as errors from './errors'; -import config from '../config'; import * as networkUtils from '../network/utils'; +import config from '../config'; -interface ClientService extends CreateDestroyStartStop {} -@CreateDestroyStartStop( - new errors.ErrorClientServiceRunning(), - new errors.ErrorClientServiceDestroyed(), - { - eventStart: events.EventClientServiceStart, - eventStarted: events.EventClientServiceStarted, - eventStop: events.EventClientServiceStop, - eventStopped: events.EventClientServiceStopped, - eventDestroy: events.EventClientServiceDestroy, - eventDestroyed: events.EventClientServiceDestroyed, - }, -) +interface ClientService extends StartStop {} +@StartStop({ + eventStart: events.EventClientServiceStart, + eventStarted: events.EventClientServiceStarted, + eventStop: events.EventClientServiceStop, + eventStopped: events.EventClientServiceStopped, +}) class ClientService { - public static async createClientService({ - manifest, - tlsConfig, - options: { - middlewareFactory, - host = config.defaultsUser.clientServiceHost, - port = config.defaultsUser.clientServicePort, - keepAliveTimeoutTime = config.defaultsSystem.clientKeepAliveTimeoutTime, - keepAliveIntervalTime = config.defaultsSystem.clientKeepAliveIntervalTime, - rpcCallTimeoutTime = config.defaultsSystem.rpcCallTimeoutTime, - rpcParserBufferSize = config.defaultsSystem.rpcParserBufferSize, - }, - logger = new Logger(this.name), - }: { - manifest: ServerManifest; - tlsConfig: TLSConfig; - options: { - middlewareFactory?: MiddlewareFactory< - JSONRPCRequest, - JSONRPCRequest, - JSONRPCResponse, - JSONRPCResponse - >; - host?: string; - port?: number; - keepAliveTimeoutTime?: number; - keepAliveIntervalTime?: number; - rpcCallTimeoutTime?: number; - rpcParserBufferSize?: number; - }; - logger?: Logger; - }): Promise { - logger.info(`Creating ${this.name}`); - - const rpcServer = new RPCServer({ - idGen: async () => null, - handlerTimeoutTime: rpcCallTimeoutTime, - middlewareFactory: rpcUtilsMiddleware.defaultServerMiddlewareWrapper( - // ClientUtilsMiddleware.middlewareServer(sessionManager, keyRing), - middlewareFactory, - rpcParserBufferSize, - ), - fromError: networkUtils.fromError, - logger: logger.getChild(RPCServer.name), - }); - - await rpcServer.start({ manifest }); - - const webSocketServer = new WebSocketServer({ - config: { - key: tlsConfig.keyPrivatePem, - cert: tlsConfig.certChainPem, - keepAliveIntervalTime, - keepAliveTimeoutTime, - }, - logger: logger.getChild(WebSocketServer.name), - }); - - const clientService = new ClientService({ - rpcServer, - webSocketServer, - logger, - }); - await clientService.start({ - options: { - host, - port, - }, - }); - logger.info(`Created ${this.name}`); - return clientService; - } - protected rpcServer: RPCServer; protected webSocketServer: WebSocketServer; protected logger: Logger; - constructor({ - rpcServer, - webSocketServer, - logger, - }: { - rpcServer: RPCServer; - webSocketServer: WebSocketServer; - logger: Logger; - }) { - this.rpcServer = rpcServer; - this.webSocketServer = webSocketServer; - this.logger = logger; - } - - get host() { - return this.webSocketServer.host; - } - - get port() { - return this.webSocketServer.port; - } - protected handleEventWebSocketServerConnection = ( evt: wsEvents.EventWebSocketServerConnection, ) => { @@ -157,18 +56,73 @@ class ClientService { ); }; + public constructor({ + tlsConfig, + middlewareFactory, + idGen = async () => null, + keepAliveTimeoutTime = config.defaultsSystem.clientKeepAliveTimeoutTime, + keepAliveIntervalTime = config.defaultsSystem.clientKeepAliveIntervalTime, + rpcCallTimeoutTime = config.defaultsSystem.rpcCallTimeoutTime, + rpcParserBufferSize = config.defaultsSystem.rpcParserBufferSize, + logger, + }: { + tlsConfig: TLSConfig; + middlewareFactory?: MiddlewareFactory< + JSONRPCRequest, + JSONRPCRequest, + JSONRPCResponse, + JSONRPCResponse + >; + idGen?: IdGen; + keepAliveTimeoutTime?: number; + keepAliveIntervalTime?: number; + rpcCallTimeoutTime?: number; + rpcParserBufferSize?: number; + logger?: Logger; + }) { + this.logger = logger ?? new Logger(this.constructor.name); + this.rpcServer = new RPCServer({ + idGen, + handlerTimeoutTime: rpcCallTimeoutTime, + middlewareFactory: rpcMiddleware.defaultServerMiddlewareWrapper( + middlewareFactory, + rpcParserBufferSize, + ), + fromError: networkUtils.fromError, + logger: this.logger.getChild(RPCServer.name), + }); + this.webSocketServer = new WebSocketServer({ + config: { + key: tlsConfig.keyPrivatePem, + cert: tlsConfig.certChainPem, + keepAliveIntervalTime, + keepAliveTimeoutTime, + }, + logger: this.logger.getChild(WebSocketServer.name), + }); + } + + @ready(new errors.ErrorClientServiceNotRunning()) + public get host() { + return this.webSocketServer.host; + } + + @ready(new errors.ErrorClientServiceNotRunning()) + public get port() { + return this.webSocketServer.port; + } + public async start({ - options: { - host = config.defaultsUser.clientServiceHost, - port = config.defaultsUser.clientServicePort, - }, + manifest, + host = config.defaultsUser.clientServiceHost, + port = config.defaultsUser.clientServicePort, }: { - options: { - host?: string; - port?: number; - }; + manifest: ServerManifest; + host?: string; + port?: number; }): Promise { - this.logger.info(`Starting ${this.constructor.name}`); + this.logger.info(`Start ${this.constructor.name}`); + await this.rpcServer.start({ manifest }); this.webSocketServer.addEventListener( wsEvents.EventWebSocketServerConnection.name, this.handleEventWebSocketServerConnection, @@ -183,7 +137,7 @@ class ClientService { public async stop({ force = false, }: { force?: boolean } = {}): Promise { - this.logger.info(`Stopping ${this.constructor.name}`); + this.logger.info(`Stop ${this.constructor.name}`); await this.webSocketServer.stop({ force }); this.webSocketServer.removeEventListener( wsEvents.EventWebSocketServerConnection.name, @@ -193,11 +147,7 @@ class ClientService { this.logger.info(`Stopped ${this.constructor.name}`); } - public async destroy(): Promise { - this.logger.info(`Destroying ${this.constructor.name}`); - this.logger.info(`Destroyed ${this.constructor.name}`); - } - + @ready(new errors.ErrorClientServiceNotRunning()) public setTlsConfig(tlsConfig: TLSConfig): void { this.webSocketServer.updateConfig({ key: tlsConfig.keyPrivatePem, diff --git a/src/client/utils/authenticationMiddleware.ts b/src/client/authenticationMiddleware.ts similarity index 91% rename from src/client/utils/authenticationMiddleware.ts rename to src/client/authenticationMiddleware.ts index b03423b61..5214144b5 100644 --- a/src/client/utils/authenticationMiddleware.ts +++ b/src/client/authenticationMiddleware.ts @@ -3,16 +3,16 @@ import type { JSONRPCResponse, MiddlewareFactory, } from '@matrixai/rpc'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; -import type { Session } from '../../sessions/index'; -import type SessionManager from '../../sessions/SessionManager'; -import type KeyRing from '../../keys/KeyRing'; +import type { ClientRPCRequestParams, ClientRPCResponseResult } from './types'; +import type { Session } from '../sessions'; +import type SessionManager from '../sessions/SessionManager'; +import type KeyRing from '../keys/KeyRing'; import type { JSONRPCError, JSONRPCResponseError } from '@matrixai/rpc'; import { TransformStream } from 'stream/web'; -import { authenticate, decodeAuth } from '../utils/utils'; -import { sysexits } from '../../errors'; -import * as utils from '../../utils/index'; -import * as networkUtils from '../../network/utils'; +import { authenticate, decodeAuth } from './utils'; +import { sysexits } from '../errors'; +import * as utils from '../utils'; +import * as networkUtils from '../network/utils'; function authenticationMiddlewareServer( sessionManager: SessionManager, diff --git a/src/client/callers/agentLockAll.ts b/src/client/callers/agentLockAll.ts new file mode 100644 index 000000000..5e19435bd --- /dev/null +++ b/src/client/callers/agentLockAll.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type AgentLockAll from '../handlers/agentLockAll'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const agentLockAll = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default agentLockAll; diff --git a/src/client/callers/agentStatus.ts b/src/client/callers/agentStatus.ts new file mode 100644 index 000000000..6f71e898b --- /dev/null +++ b/src/client/callers/agentStatus.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type AgentStatus from '../handlers/agentStatus'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const agentStatus = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default agentStatus; diff --git a/src/client/callers/agentStop.ts b/src/client/callers/agentStop.ts new file mode 100644 index 000000000..6f2c048ce --- /dev/null +++ b/src/client/callers/agentStop.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type AgentStop from '../handlers/agentStop'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const agentStop = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default agentStop; diff --git a/src/client/callers/agentUnlock.ts b/src/client/callers/agentUnlock.ts new file mode 100644 index 000000000..e83e7b3fb --- /dev/null +++ b/src/client/callers/agentUnlock.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type AgentUnlock from '../handlers/agentUnlock'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const agentUnlock = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default agentUnlock; diff --git a/src/client/callers/gestaltsActionsGetByIdentity.ts b/src/client/callers/gestaltsActionsGetByIdentity.ts new file mode 100644 index 000000000..b4e37ae8b --- /dev/null +++ b/src/client/callers/gestaltsActionsGetByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsGetByIdentity from '../handlers/gestaltsActionsGetByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsGetByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsGetByIdentity; diff --git a/src/client/callers/gestaltsActionsGetByNode.ts b/src/client/callers/gestaltsActionsGetByNode.ts new file mode 100644 index 000000000..c831cfe34 --- /dev/null +++ b/src/client/callers/gestaltsActionsGetByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsGetByNode from '../handlers/gestaltsActionsGetByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsGetByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsGetByNode; diff --git a/src/client/callers/gestaltsActionsSetByIdentity.ts b/src/client/callers/gestaltsActionsSetByIdentity.ts new file mode 100644 index 000000000..6f4723916 --- /dev/null +++ b/src/client/callers/gestaltsActionsSetByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsSetByIdentity from '../handlers/gestaltsActionsSetByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsSetByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsSetByIdentity; diff --git a/src/client/callers/gestaltsActionsSetByNode.ts b/src/client/callers/gestaltsActionsSetByNode.ts new file mode 100644 index 000000000..bc13f08cb --- /dev/null +++ b/src/client/callers/gestaltsActionsSetByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsSetByNode from '../handlers/gestaltsActionsSetByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsSetByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsSetByNode; diff --git a/src/client/callers/gestaltsActionsUnsetByIdentity.ts b/src/client/callers/gestaltsActionsUnsetByIdentity.ts new file mode 100644 index 000000000..d5ce35934 --- /dev/null +++ b/src/client/callers/gestaltsActionsUnsetByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsUnsetByIdentity from '../handlers/gestaltsActionsUnsetByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsUnsetByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsUnsetByIdentity; diff --git a/src/client/callers/gestaltsActionsUnsetByNode.ts b/src/client/callers/gestaltsActionsUnsetByNode.ts new file mode 100644 index 000000000..b17259916 --- /dev/null +++ b/src/client/callers/gestaltsActionsUnsetByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsActionsUnsetByNode from '../handlers/gestaltsActionsUnsetByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsActionsUnsetByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsActionsUnsetByNode; diff --git a/src/client/callers/gestaltsDiscoveryByIdentity.ts b/src/client/callers/gestaltsDiscoveryByIdentity.ts new file mode 100644 index 000000000..86019b902 --- /dev/null +++ b/src/client/callers/gestaltsDiscoveryByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsDiscoveryByIdentity from '../handlers/gestaltsDiscoveryByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsDiscoveryByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsDiscoveryByIdentity; diff --git a/src/client/callers/gestaltsDiscoveryByNode.ts b/src/client/callers/gestaltsDiscoveryByNode.ts new file mode 100644 index 000000000..149b91e7e --- /dev/null +++ b/src/client/callers/gestaltsDiscoveryByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsDiscoveryByNode from '../handlers/gestaltsDiscoveryByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsDiscoveryByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsDiscoveryByNode; diff --git a/src/client/callers/gestaltsGestaltGetByIdentity.ts b/src/client/callers/gestaltsGestaltGetByIdentity.ts new file mode 100644 index 000000000..c6161f1ae --- /dev/null +++ b/src/client/callers/gestaltsGestaltGetByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsGestaltGetByIdentity from '../handlers/gestaltsGestaltGetByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsGestaltGetByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsGestaltGetByIdentity; diff --git a/src/client/callers/gestaltsGestaltGetByNode.ts b/src/client/callers/gestaltsGestaltGetByNode.ts new file mode 100644 index 000000000..b09179a28 --- /dev/null +++ b/src/client/callers/gestaltsGestaltGetByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsGestaltGetByNode from '../handlers/gestaltsGestaltGetByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsGestaltGetByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsGestaltGetByNode; diff --git a/src/client/callers/gestaltsGestaltList.ts b/src/client/callers/gestaltsGestaltList.ts new file mode 100644 index 000000000..4a5f87467 --- /dev/null +++ b/src/client/callers/gestaltsGestaltList.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsGestaltList from '../handlers/gestaltsGestaltList'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsGestaltList = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsGestaltList; diff --git a/src/client/callers/gestaltsGestaltTrustByIdentity.ts b/src/client/callers/gestaltsGestaltTrustByIdentity.ts new file mode 100644 index 000000000..1c8c912ae --- /dev/null +++ b/src/client/callers/gestaltsGestaltTrustByIdentity.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsGestaltTrustByIdentity from '../handlers/gestaltsGestaltTrustByIdentity'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsGestaltTrustByIdentity = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsGestaltTrustByIdentity; diff --git a/src/client/callers/gestaltsGestaltTrustByNode.ts b/src/client/callers/gestaltsGestaltTrustByNode.ts new file mode 100644 index 000000000..1e4005185 --- /dev/null +++ b/src/client/callers/gestaltsGestaltTrustByNode.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type GestaltsGestaltTrustByNode from '../handlers/gestaltsGestaltTrustByNode'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const gestaltsGestaltTrustByNode = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default gestaltsGestaltTrustByNode; diff --git a/src/client/callers/identitiesAuthenticate.ts b/src/client/callers/identitiesAuthenticate.ts new file mode 100644 index 000000000..d9f37ef6f --- /dev/null +++ b/src/client/callers/identitiesAuthenticate.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesAuthenticate from '../handlers/identitiesAuthenticate'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesAuthenticate = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesAuthenticate; diff --git a/src/client/callers/identitiesAuthenticatedGet.ts b/src/client/callers/identitiesAuthenticatedGet.ts new file mode 100644 index 000000000..078dac8f5 --- /dev/null +++ b/src/client/callers/identitiesAuthenticatedGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesAuthenticatedGet from '../handlers/identitiesAuthenticatedGet'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesAuthenticatedGet = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesAuthenticatedGet; diff --git a/src/client/callers/identitiesClaim.ts b/src/client/callers/identitiesClaim.ts new file mode 100644 index 000000000..6fdb63015 --- /dev/null +++ b/src/client/callers/identitiesClaim.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesClaim from '../handlers/identitiesClaim'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesClaim = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesClaim; diff --git a/src/client/callers/identitiesInfoConnectedGet.ts b/src/client/callers/identitiesInfoConnectedGet.ts new file mode 100644 index 000000000..1dbaff4a0 --- /dev/null +++ b/src/client/callers/identitiesInfoConnectedGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesInfoConnectedGet from '../handlers/identitiesInfoConnectedGet'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesInfoConnectedGet = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesInfoConnectedGet; diff --git a/src/client/callers/identitiesInfoGet.ts b/src/client/callers/identitiesInfoGet.ts new file mode 100644 index 000000000..ece034d52 --- /dev/null +++ b/src/client/callers/identitiesInfoGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesInfoGet from '../handlers/identitiesInfoGet'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesInfoGet = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesInfoGet; diff --git a/src/client/callers/identitiesInvite.ts b/src/client/callers/identitiesInvite.ts new file mode 100644 index 000000000..820c5d5ac --- /dev/null +++ b/src/client/callers/identitiesInvite.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesInvite from '../handlers/identitiesInvite'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesInvite = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesInvite; diff --git a/src/client/callers/identitiesProvidersList.ts b/src/client/callers/identitiesProvidersList.ts new file mode 100644 index 000000000..ab477bfcb --- /dev/null +++ b/src/client/callers/identitiesProvidersList.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesProvidersList from '../handlers/identitiesProvidersList'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesProvidersList = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesProvidersList; diff --git a/src/client/callers/identitiesTokenDelete.ts b/src/client/callers/identitiesTokenDelete.ts new file mode 100644 index 000000000..2a517c94f --- /dev/null +++ b/src/client/callers/identitiesTokenDelete.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesTokenDelete from '../handlers/identitiesTokenDelete'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesTokenDelete = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesTokenDelete; diff --git a/src/client/callers/identitiesTokenGet.ts b/src/client/callers/identitiesTokenGet.ts new file mode 100644 index 000000000..b96af7afc --- /dev/null +++ b/src/client/callers/identitiesTokenGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesTokenGet from '../handlers/identitiesTokenGet'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesTokenGet = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesTokenGet; diff --git a/src/client/callers/identitiesTokenPut.ts b/src/client/callers/identitiesTokenPut.ts new file mode 100644 index 000000000..577a4bd7a --- /dev/null +++ b/src/client/callers/identitiesTokenPut.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type IdentitiesTokenPut from '../handlers/identitiesTokenPut'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const identitiesTokenPut = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default identitiesTokenPut; diff --git a/src/client/callers/index.ts b/src/client/callers/index.ts new file mode 100644 index 000000000..f3e96a478 --- /dev/null +++ b/src/client/callers/index.ts @@ -0,0 +1,215 @@ +import agentLockAll from './agentLockAll'; +import agentStatus from './agentStatus'; +import agentStop from './agentStop'; +import agentUnlock from './agentUnlock'; +import gestaltsActionsGetByIdentity from './gestaltsActionsGetByIdentity'; +import gestaltsActionsGetByNode from './gestaltsActionsGetByNode'; +import gestaltsActionsSetByIdentity from './gestaltsActionsSetByIdentity'; +import gestaltsActionsSetByNode from './gestaltsActionsSetByNode'; +import gestaltsActionsUnsetByIdentity from './gestaltsActionsUnsetByIdentity'; +import gestaltsActionsUnsetByNode from './gestaltsActionsUnsetByNode'; +import gestaltsDiscoveryByIdentity from './gestaltsDiscoveryByIdentity'; +import gestaltsDiscoveryByNode from './gestaltsDiscoveryByNode'; +import gestaltsGestaltGetByIdentity from './gestaltsGestaltGetByIdentity'; +import gestaltsGestaltGetByNode from './gestaltsGestaltGetByNode'; +import gestaltsGestaltList from './gestaltsGestaltList'; +import gestaltsGestaltTrustByIdentity from './gestaltsGestaltTrustByIdentity'; +import gestaltsGestaltTrustByNode from './gestaltsGestaltTrustByNode'; +import identitiesAuthenticate from './identitiesAuthenticate'; +import identitiesAuthenticatedGet from './identitiesAuthenticatedGet'; +import identitiesClaim from './identitiesClaim'; +import identitiesInfoConnectedGet from './identitiesInfoConnectedGet'; +import identitiesInfoGet from './identitiesInfoGet'; +import identitiesInvite from './identitiesInvite'; +import identitiesProvidersList from './identitiesProvidersList'; +import identitiesTokenDelete from './identitiesTokenDelete'; +import identitiesTokenGet from './identitiesTokenGet'; +import identitiesTokenPut from './identitiesTokenPut'; +import keysCertsChainGet from './keysCertsChainGet'; +import keysCertsGet from './keysCertsGet'; +import keysDecrypt from './keysDecrypt'; +import keysEncrypt from './keysEncrypt'; +import keysKeyPair from './keysKeyPair'; +import keysKeyPairRenew from './keysKeyPairRenew'; +import keysKeyPairReset from './keysKeyPairReset'; +import keysPasswordChange from './keysPasswordChange'; +import keysPublicKey from './keysPublicKey'; +import keysSign from './keysSign'; +import keysVerify from './keysVerify'; +import nodesAdd from './nodesAdd'; +import nodesClaim from './nodesClaim'; +import nodesFind from './nodesFind'; +import nodesGetAll from './nodesGetAll'; +import nodesListConnections from './nodesListConnections'; +import nodesPing from './nodesPing'; +import notificationsClear from './notificationsClear'; +import notificationsRead from './notificationsRead'; +import notificationsSend from './notificationsSend'; +import vaultsClone from './vaultsClone'; +import vaultsCreate from './vaultsCreate'; +import vaultsDelete from './vaultsDelete'; +import vaultsList from './vaultsList'; +import vaultsLog from './vaultsLog'; +import vaultsPermissionGet from './vaultsPermissionGet'; +import vaultsPermissionSet from './vaultsPermissionSet'; +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 vaultsSecretsGet from './vaultsSecretsGet'; +import vaultsSecretsList from './vaultsSecretsList'; +import vaultsSecretsMkdir from './vaultsSecretsMkdir'; +import vaultsSecretsNew from './vaultsSecretsNew'; +import vaultsSecretsNewDir from './vaultsSecretsNewDir'; +import vaultsSecretsRename from './vaultsSecretsRename'; +import vaultsSecretsStat from './vaultsSecretsStat'; +import vaultsVersion from './vaultsVersion'; + +/** + * Client manifest + */ +const clientManifest = { + agentLockAll, + agentStatus, + agentStop, + agentUnlock, + gestaltsActionsGetByIdentity, + gestaltsActionsGetByNode, + gestaltsActionsSetByIdentity, + gestaltsActionsSetByNode, + gestaltsActionsUnsetByIdentity, + gestaltsActionsUnsetByNode, + gestaltsDiscoveryByIdentity, + gestaltsDiscoveryByNode, + gestaltsGestaltGetByIdentity, + gestaltsGestaltGetByNode, + gestaltsGestaltList, + gestaltsGestaltTrustByIdentity, + gestaltsGestaltTrustByNode, + identitiesAuthenticate, + identitiesAuthenticatedGet, + identitiesClaim, + identitiesInfoConnectedGet, + identitiesInfoGet, + identitiesInvite, + identitiesProvidersList, + identitiesTokenDelete, + identitiesTokenGet, + identitiesTokenPut, + keysCertsChainGet, + keysCertsGet, + keysDecrypt, + keysEncrypt, + keysKeyPair, + keysKeyPairRenew, + keysKeyPairReset, + keysPasswordChange, + keysPublicKey, + keysSign, + keysVerify, + nodesAdd, + nodesClaim, + nodesFind, + nodesGetAll, + nodesListConnections, + nodesPing, + notificationsClear, + notificationsRead, + notificationsSend, + vaultsClone, + vaultsCreate, + vaultsDelete, + vaultsList, + vaultsLog, + vaultsPermissionGet, + vaultsPermissionSet, + vaultsPermissionUnset, + vaultsPull, + vaultsRename, + vaultsScan, + vaultsSecretsDelete, + vaultsSecretsEdit, + vaultsSecretsGet, + vaultsSecretsList, + vaultsSecretsMkdir, + vaultsSecretsNew, + vaultsSecretsNewDir, + vaultsSecretsRename, + vaultsSecretsStat, + vaultsVersion, +}; + +export default clientManifest; + +export { + agentLockAll, + agentStatus, + agentStop, + agentUnlock, + gestaltsActionsGetByIdentity, + gestaltsActionsGetByNode, + gestaltsActionsSetByIdentity, + gestaltsActionsSetByNode, + gestaltsActionsUnsetByIdentity, + gestaltsActionsUnsetByNode, + gestaltsDiscoveryByIdentity, + gestaltsDiscoveryByNode, + gestaltsGestaltGetByIdentity, + gestaltsGestaltGetByNode, + gestaltsGestaltList, + gestaltsGestaltTrustByIdentity, + gestaltsGestaltTrustByNode, + identitiesAuthenticate, + identitiesAuthenticatedGet, + identitiesClaim, + identitiesInfoConnectedGet, + identitiesInfoGet, + identitiesInvite, + identitiesProvidersList, + identitiesTokenDelete, + identitiesTokenGet, + identitiesTokenPut, + keysCertsChainGet, + keysCertsGet, + keysDecrypt, + keysEncrypt, + keysKeyPair, + keysKeyPairRenew, + keysKeyPairReset, + keysPasswordChange, + keysPublicKey, + keysSign, + keysVerify, + nodesAdd, + nodesClaim, + nodesFind, + nodesGetAll, + nodesListConnections, + nodesPing, + notificationsClear, + notificationsRead, + notificationsSend, + vaultsClone, + vaultsCreate, + vaultsDelete, + vaultsList, + vaultsLog, + vaultsPermissionGet, + vaultsPermissionSet, + vaultsPermissionUnset, + vaultsPull, + vaultsRename, + vaultsScan, + vaultsSecretsDelete, + vaultsSecretsEdit, + vaultsSecretsGet, + vaultsSecretsList, + vaultsSecretsMkdir, + vaultsSecretsNew, + vaultsSecretsNewDir, + vaultsSecretsRename, + vaultsSecretsStat, + vaultsVersion, +}; diff --git a/src/client/callers/keysCertsChainGet.ts b/src/client/callers/keysCertsChainGet.ts new file mode 100644 index 000000000..fdb27d7d1 --- /dev/null +++ b/src/client/callers/keysCertsChainGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysCertsChainGet from '../handlers/keysCertsChainGet'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysCertsChainGet = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysCertsChainGet; diff --git a/src/client/callers/keysCertsGet.ts b/src/client/callers/keysCertsGet.ts new file mode 100644 index 000000000..7c1f5d6f0 --- /dev/null +++ b/src/client/callers/keysCertsGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysCertsGet from '../handlers/keysCertsGet'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysCertsGet = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysCertsGet; diff --git a/src/client/callers/keysDecrypt.ts b/src/client/callers/keysDecrypt.ts new file mode 100644 index 000000000..39742f0cb --- /dev/null +++ b/src/client/callers/keysDecrypt.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysDecrypt from '../handlers/keysDecrypt'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysDecrypt = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysDecrypt; diff --git a/src/client/callers/keysEncrypt.ts b/src/client/callers/keysEncrypt.ts new file mode 100644 index 000000000..2c2c2ffae --- /dev/null +++ b/src/client/callers/keysEncrypt.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysEncrypt from '../handlers/keysEncrypt'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysEncrypt = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysEncrypt; diff --git a/src/client/callers/keysKeyPair.ts b/src/client/callers/keysKeyPair.ts new file mode 100644 index 000000000..1372fe910 --- /dev/null +++ b/src/client/callers/keysKeyPair.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysKeyPair from '../handlers/keysKeyPair'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysKeyPair = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysKeyPair; diff --git a/src/client/callers/keysKeyPairRenew.ts b/src/client/callers/keysKeyPairRenew.ts new file mode 100644 index 000000000..6ed40bcf3 --- /dev/null +++ b/src/client/callers/keysKeyPairRenew.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysKeyPairRenew from '../handlers/keysKeyPairRenew'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysKeyPairRenew = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysKeyPairRenew; diff --git a/src/client/callers/keysKeyPairReset.ts b/src/client/callers/keysKeyPairReset.ts new file mode 100644 index 000000000..25c6800a0 --- /dev/null +++ b/src/client/callers/keysKeyPairReset.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysKeyPairReset from '../handlers/keysKeyPairReset'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysKeyPairReset = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysKeyPairReset; diff --git a/src/client/callers/keysPasswordChange.ts b/src/client/callers/keysPasswordChange.ts new file mode 100644 index 000000000..f032b2a1e --- /dev/null +++ b/src/client/callers/keysPasswordChange.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysPasswordChange from '../handlers/keysPasswordChange'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysPasswordChange = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysPasswordChange; diff --git a/src/client/callers/keysPublicKey.ts b/src/client/callers/keysPublicKey.ts new file mode 100644 index 000000000..e17be36e6 --- /dev/null +++ b/src/client/callers/keysPublicKey.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysPublicKey from '../handlers/keysPublicKey'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysPublicKey = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysPublicKey; diff --git a/src/client/callers/keysSign.ts b/src/client/callers/keysSign.ts new file mode 100644 index 000000000..a4ea4615e --- /dev/null +++ b/src/client/callers/keysSign.ts @@ -0,0 +1,9 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysSign from '../handlers/keysSign'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysSign = new UnaryCaller(); + +export default keysSign; diff --git a/src/client/callers/keysVerify.ts b/src/client/callers/keysVerify.ts new file mode 100644 index 000000000..767f8b8c6 --- /dev/null +++ b/src/client/callers/keysVerify.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type KeysVerify from '../handlers/keysVerify'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const keysVerify = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default keysVerify; diff --git a/src/client/callers/nodesAdd.ts b/src/client/callers/nodesAdd.ts new file mode 100644 index 000000000..413cd1f40 --- /dev/null +++ b/src/client/callers/nodesAdd.ts @@ -0,0 +1,9 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesAdd from '../handlers/nodesAdd'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesAdd = new UnaryCaller(); + +export default nodesAdd; diff --git a/src/client/callers/nodesClaim.ts b/src/client/callers/nodesClaim.ts new file mode 100644 index 000000000..b114cca14 --- /dev/null +++ b/src/client/callers/nodesClaim.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesClaim from '../handlers/nodesClaim'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesClaim = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default nodesClaim; diff --git a/src/client/callers/nodesFind.ts b/src/client/callers/nodesFind.ts new file mode 100644 index 000000000..7cd80ae35 --- /dev/null +++ b/src/client/callers/nodesFind.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesFind from '../handlers/nodesFind'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesFind = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default nodesFind; diff --git a/src/client/callers/nodesGetAll.ts b/src/client/callers/nodesGetAll.ts new file mode 100644 index 000000000..cab8c4d99 --- /dev/null +++ b/src/client/callers/nodesGetAll.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesGetAll from '../handlers/nodesGetAll'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesGetAll = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default nodesGetAll; diff --git a/src/client/callers/nodesListConnections.ts b/src/client/callers/nodesListConnections.ts new file mode 100644 index 000000000..dcba7d322 --- /dev/null +++ b/src/client/callers/nodesListConnections.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesListConnections from '../handlers/nodesListConnections'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesListConnections = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default nodesListConnections; diff --git a/src/client/callers/nodesPing.ts b/src/client/callers/nodesPing.ts new file mode 100644 index 000000000..255f350c1 --- /dev/null +++ b/src/client/callers/nodesPing.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesPing from '../handlers/nodesPing'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const nodesPing = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default nodesPing; diff --git a/src/client/callers/notificationsClear.ts b/src/client/callers/notificationsClear.ts new file mode 100644 index 000000000..80d57b151 --- /dev/null +++ b/src/client/callers/notificationsClear.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NotificationsClear from '../handlers/notificationsClear'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const notificationsClear = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default notificationsClear; diff --git a/src/client/callers/notificationsRead.ts b/src/client/callers/notificationsRead.ts new file mode 100644 index 000000000..f1d000c80 --- /dev/null +++ b/src/client/callers/notificationsRead.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NotificationsRead from '../handlers/notificationsRead'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const notificationsRead = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default notificationsRead; diff --git a/src/client/callers/notificationsSend.ts b/src/client/callers/notificationsSend.ts new file mode 100644 index 000000000..a3bbcd84c --- /dev/null +++ b/src/client/callers/notificationsSend.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type NotificationsSend from '../handlers/notificationsRead'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const notificationsSend = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default notificationsSend; diff --git a/src/client/callers/vaultsClone.ts b/src/client/callers/vaultsClone.ts new file mode 100644 index 000000000..84376b696 --- /dev/null +++ b/src/client/callers/vaultsClone.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsClone from '../handlers/vaultsClone'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsClone = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsClone; diff --git a/src/client/callers/vaultsCreate.ts b/src/client/callers/vaultsCreate.ts new file mode 100644 index 000000000..e3ac9e7b1 --- /dev/null +++ b/src/client/callers/vaultsCreate.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsCreate from '../handlers/vaultsCreate'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsCreate = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsCreate; diff --git a/src/client/callers/vaultsDelete.ts b/src/client/callers/vaultsDelete.ts new file mode 100644 index 000000000..2159f4fd4 --- /dev/null +++ b/src/client/callers/vaultsDelete.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsDelete from '../handlers/vaultsDelete'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsDelete = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsDelete; diff --git a/src/client/callers/vaultsList.ts b/src/client/callers/vaultsList.ts new file mode 100644 index 000000000..597b7bcae --- /dev/null +++ b/src/client/callers/vaultsList.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsList from '../handlers/vaultsList'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsList = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsList; diff --git a/src/client/callers/vaultsLog.ts b/src/client/callers/vaultsLog.ts new file mode 100644 index 000000000..9cf9d5151 --- /dev/null +++ b/src/client/callers/vaultsLog.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsLog from '../handlers/vaultsLog'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsLog = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsLog; diff --git a/src/client/callers/vaultsPermissionGet.ts b/src/client/callers/vaultsPermissionGet.ts new file mode 100644 index 000000000..8196e4984 --- /dev/null +++ b/src/client/callers/vaultsPermissionGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsPermissionGet from '../handlers/vaultsPermissionGet'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsPermissionGet = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsPermissionGet; diff --git a/src/client/callers/vaultsPermissionSet.ts b/src/client/callers/vaultsPermissionSet.ts new file mode 100644 index 000000000..fcf6c769a --- /dev/null +++ b/src/client/callers/vaultsPermissionSet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsPermissionSet from '../handlers/vaultsPermissionSet'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsPermissionSet = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsPermissionSet; diff --git a/src/client/callers/vaultsPermissionUnset.ts b/src/client/callers/vaultsPermissionUnset.ts new file mode 100644 index 000000000..618348893 --- /dev/null +++ b/src/client/callers/vaultsPermissionUnset.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsPermissionUnset from '../handlers/vaultsPermissionUnset'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsPermissionUnset = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsPermissionUnset; diff --git a/src/client/callers/vaultsPull.ts b/src/client/callers/vaultsPull.ts new file mode 100644 index 000000000..0e1759e35 --- /dev/null +++ b/src/client/callers/vaultsPull.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsPull from '../handlers/vaultsPull'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsPull = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsPull; diff --git a/src/client/callers/vaultsRename.ts b/src/client/callers/vaultsRename.ts new file mode 100644 index 000000000..cd5cdf4dc --- /dev/null +++ b/src/client/callers/vaultsRename.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsRename from '../handlers/vaultsRename'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsRename = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsRename; diff --git a/src/client/callers/vaultsScan.ts b/src/client/callers/vaultsScan.ts new file mode 100644 index 000000000..72d35f150 --- /dev/null +++ b/src/client/callers/vaultsScan.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsScan from '../handlers/vaultsScan'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsScan = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsScan; diff --git a/src/client/callers/vaultsSecretsDelete.ts b/src/client/callers/vaultsSecretsDelete.ts new file mode 100644 index 000000000..d63a54732 --- /dev/null +++ b/src/client/callers/vaultsSecretsDelete.ts @@ -0,0 +1,12 @@ +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/callers/vaultsSecretsEdit.ts b/src/client/callers/vaultsSecretsEdit.ts new file mode 100644 index 000000000..d2524c953 --- /dev/null +++ b/src/client/callers/vaultsSecretsEdit.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsEdit from '../handlers/vaultsSecretsEdit'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsEdit = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsEdit; diff --git a/src/client/callers/vaultsSecretsGet.ts b/src/client/callers/vaultsSecretsGet.ts new file mode 100644 index 000000000..f44d05dee --- /dev/null +++ b/src/client/callers/vaultsSecretsGet.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsGet from '../handlers/vaultsSecretsGet'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsGet = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsGet; diff --git a/src/client/callers/vaultsSecretsList.ts b/src/client/callers/vaultsSecretsList.ts new file mode 100644 index 000000000..df8fc7842 --- /dev/null +++ b/src/client/callers/vaultsSecretsList.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsList from '../handlers/vaultsSecretsList'; +import { ServerCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsList = new ServerCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsList; diff --git a/src/client/callers/vaultsSecretsMkdir.ts b/src/client/callers/vaultsSecretsMkdir.ts new file mode 100644 index 000000000..d29497cf1 --- /dev/null +++ b/src/client/callers/vaultsSecretsMkdir.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsMkdir from '../handlers/vaultsSecretsMkdir'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsMkdir = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsMkdir; diff --git a/src/client/callers/vaultsSecretsNew.ts b/src/client/callers/vaultsSecretsNew.ts new file mode 100644 index 000000000..b3fce18c2 --- /dev/null +++ b/src/client/callers/vaultsSecretsNew.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsNew from '../handlers/vaultsSecretsNew'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsNew = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsNew; diff --git a/src/client/callers/vaultsSecretsNewDir.ts b/src/client/callers/vaultsSecretsNewDir.ts new file mode 100644 index 000000000..17450b115 --- /dev/null +++ b/src/client/callers/vaultsSecretsNewDir.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsNewDir from '../handlers/vaultsSecretsNewDir'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsNewDir = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsNewDir; diff --git a/src/client/callers/vaultsSecretsRename.ts b/src/client/callers/vaultsSecretsRename.ts new file mode 100644 index 000000000..f043cb337 --- /dev/null +++ b/src/client/callers/vaultsSecretsRename.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsRename from '../handlers/vaultsSecretsRename'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsRename = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsRename; diff --git a/src/client/callers/vaultsSecretsStat.ts b/src/client/callers/vaultsSecretsStat.ts new file mode 100644 index 000000000..9fe7c2991 --- /dev/null +++ b/src/client/callers/vaultsSecretsStat.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsSecretsStat from '../handlers/vaultsSecretsStat'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsSecretsStat = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsSecretsStat; diff --git a/src/client/callers/vaultsVersion.ts b/src/client/callers/vaultsVersion.ts new file mode 100644 index 000000000..11b46b810 --- /dev/null +++ b/src/client/callers/vaultsVersion.ts @@ -0,0 +1,12 @@ +import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsVersion from '../handlers/vaultsVersion'; +import { UnaryCaller } from '@matrixai/rpc'; + +type CallerTypes = HandlerTypes; + +const vaultsVersion = new UnaryCaller< + CallerTypes['input'], + CallerTypes['output'] +>(); + +export default vaultsVersion; diff --git a/src/client/events.ts b/src/client/events.ts index dbb118f20..0f363cb6c 100644 --- a/src/client/events.ts +++ b/src/client/events.ts @@ -12,10 +12,6 @@ class EventClientServiceStop extends EventsClientService {} class EventClientServiceStopped extends EventsClientService {} -class EventClientServiceDestroy extends EventsClientService {} - -class EventClientServiceDestroyed extends EventsClientService {} - export { EventsClient, EventsClientService, @@ -23,6 +19,4 @@ export { EventClientServiceStarted, EventClientServiceStop, EventClientServiceStopped, - EventClientServiceDestroy, - EventClientServiceDestroyed, }; diff --git a/src/client/handlers/agentLockAll.ts b/src/client/handlers/agentLockAll.ts index 05d82fba8..5b919a55e 100644 --- a/src/client/handlers/agentLockAll.ts +++ b/src/client/handlers/agentLockAll.ts @@ -3,7 +3,7 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; import type SessionManager from '../../sessions/SessionManager'; import { UnaryHandler } from '@matrixai/rpc'; -class AgentLockAllHandler extends UnaryHandler< +class AgentLockAll extends UnaryHandler< { sessionManager: SessionManager; db: DB; @@ -18,4 +18,4 @@ class AgentLockAllHandler extends UnaryHandler< }; } -export { AgentLockAllHandler }; +export default AgentLockAll; diff --git a/src/client/handlers/agentStatus.ts b/src/client/handlers/agentStatus.ts index 7fbdf79f8..94ceac431 100644 --- a/src/client/handlers/agentStatus.ts +++ b/src/client/handlers/agentStatus.ts @@ -1,13 +1,16 @@ -import type { StatusResultMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + StatusResultMessage, +} from '../types'; import type PolykeyAgent from '../../PolykeyAgent'; import { UnaryHandler } from '@matrixai/rpc'; import * as nodesUtils from '../../nodes/utils'; import * as keysUtils from '../../keys/utils'; -class AgentStatusHandler extends UnaryHandler< +class AgentStatus extends UnaryHandler< { - pkAgentProm: Promise; + polykeyAgent: PolykeyAgent; }, ClientRPCRequestParams, ClientRPCResponseResult @@ -15,19 +18,20 @@ class AgentStatusHandler extends UnaryHandler< public handle = async (): Promise< ClientRPCResponseResult > => { - const { pkAgentProm } = this.container; - const pkAgent = await pkAgentProm; + const { polykeyAgent } = this.container; return { pid: process.pid, - nodeIdEncoded: nodesUtils.encodeNodeId(pkAgent.keyRing.getNodeId()), - clientHost: pkAgent.clientServiceHost, - clientPort: pkAgent.clientServicePort, - agentHost: pkAgent.agentServiceHost, - agentPort: pkAgent.agentServicePort, - publicKeyJwk: keysUtils.publicKeyToJWK(pkAgent.keyRing.keyPair.publicKey), - certChainPEM: await pkAgent.certManager.getCertPEMsChainPEM(), + nodeIdEncoded: nodesUtils.encodeNodeId(polykeyAgent.keyRing.getNodeId()), + clientHost: polykeyAgent.clientServiceHost, + clientPort: polykeyAgent.clientServicePort, + agentHost: polykeyAgent.agentServiceHost, + agentPort: polykeyAgent.agentServicePort, + publicKeyJwk: keysUtils.publicKeyToJWK( + polykeyAgent.keyRing.keyPair.publicKey, + ), + certChainPEM: await polykeyAgent.certManager.getCertPEMsChainPEM(), }; }; } -export { AgentStatusHandler }; +export default AgentStatus; diff --git a/src/client/handlers/agentStop.ts b/src/client/handlers/agentStop.ts index 91729dd85..c57733adf 100644 --- a/src/client/handlers/agentStop.ts +++ b/src/client/handlers/agentStop.ts @@ -3,26 +3,25 @@ import type PolykeyAgent from '../../PolykeyAgent'; import { running, status } from '@matrixai/async-init'; import { UnaryHandler } from '@matrixai/rpc'; -class AgentStopHandler extends UnaryHandler< +class AgentStop extends UnaryHandler< { - pkAgentProm: Promise; + polykeyAgent: PolykeyAgent; }, ClientRPCRequestParams, ClientRPCResponseResult > { public handle = async (): Promise => { - const { pkAgentProm } = this.container; - const pkAgent = await pkAgentProm; + const { polykeyAgent } = this.container; // If not running or in stopping status, then respond successfully - if (!pkAgent[running] || pkAgent[status] === 'stopping') { + if (!polykeyAgent[running] || polykeyAgent[status] === 'stopping') { return {}; } // Stop PK agent in the background, allow the RPC time to respond setTimeout(async () => { - await pkAgent.stop(); + await polykeyAgent.stop(); }, 500); return {}; }; } -export { AgentStopHandler }; +export default AgentStop; diff --git a/src/client/handlers/agentUnlock.ts b/src/client/handlers/agentUnlock.ts index 9013b310d..79a9b0eb6 100644 --- a/src/client/handlers/agentUnlock.ts +++ b/src/client/handlers/agentUnlock.ts @@ -2,7 +2,7 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; import type { ContainerType } from '@matrixai/rpc'; import { UnaryHandler } from '@matrixai/rpc'; -class AgentUnlockHandler extends UnaryHandler< +class AgentUnlock extends UnaryHandler< ContainerType, ClientRPCRequestParams, ClientRPCResponseResult @@ -15,4 +15,4 @@ class AgentUnlockHandler extends UnaryHandler< }; } -export { AgentUnlockHandler }; +export default AgentUnlock; diff --git a/src/client/handlers/clientManifest.ts b/src/client/handlers/clientManifest.ts deleted file mode 100644 index 4c3bfd921..000000000 --- a/src/client/handlers/clientManifest.ts +++ /dev/null @@ -1,553 +0,0 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; -import type { - ActionsListMessage, - AddressMessage, - AuthProcessMessage, - CertMessage, - ClaimIdMessage, - ClaimNodeMessage, - DataMessage, - DecryptMessage, - GestaltMessage, - IdentityInfoMessage, - IdentityMessage, - KeyPairMessage, - NodeConnectionMessage, - NodeIdMessage, - NodesAddMessage, - NodesGetMessage, - NotificationMessage, - NotificationReadMessage, - PasswordMessage, - ProviderSearchMessage, - PublicKeyMessage, - SetIdentityActionMessage, - SetNodeActionMessage, - SignatureMessage, - StatusResultMessage, - SuccessMessage, - TokenMessage, - VerifySignatureMessage, - CloneMessage, - ContentMessage, - LogEntryMessage, - NotificationSendMessage, - PermissionSetMessage, - SecretContentMessage, - SecretDirMessage, - SecretIdentifierMessage, - SecretMkdirMessage, - SecretNameMessage, - SecretRenameMessage, - SecretStatMessage, - VaultIdentifierMessage, - VaultIdMessage, - VaultListMessage, - VaultNameMessage, - VaultPermissionMessage, - VaultsLatestVersionMessage, - VaultsLogMessage, - VaultsPullMessage, - VaultsRenameMessage, - VaultsScanMessage, - VaultsVersionMessage, -} from './types'; -import type { GestaltAction } from '../../gestalts/types'; -import { ServerCaller, UnaryCaller } from '@matrixai/rpc'; - -const agentLockAll = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const agentStatus = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const agentStop = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const agentUnlock = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsActionsGetByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult<{ - actionsList: Array; - }> ->(); - -const gestaltsActionsGetByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsActionsSetByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsActionsSetByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsActionsUnsetByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsActionsUnsetByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsDiscoveryByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsDiscoveryByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsGestaltGetByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsGestaltGetByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsGestaltList = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsGestaltTrustByIdentity = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const gestaltsGestaltTrustByNode = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesAuthenticate = new ServerCaller< - ClientRPCRequestParams<{ - providerId: string; - }>, - ClientRPCResponseResult ->(); - -const identitiesAuthenticatedGet = new ServerCaller< - ClientRPCRequestParams<{ - providerId?: string; - }>, - ClientRPCResponseResult ->(); - -const identitiesClaim = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesInfoConnectedGet = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesInfoGet = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesInvite = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesProvidersList = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult<{ - providerIds: Array; - }> ->(); - -const identitiesTokenDelete = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const identitiesTokenGet = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult> ->(); - -const identitiesTokenPut = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysCertsChainGet = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysCertsGet = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysDecrypt = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysEncrypt = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysKeyPair = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysKeyPairRenew = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysKeyPairReset = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysPasswordChange = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysPublicKey = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysSign = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const keysVerify = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesAdd = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesClaim = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesFind = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesGetAll = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesListConnections = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const nodesPing = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const notificationsClear = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const notificationsRead = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const notificationsSend = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsClone = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsCreate = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsDelete = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsList = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsLog = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsPermissionGet = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsPermissionSet = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsPermissionUnset = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsPull = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsRename = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsScan = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsDelete = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsEdit = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsGet = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsList = new ServerCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsMkdir = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsNew = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsNewDir = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsRename = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsSecretsStat = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -const vaultsVersion = new UnaryCaller< - ClientRPCRequestParams, - ClientRPCResponseResult ->(); - -/** - * All the client caller definitions for the ClientClient RPC. - * Used by the RPCClient to register callers and enforce types. - * - * No type used here, it will override type inference. - */ -const clientManifest = { - agentLockAll, - agentStatus, - agentStop, - agentUnlock, - gestaltsActionsGetByIdentity, - gestaltsActionsGetByNode, - gestaltsActionsSetByIdentity, - gestaltsActionsSetByNode, - gestaltsActionsUnsetByIdentity, - gestaltsActionsUnsetByNode, - gestaltsDiscoveryByIdentity, - gestaltsDiscoveryByNode, - gestaltsGestaltGetByIdentity, - gestaltsGestaltGetByNode, - gestaltsGestaltList, - gestaltsGestaltTrustByIdentity, - gestaltsGestaltTrustByNode, - identitiesAuthenticate, - identitiesAuthenticatedGet, - identitiesClaim, - identitiesInfoConnectedGet, - identitiesInfoGet, - identitiesInvite, - identitiesProvidersList, - identitiesTokenDelete, - identitiesTokenGet, - identitiesTokenPut, - keysCertsChainGet, - keysCertsGet, - keysDecrypt, - keysEncrypt, - keysKeyPair, - keysKeyPairRenew, - keysKeyPairReset, - keysPasswordChange, - keysPublicKey, - keysSign, - keysVerify, - nodesAdd, - nodesClaim, - nodesFind, - nodesGetAll, - nodesListConnections, - nodesPing, - notificationsClear, - notificationsRead, - notificationsSend, - vaultsClone, - vaultsCreate, - vaultsDelete, - vaultsList, - vaultsLog, - vaultsPermissionGet, - vaultsPermissionSet, - vaultsPermissionUnset, - vaultsPull, - vaultsRename, - vaultsScan, - vaultsSecretsDelete, - vaultsSecretsEdit, - vaultsSecretsGet, - vaultsSecretsList, - vaultsSecretsMkdir, - vaultsSecretsNew, - vaultsSecretsNewDir, - vaultsSecretsRename, - vaultsSecretsStat, - vaultsVersion, -}; - -export { - clientManifest, - agentLockAll, - agentStatus, - agentStop, - agentUnlock, - gestaltsActionsGetByIdentity, - gestaltsActionsGetByNode, - gestaltsActionsSetByIdentity, - gestaltsActionsSetByNode, - gestaltsActionsUnsetByIdentity, - gestaltsActionsUnsetByNode, - gestaltsDiscoveryByIdentity, - gestaltsDiscoveryByNode, - gestaltsGestaltGetByIdentity, - gestaltsGestaltGetByNode, - gestaltsGestaltList, - gestaltsGestaltTrustByIdentity, - gestaltsGestaltTrustByNode, - identitiesAuthenticate, - identitiesAuthenticatedGet, - identitiesClaim, - identitiesInfoConnectedGet, - identitiesInfoGet, - identitiesInvite, - identitiesProvidersList, - identitiesTokenDelete, - identitiesTokenGet, - identitiesTokenPut, - keysCertsChainGet, - keysCertsGet, - keysDecrypt, - keysEncrypt, - keysKeyPair, - keysKeyPairRenew, - keysKeyPairReset, - keysPasswordChange, - keysPublicKey, - keysSign, - keysVerify, - nodesAdd, - nodesClaim, - nodesFind, - nodesGetAll, - nodesListConnections, - nodesPing, - notificationsClear, - notificationsRead, - notificationsSend, - vaultsClone, - vaultsCreate, - vaultsDelete, - vaultsList, - vaultsLog, - vaultsPermissionGet, - vaultsPermissionSet, - vaultsPermissionUnset, - vaultsPull, - vaultsRename, - vaultsScan, - vaultsSecretsDelete, - vaultsSecretsEdit, - vaultsSecretsGet, - vaultsSecretsList, - vaultsSecretsMkdir, - vaultsSecretsNew, - vaultsSecretsNewDir, - vaultsSecretsRename, - vaultsSecretsStat, - vaultsVersion, -}; diff --git a/src/client/handlers/gestaltsActionsGetByIdentity.ts b/src/client/handlers/gestaltsActionsGetByIdentity.ts index 51497d726..545bc7893 100644 --- a/src/client/handlers/gestaltsActionsGetByIdentity.ts +++ b/src/client/handlers/gestaltsActionsGetByIdentity.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { GestaltAction } from '../../gestalts/types'; import type { IdentityId, ProviderId } from '../../ids/index'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsActionsGetByIdentityHandler extends UnaryHandler< +class GestaltsActionsGetByIdentity extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -56,4 +59,4 @@ class GestaltsActionsGetByIdentityHandler extends UnaryHandler< }; } -export { GestaltsActionsGetByIdentityHandler }; +export default GestaltsActionsGetByIdentity; diff --git a/src/client/handlers/gestaltsActionsGetByNode.ts b/src/client/handlers/gestaltsActionsGetByNode.ts index 6a4dbd7cd..1a6000799 100644 --- a/src/client/handlers/gestaltsActionsGetByNode.ts +++ b/src/client/handlers/gestaltsActionsGetByNode.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { ActionsListMessage, NodeIdMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ActionsListMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { GestaltAction } from '../../gestalts/types'; import type { NodeId } from '../../ids/index'; @@ -9,7 +13,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsActionsGetByNodeHandler extends UnaryHandler< +class GestaltsActionsGetByNode extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -42,4 +46,4 @@ class GestaltsActionsGetByNodeHandler extends UnaryHandler< }; } -export { GestaltsActionsGetByNodeHandler }; +export default GestaltsActionsGetByNode; diff --git a/src/client/handlers/gestaltsActionsSetByIdentity.ts b/src/client/handlers/gestaltsActionsSetByIdentity.ts index aa2c9241e..523d5bcc3 100644 --- a/src/client/handlers/gestaltsActionsSetByIdentity.ts +++ b/src/client/handlers/gestaltsActionsSetByIdentity.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { SetIdentityActionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SetIdentityActionMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type { GestaltAction } from '../../gestalts/types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; @@ -55,4 +58,4 @@ class GestaltsActionsSetByIdentityHandler extends UnaryHandler< }; } -export { GestaltsActionsSetByIdentityHandler }; +export default GestaltsActionsSetByIdentityHandler; diff --git a/src/client/handlers/gestaltsActionsSetByNode.ts b/src/client/handlers/gestaltsActionsSetByNode.ts index 3090c5d14..d0d77efba 100644 --- a/src/client/handlers/gestaltsActionsSetByNode.ts +++ b/src/client/handlers/gestaltsActionsSetByNode.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { SetNodeActionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SetNodeActionMessage, +} from '../types'; import type { GestaltAction } from '../../gestalts/types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { NodeId } from '../../ids/index'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsActionsSetByNodeHandler extends UnaryHandler< +class GestaltsActionsSetByNode extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -42,4 +45,4 @@ class GestaltsActionsSetByNodeHandler extends UnaryHandler< }; } -export { GestaltsActionsSetByNodeHandler }; +export default GestaltsActionsSetByNode; diff --git a/src/client/handlers/gestaltsActionsUnsetByIdentity.ts b/src/client/handlers/gestaltsActionsUnsetByIdentity.ts index 838417b36..149723c5e 100644 --- a/src/client/handlers/gestaltsActionsUnsetByIdentity.ts +++ b/src/client/handlers/gestaltsActionsUnsetByIdentity.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { SetIdentityActionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SetIdentityActionMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type { GestaltAction } from '../../gestalts/types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsActionsUnsetByIdentityHandler extends UnaryHandler< +class GestaltsActionsUnsetByIdentity extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -55,4 +58,4 @@ class GestaltsActionsUnsetByIdentityHandler extends UnaryHandler< }; } -export { GestaltsActionsUnsetByIdentityHandler }; +export default GestaltsActionsUnsetByIdentity; diff --git a/src/client/handlers/gestaltsActionsUnsetByNode.ts b/src/client/handlers/gestaltsActionsUnsetByNode.ts index 51df643ab..5339d82c5 100644 --- a/src/client/handlers/gestaltsActionsUnsetByNode.ts +++ b/src/client/handlers/gestaltsActionsUnsetByNode.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { SetNodeActionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SetNodeActionMessage, +} from '../types'; import type { GestaltAction } from '../../gestalts/types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { NodeId } from '../../ids/index'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsActionsUnsetByNodeHandler extends UnaryHandler< +class GestaltsActionsUnsetByNode extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -42,4 +45,4 @@ class GestaltsActionsUnsetByNodeHandler extends UnaryHandler< }; } -export { GestaltsActionsUnsetByNodeHandler }; +export default GestaltsActionsUnsetByNode; diff --git a/src/client/handlers/gestaltsDiscoveryByIdentity.ts b/src/client/handlers/gestaltsDiscoveryByIdentity.ts index eaad4b6a8..6f1559f16 100644 --- a/src/client/handlers/gestaltsDiscoveryByIdentity.ts +++ b/src/client/handlers/gestaltsDiscoveryByIdentity.ts @@ -1,5 +1,8 @@ -import type { IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type Discovery from '../../discovery/Discovery'; import { UnaryHandler } from '@matrixai/rpc'; @@ -7,7 +10,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsDiscoveryByIdentityHandler extends UnaryHandler< +class GestaltsDiscoveryByIdentity extends UnaryHandler< { discovery: Discovery; }, @@ -41,4 +44,4 @@ class GestaltsDiscoveryByIdentityHandler extends UnaryHandler< }; } -export { GestaltsDiscoveryByIdentityHandler }; +export default GestaltsDiscoveryByIdentity; diff --git a/src/client/handlers/gestaltsDiscoveryByNode.ts b/src/client/handlers/gestaltsDiscoveryByNode.ts index 495044879..c9e05f540 100644 --- a/src/client/handlers/gestaltsDiscoveryByNode.ts +++ b/src/client/handlers/gestaltsDiscoveryByNode.ts @@ -1,5 +1,8 @@ -import type { NodeIdMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, +} from '../types'; import type { NodeId } from '../../ids/index'; import type Discovery from '../../discovery/Discovery'; import { UnaryHandler } from '@matrixai/rpc'; @@ -7,7 +10,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsDiscoveryByNodeHandler extends UnaryHandler< +class GestaltsDiscoveryByNode extends UnaryHandler< { discovery: Discovery; }, @@ -36,4 +39,4 @@ class GestaltsDiscoveryByNodeHandler extends UnaryHandler< }; } -export { GestaltsDiscoveryByNodeHandler }; +export default GestaltsDiscoveryByNode; diff --git a/src/client/handlers/gestaltsGestaltGetByIdentity.ts b/src/client/handlers/gestaltsGestaltGetByIdentity.ts index 4b300dc02..e8331143d 100644 --- a/src/client/handlers/gestaltsGestaltGetByIdentity.ts +++ b/src/client/handlers/gestaltsGestaltGetByIdentity.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { GestaltMessage, IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + GestaltMessage, + IdentityMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import { UnaryHandler } from '@matrixai/rpc'; @@ -9,7 +13,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsGestaltGetByIdentityHandler extends UnaryHandler< +class GestaltsGestaltGetByIdentity extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -70,5 +74,4 @@ class GestaltsGestaltGetByIdentityHandler extends UnaryHandler< return gestaltMessage; }; } - -export { GestaltsGestaltGetByIdentityHandler }; +export default GestaltsGestaltGetByIdentity; diff --git a/src/client/handlers/gestaltsGestaltGetByNode.ts b/src/client/handlers/gestaltsGestaltGetByNode.ts index 296225cae..85487ce75 100644 --- a/src/client/handlers/gestaltsGestaltGetByNode.ts +++ b/src/client/handlers/gestaltsGestaltGetByNode.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { GestaltMessage, NodeIdMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + GestaltMessage, + NodeIdMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { NodeId } from '../../ids/index'; import { UnaryHandler } from '@matrixai/rpc'; @@ -9,7 +13,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsGestaltGetByNodeHandler extends UnaryHandler< +class GestaltsGestaltGetByNode extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -66,4 +70,4 @@ class GestaltsGestaltGetByNodeHandler extends UnaryHandler< }; } -export { GestaltsGestaltGetByNodeHandler }; +export default GestaltsGestaltGetByNode; diff --git a/src/client/handlers/gestaltsGestaltList.ts b/src/client/handlers/gestaltsGestaltList.ts index 503a444d2..ae0094531 100644 --- a/src/client/handlers/gestaltsGestaltList.ts +++ b/src/client/handlers/gestaltsGestaltList.ts @@ -1,11 +1,14 @@ import type { DB } from '@matrixai/db'; -import type { GestaltMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + GestaltMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import { ServerHandler } from '@matrixai/rpc'; import * as nodesUtils from '../../nodes/utils'; -class GestaltsGestaltListHandler extends ServerHandler< +class GestaltsGestaltList extends ServerHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -57,4 +60,4 @@ class GestaltsGestaltListHandler extends ServerHandler< } } -export { GestaltsGestaltListHandler }; +export default GestaltsGestaltList; diff --git a/src/client/handlers/gestaltsGestaltTrustByIdentity.ts b/src/client/handlers/gestaltsGestaltTrustByIdentity.ts index a2b147acd..7f4c47af6 100644 --- a/src/client/handlers/gestaltsGestaltTrustByIdentity.ts +++ b/src/client/handlers/gestaltsGestaltTrustByIdentity.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { IdentityId, ProviderId } from '../../ids/index'; import type Discovery from '../../discovery/Discovery'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsGestaltTrustByIdentityHandler extends UnaryHandler< +class GestaltsGestaltTrustByIdentity extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -67,4 +70,4 @@ class GestaltsGestaltTrustByIdentityHandler extends UnaryHandler< }; } -export { GestaltsGestaltTrustByIdentityHandler }; +export default GestaltsGestaltTrustByIdentity; diff --git a/src/client/handlers/gestaltsGestaltTrustByNode.ts b/src/client/handlers/gestaltsGestaltTrustByNode.ts index 1327eadd8..28f214b91 100644 --- a/src/client/handlers/gestaltsGestaltTrustByNode.ts +++ b/src/client/handlers/gestaltsGestaltTrustByNode.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { NodeIdMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, +} from '../types'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type { NodeId } from '../../ids/index'; import type Discovery from '../../discovery/Discovery'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class GestaltsGestaltTrustByNodeHandler extends UnaryHandler< +class GestaltsGestaltTrustByNode extends UnaryHandler< { gestaltGraph: GestaltGraph; db: DB; @@ -54,4 +57,4 @@ class GestaltsGestaltTrustByNodeHandler extends UnaryHandler< }; } -export { GestaltsGestaltTrustByNodeHandler }; +export default GestaltsGestaltTrustByNode; diff --git a/src/client/handlers/identitiesAuthenticate.ts b/src/client/handlers/identitiesAuthenticate.ts index 008317bc8..53ccfb04a 100644 --- a/src/client/handlers/identitiesAuthenticate.ts +++ b/src/client/handlers/identitiesAuthenticate.ts @@ -1,5 +1,8 @@ -import type { AuthProcessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + AuthProcessMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, +} from '../types'; import type { ProviderId } from '../../ids/index'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import { ServerHandler } from '@matrixai/rpc'; @@ -8,7 +11,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync, never } from '../../utils/index'; -class IdentitiesAuthenticateHandler extends ServerHandler< +class IdentitiesAuthenticate extends ServerHandler< { identitiesManager: IdentitiesManager; }, @@ -71,4 +74,4 @@ class IdentitiesAuthenticateHandler extends ServerHandler< } } -export { IdentitiesAuthenticateHandler }; +export default IdentitiesAuthenticate; diff --git a/src/client/handlers/identitiesAuthenticatedGet.ts b/src/client/handlers/identitiesAuthenticatedGet.ts index 54989d908..b7f8df6ef 100644 --- a/src/client/handlers/identitiesAuthenticatedGet.ts +++ b/src/client/handlers/identitiesAuthenticatedGet.ts @@ -1,5 +1,8 @@ -import type { IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type { ProviderId } from '../../ids/index'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import { ServerHandler } from '@matrixai/rpc'; @@ -7,7 +10,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class IdentitiesAuthenticatedGetHandler extends ServerHandler< +class IdentitiesAuthenticatedGet extends ServerHandler< { identitiesManager: IdentitiesManager; }, @@ -61,4 +64,4 @@ class IdentitiesAuthenticatedGetHandler extends ServerHandler< } } -export { IdentitiesAuthenticatedGetHandler }; +export default IdentitiesAuthenticatedGet; diff --git a/src/client/handlers/identitiesClaim.ts b/src/client/handlers/identitiesClaim.ts index 0e9e51aa8..95fe5f80e 100644 --- a/src/client/handlers/identitiesClaim.ts +++ b/src/client/handlers/identitiesClaim.ts @@ -1,5 +1,9 @@ -import type { ClaimIdMessage, IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClaimIdMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import { UnaryHandler } from '@matrixai/rpc'; @@ -7,7 +11,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class IdentitiesClaimHandler extends UnaryHandler< +class IdentitiesClaim extends UnaryHandler< { identitiesManager: IdentitiesManager; }, @@ -47,4 +51,4 @@ class IdentitiesClaimHandler extends UnaryHandler< }; } -export { IdentitiesClaimHandler }; +export default IdentitiesClaim; diff --git a/src/client/handlers/identitiesInfoConnectedGet.ts b/src/client/handlers/identitiesInfoConnectedGet.ts index af317b62e..77d68273a 100644 --- a/src/client/handlers/identitiesInfoConnectedGet.ts +++ b/src/client/handlers/identitiesInfoConnectedGet.ts @@ -1,5 +1,9 @@ -import type { ProviderSearchMessage, IdentityInfoMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityInfoMessage, + ProviderSearchMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import type { IdentityData } from '../../identities/types'; @@ -9,7 +13,7 @@ import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; import * as identitiesErrors from '../../identities/errors'; -class IdentitiesInfoConnectedGetHandler extends ServerHandler< +class IdentitiesInfoConnectedGet extends ServerHandler< { identitiesManager: IdentitiesManager; }, @@ -104,4 +108,4 @@ class IdentitiesInfoConnectedGetHandler extends ServerHandler< } } -export { IdentitiesInfoConnectedGetHandler }; +export default IdentitiesInfoConnectedGet; diff --git a/src/client/handlers/identitiesInfoGet.ts b/src/client/handlers/identitiesInfoGet.ts index 7deb8c890..f3c248995 100644 --- a/src/client/handlers/identitiesInfoGet.ts +++ b/src/client/handlers/identitiesInfoGet.ts @@ -1,5 +1,9 @@ -import type { ProviderSearchMessage, IdentityInfoMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityInfoMessage, + ProviderSearchMessage, +} from '../types'; import type { IdentityId, ProviderId } from '../../ids/index'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import type { IdentityData } from '../../identities/types'; @@ -10,7 +14,7 @@ import { matchSync } from '../../utils/index'; import * as identitiesErrors from '../../identities/errors'; import * as identitiesUtils from '../../identities/utils'; -class IdentitiesInfoGetHandler extends ServerHandler< +class IdentitiesInfoGet extends ServerHandler< { identitiesManager: IdentitiesManager; }, @@ -98,4 +102,4 @@ class IdentitiesInfoGetHandler extends ServerHandler< } } -export { IdentitiesInfoGetHandler }; +export default IdentitiesInfoGet; diff --git a/src/client/handlers/identitiesInvite.ts b/src/client/handlers/identitiesInvite.ts index 47a1db21d..bde0665c2 100644 --- a/src/client/handlers/identitiesInvite.ts +++ b/src/client/handlers/identitiesInvite.ts @@ -1,6 +1,9 @@ import type Logger from '@matrixai/logger'; -import type { ClaimNodeMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClaimNodeMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, +} from '../types'; import type { NodeId } from '../../ids/index'; import type NotificationsManager from '../../notifications/NotificationsManager'; import type ACL from '../../acl/ACL'; @@ -9,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class IdentitiesInviteHandler extends UnaryHandler< +class IdentitiesInvite extends UnaryHandler< { acl: ACL; notificationsManager: NotificationsManager; @@ -51,4 +54,4 @@ class IdentitiesInviteHandler extends UnaryHandler< }; } -export { IdentitiesInviteHandler }; +export default IdentitiesInvite; diff --git a/src/client/handlers/identitiesProvidersList.ts b/src/client/handlers/identitiesProvidersList.ts index ec84074f6..68da4e13b 100644 --- a/src/client/handlers/identitiesProvidersList.ts +++ b/src/client/handlers/identitiesProvidersList.ts @@ -2,7 +2,7 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import { UnaryHandler } from '@matrixai/rpc'; -class IdentitiesProvidersListHandler extends UnaryHandler< +class IdentitiesProvidersList extends UnaryHandler< { identitiesManager: IdentitiesManager; }, @@ -24,4 +24,4 @@ class IdentitiesProvidersListHandler extends UnaryHandler< }; } -export { IdentitiesProvidersListHandler }; +export default IdentitiesProvidersList; diff --git a/src/client/handlers/identitiesTokenDelete.ts b/src/client/handlers/identitiesTokenDelete.ts index 5d9a040be..7bfe75d96 100644 --- a/src/client/handlers/identitiesTokenDelete.ts +++ b/src/client/handlers/identitiesTokenDelete.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { IdentityMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, +} from '../types'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import type { IdentityId, ProviderId } from '../../ids/index'; import { UnaryHandler } from '@matrixai/rpc'; @@ -46,4 +49,4 @@ class IdentitiesTokenDeleteHandler extends UnaryHandler< }; } -export { IdentitiesTokenDeleteHandler }; +export default IdentitiesTokenDeleteHandler; diff --git a/src/client/handlers/identitiesTokenGet.ts b/src/client/handlers/identitiesTokenGet.ts index f918ec866..76ad147c9 100644 --- a/src/client/handlers/identitiesTokenGet.ts +++ b/src/client/handlers/identitiesTokenGet.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { IdentityMessage, TokenMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, + TokenMessage, +} from '../types'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import type { IdentityId, ProviderId } from '../../ids/index'; import { UnaryHandler } from '@matrixai/rpc'; @@ -8,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class IdentitiesTokenGetHandler extends UnaryHandler< +class IdentitiesTokenGet extends UnaryHandler< { db: DB; identitiesManager: IdentitiesManager; @@ -48,4 +52,4 @@ class IdentitiesTokenGetHandler extends UnaryHandler< }; } -export { IdentitiesTokenGetHandler }; +export default IdentitiesTokenGet; diff --git a/src/client/handlers/identitiesTokenPut.ts b/src/client/handlers/identitiesTokenPut.ts index 5814e8bad..e80cabb12 100644 --- a/src/client/handlers/identitiesTokenPut.ts +++ b/src/client/handlers/identitiesTokenPut.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { IdentityMessage, TokenMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + IdentityMessage, + TokenMessage, +} from '../types'; import type IdentitiesManager from '../../identities/IdentitiesManager'; import type { IdentityId, ProviderId } from '../../ids/index'; import { UnaryHandler } from '@matrixai/rpc'; @@ -8,7 +12,7 @@ import { validateSync } from '../../validation/index'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils/index'; -class IdentitiesTokenPutHandler extends UnaryHandler< +class IdentitiesTokenPut extends UnaryHandler< { db: DB; identitiesManager: IdentitiesManager; @@ -46,4 +50,4 @@ class IdentitiesTokenPutHandler extends UnaryHandler< }; } -export { IdentitiesTokenPutHandler }; +export default IdentitiesTokenPut; diff --git a/src/client/handlers/index.ts b/src/client/handlers/index.ts index 68800320f..565b9f0cb 100644 --- a/src/client/handlers/index.ts +++ b/src/client/handlers/index.ts @@ -1,71 +1,254 @@ -export * from './clientManifest'; -export * from './serverManifest'; -export * as types from './types'; -export * from './vaultsClone'; -export * from './vaultsCreate'; -export * from './vaultsDelete'; -export * from './vaultsList'; -export * from './vaultsLog'; -export * from './vaultsPermissionGet'; -export * from './vaultsPermissionSet'; -export * from './vaultsPermissionUnset'; -export * from './nodesAdd'; -export * from './nodesClaim'; -export * from './nodesFind'; -export * from './nodesGetAll'; -export * from './nodesListConnections'; -export * from './nodesPing'; -export * from './gestaltsActionsGetByIdentity'; -export * from './gestaltsActionsGetByNode'; -export * from './gestaltsActionsSetByIdentity'; -export * from './gestaltsActionsSetByNode'; -export * from './gestaltsActionsUnsetByIdentity'; -export * from './gestaltsActionsUnsetByNode'; -export * from './gestaltsDiscoveryByIdentity'; -export * from './gestaltsDiscoveryByNode'; -export * from './gestaltsGestaltGetByIdentity'; -export * from './gestaltsGestaltGetByNode'; -export * from './gestaltsGestaltList'; -export * from './gestaltsGestaltTrustByIdentity'; -export * from './gestaltsGestaltTrustByNode'; -export * from './identitiesAuthenticate'; -export * from './identitiesAuthenticatedGet'; -export * from './identitiesClaim'; -export * from './agentStatus'; -export * from './agentStop'; -export * from './agentUnlock'; -export * from './agentLockAll'; -export * from './identitiesInfoGet'; -export * from './identitiesInfoConnectedGet'; -export * from './identitiesInvite'; -export * from './identitiesProvidersList'; -export * from './identitiesTokenDelete'; -export * from './identitiesTokenGet'; -export * from './identitiesTokenPut'; -export * from './keysCertsChainGet'; -export * from './keysCertsGet'; -export * from './keysDecrypt'; -export * from './keysEncrypt'; -export * from './keysKeyPair'; -export * from './keysKeyPairRenew'; -export * from './keysKeyPairReset'; -export * from './keysPasswordChange'; -export * from './keysPublicKey'; -export * from './notificationsClear'; -export * from './notificationsRead'; -export * from './notificationsSend'; -export * from './vaultsPull'; -export * from './vaultsRename'; -export * from './vaultsScan'; -export * from './vaultsSecretsDelete'; -export * from './vaultsSecretsEdit'; -export * from './vaultsSecretsGet'; -export * from './vaultsSecretsList'; -export * from './vaultsSecretsMkdir'; -export * from './vaultsSecretsNew'; -export * from './vaultsSecretsNewDir'; -export * from './vaultsSecretsRename'; -export * from './vaultsSecretsStat'; -export * from './vaultsVersion'; -export * from '../../client/handlers/keysVerify'; -export * from '../../client/handlers/keysSign'; +import type { DB } from '@matrixai/db'; +import type Logger from '@matrixai/logger'; +import type ACL from '../../acl/ACL'; +import type KeyRing from '../../keys/KeyRing'; +import type CertManager from '../../keys/CertManager'; +import type SessionManager from '../../sessions/SessionManager'; +import type GestaltGraph from '../../gestalts/GestaltGraph'; +import type IdentitiesManager from '../../identities/IdentitiesManager'; +import type Discovery from '../../discovery/Discovery'; +import type NotificationsManager from '../../notifications/NotificationsManager'; +import type NodeManager from '../../nodes/NodeManager'; +import type NodeConnectionManager from '../../nodes/NodeConnectionManager'; +import type NodeGraph from '../../nodes/NodeGraph'; +import type VaultManager from '../../vaults/VaultManager'; +import type PolykeyAgent from '../../PolykeyAgent'; +import type { FileSystem } from '../../types'; +import agentLockAll from './agentLockAll'; +import agentStatus from './agentStatus'; +import agentStop from './agentStop'; +import agentUnlock from './agentUnlock'; +import gestaltsActionsGetByIdentity from './gestaltsActionsGetByIdentity'; +import gestaltsActionsGetByNode from './gestaltsActionsGetByNode'; +import gestaltsActionsSetByIdentity from './gestaltsActionsSetByIdentity'; +import gestaltsActionsSetByNode from './gestaltsActionsSetByNode'; +import gestaltsActionsUnsetByIdentity from './gestaltsActionsUnsetByIdentity'; +import gestaltsActionsUnsetByNode from './gestaltsActionsUnsetByNode'; +import gestaltsDiscoveryByIdentity from './gestaltsDiscoveryByIdentity'; +import gestaltsDiscoveryByNode from './gestaltsDiscoveryByNode'; +import gestaltsGestaltGetByIdentity from './gestaltsGestaltGetByIdentity'; +import gestaltsGestaltGetByNode from './gestaltsGestaltGetByNode'; +import gestaltsGestaltList from './gestaltsGestaltList'; +import gestaltsGestaltTrustByIdentity from './gestaltsGestaltTrustByIdentity'; +import gestaltsGestaltTrustByNode from './gestaltsGestaltTrustByNode'; +import identitiesAuthenticate from './identitiesAuthenticate'; +import identitiesAuthenticatedGet from './identitiesAuthenticatedGet'; +import identitiesClaim from './identitiesClaim'; +import identitiesInfoConnectedGet from './identitiesInfoConnectedGet'; +import identitiesInfoGet from './identitiesInfoGet'; +import identitiesInvite from './identitiesInvite'; +import identitiesProvidersList from './identitiesProvidersList'; +import identitiesTokenDelete from './identitiesTokenDelete'; +import identitiesTokenGet from './identitiesTokenGet'; +import identitiesTokenPut from './identitiesTokenPut'; +import keysCertsChainGet from './keysCertsChainGet'; +import keysCertsGet from './keysCertsGet'; +import keysDecrypt from './keysDecrypt'; +import keysEncrypt from './keysEncrypt'; +import keysKeyPair from './keysKeyPair'; +import keysKeyPairRenew from './keysKeyPairRenew'; +import keysKeyPairReset from './keysKeyPairReset'; +import keysPasswordChange from './keysPasswordChange'; +import keysPublicKey from './keysPublicKey'; +import keysSign from './keysSign'; +import keysVerify from './keysVerify'; +import nodesAdd from './nodesAdd'; +import nodesClaim from './nodesClaim'; +import nodesFind from './nodesFind'; +import nodesGetAll from './nodesGetAll'; +import nodesListConnections from './nodesListConnections'; +import nodesPing from './nodesPing'; +import notificationsClear from './notificationsClear'; +import notificationsRead from './notificationsRead'; +import notificationsSend from './notificationsSend'; +import vaultsClone from './vaultsClone'; +import vaultsCreate from './vaultsCreate'; +import vaultsDelete from './vaultsDelete'; +import vaultsList from './vaultsList'; +import vaultsLog from './vaultsLog'; +import vaultsPermissionGet from './vaultsPermissionGet'; +import vaultsPermissionSet from './vaultsPermissionSet'; +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 vaultsSecretsGet from './vaultsSecretsGet'; +import vaultsSecretsList from './vaultsSecretsList'; +import vaultsSecretsMkdir from './vaultsSecretsMkdir'; +import vaultsSecretsNew from './vaultsSecretsNew'; +import vaultsSecretsNewDir from './vaultsSecretsNewDir'; +import vaultsSecretsRename from './vaultsSecretsRename'; +import vaultsSecretsStat from './vaultsSecretsStat'; +import vaultsVersion from './vaultsVersion'; + +/** + * Server manifest factory. + */ +const serverManifest = (container: { + polykeyAgent: PolykeyAgent; + keyRing: KeyRing; + certManager: CertManager; + db: DB; + sessionManager: SessionManager; + gestaltGraph: GestaltGraph; + identitiesManager: IdentitiesManager; + discovery: Discovery; + acl: ACL; + notificationsManager: NotificationsManager; + nodeManager: NodeManager; + nodeConnectionManager: NodeConnectionManager; + nodeGraph: NodeGraph; + vaultManager: VaultManager; + fs: FileSystem; + logger: Logger; +}) => { + return { + agentLockAll: new agentLockAll(container), + agentStatus: new agentStatus(container), + agentStop: new agentStop(container), + agentUnlock: new agentUnlock(container), + gestaltsActionsGetByIdentity: new gestaltsActionsGetByIdentity(container), + gestaltsActionsGetByNode: new gestaltsActionsGetByNode(container), + gestaltsActionsSetByIdentity: new gestaltsActionsSetByNode(container), + gestaltsActionsSetByNode: new gestaltsActionsSetByNode(container), + gestaltsActionsUnsetByIdentity: new gestaltsActionsUnsetByIdentity( + container, + ), + gestaltsActionsUnsetByNode: new gestaltsActionsUnsetByNode(container), + gestaltsDiscoveryByIdentity: new gestaltsDiscoveryByIdentity(container), + gestaltsDiscoveryByNode: new gestaltsDiscoveryByNode(container), + gestaltsGestaltGetByIdentity: new gestaltsGestaltGetByIdentity(container), + gestaltsGestaltGetByNode: new gestaltsGestaltGetByNode(container), + gestaltsGestaltList: new gestaltsGestaltList(container), + gestaltsGestaltTrustByIdentity: new gestaltsGestaltTrustByIdentity( + container, + ), + gestaltsGestaltTrustByNode: new gestaltsGestaltTrustByNode(container), + identitiesAuthenticate: new identitiesAuthenticate(container), + identitiesAuthenticatedGet: new identitiesAuthenticatedGet(container), + identitiesClaim: new identitiesClaim(container), + identitiesInfoConnectedGet: new identitiesInfoConnectedGet(container), + identitiesInfoGet: new identitiesInfoGet(container), + identitiesInvite: new identitiesInvite(container), + identitiesProvidersList: new identitiesProvidersList(container), + identitiesTokenDelete: new identitiesTokenDelete(container), + identitiesTokenGet: new identitiesTokenGet(container), + identitiesTokenPut: new identitiesTokenPut(container), + keysCertsChainGet: new keysCertsChainGet(container), + keysCertsGet: new keysCertsGet(container), + keysDecrypt: new keysDecrypt(container), + keysEncrypt: new keysEncrypt(container), + keysKeyPair: new keysKeyPair(container), + keysKeyPairRenew: new keysKeyPairRenew(container), + keysKeyPairReset: new keysKeyPairReset(container), + keysPasswordChange: new keysPasswordChange(container), + keysPublicKey: new keysPublicKey(container), + keysSign: new keysSign(container), + keysVerify: new keysVerify(container), + nodesAdd: new nodesAdd(container), + nodesClaim: new nodesClaim(container), + nodesFind: new nodesFind(container), + nodesGetAll: new nodesGetAll(container), + nodesListConnections: new nodesListConnections(container), + nodesPing: new nodesPing(container), + notificationsClear: new notificationsClear(container), + notificationsRead: new notificationsRead(container), + notificationsSend: new notificationsSend(container), + vaultsClone: new vaultsClone(container), + vaultsCreate: new vaultsCreate(container), + vaultsDelete: new vaultsDelete(container), + vaultsList: new vaultsList(container), + vaultsLog: new vaultsLog(container), + vaultsPermissionGet: new vaultsPermissionGet(container), + vaultsPermissionSet: new vaultsPermissionSet(container), + vaultsPermissionUnset: new vaultsPermissionUnset(container), + vaultsPull: new vaultsPull(container), + vaultsRename: new vaultsRename(container), + vaultsScan: new vaultsScan(container), + vaultsSecretsDelete: new vaultsSecretsDelete(container), + vaultsSecretsEdit: new vaultsSecretsEdit(container), + vaultsSecretsGet: new vaultsSecretsGet(container), + vaultsSecretsList: new vaultsSecretsList(container), + vaultsSecretsMkdir: new vaultsSecretsMkdir(container), + vaultsSecretsNew: new vaultsSecretsNew(container), + vaultsSecretsNewDir: new vaultsSecretsNewDir(container), + vaultsSecretsRename: new vaultsSecretsRename(container), + vaultsSecretsStat: new vaultsSecretsStat(container), + vaultsVersion: new vaultsVersion(container), + }; +}; + +export default serverManifest; + +export { + agentLockAll, + agentStatus, + agentStop, + agentUnlock, + gestaltsActionsGetByIdentity, + gestaltsActionsGetByNode, + gestaltsActionsSetByIdentity, + gestaltsActionsSetByNode, + gestaltsActionsUnsetByIdentity, + gestaltsActionsUnsetByNode, + gestaltsDiscoveryByIdentity, + gestaltsDiscoveryByNode, + gestaltsGestaltGetByIdentity, + gestaltsGestaltGetByNode, + gestaltsGestaltList, + gestaltsGestaltTrustByIdentity, + gestaltsGestaltTrustByNode, + identitiesAuthenticate, + identitiesAuthenticatedGet, + identitiesClaim, + identitiesInfoConnectedGet, + identitiesInfoGet, + identitiesInvite, + identitiesProvidersList, + identitiesTokenDelete, + identitiesTokenGet, + identitiesTokenPut, + keysCertsChainGet, + keysCertsGet, + keysDecrypt, + keysEncrypt, + keysKeyPair, + keysKeyPairRenew, + keysKeyPairReset, + keysPasswordChange, + keysPublicKey, + keysSign, + keysVerify, + nodesAdd, + nodesClaim, + nodesFind, + nodesGetAll, + nodesListConnections, + nodesPing, + notificationsClear, + notificationsRead, + notificationsSend, + vaultsClone, + vaultsCreate, + vaultsDelete, + vaultsList, + vaultsLog, + vaultsPermissionGet, + vaultsPermissionSet, + vaultsPermissionUnset, + vaultsPull, + vaultsRename, + vaultsScan, + vaultsSecretsDelete, + vaultsSecretsEdit, + vaultsSecretsGet, + vaultsSecretsList, + vaultsSecretsMkdir, + vaultsSecretsNew, + vaultsSecretsNewDir, + vaultsSecretsRename, + vaultsSecretsStat, + vaultsVersion, +}; diff --git a/src/client/handlers/keysCertsChainGet.ts b/src/client/handlers/keysCertsChainGet.ts index d7b1fb887..939f42797 100644 --- a/src/client/handlers/keysCertsChainGet.ts +++ b/src/client/handlers/keysCertsChainGet.ts @@ -1,9 +1,12 @@ -import type { CertMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + CertMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, +} from '../types'; import type CertManager from '../../keys/CertManager'; import { ServerHandler } from '@matrixai/rpc'; -class KeysCertsChainGetHandler extends ServerHandler< +class KeysCertsChainGet extends ServerHandler< { certManager: CertManager; }, @@ -26,4 +29,4 @@ class KeysCertsChainGetHandler extends ServerHandler< } } -export { KeysCertsChainGetHandler }; +export default KeysCertsChainGet; diff --git a/src/client/handlers/keysCertsGet.ts b/src/client/handlers/keysCertsGet.ts index eb81d447b..8b499c187 100644 --- a/src/client/handlers/keysCertsGet.ts +++ b/src/client/handlers/keysCertsGet.ts @@ -1,9 +1,12 @@ -import type { CertMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + CertMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, +} from '../types'; import type CertManager from '../../keys/CertManager'; import { UnaryHandler } from '@matrixai/rpc'; -class KeysCertsGetHandler extends UnaryHandler< +class KeysCertsGet extends UnaryHandler< { certManager: CertManager; }, @@ -19,4 +22,4 @@ class KeysCertsGetHandler extends UnaryHandler< }; } -export { KeysCertsGetHandler }; +export default KeysCertsGet; diff --git a/src/client/handlers/keysDecrypt.ts b/src/client/handlers/keysDecrypt.ts index 74237d81d..4f3bb2c4d 100644 --- a/src/client/handlers/keysDecrypt.ts +++ b/src/client/handlers/keysDecrypt.ts @@ -1,10 +1,13 @@ -import type { DataMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + DataMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import { UnaryHandler } from '@matrixai/rpc'; import { never } from '../../utils/index'; -class KeysDecryptHandler extends UnaryHandler< +class KeysDecrypt extends UnaryHandler< { keyRing: KeyRing; }, @@ -23,4 +26,4 @@ class KeysDecryptHandler extends UnaryHandler< }; } -export { KeysDecryptHandler }; +export default KeysDecrypt; diff --git a/src/client/handlers/keysEncrypt.ts b/src/client/handlers/keysEncrypt.ts index 07c169e24..cd0ea77fc 100644 --- a/src/client/handlers/keysEncrypt.ts +++ b/src/client/handlers/keysEncrypt.ts @@ -1,5 +1,9 @@ -import type { DataMessage, DecryptMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + DataMessage, + DecryptMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import type { PublicKey } from '../../keys/types'; import { UnaryHandler } from '@matrixai/rpc'; @@ -7,7 +11,7 @@ import { never } from '../../utils/index'; import * as keysUtils from '../../keys/utils/index'; import * as keysErrors from '../../keys/errors'; -class KeysEncryptHandler extends UnaryHandler< +class KeysEncrypt extends UnaryHandler< { keyRing: KeyRing; }, @@ -34,4 +38,4 @@ class KeysEncryptHandler extends UnaryHandler< }; } -export { KeysEncryptHandler }; +export default KeysEncrypt; diff --git a/src/client/handlers/keysKeyPair.ts b/src/client/handlers/keysKeyPair.ts index c29a79147..3e62e4a09 100644 --- a/src/client/handlers/keysKeyPair.ts +++ b/src/client/handlers/keysKeyPair.ts @@ -1,10 +1,14 @@ -import type { KeyPairMessage, PasswordMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + KeyPairMessage, + PasswordMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import { UnaryHandler } from '@matrixai/rpc'; import * as keysUtils from '../../keys/utils/index'; -class KeysKeyPairHandler extends UnaryHandler< +class KeysKeyPair extends UnaryHandler< { keyRing: KeyRing; }, @@ -28,4 +32,4 @@ class KeysKeyPairHandler extends UnaryHandler< }; } -export { KeysKeyPairHandler }; +export default KeysKeyPair; diff --git a/src/client/handlers/keysKeyPairRenew.ts b/src/client/handlers/keysKeyPairRenew.ts index 314344d04..236c87690 100644 --- a/src/client/handlers/keysKeyPairRenew.ts +++ b/src/client/handlers/keysKeyPairRenew.ts @@ -1,9 +1,12 @@ -import type { PasswordMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PasswordMessage, +} from '../types'; import type CertManager from '../../keys/CertManager'; import { UnaryHandler } from '@matrixai/rpc'; -class KeysKeyPairRenewHandler extends UnaryHandler< +class KeysKeyPairRenew extends UnaryHandler< { certManager: CertManager; }, @@ -23,4 +26,4 @@ class KeysKeyPairRenewHandler extends UnaryHandler< }; } -export { KeysKeyPairRenewHandler }; +export default KeysKeyPairRenew; diff --git a/src/client/handlers/keysKeyPairReset.ts b/src/client/handlers/keysKeyPairReset.ts index dde105db8..92dd634ce 100644 --- a/src/client/handlers/keysKeyPairReset.ts +++ b/src/client/handlers/keysKeyPairReset.ts @@ -1,9 +1,12 @@ -import type { PasswordMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PasswordMessage, +} from '../types'; import type CertManager from '../../keys/CertManager'; import { UnaryHandler } from '@matrixai/rpc'; -class KeysKeyPairResethandler extends UnaryHandler< +class KeysKeyPairReset extends UnaryHandler< { certManager: CertManager; }, @@ -21,4 +24,4 @@ class KeysKeyPairResethandler extends UnaryHandler< }; } -export { KeysKeyPairResethandler }; +export default KeysKeyPairReset; diff --git a/src/client/handlers/keysPasswordChange.ts b/src/client/handlers/keysPasswordChange.ts index 3f2acc3a5..14640e4e8 100644 --- a/src/client/handlers/keysPasswordChange.ts +++ b/src/client/handlers/keysPasswordChange.ts @@ -1,9 +1,12 @@ -import type { PasswordMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PasswordMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import { UnaryHandler } from '@matrixai/rpc'; -class KeysPasswordChangeHandler extends UnaryHandler< +class KeysPasswordChange extends UnaryHandler< { keyRing: KeyRing; }, @@ -19,4 +22,4 @@ class KeysPasswordChangeHandler extends UnaryHandler< }; } -export { KeysPasswordChangeHandler }; +export default KeysPasswordChange; diff --git a/src/client/handlers/keysPublicKey.ts b/src/client/handlers/keysPublicKey.ts index 5c6a9be3d..f0710fa46 100644 --- a/src/client/handlers/keysPublicKey.ts +++ b/src/client/handlers/keysPublicKey.ts @@ -1,10 +1,14 @@ -import type { PasswordMessage, PublicKeyMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PasswordMessage, + PublicKeyMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import { UnaryHandler } from '@matrixai/rpc'; import * as keysUtils from '../../keys/utils/index'; -class KeysPublicKeyHandler extends UnaryHandler< +class KeysPublicKey extends UnaryHandler< { keyRing: KeyRing; }, @@ -22,4 +26,4 @@ class KeysPublicKeyHandler extends UnaryHandler< }; } -export { KeysPublicKeyHandler }; +export default KeysPublicKey; diff --git a/src/client/handlers/keysSign.ts b/src/client/handlers/keysSign.ts index 5244df295..9033686a8 100644 --- a/src/client/handlers/keysSign.ts +++ b/src/client/handlers/keysSign.ts @@ -1,9 +1,13 @@ -import type { DataMessage, SignatureMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + DataMessage, + SignatureMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import { UnaryHandler } from '@matrixai/rpc'; -class KeysSignHandler extends UnaryHandler< +class KeysSign extends UnaryHandler< { keyRing: KeyRing; }, @@ -21,4 +25,4 @@ class KeysSignHandler extends UnaryHandler< }; } -export { KeysSignHandler }; +export default KeysSign; diff --git a/src/client/handlers/keysVerify.ts b/src/client/handlers/keysVerify.ts index e2429693f..5a5453538 100644 --- a/src/client/handlers/keysVerify.ts +++ b/src/client/handlers/keysVerify.ts @@ -1,5 +1,9 @@ -import type { SuccessMessage, VerifySignatureMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SuccessMessage, + VerifySignatureMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import type { PublicKey, Signature } from '../../keys/types'; import { UnaryHandler } from '@matrixai/rpc'; @@ -7,7 +11,7 @@ import * as keysUtils from '../../keys/utils/index'; import { never } from '../../utils/index'; import * as keysErrors from '../../keys/errors'; -class KeysVerifyHandler extends UnaryHandler< +class KeysVerify extends UnaryHandler< { keyRing: KeyRing; }, @@ -37,4 +41,4 @@ class KeysVerifyHandler extends UnaryHandler< }; } -export { KeysVerifyHandler }; +export default KeysVerify; diff --git a/src/client/handlers/nodesAdd.ts b/src/client/handlers/nodesAdd.ts index 8f52aff8f..f5b2e5faa 100644 --- a/src/client/handlers/nodesAdd.ts +++ b/src/client/handlers/nodesAdd.ts @@ -1,6 +1,9 @@ import type { DB } from '@matrixai/db'; -import type { NodesAddMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodesAddMessage, +} from '../types'; import type { NodeId } from '../../ids'; import type { Host, Hostname, Port } from '../../network/types'; import type { NodeAddress } from '../../nodes/types'; @@ -11,7 +14,7 @@ import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import * as nodeErrors from '../../nodes/errors'; -class NodesAddHandler extends UnaryHandler< +class NodesAdd extends UnaryHandler< { nodeManager: NodeManager; db: DB; @@ -74,4 +77,4 @@ class NodesAddHandler extends UnaryHandler< }; } -export { NodesAddHandler }; +export default NodesAdd; diff --git a/src/client/handlers/nodesClaim.ts b/src/client/handlers/nodesClaim.ts index d57afaf98..91112bc1b 100644 --- a/src/client/handlers/nodesClaim.ts +++ b/src/client/handlers/nodesClaim.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { ClaimNodeMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClaimNodeMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, + SuccessMessage, +} from '../types'; import type { NodeId } from '../../ids'; import type NodeManager from '../../nodes/NodeManager'; import { UnaryHandler } from '@matrixai/rpc'; @@ -8,7 +12,7 @@ import { matchSync } from '../../utils/index'; import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; -class NodesClaimHandler extends UnaryHandler< +class NodesClaim extends UnaryHandler< { nodeManager: NodeManager; db: DB; @@ -47,4 +51,4 @@ class NodesClaimHandler extends UnaryHandler< }; } -export { NodesClaimHandler }; +export default NodesClaim; diff --git a/src/client/handlers/nodesFind.ts b/src/client/handlers/nodesFind.ts index 4c418a99e..ad3edc3d3 100644 --- a/src/client/handlers/nodesFind.ts +++ b/src/client/handlers/nodesFind.ts @@ -1,5 +1,9 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; -import type { AddressMessage, NodeIdMessage } from '../handlers/types'; +import type { + AddressMessage, + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, +} from '../types'; import type { NodeId } from '../../ids'; import type NodeConnectionManager from '../../nodes/NodeConnectionManager'; import { UnaryHandler } from '@matrixai/rpc'; @@ -8,7 +12,7 @@ import { matchSync } from '../../utils'; import * as validationUtils from '../../validation/utils'; import * as nodesErrors from '../../nodes/errors'; -class NodesFindHandler extends UnaryHandler< +class NodesFind extends UnaryHandler< { nodeConnectionManager: NodeConnectionManager; }, @@ -45,4 +49,4 @@ class NodesFindHandler extends UnaryHandler< }; } -export { NodesFindHandler }; +export default NodesFind; diff --git a/src/client/handlers/nodesGetAll.ts b/src/client/handlers/nodesGetAll.ts index 52e56b839..ee735aa17 100644 --- a/src/client/handlers/nodesGetAll.ts +++ b/src/client/handlers/nodesGetAll.ts @@ -1,13 +1,16 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodesGetMessage, +} from '../types'; import type KeyRing from '../../keys/KeyRing'; import type { NodeId } from '../../ids'; import type NodeGraph from '../../nodes/NodeGraph'; -import type { NodesGetMessage } from '../handlers/types'; import { IdInternal } from '@matrixai/id'; import { ServerHandler } from '@matrixai/rpc'; import * as nodesUtils from '../../nodes/utils'; -class NodesGetAllHandler extends ServerHandler< +class NodesGetAll extends ServerHandler< { nodeGraph: NodeGraph; keyRing: KeyRing; @@ -48,4 +51,4 @@ class NodesGetAllHandler extends ServerHandler< } } -export { NodesGetAllHandler }; +export default NodesGetAll; diff --git a/src/client/handlers/nodesListConnections.ts b/src/client/handlers/nodesListConnections.ts index 06e8afecb..98d4c972b 100644 --- a/src/client/handlers/nodesListConnections.ts +++ b/src/client/handlers/nodesListConnections.ts @@ -1,10 +1,13 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; -import type { NodeConnectionMessage } from '../handlers/types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeConnectionMessage, +} from '../types'; import type NodeConnectionManager from '../../nodes/NodeConnectionManager'; import { ServerHandler } from '@matrixai/rpc'; import * as nodesUtils from '../../nodes/utils'; -class NodesListConnectionsHandler extends ServerHandler< +class NodesListConnections extends ServerHandler< { nodeConnectionManager: NodeConnectionManager; }, @@ -33,4 +36,4 @@ class NodesListConnectionsHandler extends ServerHandler< } } -export { NodesListConnectionsHandler }; +export default NodesListConnections; diff --git a/src/client/handlers/nodesPing.ts b/src/client/handlers/nodesPing.ts index 3ab82eb2a..0e6a79727 100644 --- a/src/client/handlers/nodesPing.ts +++ b/src/client/handlers/nodesPing.ts @@ -1,13 +1,17 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, + SuccessMessage, +} from '../types'; import type { NodeId } from '../../ids'; -import type { NodeIdMessage, SuccessMessage } from '../handlers/types'; import type NodeManager from '../../nodes/NodeManager'; import { UnaryHandler } from '@matrixai/rpc'; import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils'; -class NodesPingHandler extends UnaryHandler< +class NodesPing extends UnaryHandler< { nodeManager: NodeManager; }, @@ -40,4 +44,4 @@ class NodesPingHandler extends UnaryHandler< }; } -export { NodesPingHandler }; +export default NodesPing; diff --git a/src/client/handlers/notificationsClear.ts b/src/client/handlers/notificationsClear.ts index 6916aaa60..aa895e5be 100644 --- a/src/client/handlers/notificationsClear.ts +++ b/src/client/handlers/notificationsClear.ts @@ -3,7 +3,7 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; import type NotificationsManager from '../../notifications/NotificationsManager'; import { UnaryHandler } from '@matrixai/rpc'; -class NotificationsClearHandler extends UnaryHandler< +class NotificationsClear extends UnaryHandler< { db: DB; notificationsManager: NotificationsManager; @@ -20,4 +20,4 @@ class NotificationsClearHandler extends UnaryHandler< }; } -export { NotificationsClearHandler }; +export default NotificationsClear; diff --git a/src/client/handlers/notificationsRead.ts b/src/client/handlers/notificationsRead.ts index 7a90ab706..90fcb7441 100644 --- a/src/client/handlers/notificationsRead.ts +++ b/src/client/handlers/notificationsRead.ts @@ -1,10 +1,14 @@ import type { DB } from '@matrixai/db'; -import type { NotificationMessage, NotificationReadMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NotificationMessage, + NotificationReadMessage, +} from '../types'; import type NotificationsManager from '../../notifications/NotificationsManager'; import { ServerHandler } from '@matrixai/rpc'; -class NotificationsReadHandler extends ServerHandler< +class NotificationsRead extends ServerHandler< { db: DB; notificationsManager: NotificationsManager; @@ -37,4 +41,4 @@ class NotificationsReadHandler extends ServerHandler< } } -export { NotificationsReadHandler }; +export default NotificationsRead; diff --git a/src/client/handlers/notificationsSend.ts b/src/client/handlers/notificationsSend.ts index 27e08d565..48d1d6d2c 100644 --- a/src/client/handlers/notificationsSend.ts +++ b/src/client/handlers/notificationsSend.ts @@ -1,5 +1,8 @@ -import type { NotificationSendMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NotificationSendMessage, +} from '../types'; import type { NodeId } from '../../ids'; import type { General } from '../../notifications/types'; import type NotificationsManager from '../../notifications/NotificationsManager'; @@ -8,7 +11,7 @@ import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils'; -class NotificationsSendHandler extends UnaryHandler< +class NotificationsSend extends UnaryHandler< { notificationsManager: NotificationsManager; }, @@ -44,4 +47,4 @@ class NotificationsSendHandler extends UnaryHandler< }; } -export { NotificationsSendHandler }; +export default NotificationsSend; diff --git a/src/client/handlers/serverManifest.ts b/src/client/handlers/serverManifest.ts deleted file mode 100644 index 0c8d10a4b..000000000 --- a/src/client/handlers/serverManifest.ts +++ /dev/null @@ -1,203 +0,0 @@ -import type Logger from '@matrixai/logger'; -import type { DB } from '@matrixai/db'; -import type SessionManager from '../../sessions/SessionManager'; -import type KeyRing from '../../keys/KeyRing'; -import type CertManager from '../../keys/CertManager'; -import type PolykeyAgent from '../../PolykeyAgent'; -import type GestaltGraph from '../../gestalts/GestaltGraph'; -import type Discovery from '../../discovery/Discovery'; -import type IdentitiesManager from '../../identities/IdentitiesManager'; -import type { NotificationsManager } from '../../notifications/index'; -import type ACL from '../../acl/ACL'; -import type NodeManager from '../../nodes/NodeManager'; -import type NodeConnectionManager from '../../nodes/NodeConnectionManager'; -import type NodeGraph from '../../nodes/NodeGraph'; -import type VaultManager from '../../vaults/VaultManager'; -import type { FileSystem } from '../../types'; -import { VaultsCloneHandler } from './vaultsClone'; -import { VaultsCreateHandler } from './vaultsCreate'; -import { VaultsDeleteHandler } from './vaultsDelete'; -import { VaultsListHandler } from './vaultsList'; -import { VaultsLogHandler } from './vaultsLog'; -import { VaultsPermissionGetHandler } from './vaultsPermissionGet'; -import { VaultsPermissionSetHandler } from './vaultsPermissionSet'; -import { VaultsPermissionUnsetHandler } from './vaultsPermissionUnset'; -import { NodesAddHandler } from './nodesAdd'; -import { NodesClaimHandler } from './nodesClaim'; -import { NodesFindHandler } from './nodesFind'; -import { NodesGetAllHandler } from './nodesGetAll'; -import { NodesListConnectionsHandler } from './nodesListConnections'; -import { NodesPingHandler } from './nodesPing'; -import { GestaltsActionsGetByIdentityHandler } from './gestaltsActionsGetByIdentity'; -import { GestaltsActionsGetByNodeHandler } from './gestaltsActionsGetByNode'; -import { GestaltsActionsSetByIdentityHandler } from './gestaltsActionsSetByIdentity'; -import { GestaltsActionsSetByNodeHandler } from './gestaltsActionsSetByNode'; -import { GestaltsActionsUnsetByIdentityHandler } from './gestaltsActionsUnsetByIdentity'; -import { GestaltsActionsUnsetByNodeHandler } from './gestaltsActionsUnsetByNode'; -import { GestaltsDiscoveryByIdentityHandler } from './gestaltsDiscoveryByIdentity'; -import { GestaltsDiscoveryByNodeHandler } from './gestaltsDiscoveryByNode'; -import { GestaltsGestaltGetByIdentityHandler } from './gestaltsGestaltGetByIdentity'; -import { GestaltsGestaltGetByNodeHandler } from './gestaltsGestaltGetByNode'; -import { GestaltsGestaltListHandler } from './gestaltsGestaltList'; -import { GestaltsGestaltTrustByIdentityHandler } from './gestaltsGestaltTrustByIdentity'; -import { GestaltsGestaltTrustByNodeHandler } from './gestaltsGestaltTrustByNode'; -import { IdentitiesAuthenticateHandler } from './identitiesAuthenticate'; -import { IdentitiesAuthenticatedGetHandler } from './identitiesAuthenticatedGet'; -import { IdentitiesClaimHandler } from './identitiesClaim'; -import { AgentStatusHandler } from './agentStatus'; -import { AgentStopHandler } from './agentStop'; -import { AgentUnlockHandler } from './agentUnlock'; -import { AgentLockAllHandler } from './agentLockAll'; -import { IdentitiesInfoGetHandler } from './identitiesInfoGet'; -import { IdentitiesInfoConnectedGetHandler } from './identitiesInfoConnectedGet'; -import { IdentitiesInviteHandler } from './identitiesInvite'; -import { IdentitiesProvidersListHandler } from './identitiesProvidersList'; -import { IdentitiesTokenDeleteHandler } from './identitiesTokenDelete'; -import { IdentitiesTokenGetHandler } from './identitiesTokenGet'; -import { IdentitiesTokenPutHandler } from './identitiesTokenPut'; -import { KeysCertsChainGetHandler } from './keysCertsChainGet'; -import { KeysCertsGetHandler } from './keysCertsGet'; -import { KeysDecryptHandler } from './keysDecrypt'; -import { KeysEncryptHandler } from './keysEncrypt'; -import { KeysKeyPairHandler } from './keysKeyPair'; -import { KeysKeyPairRenewHandler } from './keysKeyPairRenew'; -import { KeysKeyPairResethandler } from './keysKeyPairReset'; -import { KeysPasswordChangeHandler } from './keysPasswordChange'; -import { KeysPublicKeyHandler } from './keysPublicKey'; -import { NotificationsClearHandler } from './notificationsClear'; -import { NotificationsReadHandler } from './notificationsRead'; -import { NotificationsSendHandler } from './notificationsSend'; -import { VaultsPullHandler } from './vaultsPull'; -import { VaultsRenameHandler } from './vaultsRename'; -import { VaultsScanHandler } from './vaultsScan'; -import { VaultsSecretsDeleteHandler } from './vaultsSecretsDelete'; -import { VaultsSecretsEditHandler } from './vaultsSecretsEdit'; -import { VaultsSecretsGetHandler } from './vaultsSecretsGet'; -import { VaultsSecretsListHandler } from './vaultsSecretsList'; -import { VaultsSecretsMkdirHandler } from './vaultsSecretsMkdir'; -import { VaultsSecretsNewHandler } from './vaultsSecretsNew'; -import { VaultsSecretsNewDirHandler } from './vaultsSecretsNewDir'; -import { VaultsSecretsRenameHandler } from './vaultsSecretsRename'; -import { VaultsSecretsStatHandler } from './vaultsSecretsStat'; -import { VaultsVersionHandler } from './vaultsVersion'; -import { KeysVerifyHandler } from '../../client/handlers/keysVerify'; -import { KeysSignHandler } from '../../client/handlers/keysSign'; - -/** - * All the server handler definitions for the ClientServer RPC. - * This will take the container of all the required dependencies and create the server handlers. - * - * Used by the RPCServer to register handlers and enforce types. - */ -const serverManifest = (container: { - pkAgentProm: Promise; - keyRing: KeyRing; - certManager: CertManager; - db: DB; - sessionManager: SessionManager; - gestaltGraph: GestaltGraph; - identitiesManager: IdentitiesManager; - discovery: Discovery; - acl: ACL; - notificationsManager: NotificationsManager; - nodeManager: NodeManager; - nodeConnectionManager: NodeConnectionManager; - nodeGraph: NodeGraph; - vaultManager: VaultManager; - fs: FileSystem; - logger: Logger; -}) => { - // No type used here, it will override type inference - return { - agentLockAll: new AgentLockAllHandler(container), - agentStatus: new AgentStatusHandler(container), - agentStop: new AgentStopHandler(container), - agentUnlock: new AgentUnlockHandler(container), - gestaltsActionsGetByIdentity: new GestaltsActionsGetByIdentityHandler( - container, - ), - gestaltsActionsGetByNode: new GestaltsActionsGetByNodeHandler(container), - gestaltsActionsSetByIdentity: new GestaltsActionsSetByIdentityHandler( - container, - ), - gestaltsActionsSetByNode: new GestaltsActionsSetByNodeHandler(container), - gestaltsActionsUnsetByIdentity: new GestaltsActionsUnsetByIdentityHandler( - container, - ), - gestaltsActionsUnsetByNode: new GestaltsActionsUnsetByNodeHandler( - container, - ), - gestaltsDiscoveryByIdentity: new GestaltsDiscoveryByIdentityHandler( - container, - ), - gestaltsDiscoveryByNode: new GestaltsDiscoveryByNodeHandler(container), - gestaltsGestaltGetByIdentity: new GestaltsGestaltGetByIdentityHandler( - container, - ), - gestaltsGestaltGetByNode: new GestaltsGestaltGetByNodeHandler(container), - gestaltsGestaltList: new GestaltsGestaltListHandler(container), - gestaltsGestaltTrustByIdentity: new GestaltsGestaltTrustByIdentityHandler( - container, - ), - gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNodeHandler( - container, - ), - identitiesAuthenticate: new IdentitiesAuthenticateHandler(container), - identitiesAuthenticatedGet: new IdentitiesAuthenticatedGetHandler( - container, - ), - identitiesClaim: new IdentitiesClaimHandler(container), - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler( - container, - ), - identitiesInfoGet: new IdentitiesInfoGetHandler(container), - identitiesInvite: new IdentitiesInviteHandler(container), - identitiesProvidersList: new IdentitiesProvidersListHandler(container), - identitiesTokenDelete: new IdentitiesTokenDeleteHandler(container), - identitiesTokenGet: new IdentitiesTokenGetHandler(container), - identitiesTokenPut: new IdentitiesTokenPutHandler(container), - keysCertsChainGet: new KeysCertsChainGetHandler(container), - keysCertsGet: new KeysCertsGetHandler(container), - keysDecrypt: new KeysDecryptHandler(container), - keysEncrypt: new KeysEncryptHandler(container), - keysKeyPair: new KeysKeyPairHandler(container), - keysKeyPairRenew: new KeysKeyPairRenewHandler(container), - keysKeyPairReset: new KeysKeyPairResethandler(container), - keysPasswordChange: new KeysPasswordChangeHandler(container), - keysPublicKey: new KeysPublicKeyHandler(container), - keysSign: new KeysSignHandler(container), - keysVerify: new KeysVerifyHandler(container), - nodesAdd: new NodesAddHandler(container), - nodesClaim: new NodesClaimHandler(container), - nodesFind: new NodesFindHandler(container), - nodesGetAll: new NodesGetAllHandler(container), - nodesListConnections: new NodesListConnectionsHandler(container), - nodesPing: new NodesPingHandler(container), - notificationsClear: new NotificationsClearHandler(container), - notificationsRead: new NotificationsReadHandler(container), - notificationsSend: new NotificationsSendHandler(container), - vaultsClone: new VaultsCloneHandler(container), - vaultsCreate: new VaultsCreateHandler(container), - vaultsDelete: new VaultsDeleteHandler(container), - vaultsList: new VaultsListHandler(container), - vaultsLog: new VaultsLogHandler(container), - vaultsPermissionGet: new VaultsPermissionGetHandler(container), - vaultsPermissionSet: new VaultsPermissionSetHandler(container), - vaultsPermissionUnset: new VaultsPermissionUnsetHandler(container), - vaultsPull: new VaultsPullHandler(container), - vaultsRename: new VaultsRenameHandler(container), - vaultsScan: new VaultsScanHandler(container), - vaultsSecretsDelete: new VaultsSecretsDeleteHandler(container), - vaultsSecretsEdit: new VaultsSecretsEditHandler(container), - vaultsSecretsGet: new VaultsSecretsGetHandler(container), - vaultsSecretsList: new VaultsSecretsListHandler(container), - vaultsSecretsMkdir: new VaultsSecretsMkdirHandler(container), - vaultsSecretsNew: new VaultsSecretsNewHandler(container), - vaultsSecretsNewDir: new VaultsSecretsNewDirHandler(container), - vaultsSecretsRename: new VaultsSecretsRenameHandler(container), - vaultsSecretsStat: new VaultsSecretsStatHandler(container), - vaultsVersion: new VaultsVersionHandler(container), - }; -}; - -export { serverManifest }; diff --git a/src/client/handlers/types.ts b/src/client/handlers/types.ts deleted file mode 100644 index 8d9300704..000000000 --- a/src/client/handlers/types.ts +++ /dev/null @@ -1,281 +0,0 @@ -import type { IdentityId, ProviderId, VaultIdEncoded } from '../../ids'; -import type { GestaltAction } from '../../gestalts/types'; -import type { ProviderToken } from '../../identities/types'; -import type { GestaltIdEncoded, NodeIdEncoded } from '../../ids'; -import type { - CertificatePEM, - CertificatePEMChain, - JWKEncrypted, - PublicKeyJWK, -} from '../../keys/types'; -import type { Notification } from '../../notifications/types'; -import type { CommitId, VaultAction, VaultName } from '../../vaults/types'; - -// Agent messages -export type StatusResultMessage = { - pid: number; -} & NodeIdMessage & - PublicKeyMessage & { - clientHost: string; - clientPort: number; - agentHost: string; - agentPort: number; - certChainPEM: CertificatePEMChain; - }; - -// Identity messages -export type IdentityMessage = { - providerId: string; - identityId: string; -}; - -export type ProviderSearchMessage = { - authIdentityId?: string; - identityId: string; - disconnected: boolean; - limit?: number; - searchTermList?: Array; - providerIdList: Array; -}; - -export type IdentityInfoMessage = IdentityMessage & { - name: string; - email: string; - url: string; -}; - -export type AuthProcessMessage = { - request?: { - url: string; - dataMap: Record; - }; - response?: { - identityId: string; - }; -}; - -export type ClaimIdMessage = { - claimId: string; - url?: string; -}; - -export type ClaimNodeMessage = NodeIdMessage & { - forceInvite?: boolean; -}; - -export type TokenMessage = { - token: ProviderToken; -}; - -// Nodes messages -export type NodeIdMessage = { - nodeIdEncoded: NodeIdEncoded; -}; - -export type AddressMessage = { - host: string; - port: number; -}; - -export type NodeAddressMessage = NodeIdMessage & AddressMessage; - -export type NodesGetMessage = NodeAddressMessage & { bucketIndex: number }; - -export type NodesAddMessage = NodeAddressMessage & { - force?: boolean; - ping?: boolean; -}; - -export type NodeConnectionMessage = NodeAddressMessage & { - hostname: string; - usageCount: number; - timeout: number; -}; - -// Gestalts messages -export type ActionsListMessage = { - actionsList: Array; -}; - -export type SetIdentityActionMessage = IdentityMessage & { - action: GestaltAction; -}; - -export type SetNodeActionMessage = NodeIdMessage & { - action: GestaltAction; -}; - -export type GestaltMessage = { - gestalt: { - matrix: Record>; - nodes: Record; - identities: Record< - GestaltIdEncoded, - { - providerId: ProviderId; - identityId: IdentityId; - name?: string; - email?: string; - url?: string; - } - >; - }; -}; - -// Keys messages -export type CertMessage = { - cert: CertificatePEM; -}; - -export type DataMessage = { - data: string; -}; - -export type PublicKeyMessage = { - publicKeyJwk: PublicKeyJWK; -}; - -export type PrivateKeyMessage = { - privateKeyJwe: JWKEncrypted; -}; - -export type DecryptMessage = DataMessage & PublicKeyMessage; - -export type PasswordMessage = { - password: string; -}; - -export type KeyPairMessage = PrivateKeyMessage & PublicKeyMessage; - -export type SignatureMessage = { - signature: string; -}; - -export type VerifySignatureMessage = PublicKeyMessage & - DataMessage & - SignatureMessage; - -export type SuccessMessage = { - success: boolean; -}; - -// Notifications messages -export type NotificationReadMessage = { - unread?: boolean; - number?: number | 'all'; - order?: 'newest' | 'oldest'; -}; - -export type NotificationMessage = { - notification: Notification; -}; - -export type NotificationSendMessage = NodeIdMessage & { - message: string; -}; - -// Vaults messages -export type VaultNameMessage = { - vaultName: VaultName; -}; - -export type VaultIdMessage = { - vaultIdEncoded: VaultIdEncoded; -}; - -export type VaultIdentifierMessage = { - nameOrId: VaultIdEncoded | VaultName; -}; -export type CloneMessage = NodeIdMessage & VaultIdentifierMessage; - -export type VaultListMessage = VaultNameMessage & VaultIdMessage; - -export type VaultsLogMessage = VaultIdentifierMessage & { - depth?: number; - commitId?: string; -}; - -export type LogEntryMessage = { - commitId: CommitId; - committer: string; - timestamp: string; - message: string; -}; - -export type VaultPermissionMessage = VaultIdMessage & - NodeIdMessage & { - vaultPermissionList: Array; - }; - -export type PermissionSetMessage = VaultIdentifierMessage & - NodeIdMessage & { - vaultPermissionList: Array; - }; - -export type VaultsPullMessage = Partial & { - pullVault: VaultIdEncoded | VaultName; -}; - -export type VaultsRenameMessage = VaultIdentifierMessage & { - newName: VaultName; -}; - -export type VaultsScanMessage = VaultListMessage & { - permissions: Array; -}; - -export type VaultsVersionMessage = VaultIdentifierMessage & { - versionId: string; -}; - -export type VaultsLatestVersionMessage = { - latestVersion: boolean; -}; - -// Secrets -export type SecretNameMessage = { - secretName: string; -}; - -export type SecretIdentifierMessage = VaultIdentifierMessage & - SecretNameMessage; - -// Contains binary content as a binary string 'toString('binary')' -export type ContentMessage = { - secretContent: string; -}; - -export type SecretContentMessage = SecretIdentifierMessage & ContentMessage; - -export type SecretMkdirMessage = VaultIdentifierMessage & { - dirName: string; - recursive: boolean; -}; - -export type SecretDirMessage = VaultIdentifierMessage & { - dirName: string; -}; - -export type SecretRenameMessage = SecretIdentifierMessage & { - newSecretName: string; -}; - -// Stat is the 'JSON.stringify version of the file stat -export type SecretStatMessage = { - stat: { - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - atime: string; - mtime: string; - ctime: string; - birthtime: string; - blksize: number; - blocks: number; - }; -}; diff --git a/src/client/handlers/vaultsClone.ts b/src/client/handlers/vaultsClone.ts index 1a36779c4..48d331a23 100644 --- a/src/client/handlers/vaultsClone.ts +++ b/src/client/handlers/vaultsClone.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { CloneMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + CloneMessage, + SuccessMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type { NodeId } from '../../ids'; import { UnaryHandler } from '@matrixai/rpc'; @@ -8,7 +12,7 @@ import { validateSync } from '../../validation'; import { matchSync } from '../../utils'; import * as validationUtils from '../../validation/utils'; -class VaultsCloneHandler extends UnaryHandler< +class VaultsClone extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -45,4 +49,4 @@ class VaultsCloneHandler extends UnaryHandler< }; } -export { VaultsCloneHandler }; +export default VaultsClone; diff --git a/src/client/handlers/vaultsCreate.ts b/src/client/handlers/vaultsCreate.ts index 9c988851d..2b2aba40f 100644 --- a/src/client/handlers/vaultsCreate.ts +++ b/src/client/handlers/vaultsCreate.ts @@ -1,11 +1,15 @@ import type { DB } from '@matrixai/db'; -import type { VaultIdMessage, VaultNameMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + VaultIdMessage, + VaultNameMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import { UnaryHandler } from '@matrixai/rpc'; import * as vaultsUtils from '../../vaults/utils'; -class VaultsCreateHandler extends UnaryHandler< +class VaultsCreate extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -28,4 +32,4 @@ class VaultsCreateHandler extends UnaryHandler< }; } -export { VaultsCreateHandler }; +export default VaultsCreate; diff --git a/src/client/handlers/vaultsDelete.ts b/src/client/handlers/vaultsDelete.ts index fb8e409be..efc7938c9 100644 --- a/src/client/handlers/vaultsDelete.ts +++ b/src/client/handlers/vaultsDelete.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SuccessMessage, VaultIdentifierMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SuccessMessage, + VaultIdentifierMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type { VaultName } from '../../vaults/types'; import { UnaryHandler } from '@matrixai/rpc'; import * as vaultsUtils from '../../vaults/utils'; import * as vaultsErrors from '../../vaults/errors'; -class VaultsDeleteHandler extends UnaryHandler< +class VaultsDelete extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -37,4 +41,4 @@ class VaultsDeleteHandler extends UnaryHandler< }; } -export { VaultsDeleteHandler }; +export default VaultsDelete; diff --git a/src/client/handlers/vaultsList.ts b/src/client/handlers/vaultsList.ts index 1f338aba1..106856bae 100644 --- a/src/client/handlers/vaultsList.ts +++ b/src/client/handlers/vaultsList.ts @@ -1,11 +1,14 @@ import type { DB } from '@matrixai/db'; -import type { VaultListMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + VaultListMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import { ServerHandler } from '@matrixai/rpc'; import * as vaultsUtils from '../../vaults/utils'; -class VaultsListHandler extends ServerHandler< +class VaultsList extends ServerHandler< { db: DB; vaultManager: VaultManager; @@ -34,4 +37,4 @@ class VaultsListHandler extends ServerHandler< } } -export { VaultsListHandler }; +export default VaultsList; diff --git a/src/client/handlers/vaultsLog.ts b/src/client/handlers/vaultsLog.ts index 5fc55e8d4..a0f0b48a1 100644 --- a/src/client/handlers/vaultsLog.ts +++ b/src/client/handlers/vaultsLog.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { LogEntryMessage, VaultsLogMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + LogEntryMessage, + VaultsLogMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type { VaultName } from '../../vaults/types'; import { ServerHandler } from '@matrixai/rpc'; import * as vaultsUtils from '../../vaults/utils'; import * as vaultsErrors from '../../vaults/errors'; -class VaultsLogHandler extends ServerHandler< +class VaultsLog extends ServerHandler< { db: DB; vaultManager: VaultManager; @@ -54,4 +58,4 @@ class VaultsLogHandler extends ServerHandler< } } -export { VaultsLogHandler }; +export default VaultsLog; diff --git a/src/client/handlers/vaultsPermissionGet.ts b/src/client/handlers/vaultsPermissionGet.ts index 063e34cee..de4dfe00a 100644 --- a/src/client/handlers/vaultsPermissionGet.ts +++ b/src/client/handlers/vaultsPermissionGet.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { VaultIdentifierMessage, VaultPermissionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + VaultIdentifierMessage, + VaultPermissionMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type ACL from '../../acl/ACL'; import type { VaultAction, VaultActions } from '../../vaults/types'; @@ -11,7 +15,7 @@ import * as vaultsUtils from '../../vaults/utils'; import * as vaultsErrors from '../../vaults/errors'; import * as nodesUtils from '../../nodes/utils'; -class VaultsPermissionGetHandler extends ServerHandler< +class VaultsPermissionGet extends ServerHandler< { db: DB; vaultManager: VaultManager; @@ -64,4 +68,4 @@ class VaultsPermissionGetHandler extends ServerHandler< } } -export { VaultsPermissionGetHandler }; +export default VaultsPermissionGet; diff --git a/src/client/handlers/vaultsPermissionSet.ts b/src/client/handlers/vaultsPermissionSet.ts index 1e681f79a..7280dee74 100644 --- a/src/client/handlers/vaultsPermissionSet.ts +++ b/src/client/handlers/vaultsPermissionSet.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { PermissionSetMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PermissionSetMessage, + SuccessMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type GestaltGraph from '../../gestalts/GestaltGraph'; import type ACL from '../../acl/ACL'; @@ -14,7 +18,7 @@ import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils'; -class VaultsPermissionSetHandler extends UnaryHandler< +class VaultsPermissionSet extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -83,4 +87,4 @@ class VaultsPermissionSetHandler extends UnaryHandler< }; } -export { VaultsPermissionSetHandler }; +export default VaultsPermissionSet; diff --git a/src/client/handlers/vaultsPermissionUnset.ts b/src/client/handlers/vaultsPermissionUnset.ts index d8bcdbd99..9ee6bbcc6 100644 --- a/src/client/handlers/vaultsPermissionUnset.ts +++ b/src/client/handlers/vaultsPermissionUnset.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { PermissionSetMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + PermissionSetMessage, + SuccessMessage, +} from '../types'; import type { VaultAction } from '../../vaults/types'; import type { NodeId } from '../../ids'; import type VaultManager from '../../vaults/VaultManager'; @@ -13,7 +17,7 @@ import { validateSync } from '../../validation'; import { matchSync } from '../../utils'; import * as vaultsErrors from '../../vaults/errors'; -class VaultsPermissionUnsetHandler extends UnaryHandler< +class VaultsPermissionUnset extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -85,4 +89,4 @@ class VaultsPermissionUnsetHandler extends UnaryHandler< }; } -export { VaultsPermissionUnsetHandler }; +export default VaultsPermissionUnset; diff --git a/src/client/handlers/vaultsPull.ts b/src/client/handlers/vaultsPull.ts index b58a59d1b..4c9bb9857 100644 --- a/src/client/handlers/vaultsPull.ts +++ b/src/client/handlers/vaultsPull.ts @@ -1,6 +1,10 @@ import type { DB } from '@matrixai/db'; -import type { SuccessMessage, VaultsPullMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SuccessMessage, + VaultsPullMessage, +} from '../types'; import type { VaultName } from '../../vaults/types'; import type { NodeId } from '../../ids'; import type VaultManager from '../../vaults/VaultManager'; @@ -11,7 +15,7 @@ import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils'; -class VaultsPullHandler extends UnaryHandler< +class VaultsPull extends UnaryHandler< { db: DB; vaultManager: VaultManager; @@ -67,4 +71,4 @@ class VaultsPullHandler extends UnaryHandler< }; } -export { VaultsPullHandler }; +export default VaultsPull; diff --git a/src/client/handlers/vaultsRename.ts b/src/client/handlers/vaultsRename.ts index 0b9ae8eec..5d891739f 100644 --- a/src/client/handlers/vaultsRename.ts +++ b/src/client/handlers/vaultsRename.ts @@ -1,12 +1,16 @@ import type { DB } from '@matrixai/db'; -import type { VaultIdMessage, VaultsRenameMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + VaultIdMessage, + VaultsRenameMessage, +} 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'; -class VaultsRenameHandler extends UnaryHandler< +class VaultsRename extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -36,4 +40,4 @@ class VaultsRenameHandler extends UnaryHandler< }; } -export { VaultsRenameHandler }; +export default VaultsRename; diff --git a/src/client/handlers/vaultsScan.ts b/src/client/handlers/vaultsScan.ts index 6a51e3f74..abbfe70f0 100644 --- a/src/client/handlers/vaultsScan.ts +++ b/src/client/handlers/vaultsScan.ts @@ -1,5 +1,9 @@ -import type { NodeIdMessage, VaultsScanMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + NodeIdMessage, + VaultsScanMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import type { NodeId } from '../../ids'; import { ServerHandler } from '@matrixai/rpc'; @@ -7,7 +11,7 @@ import { validateSync } from '../../validation'; import * as validationUtils from '../../validation/utils'; import { matchSync } from '../../utils'; -class VaultsScanHandler extends ServerHandler< +class VaultsScan extends ServerHandler< { vaultManager: VaultManager; }, @@ -52,4 +56,4 @@ class VaultsScanHandler extends ServerHandler< } } -export { VaultsScanHandler }; +export default VaultsScan; diff --git a/src/client/handlers/vaultsSecretsDelete.ts b/src/client/handlers/vaultsSecretsDelete.ts index 94663d7be..f42872a79 100644 --- a/src/client/handlers/vaultsSecretsDelete.ts +++ b/src/client/handlers/vaultsSecretsDelete.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretIdentifierMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +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 VaultsSecretsDeleteHandler extends UnaryHandler< +class VaultsSecretsDelete extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -43,4 +47,4 @@ class VaultsSecretsDeleteHandler extends UnaryHandler< }; } -export { VaultsSecretsDeleteHandler }; +export default VaultsSecretsDelete; diff --git a/src/client/handlers/vaultsSecretsEdit.ts b/src/client/handlers/vaultsSecretsEdit.ts index b4d3e4dc7..a0e896934 100644 --- a/src/client/handlers/vaultsSecretsEdit.ts +++ b/src/client/handlers/vaultsSecretsEdit.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretContentMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretContentMessage, + 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 VaultsSecretsEditHandler extends UnaryHandler< +class VaultsSecretsEdit extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -44,4 +48,4 @@ class VaultsSecretsEditHandler extends UnaryHandler< }; } -export { VaultsSecretsEditHandler }; +export default VaultsSecretsEdit; diff --git a/src/client/handlers/vaultsSecretsGet.ts b/src/client/handlers/vaultsSecretsGet.ts index a22a30f37..448c10248 100644 --- a/src/client/handlers/vaultsSecretsGet.ts +++ b/src/client/handlers/vaultsSecretsGet.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { ContentMessage, SecretIdentifierMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + ContentMessage, + SecretIdentifierMessage, +} 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 VaultsSecretsGetHandler extends UnaryHandler< +class VaultsSecretsGet extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -43,4 +47,4 @@ class VaultsSecretsGetHandler extends UnaryHandler< }; } -export { VaultsSecretsGetHandler }; +export default VaultsSecretsGet; diff --git a/src/client/handlers/vaultsSecretsList.ts b/src/client/handlers/vaultsSecretsList.ts index 89b11230d..c1e1dfbfa 100644 --- a/src/client/handlers/vaultsSecretsList.ts +++ b/src/client/handlers/vaultsSecretsList.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretNameMessage, VaultIdentifierMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretNameMessage, + VaultIdentifierMessage, +} from '../types'; import type VaultManager from '../../vaults/VaultManager'; import { ServerHandler } from '@matrixai/rpc'; import * as vaultsUtils from '../../vaults/utils'; import * as vaultsErrors from '../../vaults/errors'; import * as vaultOps from '../../vaults/VaultOps'; -class VaultsSecretsListHandler extends ServerHandler< +class VaultsSecretsList extends ServerHandler< { vaultManager: VaultManager; db: DB; @@ -50,4 +54,4 @@ class VaultsSecretsListHandler extends ServerHandler< } } -export { VaultsSecretsListHandler }; +export default VaultsSecretsList; diff --git a/src/client/handlers/vaultsSecretsMkdir.ts b/src/client/handlers/vaultsSecretsMkdir.ts index d648868e4..cdcfd86ce 100644 --- a/src/client/handlers/vaultsSecretsMkdir.ts +++ b/src/client/handlers/vaultsSecretsMkdir.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretMkdirMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretMkdirMessage, + 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 VaultsSecretsMkdirHandler extends UnaryHandler< +class VaultsSecretsMkdir extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -45,4 +49,4 @@ class VaultsSecretsMkdirHandler extends UnaryHandler< }; } -export { VaultsSecretsMkdirHandler }; +export default VaultsSecretsMkdir; diff --git a/src/client/handlers/vaultsSecretsNew.ts b/src/client/handlers/vaultsSecretsNew.ts index 17b98d7a0..61744ba24 100644 --- a/src/client/handlers/vaultsSecretsNew.ts +++ b/src/client/handlers/vaultsSecretsNew.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretContentMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretContentMessage, + 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 VaultsSecretsNewHandler extends UnaryHandler< +class VaultsSecretsNew extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -44,4 +48,4 @@ class VaultsSecretsNewHandler extends UnaryHandler< }; } -export { VaultsSecretsNewHandler }; +export default VaultsSecretsNew; diff --git a/src/client/handlers/vaultsSecretsNewDir.ts b/src/client/handlers/vaultsSecretsNewDir.ts index 3d2f91289..2aede5f95 100644 --- a/src/client/handlers/vaultsSecretsNewDir.ts +++ b/src/client/handlers/vaultsSecretsNewDir.ts @@ -1,14 +1,18 @@ import type { FileSystem } from 'types'; import type { DB } from '@matrixai/db'; -import type { SecretDirMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretDirMessage, + 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 VaultsSecretsNewDirHandler extends UnaryHandler< +class VaultsSecretsNewDir extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -45,4 +49,4 @@ class VaultsSecretsNewDirHandler extends UnaryHandler< }; } -export { VaultsSecretsNewDirHandler }; +export default VaultsSecretsNewDir; diff --git a/src/client/handlers/vaultsSecretsRename.ts b/src/client/handlers/vaultsSecretsRename.ts index 6be987042..a2b59011c 100644 --- a/src/client/handlers/vaultsSecretsRename.ts +++ b/src/client/handlers/vaultsSecretsRename.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretRenameMessage, SuccessMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretRenameMessage, + 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 VaultsSecretsRenameHandler extends UnaryHandler< +class VaultsSecretsRename extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -47,4 +51,4 @@ class VaultsSecretsRenameHandler extends UnaryHandler< }; } -export { VaultsSecretsRenameHandler }; +export default VaultsSecretsRename; diff --git a/src/client/handlers/vaultsSecretsStat.ts b/src/client/handlers/vaultsSecretsStat.ts index 8ee9d6c2e..81fb3f5eb 100644 --- a/src/client/handlers/vaultsSecretsStat.ts +++ b/src/client/handlers/vaultsSecretsStat.ts @@ -1,13 +1,17 @@ import type { DB } from '@matrixai/db'; -import type { SecretIdentifierMessage, SecretStatMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + SecretIdentifierMessage, + SecretStatMessage, +} 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 VaultsSecretsStatHandler extends UnaryHandler< +class VaultsSecretsStat extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -59,4 +63,4 @@ class VaultsSecretsStatHandler extends UnaryHandler< }; } -export { VaultsSecretsStatHandler }; +export default VaultsSecretsStat; diff --git a/src/client/handlers/vaultsVersion.ts b/src/client/handlers/vaultsVersion.ts index 73d7c4bd9..23ab02dc6 100644 --- a/src/client/handlers/vaultsVersion.ts +++ b/src/client/handlers/vaultsVersion.ts @@ -1,12 +1,16 @@ import type { DB } from '@matrixai/db'; -import type { VaultsLatestVersionMessage, VaultsVersionMessage } from './types'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { + ClientRPCRequestParams, + ClientRPCResponseResult, + VaultsLatestVersionMessage, + VaultsVersionMessage, +} 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'; -class VaultsVersionHandler extends UnaryHandler< +class VaultsVersion extends UnaryHandler< { vaultManager: VaultManager; db: DB; @@ -48,4 +52,4 @@ class VaultsVersionHandler extends UnaryHandler< }; } -export { VaultsVersionHandler }; +export default VaultsVersion; diff --git a/src/client/index.ts b/src/client/index.ts index 5540ddf94..5bd24a8c3 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -1,4 +1,10 @@ -export * from './handlers'; +export { default as manifestClient } from './callers'; +export { default as manifestServer } from './handlers'; +export * as callers from './callers'; +export * as handlers from './handlers'; export * as utils from './utils'; -export * as types from './types'; +export * as middleware from './middleware'; +export * as authenticationMiddleware from './authenticationMiddleware'; +export * as timeoutMiddleWare from './timeoutMiddleware'; export * as errors from './errors'; +export * as types from './types'; diff --git a/src/client/utils/middleware.ts b/src/client/middleware.ts similarity index 93% rename from src/client/utils/middleware.ts rename to src/client/middleware.ts index e29b241a6..06b179564 100644 --- a/src/client/utils/middleware.ts +++ b/src/client/middleware.ts @@ -1,12 +1,12 @@ -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; -import type { Session } from '../../sessions'; +import type { ClientRPCRequestParams, ClientRPCResponseResult } from './types'; +import type { Session } from '../sessions'; import type { JSONRPCRequest, JSONRPCResponse, MiddlewareFactory, } from '@matrixai/rpc'; -import type SessionManager from '../../sessions/SessionManager'; -import type KeyRing from '../../keys/KeyRing'; +import type SessionManager from '../sessions/SessionManager'; +import type KeyRing from '../keys/KeyRing'; import * as authenticationMiddlewareUtils from './authenticationMiddleware'; import * as timeoutMiddlewareUtils from './timeoutMiddleware'; diff --git a/src/client/utils/timeoutMiddleware.ts b/src/client/timeoutMiddleware.ts similarity index 99% rename from src/client/utils/timeoutMiddleware.ts rename to src/client/timeoutMiddleware.ts index 1ccd7fd62..a66198962 100644 --- a/src/client/utils/timeoutMiddleware.ts +++ b/src/client/timeoutMiddleware.ts @@ -1,6 +1,6 @@ import type { ContextTimed } from '@matrixai/contexts'; import type { JSONRPCRequest, JSONRPCResponse } from '@matrixai/rpc'; -import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types'; +import type { ClientRPCRequestParams, ClientRPCResponseResult } from './types'; import type { JSONValue } from '@matrixai/rpc'; import { TransformStream } from 'stream/web'; diff --git a/src/client/types.ts b/src/client/types.ts index 40682c1ff..5f15e5e38 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -1,4 +1,21 @@ import type { JSONValue, ObjectEmpty } from '../types'; +import type { + GestaltIdEncoded, + IdentityId, + NodeIdEncoded, + ProviderId, + VaultIdEncoded, +} from '../ids'; +import type { GestaltAction } from '../gestalts/types'; +import type { CommitId, VaultAction, VaultName } from '../vaults/types'; +import type { + CertificatePEM, + CertificatePEMChain, + JWKEncrypted, + PublicKeyJWK, +} from '../keys/types'; +import type { Notification } from '../notifications/types'; +import type { ProviderToken } from '../identities/types'; // Prevent overwriting the metadata type with `Omit<>` type ClientRPCRequestParams = ObjectEmpty> = @@ -23,4 +40,333 @@ type ClientRPCResponseResult< }>; } & Omit; -export type { ClientRPCRequestParams, ClientRPCResponseResult }; +type StatusResultMessage = { + pid: number; +} & NodeIdMessage & + PublicKeyMessage & { + clientHost: string; + clientPort: number; + agentHost: string; + agentPort: number; + certChainPEM: CertificatePEMChain; + }; + +// Identity messages + +type IdentityMessage = { + providerId: string; + identityId: string; +}; + +type ProviderSearchMessage = { + authIdentityId?: string; + identityId: string; + disconnected: boolean; + limit?: number; + searchTermList?: Array; + providerIdList: Array; +}; + +type IdentityInfoMessage = IdentityMessage & { + name: string; + email: string; + url: string; +}; + +type AuthProcessMessage = { + request?: { + url: string; + dataMap: Record; + }; + response?: { + identityId: string; + }; +}; + +type ClaimIdMessage = { + claimId: string; + url?: string; +}; + +type ClaimNodeMessage = NodeIdMessage & { + forceInvite?: boolean; +}; + +type TokenMessage = { + token: ProviderToken; +}; + +// Nodes messages + +type NodeIdMessage = { + nodeIdEncoded: NodeIdEncoded; +}; + +type AddressMessage = { + host: string; + port: number; +}; + +type NodeAddressMessage = NodeIdMessage & AddressMessage; + +type NodesGetMessage = NodeAddressMessage & { bucketIndex: number }; + +type NodesAddMessage = NodeAddressMessage & { + force?: boolean; + ping?: boolean; +}; + +type NodeConnectionMessage = NodeAddressMessage & { + hostname: string; + usageCount: number; + timeout: number; +}; + +// Gestalts messages + +type ActionsListMessage = { + actionsList: Array; +}; + +type SetIdentityActionMessage = IdentityMessage & { + action: GestaltAction; +}; + +type SetNodeActionMessage = NodeIdMessage & { + action: GestaltAction; +}; + +type GestaltMessage = { + gestalt: { + matrix: Record>; + nodes: Record; + identities: Record< + GestaltIdEncoded, + { + providerId: ProviderId; + identityId: IdentityId; + name?: string; + email?: string; + url?: string; + } + >; + }; +}; + +// Keys messages + +type CertMessage = { + cert: CertificatePEM; +}; + +type DataMessage = { + data: string; +}; + +type PublicKeyMessage = { + publicKeyJwk: PublicKeyJWK; +}; + +type PrivateKeyMessage = { + privateKeyJwe: JWKEncrypted; +}; + +type DecryptMessage = DataMessage & PublicKeyMessage; + +type PasswordMessage = { + password: string; +}; + +type KeyPairMessage = PrivateKeyMessage & PublicKeyMessage; + +type SignatureMessage = { + signature: string; +}; + +type VerifySignatureMessage = PublicKeyMessage & DataMessage & SignatureMessage; + +type SuccessMessage = { + success: boolean; +}; + +// Notifications messages + +type NotificationReadMessage = { + unread?: boolean; + number?: number | 'all'; + order?: 'newest' | 'oldest'; +}; + +type NotificationMessage = { + notification: Notification; +}; + +type NotificationSendMessage = NodeIdMessage & { + message: string; +}; + +// Vaults messages + +type VaultNameMessage = { + vaultName: VaultName; +}; + +type VaultIdMessage = { + vaultIdEncoded: VaultIdEncoded; +}; + +type VaultIdentifierMessage = { + nameOrId: VaultIdEncoded | VaultName; +}; + +type CloneMessage = NodeIdMessage & VaultIdentifierMessage; + +type VaultListMessage = VaultNameMessage & VaultIdMessage; + +type VaultsLogMessage = VaultIdentifierMessage & { + depth?: number; + commitId?: string; +}; + +type LogEntryMessage = { + commitId: CommitId; + committer: string; + timestamp: string; + message: string; +}; + +type VaultPermissionMessage = VaultIdMessage & + NodeIdMessage & { + vaultPermissionList: Array; + }; + +type PermissionSetMessage = VaultIdentifierMessage & + NodeIdMessage & { + vaultPermissionList: Array; + }; + +type VaultsPullMessage = Partial & { + pullVault: VaultIdEncoded | VaultName; +}; + +type VaultsRenameMessage = VaultIdentifierMessage & { + newName: VaultName; +}; + +type VaultsScanMessage = VaultListMessage & { + permissions: Array; +}; + +type VaultsVersionMessage = VaultIdentifierMessage & { + versionId: string; +}; + +type VaultsLatestVersionMessage = { + latestVersion: boolean; +}; + +// Secrets + +type SecretNameMessage = { + secretName: string; +}; + +type SecretIdentifierMessage = VaultIdentifierMessage & SecretNameMessage; + +// Contains binary content as a binary string 'toString('binary')' +type ContentMessage = { + secretContent: string; +}; + +type SecretContentMessage = SecretIdentifierMessage & ContentMessage; + +type SecretMkdirMessage = VaultIdentifierMessage & { + dirName: string; + recursive: boolean; +}; + +type SecretDirMessage = VaultIdentifierMessage & { + dirName: string; +}; + +type SecretRenameMessage = SecretIdentifierMessage & { + newSecretName: string; +}; + +// Stat is the 'JSON.stringify version of the file stat +type SecretStatMessage = { + stat: { + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + atime: string; + mtime: string; + ctime: string; + birthtime: string; + blksize: number; + blocks: number; + }; +}; + +export type { + ClientRPCRequestParams, + ClientRPCResponseResult, + StatusResultMessage, + IdentityMessage, + ProviderSearchMessage, + IdentityInfoMessage, + AuthProcessMessage, + ClaimIdMessage, + ClaimNodeMessage, + TokenMessage, + NodeIdMessage, + AddressMessage, + NodeAddressMessage, + NodeConnectionMessage, + ActionsListMessage, + SetIdentityActionMessage, + SetNodeActionMessage, + GestaltMessage, + CertMessage, + DataMessage, + PublicKeyMessage, + PrivateKeyMessage, + DecryptMessage, + KeyPairMessage, + VerifySignatureMessage, + PasswordMessage, + NodesGetMessage, + NodesAddMessage, + SuccessMessage, + NotificationMessage, + NotificationReadMessage, + NotificationSendMessage, + VaultNameMessage, + VaultIdMessage, + VaultIdentifierMessage, + CloneMessage, + VaultListMessage, + VaultsLogMessage, + LogEntryMessage, + VaultPermissionMessage, + PermissionSetMessage, + VaultsPullMessage, + VaultsRenameMessage, + VaultsScanMessage, + VaultsVersionMessage, + VaultsLatestVersionMessage, + SecretNameMessage, + SecretIdentifierMessage, + ContentMessage, + SecretContentMessage, + SecretMkdirMessage, + SecretDirMessage, + SecretRenameMessage, + SecretStatMessage, + SignatureMessage, +}; diff --git a/src/client/utils/utils.ts b/src/client/utils.ts similarity index 93% rename from src/client/utils/utils.ts rename to src/client/utils.ts index d1188c350..e50d4b5e8 100644 --- a/src/client/utils/utils.ts +++ b/src/client/utils.ts @@ -1,13 +1,13 @@ import type { JSONRPCRequest } from '@matrixai/rpc'; -import type { ClientRPCRequestParams } from '../types'; -import type SessionManager from '../../sessions/SessionManager'; -import type { Certificate, CertificatePEM } from '../../keys/types'; -import type KeyRing from '../../keys/KeyRing'; -import type { SessionToken } from '../../sessions/types'; -import type { NodeId } from '../../ids'; +import type { ClientRPCRequestParams } from './types'; +import type SessionManager from '../sessions/SessionManager'; +import type { SessionToken } from '../sessions/types'; +import type KeyRing from '../keys/KeyRing'; +import type { Certificate, CertificatePEM } from '../keys/types'; +import type { NodeId } from '../ids'; import { utils as wsUtils } from '@matrixai/ws'; -import * as keysUtils from '../../keys/utils'; -import * as clientErrors from '../errors'; +import * as keysUtils from '../keys/utils'; +import * as clientErrors from './errors'; async function authenticate( sessionManager: SessionManager, diff --git a/src/client/utils/index.ts b/src/client/utils/index.ts deleted file mode 100644 index 540591861..000000000 --- a/src/client/utils/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './authenticationMiddleware'; -export * from './timeoutMiddleware'; -export * from './middleware'; -export * from './utils'; diff --git a/src/nodes/agent/callers/nodesClaimsGet.ts b/src/nodes/agent/callers/nodesClaimsGet.ts index b70e23ce7..4d32cb110 100644 --- a/src/nodes/agent/callers/nodesClaimsGet.ts +++ b/src/nodes/agent/callers/nodesClaimsGet.ts @@ -1,8 +1,8 @@ -import type NodesClaimsGetHandler from '../handlers/NodesClaimsGet'; import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesClaimsGet from '../handlers/NodesClaimsGet'; import { ServerCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const nodesClaimsGet = new ServerCaller< CallerTypes['input'], diff --git a/src/nodes/agent/callers/nodesClosestLocalNodesGet.ts b/src/nodes/agent/callers/nodesClosestLocalNodesGet.ts index 770c945b4..9de8e6417 100644 --- a/src/nodes/agent/callers/nodesClosestLocalNodesGet.ts +++ b/src/nodes/agent/callers/nodesClosestLocalNodesGet.ts @@ -1,8 +1,8 @@ -import type NodesClosestLocalNodesGetHandler from '../handlers/NodesClosestLocalNodesGet'; import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesClosestLocalNodesGet from '../handlers/NodesClosestLocalNodesGet'; import { ServerCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const nodesClosestLocalNodesGet = new ServerCaller< CallerTypes['input'], diff --git a/src/nodes/agent/callers/nodesCrossSignClaim.ts b/src/nodes/agent/callers/nodesCrossSignClaim.ts index 00a4668dc..f94684ff0 100644 --- a/src/nodes/agent/callers/nodesCrossSignClaim.ts +++ b/src/nodes/agent/callers/nodesCrossSignClaim.ts @@ -1,8 +1,8 @@ -import type NodesCrossSignClaimHandler from '../handlers/NodesCrossSignClaim'; import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesCrossSignClaim from '../handlers/NodesCrossSignClaim'; import { DuplexCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const nodesCrossSignClaim = new DuplexCaller< CallerTypes['input'], diff --git a/src/nodes/agent/callers/nodesHolePunchMessageSend.ts b/src/nodes/agent/callers/nodesHolePunchMessageSend.ts index 6a57bf7fe..cea3acc06 100644 --- a/src/nodes/agent/callers/nodesHolePunchMessageSend.ts +++ b/src/nodes/agent/callers/nodesHolePunchMessageSend.ts @@ -1,8 +1,8 @@ -import type NodesHolePunchMessageSendHandler from '../handlers/NodesHolePunchMessageSend'; import type { HandlerTypes } from '@matrixai/rpc'; +import type NodesHolePunchMessageSend from '../handlers/NodesHolePunchMessageSend'; import { UnaryCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const nodesHolePunchMessageSend = new UnaryCaller< CallerTypes['input'], diff --git a/src/nodes/agent/callers/notificationsSend.ts b/src/nodes/agent/callers/notificationsSend.ts index 0d2676752..d4f6dd182 100644 --- a/src/nodes/agent/callers/notificationsSend.ts +++ b/src/nodes/agent/callers/notificationsSend.ts @@ -1,8 +1,8 @@ -import type NotificationsSendHandler from '../handlers/NotificationsSend'; import type { HandlerTypes } from '@matrixai/rpc'; +import type NotificationsSend from '../handlers/NotificationsSend'; import { UnaryCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const notificationsSend = new UnaryCaller< CallerTypes['input'], diff --git a/src/nodes/agent/callers/vaultsScan.ts b/src/nodes/agent/callers/vaultsScan.ts index 6f23b36f3..b24e94673 100644 --- a/src/nodes/agent/callers/vaultsScan.ts +++ b/src/nodes/agent/callers/vaultsScan.ts @@ -1,8 +1,8 @@ -import type VaultsScanHandler from '../handlers/VaultsScan'; import type { HandlerTypes } from '@matrixai/rpc'; +import type VaultsScan from '../handlers/VaultsScan'; import { ServerCaller } from '@matrixai/rpc'; -type CallerTypes = HandlerTypes; +type CallerTypes = HandlerTypes; const vaultsScan = new ServerCaller< CallerTypes['input'], From 4c0c9f2ca3d05d9541eb3e013eb659247ff3925a Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Wed, 11 Oct 2023 18:01:54 +1100 Subject: [PATCH 2/3] fix: client handlers should be capitalized --- src/client/callers/agentLockAll.ts | 2 +- src/client/callers/agentStatus.ts | 2 +- src/client/callers/agentStop.ts | 2 +- src/client/callers/agentUnlock.ts | 2 +- .../callers/gestaltsActionsGetByIdentity.ts | 2 +- .../callers/gestaltsActionsGetByNode.ts | 2 +- .../callers/gestaltsActionsSetByIdentity.ts | 2 +- .../callers/gestaltsActionsSetByNode.ts | 2 +- .../callers/gestaltsActionsUnsetByIdentity.ts | 2 +- .../callers/gestaltsActionsUnsetByNode.ts | 2 +- .../callers/gestaltsDiscoveryByIdentity.ts | 2 +- src/client/callers/gestaltsDiscoveryByNode.ts | 2 +- .../callers/gestaltsGestaltGetByIdentity.ts | 2 +- .../callers/gestaltsGestaltGetByNode.ts | 2 +- src/client/callers/gestaltsGestaltList.ts | 2 +- .../callers/gestaltsGestaltTrustByIdentity.ts | 2 +- .../callers/gestaltsGestaltTrustByNode.ts | 2 +- src/client/callers/identitiesAuthenticate.ts | 2 +- .../callers/identitiesAuthenticatedGet.ts | 2 +- src/client/callers/identitiesClaim.ts | 2 +- .../callers/identitiesInfoConnectedGet.ts | 2 +- src/client/callers/identitiesInfoGet.ts | 2 +- src/client/callers/identitiesInvite.ts | 2 +- src/client/callers/identitiesProvidersList.ts | 2 +- src/client/callers/identitiesTokenDelete.ts | 2 +- src/client/callers/identitiesTokenGet.ts | 2 +- src/client/callers/identitiesTokenPut.ts | 2 +- src/client/callers/keysCertsChainGet.ts | 2 +- src/client/callers/keysCertsGet.ts | 2 +- src/client/callers/keysDecrypt.ts | 2 +- src/client/callers/keysEncrypt.ts | 2 +- src/client/callers/keysKeyPair.ts | 2 +- src/client/callers/keysKeyPairRenew.ts | 2 +- src/client/callers/keysKeyPairReset.ts | 2 +- src/client/callers/keysPasswordChange.ts | 2 +- src/client/callers/keysPublicKey.ts | 2 +- src/client/callers/keysSign.ts | 2 +- src/client/callers/keysVerify.ts | 2 +- src/client/callers/nodesAdd.ts | 2 +- src/client/callers/nodesClaim.ts | 2 +- src/client/callers/nodesFind.ts | 2 +- src/client/callers/nodesGetAll.ts | 2 +- src/client/callers/nodesListConnections.ts | 2 +- src/client/callers/nodesPing.ts | 2 +- src/client/callers/notificationsClear.ts | 2 +- src/client/callers/notificationsRead.ts | 2 +- src/client/callers/notificationsSend.ts | 2 +- src/client/callers/vaultsClone.ts | 2 +- src/client/callers/vaultsCreate.ts | 2 +- src/client/callers/vaultsDelete.ts | 2 +- src/client/callers/vaultsList.ts | 2 +- src/client/callers/vaultsLog.ts | 2 +- src/client/callers/vaultsPermissionGet.ts | 2 +- src/client/callers/vaultsPermissionSet.ts | 2 +- src/client/callers/vaultsPermissionUnset.ts | 2 +- src/client/callers/vaultsPull.ts | 2 +- src/client/callers/vaultsRename.ts | 2 +- src/client/callers/vaultsScan.ts | 2 +- src/client/callers/vaultsSecretsDelete.ts | 2 +- src/client/callers/vaultsSecretsEdit.ts | 2 +- src/client/callers/vaultsSecretsGet.ts | 2 +- src/client/callers/vaultsSecretsList.ts | 2 +- src/client/callers/vaultsSecretsMkdir.ts | 2 +- src/client/callers/vaultsSecretsNew.ts | 2 +- src/client/callers/vaultsSecretsNewDir.ts | 2 +- src/client/callers/vaultsSecretsRename.ts | 2 +- src/client/callers/vaultsSecretsStat.ts | 2 +- src/client/callers/vaultsVersion.ts | 2 +- .../{agentLockAll.ts => AgentLockAll.ts} | 0 .../{agentStatus.ts => AgentStatus.ts} | 0 .../handlers/{agentStop.ts => AgentStop.ts} | 0 .../{agentUnlock.ts => AgentUnlock.ts} | 0 ...ity.ts => GestaltsActionsGetByIdentity.ts} | 0 ...tByNode.ts => GestaltsActionsGetByNode.ts} | 0 ...ity.ts => GestaltsActionsSetByIdentity.ts} | 0 ...tByNode.ts => GestaltsActionsSetByNode.ts} | 0 ...y.ts => GestaltsActionsUnsetByIdentity.ts} | 0 ...yNode.ts => GestaltsActionsUnsetByNode.ts} | 0 ...tity.ts => GestaltsDiscoveryByIdentity.ts} | 0 ...ryByNode.ts => GestaltsDiscoveryByNode.ts} | 0 ...ity.ts => GestaltsGestaltGetByIdentity.ts} | 0 ...tByNode.ts => GestaltsGestaltGetByNode.ts} | 0 ...sGestaltList.ts => GestaltsGestaltList.ts} | 0 ...y.ts => GestaltsGestaltTrustByIdentity.ts} | 0 ...yNode.ts => GestaltsGestaltTrustByNode.ts} | 0 ...henticate.ts => IdentitiesAuthenticate.ts} | 0 ...edGet.ts => IdentitiesAuthenticatedGet.ts} | 0 ...{identitiesClaim.ts => IdentitiesClaim.ts} | 0 ...edGet.ts => IdentitiesInfoConnectedGet.ts} | 0 ...ntitiesInfoGet.ts => IdentitiesInfoGet.ts} | 0 ...dentitiesInvite.ts => IdentitiesInvite.ts} | 0 ...dersList.ts => IdentitiesProvidersList.ts} | 0 ...okenDelete.ts => IdentitiesTokenDelete.ts} | 0 ...itiesTokenGet.ts => IdentitiesTokenGet.ts} | 0 ...itiesTokenPut.ts => IdentitiesTokenPut.ts} | 0 ...sCertsChainGet.ts => KeysCertsChainGet.ts} | 0 .../{keysCertsGet.ts => KeysCertsGet.ts} | 0 .../{keysDecrypt.ts => KeysDecrypt.ts} | 0 .../{keysEncrypt.ts => KeysEncrypt.ts} | 0 .../{keysKeyPair.ts => KeysKeyPair.ts} | 0 ...eysKeyPairRenew.ts => KeysKeyPairRenew.ts} | 0 ...eysKeyPairReset.ts => KeysKeyPairReset.ts} | 0 ...asswordChange.ts => KeysPasswordChange.ts} | 0 .../{keysPublicKey.ts => KeysPublicKey.ts} | 0 .../handlers/{keysSign.ts => KeysSign.ts} | 0 .../handlers/{keysVerify.ts => KeysVerify.ts} | 0 .../handlers/{nodesAdd.ts => NodesAdd.ts} | 0 .../handlers/{nodesClaim.ts => NodesClaim.ts} | 0 .../handlers/{nodesFind.ts => NodesFind.ts} | 0 .../{nodesGetAll.ts => NodesGetAll.ts} | 0 ...Connections.ts => NodesListConnections.ts} | 0 .../handlers/{nodesPing.ts => NodesPing.ts} | 0 ...icationsClear.ts => NotificationsClear.ts} | 0 ...ificationsRead.ts => NotificationsRead.ts} | 0 ...ificationsSend.ts => NotificationsSend.ts} | 0 .../{vaultsClone.ts => VaultsClone.ts} | 0 .../{vaultsCreate.ts => VaultsCreate.ts} | 0 .../{vaultsDelete.ts => VaultsDelete.ts} | 0 .../handlers/{vaultsList.ts => VaultsList.ts} | 0 .../handlers/{vaultsLog.ts => VaultsLog.ts} | 0 ...ermissionGet.ts => VaultsPermissionGet.ts} | 0 ...ermissionSet.ts => VaultsPermissionSet.ts} | 0 ...ssionUnset.ts => VaultsPermissionUnset.ts} | 0 .../handlers/{vaultsPull.ts => VaultsPull.ts} | 0 .../{vaultsRename.ts => VaultsRename.ts} | 0 .../handlers/{vaultsScan.ts => VaultsScan.ts} | 0 ...ecretsDelete.ts => VaultsSecretsDelete.ts} | 0 ...ltsSecretsEdit.ts => VaultsSecretsEdit.ts} | 0 ...aultsSecretsGet.ts => VaultsSecretsGet.ts} | 0 ...ltsSecretsList.ts => VaultsSecretsList.ts} | 0 ...sSecretsMkdir.ts => VaultsSecretsMkdir.ts} | 0 ...aultsSecretsNew.ts => VaultsSecretsNew.ts} | 0 ...ecretsNewDir.ts => VaultsSecretsNewDir.ts} | 0 ...ecretsRename.ts => VaultsSecretsRename.ts} | 0 ...ltsSecretsStat.ts => VaultsSecretsStat.ts} | 0 .../{vaultsVersion.ts => VaultsVersion.ts} | 0 src/client/handlers/index.ts | 408 +++++++++--------- 137 files changed, 272 insertions(+), 272 deletions(-) rename src/client/handlers/{agentLockAll.ts => AgentLockAll.ts} (100%) rename src/client/handlers/{agentStatus.ts => AgentStatus.ts} (100%) rename src/client/handlers/{agentStop.ts => AgentStop.ts} (100%) rename src/client/handlers/{agentUnlock.ts => AgentUnlock.ts} (100%) rename src/client/handlers/{gestaltsActionsGetByIdentity.ts => GestaltsActionsGetByIdentity.ts} (100%) rename src/client/handlers/{gestaltsActionsGetByNode.ts => GestaltsActionsGetByNode.ts} (100%) rename src/client/handlers/{gestaltsActionsSetByIdentity.ts => GestaltsActionsSetByIdentity.ts} (100%) rename src/client/handlers/{gestaltsActionsSetByNode.ts => GestaltsActionsSetByNode.ts} (100%) rename src/client/handlers/{gestaltsActionsUnsetByIdentity.ts => GestaltsActionsUnsetByIdentity.ts} (100%) rename src/client/handlers/{gestaltsActionsUnsetByNode.ts => GestaltsActionsUnsetByNode.ts} (100%) rename src/client/handlers/{gestaltsDiscoveryByIdentity.ts => GestaltsDiscoveryByIdentity.ts} (100%) rename src/client/handlers/{gestaltsDiscoveryByNode.ts => GestaltsDiscoveryByNode.ts} (100%) rename src/client/handlers/{gestaltsGestaltGetByIdentity.ts => GestaltsGestaltGetByIdentity.ts} (100%) rename src/client/handlers/{gestaltsGestaltGetByNode.ts => GestaltsGestaltGetByNode.ts} (100%) rename src/client/handlers/{gestaltsGestaltList.ts => GestaltsGestaltList.ts} (100%) rename src/client/handlers/{gestaltsGestaltTrustByIdentity.ts => GestaltsGestaltTrustByIdentity.ts} (100%) rename src/client/handlers/{gestaltsGestaltTrustByNode.ts => GestaltsGestaltTrustByNode.ts} (100%) rename src/client/handlers/{identitiesAuthenticate.ts => IdentitiesAuthenticate.ts} (100%) rename src/client/handlers/{identitiesAuthenticatedGet.ts => IdentitiesAuthenticatedGet.ts} (100%) rename src/client/handlers/{identitiesClaim.ts => IdentitiesClaim.ts} (100%) rename src/client/handlers/{identitiesInfoConnectedGet.ts => IdentitiesInfoConnectedGet.ts} (100%) rename src/client/handlers/{identitiesInfoGet.ts => IdentitiesInfoGet.ts} (100%) rename src/client/handlers/{identitiesInvite.ts => IdentitiesInvite.ts} (100%) rename src/client/handlers/{identitiesProvidersList.ts => IdentitiesProvidersList.ts} (100%) rename src/client/handlers/{identitiesTokenDelete.ts => IdentitiesTokenDelete.ts} (100%) rename src/client/handlers/{identitiesTokenGet.ts => IdentitiesTokenGet.ts} (100%) rename src/client/handlers/{identitiesTokenPut.ts => IdentitiesTokenPut.ts} (100%) rename src/client/handlers/{keysCertsChainGet.ts => KeysCertsChainGet.ts} (100%) rename src/client/handlers/{keysCertsGet.ts => KeysCertsGet.ts} (100%) rename src/client/handlers/{keysDecrypt.ts => KeysDecrypt.ts} (100%) rename src/client/handlers/{keysEncrypt.ts => KeysEncrypt.ts} (100%) rename src/client/handlers/{keysKeyPair.ts => KeysKeyPair.ts} (100%) rename src/client/handlers/{keysKeyPairRenew.ts => KeysKeyPairRenew.ts} (100%) rename src/client/handlers/{keysKeyPairReset.ts => KeysKeyPairReset.ts} (100%) rename src/client/handlers/{keysPasswordChange.ts => KeysPasswordChange.ts} (100%) rename src/client/handlers/{keysPublicKey.ts => KeysPublicKey.ts} (100%) rename src/client/handlers/{keysSign.ts => KeysSign.ts} (100%) rename src/client/handlers/{keysVerify.ts => KeysVerify.ts} (100%) rename src/client/handlers/{nodesAdd.ts => NodesAdd.ts} (100%) rename src/client/handlers/{nodesClaim.ts => NodesClaim.ts} (100%) rename src/client/handlers/{nodesFind.ts => NodesFind.ts} (100%) rename src/client/handlers/{nodesGetAll.ts => NodesGetAll.ts} (100%) rename src/client/handlers/{nodesListConnections.ts => NodesListConnections.ts} (100%) rename src/client/handlers/{nodesPing.ts => NodesPing.ts} (100%) rename src/client/handlers/{notificationsClear.ts => NotificationsClear.ts} (100%) rename src/client/handlers/{notificationsRead.ts => NotificationsRead.ts} (100%) rename src/client/handlers/{notificationsSend.ts => NotificationsSend.ts} (100%) rename src/client/handlers/{vaultsClone.ts => VaultsClone.ts} (100%) rename src/client/handlers/{vaultsCreate.ts => VaultsCreate.ts} (100%) rename src/client/handlers/{vaultsDelete.ts => VaultsDelete.ts} (100%) rename src/client/handlers/{vaultsList.ts => VaultsList.ts} (100%) rename src/client/handlers/{vaultsLog.ts => VaultsLog.ts} (100%) rename src/client/handlers/{vaultsPermissionGet.ts => VaultsPermissionGet.ts} (100%) rename src/client/handlers/{vaultsPermissionSet.ts => VaultsPermissionSet.ts} (100%) rename src/client/handlers/{vaultsPermissionUnset.ts => VaultsPermissionUnset.ts} (100%) rename src/client/handlers/{vaultsPull.ts => VaultsPull.ts} (100%) rename src/client/handlers/{vaultsRename.ts => VaultsRename.ts} (100%) rename src/client/handlers/{vaultsScan.ts => VaultsScan.ts} (100%) rename src/client/handlers/{vaultsSecretsDelete.ts => VaultsSecretsDelete.ts} (100%) rename src/client/handlers/{vaultsSecretsEdit.ts => VaultsSecretsEdit.ts} (100%) rename src/client/handlers/{vaultsSecretsGet.ts => VaultsSecretsGet.ts} (100%) rename src/client/handlers/{vaultsSecretsList.ts => VaultsSecretsList.ts} (100%) rename src/client/handlers/{vaultsSecretsMkdir.ts => VaultsSecretsMkdir.ts} (100%) rename src/client/handlers/{vaultsSecretsNew.ts => VaultsSecretsNew.ts} (100%) rename src/client/handlers/{vaultsSecretsNewDir.ts => VaultsSecretsNewDir.ts} (100%) rename src/client/handlers/{vaultsSecretsRename.ts => VaultsSecretsRename.ts} (100%) rename src/client/handlers/{vaultsSecretsStat.ts => VaultsSecretsStat.ts} (100%) rename src/client/handlers/{vaultsVersion.ts => VaultsVersion.ts} (100%) diff --git a/src/client/callers/agentLockAll.ts b/src/client/callers/agentLockAll.ts index 5e19435bd..dad0823c4 100644 --- a/src/client/callers/agentLockAll.ts +++ b/src/client/callers/agentLockAll.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type AgentLockAll from '../handlers/agentLockAll'; +import type AgentLockAll from '../handlers/AgentLockAll'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/agentStatus.ts b/src/client/callers/agentStatus.ts index 6f71e898b..c3a1db287 100644 --- a/src/client/callers/agentStatus.ts +++ b/src/client/callers/agentStatus.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type AgentStatus from '../handlers/agentStatus'; +import type AgentStatus from '../handlers/AgentStatus'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/agentStop.ts b/src/client/callers/agentStop.ts index 6f2c048ce..5ba9144d3 100644 --- a/src/client/callers/agentStop.ts +++ b/src/client/callers/agentStop.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type AgentStop from '../handlers/agentStop'; +import type AgentStop from '../handlers/AgentStop'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/agentUnlock.ts b/src/client/callers/agentUnlock.ts index e83e7b3fb..d47dbe534 100644 --- a/src/client/callers/agentUnlock.ts +++ b/src/client/callers/agentUnlock.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type AgentUnlock from '../handlers/agentUnlock'; +import type AgentUnlock from '../handlers/AgentUnlock'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsGetByIdentity.ts b/src/client/callers/gestaltsActionsGetByIdentity.ts index b4e37ae8b..0d918986d 100644 --- a/src/client/callers/gestaltsActionsGetByIdentity.ts +++ b/src/client/callers/gestaltsActionsGetByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsGetByIdentity from '../handlers/gestaltsActionsGetByIdentity'; +import type GestaltsActionsGetByIdentity from '../handlers/GestaltsActionsGetByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsGetByNode.ts b/src/client/callers/gestaltsActionsGetByNode.ts index c831cfe34..3a17eedeb 100644 --- a/src/client/callers/gestaltsActionsGetByNode.ts +++ b/src/client/callers/gestaltsActionsGetByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsGetByNode from '../handlers/gestaltsActionsGetByNode'; +import type GestaltsActionsGetByNode from '../handlers/GestaltsActionsGetByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsSetByIdentity.ts b/src/client/callers/gestaltsActionsSetByIdentity.ts index 6f4723916..f4eb977dc 100644 --- a/src/client/callers/gestaltsActionsSetByIdentity.ts +++ b/src/client/callers/gestaltsActionsSetByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsSetByIdentity from '../handlers/gestaltsActionsSetByIdentity'; +import type GestaltsActionsSetByIdentity from '../handlers/GestaltsActionsSetByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsSetByNode.ts b/src/client/callers/gestaltsActionsSetByNode.ts index bc13f08cb..adbaf625e 100644 --- a/src/client/callers/gestaltsActionsSetByNode.ts +++ b/src/client/callers/gestaltsActionsSetByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsSetByNode from '../handlers/gestaltsActionsSetByNode'; +import type GestaltsActionsSetByNode from '../handlers/GestaltsActionsSetByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsUnsetByIdentity.ts b/src/client/callers/gestaltsActionsUnsetByIdentity.ts index d5ce35934..2f2c97e42 100644 --- a/src/client/callers/gestaltsActionsUnsetByIdentity.ts +++ b/src/client/callers/gestaltsActionsUnsetByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsUnsetByIdentity from '../handlers/gestaltsActionsUnsetByIdentity'; +import type GestaltsActionsUnsetByIdentity from '../handlers/GestaltsActionsUnsetByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsActionsUnsetByNode.ts b/src/client/callers/gestaltsActionsUnsetByNode.ts index b17259916..15b22b29e 100644 --- a/src/client/callers/gestaltsActionsUnsetByNode.ts +++ b/src/client/callers/gestaltsActionsUnsetByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsActionsUnsetByNode from '../handlers/gestaltsActionsUnsetByNode'; +import type GestaltsActionsUnsetByNode from '../handlers/GestaltsActionsUnsetByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsDiscoveryByIdentity.ts b/src/client/callers/gestaltsDiscoveryByIdentity.ts index 86019b902..46913d060 100644 --- a/src/client/callers/gestaltsDiscoveryByIdentity.ts +++ b/src/client/callers/gestaltsDiscoveryByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsDiscoveryByIdentity from '../handlers/gestaltsDiscoveryByIdentity'; +import type GestaltsDiscoveryByIdentity from '../handlers/GestaltsDiscoveryByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsDiscoveryByNode.ts b/src/client/callers/gestaltsDiscoveryByNode.ts index 149b91e7e..dad4d4506 100644 --- a/src/client/callers/gestaltsDiscoveryByNode.ts +++ b/src/client/callers/gestaltsDiscoveryByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsDiscoveryByNode from '../handlers/gestaltsDiscoveryByNode'; +import type GestaltsDiscoveryByNode from '../handlers/GestaltsDiscoveryByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsGestaltGetByIdentity.ts b/src/client/callers/gestaltsGestaltGetByIdentity.ts index c6161f1ae..9366670b4 100644 --- a/src/client/callers/gestaltsGestaltGetByIdentity.ts +++ b/src/client/callers/gestaltsGestaltGetByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsGestaltGetByIdentity from '../handlers/gestaltsGestaltGetByIdentity'; +import type GestaltsGestaltGetByIdentity from '../handlers/GestaltsGestaltGetByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsGestaltGetByNode.ts b/src/client/callers/gestaltsGestaltGetByNode.ts index b09179a28..4afc101cf 100644 --- a/src/client/callers/gestaltsGestaltGetByNode.ts +++ b/src/client/callers/gestaltsGestaltGetByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsGestaltGetByNode from '../handlers/gestaltsGestaltGetByNode'; +import type GestaltsGestaltGetByNode from '../handlers/GestaltsGestaltGetByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsGestaltList.ts b/src/client/callers/gestaltsGestaltList.ts index 4a5f87467..8fe33551c 100644 --- a/src/client/callers/gestaltsGestaltList.ts +++ b/src/client/callers/gestaltsGestaltList.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsGestaltList from '../handlers/gestaltsGestaltList'; +import type GestaltsGestaltList from '../handlers/GestaltsGestaltList'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsGestaltTrustByIdentity.ts b/src/client/callers/gestaltsGestaltTrustByIdentity.ts index 1c8c912ae..a8eb59a44 100644 --- a/src/client/callers/gestaltsGestaltTrustByIdentity.ts +++ b/src/client/callers/gestaltsGestaltTrustByIdentity.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsGestaltTrustByIdentity from '../handlers/gestaltsGestaltTrustByIdentity'; +import type GestaltsGestaltTrustByIdentity from '../handlers/GestaltsGestaltTrustByIdentity'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/gestaltsGestaltTrustByNode.ts b/src/client/callers/gestaltsGestaltTrustByNode.ts index 1e4005185..dcde4eba8 100644 --- a/src/client/callers/gestaltsGestaltTrustByNode.ts +++ b/src/client/callers/gestaltsGestaltTrustByNode.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type GestaltsGestaltTrustByNode from '../handlers/gestaltsGestaltTrustByNode'; +import type GestaltsGestaltTrustByNode from '../handlers/GestaltsGestaltTrustByNode'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesAuthenticate.ts b/src/client/callers/identitiesAuthenticate.ts index d9f37ef6f..82b4201ba 100644 --- a/src/client/callers/identitiesAuthenticate.ts +++ b/src/client/callers/identitiesAuthenticate.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesAuthenticate from '../handlers/identitiesAuthenticate'; +import type IdentitiesAuthenticate from '../handlers/IdentitiesAuthenticate'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesAuthenticatedGet.ts b/src/client/callers/identitiesAuthenticatedGet.ts index 078dac8f5..638a057c6 100644 --- a/src/client/callers/identitiesAuthenticatedGet.ts +++ b/src/client/callers/identitiesAuthenticatedGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesAuthenticatedGet from '../handlers/identitiesAuthenticatedGet'; +import type IdentitiesAuthenticatedGet from '../handlers/IdentitiesAuthenticatedGet'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesClaim.ts b/src/client/callers/identitiesClaim.ts index 6fdb63015..3517f1a88 100644 --- a/src/client/callers/identitiesClaim.ts +++ b/src/client/callers/identitiesClaim.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesClaim from '../handlers/identitiesClaim'; +import type IdentitiesClaim from '../handlers/IdentitiesClaim'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesInfoConnectedGet.ts b/src/client/callers/identitiesInfoConnectedGet.ts index 1dbaff4a0..c9227b7ba 100644 --- a/src/client/callers/identitiesInfoConnectedGet.ts +++ b/src/client/callers/identitiesInfoConnectedGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesInfoConnectedGet from '../handlers/identitiesInfoConnectedGet'; +import type IdentitiesInfoConnectedGet from '../handlers/IdentitiesInfoConnectedGet'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesInfoGet.ts b/src/client/callers/identitiesInfoGet.ts index ece034d52..35d984b64 100644 --- a/src/client/callers/identitiesInfoGet.ts +++ b/src/client/callers/identitiesInfoGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesInfoGet from '../handlers/identitiesInfoGet'; +import type IdentitiesInfoGet from '../handlers/IdentitiesInfoGet'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesInvite.ts b/src/client/callers/identitiesInvite.ts index 820c5d5ac..8ccf179d4 100644 --- a/src/client/callers/identitiesInvite.ts +++ b/src/client/callers/identitiesInvite.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesInvite from '../handlers/identitiesInvite'; +import type IdentitiesInvite from '../handlers/IdentitiesInvite'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesProvidersList.ts b/src/client/callers/identitiesProvidersList.ts index ab477bfcb..5db63eb8d 100644 --- a/src/client/callers/identitiesProvidersList.ts +++ b/src/client/callers/identitiesProvidersList.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesProvidersList from '../handlers/identitiesProvidersList'; +import type IdentitiesProvidersList from '../handlers/IdentitiesProvidersList'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesTokenDelete.ts b/src/client/callers/identitiesTokenDelete.ts index 2a517c94f..878dcdd36 100644 --- a/src/client/callers/identitiesTokenDelete.ts +++ b/src/client/callers/identitiesTokenDelete.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesTokenDelete from '../handlers/identitiesTokenDelete'; +import type IdentitiesTokenDelete from '../handlers/IdentitiesTokenDelete'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesTokenGet.ts b/src/client/callers/identitiesTokenGet.ts index b96af7afc..2bf564eec 100644 --- a/src/client/callers/identitiesTokenGet.ts +++ b/src/client/callers/identitiesTokenGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesTokenGet from '../handlers/identitiesTokenGet'; +import type IdentitiesTokenGet from '../handlers/IdentitiesTokenGet'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/identitiesTokenPut.ts b/src/client/callers/identitiesTokenPut.ts index 577a4bd7a..94e29029c 100644 --- a/src/client/callers/identitiesTokenPut.ts +++ b/src/client/callers/identitiesTokenPut.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type IdentitiesTokenPut from '../handlers/identitiesTokenPut'; +import type IdentitiesTokenPut from '../handlers/IdentitiesTokenPut'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysCertsChainGet.ts b/src/client/callers/keysCertsChainGet.ts index fdb27d7d1..966f1a396 100644 --- a/src/client/callers/keysCertsChainGet.ts +++ b/src/client/callers/keysCertsChainGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysCertsChainGet from '../handlers/keysCertsChainGet'; +import type KeysCertsChainGet from '../handlers/KeysCertsChainGet'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysCertsGet.ts b/src/client/callers/keysCertsGet.ts index 7c1f5d6f0..8a1914a1d 100644 --- a/src/client/callers/keysCertsGet.ts +++ b/src/client/callers/keysCertsGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysCertsGet from '../handlers/keysCertsGet'; +import type KeysCertsGet from '../handlers/KeysCertsGet'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysDecrypt.ts b/src/client/callers/keysDecrypt.ts index 39742f0cb..3f5bb4875 100644 --- a/src/client/callers/keysDecrypt.ts +++ b/src/client/callers/keysDecrypt.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysDecrypt from '../handlers/keysDecrypt'; +import type KeysDecrypt from '../handlers/KeysDecrypt'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysEncrypt.ts b/src/client/callers/keysEncrypt.ts index 2c2c2ffae..ae2fa6098 100644 --- a/src/client/callers/keysEncrypt.ts +++ b/src/client/callers/keysEncrypt.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysEncrypt from '../handlers/keysEncrypt'; +import type KeysEncrypt from '../handlers/KeysEncrypt'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysKeyPair.ts b/src/client/callers/keysKeyPair.ts index 1372fe910..5c1493123 100644 --- a/src/client/callers/keysKeyPair.ts +++ b/src/client/callers/keysKeyPair.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysKeyPair from '../handlers/keysKeyPair'; +import type KeysKeyPair from '../handlers/KeysKeyPair'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysKeyPairRenew.ts b/src/client/callers/keysKeyPairRenew.ts index 6ed40bcf3..00e6034a0 100644 --- a/src/client/callers/keysKeyPairRenew.ts +++ b/src/client/callers/keysKeyPairRenew.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysKeyPairRenew from '../handlers/keysKeyPairRenew'; +import type KeysKeyPairRenew from '../handlers/KeysKeyPairRenew'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysKeyPairReset.ts b/src/client/callers/keysKeyPairReset.ts index 25c6800a0..97221d519 100644 --- a/src/client/callers/keysKeyPairReset.ts +++ b/src/client/callers/keysKeyPairReset.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysKeyPairReset from '../handlers/keysKeyPairReset'; +import type KeysKeyPairReset from '../handlers/KeysKeyPairReset'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysPasswordChange.ts b/src/client/callers/keysPasswordChange.ts index f032b2a1e..40ac575b9 100644 --- a/src/client/callers/keysPasswordChange.ts +++ b/src/client/callers/keysPasswordChange.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysPasswordChange from '../handlers/keysPasswordChange'; +import type KeysPasswordChange from '../handlers/KeysPasswordChange'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysPublicKey.ts b/src/client/callers/keysPublicKey.ts index e17be36e6..99da93d72 100644 --- a/src/client/callers/keysPublicKey.ts +++ b/src/client/callers/keysPublicKey.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysPublicKey from '../handlers/keysPublicKey'; +import type KeysPublicKey from '../handlers/KeysPublicKey'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysSign.ts b/src/client/callers/keysSign.ts index a4ea4615e..086dad6fc 100644 --- a/src/client/callers/keysSign.ts +++ b/src/client/callers/keysSign.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysSign from '../handlers/keysSign'; +import type KeysSign from '../handlers/KeysSign'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/keysVerify.ts b/src/client/callers/keysVerify.ts index 767f8b8c6..21b474744 100644 --- a/src/client/callers/keysVerify.ts +++ b/src/client/callers/keysVerify.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type KeysVerify from '../handlers/keysVerify'; +import type KeysVerify from '../handlers/KeysVerify'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesAdd.ts b/src/client/callers/nodesAdd.ts index 413cd1f40..663c6049a 100644 --- a/src/client/callers/nodesAdd.ts +++ b/src/client/callers/nodesAdd.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesAdd from '../handlers/nodesAdd'; +import type NodesAdd from '../handlers/NodesAdd'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesClaim.ts b/src/client/callers/nodesClaim.ts index b114cca14..40bef1363 100644 --- a/src/client/callers/nodesClaim.ts +++ b/src/client/callers/nodesClaim.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesClaim from '../handlers/nodesClaim'; +import type NodesClaim from '../handlers/NodesClaim'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesFind.ts b/src/client/callers/nodesFind.ts index 7cd80ae35..98c04a4ec 100644 --- a/src/client/callers/nodesFind.ts +++ b/src/client/callers/nodesFind.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesFind from '../handlers/nodesFind'; +import type NodesFind from '../handlers/NodesFind'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesGetAll.ts b/src/client/callers/nodesGetAll.ts index cab8c4d99..33fb68177 100644 --- a/src/client/callers/nodesGetAll.ts +++ b/src/client/callers/nodesGetAll.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesGetAll from '../handlers/nodesGetAll'; +import type NodesGetAll from '../handlers/NodesGetAll'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesListConnections.ts b/src/client/callers/nodesListConnections.ts index dcba7d322..75426d5ad 100644 --- a/src/client/callers/nodesListConnections.ts +++ b/src/client/callers/nodesListConnections.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesListConnections from '../handlers/nodesListConnections'; +import type NodesListConnections from '../handlers/NodesListConnections'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/nodesPing.ts b/src/client/callers/nodesPing.ts index 255f350c1..766cdf395 100644 --- a/src/client/callers/nodesPing.ts +++ b/src/client/callers/nodesPing.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NodesPing from '../handlers/nodesPing'; +import type NodesPing from '../handlers/NodesPing'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/notificationsClear.ts b/src/client/callers/notificationsClear.ts index 80d57b151..44ab37ba4 100644 --- a/src/client/callers/notificationsClear.ts +++ b/src/client/callers/notificationsClear.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NotificationsClear from '../handlers/notificationsClear'; +import type NotificationsClear from '../handlers/NotificationsClear'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/notificationsRead.ts b/src/client/callers/notificationsRead.ts index f1d000c80..2fc853f2f 100644 --- a/src/client/callers/notificationsRead.ts +++ b/src/client/callers/notificationsRead.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NotificationsRead from '../handlers/notificationsRead'; +import type NotificationsRead from '../handlers/NotificationsRead'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/notificationsSend.ts b/src/client/callers/notificationsSend.ts index a3bbcd84c..c1ea5467d 100644 --- a/src/client/callers/notificationsSend.ts +++ b/src/client/callers/notificationsSend.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NotificationsSend from '../handlers/notificationsRead'; +import type NotificationsSend from '../handlers/NotificationsRead'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsClone.ts b/src/client/callers/vaultsClone.ts index 84376b696..ddec40fcb 100644 --- a/src/client/callers/vaultsClone.ts +++ b/src/client/callers/vaultsClone.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsClone from '../handlers/vaultsClone'; +import type VaultsClone from '../handlers/VaultsClone'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsCreate.ts b/src/client/callers/vaultsCreate.ts index e3ac9e7b1..e4023a6b7 100644 --- a/src/client/callers/vaultsCreate.ts +++ b/src/client/callers/vaultsCreate.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsCreate from '../handlers/vaultsCreate'; +import type VaultsCreate from '../handlers/VaultsCreate'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsDelete.ts b/src/client/callers/vaultsDelete.ts index 2159f4fd4..83596ea1c 100644 --- a/src/client/callers/vaultsDelete.ts +++ b/src/client/callers/vaultsDelete.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsDelete from '../handlers/vaultsDelete'; +import type VaultsDelete from '../handlers/VaultsDelete'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsList.ts b/src/client/callers/vaultsList.ts index 597b7bcae..afaed2581 100644 --- a/src/client/callers/vaultsList.ts +++ b/src/client/callers/vaultsList.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsList from '../handlers/vaultsList'; +import type VaultsList from '../handlers/VaultsList'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsLog.ts b/src/client/callers/vaultsLog.ts index 9cf9d5151..8bd6d8c31 100644 --- a/src/client/callers/vaultsLog.ts +++ b/src/client/callers/vaultsLog.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsLog from '../handlers/vaultsLog'; +import type VaultsLog from '../handlers/VaultsLog'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsPermissionGet.ts b/src/client/callers/vaultsPermissionGet.ts index 8196e4984..43e373a03 100644 --- a/src/client/callers/vaultsPermissionGet.ts +++ b/src/client/callers/vaultsPermissionGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsPermissionGet from '../handlers/vaultsPermissionGet'; +import type VaultsPermissionGet from '../handlers/VaultsPermissionGet'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsPermissionSet.ts b/src/client/callers/vaultsPermissionSet.ts index fcf6c769a..3966263c6 100644 --- a/src/client/callers/vaultsPermissionSet.ts +++ b/src/client/callers/vaultsPermissionSet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsPermissionSet from '../handlers/vaultsPermissionSet'; +import type VaultsPermissionSet from '../handlers/VaultsPermissionSet'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsPermissionUnset.ts b/src/client/callers/vaultsPermissionUnset.ts index 618348893..0685ec021 100644 --- a/src/client/callers/vaultsPermissionUnset.ts +++ b/src/client/callers/vaultsPermissionUnset.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsPermissionUnset from '../handlers/vaultsPermissionUnset'; +import type VaultsPermissionUnset from '../handlers/VaultsPermissionUnset'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsPull.ts b/src/client/callers/vaultsPull.ts index 0e1759e35..db4f14d04 100644 --- a/src/client/callers/vaultsPull.ts +++ b/src/client/callers/vaultsPull.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsPull from '../handlers/vaultsPull'; +import type VaultsPull from '../handlers/VaultsPull'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsRename.ts b/src/client/callers/vaultsRename.ts index cd5cdf4dc..ace8e7f75 100644 --- a/src/client/callers/vaultsRename.ts +++ b/src/client/callers/vaultsRename.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsRename from '../handlers/vaultsRename'; +import type VaultsRename from '../handlers/VaultsRename'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsScan.ts b/src/client/callers/vaultsScan.ts index 72d35f150..b24e94673 100644 --- a/src/client/callers/vaultsScan.ts +++ b/src/client/callers/vaultsScan.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsScan from '../handlers/vaultsScan'; +import type VaultsScan from '../handlers/VaultsScan'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsDelete.ts b/src/client/callers/vaultsSecretsDelete.ts index d63a54732..e6c48f188 100644 --- a/src/client/callers/vaultsSecretsDelete.ts +++ b/src/client/callers/vaultsSecretsDelete.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsDelete from '../handlers/vaultsSecretsDelete'; +import type VaultsSecretsDelete from '../handlers/VaultsSecretsDelete'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsEdit.ts b/src/client/callers/vaultsSecretsEdit.ts index d2524c953..01815a555 100644 --- a/src/client/callers/vaultsSecretsEdit.ts +++ b/src/client/callers/vaultsSecretsEdit.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsEdit from '../handlers/vaultsSecretsEdit'; +import type VaultsSecretsEdit from '../handlers/VaultsSecretsEdit'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsGet.ts b/src/client/callers/vaultsSecretsGet.ts index f44d05dee..5f4a6b541 100644 --- a/src/client/callers/vaultsSecretsGet.ts +++ b/src/client/callers/vaultsSecretsGet.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsGet from '../handlers/vaultsSecretsGet'; +import type VaultsSecretsGet from '../handlers/VaultsSecretsGet'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsList.ts b/src/client/callers/vaultsSecretsList.ts index df8fc7842..c8bba49ae 100644 --- a/src/client/callers/vaultsSecretsList.ts +++ b/src/client/callers/vaultsSecretsList.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsList from '../handlers/vaultsSecretsList'; +import type VaultsSecretsList from '../handlers/VaultsSecretsList'; import { ServerCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsMkdir.ts b/src/client/callers/vaultsSecretsMkdir.ts index d29497cf1..fb83985c7 100644 --- a/src/client/callers/vaultsSecretsMkdir.ts +++ b/src/client/callers/vaultsSecretsMkdir.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsMkdir from '../handlers/vaultsSecretsMkdir'; +import type VaultsSecretsMkdir from '../handlers/VaultsSecretsMkdir'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsNew.ts b/src/client/callers/vaultsSecretsNew.ts index b3fce18c2..581bac90b 100644 --- a/src/client/callers/vaultsSecretsNew.ts +++ b/src/client/callers/vaultsSecretsNew.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsNew from '../handlers/vaultsSecretsNew'; +import type VaultsSecretsNew from '../handlers/VaultsSecretsNew'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsNewDir.ts b/src/client/callers/vaultsSecretsNewDir.ts index 17450b115..2c840228e 100644 --- a/src/client/callers/vaultsSecretsNewDir.ts +++ b/src/client/callers/vaultsSecretsNewDir.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsNewDir from '../handlers/vaultsSecretsNewDir'; +import type VaultsSecretsNewDir from '../handlers/VaultsSecretsNewDir'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsRename.ts b/src/client/callers/vaultsSecretsRename.ts index f043cb337..1bc07ce1d 100644 --- a/src/client/callers/vaultsSecretsRename.ts +++ b/src/client/callers/vaultsSecretsRename.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsRename from '../handlers/vaultsSecretsRename'; +import type VaultsSecretsRename from '../handlers/VaultsSecretsRename'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsSecretsStat.ts b/src/client/callers/vaultsSecretsStat.ts index 9fe7c2991..507086343 100644 --- a/src/client/callers/vaultsSecretsStat.ts +++ b/src/client/callers/vaultsSecretsStat.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsSecretsStat from '../handlers/vaultsSecretsStat'; +import type VaultsSecretsStat from '../handlers/VaultsSecretsStat'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/callers/vaultsVersion.ts b/src/client/callers/vaultsVersion.ts index 11b46b810..c6e7bfdb8 100644 --- a/src/client/callers/vaultsVersion.ts +++ b/src/client/callers/vaultsVersion.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type VaultsVersion from '../handlers/vaultsVersion'; +import type VaultsVersion from '../handlers/VaultsVersion'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/handlers/agentLockAll.ts b/src/client/handlers/AgentLockAll.ts similarity index 100% rename from src/client/handlers/agentLockAll.ts rename to src/client/handlers/AgentLockAll.ts diff --git a/src/client/handlers/agentStatus.ts b/src/client/handlers/AgentStatus.ts similarity index 100% rename from src/client/handlers/agentStatus.ts rename to src/client/handlers/AgentStatus.ts diff --git a/src/client/handlers/agentStop.ts b/src/client/handlers/AgentStop.ts similarity index 100% rename from src/client/handlers/agentStop.ts rename to src/client/handlers/AgentStop.ts diff --git a/src/client/handlers/agentUnlock.ts b/src/client/handlers/AgentUnlock.ts similarity index 100% rename from src/client/handlers/agentUnlock.ts rename to src/client/handlers/AgentUnlock.ts diff --git a/src/client/handlers/gestaltsActionsGetByIdentity.ts b/src/client/handlers/GestaltsActionsGetByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsActionsGetByIdentity.ts rename to src/client/handlers/GestaltsActionsGetByIdentity.ts diff --git a/src/client/handlers/gestaltsActionsGetByNode.ts b/src/client/handlers/GestaltsActionsGetByNode.ts similarity index 100% rename from src/client/handlers/gestaltsActionsGetByNode.ts rename to src/client/handlers/GestaltsActionsGetByNode.ts diff --git a/src/client/handlers/gestaltsActionsSetByIdentity.ts b/src/client/handlers/GestaltsActionsSetByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsActionsSetByIdentity.ts rename to src/client/handlers/GestaltsActionsSetByIdentity.ts diff --git a/src/client/handlers/gestaltsActionsSetByNode.ts b/src/client/handlers/GestaltsActionsSetByNode.ts similarity index 100% rename from src/client/handlers/gestaltsActionsSetByNode.ts rename to src/client/handlers/GestaltsActionsSetByNode.ts diff --git a/src/client/handlers/gestaltsActionsUnsetByIdentity.ts b/src/client/handlers/GestaltsActionsUnsetByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsActionsUnsetByIdentity.ts rename to src/client/handlers/GestaltsActionsUnsetByIdentity.ts diff --git a/src/client/handlers/gestaltsActionsUnsetByNode.ts b/src/client/handlers/GestaltsActionsUnsetByNode.ts similarity index 100% rename from src/client/handlers/gestaltsActionsUnsetByNode.ts rename to src/client/handlers/GestaltsActionsUnsetByNode.ts diff --git a/src/client/handlers/gestaltsDiscoveryByIdentity.ts b/src/client/handlers/GestaltsDiscoveryByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsDiscoveryByIdentity.ts rename to src/client/handlers/GestaltsDiscoveryByIdentity.ts diff --git a/src/client/handlers/gestaltsDiscoveryByNode.ts b/src/client/handlers/GestaltsDiscoveryByNode.ts similarity index 100% rename from src/client/handlers/gestaltsDiscoveryByNode.ts rename to src/client/handlers/GestaltsDiscoveryByNode.ts diff --git a/src/client/handlers/gestaltsGestaltGetByIdentity.ts b/src/client/handlers/GestaltsGestaltGetByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsGestaltGetByIdentity.ts rename to src/client/handlers/GestaltsGestaltGetByIdentity.ts diff --git a/src/client/handlers/gestaltsGestaltGetByNode.ts b/src/client/handlers/GestaltsGestaltGetByNode.ts similarity index 100% rename from src/client/handlers/gestaltsGestaltGetByNode.ts rename to src/client/handlers/GestaltsGestaltGetByNode.ts diff --git a/src/client/handlers/gestaltsGestaltList.ts b/src/client/handlers/GestaltsGestaltList.ts similarity index 100% rename from src/client/handlers/gestaltsGestaltList.ts rename to src/client/handlers/GestaltsGestaltList.ts diff --git a/src/client/handlers/gestaltsGestaltTrustByIdentity.ts b/src/client/handlers/GestaltsGestaltTrustByIdentity.ts similarity index 100% rename from src/client/handlers/gestaltsGestaltTrustByIdentity.ts rename to src/client/handlers/GestaltsGestaltTrustByIdentity.ts diff --git a/src/client/handlers/gestaltsGestaltTrustByNode.ts b/src/client/handlers/GestaltsGestaltTrustByNode.ts similarity index 100% rename from src/client/handlers/gestaltsGestaltTrustByNode.ts rename to src/client/handlers/GestaltsGestaltTrustByNode.ts diff --git a/src/client/handlers/identitiesAuthenticate.ts b/src/client/handlers/IdentitiesAuthenticate.ts similarity index 100% rename from src/client/handlers/identitiesAuthenticate.ts rename to src/client/handlers/IdentitiesAuthenticate.ts diff --git a/src/client/handlers/identitiesAuthenticatedGet.ts b/src/client/handlers/IdentitiesAuthenticatedGet.ts similarity index 100% rename from src/client/handlers/identitiesAuthenticatedGet.ts rename to src/client/handlers/IdentitiesAuthenticatedGet.ts diff --git a/src/client/handlers/identitiesClaim.ts b/src/client/handlers/IdentitiesClaim.ts similarity index 100% rename from src/client/handlers/identitiesClaim.ts rename to src/client/handlers/IdentitiesClaim.ts diff --git a/src/client/handlers/identitiesInfoConnectedGet.ts b/src/client/handlers/IdentitiesInfoConnectedGet.ts similarity index 100% rename from src/client/handlers/identitiesInfoConnectedGet.ts rename to src/client/handlers/IdentitiesInfoConnectedGet.ts diff --git a/src/client/handlers/identitiesInfoGet.ts b/src/client/handlers/IdentitiesInfoGet.ts similarity index 100% rename from src/client/handlers/identitiesInfoGet.ts rename to src/client/handlers/IdentitiesInfoGet.ts diff --git a/src/client/handlers/identitiesInvite.ts b/src/client/handlers/IdentitiesInvite.ts similarity index 100% rename from src/client/handlers/identitiesInvite.ts rename to src/client/handlers/IdentitiesInvite.ts diff --git a/src/client/handlers/identitiesProvidersList.ts b/src/client/handlers/IdentitiesProvidersList.ts similarity index 100% rename from src/client/handlers/identitiesProvidersList.ts rename to src/client/handlers/IdentitiesProvidersList.ts diff --git a/src/client/handlers/identitiesTokenDelete.ts b/src/client/handlers/IdentitiesTokenDelete.ts similarity index 100% rename from src/client/handlers/identitiesTokenDelete.ts rename to src/client/handlers/IdentitiesTokenDelete.ts diff --git a/src/client/handlers/identitiesTokenGet.ts b/src/client/handlers/IdentitiesTokenGet.ts similarity index 100% rename from src/client/handlers/identitiesTokenGet.ts rename to src/client/handlers/IdentitiesTokenGet.ts diff --git a/src/client/handlers/identitiesTokenPut.ts b/src/client/handlers/IdentitiesTokenPut.ts similarity index 100% rename from src/client/handlers/identitiesTokenPut.ts rename to src/client/handlers/IdentitiesTokenPut.ts diff --git a/src/client/handlers/keysCertsChainGet.ts b/src/client/handlers/KeysCertsChainGet.ts similarity index 100% rename from src/client/handlers/keysCertsChainGet.ts rename to src/client/handlers/KeysCertsChainGet.ts diff --git a/src/client/handlers/keysCertsGet.ts b/src/client/handlers/KeysCertsGet.ts similarity index 100% rename from src/client/handlers/keysCertsGet.ts rename to src/client/handlers/KeysCertsGet.ts diff --git a/src/client/handlers/keysDecrypt.ts b/src/client/handlers/KeysDecrypt.ts similarity index 100% rename from src/client/handlers/keysDecrypt.ts rename to src/client/handlers/KeysDecrypt.ts diff --git a/src/client/handlers/keysEncrypt.ts b/src/client/handlers/KeysEncrypt.ts similarity index 100% rename from src/client/handlers/keysEncrypt.ts rename to src/client/handlers/KeysEncrypt.ts diff --git a/src/client/handlers/keysKeyPair.ts b/src/client/handlers/KeysKeyPair.ts similarity index 100% rename from src/client/handlers/keysKeyPair.ts rename to src/client/handlers/KeysKeyPair.ts diff --git a/src/client/handlers/keysKeyPairRenew.ts b/src/client/handlers/KeysKeyPairRenew.ts similarity index 100% rename from src/client/handlers/keysKeyPairRenew.ts rename to src/client/handlers/KeysKeyPairRenew.ts diff --git a/src/client/handlers/keysKeyPairReset.ts b/src/client/handlers/KeysKeyPairReset.ts similarity index 100% rename from src/client/handlers/keysKeyPairReset.ts rename to src/client/handlers/KeysKeyPairReset.ts diff --git a/src/client/handlers/keysPasswordChange.ts b/src/client/handlers/KeysPasswordChange.ts similarity index 100% rename from src/client/handlers/keysPasswordChange.ts rename to src/client/handlers/KeysPasswordChange.ts diff --git a/src/client/handlers/keysPublicKey.ts b/src/client/handlers/KeysPublicKey.ts similarity index 100% rename from src/client/handlers/keysPublicKey.ts rename to src/client/handlers/KeysPublicKey.ts diff --git a/src/client/handlers/keysSign.ts b/src/client/handlers/KeysSign.ts similarity index 100% rename from src/client/handlers/keysSign.ts rename to src/client/handlers/KeysSign.ts diff --git a/src/client/handlers/keysVerify.ts b/src/client/handlers/KeysVerify.ts similarity index 100% rename from src/client/handlers/keysVerify.ts rename to src/client/handlers/KeysVerify.ts diff --git a/src/client/handlers/nodesAdd.ts b/src/client/handlers/NodesAdd.ts similarity index 100% rename from src/client/handlers/nodesAdd.ts rename to src/client/handlers/NodesAdd.ts diff --git a/src/client/handlers/nodesClaim.ts b/src/client/handlers/NodesClaim.ts similarity index 100% rename from src/client/handlers/nodesClaim.ts rename to src/client/handlers/NodesClaim.ts diff --git a/src/client/handlers/nodesFind.ts b/src/client/handlers/NodesFind.ts similarity index 100% rename from src/client/handlers/nodesFind.ts rename to src/client/handlers/NodesFind.ts diff --git a/src/client/handlers/nodesGetAll.ts b/src/client/handlers/NodesGetAll.ts similarity index 100% rename from src/client/handlers/nodesGetAll.ts rename to src/client/handlers/NodesGetAll.ts diff --git a/src/client/handlers/nodesListConnections.ts b/src/client/handlers/NodesListConnections.ts similarity index 100% rename from src/client/handlers/nodesListConnections.ts rename to src/client/handlers/NodesListConnections.ts diff --git a/src/client/handlers/nodesPing.ts b/src/client/handlers/NodesPing.ts similarity index 100% rename from src/client/handlers/nodesPing.ts rename to src/client/handlers/NodesPing.ts diff --git a/src/client/handlers/notificationsClear.ts b/src/client/handlers/NotificationsClear.ts similarity index 100% rename from src/client/handlers/notificationsClear.ts rename to src/client/handlers/NotificationsClear.ts diff --git a/src/client/handlers/notificationsRead.ts b/src/client/handlers/NotificationsRead.ts similarity index 100% rename from src/client/handlers/notificationsRead.ts rename to src/client/handlers/NotificationsRead.ts diff --git a/src/client/handlers/notificationsSend.ts b/src/client/handlers/NotificationsSend.ts similarity index 100% rename from src/client/handlers/notificationsSend.ts rename to src/client/handlers/NotificationsSend.ts diff --git a/src/client/handlers/vaultsClone.ts b/src/client/handlers/VaultsClone.ts similarity index 100% rename from src/client/handlers/vaultsClone.ts rename to src/client/handlers/VaultsClone.ts diff --git a/src/client/handlers/vaultsCreate.ts b/src/client/handlers/VaultsCreate.ts similarity index 100% rename from src/client/handlers/vaultsCreate.ts rename to src/client/handlers/VaultsCreate.ts diff --git a/src/client/handlers/vaultsDelete.ts b/src/client/handlers/VaultsDelete.ts similarity index 100% rename from src/client/handlers/vaultsDelete.ts rename to src/client/handlers/VaultsDelete.ts diff --git a/src/client/handlers/vaultsList.ts b/src/client/handlers/VaultsList.ts similarity index 100% rename from src/client/handlers/vaultsList.ts rename to src/client/handlers/VaultsList.ts diff --git a/src/client/handlers/vaultsLog.ts b/src/client/handlers/VaultsLog.ts similarity index 100% rename from src/client/handlers/vaultsLog.ts rename to src/client/handlers/VaultsLog.ts diff --git a/src/client/handlers/vaultsPermissionGet.ts b/src/client/handlers/VaultsPermissionGet.ts similarity index 100% rename from src/client/handlers/vaultsPermissionGet.ts rename to src/client/handlers/VaultsPermissionGet.ts diff --git a/src/client/handlers/vaultsPermissionSet.ts b/src/client/handlers/VaultsPermissionSet.ts similarity index 100% rename from src/client/handlers/vaultsPermissionSet.ts rename to src/client/handlers/VaultsPermissionSet.ts diff --git a/src/client/handlers/vaultsPermissionUnset.ts b/src/client/handlers/VaultsPermissionUnset.ts similarity index 100% rename from src/client/handlers/vaultsPermissionUnset.ts rename to src/client/handlers/VaultsPermissionUnset.ts diff --git a/src/client/handlers/vaultsPull.ts b/src/client/handlers/VaultsPull.ts similarity index 100% rename from src/client/handlers/vaultsPull.ts rename to src/client/handlers/VaultsPull.ts diff --git a/src/client/handlers/vaultsRename.ts b/src/client/handlers/VaultsRename.ts similarity index 100% rename from src/client/handlers/vaultsRename.ts rename to src/client/handlers/VaultsRename.ts diff --git a/src/client/handlers/vaultsScan.ts b/src/client/handlers/VaultsScan.ts similarity index 100% rename from src/client/handlers/vaultsScan.ts rename to src/client/handlers/VaultsScan.ts diff --git a/src/client/handlers/vaultsSecretsDelete.ts b/src/client/handlers/VaultsSecretsDelete.ts similarity index 100% rename from src/client/handlers/vaultsSecretsDelete.ts rename to src/client/handlers/VaultsSecretsDelete.ts diff --git a/src/client/handlers/vaultsSecretsEdit.ts b/src/client/handlers/VaultsSecretsEdit.ts similarity index 100% rename from src/client/handlers/vaultsSecretsEdit.ts rename to src/client/handlers/VaultsSecretsEdit.ts diff --git a/src/client/handlers/vaultsSecretsGet.ts b/src/client/handlers/VaultsSecretsGet.ts similarity index 100% rename from src/client/handlers/vaultsSecretsGet.ts rename to src/client/handlers/VaultsSecretsGet.ts diff --git a/src/client/handlers/vaultsSecretsList.ts b/src/client/handlers/VaultsSecretsList.ts similarity index 100% rename from src/client/handlers/vaultsSecretsList.ts rename to src/client/handlers/VaultsSecretsList.ts diff --git a/src/client/handlers/vaultsSecretsMkdir.ts b/src/client/handlers/VaultsSecretsMkdir.ts similarity index 100% rename from src/client/handlers/vaultsSecretsMkdir.ts rename to src/client/handlers/VaultsSecretsMkdir.ts diff --git a/src/client/handlers/vaultsSecretsNew.ts b/src/client/handlers/VaultsSecretsNew.ts similarity index 100% rename from src/client/handlers/vaultsSecretsNew.ts rename to src/client/handlers/VaultsSecretsNew.ts diff --git a/src/client/handlers/vaultsSecretsNewDir.ts b/src/client/handlers/VaultsSecretsNewDir.ts similarity index 100% rename from src/client/handlers/vaultsSecretsNewDir.ts rename to src/client/handlers/VaultsSecretsNewDir.ts diff --git a/src/client/handlers/vaultsSecretsRename.ts b/src/client/handlers/VaultsSecretsRename.ts similarity index 100% rename from src/client/handlers/vaultsSecretsRename.ts rename to src/client/handlers/VaultsSecretsRename.ts diff --git a/src/client/handlers/vaultsSecretsStat.ts b/src/client/handlers/VaultsSecretsStat.ts similarity index 100% rename from src/client/handlers/vaultsSecretsStat.ts rename to src/client/handlers/VaultsSecretsStat.ts diff --git a/src/client/handlers/vaultsVersion.ts b/src/client/handlers/VaultsVersion.ts similarity index 100% rename from src/client/handlers/vaultsVersion.ts rename to src/client/handlers/VaultsVersion.ts diff --git a/src/client/handlers/index.ts b/src/client/handlers/index.ts index 565b9f0cb..c9271798b 100644 --- a/src/client/handlers/index.ts +++ b/src/client/handlers/index.ts @@ -14,74 +14,74 @@ import type NodeGraph from '../../nodes/NodeGraph'; import type VaultManager from '../../vaults/VaultManager'; import type PolykeyAgent from '../../PolykeyAgent'; import type { FileSystem } from '../../types'; -import agentLockAll from './agentLockAll'; -import agentStatus from './agentStatus'; -import agentStop from './agentStop'; -import agentUnlock from './agentUnlock'; -import gestaltsActionsGetByIdentity from './gestaltsActionsGetByIdentity'; -import gestaltsActionsGetByNode from './gestaltsActionsGetByNode'; -import gestaltsActionsSetByIdentity from './gestaltsActionsSetByIdentity'; -import gestaltsActionsSetByNode from './gestaltsActionsSetByNode'; -import gestaltsActionsUnsetByIdentity from './gestaltsActionsUnsetByIdentity'; -import gestaltsActionsUnsetByNode from './gestaltsActionsUnsetByNode'; -import gestaltsDiscoveryByIdentity from './gestaltsDiscoveryByIdentity'; -import gestaltsDiscoveryByNode from './gestaltsDiscoveryByNode'; -import gestaltsGestaltGetByIdentity from './gestaltsGestaltGetByIdentity'; -import gestaltsGestaltGetByNode from './gestaltsGestaltGetByNode'; -import gestaltsGestaltList from './gestaltsGestaltList'; -import gestaltsGestaltTrustByIdentity from './gestaltsGestaltTrustByIdentity'; -import gestaltsGestaltTrustByNode from './gestaltsGestaltTrustByNode'; -import identitiesAuthenticate from './identitiesAuthenticate'; -import identitiesAuthenticatedGet from './identitiesAuthenticatedGet'; -import identitiesClaim from './identitiesClaim'; -import identitiesInfoConnectedGet from './identitiesInfoConnectedGet'; -import identitiesInfoGet from './identitiesInfoGet'; -import identitiesInvite from './identitiesInvite'; -import identitiesProvidersList from './identitiesProvidersList'; -import identitiesTokenDelete from './identitiesTokenDelete'; -import identitiesTokenGet from './identitiesTokenGet'; -import identitiesTokenPut from './identitiesTokenPut'; -import keysCertsChainGet from './keysCertsChainGet'; -import keysCertsGet from './keysCertsGet'; -import keysDecrypt from './keysDecrypt'; -import keysEncrypt from './keysEncrypt'; -import keysKeyPair from './keysKeyPair'; -import keysKeyPairRenew from './keysKeyPairRenew'; -import keysKeyPairReset from './keysKeyPairReset'; -import keysPasswordChange from './keysPasswordChange'; -import keysPublicKey from './keysPublicKey'; -import keysSign from './keysSign'; -import keysVerify from './keysVerify'; -import nodesAdd from './nodesAdd'; -import nodesClaim from './nodesClaim'; -import nodesFind from './nodesFind'; -import nodesGetAll from './nodesGetAll'; -import nodesListConnections from './nodesListConnections'; -import nodesPing from './nodesPing'; -import notificationsClear from './notificationsClear'; -import notificationsRead from './notificationsRead'; -import notificationsSend from './notificationsSend'; -import vaultsClone from './vaultsClone'; -import vaultsCreate from './vaultsCreate'; -import vaultsDelete from './vaultsDelete'; -import vaultsList from './vaultsList'; -import vaultsLog from './vaultsLog'; -import vaultsPermissionGet from './vaultsPermissionGet'; -import vaultsPermissionSet from './vaultsPermissionSet'; -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 vaultsSecretsGet from './vaultsSecretsGet'; -import vaultsSecretsList from './vaultsSecretsList'; -import vaultsSecretsMkdir from './vaultsSecretsMkdir'; -import vaultsSecretsNew from './vaultsSecretsNew'; -import vaultsSecretsNewDir from './vaultsSecretsNewDir'; -import vaultsSecretsRename from './vaultsSecretsRename'; -import vaultsSecretsStat from './vaultsSecretsStat'; -import vaultsVersion from './vaultsVersion'; +import AgentLockAll from './AgentLockAll'; +import AgentStatus from './AgentStatus'; +import AgentStop from './AgentStop'; +import AgentUnlock from './AgentUnlock'; +import GestaltsActionsGetByIdentity from './GestaltsActionsGetByIdentity'; +import GestaltsActionsGetByNode from './GestaltsActionsGetByNode'; +import GestaltsActionsSetByIdentity from './GestaltsActionsSetByIdentity'; +import GestaltsActionsSetByNode from './GestaltsActionsSetByNode'; +import GestaltsActionsUnsetByIdentity from './GestaltsActionsUnsetByIdentity'; +import GestaltsActionsUnsetByNode from './GestaltsActionsUnsetByNode'; +import GestaltsDiscoveryByIdentity from './GestaltsDiscoveryByIdentity'; +import GestaltsDiscoveryByNode from './GestaltsDiscoveryByNode'; +import GestaltsGestaltGetByIdentity from './GestaltsGestaltGetByIdentity'; +import GestaltsGestaltGetByNode from './GestaltsGestaltGetByNode'; +import GestaltsGestaltList from './GestaltsGestaltList'; +import GestaltsGestaltTrustByIdentity from './GestaltsGestaltTrustByIdentity'; +import GestaltsGestaltTrustByNode from './GestaltsGestaltTrustByNode'; +import IdentitiesAuthenticate from './IdentitiesAuthenticate'; +import IdentitiesAuthenticatedGet from './IdentitiesAuthenticatedGet'; +import IdentitiesClaim from './IdentitiesClaim'; +import IdentitiesInfoConnectedGet from './IdentitiesInfoConnectedGet'; +import IdentitiesInfoGet from './IdentitiesInfoGet'; +import IdentitiesInvite from './IdentitiesInvite'; +import IdentitiesProvidersList from './IdentitiesProvidersList'; +import IdentitiesTokenDelete from './IdentitiesTokenDelete'; +import IdentitiesTokenGet from './IdentitiesTokenGet'; +import IdentitiesTokenPut from './IdentitiesTokenPut'; +import KeysCertsChainGet from './KeysCertsChainGet'; +import KeysCertsGet from './KeysCertsGet'; +import KeysDecrypt from './KeysDecrypt'; +import KeysEncrypt from './KeysEncrypt'; +import KeysKeyPair from './KeysKeyPair'; +import KeysKeyPairRenew from './KeysKeyPairRenew'; +import KeysKeyPairReset from './KeysKeyPairReset'; +import KeysPasswordChange from './KeysPasswordChange'; +import KeysPublicKey from './KeysPublicKey'; +import KeysSign from './KeysSign'; +import KeysVerify from './KeysVerify'; +import NodesAdd from './NodesAdd'; +import NodesClaim from './NodesClaim'; +import NodesFind from './NodesFind'; +import NodesGetAll from './NodesGetAll'; +import NodesListConnections from './NodesListConnections'; +import NodesPing from './NodesPing'; +import NotificationsClear from './NotificationsClear'; +import NotificationsRead from './NotificationsRead'; +import NotificationsSend from './NotificationsSend'; +import VaultsClone from './VaultsClone'; +import VaultsCreate from './VaultsCreate'; +import VaultsDelete from './VaultsDelete'; +import VaultsList from './VaultsList'; +import VaultsLog from './VaultsLog'; +import VaultsPermissionGet from './VaultsPermissionGet'; +import VaultsPermissionSet from './VaultsPermissionSet'; +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 VaultsSecretsGet from './VaultsSecretsGet'; +import VaultsSecretsList from './VaultsSecretsList'; +import VaultsSecretsMkdir from './VaultsSecretsMkdir'; +import VaultsSecretsNew from './VaultsSecretsNew'; +import VaultsSecretsNewDir from './VaultsSecretsNewDir'; +import VaultsSecretsRename from './VaultsSecretsRename'; +import VaultsSecretsStat from './VaultsSecretsStat'; +import VaultsVersion from './VaultsVersion'; /** * Server manifest factory. @@ -105,150 +105,150 @@ const serverManifest = (container: { logger: Logger; }) => { return { - agentLockAll: new agentLockAll(container), - agentStatus: new agentStatus(container), - agentStop: new agentStop(container), - agentUnlock: new agentUnlock(container), - gestaltsActionsGetByIdentity: new gestaltsActionsGetByIdentity(container), - gestaltsActionsGetByNode: new gestaltsActionsGetByNode(container), - gestaltsActionsSetByIdentity: new gestaltsActionsSetByNode(container), - gestaltsActionsSetByNode: new gestaltsActionsSetByNode(container), - gestaltsActionsUnsetByIdentity: new gestaltsActionsUnsetByIdentity( + agentLockAll: new AgentLockAll(container), + agentStatus: new AgentStatus(container), + agentStop: new AgentStop(container), + agentUnlock: new AgentUnlock(container), + gestaltsActionsGetByIdentity: new GestaltsActionsGetByIdentity(container), + gestaltsActionsGetByNode: new GestaltsActionsGetByNode(container), + gestaltsActionsSetByIdentity: new GestaltsActionsSetByNode(container), + gestaltsActionsSetByNode: new GestaltsActionsSetByNode(container), + gestaltsActionsUnsetByIdentity: new GestaltsActionsUnsetByIdentity( container, ), - gestaltsActionsUnsetByNode: new gestaltsActionsUnsetByNode(container), - gestaltsDiscoveryByIdentity: new gestaltsDiscoveryByIdentity(container), - gestaltsDiscoveryByNode: new gestaltsDiscoveryByNode(container), - gestaltsGestaltGetByIdentity: new gestaltsGestaltGetByIdentity(container), - gestaltsGestaltGetByNode: new gestaltsGestaltGetByNode(container), - gestaltsGestaltList: new gestaltsGestaltList(container), - gestaltsGestaltTrustByIdentity: new gestaltsGestaltTrustByIdentity( + gestaltsActionsUnsetByNode: new GestaltsActionsUnsetByNode(container), + gestaltsDiscoveryByIdentity: new GestaltsDiscoveryByIdentity(container), + gestaltsDiscoveryByNode: new GestaltsDiscoveryByNode(container), + gestaltsGestaltGetByIdentity: new GestaltsGestaltGetByIdentity(container), + gestaltsGestaltGetByNode: new GestaltsGestaltGetByNode(container), + gestaltsGestaltList: new GestaltsGestaltList(container), + gestaltsGestaltTrustByIdentity: new GestaltsGestaltTrustByIdentity( container, ), - gestaltsGestaltTrustByNode: new gestaltsGestaltTrustByNode(container), - identitiesAuthenticate: new identitiesAuthenticate(container), - identitiesAuthenticatedGet: new identitiesAuthenticatedGet(container), - identitiesClaim: new identitiesClaim(container), - identitiesInfoConnectedGet: new identitiesInfoConnectedGet(container), - identitiesInfoGet: new identitiesInfoGet(container), - identitiesInvite: new identitiesInvite(container), - identitiesProvidersList: new identitiesProvidersList(container), - identitiesTokenDelete: new identitiesTokenDelete(container), - identitiesTokenGet: new identitiesTokenGet(container), - identitiesTokenPut: new identitiesTokenPut(container), - keysCertsChainGet: new keysCertsChainGet(container), - keysCertsGet: new keysCertsGet(container), - keysDecrypt: new keysDecrypt(container), - keysEncrypt: new keysEncrypt(container), - keysKeyPair: new keysKeyPair(container), - keysKeyPairRenew: new keysKeyPairRenew(container), - keysKeyPairReset: new keysKeyPairReset(container), - keysPasswordChange: new keysPasswordChange(container), - keysPublicKey: new keysPublicKey(container), - keysSign: new keysSign(container), - keysVerify: new keysVerify(container), - nodesAdd: new nodesAdd(container), - nodesClaim: new nodesClaim(container), - nodesFind: new nodesFind(container), - nodesGetAll: new nodesGetAll(container), - nodesListConnections: new nodesListConnections(container), - nodesPing: new nodesPing(container), - notificationsClear: new notificationsClear(container), - notificationsRead: new notificationsRead(container), - notificationsSend: new notificationsSend(container), - vaultsClone: new vaultsClone(container), - vaultsCreate: new vaultsCreate(container), - vaultsDelete: new vaultsDelete(container), - vaultsList: new vaultsList(container), - vaultsLog: new vaultsLog(container), - vaultsPermissionGet: new vaultsPermissionGet(container), - vaultsPermissionSet: new vaultsPermissionSet(container), - vaultsPermissionUnset: new vaultsPermissionUnset(container), - vaultsPull: new vaultsPull(container), - vaultsRename: new vaultsRename(container), - vaultsScan: new vaultsScan(container), - vaultsSecretsDelete: new vaultsSecretsDelete(container), - vaultsSecretsEdit: new vaultsSecretsEdit(container), - vaultsSecretsGet: new vaultsSecretsGet(container), - vaultsSecretsList: new vaultsSecretsList(container), - vaultsSecretsMkdir: new vaultsSecretsMkdir(container), - vaultsSecretsNew: new vaultsSecretsNew(container), - vaultsSecretsNewDir: new vaultsSecretsNewDir(container), - vaultsSecretsRename: new vaultsSecretsRename(container), - vaultsSecretsStat: new vaultsSecretsStat(container), - vaultsVersion: new vaultsVersion(container), + gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNode(container), + identitiesAuthenticate: new IdentitiesAuthenticate(container), + identitiesAuthenticatedGet: new IdentitiesAuthenticatedGet(container), + identitiesClaim: new IdentitiesClaim(container), + identitiesInfoConnectedGet: new IdentitiesInfoConnectedGet(container), + identitiesInfoGet: new IdentitiesInfoGet(container), + identitiesInvite: new IdentitiesInvite(container), + identitiesProvidersList: new IdentitiesProvidersList(container), + identitiesTokenDelete: new IdentitiesTokenDelete(container), + identitiesTokenGet: new IdentitiesTokenGet(container), + identitiesTokenPut: new IdentitiesTokenPut(container), + keysCertsChainGet: new KeysCertsChainGet(container), + keysCertsGet: new KeysCertsGet(container), + keysDecrypt: new KeysDecrypt(container), + keysEncrypt: new KeysEncrypt(container), + keysKeyPair: new KeysKeyPair(container), + keysKeyPairRenew: new KeysKeyPairRenew(container), + keysKeyPairReset: new KeysKeyPairReset(container), + keysPasswordChange: new KeysPasswordChange(container), + keysPublicKey: new KeysPublicKey(container), + keysSign: new KeysSign(container), + keysVerify: new KeysVerify(container), + nodesAdd: new NodesAdd(container), + nodesClaim: new NodesClaim(container), + nodesFind: new NodesFind(container), + nodesGetAll: new NodesGetAll(container), + nodesListConnections: new NodesListConnections(container), + nodesPing: new NodesPing(container), + notificationsClear: new NotificationsClear(container), + notificationsRead: new NotificationsRead(container), + notificationsSend: new NotificationsSend(container), + vaultsClone: new VaultsClone(container), + vaultsCreate: new VaultsCreate(container), + vaultsDelete: new VaultsDelete(container), + vaultsList: new VaultsList(container), + vaultsLog: new VaultsLog(container), + vaultsPermissionGet: new VaultsPermissionGet(container), + vaultsPermissionSet: new VaultsPermissionSet(container), + vaultsPermissionUnset: new VaultsPermissionUnset(container), + vaultsPull: new VaultsPull(container), + vaultsRename: new VaultsRename(container), + vaultsScan: new VaultsScan(container), + vaultsSecretsDelete: new VaultsSecretsDelete(container), + vaultsSecretsEdit: new VaultsSecretsEdit(container), + vaultsSecretsGet: new VaultsSecretsGet(container), + vaultsSecretsList: new VaultsSecretsList(container), + vaultsSecretsMkdir: new VaultsSecretsMkdir(container), + vaultsSecretsNew: new VaultsSecretsNew(container), + vaultsSecretsNewDir: new VaultsSecretsNewDir(container), + vaultsSecretsRename: new VaultsSecretsRename(container), + vaultsSecretsStat: new VaultsSecretsStat(container), + vaultsVersion: new VaultsVersion(container), }; }; export default serverManifest; export { - agentLockAll, - agentStatus, - agentStop, - agentUnlock, - gestaltsActionsGetByIdentity, - gestaltsActionsGetByNode, - gestaltsActionsSetByIdentity, - gestaltsActionsSetByNode, - gestaltsActionsUnsetByIdentity, - gestaltsActionsUnsetByNode, - gestaltsDiscoveryByIdentity, - gestaltsDiscoveryByNode, - gestaltsGestaltGetByIdentity, - gestaltsGestaltGetByNode, - gestaltsGestaltList, - gestaltsGestaltTrustByIdentity, - gestaltsGestaltTrustByNode, - identitiesAuthenticate, - identitiesAuthenticatedGet, - identitiesClaim, - identitiesInfoConnectedGet, - identitiesInfoGet, - identitiesInvite, - identitiesProvidersList, - identitiesTokenDelete, - identitiesTokenGet, - identitiesTokenPut, - keysCertsChainGet, - keysCertsGet, - keysDecrypt, - keysEncrypt, - keysKeyPair, - keysKeyPairRenew, - keysKeyPairReset, - keysPasswordChange, - keysPublicKey, - keysSign, - keysVerify, - nodesAdd, - nodesClaim, - nodesFind, - nodesGetAll, - nodesListConnections, - nodesPing, - notificationsClear, - notificationsRead, - notificationsSend, - vaultsClone, - vaultsCreate, - vaultsDelete, - vaultsList, - vaultsLog, - vaultsPermissionGet, - vaultsPermissionSet, - vaultsPermissionUnset, - vaultsPull, - vaultsRename, - vaultsScan, - vaultsSecretsDelete, - vaultsSecretsEdit, - vaultsSecretsGet, - vaultsSecretsList, - vaultsSecretsMkdir, - vaultsSecretsNew, - vaultsSecretsNewDir, - vaultsSecretsRename, - vaultsSecretsStat, - vaultsVersion, + AgentLockAll, + AgentStatus, + AgentStop, + AgentUnlock, + GestaltsActionsGetByIdentity, + GestaltsActionsGetByNode, + GestaltsActionsSetByIdentity, + GestaltsActionsSetByNode, + GestaltsActionsUnsetByIdentity, + GestaltsActionsUnsetByNode, + GestaltsDiscoveryByIdentity, + GestaltsDiscoveryByNode, + GestaltsGestaltGetByIdentity, + GestaltsGestaltGetByNode, + GestaltsGestaltList, + GestaltsGestaltTrustByIdentity, + GestaltsGestaltTrustByNode, + IdentitiesAuthenticate, + IdentitiesAuthenticatedGet, + IdentitiesClaim, + IdentitiesInfoConnectedGet, + IdentitiesInfoGet, + IdentitiesInvite, + IdentitiesProvidersList, + IdentitiesTokenDelete, + IdentitiesTokenGet, + IdentitiesTokenPut, + KeysCertsChainGet, + KeysCertsGet, + KeysDecrypt, + KeysEncrypt, + KeysKeyPair, + KeysKeyPairRenew, + KeysKeyPairReset, + KeysPasswordChange, + KeysPublicKey, + KeysSign, + KeysVerify, + NodesAdd, + NodesClaim, + NodesFind, + NodesGetAll, + NodesListConnections, + NodesPing, + NotificationsClear, + NotificationsRead, + NotificationsSend, + VaultsClone, + VaultsCreate, + VaultsDelete, + VaultsList, + VaultsLog, + VaultsPermissionGet, + VaultsPermissionSet, + VaultsPermissionUnset, + VaultsPull, + VaultsRename, + VaultsScan, + VaultsSecretsDelete, + VaultsSecretsEdit, + VaultsSecretsGet, + VaultsSecretsList, + VaultsSecretsMkdir, + VaultsSecretsNew, + VaultsSecretsNewDir, + VaultsSecretsRename, + VaultsSecretsStat, + VaultsVersion, }; From 9838c1cdbe7e93e97dce9f456e0f7a32e7651032 Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Wed, 11 Oct 2023 18:15:43 +1100 Subject: [PATCH 3/3] fix: client tests had to be updated with new `client` domain --- src/client/callers/notificationsSend.ts | 2 +- src/client/handlers/KeysPublicKey.ts | 3 +- src/client/utils.ts | 2 +- tests/client/ClientService.test.ts | 23 +- tests/client/authenticationMiddleware.test.ts | 24 +- tests/client/handlers/agent.test.ts | 251 ++-- tests/client/handlers/gestalts.test.ts | 819 +++++------ tests/client/handlers/identities.test.ts | 1211 ++++------------- tests/client/handlers/keys.test.ts | 528 ++++--- tests/client/handlers/nodes.test.ts | 470 ++----- tests/client/handlers/notifications.test.ts | 405 ++---- tests/client/handlers/vaults.test.ts | 936 +++++-------- tests/client/timeoutMiddleware.test.ts | 36 +- 13 files changed, 1605 insertions(+), 3105 deletions(-) diff --git a/src/client/callers/notificationsSend.ts b/src/client/callers/notificationsSend.ts index c1ea5467d..d4f6dd182 100644 --- a/src/client/callers/notificationsSend.ts +++ b/src/client/callers/notificationsSend.ts @@ -1,5 +1,5 @@ import type { HandlerTypes } from '@matrixai/rpc'; -import type NotificationsSend from '../handlers/NotificationsRead'; +import type NotificationsSend from '../handlers/NotificationsSend'; import { UnaryCaller } from '@matrixai/rpc'; type CallerTypes = HandlerTypes; diff --git a/src/client/handlers/KeysPublicKey.ts b/src/client/handlers/KeysPublicKey.ts index f0710fa46..3c48fe100 100644 --- a/src/client/handlers/KeysPublicKey.ts +++ b/src/client/handlers/KeysPublicKey.ts @@ -1,7 +1,6 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult, - PasswordMessage, PublicKeyMessage, } from '../types'; import type KeyRing from '../../keys/KeyRing'; @@ -12,7 +11,7 @@ class KeysPublicKey extends UnaryHandler< { keyRing: KeyRing; }, - ClientRPCRequestParams, + ClientRPCRequestParams, ClientRPCResponseResult > { public handle = async (): Promise< diff --git a/src/client/utils.ts b/src/client/utils.ts index e50d4b5e8..66a236286 100644 --- a/src/client/utils.ts +++ b/src/client/utils.ts @@ -6,8 +6,8 @@ import type KeyRing from '../keys/KeyRing'; import type { Certificate, CertificatePEM } from '../keys/types'; import type { NodeId } from '../ids'; import { utils as wsUtils } from '@matrixai/ws'; -import * as keysUtils from '../keys/utils'; import * as clientErrors from './errors'; +import * as keysUtils from '../keys/utils'; async function authenticate( sessionManager: SessionManager, diff --git a/tests/client/ClientService.test.ts b/tests/client/ClientService.test.ts index 008b0d9d1..4d01ccf41 100644 --- a/tests/client/ClientService.test.ts +++ b/tests/client/ClientService.test.ts @@ -2,7 +2,7 @@ import type { TLSConfig } from '@/network/types'; import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger'; import ClientService from '@/client/ClientService'; import * as keysUtils from '@/keys/utils'; -import * as utils from '../utils'; +import * as testsUtils from '../utils'; describe(`ClientService tests`, () => { const logger = new Logger(`${ClientService.name} test`, LogLevel.WARN, [ @@ -11,32 +11,25 @@ describe(`ClientService tests`, () => { ), ]); const localHost = '127.0.0.1'; - let clientService: ClientService; let tlsConfig: TLSConfig; - beforeEach(async () => { - tlsConfig = await utils.createTLSConfig(keysUtils.generateKeyPair()); + tlsConfig = await testsUtils.createTLSConfig(keysUtils.generateKeyPair()); }); afterEach(async () => { await clientService?.stop({ force: true }); }); - test('ClientService readiness', async () => { - clientService = await ClientService.createClientService({ - manifest: {}, - options: { - host: localHost, - }, + clientService = new ClientService({ tlsConfig, - logger, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: {}, + host: localHost, }); await clientService.stop({ force: true }); // Should be a noop await clientService.stop({ force: true }); - await clientService.destroy(); - // Should be a noop - await clientService.destroy(); }); - // TODO: tests? }); diff --git a/tests/client/authenticationMiddleware.test.ts b/tests/client/authenticationMiddleware.test.ts index 632ca95fc..9aa80157e 100644 --- a/tests/client/authenticationMiddleware.test.ts +++ b/tests/client/authenticationMiddleware.test.ts @@ -16,13 +16,13 @@ import { } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; import TaskManager from '@/tasks/TaskManager'; import CertManager from '@/keys/CertManager'; +import ClientService from '@/client/ClientService'; import { Session, SessionManager } from '@/sessions'; +import * as authMiddleware from '@/client/authenticationMiddleware'; +import * as keysUtils from '@/keys/utils'; import * as clientUtils from '@/client/utils'; -import * as authMiddleware from '@/client/utils/authenticationMiddleware'; -import ClientService from '@/client/ClientService'; import * as networkUtils from '@/network/utils'; import * as testsUtils from '../utils'; @@ -107,19 +107,19 @@ describe('authenticationMiddleware', () => { return input; } } - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + middlewareFactory: authMiddleware.authenticationMiddlewareServer( + sessionManager, + keyRing, + ), + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { testHandler: new EchoHandler({ logger }), }, - options: { - host: localhost, - middlewareFactory: authMiddleware.authenticationMiddlewareServer( - sessionManager, - keyRing, - ), - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); clientClient = await WebSocketClient.createWebSocketClient({ config: { diff --git a/tests/client/handlers/agent.test.ts b/tests/client/handlers/agent.test.ts index 580f40f46..fc0be56da 100644 --- a/tests/client/handlers/agent.test.ts +++ b/tests/client/handlers/agent.test.ts @@ -8,27 +8,29 @@ import { running } from '@matrixai/async-init'; import { RPCClient, middleware as rpcUtilsMiddleware } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; import TaskManager from '@/tasks/TaskManager'; -import { AgentLockAllHandler } from '@/client/handlers/agentLockAll'; +import PolykeyAgent from '@/PolykeyAgent'; +import Status from '@/status/Status'; +import CertManager from '@/keys/CertManager'; +import ClientService from '@/client/ClientService'; import { Session, SessionManager } from '@/sessions'; +import config from '@/config'; +import { + AgentLockAll, + AgentStatus, + AgentStop, + AgentUnlock, +} from '@/client/handlers'; import { agentLockAll, agentStatus, - AgentStatusHandler, agentStop, - AgentStopHandler, agentUnlock, - AgentUnlockHandler, -} from '@/client'; -import PolykeyAgent from '@/PolykeyAgent'; -import * as nodesUtils from '@/nodes/utils'; -import config from '@/config'; -import Status from '@/status/Status'; -import CertManager from '@/keys/CertManager'; -import * as clientUtilsAuthMiddleware from '@/client/utils/authenticationMiddleware'; +} from '@/client/callers'; import * as clientUtils from '@/client/utils'; -import ClientService from '@/client/ClientService'; +import * as clientUtilsAuthMiddleware from '@/client/authenticationMiddleware'; +import * as keysUtils from '@/keys/utils'; +import * as nodesUtils from '@/nodes/utils'; import * as networkUtils from '@/network/utils'; import * as testsUtils from '../../utils'; @@ -45,8 +47,11 @@ describe('agentLockAll', () => { let keyRing: KeyRing; let taskManager: TaskManager; let sessionManager: SessionManager; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + agentLockAll: typeof agentLockAll; + }>; let tlsConfig: TLSConfig; beforeEach(async () => { @@ -76,50 +81,47 @@ describe('agentLockAll', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await taskManager.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('locks all current sessions', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - agentLockAll: new AgentLockAllHandler({ + agentLockAll: new AgentLockAll({ db, sessionManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { agentLockAll, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await taskManager.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('locks all current sessions', async () => { const token = await sessionManager.createToken(); await rpcClient.methods.agentLockAll({}); expect(await sessionManager.verifyToken(token)).toBeFalsy(); @@ -134,7 +136,10 @@ describe('agentStatus', () => { let dataDir: string; let pkAgent: PolykeyAgent; let clientService: ClientService; - let clientClient: WebSocketClient; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + agentStatus: typeof agentStatus; + }>; let tlsConfig: TLSConfig; beforeEach(async () => { @@ -155,31 +160,19 @@ describe('agentStatus', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(pkAgent.keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await clientClient?.destroy({ force: true }); - await pkAgent.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('get status', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - agentStatus: new AgentStatusHandler({ - pkAgentProm: Promise.resolve(pkAgent), + agentStatus: new AgentStatus({ + polykeyAgent: pkAgent, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); - clientClient = await WebSocketClient.createWebSocketClient({ + webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, @@ -187,15 +180,25 @@ describe('agentStatus', () => { port: clientService.port, logger, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { agentStatus, }, - streamFactory: () => clientClient.connection.newStream(), + streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('RPCClient'), + logger: logger.getChild(RPCClient.name), }); - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient?.destroy({ force: true }); + await pkAgent.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('get status', async () => { const result = await rpcClient.methods.agentStatus({}); expect(result).toStrictEqual({ pid: process.pid, @@ -222,8 +225,11 @@ describe('agentStop', () => { let db: DB; let keyRing: KeyRing; let taskManager: TaskManager; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + agentStop: typeof agentStop; + }>; let tlsConfig: TLSConfig; let pkAgent: PolykeyAgent; @@ -262,50 +268,47 @@ describe('agentStop', () => { }, logger, }); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('stops the agent', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - agentStop: new AgentStopHandler({ - pkAgentProm: Promise.resolve(pkAgent), + agentStop: new AgentStop({ + polykeyAgent: pkAgent, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { agentStop, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('stops the agent', async () => { const statusPath = path.join(nodePath, config.paths.statusBase); const statusLockPath = path.join(nodePath, config.paths.statusLockBase); const status = new Status({ @@ -336,8 +339,11 @@ describe('agentUnlock', () => { let certManager: CertManager; let session: Session; let sessionManager: SessionManager; - let clientClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + agentUnlock: typeof agentUnlock; + }>; let tlsConfig: TLSConfig; beforeEach(async () => { @@ -378,57 +384,54 @@ describe('agentUnlock', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await clientClient.destroy({ force: true }); - await certManager.stop(); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('unlock', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + middlewareFactory: + clientUtilsAuthMiddleware.authenticationMiddlewareServer( + sessionManager, + keyRing, + ), + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - agentUnlock: new AgentUnlockHandler({}), + agentUnlock: new AgentUnlock({}), }, - options: { - host: localhost, - middlewareFactory: - clientUtilsAuthMiddleware.authenticationMiddlewareServer( - sessionManager, - keyRing, - ), - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); - clientClient = await WebSocketClient.createWebSocketClient({ + webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger, + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { agentUnlock, }, - streamFactory: () => clientClient.connection.newStream(), + streamFactory: () => webSocketClient.connection.newStream(), middlewareFactory: rpcUtilsMiddleware.defaultClientMiddlewareWrapper( clientUtilsAuthMiddleware.authenticationMiddlewareClient(session), ), toError: networkUtils.toError, - logger, + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await certManager.stop(); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('unlock', async () => { const result = await rpcClient.methods.agentUnlock({ metadata: { authorization: clientUtils.encodeAuthFromPassword(password), diff --git a/tests/client/handlers/gestalts.test.ts b/tests/client/handlers/gestalts.test.ts index a675812d5..8f6360502 100644 --- a/tests/client/handlers/gestalts.test.ts +++ b/tests/client/handlers/gestalts.test.ts @@ -1,5 +1,3 @@ -import type { TLSConfig } from '@/network/types'; -import type { ClaimLinkIdentity } from '@/claims/payloads'; import type { ClaimIdEncoded, IdentityId, @@ -9,10 +7,15 @@ import type { NodeId, NodeIdEncoded, } from '@/ids'; -import type { GestaltIdentityInfo, GestaltNodeInfo } from '@/gestalts/types'; -import type { Gestalt } from '@/gestalts/types'; +import type { TLSConfig } from '@/network/types'; +import type { + Gestalt, + GestaltIdentityInfo, + GestaltNodeInfo, +} from '@/gestalts/types'; import type { SignedClaim } from '@/claims/types'; import type { Host } from '@/network/types'; +import type { ClaimLinkIdentity } from '@/claims/payloads'; import fs from 'fs'; import path from 'path'; import os from 'os'; @@ -21,58 +24,58 @@ import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; import TaskManager from '@/tasks/TaskManager'; -import { GestaltsActionsGetByIdentityHandler } from '@/client/handlers/gestaltsActionsGetByIdentity'; -import { GestaltsActionsSetByIdentityHandler } from '@/client/handlers/gestaltsActionsSetByIdentity'; -import { GestaltsActionsUnsetByIdentityHandler } from '@/client/handlers/gestaltsActionsUnsetByIdentity'; -import GestaltGraph from '@/gestalts/GestaltGraph'; import ACL from '@/acl/ACL'; -import * as nodesUtils from '@/nodes/utils'; -import { encodeProviderIdentityId } from '@/ids'; +import GestaltGraph from '@/gestalts/GestaltGraph'; +import PolykeyAgent from '@/PolykeyAgent'; import Token from '@/tokens/Token'; +import IdentitiesManager from '@/identities/IdentitiesManager'; +import NodeGraph from '@/nodes/NodeGraph'; +import NodeManager from '@/nodes/NodeManager'; +import NodeConnectionManager from '@/nodes/NodeConnectionManager'; +import Sigchain from '@/sigchain/Sigchain'; +import Discovery from '@/discovery/Discovery'; +import ClientService from '@/client/ClientService'; +import { + GestaltsActionsGetByIdentity, + GestaltsActionsSetByIdentity, + GestaltsActionsUnsetByIdentity, + GestaltsActionsGetByNode, + GestaltsActionsSetByNode, + GestaltsActionsUnsetByNode, + GestaltsDiscoveryByIdentity, + GestaltsDiscoveryByNode, + GestaltsGestaltGetByIdentity, + GestaltsGestaltGetByNode, + GestaltsGestaltList, + GestaltsGestaltTrustByIdentity, + GestaltsGestaltTrustByNode, +} from '@/client/handlers'; import { gestaltsActionsGetByIdentity, gestaltsActionsGetByNode, - GestaltsActionsGetByNodeHandler, gestaltsActionsSetByIdentity, gestaltsActionsSetByNode, - GestaltsActionsSetByNodeHandler, gestaltsActionsUnsetByIdentity, gestaltsActionsUnsetByNode, - GestaltsActionsUnsetByNodeHandler, gestaltsDiscoveryByIdentity, - GestaltsDiscoveryByIdentityHandler, gestaltsDiscoveryByNode, - GestaltsDiscoveryByNodeHandler, gestaltsGestaltGetByIdentity, - GestaltsGestaltGetByIdentityHandler, gestaltsGestaltGetByNode, - GestaltsGestaltGetByNodeHandler, gestaltsGestaltList, - GestaltsGestaltListHandler, gestaltsGestaltTrustByIdentity, - GestaltsGestaltTrustByIdentityHandler, gestaltsGestaltTrustByNode, - GestaltsGestaltTrustByNodeHandler, -} from '@/client'; -import IdentitiesManager from '@/identities/IdentitiesManager'; -import NodeGraph from '@/nodes/NodeGraph'; -import NodeManager from '@/nodes/NodeManager'; -import NodeConnectionManager from '@/nodes/NodeConnectionManager'; -import Sigchain from '@/sigchain/Sigchain'; -import Discovery from '@/discovery/Discovery'; +} from '@/client/callers'; +import { encodeProviderIdentityId } from '@/ids'; +import * as nodesUtils from '@/nodes/utils'; import * as gestaltUtils from '@/gestalts/utils'; import * as gestaltsErrors from '@/gestalts/errors'; -import { sleep } from '@/utils/utils'; -import PolykeyAgent from '@/PolykeyAgent'; -import ClientService from '@/client/ClientService'; import * as networkUtils from '@/network/utils'; +import * as keysUtils from '@/keys/utils'; +import * as utils from '@/utils'; import * as testsUtils from '../../utils'; -import TestProvider from '../../identities/TestProvider'; -import * as testUtils from '../../utils/utils'; -import * as tlsTestsUtils from '../../utils/tls'; import * as testNodesUtils from '../../nodes/utils'; +import TestProvider from '../../identities/TestProvider'; describe('gestaltsActionsByIdentity', () => { const logger = new Logger('gestaltsActionsByIdentity test', LogLevel.WARN, [ @@ -139,34 +142,33 @@ describe('gestaltsActionsByIdentity', () => { }); test('sets/unsets/gets actions by identity', async () => { // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - gestaltsActionsGetByIdentity: new GestaltsActionsGetByIdentityHandler({ + gestaltsActionsGetByIdentity: new GestaltsActionsGetByIdentity({ db, gestaltGraph, }), - gestaltsActionsSetByIdentity: new GestaltsActionsSetByIdentityHandler({ + gestaltsActionsSetByIdentity: new GestaltsActionsSetByIdentity({ + db, + gestaltGraph, + }), + gestaltsActionsUnsetByIdentity: new GestaltsActionsUnsetByIdentity({ db, gestaltGraph, }), - gestaltsActionsUnsetByIdentity: - new GestaltsActionsUnsetByIdentityHandler({ - db, - gestaltGraph, - }), - }, - options: { - host: localhost, }, - logger: logger.getChild('server'), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); const rpcClient = new RPCClient({ @@ -177,7 +179,7 @@ describe('gestaltsActionsByIdentity', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); // Doing the test @@ -244,12 +246,16 @@ describe('gestaltsActionsByNode', () => { let db: DB; let keyRing: KeyRing; let taskManager: TaskManager; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + gestaltsActionsGetByNode: typeof gestaltsActionsGetByNode; + gestaltsActionsSetByNode: typeof gestaltsActionsSetByNode; + gestaltsActionsUnsetByNode: typeof gestaltsActionsUnsetByNode; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -281,52 +287,36 @@ describe('gestaltsActionsByNode', () => { db, logger, }); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await acl.stop(); - await gestaltGraph.stop(); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('sets/unsets/gets actions by node', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - gestaltsActionsGetByNode: new GestaltsActionsGetByNodeHandler({ + gestaltsActionsGetByNode: new GestaltsActionsGetByNode({ db, gestaltGraph, }), - gestaltsActionsSetByNode: new GestaltsActionsSetByNodeHandler({ + gestaltsActionsSetByNode: new GestaltsActionsSetByNode({ db, gestaltGraph, }), - gestaltsActionsUnsetByNode: new GestaltsActionsUnsetByNodeHandler({ + gestaltsActionsUnsetByNode: new GestaltsActionsUnsetByNode({ db, gestaltGraph, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { gestaltsActionsGetByNode, gestaltsActionsSetByNode, @@ -334,10 +324,23 @@ describe('gestaltsActionsByNode', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await acl.stop(); + await gestaltGraph.stop(); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('sets/unsets/gets actions by node', async () => { const nodeId = keyRing.getNodeId(); const node: GestaltNodeInfo = { nodeId: nodeId, @@ -365,7 +368,7 @@ describe('gestaltsActionsByNode', () => { expect(getUnsetResponse.actionsList).toHaveLength(0); }); }); -describe('gestaltsDiscoverByIdentity', () => { +describe('gestaltsDiscoveryByIdentity', () => { const logger = new Logger('gestaltsDiscoverByIdentity test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -380,6 +383,9 @@ describe('gestaltsDiscoverByIdentity', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsDiscoveryByIdentity: typeof gestaltsDiscoveryByIdentity; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; let identitiesManager: IdentitiesManager; @@ -388,7 +394,6 @@ describe('gestaltsDiscoverByIdentity', () => { let nodeManager: NodeManager; let nodeConnectionManager: NodeConnectionManager; let discovery: Discovery; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -414,7 +419,7 @@ describe('gestaltsDiscoverByIdentity', () => { logger, lazy: true, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); acl = await ACL.createACL({ db, logger, @@ -474,6 +479,34 @@ describe('gestaltsDiscoverByIdentity', () => { taskManager, }); await taskManager.startProcessing(); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + gestaltsDiscoveryByIdentity: new GestaltsDiscoveryByIdentity({ + discovery, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + gestaltsDiscoveryByIdentity, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { await taskManager.stopProcessing(); @@ -497,37 +530,6 @@ describe('gestaltsDiscoverByIdentity', () => { }); }); test('discovers by identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsDiscoveryByIdentity: new GestaltsDiscoveryByIdentityHandler({ - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsDiscoveryByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const identity: GestaltIdentityInfo = { identityId: 'identityId' as IdentityId, providerId: 'providerId' as ProviderId, @@ -544,7 +546,7 @@ describe('gestaltsDiscoverByIdentity', () => { mockDiscoveryByIdentity.mockRestore(); }); }); -describe('gestaltsDiscoverByNode', () => { +describe('gestaltsDiscoveryByNode', () => { const logger = new Logger('gestaltsDiscoverByNode test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -556,8 +558,11 @@ describe('gestaltsDiscoverByNode', () => { let db: DB; let keyRing: KeyRing; let taskManager: TaskManager; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + gestaltsDiscoveryByNode: typeof gestaltsDiscoveryByNode; + }>; let tlsConfig: TLSConfig; let acl: ACL; let gestaltGraph: GestaltGraph; @@ -593,7 +598,7 @@ describe('gestaltsDiscoverByNode', () => { logger, lazy: true, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); acl = await ACL.createACL({ db, logger, @@ -651,6 +656,34 @@ describe('gestaltsDiscoverByNode', () => { taskManager, }); await taskManager.startProcessing(); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + gestaltsDiscoveryByNode: new GestaltsDiscoveryByNode({ + discovery, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + gestaltsDiscoveryByNode, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { await taskManager.stopProcessing(); @@ -674,37 +707,6 @@ describe('gestaltsDiscoverByNode', () => { }); }); test('discovers by node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsDiscoveryByNode: new GestaltsDiscoveryByNodeHandler({ - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsDiscoveryByNode, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const mockDiscoveryByNode = jest .spyOn(Discovery.prototype, 'queueDiscoveryByNode') .mockResolvedValue(); @@ -737,9 +739,11 @@ describe('gestaltsGestaltGetByIdentity', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsGestaltGetByIdentity: typeof gestaltsGestaltGetByIdentity; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -771,53 +775,50 @@ describe('gestaltsGestaltGetByIdentity', () => { db, logger, }); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await acl.stop(); - await gestaltGraph.stop(); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets gestalt by identity', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - gestaltsGestaltGetByIdentity: new GestaltsGestaltGetByIdentityHandler({ + gestaltsGestaltGetByIdentity: new GestaltsGestaltGetByIdentity({ db, gestaltGraph, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { gestaltsGestaltGetByIdentity, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await acl.stop(); + await gestaltGraph.stop(); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets gestalt by identity', async () => { const nodeId = keyRing.getNodeId(); const node: GestaltNodeInfo = { nodeId: nodeId, @@ -887,9 +888,11 @@ describe('gestaltsGestaltGetByNode', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsGestaltGetByNode: typeof gestaltsGestaltGetByNode; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -921,56 +924,53 @@ describe('gestaltsGestaltGetByNode', () => { db, logger, }); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await acl.stop(); - await gestaltGraph.stop(); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets gestalt by node', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - gestaltsGestaltGetByNode: new GestaltsGestaltGetByNodeHandler({ + gestaltsGestaltGetByNode: new GestaltsGestaltGetByNode({ db, gestaltGraph, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { gestaltsGestaltGetByNode, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test - const nodeId = keyRing.getNodeId(); - const node: GestaltNodeInfo = { - nodeId: nodeId, + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await acl.stop(); + await gestaltGraph.stop(); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets gestalt by node', async () => { + const nodeId = keyRing.getNodeId(); + const node: GestaltNodeInfo = { + nodeId: nodeId, }; const identity: GestaltIdentityInfo = { identityId: 'identityId' as IdentityId, @@ -1035,9 +1035,11 @@ describe('gestaltsGestaltList', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsGestaltList: typeof gestaltsGestaltList; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1069,53 +1071,50 @@ describe('gestaltsGestaltList', () => { db, logger, }); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await acl.stop(); - await gestaltGraph.stop(); - await taskManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('lists gestalts', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - gestaltsGestaltList: new GestaltsGestaltListHandler({ + gestaltsGestaltList: new GestaltsGestaltList({ db, gestaltGraph, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { gestaltsGestaltList, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await acl.stop(); + await gestaltGraph.stop(); + await taskManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('lists gestalts', async () => { const nodeId = keyRing.getNodeId(); const node: GestaltNodeInfo = { nodeId: nodeId, @@ -1178,6 +1177,9 @@ describe('gestaltsGestaltTrustByIdentity', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsGestaltTrustByIdentity: typeof gestaltsGestaltTrustByIdentity; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; let identitiesManager: IdentitiesManager; @@ -1216,7 +1218,7 @@ describe('gestaltsGestaltTrustByIdentity', () => { logger, lazy: true, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); acl = await ACL.createACL({ db, logger, @@ -1293,6 +1295,36 @@ describe('gestaltsGestaltTrustByIdentity', () => { connectedIdentity, claim as SignedClaim, ); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + gestaltsGestaltTrustByIdentity: new GestaltsGestaltTrustByIdentity({ + db, + gestaltGraph, + discovery, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + gestaltsGestaltTrustByIdentity, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { await taskManager.stopProcessing(); @@ -1316,40 +1348,6 @@ describe('gestaltsGestaltTrustByIdentity', () => { }); }); test('trusts an identity (already set in gestalt graph)', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByIdentity: - new GestaltsGestaltTrustByIdentityHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test testProvider.users['disconnected-user'] = {}; await gestaltGraph.linkNodeAndIdentity( { nodeId: keyRing.getNodeId() }, @@ -1379,47 +1377,13 @@ describe('gestaltsGestaltTrustByIdentity', () => { }); }); test('trusts an identity (new identity)', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByIdentity: - new GestaltsGestaltTrustByIdentityHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const request = { providerId: testProvider.id, identityId: connectedIdentity, }; // Should fail on first attempt - need to allow time for the identity to be // linked to a node via discovery - await testUtils.expectRemoteError( + await testsUtils.expectRemoteError( rpcClient.methods.gestaltsGestaltTrustByIdentity(request), gestaltsErrors.ErrorGestaltsGraphIdentityIdMissing, ); @@ -1439,92 +1403,24 @@ describe('gestaltsGestaltTrustByIdentity', () => { }); }); test('cannot trust a disconnected identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByIdentity: - new GestaltsGestaltTrustByIdentityHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test testProvider.users['disconnected-user'] = {}; const request = { providerId: testProvider.id, identityId: connectedIdentity, }; // Should fail on first attempt - attempt to find a connected node - await testUtils.expectRemoteError( + await testsUtils.expectRemoteError( rpcClient.methods.gestaltsGestaltTrustByIdentity(request), gestaltsErrors.ErrorGestaltsGraphIdentityIdMissing, ); // Wait and try again - should fail again because the identity has no // linked nodes we can trust - await testUtils.expectRemoteError( + await testsUtils.expectRemoteError( rpcClient.methods.gestaltsGestaltTrustByIdentity(request), gestaltsErrors.ErrorGestaltsGraphIdentityIdMissing, ); }); test('trust extends to entire gestalt', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByIdentity: - new GestaltsGestaltTrustByIdentityHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await gestaltGraph.linkNodeAndIdentity( { nodeId: keyRing.getNodeId() }, { @@ -1558,40 +1454,6 @@ describe('gestaltsGestaltTrustByIdentity', () => { }); }); test('links trusted identity to an existing node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByIdentity: - new GestaltsGestaltTrustByIdentityHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByIdentity, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await gestaltGraph.setNode({ nodeId: keyRing.getNodeId(), }); @@ -1601,12 +1463,12 @@ describe('gestaltsGestaltTrustByIdentity', () => { }; // Should fail on first attempt - need to allow time for the identity to be // linked to a node via discovery - await testUtils.expectRemoteError( + await testsUtils.expectRemoteError( rpcClient.methods.gestaltsGestaltTrustByIdentity(request), gestaltsErrors.ErrorGestaltsGraphIdentityIdMissing, ); // Wait and try again - should succeed second time - await sleep(2000); + await utils.sleep(2000); await rpcClient.methods.gestaltsGestaltTrustByIdentity(request); // Wait for both identity and node to be set in GG let existingTasks: number = 0; @@ -1644,6 +1506,9 @@ describe('gestaltsGestaltTrustByNode', () => { let webSocketClient: WebSocketClient; let clientService: ClientService; let tlsConfig: TLSConfig; + let rpcClient: RPCClient<{ + gestaltsGestaltTrustByNode: typeof gestaltsGestaltTrustByNode; + }>; let acl: ACL; let gestaltGraph: GestaltGraph; let identitiesManager: IdentitiesManager; @@ -1660,7 +1525,6 @@ describe('gestaltsGestaltTrustByNode', () => { let node: PolykeyAgent; let mockedRequestChainData: jest.SpyInstance; let nodeDataDir: string; - beforeEach(async () => { testProvider = new TestProvider(); dataDir = await fs.promises.mkdtemp( @@ -1727,7 +1591,7 @@ describe('gestaltsGestaltTrustByNode', () => { logger, lazy: true, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); acl = await ACL.createACL({ db, logger, @@ -1793,6 +1657,36 @@ describe('gestaltsGestaltTrustByNode', () => { taskManager, }); await taskManager.startProcessing(); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNode({ + db, + gestaltGraph, + discovery, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + gestaltsGestaltTrustByNode, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { await taskManager.stopProcessing(); @@ -1822,39 +1716,6 @@ describe('gestaltsGestaltTrustByNode', () => { mockedRequestChainData.mockRestore(); }); test('trusts a node (already set in gestalt graph)', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNodeHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByNode, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await gestaltGraph.setNode({ nodeId: nodeIdRemote }); const request = { nodeIdEncoded: nodeIdEncodedRemote, @@ -1867,39 +1728,6 @@ describe('gestaltsGestaltTrustByNode', () => { }); }); test('trusts a node (new node)', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNodeHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByNode, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const request = { nodeIdEncoded: nodeIdEncodedRemote, }; @@ -1911,39 +1739,6 @@ describe('gestaltsGestaltTrustByNode', () => { }); }); test('trust extends to entire gestalt', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - gestaltsGestaltTrustByNode: new GestaltsGestaltTrustByNodeHandler({ - db, - gestaltGraph, - discovery, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - gestaltsGestaltTrustByNode, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const request = { nodeIdEncoded: nodeIdEncodedRemote, }; diff --git a/tests/client/handlers/identities.test.ts b/tests/client/handlers/identities.test.ts index 4347f577e..e901e7c11 100644 --- a/tests/client/handlers/identities.test.ts +++ b/tests/client/handlers/identities.test.ts @@ -1,12 +1,12 @@ -import type { TLSConfig } from '@/network/types'; +import type GestaltGraph from '@/gestalts/GestaltGraph'; import type { IdentityId, ProviderId } from '@/ids'; -import type { ClientRPCResponseResult } from '@/client/types'; import type { + ClientRPCResponseResult, IdentityInfoMessage, IdentityMessage, -} from '@/client/handlers/types'; +} from '@/client/types'; +import type { TLSConfig } from '@/network/types'; import type { Claim } from '@/claims/types'; -import type GestaltGraph from '@/gestalts/GestaltGraph'; import type { ClaimLinkIdentity } from '@/claims/payloads'; import type ACL from '@/acl/ACL'; import type NotificationsManager from '@/notifications/NotificationsManager'; @@ -17,39 +17,41 @@ import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger'; import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; -import { encodeProviderIdentityId } from '@/ids'; +import Token from '@/tokens/Token'; import Sigchain from '@/sigchain/Sigchain'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; -import { IdentitiesAuthenticateHandler } from '@/client/handlers/identitiesAuthenticate'; import IdentitiesManager from '@/identities/IdentitiesManager'; -import * as validationErrors from '@/validation/errors'; +import ClientService from '@/client/ClientService'; +import { + IdentitiesAuthenticate, + IdentitiesAuthenticatedGet, + IdentitiesClaim, + IdentitiesInfoConnectedGet, + IdentitiesInfoGet, + IdentitiesInvite, + IdentitiesProvidersList, + IdentitiesTokenDelete, + IdentitiesTokenGet, + IdentitiesTokenPut, +} from '@/client/handlers'; import { identitiesAuthenticate, identitiesAuthenticatedGet, - IdentitiesAuthenticatedGetHandler, identitiesClaim, - IdentitiesClaimHandler, identitiesInfoConnectedGet, - IdentitiesInfoConnectedGetHandler, identitiesInfoGet, - IdentitiesInfoGetHandler, identitiesInvite, - IdentitiesInviteHandler, identitiesProvidersList, - IdentitiesProvidersListHandler, identitiesTokenDelete, - IdentitiesTokenDeleteHandler, identitiesTokenGet, - IdentitiesTokenGetHandler, identitiesTokenPut, - IdentitiesTokenPutHandler, -} from '@/client'; +} from '@/client/callers'; +import { encodeProviderIdentityId } from '@/ids'; +import * as keysUtils from '@/keys/utils'; +import * as validationErrors from '@/validation/errors'; import * as claimsUtils from '@/claims/utils'; import * as nodesUtils from '@/nodes/utils'; -import Token from '@/tokens/Token'; import * as identitiesErrors from '@/identities/errors'; -import ClientService from '@/client/ClientService'; import * as networkUtils from '@/network/utils'; import * as testUtils from '../../utils'; import * as testsUtils from '../../utils'; @@ -66,8 +68,11 @@ describe('identitiesAuthenticate', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesAuthenticate: typeof identitiesAuthenticate; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; let testProvider: TestProvider; @@ -78,7 +83,6 @@ describe('identitiesAuthenticate', () => { accessToken: 'abc123', }, }; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -109,50 +113,47 @@ describe('identitiesAuthenticate', () => { testProvider = new TestProvider(); identitiesManager.registerProvider(testProvider); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('authenticates identity', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesAuthenticate: new IdentitiesAuthenticateHandler({ + identitiesAuthenticate: new IdentitiesAuthenticate({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesAuthenticate, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('authenticates identity', async () => { const request = { providerId: testToken.providerId, }; @@ -187,37 +188,6 @@ describe('identitiesAuthenticate', () => { ); }); test('cannot authenticate invalid provider', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesAuthenticate: new IdentitiesAuthenticateHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesAuthenticate, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const request = { providerId: '', }; @@ -240,8 +210,11 @@ describe('identitiesAuthenticatedGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesAuthenticatedGet: typeof identitiesAuthenticatedGet; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; const providerToken = { @@ -276,50 +249,47 @@ describe('identitiesAuthenticatedGet', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets an authenticated identity', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesAuthenticatedGet: new IdentitiesAuthenticatedGetHandler({ + identitiesAuthenticatedGet: new IdentitiesAuthenticatedGet({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesAuthenticatedGet, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets an authenticated identity', async () => { // Setup provider const provider = new TestProvider(); const user1 = { @@ -342,37 +312,6 @@ describe('identitiesAuthenticatedGet', () => { expect(output[0]).toEqual(user1); }); test('does not get an unauthenticated identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesAuthenticatedGet: new IdentitiesAuthenticatedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesAuthenticatedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test // Setup provider const provider = new TestProvider(); const user1 = { @@ -395,37 +334,6 @@ describe('identitiesAuthenticatedGet', () => { expect(output).toHaveLength(0); }); test('gets authenticated identities from multiple providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesAuthenticatedGet: new IdentitiesAuthenticatedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesAuthenticatedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); @@ -472,37 +380,6 @@ describe('identitiesAuthenticatedGet', () => { expect(output[2]).toEqual(user3); }); test('gets authenticated identities a specific provider', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesAuthenticatedGet: new IdentitiesAuthenticatedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesAuthenticatedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); @@ -560,8 +437,11 @@ describe('identitiesClaim', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesClaim: typeof identitiesClaim; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; let mockedAddClaim: jest.SpyInstance; @@ -640,52 +520,50 @@ describe('identitiesClaim', () => { testProvider = new TestProvider(); identitiesManager.registerProvider(testProvider); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await sigchain.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - mockedAddClaim.mockRestore(); - }); - test('claims identity', async () => { // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesClaim: new IdentitiesClaimHandler({ + identitiesClaim: new IdentitiesClaim({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesClaim, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await sigchain.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + mockedAddClaim.mockRestore(); + }); + test('claims identity', async () => { // Setup provider // Need an authenticated identity await identitiesManager.putToken( @@ -702,37 +580,6 @@ describe('identitiesClaim', () => { expect(response.url).toBe('test.com'); }); test('cannot claim invalid identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesClaim: new IdentitiesClaimHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesClaim, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test // Setup provider await testUtils.expectRemoteError( rpcClient.methods.identitiesClaim({ @@ -768,8 +615,11 @@ describe('identitiesInfoConnectedGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesInfoConnectedGet: typeof identitiesInfoConnectedGet; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; const testToken = { @@ -778,7 +628,6 @@ describe('identitiesInfoConnectedGet', () => { accessToken: 'abc123', }, }; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -807,51 +656,47 @@ describe('identitiesInfoConnectedGet', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets connected identities from a single provider', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ + identitiesInfoConnectedGet: new IdentitiesInfoConnectedGet({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesInfoConnectedGet, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test - // Setup provider + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets connected identities from a single provider', async () => { const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -906,38 +751,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('gets connected identities to a particular identity id', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // Setup provider const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -989,38 +802,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('gets connected identities from multiple providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1080,39 +861,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('gets connected identities from all providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1172,39 +920,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('searches for identities matching a search term', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup provider const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -1252,39 +967,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('searches for identities matching multiple search terms', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -1339,38 +1021,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('searches for identities matching a search term across multiple providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1430,39 +1080,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('gets no connected identities', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup provider const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -1503,39 +1120,6 @@ describe('identitiesInfoConnectedGet', () => { expect(output).toHaveLength(0); }); test('gets one connected identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1588,39 +1172,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('cannot get more identities than available', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1680,39 +1231,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('can only get from authenticated providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -1759,38 +1277,6 @@ describe('identitiesInfoConnectedGet', () => { }); }); test('gets disconnected identities', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoConnectedGet: new IdentitiesInfoConnectedGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoConnectedGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // This feature is not implemented yet - should throw error const response = await rpcClient.methods.identitiesInfoConnectedGet({ disconnected: true, @@ -1815,8 +1301,11 @@ describe('identitiesInfoGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesInfoGet: typeof identitiesInfoGet; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; const testToken = { @@ -1825,7 +1314,6 @@ describe('identitiesInfoGet', () => { accessToken: 'abc123', }, }; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1854,51 +1342,47 @@ describe('identitiesInfoGet', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets an identity', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ + identitiesInfoGet: new IdentitiesInfoGet({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesInfoGet, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test - // Setup provider + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets an identity', async () => { const provider = new TestProvider(); const user1 = { providerId: provider.id, @@ -1931,40 +1415,8 @@ describe('identitiesInfoGet', () => { providerId: user1.providerId, url: user1.url, }); - }); - test('searches for a handle across providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // Setup providers + }); + test('searches for a handle across providers', async () => { const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -2021,39 +1473,6 @@ describe('identitiesInfoGet', () => { }); }); test('searches for identities matching a search term', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -2103,39 +1522,6 @@ describe('identitiesInfoGet', () => { }); }); test('gets no connected identities', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup provider const provider = new TestProvider(); provider.users['user1'] = { providerId: provider.id, @@ -2170,39 +1556,6 @@ describe('identitiesInfoGet', () => { expect(output).toHaveLength(0); }); test('gets one connected identity', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -2252,39 +1605,6 @@ describe('identitiesInfoGet', () => { }); }); test('cannot get more identities than available', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -2342,39 +1662,6 @@ describe('identitiesInfoGet', () => { }); }); test('can only get from authenticated providers', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - identitiesInfoGet: new IdentitiesInfoGetHandler({ - identitiesManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - identitiesInfoGet, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - - // Setup providers const provider1 = new TestProvider('provider1' as ProviderId); const provider2 = new TestProvider('provider2' as ProviderId); const user1 = { @@ -2429,13 +1716,18 @@ describe('identitiesInvite', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesInvite: typeof identitiesInvite; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; let mockedAddClaim: jest.SpyInstance; let testProvider: TestProvider; let sigchain: Sigchain; + let acl: ACL; + let notificationsManager: NotificationsManager; const testToken = { providerId: 'test-provider' as ProviderId, identityId: 'test_user' as IdentityId, @@ -2462,7 +1754,6 @@ describe('identitiesInvite', () => { const token = Token.fromPayload(dummyClaim); token.signWithPrivateKey(issNodeKeypair); const signedClaim = token.toSigned(); - beforeEach(async () => { mockedAddClaim = jest .spyOn(Sigchain.prototype, 'addClaim') @@ -2509,61 +1800,58 @@ describe('identitiesInvite', () => { testProvider = new TestProvider(); identitiesManager.registerProvider(testProvider); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await sigchain.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - mockedAddClaim.mockRestore(); - }); - test('Invite a node', async () => { - // Setup - const acl = { + acl = { setNodeAction: jest.fn(), - }; - const notificationsManager = { + } as unknown as ACL; + notificationsManager = { sendNotification: jest.fn(), - }; - clientService = await ClientService.createClientService({ + } as unknown as NotificationsManager; + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesInvite: new IdentitiesInviteHandler({ + identitiesInvite: new IdentitiesInvite({ acl: acl as unknown as ACL, notificationsManager: notificationsManager as unknown as NotificationsManager, logger, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesInvite, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await sigchain.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + mockedAddClaim.mockRestore(); + }); + test('Invite a node', async () => { const nodeId = testsUtils.generateRandomNodeId(); await rpcClient.methods.identitiesInvite({ nodeIdEncoded: nodesUtils.encodeNodeId(nodeId), @@ -2585,9 +1873,12 @@ describe('identitiesProvidersList', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesProvidersList: typeof identitiesProvidersList; + }>; let identitiesManager: IdentitiesManager; const id1 = 'provider1' as ProviderId; const id2 = 'provider2' as ProviderId; @@ -2595,7 +1886,6 @@ describe('identitiesProvidersList', () => { providers[id1] = new TestProvider(); providers[id2] = new TestProvider(); let mockedGetProviders: jest.SpyInstance; - beforeEach(async () => { mockedGetProviders = jest .spyOn(IdentitiesManager.prototype, 'getProviders') @@ -2627,51 +1917,48 @@ describe('identitiesProvidersList', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - mockedGetProviders.mockRestore(); - }); - test('identitiesProvidersList', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesProvidersList: new IdentitiesProvidersListHandler({ + identitiesProvidersList: new IdentitiesProvidersList({ identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesProvidersList, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + mockedGetProviders.mockRestore(); + }); + test('identitiesProvidersList', async () => { const response = await rpcClient.methods.identitiesProvidersList({}); expect(response.providerIds).toContain('provider1'); expect(response.providerIds).toContain('provider2'); @@ -2688,9 +1975,15 @@ describe('identitiesTokenPutDeleteGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; + let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + identitiesTokenPut: typeof identitiesTokenPut; + identitiesTokenDelete: typeof identitiesTokenDelete; + identitiesTokenGet: typeof identitiesTokenGet; + }>; let identitiesManager: IdentitiesManager; const testToken = { providerId: 'test-provider' as ProviderId, @@ -2699,7 +1992,6 @@ describe('identitiesTokenPutDeleteGet', () => { accessToken: 'abc123', }, }; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -2728,50 +2020,36 @@ describe('identitiesTokenPutDeleteGet', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('puts/deletes/gets tokens', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - identitiesTokenPut: new IdentitiesTokenPutHandler({ + identitiesTokenPut: new IdentitiesTokenPut({ identitiesManager, db, }), - identitiesTokenDelete: new IdentitiesTokenDeleteHandler({ + identitiesTokenDelete: new IdentitiesTokenDelete({ db, identitiesManager, }), - identitiesTokenGet: new IdentitiesTokenGetHandler({ + identitiesTokenGet: new IdentitiesTokenGet({ db, identitiesManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { identitiesTokenPut, identitiesTokenDelete, @@ -2779,10 +2057,21 @@ describe('identitiesTokenPutDeleteGet', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('puts/deletes/gets tokens', async () => { // Put token const providerMessage = { providerId: testToken.providerId, diff --git a/tests/client/handlers/keys.test.ts b/tests/client/handlers/keys.test.ts index 3d8c065c0..93a70dcd0 100644 --- a/tests/client/handlers/keys.test.ts +++ b/tests/client/handlers/keys.test.ts @@ -1,6 +1,6 @@ -import type { TLSConfig } from '@/network/types'; import type GestaltGraph from '@/gestalts/GestaltGraph'; import type Sigchain from '@/sigchain/Sigchain'; +import type { TLSConfig } from '@/network/types'; import type { CertificatePEM } from '@/keys/types'; import fs from 'fs'; import path from 'path'; @@ -9,42 +9,43 @@ import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger'; import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; +import PolykeyAgent from '@/PolykeyAgent'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; -import { KeysCertsChainGetHandler } from '@/client/handlers/keysCertsChainGet'; -import IdentitiesManager from '@/identities/IdentitiesManager'; import CertManager from '@/keys/CertManager'; import TaskManager from '@/tasks/TaskManager'; +import NodeManager from '@/nodes/NodeManager'; +import IdentitiesManager from '@/identities/IdentitiesManager'; +import ClientService from '@/client/ClientService'; +import { + KeysCertsChainGet, + KeysCertsGet, + KeysDecrypt, + KeysEncrypt, + KeysKeyPair, + KeysKeyPairRenew, + KeysKeyPairReset, + KeysPasswordChange, + KeysPublicKey, + KeysSign, + KeysVerify, +} from '@/client/handlers'; import { keysCertsChainGet, keysCertsGet, - KeysCertsGetHandler, keysDecrypt, - KeysDecryptHandler, keysEncrypt, - KeysEncryptHandler, keysKeyPair, - KeysKeyPairHandler, keysKeyPairRenew, - KeysKeyPairRenewHandler, keysKeyPairReset, - KeysKeyPairResethandler, keysPasswordChange, - KeysPasswordChangeHandler, keysPublicKey, - KeysPublicKeyHandler, keysSign, - KeysSignHandler, keysVerify, - KeysVerifyHandler, -} from '@/client'; -import PolykeyAgent from '@/PolykeyAgent'; -import { NodeManager } from '@/nodes'; -import { publicKeyToJWK } from '@/keys/utils'; -import ClientService from '@/client/ClientService'; -import { sleep } from '@/utils'; +} from '@/client/callers'; +import * as keysUtils from '@/keys/utils'; import * as keysEvents from '@/keys/events'; import * as networkUtils from '@/network/utils'; +import * as utils from '@/utils'; import * as testsUtils from '../../utils'; describe('keysCertsChainGet', () => { @@ -61,12 +62,14 @@ describe('keysCertsChainGet', () => { let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysCertsChainGet: typeof keysCertsChainGet; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; let taskManager: TaskManager; let certManager: CertManager; let mockedGetRootCertChainPems: jest.SpyInstance; - beforeEach(async () => { mockedGetRootCertChainPems = jest .spyOn(CertManager.prototype, 'getCertPEMsChain') @@ -108,53 +111,50 @@ describe('keysCertsChainGet', () => { taskManager, logger, }); - }); - afterEach(async () => { - mockedGetRootCertChainPems.mockRestore(); - await certManager.stop(); - await taskManager.stop(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets the root certchain', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysCertsChainGet: new KeysCertsChainGetHandler({ + keysCertsChainGet: new KeysCertsChainGet({ certManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysCertsChainGet, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedGetRootCertChainPems.mockRestore(); + await certManager.stop(); + await taskManager.stop(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets the root certchain', async () => { const response = await rpcClient.methods.keysCertsChainGet({}); const output = Array(); for await (const cert of response) { @@ -176,12 +176,14 @@ describe('keysCertsGet', () => { let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysCertsGet: typeof keysCertsGet; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; let taskManager: TaskManager; let certManager: CertManager; let mockedGetRootCertPem: jest.SpyInstance; - beforeEach(async () => { mockedGetRootCertPem = jest .spyOn(CertManager.prototype, 'getCurrentCertPEM') @@ -223,58 +225,55 @@ describe('keysCertsGet', () => { taskManager, logger, }); - }); - afterEach(async () => { - mockedGetRootCertPem.mockRestore(); - await certManager.stop(); - await taskManager.stop(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets the root certificate', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysCertsGet: new KeysCertsGetHandler({ + keysCertsGet: new KeysCertsGet({ certManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysCertsGet, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedGetRootCertPem.mockRestore(); + await certManager.stop(); + await taskManager.stop(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets the root certificate', async () => { const response = await rpcClient.methods.keysCertsGet({}); expect(response.cert).toBe('rootCertPem'); }); }); -describe('keysEncryptDecrypt', () => { +describe('keysEncrypt and keysDecrypt', () => { const logger = new Logger('keysEncryptDecrypt test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -287,9 +286,12 @@ describe('keysEncryptDecrypt', () => { let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysEncrypt: typeof keysEncrypt; + keysDecrypt: typeof keysDecrypt; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -318,54 +320,51 @@ describe('keysEncryptDecrypt', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('encrypts and decrypts data', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysEncrypt: new KeysEncryptHandler({ + keysEncrypt: new KeysEncrypt({ keyRing, }), - keysDecrypt: new KeysDecryptHandler({ + keysDecrypt: new KeysDecrypt({ keyRing, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysEncrypt, keysDecrypt, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('encrypts and decrypts data', async () => { const plainText = Buffer.from('abc'); const publicKeyJWK = keysUtils.publicKeyToJWK(keyRing.keyPair.publicKey); const encrypted = await rpcClient.methods.keysEncrypt({ @@ -387,11 +386,13 @@ describe('keysKeyPair', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + keysKeyPair: typeof keysKeyPair; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -420,31 +421,17 @@ describe('keysKeyPair', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets the keypair', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysKeyPair: new KeysKeyPairHandler({ + keysKeyPair: new KeysKeyPair({ keyRing, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { @@ -454,7 +441,7 @@ describe('keysKeyPair', () => { logger: logger.getChild('client'), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysKeyPair, }, @@ -462,8 +449,19 @@ describe('keysKeyPair', () => { toError: networkUtils.toError, logger: logger.getChild('clientRPC'), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets the keypair', async () => { const response = await rpcClient.methods.keysKeyPair({ password: 'password', }); @@ -493,11 +491,13 @@ describe('keysKeyPairRenew', () => { const localhost = '127.0.0.1'; let dataDir: string; let pkAgent: PolykeyAgent; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + keysKeyPairRenew: typeof keysKeyPairRenew; + }>; let mockedRefreshBuckets: jest.SpyInstance; - beforeEach(async () => { mockedRefreshBuckets = jest.spyOn(NodeManager.prototype, 'resetBuckets'); dataDir = await fs.promises.mkdtemp( @@ -519,49 +519,46 @@ describe('keysKeyPairRenew', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(pkAgent.keyRing.keyPair); - }); - afterEach(async () => { - mockedRefreshBuckets.mockRestore(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await pkAgent.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('renews the root key pair', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysKeyPairRenew: new KeysKeyPairRenewHandler({ + keysKeyPairRenew: new KeysKeyPairRenew({ certManager: pkAgent.certManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysKeyPairRenew, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedRefreshBuckets.mockRestore(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await pkAgent.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('renews the root key pair', async () => { const rootKeyPair1 = pkAgent.keyRing.keyPair; const nodeId1 = pkAgent.keyRing.getNodeId(); // @ts-ignore - get protected property @@ -589,7 +586,7 @@ describe('keysKeyPairRenew', () => { // Awaiting change to propagate await certChangeEventProm.p; // Wait some time after event for domains to update - await sleep(500); + await utils.sleep(500); const rootKeyPair2 = pkAgent.keyRing.keyPair; const nodeId2 = pkAgent.keyRing.getNodeId(); // @ts-ignore - get protected property @@ -623,10 +620,12 @@ describe('keysKeyPairReset', () => { let dataDir: string; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysKeyPairReset: typeof keysKeyPairReset; + }>; let pkAgent: PolykeyAgent; let tlsConfig: TLSConfig; let mockedRefreshBuckets: jest.SpyInstance; - beforeEach(async () => { mockedRefreshBuckets = jest.spyOn(NodeManager.prototype, 'resetBuckets'); dataDir = await fs.promises.mkdtemp( @@ -648,49 +647,46 @@ describe('keysKeyPairReset', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(pkAgent.keyRing.keyPair); - }); - afterEach(async () => { - mockedRefreshBuckets.mockRestore(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await pkAgent.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('resets the root key pair', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysKeyPairReset: new KeysKeyPairResethandler({ + keysKeyPairReset: new KeysKeyPairReset({ certManager: pkAgent.certManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysKeyPairReset, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedRefreshBuckets.mockRestore(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await pkAgent.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('resets the root key pair', async () => { const rootKeyPair1 = pkAgent.keyRing.keyPair; const nodeId1 = pkAgent.keyRing.getNodeId(); // @ts-ignore - get protected property @@ -718,7 +714,7 @@ describe('keysKeyPairReset', () => { // Awaiting change to propagate await certChangeEventProm.p; // Wait some time after event for domains to update - await sleep(500); + await utils.sleep(500); const rootKeyPair2 = pkAgent.keyRing.keyPair; const nodeId2 = pkAgent.keyRing.getNodeId(); // @ts-ignore - get protected property @@ -752,11 +748,13 @@ describe('keysPasswordChange', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + keysPasswordChange: typeof keysPasswordChange; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -785,50 +783,47 @@ describe('keysPasswordChange', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('changes the password', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysPasswordChange: new KeysPasswordChangeHandler({ + keysPasswordChange: new KeysPasswordChange({ keyRing, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysPasswordChange, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('changes the password', async () => { await rpcClient.methods.keysPasswordChange({ password: 'newpassword', }); @@ -851,9 +846,11 @@ describe('keysPublicKey', () => { let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysPublicKey: typeof keysPublicKey; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -882,50 +879,47 @@ describe('keysPublicKey', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('gets the public key', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysPublicKey: new KeysPublicKeyHandler({ + keysPublicKey: new KeysPublicKey({ keyRing, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysPublicKey, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('gets the public key', async () => { const response = await rpcClient.methods.keysPublicKey({}); expect(response.publicKeyJwk).toEqual({ alg: expect.any(String), @@ -937,7 +931,7 @@ describe('keysPublicKey', () => { }); }); }); -describe('keysSignVerify', () => { +describe('keysSign and keysVerify', () => { const logger = new Logger('keysSignVerify test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -950,9 +944,12 @@ describe('keysSignVerify', () => { let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; + let rpcClient: RPCClient<{ + keysSign: typeof keysSign; + keysVerify: typeof keysVerify; + }>; let tlsConfig: TLSConfig; let identitiesManager: IdentitiesManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -981,59 +978,56 @@ describe('keysSignVerify', () => { logger, }); tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); - }); - afterEach(async () => { - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await identitiesManager.stop(); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('signs and verifies with root keypair', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - keysSign: new KeysSignHandler({ + keysSign: new KeysSign({ keyRing, }), - keysVerify: new KeysVerifyHandler({ + keysVerify: new KeysVerify({ keyRing, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { keysSign, keysVerify, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await identitiesManager.stop(); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('signs and verifies with root keypair', async () => { const data = Buffer.from('abc'); const signed = await rpcClient.methods.keysSign({ data: data.toString('binary'), }); - const publicKeyJWK = publicKeyToJWK(keyRing.keyPair.publicKey); + const publicKeyJWK = keysUtils.publicKeyToJWK(keyRing.keyPair.publicKey); const response = await rpcClient.methods.keysVerify({ data: data.toString('binary'), signature: signed.signature, diff --git a/tests/client/handlers/nodes.test.ts b/tests/client/handlers/nodes.test.ts index ebca51194..3cea8aa98 100644 --- a/tests/client/handlers/nodes.test.ts +++ b/tests/client/handlers/nodes.test.ts @@ -1,7 +1,6 @@ -import type { TLSConfig } from '@/network/types'; import type GestaltGraph from '@/gestalts/GestaltGraph'; import type { NodeIdEncoded } from '@/ids/types'; -import type { Host, Port } from '@/network/types'; +import type { TLSConfig, Host, Port } from '@/network/types'; import type { Notification } from '@/notifications/types'; import fs from 'fs'; import path from 'path'; @@ -10,31 +9,22 @@ import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger'; import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; +import ACL from '@/acl/ACL'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; -import { NodesAddHandler } from '@/client/handlers/nodesAdd'; -import * as nodesUtils from '@/nodes/utils'; -import * as networkUtils from '@/network/utils'; import NodeManager from '@/nodes/NodeManager'; import NodeGraph from '@/nodes/NodeGraph'; -import NodeConnectionManager from '@/nodes/NodeConnectionManager'; -import * as validationErrors from '@/validation/errors'; -import { - nodesAdd, - nodesClaim, - NodesClaimHandler, - nodesFind, - NodesFindHandler, - nodesPing, - NodesPingHandler, -} from '@/client'; -import ClientService from '@/client/ClientService'; import TaskManager from '@/tasks/TaskManager'; import Sigchain from '@/sigchain/Sigchain'; import NotificationsManager from '@/notifications/NotificationsManager'; -import ACL from '@/acl/ACL'; -import * as tlsTestsUtils from '../../utils/tls'; -import * as testsUtils from '../../utils/utils'; +import NodeConnectionManager from '@/nodes/NodeConnectionManager'; +import ClientService from '@/client/ClientService'; +import { NodesAdd, NodesClaim, NodesFind, NodesPing } from '@/client/handlers'; +import { nodesAdd, nodesClaim, nodesFind, nodesPing } from '@/client/callers'; +import * as keysUtils from '@/keys/utils'; +import * as nodesUtils from '@/nodes/utils'; +import * as networkUtils from '@/network/utils'; +import * as validationErrors from '@/validation/errors'; +import * as testsUtils from '../../utils'; describe('nodesAdd', () => { const logger = new Logger('nodesAdd test', LogLevel.WARN, [ @@ -47,15 +37,17 @@ describe('nodesAdd', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + nodesAdd: typeof nodesAdd; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; let nodeManager: NodeManager; let sigchain: Sigchain; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -76,7 +68,7 @@ describe('nodesAdd', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); sigchain = await Sigchain.createSigchain({ db, keyRing, @@ -116,58 +108,55 @@ describe('nodesAdd', () => { await nodeManager.start(); await nodeConnectionManager.start({ host: localhost as Host }); await taskManager.startProcessing(); - }); - afterEach(async () => { - await taskManager.stopProcessing(); - await taskManager.stopTasks(); - await nodeGraph.stop(); - await nodeConnectionManager.stop(); - await nodeManager.stop(); - await sigchain.stop(); - await db.stop(); - await keyRing.stop(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await keyRing.stop(); - await db.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('adds a node', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - nodesAdd: new NodesAddHandler({ + nodesAdd: new NodesAdd({ db, nodeManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { nodesAdd, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await taskManager.stopProcessing(); + await taskManager.stopTasks(); + await nodeGraph.stop(); + await nodeConnectionManager.stop(); + await nodeManager.stop(); + await sigchain.stop(); + await db.stop(); + await keyRing.stop(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await keyRing.stop(); + await db.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('adds a node', async () => { await rpcClient.methods.nodesAdd({ nodeIdEncoded: 'vrsc24a1er424epq77dtoveo93meij0pc8ig4uvs9jbeld78n9nl0' as NodeIdEncoded, @@ -185,39 +174,6 @@ describe('nodesAdd', () => { expect(result!.address).toEqual({ host: '127.0.0.1', port: 11111 }); }); test('cannot add invalid node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesAdd: new NodesAddHandler({ - db, - nodeManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesAdd, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test - // Invalid host await testsUtils.expectRemoteError( rpcClient.methods.nodesAdd({ @@ -275,9 +231,12 @@ describe('nodesClaim', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + nodesClaim: typeof nodesClaim; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; @@ -288,7 +247,6 @@ describe('nodesClaim', () => { let mockedFindGestaltInvite: jest.SpyInstance; let mockedSendNotification: jest.SpyInstance; let mockedClaimNode: jest.SpyInstance; - beforeEach(async () => { mockedFindGestaltInvite = jest .spyOn(NotificationsManager.prototype, 'findGestaltInvite') @@ -319,7 +277,7 @@ describe('nodesClaim', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); acl = await ACL.createACL({ db, @@ -373,6 +331,35 @@ describe('nodesClaim', () => { keyRing, logger, }); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + nodesClaim: new NodesClaim({ + db, + nodeManager, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + nodesClaim, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { mockedFindGestaltInvite.mockRestore(); @@ -397,38 +384,6 @@ describe('nodesClaim', () => { }); }); test('claims a node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesClaim: new NodesClaimHandler({ - db, - nodeManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesClaim, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const response = await rpcClient.methods.nodesClaim({ nodeIdEncoded: 'vrsc24a1er424epq77dtoveo93meij0pc8ig4uvs9jbeld78n9nl0' as NodeIdEncoded, @@ -437,38 +392,6 @@ describe('nodesClaim', () => { expect(response.success).toBeTruthy(); }); test('cannot claim an invalid node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesClaim: new NodesClaimHandler({ - db, - nodeManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesClaim, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await testsUtils.expectRemoteError( rpcClient.methods.nodesClaim({ nodeIdEncoded: 'nodeId' as NodeIdEncoded, @@ -488,15 +411,17 @@ describe('nodesFind', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + nodesFind: typeof nodesFind; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; let sigchain: Sigchain; let mockedFindNode: jest.SpyInstance; - beforeEach(async () => { mockedFindNode = jest .spyOn(NodeConnectionManager.prototype, 'findNode') @@ -523,7 +448,7 @@ describe('nodesFind', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); sigchain = await Sigchain.createSigchain({ db, keyRing, @@ -552,56 +477,53 @@ describe('nodesFind', () => { }); await nodeConnectionManager.start({ host: localhost as Host }); await taskManager.startProcessing(); - }); - afterEach(async () => { - mockedFindNode.mockRestore(); - await taskManager.stopProcessing(); - await taskManager.stopTasks(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await sigchain.stop(); - await nodeGraph.stop(); - await nodeConnectionManager.stop(); - await db.stop(); - await keyRing.stop(); - await taskManager.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('finds a node', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - nodesFind: new NodesFindHandler({ + nodesFind: new NodesFind({ nodeConnectionManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { nodesFind, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedFindNode.mockRestore(); + await taskManager.stopProcessing(); + await taskManager.stopTasks(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await sigchain.stop(); + await nodeGraph.stop(); + await nodeConnectionManager.stop(); + await db.stop(); + await keyRing.stop(); + await taskManager.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('finds a node', async () => { const response = await rpcClient.methods.nodesFind({ nodeIdEncoded: 'vrsc24a1er424epq77dtoveo93meij0pc8ig4uvs9jbeld78n9nl0' as NodeIdEncoded, @@ -610,37 +532,6 @@ describe('nodesFind', () => { expect(response.port).toBe(11111); }); test('cannot find an invalid node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesFind: new NodesFindHandler({ - nodeConnectionManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesFind, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await testsUtils.expectRemoteError( rpcClient.methods.nodesFind({ nodeIdEncoded: 'nodeId' as NodeIdEncoded, @@ -660,16 +551,18 @@ describe('nodesPing', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + nodesPing: typeof nodesPing; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; let nodeManager: NodeManager; let sigchain: Sigchain; let mockedPingNode: jest.SpyInstance; - beforeEach(async () => { mockedPingNode = jest.spyOn(NodeManager.prototype, 'pingNode'); dataDir = await fs.promises.mkdtemp( @@ -686,7 +579,7 @@ describe('nodesPing', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -730,56 +623,53 @@ describe('nodesPing', () => { }); await nodeConnectionManager.start({ host: localhost as Host }); await taskManager.startProcessing(); - }); - afterEach(async () => { - mockedPingNode.mockRestore(); - await taskManager.stopProcessing(); - await taskManager.stopTasks(); - await clientService.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await sigchain.stop(); - await nodeGraph.stop(); - await nodeConnectionManager.stop(); - await db.stop(); - await keyRing.stop(); - await taskManager.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('pings a node (offline)', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - nodesPing: new NodesPingHandler({ + nodesPing: new NodesPing({ nodeManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { nodesPing, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedPingNode.mockRestore(); + await taskManager.stopProcessing(); + await taskManager.stopTasks(); + await clientService.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await sigchain.stop(); + await nodeGraph.stop(); + await nodeConnectionManager.stop(); + await db.stop(); + await keyRing.stop(); + await taskManager.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('pings a node (offline)', async () => { mockedPingNode.mockResolvedValue(false); const response = await rpcClient.methods.nodesPing({ nodeIdEncoded: @@ -788,37 +678,6 @@ describe('nodesPing', () => { expect(response.success).toBeFalsy(); }); test('pings a node (online)', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesPing: new NodesPingHandler({ - nodeManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesPing, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedPingNode.mockResolvedValue(true); const response = await rpcClient.methods.nodesPing({ nodeIdEncoded: @@ -827,37 +686,6 @@ describe('nodesPing', () => { expect(response.success).toBeTruthy(); }); test('cannot ping an invalid node', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - nodesPing: new NodesPingHandler({ - nodeManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - nodesPing, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await testsUtils.expectRemoteError( rpcClient.methods.nodesPing({ nodeIdEncoded: 'nodeId' as NodeIdEncoded, diff --git a/tests/client/handlers/notifications.test.ts b/tests/client/handlers/notifications.test.ts index 6239d8a10..3efac49c3 100644 --- a/tests/client/handlers/notifications.test.ts +++ b/tests/client/handlers/notifications.test.ts @@ -1,9 +1,8 @@ -import type { Host, TLSConfig } from '@/network/types'; import type GestaltGraph from '@/gestalts/GestaltGraph'; +import type { Host, TLSConfig } from '@/network/types'; import type { General, Notification, VaultShare } from '@/notifications/types'; -import type { VaultIdEncoded } from '@/ids/types'; +import type { VaultIdEncoded, NodeIdEncoded } from '@/ids/types'; import type { VaultName } from '@/vaults/types'; -import type { NodeIdEncoded } from '@/ids/types'; import fs from 'fs'; import path from 'path'; import os from 'os'; @@ -12,17 +11,7 @@ import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; -import { NotificationsClearHandler } from '@/client/handlers/notificationsClear'; -import { - notificationsClear, - notificationsRead, - NotificationsReadHandler, - notificationsSend, - NotificationsSendHandler, -} from '@/client'; import ClientService from '@/client/ClientService'; -import * as nodesUtils from '@/nodes/utils'; import ACL from '@/acl/ACL'; import Sigchain from '@/sigchain/Sigchain'; import NodeGraph from '@/nodes/NodeGraph'; @@ -30,9 +19,21 @@ import TaskManager from '@/tasks/TaskManager'; import NodeConnectionManager from '@/nodes/NodeConnectionManager'; import NodeManager from '@/nodes/NodeManager'; import NotificationsManager from '@/notifications/NotificationsManager'; +import { + NotificationsClear, + NotificationsRead, + NotificationsSend, +} from '@/client/handlers'; +import { + notificationsClear, + notificationsRead, + notificationsSend, +} from '@/client/callers'; +import * as nodesUtils from '@/nodes/utils'; +import * as keysUtils from '@/keys/utils'; import * as networkUtils from '@/network/utils'; -import * as tlsTestsUtils from '../../utils/tls'; -import * as testNodesUtils from '../../nodes/utils'; +import * as testsNodesUtils from '../../nodes/utils'; +import * as testsUtils from '../../utils'; describe('notificationsClear', () => { const logger = new Logger('notificationsClear test', LogLevel.WARN, [ @@ -45,9 +46,12 @@ describe('notificationsClear', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + notificationsClear: typeof notificationsClear; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; @@ -56,7 +60,6 @@ describe('notificationsClear', () => { let acl: ACL; let sigchain: Sigchain; let mockedClearNotifications: jest.SpyInstance; - beforeEach(async () => { mockedClearNotifications = jest .spyOn(NotificationsManager.prototype, 'clearNotifications') @@ -75,7 +78,7 @@ describe('notificationsClear', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -133,6 +136,35 @@ describe('notificationsClear', () => { keyRing, logger, }); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + notificationsClear: new NotificationsClear({ + db, + notificationsManager, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + notificationsClear, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { mockedClearNotifications.mockRestore(); @@ -154,39 +186,6 @@ describe('notificationsClear', () => { }); }); test('puts/deletes/gets tokens', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsClear: new NotificationsClearHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsClear, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test await rpcClient.methods.notificationsClear({}); expect(mockedClearNotifications.mock.calls.length).toBe(1); }); @@ -199,15 +198,18 @@ describe('notificationsRead', () => { ]); const password = 'helloWorld'; const localhost = '127.0.0.1'; - const nodeIdSender = testNodesUtils.generateRandomNodeId(); + const nodeIdSender = testsNodesUtils.generateRandomNodeId(); const nodeIdSenderEncoded = nodesUtils.encodeNodeId(nodeIdSender); const nodeIdReceiverEncoded = 'test'; let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + notificationsRead: typeof notificationsRead; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; @@ -216,7 +218,6 @@ describe('notificationsRead', () => { let acl: ACL; let sigchain: Sigchain; let mockedReadNotifications: jest.SpyInstance; - beforeEach(async () => { mockedReadNotifications = jest.spyOn( NotificationsManager.prototype, @@ -236,7 +237,7 @@ describe('notificationsRead', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -294,6 +295,35 @@ describe('notificationsRead', () => { keyRing, logger, }); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + notificationsRead: new NotificationsRead({ + db, + notificationsManager, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + notificationsRead, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { mockedReadNotifications.mockRestore(); @@ -316,38 +346,6 @@ describe('notificationsRead', () => { }); }); test('reads a single notification', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([ { typ: 'notification', @@ -383,38 +381,6 @@ describe('notificationsRead', () => { expect(mockedReadNotifications.mock.calls[0][0].order).toBe('newest'); }); test('reads unread notifications', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([ { typ: 'notification', @@ -467,38 +433,6 @@ describe('notificationsRead', () => { expect(mockedReadNotifications.mock.calls[0][0].order).toBe('newest'); }); test('reads notifications in reverse order', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([ { typ: 'notification', @@ -551,38 +485,6 @@ describe('notificationsRead', () => { expect(mockedReadNotifications.mock.calls[0][0].order).toBe('oldest'); }); test('reads gestalt invite notifications', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([ { typ: 'notification', @@ -615,38 +517,6 @@ describe('notificationsRead', () => { expect(mockedReadNotifications.mock.calls[0][0].order).toBe('newest'); }); test('reads vault share notifications', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([ { typ: 'notification', @@ -692,38 +562,6 @@ describe('notificationsRead', () => { expect(mockedReadNotifications.mock.calls[0][0].order).toBe('newest'); }); test('reads no notifications', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsRead: new NotificationsReadHandler({ - db, - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsRead, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedReadNotifications.mockResolvedValueOnce([]); const response = await rpcClient.methods.notificationsRead({ unread: false, @@ -752,9 +590,12 @@ describe('notificationsSend', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + notificationsSend: typeof notificationsSend; + }>; let nodeGraph: NodeGraph; let taskManager: TaskManager; let nodeConnectionManager: NodeConnectionManager; @@ -763,7 +604,6 @@ describe('notificationsSend', () => { let acl: ACL; let sigchain: Sigchain; let mockedSendNotification: jest.SpyInstance; - beforeEach(async () => { mockedSendNotification = jest.spyOn( NodeConnectionManager.prototype, @@ -783,7 +623,7 @@ describe('notificationsSend', () => { }, logger, }); - tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair); + tlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -840,6 +680,34 @@ describe('notificationsSend', () => { keyRing, logger, }); + clientService = new ClientService({ + tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ + manifest: { + notificationsSend: new NotificationsSend({ + notificationsManager, + }), + }, + host: localhost, + }); + webSocketClient = await WebSocketClient.createWebSocketClient({ + config: { + verifyPeer: false, + }, + host: localhost, + logger: logger.getChild(WebSocketClient.name), + port: clientService.port, + }); + rpcClient = new RPCClient({ + manifest: { + notificationsSend, + }, + streamFactory: () => webSocketClient.connection.newStream(), + toError: networkUtils.toError, + logger: logger.getChild(RPCClient.name), + }); }); afterEach(async () => { mockedSendNotification.mockRestore(); @@ -862,37 +730,6 @@ describe('notificationsSend', () => { }); }); test('sends a notification', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - notificationsSend: new NotificationsSendHandler({ - notificationsManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - notificationsSend, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test mockedSendNotification.mockImplementation(); const receiverNodeIdEncoded = 'vrsc24a1er424epq77dtoveo93meij0pc8ig4uvs9jbeld78n9nl0' as NodeIdEncoded; diff --git a/tests/client/handlers/vaults.test.ts b/tests/client/handlers/vaults.test.ts index 333947ba0..22ed427f2 100644 --- a/tests/client/handlers/vaults.test.ts +++ b/tests/client/handlers/vaults.test.ts @@ -1,13 +1,13 @@ import type NodeConnectionManager from '@/nodes/NodeConnectionManager'; import type { TLSConfig } from '@/network/types'; import type { FileSystem } from '@/types'; +import type { VaultId } from '@/ids'; +import type NodeManager from '@/nodes/NodeManager'; import type { LogEntryMessage, VaultListMessage, VaultPermissionMessage, -} from '@/client/handlers/types'; -import type { VaultId } from '@/ids'; -import type NodeManager from '@/nodes/NodeManager'; +} from '@/client/types'; import fs from 'fs'; import path from 'path'; import os from 'os'; @@ -15,51 +15,53 @@ import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger'; import { DB } from '@matrixai/db'; import { RPCClient } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; -import VaultManager from '@/vaults/VaultManager'; +import ACL from '@/acl/ACL'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; +import VaultManager from '@/vaults/VaultManager'; import GestaltGraph from '@/gestalts/GestaltGraph'; import NotificationsManager from '@/notifications/NotificationsManager'; -import ACL from '@/acl/ACL'; +import ClientService from '@/client/ClientService'; +import { + VaultsCreate, + VaultsDelete, + VaultsList, + VaultsLog, + VaultsPermissionGet, + VaultsPermissionSet, + VaultsPermissionUnset, + VaultsRename, + VaultsSecretsDelete, + VaultsSecretsEdit, + VaultsSecretsGet, + VaultsSecretsList, + VaultsSecretsMkdir, + VaultsSecretsNewDir, + VaultsSecretsNew, + VaultsSecretsRename, + VaultsSecretsStat, + VaultsVersion, +} from '@/client/handlers'; import { vaultsCreate, - VaultsCreateHandler, vaultsDelete, - VaultsDeleteHandler, vaultsList, - VaultsListHandler, vaultsLog, - VaultsLogHandler, vaultsPermissionGet, - VaultsPermissionGetHandler, vaultsPermissionSet, - VaultsPermissionSetHandler, vaultsPermissionUnset, - VaultsPermissionUnsetHandler, vaultsRename, - VaultsRenameHandler, vaultsSecretsDelete, - VaultsSecretsDeleteHandler, vaultsSecretsEdit, - VaultsSecretsEditHandler, vaultsSecretsGet, - VaultsSecretsGetHandler, vaultsSecretsList, - VaultsSecretsListHandler, vaultsSecretsMkdir, - VaultsSecretsMkdirHandler, vaultsSecretsNew, vaultsSecretsNewDir, - VaultsSecretsNewDirHandler, - VaultsSecretsNewHandler, vaultsSecretsRename, - VaultsSecretsRenameHandler, vaultsSecretsStat, - VaultsSecretsStatHandler, vaultsVersion, - VaultsVersionHandler, -} from '@/client'; -import ClientService from '@/client/ClientService'; +} from '@/client/callers'; +import * as keysUtils from '@/keys/utils'; import * as nodesUtils from '@/nodes/utils'; import * as vaultsUtils from '@/vaults/utils'; import * as vaultsErrors from '@/vaults/errors'; @@ -73,15 +75,12 @@ describe('vaultsClone', () => { ), ]); const password = 'helloWorld'; - // Const host = '127.0.0.1'; let dataDir: string; let db: DB; let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; - // Let tlsConfig: TLSConfig; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -126,43 +125,9 @@ describe('vaultsClone', () => { recursive: true, }); }); - // TODO: implement this test? Pending agent migration stage 2. - test.todo('clones a vault'); // , async () => { - // // Setup - // const rpcServer = await RPCServer.createRPCServer({ - // manifest: { - // notificationsSend: new NotificationsSendHandler({ - // notificationsManager, - // }), - // }, - // logger, - // }); - // webSocketServer = await WebSocketServer.createWebSocketServer({ - // connectionCallback: (streamPair) => - // rpcServer.handleStream(streamPair), - // host, - // tlsConfig, - // logger: logger.getChild('server'), - // }); - // webSocketClient = await WebSocketClient.createWebSocketClient({ - // expectedNodeIds: [keyRing.getNodeId()], - // host, - // logger: logger.getChild('client'), - // port: webSocketServer.port, - // }); - // const rpcClient = new RPCClient({ - // manifest: { - // notificationsSend, - // }, - // streamFactory: () => webSocketClient.connection.newStream(), - // logger: logger.getChild('clientRPC'), - // }); - // - // // Doing the test - // - // }); + test.todo('clones a vault'); }); -describe('vaultsCreateDeleteList', () => { +describe('vaultsCreate and vaultsDelete and vaultsList', () => { const logger = new Logger('vaultsCreateDeleteList test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -173,11 +138,15 @@ describe('vaultsCreateDeleteList', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsCreate: typeof vaultsCreate; + vaultsDelete: typeof vaultsDelete; + vaultsList: typeof vaultsList; + }>; let tlsConfig: TLSConfig; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -210,40 +179,26 @@ describe('vaultsCreateDeleteList', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('creates, lists, and deletes vaults', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsCreate: new VaultsCreateHandler({ + vaultsCreate: new VaultsCreate({ vaultManager, db, }), - vaultsDelete: new VaultsDeleteHandler({ + vaultsDelete: new VaultsDelete({ vaultManager, db, }), - vaultsList: new VaultsListHandler({ + vaultsList: new VaultsList({ vaultManager, db, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { @@ -251,10 +206,10 @@ describe('vaultsCreateDeleteList', () => { }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsCreate, vaultsDelete, @@ -262,10 +217,21 @@ describe('vaultsCreateDeleteList', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('creates, lists, and deletes vaults', async () => { // Create vault const createResponse = await rpcClient.methods.vaultsCreate({ vaultName: 'test-vault', @@ -304,11 +270,13 @@ describe('vaultsLog', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsLog: typeof vaultsLog; + }>; let vaultManager: VaultManager; - const vaultName = 'test-vault'; const secret1 = { name: 'secret1', content: 'Secret-1-content' }; const secret2 = { name: 'secret2', content: 'Secret-2-content' }; @@ -316,7 +284,6 @@ describe('vaultsLog', () => { let commit1Oid: string; let commit2Oid: string; let commit3Oid: string; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -364,51 +331,48 @@ describe('vaultsLog', () => { }); commit3Oid = (await vault.log(undefined, 0))[0].commitId; }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('should get the full log', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsLog: new VaultsLogHandler({ + vaultsLog: new VaultsLog({ vaultManager, db, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsLog, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('should get the full log', async () => { const logStream = await rpcClient.methods.vaultsLog({ nameOrId: vaultName, }); @@ -422,38 +386,6 @@ describe('vaultsLog', () => { expect(logMessages[0].commitId).toEqual(commit3Oid); }); test('should get a part of the log', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - vaultsLog: new VaultsLogHandler({ - vaultManager, - db, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - vaultsLog, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const logStream = await rpcClient.methods.vaultsLog({ nameOrId: vaultName, depth: 2, @@ -467,38 +399,6 @@ describe('vaultsLog', () => { expect(logMessages[0].commitId).toEqual(commit3Oid); }); test('should get a specific commit', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - vaultsLog: new VaultsLogHandler({ - vaultManager, - db, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - vaultsLog, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test const logStream = await rpcClient.methods.vaultsLog({ nameOrId: vaultName, commitId: commit2Oid, @@ -511,7 +411,7 @@ describe('vaultsLog', () => { expect(logMessages[0].commitId).toEqual(commit2Oid); }); }); -describe('vaultsPermissionSetUnsetGet', () => { +describe('vaultsPermissionSet and vaultsPermissionUnset and vaultsPermissionGet', () => { const logger = new Logger('vaultsPermissionSetUnsetGet test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -523,15 +423,19 @@ describe('vaultsPermissionSetUnsetGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsPermissionSet: typeof vaultsPermissionSet; + vaultsPermissionUnset: typeof vaultsPermissionUnset; + vaultsPermissionGet: typeof vaultsPermissionGet; + }>; let vaultManager: VaultManager; let acl: ACL; let gestaltGraph: GestaltGraph; let notificationsManager: NotificationsManager; let mockedSendNotification: jest.SpyInstance; - beforeEach(async () => { mockedSendNotification = jest .spyOn(NotificationsManager.prototype, 'sendNotification') @@ -588,60 +492,42 @@ describe('vaultsPermissionSetUnsetGet', () => { notificationsManager, logger, }); - }); - afterEach(async () => { - mockedSendNotification.mockRestore(); - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await notificationsManager.stop(); - await gestaltGraph.stop(); - await acl.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('sets, gets, and unsets vault permissions', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsPermissionSet: new VaultsPermissionSetHandler({ + vaultsPermissionSet: new VaultsPermissionSet({ acl, db, gestaltGraph, notificationsManager, vaultManager, }), - vaultsPermissionGet: new VaultsPermissionGetHandler({ + vaultsPermissionGet: new VaultsPermissionGet({ acl, db, vaultManager, }), - vaultsPermissionUnset: new VaultsPermissionUnsetHandler({ + vaultsPermissionUnset: new VaultsPermissionUnset({ acl, db, gestaltGraph, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsPermissionSet, vaultsPermissionGet, @@ -649,10 +535,25 @@ describe('vaultsPermissionSetUnsetGet', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + mockedSendNotification.mockRestore(); + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await notificationsManager.stop(); + await gestaltGraph.stop(); + await acl.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('sets, gets, and unsets vault permissions', async () => { const nodeIdEncoded = nodesUtils.encodeNodeId(nodeId); const vaultName = 'test-vault'; await vaultManager.createVault(vaultName); @@ -705,19 +606,16 @@ describe('vaultsPull', () => { ), ]); const password = 'helloWorld'; - // Const host = '127.0.0.1'; const nodeId = testsUtils.generateRandomNodeId(); let dataDir: string; let db: DB; let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; - // Let tlsConfig: TLSConfig; let vaultManager: VaultManager; let acl: ACL; let gestaltGraph: GestaltGraph; let notificationsManager: NotificationsManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -733,7 +631,6 @@ describe('vaultsPull', () => { }, logger, }); - // TlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -786,57 +683,7 @@ describe('vaultsPull', () => { recursive: true, }); }); - test.todo('pulls from a vault'); // , async () => { - // // Setup - // const rpcServer = await RPCServer.createRPCServer({ - // manifest: { - // vaultsPermissionSet: new VaultsPermissionSetHandler({ - // acl, - // db, - // gestaltGraph, - // notificationsManager, - // vaultManager - // }), - // vaultsPermissionGet: new VaultsPermissionGetHandler({ - // acl, - // db, - // vaultManager - // }), - // vaultsPermissionUnset: new VaultsPermissionUnsetHandler({ - // acl, - // db, - // gestaltGraph, - // vaultManager - // }), - // }, - // logger, - // }); - // webSocketServer = await WebSocketServer.createWebSocketServer({ - // connectionCallback: (streamPair) => - // rpcServer.handleStream(streamPair), - // host, - // tlsConfig, - // logger: logger.getChild('server'), - // }); - // webSocketClient = await WebSocketClient.createWebSocketClient({ - // expectedNodeIds: [keyRing.getNodeId()], - // host, - // logger: logger.getChild('client'), - // port: webSocketServer.port, - // }); - // const rpcClient = new RPCClient({ - // manifest: { - // vaultsPermissionSet, - // vaultsPermissionGet, - // vaultsPermissionUnset, - // }, - // streamFactory: () => webSocketClient.connection.newStream(), - // logger: logger.getChild('clientRPC'), - // }); - // - // // Doing the test - // - // }); + test.todo('pulls from a vault'); }); describe('vaultsRename', () => { const logger = new Logger('vaultsRename test', LogLevel.WARN, [ @@ -849,11 +696,13 @@ describe('vaultsRename', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsRename: typeof vaultsRename; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -886,51 +735,48 @@ describe('vaultsRename', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('should rename vault', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsRename: new VaultsRenameHandler({ + vaultsRename: new VaultsRename({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsRename, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('should rename vault', async () => { const vaultId1 = await vaultManager.createVault('test-vault1'); const vaultId1Encoded = vaultsUtils.encodeVaultId(vaultId1); const vaultId2 = await rpcClient.methods.vaultsRename({ @@ -949,15 +795,12 @@ describe('vaultsScan', () => { ), ]); const password = 'helloWorld'; - // Const host = '127.0.0.1'; let dataDir: string; let db: DB; let keyRing: KeyRing; let webSocketClient: WebSocketClient; let clientService: ClientService; - // Let tlsConfig: TLSConfig; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -973,7 +816,6 @@ describe('vaultsScan', () => { }, logger, }); - // TlsConfig = await testsUtils.createTLSConfig(keyRing.keyPair); const dbPath = path.join(dataDir, 'db'); db = await DB.createDB({ dbPath, @@ -1002,52 +844,7 @@ describe('vaultsScan', () => { recursive: true, }); }); - test.todo('scans a vault'); // , async () => { - // // Setup - // const rpcServer = await RPCServer.createRPCServer({ - // manifest: { - // vaultsRename: new VaultsRenameHandler({ - // db, - // vaultManager, - // }), - // }, - // logger, - // }); - // webSocketServer = await WebSocketServer.createWebSocketServer({ - // connectionCallback: (streamPair) => - // rpcServer.handleStream(streamPair), - // host, - // tlsConfig, - // logger: logger.getChild('server'), - // }); - // webSocketClient = await WebSocketClient.createWebSocketClient({ - // expectedNodeIds: [keyRing.getNodeId()], - // host, - // logger: logger.getChild('client'), - // port: webSocketServer.port, - // }); - // const rpcClient = new RPCClient({ - // manifest: { - // vaultsRename, - // }, - // streamFactory: () => webSocketClient.connection.newStream(), - // logger: logger.getChild('clientRPC'), - // }); - // - // // Doing the test - // const vaultId1 = await vaultManager.createVault('test-vault1'); - // const vaultId1Encoded = vaultsUtils.encodeVaultId(vaultId1); - // const vaultId2 = await rpcClient.methods.vaultsRename({ - // nameOrId: vaultId1Encoded, - // newName: 'test-vault2', - // }, - // ); - // expect(vaultId2.vaultIdEncoded).toEqual( - // vaultId1Encoded, - // ); - // const renamedVaultId = await vaultManager.getVaultId('test-vault2'); - // expect(renamedVaultId).toStrictEqual(vaultId1); - // }); + test.todo('scans a vault'); }); describe('vaultsSecretsEdit', () => { const logger = new Logger('vaultsSecretsEdit test', LogLevel.WARN, [ @@ -1060,11 +857,13 @@ describe('vaultsSecretsEdit', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsEdit: typeof vaultsSecretsEdit; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1097,51 +896,48 @@ describe('vaultsSecretsEdit', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('edits secrets', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsEdit: new VaultsSecretsEditHandler({ + vaultsSecretsEdit: new VaultsSecretsEdit({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsEdit, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('edits secrets', async () => { const vaultName = 'test-vault'; const secretName = 'test-secret'; const vaultId = await vaultManager.createVault(vaultName); @@ -1176,11 +972,13 @@ describe('vaultsSecretsMkdir', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsMkdir: typeof vaultsSecretsMkdir; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1213,51 +1011,48 @@ describe('vaultsSecretsMkdir', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('makes a directory', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsMkdir: new VaultsSecretsMkdirHandler({ + vaultsSecretsMkdir: new VaultsSecretsMkdir({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsMkdir, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('makes a directory', async () => { const vaultName = 'test-vault'; const vaultId = await vaultManager.createVault(vaultName); const dirPath = 'dir/dir1/dir2'; @@ -1274,7 +1069,7 @@ describe('vaultsSecretsMkdir', () => { }); }); }); -describe('vaultsSecretsNewDeleteGet', () => { +describe('vaultsSecretsNew and vaultsSecretsDelete, vaultsSecretsGet', () => { Error.stackTraceLimit = 100; const logger = new Logger('vaultsSecretsNewDeleteGet test', LogLevel.WARN, [ new StreamHandler( @@ -1286,11 +1081,15 @@ describe('vaultsSecretsNewDeleteGet', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsNew: typeof vaultsSecretsNew; + vaultsSecretsDelete: typeof vaultsSecretsDelete; + vaultsSecretsGet: typeof vaultsSecretsGet; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1323,50 +1122,36 @@ describe('vaultsSecretsNewDeleteGet', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('creates, gets, and deletes secrets', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsNew: new VaultsSecretsNewHandler({ + vaultsSecretsNew: new VaultsSecretsNew({ db, vaultManager, }), - vaultsSecretsDelete: new VaultsSecretsDeleteHandler({ + vaultsSecretsDelete: new VaultsSecretsDelete({ db, vaultManager, }), - vaultsSecretsGet: new VaultsSecretsGetHandler({ + vaultsSecretsGet: new VaultsSecretsGet({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsNew, vaultsSecretsDelete, @@ -1374,10 +1159,21 @@ describe('vaultsSecretsNewDeleteGet', () => { }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('creates, gets, and deletes secrets', async () => { // Create secret const secret = 'test-secret'; const vaultId = await vaultManager.createVault('test-vault'); @@ -1411,7 +1207,7 @@ describe('vaultsSecretsNewDeleteGet', () => { ); }); }); -describe('vaultsSecretsNewDirList', () => { +describe('vaultsSecretsNewDir and vaultsSecretsList', () => { const logger = new Logger('vaultsSecretsNewDirList test', LogLevel.WARN, [ new StreamHandler( formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`, @@ -1423,11 +1219,14 @@ describe('vaultsSecretsNewDirList', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsNewDir: typeof vaultsSecretsNewDir; + vaultsSecretsList: typeof vaultsSecretsList; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1460,56 +1259,54 @@ describe('vaultsSecretsNewDirList', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('adds and lists a directory of secrets', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsNewDir: new VaultsSecretsNewDirHandler({ + vaultsSecretsNewDir: new VaultsSecretsNewDir({ db, fs, vaultManager, }), - vaultsSecretsList: new VaultsSecretsListHandler({ + vaultsSecretsList: new VaultsSecretsList({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsNewDir, vaultsSecretsList, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('adds and lists a directory of secrets', async () => { // Doing the test // Add directory of secrets const vaultName = 'test-vault'; @@ -1553,11 +1350,13 @@ describe('vaultsSecretsRename', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsRename: typeof vaultsSecretsRename; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1590,51 +1389,48 @@ describe('vaultsSecretsRename', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('renames a secret', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsRename: new VaultsSecretsRenameHandler({ + vaultsSecretsRename: new VaultsSecretsRename({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsRename, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('renames a secret', async () => { const vaultName = 'test-vault'; const secretName = 'test-secret'; const vaultId = await vaultManager.createVault(vaultName); @@ -1670,11 +1466,13 @@ describe('vaultsSecretsStat', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsSecretsStat: typeof vaultsSecretsStat; + }>; let vaultManager: VaultManager; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1707,51 +1505,48 @@ describe('vaultsSecretsStat', () => { notificationsManager: {} as NotificationsManager, logger, }); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('stats a file', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsSecretsStat: new VaultsSecretsStatHandler({ + vaultsSecretsStat: new VaultsSecretsStat({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsSecretsStat, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('stats a file', async () => { const vaultName = 'test-vault'; const secretName = 'test-secret'; const vaultId = await vaultManager.createVault(vaultName); @@ -1782,9 +1577,12 @@ describe('vaultsVersion', () => { let dataDir: string; let db: DB; let keyRing: KeyRing; - let webSocketClient: WebSocketClient; - let clientService: ClientService; let tlsConfig: TLSConfig; + let clientService: ClientService; + let webSocketClient: WebSocketClient; + let rpcClient: RPCClient<{ + vaultsVersion: typeof vaultsVersion; + }>; let vaultManager: VaultManager; let vaultId: VaultId; const secretVer1 = { @@ -1796,7 +1594,6 @@ describe('vaultsVersion', () => { content: 'Secret-1-content-ver2', }; const vaultName = 'test-vault'; - beforeEach(async () => { dataDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'polykey-test-'), @@ -1830,51 +1627,48 @@ describe('vaultsVersion', () => { logger, }); vaultId = await vaultManager.createVault(vaultName); - }); - afterEach(async () => { - await clientService?.stop({ force: true }); - await webSocketClient.destroy({ force: true }); - await vaultManager.stop(); - await db.stop(); - await keyRing.stop(); - await fs.promises.rm(dataDir, { - force: true, - recursive: true, - }); - }); - test('should switch a vault to a version', async () => { - // Setup - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { - vaultsVersion: new VaultsVersionHandler({ + vaultsVersion: new VaultsVersion({ db, vaultManager, }), }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); webSocketClient = await WebSocketClient.createWebSocketClient({ config: { verifyPeer: false, }, host: localhost, - logger: logger.getChild('client'), + logger: logger.getChild(WebSocketClient.name), port: clientService.port, }); - const rpcClient = new RPCClient({ + rpcClient = new RPCClient({ manifest: { vaultsVersion, }, streamFactory: () => webSocketClient.connection.newStream(), toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), + logger: logger.getChild(RPCClient.name), }); - - // Doing the test + }); + afterEach(async () => { + await clientService?.stop({ force: true }); + await webSocketClient.destroy({ force: true }); + await vaultManager.stop(); + await db.stop(); + await keyRing.stop(); + await fs.promises.rm(dataDir, { + force: true, + recursive: true, + }); + }); + test('should switch a vault to a version', async () => { // Commit some history const ver1Oid = await vaultManager.withVaults([vaultId], async (vault) => { await vault.writeF(async (efs) => { @@ -1902,38 +1696,6 @@ describe('vaultsVersion', () => { }); }); test('should fail to find a non existent version', async () => { - // Setup - clientService = await ClientService.createClientService({ - tlsConfig, - manifest: { - vaultsVersion: new VaultsVersionHandler({ - db, - vaultManager, - }), - }, - options: { - host: localhost, - }, - logger: logger.getChild(ClientService.name), - }); - webSocketClient = await WebSocketClient.createWebSocketClient({ - config: { - verifyPeer: false, - }, - host: localhost, - logger: logger.getChild('client'), - port: clientService.port, - }); - const rpcClient = new RPCClient({ - manifest: { - vaultsVersion, - }, - streamFactory: () => webSocketClient.connection.newStream(), - toError: networkUtils.toError, - logger: logger.getChild('clientRPC'), - }); - - // Doing the test // Revert the version const vaultIdEncoded = vaultsUtils.encodeVaultId(vaultId); const version = rpcClient.methods.vaultsVersion({ diff --git a/tests/client/timeoutMiddleware.test.ts b/tests/client/timeoutMiddleware.test.ts index bf24dee34..762e5618f 100644 --- a/tests/client/timeoutMiddleware.test.ts +++ b/tests/client/timeoutMiddleware.test.ts @@ -3,7 +3,7 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult, } from '@/client/types'; -import type { TLSConfig } from '../../src/network/types'; +import type { TLSConfig } from '@/network/types'; import fs from 'fs'; import path from 'path'; import os from 'os'; @@ -18,13 +18,13 @@ import { } from '@matrixai/rpc'; import { WebSocketClient } from '@matrixai/ws'; import KeyRing from '@/keys/KeyRing'; -import * as keysUtils from '@/keys/utils'; import TaskManager from '@/tasks/TaskManager'; import CertManager from '@/keys/CertManager'; -import * as timeoutMiddleware from '@/client/utils/timeoutMiddleware'; -import { promise } from '@/utils'; import ClientService from '@/client/ClientService'; +import * as timeoutMiddleware from '@/client/timeoutMiddleware'; +import * as keysUtils from '@/keys/utils'; import * as networkUtils from '@/network/utils'; +import * as utils from '@/utils'; import * as testsUtils from '../utils'; describe('timeoutMiddleware', () => { @@ -88,7 +88,7 @@ describe('timeoutMiddleware', () => { }); test('server side timeout updates', async () => { // Setup - const ctxProm = promise(); + const ctxProm = utils.promise(); class EchoHandler extends UnaryHandler< { logger: Logger }, ClientRPCRequestParams, @@ -104,16 +104,16 @@ describe('timeoutMiddleware', () => { return input; }; } - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + middlewareFactory: timeoutMiddleware.timeoutMiddlewareServer, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { testHandler: new EchoHandler({ logger }), }, - options: { - host: localhost, - middlewareFactory: timeoutMiddleware.timeoutMiddlewareServer, - }, - logger: logger.getChild(ClientService.name), + host: localhost, }); clientClient = await WebSocketClient.createWebSocketClient({ config: { @@ -169,17 +169,17 @@ describe('timeoutMiddleware', () => { return input; }; } - clientService = await ClientService.createClientService({ + clientService = new ClientService({ tlsConfig, + middlewareFactory: timeoutMiddleware.timeoutMiddlewareServer, + rpcCallTimeoutTime: 100, + logger: logger.getChild(ClientService.name), + }); + await clientService.start({ manifest: { testHandler: new EchoHandler({ logger }), }, - options: { - host: localhost, - middlewareFactory: timeoutMiddleware.timeoutMiddlewareServer, - rpcCallTimeoutTime: 100, - }, - logger, + host: localhost, }); clientClient = await WebSocketClient.createWebSocketClient({ config: {