@@ -24,6 +24,7 @@ import { EmitterAugmentation1 } from './events';
24
24
import { Metadata } from './metadata' ;
25
25
import { ObjectReadable , ObjectWritable , WriteCallback } from './object-stream' ;
26
26
import { InterceptingCallInterface } from './client-interceptors' ;
27
+ import { AuthContext } from './auth-context' ;
27
28
28
29
/**
29
30
* A type extending the built-in Error object with additional fields.
@@ -37,6 +38,7 @@ export type SurfaceCall = {
37
38
call ?: InterceptingCallInterface ;
38
39
cancel ( ) : void ;
39
40
getPeer ( ) : string ;
41
+ getAuthContext ( ) : AuthContext | null ;
40
42
} & EmitterAugmentation1 < 'metadata' , Metadata > &
41
43
EmitterAugmentation1 < 'status' , StatusObject > &
42
44
EventEmitter ;
@@ -100,6 +102,10 @@ export class ClientUnaryCallImpl
100
102
getPeer ( ) : string {
101
103
return this . call ?. getPeer ( ) ?? 'unknown' ;
102
104
}
105
+
106
+ getAuthContext ( ) : AuthContext | null {
107
+ return this . call ?. getAuthContext ( ) ?? null ;
108
+ }
103
109
}
104
110
105
111
export class ClientReadableStreamImpl < ResponseType >
@@ -119,6 +125,10 @@ export class ClientReadableStreamImpl<ResponseType>
119
125
return this . call ?. getPeer ( ) ?? 'unknown' ;
120
126
}
121
127
128
+ getAuthContext ( ) : AuthContext | null {
129
+ return this . call ?. getAuthContext ( ) ?? null ;
130
+ }
131
+
122
132
_read ( _size : number ) : void {
123
133
this . call ?. startRead ( ) ;
124
134
}
@@ -141,6 +151,10 @@ export class ClientWritableStreamImpl<RequestType>
141
151
return this . call ?. getPeer ( ) ?? 'unknown' ;
142
152
}
143
153
154
+ getAuthContext ( ) : AuthContext | null {
155
+ return this . call ?. getAuthContext ( ) ?? null ;
156
+ }
157
+
144
158
_write ( chunk : RequestType , encoding : string , cb : WriteCallback ) {
145
159
const context : MessageContext = {
146
160
callback : cb ,
@@ -178,6 +192,10 @@ export class ClientDuplexStreamImpl<RequestType, ResponseType>
178
192
return this . call ?. getPeer ( ) ?? 'unknown' ;
179
193
}
180
194
195
+ getAuthContext ( ) : AuthContext | null {
196
+ return this . call ?. getAuthContext ( ) ?? null ;
197
+ }
198
+
181
199
_read ( _size : number ) : void {
182
200
this . call ?. startRead ( ) ;
183
201
}
0 commit comments