Skip to content

Commit 56a6a9d

Browse files
authored
auto-init auth-internal after initializing auth (#5071)
* auto-init auth-internal after initializing auth * Create sixty-masks-wash.md
1 parent 1bbdbfe commit 56a6a9d

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.changeset/sixty-masks-wash.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@firebase/auth": patch
3+
"@firebase/component": patch
4+
---
5+
6+
Auto initialize `auth-internal` after `auth` has been initialized.

packages/auth/src/exports_auth.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,16 @@ fireauth.exportlib.exportFunction(
761761
'multipleInstances': false,
762762
'serviceProps': namespace,
763763
'instantiationMode': 'LAZY',
764-
'type': 'PUBLIC'
764+
'type': 'PUBLIC',
765+
/**
766+
* Initialize auth-internal after auth is initialized to make auth available to other firebase products.
767+
*/
768+
'onInstanceCreated': function (container, _instanceIdentifier, _instance) {
769+
const authInternalProvider = container['getProvider'](
770+
'auth-internal'
771+
);
772+
authInternalProvider['initialize']();
773+
}
765774
};
766775

767776
// Provides Auth internal APIs.

packages/component/src/provider.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ export class Provider<T extends Name> {
251251
}
252252
}
253253

254-
this.invokeOnInitCallbacks(instance, normalizedIdentifier);
255-
256254
return instance;
257255
}
258256

@@ -318,6 +316,13 @@ export class Provider<T extends Name> {
318316
});
319317
this.instances.set(instanceIdentifier, instance);
320318

319+
/**
320+
* Invoke onInit listeners.
321+
* Note this.component.onInstanceCreated is different, which is used by the component creator,
322+
* while onInit listeners are registered by consumers of the provider.
323+
*/
324+
this.invokeOnInitCallbacks(instance, instanceIdentifier);
325+
321326
/**
322327
* Order is important
323328
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which

0 commit comments

Comments
 (0)