Skip to content

Commit de01723

Browse files
committed
fix: build
1 parent ed15cf4 commit de01723

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

src/nodes/NodeConnectionManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,11 @@ class NodeConnectionManager {
875875
ctx,
876876
);
877877
this.addConnection(nodeConnection.validatedNodeId, nodeConnection);
878+
// TODO(aryanj): add the handshake rpc call here.
879+
// TODO the handshake needs to do the following:
880+
// TODO - send forward auth info
881+
// TODO - parse reverse auth info
882+
// TODO - success: true if match, success: false if not
878883
// Dispatch the connection event
879884
const connectionData: ConnectionData = {
880885
remoteNodeId: nodeConnection.nodeId,
@@ -1231,6 +1236,7 @@ class NodeConnectionManager {
12311236
*/
12321237
@startStop.ready(new nodesErrors.ErrorNodeConnectionManagerNotRunning())
12331238
protected handleConnectionReverse(quicConnection: QUICConnection) {
1239+
console.log('reverse conn')
12341240
// Checking NodeId
12351241
// No specific error here, validation is handled by the QUICServer
12361242
const certChain = quicConnection.getRemoteCertsChain().map((der) => {
@@ -1282,6 +1288,7 @@ class NodeConnectionManager {
12821288
}),
12831289
);
12841290
}
1291+
console.log('end revconn')
12851292
}
12861293

12871294
/**

src/nodes/NodeGraph.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import type {
1414
import type KeyRing from '../keys/KeyRing.js';
1515
import Logger from '@matrixai/logger';
1616
import { createDestroyStartStop } from '@matrixai/async-init';
17-
import { IdInternal } from '@matrixai/id';
1817
import { decorators } from '@matrixai/contexts';
18+
import { IdInternal } from '@matrixai/id';
1919
import * as nodesUtils from './utils.js';
2020
import * as nodesErrors from './errors.js';
2121
import * as nodesEvents from './events.js';
@@ -744,10 +744,10 @@ class NodeGraph {
744744
ctx?: ContextTimed,
745745
): Promise<void>;
746746
@createDestroyStartStop.ready(new nodesErrors.ErrorNodeGraphNotRunning())
747-
@timedCancellable(true)
747+
@decorators.timedCancellable(true)
748748
public async resetBuckets(
749749
tran: DBTransaction | undefined,
750-
@context ctx: ContextTimed,
750+
@decorators.context ctx: ContextTimed,
751751
): Promise<void> {
752752
if (tran == null) {
753753
return this.db.withTransactionF((tran) => this.resetBuckets(tran, ctx));

src/nodes/agent/handlers/NodesAuthenticateConnection.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class NodesAuthenticateConnection extends UnaryHandler<
2424
meta: Record<string, JSONValue> | undefined,
2525
ctx: ContextTimed,
2626
): Promise<AgentRPCResponseResult<SuccessMessage>> => {
27+
// Need to make this duplex. It will take in a forward message and parse it
28+
// with the reverse handler. It will also take in another reverse auth
29+
// handler from the sending node side which will parse it's forward token
30+
// and see if it is authorised.
31+
32+
// -> forward message
33+
// -> reverse handler
34+
// <- success code?
35+
// TODO: draw diagram to visualise this
36+
2737
const { nodeConnectionManager } = this.container;
2838
// Connections should always be validated
2939
const requestingNodeId = agentUtils.nodeIdFromMeta(meta);

tests/nodes/NodeConnection.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,16 @@ describe(`${NodeConnection.name}`, () => {
439439
await nodeConnectionReverse.destroy({ force: true });
440440
await destroyP;
441441
});
442-
});
442+
443+
test('asb', async () => {
444+
await NodeConnection.createNodeConnection({
445+
targetNodeIds: [serverNodeId],
446+
targetHost: localHost as Host,
447+
targetPort: quicServer.port as unknown as Port,
448+
manifest: {} as AgentClientManifest,
449+
tlsConfig: clientTlsConfig,
450+
quicSocket: clientSocket,
451+
logger: logger.getChild(`${NodeConnection.name}`),
452+
}).then(extractNodeConnection);
453+
});
454+
});

tests/nodes/NodeConnectionManager.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,17 @@ describe(`${NodeConnectionManager.name}`, () => {
997997
},
998998
);
999999
});
1000+
test('asb', async () => {
1001+
await ncmLocal.nodeConnectionManager.createConnection(
1002+
[ncmPeer1.nodeId],
1003+
localHost,
1004+
ncmPeer1.port,
1005+
);
1006+
// Should exist in the map now.
1007+
expect(
1008+
ncmLocal.nodeConnectionManager.hasConnection(ncmPeer1.nodeId),
1009+
).toBeTrue();
1010+
});
10001011
});
10011012
describe('With 2 peers', () => {
10021013
let ncmLocal: NCMState;

0 commit comments

Comments
 (0)