16
16
*/
17
17
import firebase from '@firebase/app' ;
18
18
import { _FirebaseNamespace } from '@firebase/app-types/private' ;
19
- import { Component , ComponentType } from '@firebase/component' ;
19
+ import {
20
+ Component ,
21
+ ComponentType ,
22
+ InstantiationMode
23
+ } from '@firebase/component' ;
20
24
import {
21
25
FirebaseAppCheck ,
22
26
AppCheckComponentName
@@ -41,6 +45,26 @@ function registerAppCheck(firebase: _FirebaseNamespace): void {
41
45
} ,
42
46
ComponentType . PUBLIC
43
47
)
48
+ /**
49
+ * AppCheck can only be initialized by explicitly calling firebase.appCheck()
50
+ * We don't want firebase products that consume AppCheck to gate on AppCheck
51
+ * if the user doesn't intend them to, just because the AppCheck component
52
+ * is registered.
53
+ */
54
+ . setInstantiationMode ( InstantiationMode . EXPLICIT )
55
+ /**
56
+ * Because all firebase products that depend on app-check depend on app-check-internal directly,
57
+ * we need to initialize app-check-internal after app-check is initialized to make it
58
+ * available to other firebase products.
59
+ */
60
+ . setInstanceCreatedCallback (
61
+ ( container , _instanceIdentifier , _instance ) => {
62
+ const appCheckInternalProvider = container . getProvider (
63
+ APP_CHECK_NAME_INTERNAL
64
+ ) ;
65
+ appCheckInternalProvider . initialize ( ) ;
66
+ }
67
+ )
44
68
) ;
45
69
46
70
// The internal interface used by other Firebase products
@@ -54,7 +78,7 @@ function registerAppCheck(firebase: _FirebaseNamespace): void {
54
78
return internalFactory ( app , platformLoggerProvider ) ;
55
79
} ,
56
80
ComponentType . PUBLIC
57
- )
81
+ ) . setInstantiationMode ( InstantiationMode . EXPLICIT )
58
82
) ;
59
83
60
84
firebase . registerVersion ( name , version ) ;
0 commit comments