///
///
import * as grpc from '@grpc/grpc-js';
import type { Authenticator } from '../authenticators';
import type { CouchbaseLogger } from '../logger';
import type { Couchbase2ConnStr } from './connstr';
/**
* How often an idle connection is pinged, in milliseconds.
*
* @internal
*/
export declare const KEEPALIVE_TIME_MS = 30000;
/**
* How long a ping may go unanswered before the connection is dropped, in
* milliseconds.
*
* @internal
*/
export declare const KEEPALIVE_TIMEOUT_MS = 5000;
/**
* The largest message the channel accepts. gRPC's default of 4 MiB is smaller
* than the largest document Couchbase serves.
*
* @internal
*/
export declare const MAX_RECEIVE_MESSAGE_LENGTH: number;
/**
* The TLS server name sent when the target is an IP address. grpc-js sends the
* target's host as the server name, and newer Node versions refuse an IP
* there, so an IP target names this instead and its certificate is checked
* against the IP by {@link channelCredentials}.
*
* @internal
*/
export declare const IP_TARGET_SERVER_NAME = "gateway.invalid";
/**
* How long the channel stays connected with no call in flight before it
* closes the connection, in milliseconds. It is grpc-js's own default, set
* explicitly so that the connectivity log can tell this from a lost
* connection.
*
* @internal
*/
export declare const CLIENT_IDLE_TIMEOUT_MS: number;
/**
* The Capella root, which a couchbase2 channel trusts by default as a classic
* connection does.
*
* @internal
*/
export declare const CAPELLA_ROOT_CA = "-----BEGIN CERTIFICATE-----\nMIIDFTCCAf2gAwIBAgIRANLVkgOvtaXiQJi0V6qeNtswDQYJKoZIhvcNAQELBQAw\nJDESMBAGA1UECgwJQ291Y2hiYXNlMQ4wDAYDVQQLDAVDbG91ZDAeFw0xOTEyMDYy\nMjEyNTlaFw0yOTEyMDYyMzEyNTlaMCQxEjAQBgNVBAoMCUNvdWNoYmFzZTEOMAwG\nA1UECwwFQ2xvdWQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCfvOIi\nenG4Dp+hJu9asdxEMRmH70hDyMXv5ZjBhbo39a42QwR59y/rC/sahLLQuNwqif85\nFod1DkqgO6Ng3vecSAwyYVkj5NKdycQu5tzsZkghlpSDAyI0xlIPSQjoORA/pCOU\nWOpymA9dOjC1bo6rDyw0yWP2nFAI/KA4Z806XeqLREuB7292UnSsgFs4/5lqeil6\nrL3ooAw/i0uxr/TQSaxi1l8t4iMt4/gU+W52+8Yol0JbXBTFX6itg62ppb/Eugmn\nmQRMgL67ccZs7cJ9/A0wlXencX2ohZQOR3mtknfol3FH4+glQFn27Q4xBCzVkY9j\nKQ20T1LgmGSngBInAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE\nFJQOBPvrkU2In1Sjoxt97Xy8+cKNMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B\nAQsFAAOCAQEARgM6XwcXPLSpFdSf0w8PtpNGehmdWijPM3wHb7WZiS47iNen3oq8\nm2mm6V3Z57wbboPpfI+VEzbhiDcFfVnK1CXMC0tkF3fnOG1BDDvwt4jU95vBiNjY\nxdzlTP/Z+qr0cnVbGBSZ+fbXstSiRaaAVcqQyv3BRvBadKBkCyPwo+7svQnScQ5P\nJs7HEHKVms5tZTgKIw1fbmgR2XHleah1AcANB+MAPBCcTgqurqr5G7W2aPSBLLGA\nfRIiVzm7VFLc7kWbp7ENH39HVG6TZzKnfl9zJYeiklo5vQQhGSMhzBsO70z4RRzi\nDPFAN/4qZAgD5q3AFNIq2WWADFQGSwVJhg==\n-----END CERTIFICATE-----\n";
/**
* What the channel is built from, read once at connect. It holds paths, not
* secrets: the authorization header is kept apart, by {@link callMetadata}.
*
* @internal
*/
export interface ChannelSettings {
/**
* The gateway's address, `host:port`.
*/
target: string;
/**
* False when `tls_verify=none`: the channel encrypts but trusts whatever
* certificate the gateway presents.
*/
verifyPeer: boolean;
/**
* A PEM file whose certificates replace the default roots.
*/
trustCertificatePath?: string;
/**
* Whether the default roots include Node's bundled Mozilla roots beside
* the system store and the Capella root.
*/
includeMozillaRoots: boolean;
/**
* A certificate authenticator's certificate chain, presented as the
* channel's own identity.
*/
clientCertificatePath?: string;
/**
* A certificate authenticator's private key.
*/
clientKeyPath?: string;
/**
* The `user-agent` the channel sends.
*/
userAgent: string;
}
/**
* Collects the channel's settings from the connection string, the
* authenticator and the cluster's security options. A trust store set on the
* cluster wins over the connection string's, as on classic.
*
* @internal
*/
export declare function channelSettings(connStr: Couchbase2ConnStr, auth: Authenticator | undefined, trustStorePath?: string): ChannelSettings;
/**
* The `authorization` header the authenticator implies: Bearer for a JWT,
* Basic for a username and password, none for a certificate, whose identity
* is the channel's client certificate.
*
* @internal
*/
export declare function authorizationHeader(auth: Authenticator | undefined): string | undefined;
/**
* The kind of credentials the authenticator carries, or undefined for none.
*
* @internal
*/
export declare function authenticatorKind(auth: Authenticator | undefined): 'JWT' | 'password' | 'certificate' | undefined;
/**
* The metadata every call carries. The password or token travels per call,
* not as call credentials, as the C++ client sends it.
*
* @internal
*/
export declare function callMetadata(authorization: string | undefined): grpc.Metadata;
/**
* The certificates in the operating system's trust store, which a classic
* connection also trusts. Empty where the running Node version cannot read the
* store, or reading it fails.
*
* @internal
*/
export declare function systemRootCertificates(): string[];
/**
* The roots a verifying channel trusts, as one PEM. A trust store replaces the
* default set, which is the Capella root, the system store and, unless
* disabled, Node's bundled Mozilla roots. A certificate in more than one of
* them appears once.
*
* @internal
*/
export declare function rootCertificates(settings: ChannelSettings, systemRoots?: readonly string[]): Buffer;
/**
* The target's host when it is an IP address, without brackets, or undefined.
*
* @internal
*/
export declare function targetIp(target: string): string | undefined;
/**
* The channel's TLS credentials. With verification off, neither the
* gateway's certificate nor its host name is checked; a configured client
* identity is still presented. With it on, an IP target's certificate is
* checked against the IP rather than {@link IP_TARGET_SERVER_NAME}.
*
* @internal
*/
export declare function channelCredentials(settings: ChannelSettings, logger: CouchbaseLogger): grpc.ChannelCredentials;
/**
* The channel's options: keepalive, the idle timeout, the receive limit and
* the user agent, and for an IP target the server name to send instead of
* the IP.
*
* @internal
*/
export declare function channelOptions(settings: ChannelSettings): grpc.ChannelOptions;
/**
* How the channel connects, as the `key: value` pairs of the log line written
* when a cluster opens. It never includes a credential.
*
* @internal
*/
export declare function describeChannel(settings: ChannelSettings, auth: ReturnType, systemRoots?: readonly string[]): string;
/**
* Opens the channel every stub shares. It connects lazily, on the first call,
* and reconnects for as long as it is open.
*
* @internal
*/
export declare function openChannel(settings: ChannelSettings, logger: CouchbaseLogger): grpc.Channel;