mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Added contract id verification. (#180)
* Added contract id config. * Verify contract id with user/peer challenge. * Updated cluster scripts. * Updated node client lib for contract id verification.
This commit is contained in:
@@ -15,7 +15,7 @@ async function main() {
|
||||
let server = 'wss://localhost:8080'
|
||||
if (process.argv.length == 3) server = 'wss://localhost:' + process.argv[2]
|
||||
if (process.argv.length == 4) server = 'wss://' + process.argv[2] + ':' + process.argv[3]
|
||||
const hpc = new HotPocket.Client(server, keys, HotPocket.protocols.bson);
|
||||
const hpc = new HotPocket.Client(null, server, keys, HotPocket.protocols.bson);
|
||||
|
||||
// Establish HotPocket connection.
|
||||
if (!await hpc.connect()) {
|
||||
|
||||
@@ -40,7 +40,7 @@ const HotPocketKeyGenerator = {
|
||||
},
|
||||
}
|
||||
|
||||
function HotPocketClient(server, keys, protocol = protocols.json) {
|
||||
function HotPocketClient(contractId, server, keys, protocol = protocols.json) {
|
||||
|
||||
let ws = null;
|
||||
const msgHelper = new MessageHelper(keys, protocol);
|
||||
@@ -102,7 +102,14 @@ function HotPocketClient(server, keys, protocol = protocols.json) {
|
||||
}
|
||||
|
||||
if (m.type == 'handshake_challenge') {
|
||||
// sign the challenge and send back the response
|
||||
// Check whether contract id is matching if specified.
|
||||
if (contractId && m.contract_id != contractId)
|
||||
{
|
||||
console.error("Contract id mismatch.")
|
||||
ws.close();
|
||||
}
|
||||
|
||||
// Sign the challenge and send back the response
|
||||
const response = msgHelper.createHandshakeResponse(m.challenge);
|
||||
ws.send(JSON.stringify(response));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ function RoboClient(server, port, clientId) {
|
||||
|
||||
this.connect = async () => {
|
||||
this.keys = await HotPocketKeyGenerator.generate();
|
||||
this.hpclient = new HotPocketClient(server + port, this.keys);
|
||||
this.hpclient = new HotPocketClient(null, server + port, this.keys);
|
||||
|
||||
|
||||
if (!await this.hpclient.connect()) {
|
||||
|
||||
@@ -11,7 +11,7 @@ async function main() {
|
||||
let server = 'wss://localhost:8080'
|
||||
if (process.argv.length == 3) server = 'wss://localhost:' + process.argv[2]
|
||||
if (process.argv.length == 4) server = 'wss://' + process.argv[2] + ':' + process.argv[3]
|
||||
const hpc = new HotPocket.Client(server, keys, HotPocket.protocols.json);
|
||||
const hpc = new HotPocket.Client(null, server, keys, HotPocket.protocols.json);
|
||||
|
||||
// Establish HotPocket connection.
|
||||
if (!await hpc.connect()) {
|
||||
|
||||
Reference in New Issue
Block a user