File tree 2 files changed +5
-2
lines changed 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ function createUnsecuredJwt(auth: object): string {
63
63
( auth as any ) . iat = ( auth as any ) . iat || 0 ;
64
64
// Use `uid` field as a backup when `sub` is missing.
65
65
( auth as any ) . sub = ( auth as any ) . sub || ( auth as any ) . uid ;
66
+ if ( ! ( auth as any ) . sub ) {
67
+ throw new Error ( "auth must be an object with a 'sub' or 'uid' field" ) ;
68
+ }
66
69
// Unsecured JWTs use the empty string as a signature.
67
70
const signature = '' ;
68
71
return [
Original file line number Diff line number Diff line change @@ -117,9 +117,9 @@ describe('Testing Module Tests', function() {
117
117
118
118
it ( 'apps() returns apps created with initializeTestApp' , async function ( ) {
119
119
const numApps = firebase . apps ( ) . length ;
120
- await firebase . initializeTestApp ( { databaseName : 'foo' , auth : { } } ) ;
120
+ await firebase . initializeTestApp ( { databaseName : 'foo' , auth : null } ) ;
121
121
expect ( firebase . apps ( ) . length ) . to . equal ( numApps + 1 ) ;
122
- await firebase . initializeTestApp ( { databaseName : 'bar' , auth : { } } ) ;
122
+ await firebase . initializeTestApp ( { databaseName : 'bar' , auth : null } ) ;
123
123
expect ( firebase . apps ( ) . length ) . to . equal ( numApps + 2 ) ;
124
124
} ) ;
125
125
You can’t perform that action at this time.
0 commit comments