diff --git a/.changeset/sixty-masks-wash.md b/.changeset/sixty-masks-wash.md new file mode 100644 index 00000000000..fbe46843b44 --- /dev/null +++ b/.changeset/sixty-masks-wash.md @@ -0,0 +1,6 @@ +--- +"@firebase/auth": patch +"@firebase/component": patch +--- + +Auto initialize `auth-internal` after `auth` has been initialized. diff --git a/packages/auth/src/exports_auth.js b/packages/auth/src/exports_auth.js index fbbf123818e..9f4ddc000de 100644 --- a/packages/auth/src/exports_auth.js +++ b/packages/auth/src/exports_auth.js @@ -761,7 +761,16 @@ fireauth.exportlib.exportFunction( 'multipleInstances': false, 'serviceProps': namespace, 'instantiationMode': 'LAZY', - 'type': 'PUBLIC' + 'type': 'PUBLIC', + /** + * Initialize auth-internal after auth is initialized to make auth available to other firebase products. + */ + 'onInstanceCreated': function (container, _instanceIdentifier, _instance) { + const authInternalProvider = container['getProvider']( + 'auth-internal' + ); + authInternalProvider['initialize'](); + } }; // Provides Auth internal APIs. diff --git a/packages/component/src/provider.ts b/packages/component/src/provider.ts index 290cead4eaf..716f4c78d63 100644 --- a/packages/component/src/provider.ts +++ b/packages/component/src/provider.ts @@ -251,8 +251,6 @@ export class Provider { } } - this.invokeOnInitCallbacks(instance, normalizedIdentifier); - return instance; } @@ -318,6 +316,13 @@ export class Provider { }); this.instances.set(instanceIdentifier, instance); + /** + * Invoke onInit listeners. + * Note this.component.onInstanceCreated is different, which is used by the component creator, + * while onInit listeners are registered by consumers of the provider. + */ + this.invokeOnInitCallbacks(instance, instanceIdentifier); + /** * Order is important * onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which