mirror of https://github.com/grpc/grpc-node.git
Load 'google-auth-library' lazily to avoid impacting load times
This commit is contained in:
parent
010ef569f7
commit
cefb8d1f62
|
@ -19,7 +19,7 @@ import { ConnectionOptions, createSecureContext, PeerCertificate } from 'tls';
|
||||||
|
|
||||||
import { CallCredentials } from './call-credentials';
|
import { CallCredentials } from './call-credentials';
|
||||||
import { CIPHER_SUITES, getDefaultRootsData } from './tls-helpers';
|
import { CIPHER_SUITES, getDefaultRootsData } from './tls-helpers';
|
||||||
import { GoogleAuth } from 'google-auth-library';
|
import { GoogleAuth as GoogleAuthType } from 'google-auth-library';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function verifyIsBufferOrNull(obj: any, friendlyName: string): void {
|
function verifyIsBufferOrNull(obj: any, friendlyName: string): void {
|
||||||
|
@ -281,6 +281,8 @@ class ComposedChannelCredentialsImpl extends ChannelCredentials {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createGoogleDefaultCredentials(): ChannelCredentials {
|
export function createGoogleDefaultCredentials(): ChannelCredentials {
|
||||||
|
const GoogleAuth = require('google-auth-library')
|
||||||
|
.GoogleAuth as typeof GoogleAuthType;
|
||||||
const sslCreds = ChannelCredentials.createSsl();
|
const sslCreds = ChannelCredentials.createSsl();
|
||||||
const googleAuthCreds = CallCredentials.createFromGoogleCredential(
|
const googleAuthCreds = CallCredentials.createFromGoogleCredential(
|
||||||
new GoogleAuth()
|
new GoogleAuth()
|
||||||
|
|
Loading…
Reference in New Issue