File tree 3 files changed +2
-14
lines changed
3 files changed +2
-14
lines changed Original file line number Diff line number Diff line change @@ -87,9 +87,6 @@ class RecognizeStream extends Duplex {
87
87
private initialized : boolean ;
88
88
private finished : boolean ;
89
89
private socket ;
90
- private authenticated : boolean ;
91
-
92
-
93
90
94
91
/**
95
92
* pipe()-able Node.js Duplex stream - accepts binary audio and emits text/objects in it's `data` events.
@@ -150,9 +147,6 @@ class RecognizeStream extends Duplex {
150
147
this . initialized = false ;
151
148
this . finished = false ;
152
149
153
- // is using iam, another authentication step is needed
154
- this . authenticated = options . token_manager ? false : true ;
155
-
156
150
this . on ( 'newListener' , event => {
157
151
if ( ! options . silent ) {
158
152
if (
@@ -535,14 +529,13 @@ class RecognizeStream extends Duplex {
535
529
* @param {Function } callback
536
530
*/
537
531
setAuthorizationHeaderToken ( callback ) {
538
- if ( ! this . authenticated ) {
532
+ if ( this . options . token_manager ) {
539
533
this . options . token_manager . getToken ( ( err , token ) => {
540
534
if ( err ) {
541
535
callback ( err ) ;
542
536
}
543
537
const authHeader = { authorization : 'Bearer ' + token } ;
544
538
this . options . headers = extend ( authHeader , this . options . headers ) ;
545
- this . authenticated = true ;
546
539
callback ( null ) ;
547
540
} ) ;
548
541
} else {
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ class SynthesizeStream extends Readable {
57
57
private options ;
58
58
private socket ;
59
59
private initialized : boolean ;
60
- private authenticated : boolean ;
61
60
62
61
63
62
/**
@@ -89,7 +88,6 @@ class SynthesizeStream extends Readable {
89
88
super ( options ) ;
90
89
this . options = options ;
91
90
this . initialized = false ;
92
- this . authenticated = options . token_manager ? false : true ;
93
91
}
94
92
95
93
initialize ( ) {
@@ -190,14 +188,13 @@ class SynthesizeStream extends Readable {
190
188
* @param {Function } callback
191
189
*/
192
190
setAuthorizationHeaderToken ( callback ) {
193
- if ( ! this . authenticated ) {
191
+ if ( this . options . token_manager ) {
194
192
this . options . token_manager . getToken ( ( err , token ) => {
195
193
if ( err ) {
196
194
callback ( err ) ;
197
195
}
198
196
const authHeader = { authorization : 'Bearer ' + token } ;
199
197
this . options . headers = extend ( authHeader , this . options . headers ) ;
200
- this . authenticated = true ;
201
198
callback ( null ) ;
202
199
} ) ;
203
200
} else {
Original file line number Diff line number Diff line change @@ -31,15 +31,13 @@ describe('speech_to_text', function() {
31
31
const stream = speech_to_text . recognizeUsingWebSocket ( ) ;
32
32
expect ( stream . options . url ) . toBe ( service . url ) ;
33
33
expect ( stream . options . headers . authorization ) . toBeTruthy ( ) ;
34
- expect ( stream . authenticated ) . toBe ( true ) ;
35
34
expect ( stream . options . token_manager ) . toBeUndefined ( ) ;
36
35
} ) ;
37
36
38
37
it ( 'should create a token manager in RecognizeStream if using IAM' , function ( ) {
39
38
const stream = rc_speech_to_text . recognizeUsingWebSocket ( ) ;
40
39
expect ( stream . options . url ) . toBe ( service . url ) ;
41
40
expect ( stream . options . headers . authorization ) . toBeUndefined ( ) ;
42
- expect ( stream . authenticated ) . toBe ( false ) ;
43
41
expect ( stream . options . token_manager ) . toBeDefined ( ) ;
44
42
} ) ;
45
43
} ) ;
You can’t perform that action at this time.
0 commit comments