-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: frame-worked tracking state and making authentication RPC call
- Loading branch information
1 parent
18e0e48
commit 3e7b842
Showing
7 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { HandlerTypes } from '@matrixai/rpc'; | ||
import type NodesAuthenticateConnection from '../handlers/NodesAuthenticateConnection'; | ||
import { UnaryCaller } from '@matrixai/rpc'; | ||
|
||
type CallerTypes = HandlerTypes<NodesAuthenticateConnection>; | ||
|
||
const nodesAuthenticateConnection = new UnaryCaller< | ||
CallerTypes['input'], | ||
CallerTypes['output'] | ||
>(); | ||
|
||
export default nodesAuthenticateConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { | ||
AgentRPCRequestParams, | ||
AgentRPCResponseResult, | ||
SuccessMessage, | ||
} from '../types'; | ||
import type NodeConnectionManager from '../../../nodes/NodeConnectionManager'; | ||
import type { JSONValue } from '../../../types'; | ||
import type { ContextTimed } from '@matrixai/contexts'; | ||
import { UnaryHandler } from '@matrixai/rpc'; | ||
import * as agentErrors from '../errors'; | ||
import * as agentUtils from '../utils'; | ||
|
||
class NodesAuthenticateConnection extends UnaryHandler< | ||
{ | ||
nodeConnectionManager: NodeConnectionManager; | ||
}, | ||
AgentRPCRequestParams, | ||
AgentRPCResponseResult<SuccessMessage> | ||
> { | ||
public handle = async ( | ||
_input, | ||
_cancel, | ||
meta: Record<string, JSONValue> | undefined, | ||
ctx: ContextTimed, | ||
): Promise<AgentRPCResponseResult<SuccessMessage>> => { | ||
const { nodeConnectionManager } = this.container; | ||
// Connections should always be validated | ||
const requestingNodeId = agentUtils.nodeIdFromMeta(meta); | ||
if (requestingNodeId == null) { | ||
throw new agentErrors.ErrorAgentNodeIdMissing(); | ||
} | ||
await nodeConnectionManager.handleReverseAuthenticate( | ||
requestingNodeId, | ||
ctx, | ||
); | ||
return { | ||
type: 'success', | ||
success: true, | ||
}; | ||
}; | ||
} | ||
|
||
export default NodesAuthenticateConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters