@fluent-org/logger
Version:
A node fluent protocol compatible logger
76 lines (75 loc) • 2.2 kB
TypeScript
import { FluentSocket, FluentSocketOptions } from "./socket";
import * as protocol from "./protocol";
/**
* The authentication options for the client
*/
export declare type FluentAuthOptions = {
/**
* The client host name (required).
*
* Must be unique to this process
*/
clientHostname: string;
/**
* The shared key with the server. (required)
*/
sharedKey: string;
/**
* The username to authenticate with. (optional)
*/
username?: string;
/**
* The password to authenticate with. (optional)
*/
password?: string;
};
/**
* An implementation of FluentSocket which authenticates the socket using the [Forward protocol Handshake](https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#handshake-messages)
*/
export declare class FluentAuthSocket extends FluentSocket {
private authState;
private sharedKeyInfo;
private authInfo?;
private clientHostname;
private username;
private password;
/**
* Creates a new instance of the socket
* @param authOptions The authentication options to use
* @param socketOptions The socket options to pass to the underlying socket
*/
constructor(authOptions: FluentAuthOptions, socketOptions?: FluentSocketOptions);
/**
* Once the socket is connected, we expect a HELO
*/
protected onConnected(): void;
/**
* When the socket is closed, we're unauthenticated
*/
protected onClose(): void;
/**
* Handles messages from the server
*
* If we're waiting for a message, this will trigger it, otherwise just forward to the superclass.
*
* @param message The message to check
*/
protected onMessage(message: protocol.ServerMessage): void;
/**
* Called on a HELO message
*
* Should parse the message, and send back a PING
*
* @param message The HELO message
*/
private handleHelo;
/**
* Called on a PONG message
*
* Should parse and validate the message, and if valid, establish the connection
*
* @param message The PONG message
* @returns void
*/
private handlePong;
}