Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function registerStorage(instance: _FirebaseNamespace): void {
const namespaceExports = {
// no-inline
TaskState,
TaskEvent,
StringFormat,
Storage: Service,
Reference
};
instance.INTERNAL.registerComponent(
new Component(STORAGE_TYPE, factory, ComponentType.PUBLIC)
.setServiceProps(namespaceExports)
.setMultipleInstances(true)
);
instance.registerVersion(name, version);
}
// Register performance with firebase-app.
(instance as _FirebaseNamespace).INTERNAL.registerComponent(
new Component(
'performance',
container => {
/* Dependencies */
// getImmediate for FirebaseApp will always succeed
const app = container.getProvider('app').getImmediate();
// The following call will always succeed because perf has `import '@firebase/installations'`
const installations = container
.getProvider('installations')
.getImmediate();
return factoryMethod(app, installations);
},
ComponentType.PUBLIC
)
);
instance.registerVersion(name, version);
}
return new SwController(firebaseServices);
} else {
// Assume we are in the window context.
return new WindowController(firebaseServices);
}
};
const namespaceExports = {
isSupported
};
instance.INTERNAL.registerComponent(
new Component(
messagingName,
factoryMethod,
ComponentType.PUBLIC
).setServiceProps(namespaceExports)
);
instance.registerVersion(name, version);
}
constructor(
options: FirebaseOptions,
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(
export function registerRemoteConfig(
firebaseInstance: _FirebaseNamespace
): void {
firebaseInstance.INTERNAL.registerComponent(
new Component(
'remoteConfig',
remoteConfigFactory,
ComponentType.PUBLIC
).setMultipleInstances(true)
);
firebaseInstance.registerVersion(packageName, version);
function remoteConfigFactory(
container: ComponentContainer,
namespace?: string
): RemoteConfig {
/* Dependencies */
// getImmediate for FirebaseApp will always succeed
const app = container.getProvider('app').getImmediate();
// The following call will always succeed because rc has `import '@firebase/installations'`
const installations = container.getProvider('installations').getImmediate();
// Guards against the SDK being used in non-browser environments.
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
new Component(
'database',
(container, url) => {
/* Dependencies */
// getImmediate for FirebaseApp will always succeed
const app = container.getProvider('app').getImmediate();
const authProvider = container.getProvider('auth-internal');
return RepoManager.getInstance().databaseFromApp(
app,
authProvider,
url
);
},
ComponentType.PUBLIC
)
.setServiceProps(
// firebase.database namespace properties
{
Reference,
Query,
Database,
DataSnapshot,
enableLogging,
INTERNAL,
ServerValue,
TEST_ACCESS
}
)
.setMultipleInstances(true)
);
const appConfig = extractAppConfig(app);
const platformLoggerProvider = container.getProvider('platform-logger');
const dependencies: FirebaseDependencies = {
appConfig,
platformLoggerProvider
};
return {
app,
getId: () => getId(dependencies),
getToken: (forceRefresh?: boolean) =>
getToken(dependencies, forceRefresh),
delete: () => deleteInstallation(dependencies)
};
},
ComponentType.PUBLIC
)
);
instance.registerVersion(name, version);
}