• Performs the handshake with a Sentinel dVPN node to initiate a VPN session.

    Replicates the InitHandshake method of the Sentinel Go SDK client. The process is:

    1. JSON-encodes the protocol-specific peer request
    2. Builds the message as bigEndian(sessionId) || JSON(data)
    3. Signs the SHA256 hash of the message with the Cosmos secp256k1 private key
    4. POSTs { data, id, pub_key, signature } to the node's root endpoint (/)

    The node verifies the signature, derives the account address from pub_key, and checks it matches the on-chain session's account address before adding the peer to the active VPN service.

    SSL certificate verification is intentionally disabled since node daemons use self-signed certificates.

    Parameters

    • sessionId: Long

      The on-chain session identifier (uint64), obtained after broadcasting a MsgStartSessionRequest transaction

    • data: any

      The protocol-specific peer request returned by the selected VPN client's getPeerRequest() method.

    • privateKey: Uint8Array

      The 32-byte secp256k1 private key of the Cosmos wallet that owns the session on-chain

    • remoteUrl: string

      The node's remote URL as stored on-chain (e.g. https://1.2.3.4:port)

    • timeout: number = 60000

      request timeout in milliseconds

    Returns Promise<NodeHandshakeResult>

    A NodeHandshakeResult containing:

    • result.addrs — list of node endpoints to connect to (e.g. ["1.2.3.4:51820"])
    • result.data — base64-encoded protocol handshake response

    Throws

    Will throw if the HTTP request fails, or if the node returns an unsuccessful envelope (success: false / an error payload) — e.g. the session is not active on-chain or signature verification failed. The thrown message includes the node's error code and text when present. Also throws if a resolved response is unsuccessful or has no result.

    Example

    // WireGuard
    const wgKeys = generateKeypair();
    const result = await handshake(
    sessionId,
    wireguard.getPeerRequest(),
    cosmosPrivKeyBytes,
    node.remoteUrl,
    );
    // result.addrs → ["1.2.3.4"]
    // result.data → base64-encoded WireGuard peer config

    Example

    // v2ray
    const v2ray = new V2Ray();
    const result = await handshake(
    sessionId,
    v2ray.getPeerRequest(),
    cosmosPrivKeyBytes,
    node.remoteUrl,
    );

Generated using TypeDoc