Constructors

Properties

interface: null | Interface
peer: null | Peer
privateKey: string
publicKey: string

Methods

  • Builds the WireGuard config string without writing it to disk. Useful for displaying or generating a QR code.

    Returns null | string

    The config string, or null if not yet initialized.

  • Brings up the WireGuard tunnel using wg-quick up. Requires sudo/root privileges.

    Parameters

    • Optional configFile: string

      Optional path to an existing .conf file. If omitted, writes the current config to a temp file first.

    Returns void

  • Brings down the WireGuard tunnel using wg-quick down. Requires sudo/root privileges.

    Parameters

    • configFile: string

      Path to the .conf file used when connecting.

    Returns void

  • Generates a WireGuard X25519 keypair.

    Returns {
        [k: string]: string;
    }

    An object with pub (base64 public key) and prv (base64 private key)

    • [k: string]: string
  • Parses the JSON response from the node handshake and builds the WireGuard interface + peer configuration.

    Replaces the old binary buffer parsing (58-byte format) with the new JSON format introduced in hub v12 / sentinel-dvpnx.

    Parameters

    • handshakeData: WireGuardHandshakeData

      Parsed result.data from the handshake response

    • nodeAddrs: string[]

      result.addrs from the handshake response (public IPs of the node)

    • dns: string[] = ...

    Returns Promise<void>

    Example

    const data: WireGuardHandshakeData = JSON.parse(
    Buffer.from(result.data, 'base64').toString('utf8')
    );
    await wg.parseConfig(data, result.addrs);
  • Prints the WireGuard configuration as a QR code to the terminal. Useful for importing the config directly into a mobile WireGuard app.

    Requires qrcode package: npm install qrcode @types/qrcode

    Returns Promise<void>

    Throws

    If the config is not yet initialized or QR generation fails.

    Example

    await wg.printQRCode();
    // Prints a scannable QR code to stdout
  • Returns the current status of the WireGuard tunnel by running wg show.

    Parameters

    • Optional configFile: string

      Optional path to the .conf file (used to derive the interface name). Defaults to wgsent0.

    Returns Promise<any[]>

    Array of peer objects with handshake, transfer, and keepalive info.

  • Serializes the current interface + peer configuration to a WireGuard .conf file format and writes it to disk.

    Parameters

    • Optional output: string

      Optional file path. If omitted, a temp file is created in the system temp directory under a sentinel-js-sdk prefix.

    Returns null | string

    The path of the written config file, or null if the config is not yet initialized (call parseConfig first).

Generated using TypeDoc