Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/sixty-masks-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/auth": patch
"@firebase/component": patch
---

Auto initialize `auth-internal` after `auth` has been initialized.
11 changes: 10 additions & 1 deletion packages/auth/src/exports_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions packages/component/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ export class Provider<T extends Name> {
}
}

this.invokeOnInitCallbacks(instance, normalizedIdentifier);

return instance;
}

Expand Down Expand Up @@ -318,6 +316,13 @@ export class Provider<T extends Name> {
});
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
Expand Down