Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config: FirebaseAppConfig,
private readonly firebase_: _FirebaseNamespace
) {
this.name_ = config.name!;
this.automaticDataCollectionEnabled_ =
config.automaticDataCollectionEnabled || false;
this.options_ = deepCopy(options);
this.container = new ComponentContainer(config.name!);
// add itself to container
this._addComponent(new Component('app', () => this, ComponentType.PUBLIC));
this._addComponent(
new Component(
'platform-logger',
container => new PlatformLoggerService(container),
ComponentType.PRIVATE
)
);
this._addComponent(
new Component(
'app-version',
() => new VersionService('app', version),
ComponentType.VERSION
)
);
this._addComponent(
new Component(
'platform-identifier',
// Adds a string identifying version header as belonging to JS SDK
() => new VersionService('fire-js', ''),
ComponentType.VERSION
)
* Create a 'auth-internal' component using firebase-admin-node's implementation
* that implements FirebaseAuthInternal.
* ComponentContainer('database-admin') is just a placeholder that doesn't perform
* any actual function.
*/
const authProvider = new Provider(
'auth-internal',
new ComponentContainer('database-admin')
);
authProvider.setComponent(
new Component(
'auth-internal',
// firebase-admin-node's app.INTERNAL implements FirebaseAuthInternal interface
// eslint-disable-next-line @typescript-eslint/no-explicit-any
() => (app as any).INTERNAL,
ComponentType.PRIVATE
)
);
return {
instance: RepoManager.getInstance().databaseFromApp(app, authProvider, url),
namespace: {
Reference,
Query,
Database,
DataSnapshot,
enableLogging,
INTERNAL,
ServerValue,
TEST_ACCESS
}
};
export function registerCoreComponents(
firebase: FirebaseNamespace,
variant?: string
): void {
(firebase as _FirebaseNamespace).INTERNAL.registerComponent(
new Component(
'platform-logger',
container => new PlatformLoggerService(container),
ComponentType.PRIVATE
)
);
// Register `app` package.
firebase.registerVersion(name, version, variant);
// Register platform SDK identifier (no version).
firebase.registerVersion('fire-js', '');
}
export function getFakeDependencies(): FirebaseDependencies {
const container = new ComponentContainer('test');
container.addComponent(
new Component(
'platform-logger',
() => ({ getPlatformInfoString: () => 'a/1.2.3 b/2.3.4' }),
ComponentType.PRIVATE
)
);
return {
appConfig: getFakeAppConfig(),
platformLoggerProvider: container.getProvider('platform-logger')
};
}