edgeport - v1.0.3
    Preparing search index...

    Function signNonce

    • Signs a NATS server nonce with the ed25519 key carried by a seed string.

      Decodes the seed, derives the public nkey string for its role, and produces a detached ed25519 signature over the raw nonce bytes encoded as base64url without padding. This is the exact pair the NATS CONNECT message expects in its nkey and sig fields.

      Parameters

      • seed: string

        The base32 seed string, e.g. SUAB....

      • nonce: Uint8Array

        The raw nonce bytes from the server INFO message.

      Returns Promise<SignedNonce>

      The public nkey string and the base64url signature.

      If the seed is malformed or cannot be imported.

      1.0.0

      import { signNonce } from 'edgeport/nats';
      const nonce = new TextEncoder().encode('server-nonce');
      const { nkey, sig } = await signNonce('SUAEL6GG2L2HIF7DUGZJGMRUFKXELGGYFMHF76UO2AYBG3K4YLWR3FKC2Q', nonce);