@grpc/grpc-js
Advanced tools
Comparing version 0.6.12 to 0.6.13
@@ -115,3 +115,8 @@ "use strict"; | ||
ConnectivityState.READY) { | ||
pickResult.subchannel.startCallStream(finalMetadata, callStream); | ||
try { | ||
pickResult.subchannel.startCallStream(finalMetadata, callStream); | ||
} | ||
catch (error) { | ||
callStream.cancelWithStatus(constants_1.Status.UNAVAILABLE, 'Failed to start call on picked subchannel'); | ||
} | ||
} | ||
@@ -118,0 +123,0 @@ else { |
@@ -17,6 +17,6 @@ /// <reference types="node" /> | ||
getRequestMetadata: (url: string, callback: (err: Error | null, headers?: { | ||
Authorization: string; | ||
[index: string]: string; | ||
}) => void) => void; | ||
getRequestHeaders: (url?: string) => Promise<{ | ||
Authorization: string; | ||
[index: string]: string; | ||
}>; | ||
@@ -39,3 +39,3 @@ } | ||
export declare const closeClient: (client: Client) => void; | ||
export declare const waitForClientReady: (client: Client, deadline: Deadline, callback: (error?: Error | undefined) => void) => void; | ||
export declare const waitForClientReady: (client: Client, deadline: number | Date, callback: (error?: Error | undefined) => void) => void; | ||
export { ChannelCredentials, CallCredentials, Deadline, Serialize as serialize, Deserialize as deserialize, ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream, CallOptions, StatusObject, ServiceError, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream, ServiceDefinition, UntypedHandleCall, UntypedServiceImplementation, }; | ||
@@ -42,0 +42,0 @@ /**** Server ****/ |
@@ -90,3 +90,5 @@ "use strict"; | ||
const metadata = new metadata_1.Metadata(); | ||
metadata.add('authorization', headers.Authorization); | ||
for (const key of Object.keys(headers)) { | ||
metadata.add(key, headers[key]); | ||
} | ||
callback(null, metadata); | ||
@@ -93,0 +95,0 @@ }, err => { |
@@ -32,2 +32,5 @@ "use strict"; | ||
} | ||
function isCustomMetadata(key) { | ||
return !key.startsWith('grpc-'); | ||
} | ||
function normalizeKey(key) { | ||
@@ -217,5 +220,10 @@ return key.toLowerCase(); | ||
else if (values !== undefined) { | ||
values.split(',').forEach(v => { | ||
result.add(key, Buffer.from(v.trim(), 'base64')); | ||
}); | ||
if (isCustomMetadata(key)) { | ||
values.split(',').forEach(v => { | ||
result.add(key, Buffer.from(v.trim(), 'base64')); | ||
}); | ||
} | ||
else { | ||
result.add(key, Buffer.from(values, 'base64')); | ||
} | ||
} | ||
@@ -230,3 +238,8 @@ } | ||
else if (values !== undefined) { | ||
values.split(',').forEach(v => result.add(key, v.trim())); | ||
if (isCustomMetadata(key)) { | ||
values.split(',').forEach(v => result.add(key, v.trim())); | ||
} | ||
else { | ||
result.add(key, values); | ||
} | ||
} | ||
@@ -233,0 +246,0 @@ } |
@@ -94,9 +94,9 @@ "use strict"; | ||
* want the first one that matches the target string, if any do. */ | ||
const match = IPV4_REGEX.exec(target) || | ||
IPV6_REGEX.exec(target) || | ||
IPV6_BRACKET_REGEX.exec(target); | ||
const ipv4Match = IPV4_REGEX.exec(target); | ||
const match = ipv4Match || IPV6_REGEX.exec(target) || IPV6_BRACKET_REGEX.exec(target); | ||
if (match === null) { | ||
return null; | ||
} | ||
const addr = match[1]; | ||
// ipv6 addresses should be bracketed | ||
const addr = ipv4Match ? match[1] : `[${match[1]}]`; | ||
let port; | ||
@@ -103,0 +103,0 @@ if (match[2]) { |
{ | ||
"name": "@grpc/grpc-js", | ||
"version": "0.6.12", | ||
"version": "0.6.13", | ||
"description": "gRPC Library for Node - pure JS implementation", | ||
@@ -5,0 +5,0 @@ "homepage": "https://grpc.io/", |
@@ -219,6 +219,13 @@ /* | ||
) { | ||
pickResult.subchannel!.startCallStream( | ||
finalMetadata, | ||
callStream | ||
); | ||
try { | ||
pickResult.subchannel!.startCallStream( | ||
finalMetadata, | ||
callStream | ||
); | ||
} catch (error) { | ||
callStream.cancelWithStatus( | ||
Status.UNAVAILABLE, | ||
'Failed to start call on picked subchannel' | ||
); | ||
} | ||
} else { | ||
@@ -225,0 +232,0 @@ callStream.cancelWithStatus( |
@@ -88,7 +88,7 @@ /* | ||
headers?: { | ||
Authorization: string; | ||
[index: string]: string; | ||
} | ||
) => void | ||
) => void; | ||
getRequestHeaders: (url?: string) => Promise<{ Authorization: string }>; | ||
getRequestHeaders: (url?: string) => Promise<{ [index: string]: string }>; | ||
} | ||
@@ -113,3 +113,3 @@ | ||
// but has getRequestMetadata, which is deprecated in v2.0.0 | ||
let getHeaders: Promise<{ Authorization: string }>; | ||
let getHeaders: Promise<{ [index: string]: string }>; | ||
if (typeof googleCredentials.getRequestHeaders === 'function') { | ||
@@ -136,3 +136,5 @@ getHeaders = googleCredentials.getRequestHeaders( | ||
const metadata = new Metadata(); | ||
metadata.add('authorization', headers.Authorization); | ||
for (const key of Object.keys(headers)) { | ||
metadata.add(key, headers[key]); | ||
} | ||
callback(null, metadata); | ||
@@ -139,0 +141,0 @@ }, |
@@ -39,2 +39,6 @@ /* | ||
function isCustomMetadata(key: string): boolean { | ||
return !key.startsWith('grpc-'); | ||
} | ||
function normalizeKey(key: string): string { | ||
@@ -264,5 +268,9 @@ return key.toLowerCase(); | ||
} else if (values !== undefined) { | ||
values.split(',').forEach(v => { | ||
result.add(key, Buffer.from(v.trim(), 'base64')); | ||
}); | ||
if (isCustomMetadata(key)) { | ||
values.split(',').forEach(v => { | ||
result.add(key, Buffer.from(v.trim(), 'base64')); | ||
}); | ||
} else { | ||
result.add(key, Buffer.from(values, 'base64')); | ||
} | ||
} | ||
@@ -275,3 +283,7 @@ } else { | ||
} else if (values !== undefined) { | ||
values.split(',').forEach(v => result.add(key, v.trim())); | ||
if (isCustomMetadata(key)) { | ||
values.split(',').forEach(v => result.add(key, v.trim())); | ||
} else { | ||
result.add(key, values); | ||
} | ||
} | ||
@@ -278,0 +290,0 @@ } |
@@ -118,10 +118,11 @@ /* | ||
* want the first one that matches the target string, if any do. */ | ||
const ipv4Match = IPV4_REGEX.exec(target); | ||
const match = | ||
IPV4_REGEX.exec(target) || | ||
IPV6_REGEX.exec(target) || | ||
IPV6_BRACKET_REGEX.exec(target); | ||
ipv4Match || IPV6_REGEX.exec(target) || IPV6_BRACKET_REGEX.exec(target); | ||
if (match === null) { | ||
return null; | ||
} | ||
const addr = match[1]; | ||
// ipv6 addresses should be bracketed | ||
const addr = ipv4Match ? match[1] : `[${match[1]}]`; | ||
let port: string; | ||
@@ -128,0 +129,0 @@ if (match[2]) { |
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
732172
15470