aws-crt
Version:
NodeJS bindings to the aws-c-* libraries
91 lines (90 loc) • 3.9 kB
TypeScript
import { MqttConnectionConfig, MqttWill } from "./mqtt";
import * as io from "./io";
import { HttpProxyOptions } from "./http";
import { AwsCredentialsProvider, AwsSigningConfig } from "./auth";
export interface WebsocketConfig {
credentials_provider: AwsCredentialsProvider;
create_signing_config?: () => AwsSigningConfig;
proxy_options?: HttpProxyOptions;
region: string;
service?: string;
}
/** Creates a MqttConnectionConfig to simplify configuring a connection to IoT services */
export declare class AwsIotMqttConnectionConfigBuilder {
private tls_ctx_options;
private params;
private constructor();
/**
* Create a new builder with mTLS file paths
* @param cert_path - Path to certificate, in PEM format
* @param key_path - Path to private key, in PEM format
*/
static new_mtls_builder_from_path(cert_path: string, key_path: string): AwsIotMqttConnectionConfigBuilder;
/**
* Create a new builder with mTLS cert pair in memory
* @param cert - Certificate, in PEM format
* @param private_key - Private key, in PEM format
*/
static new_mtls_builder(cert: string, private_key: string): AwsIotMqttConnectionConfigBuilder;
/**
* Configures the connection to use MQTT over websockets. Forces the port to 443.
*/
static new_with_websockets(options?: WebsocketConfig): AwsIotMqttConnectionConfigBuilder;
/**
* Overrides the default system trust store.
* @param ca_dirpath - Only used on Unix-style systems where all trust anchors are
* stored in a directory (e.g. /etc/ssl/certs).
* @param ca_filepath - Single file containing all trust CAs, in PEM format
*/
with_certificate_authority_from_path(ca_dirpath?: string, ca_filepath?: string): this;
/**
* Overrides the default system trust store.
* @param ca - Buffer containing all trust CAs, in PEM format
*/
with_certificate_authority(ca: string): this;
/**
* Configures the IoT endpoint for this connection
* @param endpoint The IoT endpoint to connect to
*/
with_endpoint(endpoint: string): this;
/**
* The port to connect to on the IoT endpoint
* @param port The port to connect to on the IoT endpoint. Usually 8883 for MQTT, or 443 for websockets
*/
with_port(port: number): this;
/**
* Configures the client_id to use to connect to the IoT Core service
* @param client_id The client id for this connection. Needs to be unique across all devices/clients.
*/
with_client_id(client_id: string): this;
/**
* Determines whether or not the service should try to resume prior subscriptions, if it has any
* @param clean_session true if the session should drop prior subscriptions when this client connects, false to resume the session
*/
with_clean_session(clean_session: boolean): this;
/**
* Configures MQTT keep-alive via PING messages. Note that this is not TCP keepalive.
* @param keep_alive How often in seconds to send an MQTT PING message to the service to keep the connection alive
*/
with_keep_alive_seconds(keep_alive: number): this;
/**
* Configures the TCP socket timeout (in milliseconds)
* @param timeout_ms TCP socket timeout
*/
with_timeout_ms(timeout_ms: number): this;
/**
* Configures the will message to be sent when this client disconnects
* @param will The will topic, qos, and message
*/
with_will(will: MqttWill): this;
/**
* Configures the common settings for the socket to use when opening a connection to the server
* @param socket_options The socket settings
*/
with_socket_options(socket_options: io.SocketOptions): this;
/**
* Returns the configured MqttConnectionConfig
* @returns The configured MqttConnectionConfig
*/
build(): MqttConnectionConfig;
}