@grpc/grpc-js
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -121,3 +121,4 @@ "use strict"; | ||
_getConnectionOptions() { | ||
return this.connectionOptions; | ||
// Copy to prevent callers from mutating this.connectionOptions | ||
return Object.assign({}, this.connectionOptions); | ||
} | ||
@@ -124,0 +125,0 @@ _isSecure() { |
@@ -130,3 +130,3 @@ "use strict"; | ||
scheme: 'dns', | ||
path: proxyInfo.address | ||
path: proxyInfo.address, | ||
}, | ||
@@ -176,6 +176,2 @@ extraOptions: extraOptions, | ||
proxyAddressString); | ||
resolve({ | ||
socket, | ||
realTarget: parsedTarget, | ||
}); | ||
if ('secureContext' in connectionOptions) { | ||
@@ -186,5 +182,13 @@ /* The proxy is connecting to a TLS server, so upgrade this socket | ||
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */ | ||
const cts = tls.connect(Object.assign(Object.assign({}, connectionOptions), { host: resolver_1.getDefaultAuthority(parsedTarget), socket: socket }), () => { | ||
const remoteHost = resolver_1.getDefaultAuthority(parsedTarget); | ||
const cts = tls.connect(Object.assign({ host: remoteHost, servername: remoteHost, socket: socket }, connectionOptions), () => { | ||
trace('Successfully established a TLS connection to ' + | ||
options.path + | ||
' through proxy ' + | ||
proxyAddressString); | ||
resolve({ socket: cts, realTarget: parsedTarget }); | ||
}); | ||
cts.on('error', () => { | ||
reject(); | ||
}); | ||
} | ||
@@ -191,0 +195,0 @@ else { |
@@ -54,3 +54,3 @@ /// <reference types="node" /> | ||
sendMetadata(responseMetadata: Metadata): void; | ||
_write(chunk: ResponseType, encoding: string, callback: (...args: any[]) => void): Promise<void>; | ||
_write(chunk: ResponseType, encoding: string, callback: (...args: any[]) => void): void; | ||
_final(callback: Function): void; | ||
@@ -122,3 +122,3 @@ end(metadata?: any): void; | ||
serializeMessage(value: ResponseType): Buffer; | ||
deserializeMessage(bytes: Buffer): Promise<RequestType>; | ||
deserializeMessage(bytes: Buffer): RequestType; | ||
sendUnaryMessage(err: ServerErrorResponse | ServerStatusResponse | null, value: ResponseType | null, metadata?: Metadata, flags?: number): Promise<void>; | ||
@@ -125,0 +125,0 @@ sendStatus(statusObj: StatusObject): void; |
@@ -112,7 +112,7 @@ "use strict"; | ||
} | ||
async _write(chunk, encoding, | ||
_write(chunk, encoding, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
callback) { | ||
try { | ||
const response = await this.call.serializeMessage(chunk); | ||
const response = this.call.serializeMessage(chunk); | ||
if (!this.call.write(response)) { | ||
@@ -280,3 +280,3 @@ this.call.once('drain', callback); | ||
} | ||
resolve(await this.deserializeMessage(requestBytes)); | ||
resolve(this.deserializeMessage(requestBytes)); | ||
} | ||
@@ -301,3 +301,3 @@ catch (err) { | ||
} | ||
async deserializeMessage(bytes) { | ||
deserializeMessage(bytes) { | ||
// TODO(cjihrig): Call compression aware deserializeMessage(). | ||
@@ -322,3 +322,3 @@ const receivedMessage = bytes.slice(5); | ||
try { | ||
const response = await this.serializeMessage(value); | ||
const response = this.serializeMessage(value); | ||
this.write(response); | ||
@@ -325,0 +325,0 @@ this.sendStatus({ code: constants_1.Status.OK, details: 'OK', metadata }); |
@@ -233,3 +233,3 @@ "use strict"; | ||
} | ||
connectionOptions = Object.assign(connectionOptions, this.subchannelAddress); | ||
connectionOptions = Object.assign(Object.assign({}, connectionOptions), this.subchannelAddress); | ||
/* http2.connect uses the options here: | ||
@@ -236,0 +236,0 @@ * https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036 |
{ | ||
"name": "@grpc/grpc-js", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "gRPC Library for Node - pure JS implementation", | ||
@@ -5,0 +5,0 @@ "homepage": "https://grpc.io/", |
@@ -214,3 +214,4 @@ /* | ||
_getConnectionOptions(): ConnectionOptions | null { | ||
return this.connectionOptions; | ||
// Copy to prevent callers from mutating this.connectionOptions | ||
return { ...this.connectionOptions }; | ||
} | ||
@@ -217,0 +218,0 @@ _isSecure(): boolean { |
@@ -150,5 +150,5 @@ /* | ||
return { | ||
target: { | ||
target: { | ||
scheme: 'dns', | ||
path: proxyInfo.address | ||
path: proxyInfo.address, | ||
}, | ||
@@ -211,6 +211,2 @@ extraOptions: extraOptions, | ||
); | ||
resolve({ | ||
socket, | ||
realTarget: parsedTarget, | ||
}); | ||
if ('secureContext' in connectionOptions) { | ||
@@ -221,10 +217,24 @@ /* The proxy is connecting to a TLS server, so upgrade this socket | ||
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */ | ||
const cts = tls.connect({ | ||
const remoteHost = getDefaultAuthority(parsedTarget); | ||
const cts = tls.connect( | ||
{ | ||
host: remoteHost, | ||
servername: remoteHost, | ||
socket: socket, | ||
...connectionOptions, | ||
host: getDefaultAuthority(parsedTarget), | ||
socket: socket, | ||
}, () => { | ||
}, | ||
() => { | ||
trace( | ||
'Successfully established a TLS connection to ' + | ||
options.path + | ||
' through proxy ' + | ||
proxyAddressString | ||
); | ||
resolve({ socket: cts, realTarget: parsedTarget }); | ||
} | ||
); | ||
cts.on('error', () => { | ||
reject(); | ||
}); | ||
} else { | ||
@@ -231,0 +241,0 @@ resolve({ |
@@ -175,3 +175,3 @@ /* | ||
async _write( | ||
_write( | ||
chunk: ResponseType, | ||
@@ -183,3 +183,3 @@ encoding: string, | ||
try { | ||
const response = await this.call.serializeMessage(chunk); | ||
const response = this.call.serializeMessage(chunk); | ||
@@ -459,3 +459,3 @@ if (!this.call.write(response)) { | ||
resolve(await this.deserializeMessage(requestBytes)); | ||
resolve(this.deserializeMessage(requestBytes)); | ||
} catch (err) { | ||
@@ -482,3 +482,3 @@ err.code = Status.INTERNAL; | ||
async deserializeMessage(bytes: Buffer) { | ||
deserializeMessage(bytes: Buffer) { | ||
// TODO(cjihrig): Call compression aware deserializeMessage(). | ||
@@ -512,3 +512,3 @@ const receivedMessage = bytes.slice(5); | ||
try { | ||
const response = await this.serializeMessage(value!); | ||
const response = this.serializeMessage(value!); | ||
@@ -515,0 +515,0 @@ this.write(response); |
@@ -325,6 +325,7 @@ /* | ||
connectionOptions = Object.assign( | ||
connectionOptions, | ||
this.subchannelAddress | ||
); | ||
connectionOptions = { | ||
...connectionOptions, | ||
...this.subchannelAddress, | ||
}; | ||
/* http2.connect uses the options here: | ||
@@ -331,0 +332,0 @@ * https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
890200
18692