1 |
|
2 |
|
3 | import { ConnectionOptions, PeerCertificate, SecureContext } from 'tls';
|
4 | import { CallCredentials } from './call-credentials';
|
5 | import { CertificateProvider } from './certificate-provider';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export type CheckServerIdentityCallback = (hostname: string, cert: PeerCertificate) => Error | undefined;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export interface VerifyOptions {
|
18 | |
19 |
|
20 |
|
21 |
|
22 | checkServerIdentity?: CheckServerIdentityCallback;
|
23 | rejectUnauthorized?: boolean;
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export declare abstract class ChannelCredentials {
|
31 | protected callCredentials: CallCredentials;
|
32 | protected constructor(callCredentials?: CallCredentials);
|
33 | /**
|
34 | * Returns a copy of this object with the included set of per-call credentials
|
35 | * expanded to include callCredentials.
|
36 | * @param callCredentials A CallCredentials object to associate with this
|
37 | * instance.
|
38 | */
|
39 | abstract compose(callCredentials: CallCredentials): ChannelCredentials;
|
40 | /**
|
41 | * Gets the set of per-call credentials associated with this instance.
|
42 | */
|
43 | _getCallCredentials(): CallCredentials;
|
44 | /**
|
45 | * Gets a SecureContext object generated from input parameters if this
|
46 | * instance was created with createSsl, or null if this instance was created
|
47 | * with createInsecure.
|
48 | */
|
49 | abstract _getConnectionOptions(): ConnectionOptions | null;
|
50 | /**
|
51 | * Indicates whether this credentials object creates a secure channel.
|
52 | */
|
53 | abstract _isSecure(): boolean;
|
54 | /**
|
55 | * Check whether two channel credentials objects are equal. Two secure
|
56 | * credentials are equal if they were constructed with the same parameters.
|
57 | * @param other The other ChannelCredentials Object
|
58 | */
|
59 | abstract _equals(other: ChannelCredentials): boolean;
|
60 | _ref(): void;
|
61 | _unref(): void;
|
62 | /**
|
63 | * Return a new ChannelCredentials instance with a given set of credentials.
|
64 | * The resulting instance can be used to construct a Channel that communicates
|
65 | * over TLS.
|
66 | * @param rootCerts The root certificate data.
|
67 | * @param privateKey The client certificate private key, if available.
|
68 | * @param certChain The client certificate key chain, if available.
|
69 | * @param verifyOptions Additional options to modify certificate verification
|
70 | */
|
71 | static createSsl(rootCerts?: Buffer | null, privateKey?: Buffer | null, certChain?: Buffer | null, verifyOptions?: VerifyOptions): ChannelCredentials;
|
72 | /**
|
73 | * Return a new ChannelCredentials instance with credentials created using
|
74 | * the provided secureContext. The resulting instances can be used to
|
75 | * construct a Channel that communicates over TLS. gRPC will not override
|
76 | * anything in the provided secureContext, so the environment variables
|
77 | * GRPC_SSL_CIPHER_SUITES and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH will
|
78 | * not be applied.
|
79 | * @param secureContext The return value of tls.createSecureContext()
|
80 | * @param verifyOptions Additional options to modify certificate verification
|
81 | */
|
82 | static createFromSecureContext(secureContext: SecureContext, verifyOptions?: VerifyOptions): ChannelCredentials;
|
83 | /**
|
84 | * Return a new ChannelCredentials instance with no credentials.
|
85 | */
|
86 | static createInsecure(): ChannelCredentials;
|
87 | }
|
88 | declare class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
89 | private caCertificateProvider;
|
90 | private identityCertificateProvider;
|
91 | private verifyOptions;
|
92 | private refcount;
|
93 | private latestCaUpdate;
|
94 | private latestIdentityUpdate;
|
95 | private caCertificateUpdateListener;
|
96 | private identityCertificateUpdateListener;
|
97 | constructor(caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, verifyOptions: VerifyOptions | null);
|
98 | compose(callCredentials: CallCredentials): ChannelCredentials;
|
99 | _getConnectionOptions(): ConnectionOptions | null;
|
100 | _isSecure(): boolean;
|
101 | _equals(other: ChannelCredentials): boolean;
|
102 | _ref(): void;
|
103 | _unref(): void;
|
104 | private handleCaCertificateUpdate;
|
105 | private handleIdentityCertitificateUpdate;
|
106 | }
|
107 | export declare function createCertificateProviderChannelCredentials(caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, verifyOptions?: VerifyOptions): CertificateProviderChannelCredentialsImpl;
|
108 | export {};
|