@@ -341,7 +341,8 @@ describe('FirebaseTokenVerifier', () => {
341
341
} ) ;
342
342
343
343
return tokenVerifier . verifyJWT ( mockIdToken )
344
- . should . eventually . be . rejectedWith ( 'Firebase ID token has "sub" (subject) claim longer than 128 characters' ) ;
344
+ . should . eventually . be . rejectedWith ( 'Firebase ID token has a "sub" (subject) claim longer than 128 ' +
345
+ 'characters' ) ;
345
346
} ) ;
346
347
} ) ;
347
348
@@ -659,7 +660,7 @@ describe('FirebaseTokenVerifier', () => {
659
660
660
661
return authBlockingTokenVerifier . _verifyAuthBlockingToken ( mockAuthBlockingToken , false , undefined )
661
662
. should . eventually . be . rejectedWith (
662
- 'Firebase Auth Blocking token has "sub" (subject) claim longer than 128 characters' ) ;
663
+ 'Firebase Auth Blocking token has a "sub" (subject) claim longer than 128 characters' ) ;
663
664
} ) ;
664
665
} ) ;
665
666
@@ -780,5 +781,41 @@ describe('FirebaseTokenVerifier', () => {
780
781
await authBlockingTokenVerifier . _verifyAuthBlockingToken ( idTokenNoHeader , false , undefined )
781
782
. should . eventually . be . rejectedWith ( 'Firebase Auth Blocking token has no "kid" claim.' ) ;
782
783
} ) ;
784
+
785
+ const eventTypesWithoutUid = [ 'beforeSendSms' , 'beforeSendEmail' ] ;
786
+ eventTypesWithoutUid . forEach ( ( eventType ) => {
787
+ it ( 'should not throw error on invalid `sub` when event_type is "' + eventType + '"' , async ( ) => {
788
+ const verifierStub = sinon . stub ( PublicKeySignatureVerifier . prototype , 'verify' )
789
+ . resolves ( ) ;
790
+ stubs . push ( verifierStub ) ;
791
+
792
+ const mockAuthBlockingToken = mocks . generateAuthBlockingToken ( {
793
+ subject : ''
794
+ } , {
795
+ event_type : eventType ,
796
+ } ) ;
797
+ return authBlockingTokenVerifier . _verifyAuthBlockingToken ( mockAuthBlockingToken , false , undefined )
798
+ . should . eventually . be . fulfilled ;
799
+ } ) ;
800
+ } ) ;
801
+
802
+ const eventTypesWithUid = [ 'beforeCreate' , 'beforeSignIn' , undefined ] ;
803
+ eventTypesWithUid . forEach ( ( eventType ) => {
804
+ it ( 'should not throw error on invalid `sub` when event_type is "' + eventType + '"' , async ( ) => {
805
+ const verifierStub = sinon . stub ( PublicKeySignatureVerifier . prototype , 'verify' )
806
+ . resolves ( ) ;
807
+ stubs . push ( verifierStub ) ;
808
+
809
+ const mockAuthBlockingToken = mocks . generateAuthBlockingToken ( {
810
+ subject : ''
811
+ } , {
812
+ event_type : eventType ,
813
+ } ) ;
814
+ return authBlockingTokenVerifier . _verifyAuthBlockingToken ( mockAuthBlockingToken , false , undefined )
815
+ . should . eventually . be . rejectedWith ( 'Firebase Auth Blocking token has an empty "sub" (subject) claim.' +
816
+ ' See https://cloud.google.com/identity-platform/docs/blocking-functions for details on how to retrieve an' +
817
+ ' Auth Blocking token.' ) ;
818
+ } ) ;
819
+ } ) ;
783
820
} ) ;
784
821
} ) ;
0 commit comments