Merge branch 'master' into grpc-js-xds_routing_traffic_splitting_config_selector

This commit is contained in:
Michael Lumish 2021-03-02 12:47:38 -08:00
commit eff8cfc0f5
6 changed files with 29 additions and 14 deletions

View File

@ -43,6 +43,7 @@
}, },
"dependencies": { "dependencies": {
"@grpc/proto-loader": "^0.6.0-pre14", "@grpc/proto-loader": "^0.6.0-pre14",
"google-auth-library": "^7.0.2",
"re2-wasm": "^1.0.1" "re2-wasm": "^1.0.1"
}, },
"peerDependencies": { "peerDependencies": {

View File

@ -0,0 +1,27 @@
/*
* Copyright 2021 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { GoogleAuth } from 'google-auth-library';
import { ChannelCredentials, CallCredentials } from '@grpc/grpc-js';
export function createGoogleDefaultCredentials(): ChannelCredentials {
const sslCreds = ChannelCredentials.createSsl();
const googleAuthCreds = CallCredentials.createFromGoogleCredential(
new GoogleAuth()
);
return sslCreds.compose(googleAuthCreds);
}

View File

@ -48,7 +48,7 @@ import { RouteConfiguration__Output } from './generated/envoy/api/v2/RouteConfig
import { Any__Output } from './generated/google/protobuf/Any'; import { Any__Output } from './generated/google/protobuf/Any';
import BackoffTimeout = experimental.BackoffTimeout; import BackoffTimeout = experimental.BackoffTimeout;
import ServiceConfig = experimental.ServiceConfig; import ServiceConfig = experimental.ServiceConfig;
import createGoogleDefaultCredentials = experimental.createGoogleDefaultCredentials; import { createGoogleDefaultCredentials } from './google-default-credentials';
import { CdsLoadBalancingConfig } from './load-balancer-cds'; import { CdsLoadBalancingConfig } from './load-balancer-cds';
import { EdsState } from './xds-stream-state/eds-state'; import { EdsState } from './xds-stream-state/eds-state';
import { CdsState } from './xds-stream-state/cds-state'; import { CdsState } from './xds-stream-state/cds-state';

View File

@ -58,7 +58,6 @@
}, },
"dependencies": { "dependencies": {
"@types/node": "^12.12.47", "@types/node": "^12.12.47",
"google-auth-library": "^6.1.1",
"semver": "^6.2.0" "semver": "^6.2.0"
}, },
"files": [ "files": [

View File

@ -19,7 +19,6 @@ 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 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 {
@ -279,13 +278,3 @@ class ComposedChannelCredentialsImpl extends ChannelCredentials {
} }
} }
} }
export function createGoogleDefaultCredentials(): ChannelCredentials {
const GoogleAuth = require('google-auth-library')
.GoogleAuth as typeof GoogleAuthType;
const sslCreds = ChannelCredentials.createSsl();
const googleAuthCreds = CallCredentials.createFromGoogleCredential(
new GoogleAuth()
);
return sslCreds.compose(googleAuthCreds);
}

View File

@ -2,7 +2,6 @@ export { trace } from './logging';
export { Resolver, ResolverListener, registerResolver, ConfigSelector } from './resolver'; export { Resolver, ResolverListener, registerResolver, ConfigSelector } from './resolver';
export { GrpcUri, uriToString } from './uri-parser'; export { GrpcUri, uriToString } from './uri-parser';
export { ServiceConfig } from './service-config'; export { ServiceConfig } from './service-config';
export { createGoogleDefaultCredentials } from './channel-credentials';
export { BackoffTimeout } from './backoff-timeout'; export { BackoffTimeout } from './backoff-timeout';
export { LoadBalancer, LoadBalancingConfig, ChannelControlHelper, registerLoadBalancerType, getFirstUsableConfig, validateLoadBalancingConfig } from './load-balancer'; export { LoadBalancer, LoadBalancingConfig, ChannelControlHelper, registerLoadBalancerType, getFirstUsableConfig, validateLoadBalancingConfig } from './load-balancer';
export { SubchannelAddress, subchannelAddressToString } from './subchannel'; export { SubchannelAddress, subchannelAddressToString } from './subchannel';