server-credentials.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. /// <reference types="node" />
  4. import { SecureServerOptions } from 'http2';
  5. import { SecureContextOptions } from 'tls';
  6. import { ServerInterceptor } from '.';
  7. import { CertificateProvider } from './certificate-provider';
  8. export interface KeyCertPair {
  9. private_key: Buffer;
  10. cert_chain: Buffer;
  11. }
  12. export interface SecureContextWatcher {
  13. (context: SecureContextOptions | null): void;
  14. }
  15. export 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. }
  29. declare 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. }
  47. export declare function createCertificateProviderServerCredentials(caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, requireClientCertificate: boolean): CertificateProviderServerCredentials;
  48. export declare function createServerCredentialsWithInterceptors(credentials: ServerCredentials, interceptors: ServerInterceptor[]): ServerCredentials;
  49. export {};