UNPKG

2.41 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3/// <reference types="node" />
4import { SecureServerOptions } from 'http2';
5import { SecureContextOptions } from 'tls';
6import { ServerInterceptor } from '.';
7import { CertificateProvider } from './certificate-provider';
8export interface KeyCertPair {
9 private_key: Buffer;
10 cert_chain: Buffer;
11}
12export interface SecureContextWatcher {
13 (context: SecureContextOptions | null): void;
14}
15export declare abstract class ServerCredentials {
16 private watchers;
17 private latestContextOptions;
18 _addWatcher(watcher: SecureContextWatcher): void;
19 _removeWatcher(watcher: SecureContextWatcher): void;
20 protected getWatcherCount(): number;
21 protected updateSecureContextOptions(options: SecureServerOptions | null): void;
22 abstract _isSecure(): boolean;
23 _getSettings(): SecureServerOptions | null;
24 _getInterceptors(): ServerInterceptor[];
25 abstract _equals(other: ServerCredentials): boolean;
26 static createInsecure(): ServerCredentials;
27 static createSsl(rootCerts: Buffer | null, keyCertPairs: KeyCertPair[], checkClientCertificate?: boolean): ServerCredentials;
28}
29declare class CertificateProviderServerCredentials extends ServerCredentials {
30 private identityCertificateProvider;
31 private caCertificateProvider;
32 private requireClientCertificate;
33 private latestCaUpdate;
34 private latestIdentityUpdate;
35 private caCertificateUpdateListener;
36 private identityCertificateUpdateListener;
37 constructor(identityCertificateProvider: CertificateProvider, caCertificateProvider: CertificateProvider | null, requireClientCertificate: boolean);
38 _addWatcher(watcher: SecureContextWatcher): void;
39 _removeWatcher(watcher: SecureContextWatcher): void;
40 _isSecure(): boolean;
41 _equals(other: ServerCredentials): boolean;
42 private calculateSecureContextOptions;
43 private finalizeUpdate;
44 private handleCaCertificateUpdate;
45 private handleIdentityCertitificateUpdate;
46}
47export declare function createCertificateProviderServerCredentials(caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, requireClientCertificate: boolean): CertificateProviderServerCredentials;
48export declare function createServerCredentialsWithInterceptors(credentials: ServerCredentials, interceptors: ServerInterceptor[]): ServerCredentials;
49export {};