How to use the firebase-admin.credential.cert function in firebase-admin

To help you get started, we’ve selected a few firebase-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / extensions / firestore-counter / stress_test / bin / driver.ts View on Github external
*    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { initializeApp, credential } from "firebase-admin";
import * as uuid from "uuid";

let serviceAccount = require("../../test-project-key.json");

const app = initializeApp({
  credential: credential.cert(serviceAccount),
  projectId: serviceAccount.project_id,
});

const db = app.firestore();

function range(n: number) {
  return Array.from(Array(n).keys());
}

async function delay(ms: number): Promise {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

async function main() {
  for (let i = 0; i < 100000; i++) {
    const timestamp = Date.now();
github WalletConnect / firebase-walletconnect-push / functions / src / index.ts View on Github external
import {https, Request, config} from 'firebase-functions';
import {initializeApp, credential} from 'firebase-admin';
import { push } from './routes/push';
import { register } from './routes/register';
import cors from 'cors';

import * as serviceAccount from "./service-account.json";

const adminConfig = JSON.parse(process.env.FIREBASE_CONFIG);
adminConfig.credential = credential.cert(serviceAccount as any);
initializeApp(adminConfig);

exports.push = https.onRequest(async (req: Request, res) => {
    cors()(req, res, () => {});  
    if (req.method.toUpperCase() === "OPTIONS") {
      return res;
    }

    let response: IResponse = {
      code: 404, 
      success: false, 
      errorMessage: 'Error: Operation not supported'
    };
  
    if (req.method.toUpperCase() === "POST") {
      switch (req.params[0]) {
github patrickmichalina / fusing-angular-cli / src / modules / firebase / auth / server.auth.module.ts View on Github external
export function fbAdminFactory(es: EnvironmentService) {
  !firebaseAdminAppAlreadyExists() &&
    initializeApp({
      credential: credential.cert({
        projectId: es.config.FIREBASE_PROJECT_ID,
        clientEmail: es.config.SERVER_FIREBASE_CLIENT_EMAIL,
        privateKey: repairInlinePem(es.config.SERVER_FIREBASE_PRIVATE_KEY)
      }),
      databaseURL: es.config.FIREBASE_DATABASE_URL
    })
  return auth()
}