Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@forest-fire/utility

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forest-fire/utility - npm Package Compare versions

Comparing version 0.55.3 to 0.55.4

dist/types/admin-sdk/initializeAdminApp.d.ts

44

dist/cjs/index.js

@@ -27,2 +27,10 @@ 'use strict';

}
function isAdminConfig(config) {
return config &&
config.mocking !== true &&
config.apiKey === undefined &&
config.databaseURL !== undefined
? true
: false;
}

@@ -113,2 +121,24 @@ var RealQueryOrderType;

/**
* Initializes Firebase's App (for Admin SDK)
*
* @param fb the `firebase-admin` API surface
* @param config the configuration to use for initialization
*/
function initializeAdminApp(fb, config) {
try {
if (isAdminConfig(config)) {
const credential = fb.credential.cert(config.serviceAccount);
const databaseURL = config.databaseURL;
return fb.initializeApp({ credential, databaseURL });
}
else {
throw new FireError(`Attempt to initialize Firebase App failed because the configuration passed in was not an Admin configuration! The configuration was:\n${JSON.stringify(config, null, 2)}`);
}
}
catch (e) {
throw new FireError(`There were problems initializing the Admin SDK's Firebase App! The error reported was:\n\n${e.message}\n`, 'firebase-app-failed');
}
}
/**
* Returns an array of named apps that are running under

@@ -175,2 +205,5 @@ * Firebase's control (admin API)

/**
* Determines the appropriate App name based on the configuration passed in
*/
function determineDefaultAppName(config) {

@@ -180,7 +213,11 @@ if (!config) {

}
const url = config.databaseURL || process.env.FIREBASE_DATABASE_URL;
if (!url && !config.mocking) {
throw new FireError(`Attempt to determine a default name leverages the database URL property (when a real database connection is used) and it is not present!`, 'not-ready');
}
return config.name
? config.name
: config.databaseURL
? config.databaseURL.replace(/.*https:\W*([\w-]*)\.((.|\n)*)/g, '$1')
: '[DEFAULT]';
: url
? url.replace(/.*https:\W*([\w-]*)\.((.|\n)*)/g, '$1')
: 'mock-db-app-name';
}

@@ -205,3 +242,4 @@

exports.getRunningFirebaseApp = getRunningFirebaseApp;
exports.initializeAdminApp = initializeAdminApp;
exports.looksLikeJson = looksLikeJson;
exports.slashNotation = slashNotation;

@@ -23,2 +23,10 @@ class FireError extends Error {

}
function isAdminConfig(config) {
return config &&
config.mocking !== true &&
config.apiKey === undefined &&
config.databaseURL !== undefined
? true
: false;
}

@@ -109,2 +117,24 @@ var RealQueryOrderType;

/**
* Initializes Firebase's App (for Admin SDK)
*
* @param fb the `firebase-admin` API surface
* @param config the configuration to use for initialization
*/
function initializeAdminApp(fb, config) {
try {
if (isAdminConfig(config)) {
const credential = fb.credential.cert(config.serviceAccount);
const databaseURL = config.databaseURL;
return fb.initializeApp({ credential, databaseURL });
}
else {
throw new FireError(`Attempt to initialize Firebase App failed because the configuration passed in was not an Admin configuration! The configuration was:\n${JSON.stringify(config, null, 2)}`);
}
}
catch (e) {
throw new FireError(`There were problems initializing the Admin SDK's Firebase App! The error reported was:\n\n${e.message}\n`, 'firebase-app-failed');
}
}
/**
* Returns an array of named apps that are running under

@@ -171,2 +201,5 @@ * Firebase's control (admin API)

/**
* Determines the appropriate App name based on the configuration passed in
*/
function determineDefaultAppName(config) {

@@ -176,7 +209,11 @@ if (!config) {

}
const url = config.databaseURL || process.env.FIREBASE_DATABASE_URL;
if (!url && !config.mocking) {
throw new FireError(`Attempt to determine a default name leverages the database URL property (when a real database connection is used) and it is not present!`, 'not-ready');
}
return config.name
? config.name
: config.databaseURL
? config.databaseURL.replace(/.*https:\W*([\w-]*)\.((.|\n)*)/g, '$1')
: '[DEFAULT]';
: url
? url.replace(/.*https:\W*([\w-]*)\.((.|\n)*)/g, '$1')
: 'mock-db-app-name';
}

@@ -192,2 +229,2 @@

export { FireError, determineDefaultAppName, dotNotation, extractClientConfig, extractDataUrl, extractEncodedString, extractServiceAccount, getRunningApps, getRunningFirebaseApp, looksLikeJson, slashNotation };
export { FireError, determineDefaultAppName, dotNotation, extractClientConfig, extractDataUrl, extractEncodedString, extractServiceAccount, getRunningApps, getRunningFirebaseApp, initializeAdminApp, looksLikeJson, slashNotation };
export * from './extractServiceAccount';
export * from './extractDataUrl';
export * from './initializeAdminApp';
import type { IDatabaseConfig } from '@forest-fire/types';
/**
* Determines the appropriate App name based on the configuration passed in
*/
export declare function determineDefaultAppName(config?: IDatabaseConfig): string;

6

package.json
{
"name": "@forest-fire/utility",
"version": "0.55.3",
"version": "0.55.4",
"description": "Utility functions that are shared across the monorepo",

@@ -31,3 +31,3 @@ "module": "dist/es/index.js",

"devDependencies": {
"@forest-fire/types": "^0.55.3",
"@forest-fire/types": "^0.55.4",
"@types/chai": "^4.2.11",

@@ -48,3 +48,3 @@ "@types/mocha": "^7.0.2",

"license": "MIT",
"gitHead": "d2112dd298ed86c2531a7918300b64d20d88e1d6"
"gitHead": "846fcb6e6ca12542d86f2f22b4fbf055d41a6bfe"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc