@nats-io/nats-core
    Preparing search index...

    Interface Authenticator

    Authenticator is an interface that returns credentials.

    Returning a Promise is experimental, and subject to change or removal. The authenticator can return a Promise for credentials that cannot be computed synchronously (such as signing the nonce with a non-extractable WebCrypto key). The promise must resolve within the server's auth_timeout (2 seconds by default, 1 second more than the TLS timeout with TLS), otherwise the server closes the connection. If that happens on a reconnect while the promise is pending, the client notifies an AuthenticatorPendingStatus before the server's error. On the first connect, connect() rejects with the server's error. Two auth errors in a row stop reconnecting unless ConnectionOptions.ignoreAuthErrorAbort is set.

    If the authenticator throws or its promise rejects, the connection closes with that error and isn't retried; ConnectionOptions.ignoreAuthErrorAbort doesn't apply.

    The signal is aborted when the connection attempt the authenticator was called for is abandoned (the client closed or moved on to another attempt). Pass it to any request the authenticator makes, so abandoned work is cancelled; a late result is ignored either way.

    • Parameters

      • Optionalnonce: string
      • Optionalsignal: AbortSignal

      Returns Auth | Promise<Auth>