From 834a3b50cc06256512b391fec17abe855b4934b3 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Sat, 21 Oct 2017 09:52:57 -0700 Subject: [PATCH] fix(rpc): pass auth credentials into duplex streams --- bin/template/duplex-stream-method.tmpl | 4 +++- bin/template/rpc-prefix.tmpl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/template/duplex-stream-method.tmpl b/bin/template/duplex-stream-method.tmpl index 11e9362..29a8e2a 100644 --- a/bin/template/duplex-stream-method.tmpl +++ b/bin/template/duplex-stream-method.tmpl @@ -1,4 +1,6 @@ --<%= getCommentPrefixing(`rpc ${name}(`) %> public <%= _.lowerFirst(name) %>(): Promise, <%= responseTsType %>>> { - return this.client.getConnection('<%= service %>').then(cnx => ( cnx.client).<%= _.lowerFirst(name) %>()); + return this.client + .getConnection('<%= service %>') + .then(({ client, metadata }) => ( client).<%= _.lowerFirst(name) %>(metadata)); } diff --git a/bin/template/rpc-prefix.tmpl b/bin/template/rpc-prefix.tmpl index 0118f78..b56222d 100644 --- a/bin/template/rpc-prefix.tmpl +++ b/bin/template/rpc-prefix.tmpl @@ -5,7 +5,7 @@ import * as grpc from 'grpc'; export interface ICallable { exec(service: keyof typeof Services, method: string, params: object): Promise; - getConnection(service: keyof typeof Services): Promise<{ client: grpc.Client }>; + getConnection(service: keyof typeof Services): Promise<{ client: grpc.Client, metadata: grpc.Metadata }>; } export interface IResponseStream {