better-grpc 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +43 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3923,10 +3923,10 @@ var require_client_interceptors = __commonJS({
|
|
|
3923
3923
|
const host = options.host;
|
|
3924
3924
|
const parent = (_b = options.parent) !== null && _b !== void 0 ? _b : null;
|
|
3925
3925
|
const propagateFlags = options.propagate_flags;
|
|
3926
|
-
const
|
|
3926
|
+
const credentials = options.credentials;
|
|
3927
3927
|
const call = channel.createCall(path, deadline, host, parent, propagateFlags);
|
|
3928
|
-
if (
|
|
3929
|
-
call.setCredentials(
|
|
3928
|
+
if (credentials) {
|
|
3929
|
+
call.setCredentials(credentials);
|
|
3930
3930
|
}
|
|
3931
3931
|
return call;
|
|
3932
3932
|
}
|
|
@@ -4085,7 +4085,7 @@ var require_client = __commonJS({
|
|
|
4085
4085
|
return ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split("\n").slice(1).join("\n")) || "no stack trace available";
|
|
4086
4086
|
}
|
|
4087
4087
|
var Client = class {
|
|
4088
|
-
constructor(address,
|
|
4088
|
+
constructor(address, credentials, options = {}) {
|
|
4089
4089
|
var _a, _b;
|
|
4090
4090
|
options = Object.assign({}, options);
|
|
4091
4091
|
this[INTERCEPTOR_SYMBOL] = (_a = options.interceptors) !== null && _a !== void 0 ? _a : [];
|
|
@@ -4102,9 +4102,9 @@ var require_client = __commonJS({
|
|
|
4102
4102
|
} else if (options.channelFactoryOverride) {
|
|
4103
4103
|
const channelFactoryOverride = options.channelFactoryOverride;
|
|
4104
4104
|
delete options.channelFactoryOverride;
|
|
4105
|
-
this[CHANNEL_SYMBOL] = channelFactoryOverride(address,
|
|
4105
|
+
this[CHANNEL_SYMBOL] = channelFactoryOverride(address, credentials, options);
|
|
4106
4106
|
} else {
|
|
4107
|
-
this[CHANNEL_SYMBOL] = new channel_1.ChannelImplementation(address,
|
|
4107
|
+
this[CHANNEL_SYMBOL] = new channel_1.ChannelImplementation(address, credentials, options);
|
|
4108
4108
|
}
|
|
4109
4109
|
}
|
|
4110
4110
|
close() {
|
|
@@ -15024,7 +15024,7 @@ var require_single_subchannel_channel = __commonJS({
|
|
|
15024
15024
|
getCallNumber() {
|
|
15025
15025
|
return this.callNumber;
|
|
15026
15026
|
}
|
|
15027
|
-
setCredentials(
|
|
15027
|
+
setCredentials(credentials) {
|
|
15028
15028
|
throw new Error("Method not implemented.");
|
|
15029
15029
|
}
|
|
15030
15030
|
getAuthContext() {
|
|
@@ -15114,7 +15114,7 @@ var require_subchannel = __commonJS({
|
|
|
15114
15114
|
* @param credentials The channel credentials used to establish this
|
|
15115
15115
|
* connection
|
|
15116
15116
|
*/
|
|
15117
|
-
constructor(channelTarget, subchannelAddress, options,
|
|
15117
|
+
constructor(channelTarget, subchannelAddress, options, credentials, connector) {
|
|
15118
15118
|
var _a;
|
|
15119
15119
|
this.channelTarget = channelTarget;
|
|
15120
15120
|
this.subchannelAddress = subchannelAddress;
|
|
@@ -15153,7 +15153,7 @@ var require_subchannel = __commonJS({
|
|
|
15153
15153
|
this.channelzRef = (0, channelz_1.registerChannelzSubchannel)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled);
|
|
15154
15154
|
this.channelzTrace.addTrace("CT_INFO", "Subchannel created");
|
|
15155
15155
|
this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2));
|
|
15156
|
-
this.secureConnector =
|
|
15156
|
+
this.secureConnector = credentials._createSecureConnector(channelTarget, options);
|
|
15157
15157
|
}
|
|
15158
15158
|
getChannelzInfo() {
|
|
15159
15159
|
return {
|
|
@@ -17052,13 +17052,13 @@ var require_load_balancing_call = __commonJS({
|
|
|
17052
17052
|
var http2 = __require("http2");
|
|
17053
17053
|
var TRACER_NAME = "load_balancing_call";
|
|
17054
17054
|
var LoadBalancingCall = class {
|
|
17055
|
-
constructor(channel, callConfig, methodName, host,
|
|
17055
|
+
constructor(channel, callConfig, methodName, host, credentials, deadline, callNumber) {
|
|
17056
17056
|
var _a, _b;
|
|
17057
17057
|
this.channel = channel;
|
|
17058
17058
|
this.callConfig = callConfig;
|
|
17059
17059
|
this.methodName = methodName;
|
|
17060
17060
|
this.host = host;
|
|
17061
|
-
this.credentials =
|
|
17061
|
+
this.credentials = credentials;
|
|
17062
17062
|
this.deadline = deadline;
|
|
17063
17063
|
this.callNumber = callNumber;
|
|
17064
17064
|
this.child = null;
|
|
@@ -17260,7 +17260,7 @@ var require_load_balancing_call = __commonJS({
|
|
|
17260
17260
|
this.pendingHalfClose = true;
|
|
17261
17261
|
}
|
|
17262
17262
|
}
|
|
17263
|
-
setCredentials(
|
|
17263
|
+
setCredentials(credentials) {
|
|
17264
17264
|
throw new Error("Method not implemented.");
|
|
17265
17265
|
}
|
|
17266
17266
|
getCallNumber() {
|
|
@@ -17541,8 +17541,8 @@ var require_resolving_call = __commonJS({
|
|
|
17541
17541
|
this.pendingHalfClose = true;
|
|
17542
17542
|
}
|
|
17543
17543
|
}
|
|
17544
|
-
setCredentials(
|
|
17545
|
-
this.credentials =
|
|
17544
|
+
setCredentials(credentials) {
|
|
17545
|
+
this.credentials = credentials;
|
|
17546
17546
|
}
|
|
17547
17547
|
addStatusWatcher(watcher) {
|
|
17548
17548
|
this.statusWatchers.push(watcher);
|
|
@@ -17636,13 +17636,13 @@ var require_retrying_call = __commonJS({
|
|
|
17636
17636
|
var PREVIONS_RPC_ATTEMPTS_METADATA_KEY = "grpc-previous-rpc-attempts";
|
|
17637
17637
|
var DEFAULT_MAX_ATTEMPTS_LIMIT = 5;
|
|
17638
17638
|
var RetryingCall = class {
|
|
17639
|
-
constructor(channel, callConfig, methodName, host,
|
|
17639
|
+
constructor(channel, callConfig, methodName, host, credentials, deadline, callNumber, bufferTracker, retryThrottler) {
|
|
17640
17640
|
var _a;
|
|
17641
17641
|
this.channel = channel;
|
|
17642
17642
|
this.callConfig = callConfig;
|
|
17643
17643
|
this.methodName = methodName;
|
|
17644
17644
|
this.host = host;
|
|
17645
|
-
this.credentials =
|
|
17645
|
+
this.credentials = credentials;
|
|
17646
17646
|
this.deadline = deadline;
|
|
17647
17647
|
this.callNumber = callNumber;
|
|
17648
17648
|
this.bufferTracker = bufferTracker;
|
|
@@ -18367,9 +18367,9 @@ var require_internal_channel = __commonJS({
|
|
|
18367
18367
|
}
|
|
18368
18368
|
};
|
|
18369
18369
|
var InternalChannel = class {
|
|
18370
|
-
constructor(target,
|
|
18370
|
+
constructor(target, credentials, options) {
|
|
18371
18371
|
var _a, _b, _c, _d, _e, _f;
|
|
18372
|
-
this.credentials =
|
|
18372
|
+
this.credentials = credentials;
|
|
18373
18373
|
this.options = options;
|
|
18374
18374
|
this.connectivityState = connectivity_state_1.ConnectivityState.IDLE;
|
|
18375
18375
|
this.currentPicker = new picker_1.UnavailablePicker();
|
|
@@ -18387,7 +18387,7 @@ var require_internal_channel = __commonJS({
|
|
|
18387
18387
|
if (typeof target !== "string") {
|
|
18388
18388
|
throw new TypeError("Channel target must be a string");
|
|
18389
18389
|
}
|
|
18390
|
-
if (!(
|
|
18390
|
+
if (!(credentials instanceof channel_credentials_1.ChannelCredentials)) {
|
|
18391
18391
|
throw new TypeError("Channel credentials must be a ChannelCredentials object");
|
|
18392
18392
|
}
|
|
18393
18393
|
if (options) {
|
|
@@ -18669,15 +18669,15 @@ var require_internal_channel = __commonJS({
|
|
|
18669
18669
|
this.lastActivityTimestamp = /* @__PURE__ */ new Date();
|
|
18670
18670
|
this.maybeStartIdleTimer();
|
|
18671
18671
|
}
|
|
18672
|
-
createLoadBalancingCall(callConfig, method, host,
|
|
18672
|
+
createLoadBalancingCall(callConfig, method, host, credentials, deadline) {
|
|
18673
18673
|
const callNumber = (0, call_number_1.getNextCallNumber)();
|
|
18674
18674
|
this.trace("createLoadBalancingCall [" + callNumber + '] method="' + method + '"');
|
|
18675
|
-
return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host,
|
|
18675
|
+
return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, callNumber);
|
|
18676
18676
|
}
|
|
18677
|
-
createRetryingCall(callConfig, method, host,
|
|
18677
|
+
createRetryingCall(callConfig, method, host, credentials, deadline) {
|
|
18678
18678
|
const callNumber = (0, call_number_1.getNextCallNumber)();
|
|
18679
18679
|
this.trace("createRetryingCall [" + callNumber + '] method="' + method + '"');
|
|
18680
|
-
return new retrying_call_1.RetryingCall(this, callConfig, method, host,
|
|
18680
|
+
return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget()));
|
|
18681
18681
|
}
|
|
18682
18682
|
createResolvingCall(method, deadline, host, parentCall, propagateFlags) {
|
|
18683
18683
|
const callNumber = (0, call_number_1.getNextCallNumber)();
|
|
@@ -18793,11 +18793,11 @@ var require_channel = __commonJS({
|
|
|
18793
18793
|
var channel_credentials_1 = require_channel_credentials();
|
|
18794
18794
|
var internal_channel_1 = require_internal_channel();
|
|
18795
18795
|
var ChannelImplementation = class {
|
|
18796
|
-
constructor(target,
|
|
18796
|
+
constructor(target, credentials, options) {
|
|
18797
18797
|
if (typeof target !== "string") {
|
|
18798
18798
|
throw new TypeError("Channel target must be a string");
|
|
18799
18799
|
}
|
|
18800
|
-
if (!(
|
|
18800
|
+
if (!(credentials instanceof channel_credentials_1.ChannelCredentials)) {
|
|
18801
18801
|
throw new TypeError("Channel credentials must be a ChannelCredentials object");
|
|
18802
18802
|
}
|
|
18803
18803
|
if (options) {
|
|
@@ -18805,7 +18805,7 @@ var require_channel = __commonJS({
|
|
|
18805
18805
|
throw new TypeError("Channel options must be an object");
|
|
18806
18806
|
}
|
|
18807
18807
|
}
|
|
18808
|
-
this.internalChannel = new internal_channel_1.InternalChannel(target,
|
|
18808
|
+
this.internalChannel = new internal_channel_1.InternalChannel(target, credentials, options);
|
|
18809
18809
|
}
|
|
18810
18810
|
close() {
|
|
18811
18811
|
this.internalChannel.close();
|
|
@@ -19332,8 +19332,8 @@ var require_server_credentials = __commonJS({
|
|
|
19332
19332
|
return this.childCredentials._getSecureContextOptions();
|
|
19333
19333
|
}
|
|
19334
19334
|
};
|
|
19335
|
-
function createServerCredentialsWithInterceptors(
|
|
19336
|
-
return new InterceptorServerCredentials(
|
|
19335
|
+
function createServerCredentialsWithInterceptors(credentials, interceptors) {
|
|
19336
|
+
return new InterceptorServerCredentials(credentials, interceptors);
|
|
19337
19337
|
}
|
|
19338
19338
|
}
|
|
19339
19339
|
});
|
|
@@ -20729,11 +20729,11 @@ var require_server = __commonJS({
|
|
|
20729
20729
|
experimentalUnregisterListenerFromChannelz(channelzRef) {
|
|
20730
20730
|
(0, channelz_1.unregisterChannelzRef)(channelzRef);
|
|
20731
20731
|
}
|
|
20732
|
-
createHttp2Server(
|
|
20732
|
+
createHttp2Server(credentials) {
|
|
20733
20733
|
let http2Server;
|
|
20734
|
-
if (
|
|
20735
|
-
const constructorOptions =
|
|
20736
|
-
const contextOptions =
|
|
20734
|
+
if (credentials._isSecure()) {
|
|
20735
|
+
const constructorOptions = credentials._getConstructorOptions();
|
|
20736
|
+
const contextOptions = credentials._getSecureContextOptions();
|
|
20737
20737
|
const secureServerOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, this.commonServerOptions), constructorOptions), contextOptions), { enableTrace: this.options["grpc-node.tls_enable_trace"] === 1 });
|
|
20738
20738
|
let areCredentialsValid = contextOptions !== null;
|
|
20739
20739
|
this.trace("Initial credentials valid: " + areCredentialsValid);
|
|
@@ -20762,15 +20762,15 @@ var require_server = __commonJS({
|
|
|
20762
20762
|
areCredentialsValid = options !== null;
|
|
20763
20763
|
this.trace("Post-update credentials valid: " + areCredentialsValid);
|
|
20764
20764
|
};
|
|
20765
|
-
|
|
20765
|
+
credentials._addWatcher(credsWatcher);
|
|
20766
20766
|
http2Server.on("close", () => {
|
|
20767
|
-
|
|
20767
|
+
credentials._removeWatcher(credsWatcher);
|
|
20768
20768
|
});
|
|
20769
20769
|
} else {
|
|
20770
20770
|
http2Server = http2.createServer(this.commonServerOptions);
|
|
20771
20771
|
}
|
|
20772
20772
|
http2Server.setTimeout(0, noop);
|
|
20773
|
-
this._setupHandlers(http2Server,
|
|
20773
|
+
this._setupHandlers(http2Server, credentials._getInterceptors());
|
|
20774
20774
|
return http2Server;
|
|
20775
20775
|
}
|
|
20776
20776
|
bindOneAddress(address, boundPortObject) {
|
|
@@ -21005,14 +21005,14 @@ var require_server = __commonJS({
|
|
|
21005
21005
|
* @param channelzRef
|
|
21006
21006
|
* @returns
|
|
21007
21007
|
*/
|
|
21008
|
-
experimentalCreateConnectionInjectorWithChannelzRef(
|
|
21009
|
-
if (
|
|
21008
|
+
experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef, ownsChannelzRef = false) {
|
|
21009
|
+
if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
|
|
21010
21010
|
throw new TypeError("creds must be a ServerCredentials object");
|
|
21011
21011
|
}
|
|
21012
21012
|
if (this.channelzEnabled) {
|
|
21013
21013
|
this.listenerChildrenTracker.refChild(channelzRef);
|
|
21014
21014
|
}
|
|
21015
|
-
const server2 = this.createHttp2Server(
|
|
21015
|
+
const server2 = this.createHttp2Server(credentials);
|
|
21016
21016
|
const sessionsSet = /* @__PURE__ */ new Set();
|
|
21017
21017
|
this.http2Servers.set(server2, {
|
|
21018
21018
|
channelzRef,
|
|
@@ -21042,12 +21042,12 @@ var require_server = __commonJS({
|
|
|
21042
21042
|
}
|
|
21043
21043
|
};
|
|
21044
21044
|
}
|
|
21045
|
-
createConnectionInjector(
|
|
21046
|
-
if (
|
|
21045
|
+
createConnectionInjector(credentials) {
|
|
21046
|
+
if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
|
|
21047
21047
|
throw new TypeError("creds must be a ServerCredentials object");
|
|
21048
21048
|
}
|
|
21049
21049
|
const channelzRef = this.registerInjectorToChannelz();
|
|
21050
|
-
return this.experimentalCreateConnectionInjectorWithChannelzRef(
|
|
21050
|
+
return this.experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef, true);
|
|
21051
21051
|
}
|
|
21052
21052
|
closeServer(server2, callback) {
|
|
21053
21053
|
this.trace("Closing server with address " + JSON.stringify(server2.address()));
|
|
@@ -24225,8 +24225,8 @@ var GrpcClient = class {
|
|
|
24225
24225
|
this.serviceImpls = serviceImpls;
|
|
24226
24226
|
this.proto = loadProtoFromString(buildProtoString(serviceImpls));
|
|
24227
24227
|
const useSSL = !address.includes("localhost") && !address.includes("127.0.0.1") && !address.includes("0.0.0.0");
|
|
24228
|
-
const
|
|
24229
|
-
this.channel = createChannel(address,
|
|
24228
|
+
const credentials = useSSL ? ChannelCredentials.createSsl() : ChannelCredentials.createInsecure();
|
|
24229
|
+
this.channel = createChannel(address, credentials, {
|
|
24230
24230
|
"grpc.max_receive_message_length": 10 * 1024 * 1024,
|
|
24231
24231
|
"grpc.max_send_message_length": 10 * 1024 * 1024,
|
|
24232
24232
|
"grpc.keepalive_time_ms": 3e4,
|