@@ -30,7 +30,8 @@ import { base64Decode } from '@firebase/util';
30
30
31
31
export class FirebaseServerAppImpl
32
32
extends FirebaseAppImpl
33
- implements FirebaseServerApp {
33
+ implements FirebaseServerApp
34
+ {
34
35
private readonly _serverConfig : FirebaseServerAppSettings ;
35
36
private _finalizationRegistry : FinalizationRegistry < object > | null ;
36
37
private _refCount : number ;
@@ -69,17 +70,20 @@ export class FirebaseServerAppImpl
69
70
} ;
70
71
71
72
// Parse the installationAuthToken if provided.
73
+ this . _installationsId = null ;
72
74
if ( this . _serverConfig . installationsAuthToken !== undefined ) {
73
- const thirdPart = this . _serverConfig . installationsAuthToken . split ( "." ) [ 1 ] . split ( "." ) [ 0 ] ;
74
- const decodedToken = base64Decode ( thirdPart ) ;
75
- const tokenJSON = JSON . parse ( decodedToken ? decodedToken : "" ) ;
76
- if ( ! decodedToken || ! tokenJSON || tokenJSON . fid === undefined ) {
77
- throw ERROR_FACTORY . create ( AppError . INVALID_SERVER_APP_INSTALLATIONS_AUTH_TOKEN ) ;
78
- } else {
75
+ try {
76
+ const decodedToken = base64Decode (
77
+ this . _serverConfig . installationsAuthToken . split ( '.' ) [ 1 ]
78
+ ) ;
79
+ const tokenJSON = JSON . parse ( decodedToken ? decodedToken : '' ) ;
79
80
this . _installationsId = tokenJSON . fid ;
81
+ } catch ( e ) {
82
+ console . warn ( e ) ;
83
+ }
84
+ if ( ! this . _installationsId ) {
85
+ console . error ( 'INVALID SERVER APP INSTALLATIONS AUTH TOKEN!' ) ;
80
86
}
81
- } else {
82
- this . _installationsId = null ;
83
87
}
84
88
85
89
this . _finalizationRegistry = null ;
0 commit comments