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

firebase-admin

Package Overview
Dependencies
Maintainers
4
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-admin - npm Package Compare versions

Comparing version 12.2.0 to 12.3.0

2

lib/app-check/app-check-api-client-internal.d.ts

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -191,3 +191,3 @@ /*!

.catch((err) => {
const detail = (err instanceof api_request_1.HttpError) ? getDetailFromResponse(err.response) : err.message;
const detail = (err instanceof api_request_1.RequestResponseError) ? getDetailFromResponse(err.response) : err.message;
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, `Failed to determine project ID: ${detail}`);

@@ -207,3 +207,3 @@ });

.catch((err) => {
const detail = (err instanceof api_request_1.HttpError) ? getDetailFromResponse(err.response) : err.message;
const detail = (err instanceof api_request_1.RequestResponseError) ? getDetailFromResponse(err.response) : err.message;
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, `Failed to determine service account email: ${detail}`);

@@ -462,3 +462,3 @@ });

function getErrorMessage(err) {
const detail = (err instanceof api_request_1.HttpError) ? getDetailFromResponse(err.response) : err.message;
const detail = (err instanceof api_request_1.RequestResponseError) ? getDetailFromResponse(err.response) : err.message;
return `Error fetching access token: ${detail}`;

@@ -465,0 +465,0 @@ }

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
import { ProjectConfig, UpdateProjectConfigRequest } from './project-config';

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
import { SmsRegionConfig, MultiFactorConfig, MultiFactorAuthServerConfig, RecaptchaConfig, PasswordPolicyAuthServerConfig, PasswordPolicyConfig, EmailPrivacyConfig } from './auth-config';

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2019 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2019 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -227,3 +227,3 @@ /*!

handleError(err) {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
return new error_1.FirebaseDatabaseError({

@@ -230,0 +230,0 @@ code: error_1.AppErrorCodes.INTERNAL_ERROR,

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -87,3 +87,3 @@ /*!

catch (err) {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
if (err.response.status === 404) {

@@ -142,3 +142,3 @@ // if no task with the provided ID exists, then ignore the delete.

catch (err) {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
if (err.response.status === 409) {

@@ -145,0 +145,0 @@ throw new FirebaseFunctionsError('task-already-exists', `A task with ID ${opts?.id} already exists`);

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -83,3 +83,3 @@ /*!

.catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
const response = err.response;

@@ -86,0 +86,0 @@ const errorMessage = (response.isJson() && 'error' in response.data) ?

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
import { App } from '../app/index';

@@ -3,0 +3,0 @@ import { InstanceId as TInstanceId } from './instance-id';

@@ -1,3 +0,3 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -17,3 +17,3 @@ * Copyright 2019 Google Inc.

*/
import { HttpClient, HttpResponse } from '../utils/api-request';
import { HttpClient, RequestResponse } from '../utils/api-request';
/**

@@ -49,3 +49,3 @@ * Represents a request that can be sent as part of an HTTP batch request.

* Sends the given array of sub requests as a single batch, and parses the results into an array
* of HttpResponse objects.
* of `RequestResponse` objects.
*

@@ -55,4 +55,4 @@ * @param requests - An array of sub requests to send.

*/
send(requests: SubRequest[]): Promise<HttpResponse[]>;
send(requests: SubRequest[]): Promise<RequestResponse[]>;
private getMultipartPayload;
}

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -45,3 +45,3 @@ /*!

* Sends the given array of sub requests as a single batch, and parses the results into an array
* of HttpResponse objects.
* of `RequestResponse` objects.
*

@@ -48,0 +48,0 @@ * @param requests - An array of sub requests to send.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -19,2 +19,3 @@ * @license

import { App } from '../app';
import { Http2SessionHandler } from '../utils/api-request';
import { SubRequest } from './batch-request-internal';

@@ -27,2 +28,3 @@ import { SendResponse, BatchResponse } from './messaging-api';

private readonly httpClient;
private readonly http2Client;
private readonly batchClient;

@@ -44,3 +46,3 @@ /**

/**
* Invokes the request handler with the provided request data.
* Invokes the HTTP/1.1 request handler with the provided request data.
*

@@ -52,6 +54,15 @@ * @param host - The host to which to send the request.

*/
invokeRequestHandlerForSendResponse(host: string, path: string, requestData: object): Promise<SendResponse>;
invokeHttpRequestHandlerForSendResponse(host: string, path: string, requestData: object): Promise<SendResponse>;
/**
* Invokes the HTTP/2 request handler with the provided request data.
*
* @param host - The host to which to send the request.
* @param path - The path to which to send the request.
* @param requestData - The request data.
* @returns A promise that resolves with the {@link SendResponse}.
*/
invokeHttp2RequestHandlerForSendResponse(host: string, path: string, requestData: object, http2SessionHandler: Http2SessionHandler): Promise<SendResponse>;
/**
* Sends the given array of sub requests as a single batch to FCM, and parses the result into
* a BatchResponse object.
* a `BatchResponse` object.
*

@@ -58,0 +69,0 @@ * @param requests - An array of sub requests to send.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -46,2 +46,3 @@ /*!

this.httpClient = new api_request_1.AuthorizedHttpClient(app);
this.http2Client = new api_request_1.AuthorizedHttp2Client(app);
this.batchClient = new batch_request_internal_1.BatchRequestClient(this.httpClient, FIREBASE_MESSAGING_BATCH_URL, FIREBASE_MESSAGING_HEADERS);

@@ -68,3 +69,3 @@ }

if (!response.isJson()) {
throw new api_request_1.HttpError(response);
throw new api_request_1.RequestResponseError(response);
}

@@ -74,3 +75,3 @@ // Check for backend errors in the response.

if (errorCode) {
throw new api_request_1.HttpError(response);
throw new api_request_1.RequestResponseError(response);
}

@@ -81,3 +82,3 @@ // Return entire response.

.catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
throw (0, messaging_errors_internal_1.createFirebaseError)(err);

@@ -90,3 +91,3 @@ }

/**
* Invokes the request handler with the provided request data.
* Invokes the HTTP/1.1 request handler with the provided request data.
*

@@ -98,3 +99,3 @@ * @param host - The host to which to send the request.

*/
invokeRequestHandlerForSendResponse(host, path, requestData) {
invokeHttpRequestHandlerForSendResponse(host, path, requestData) {
const request = {

@@ -111,3 +112,3 @@ method: FIREBASE_MESSAGING_HTTP_METHOD,

.catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
return this.buildSendResponseFromError(err);

@@ -120,4 +121,32 @@ }

/**
* Invokes the HTTP/2 request handler with the provided request data.
*
* @param host - The host to which to send the request.
* @param path - The path to which to send the request.
* @param requestData - The request data.
* @returns A promise that resolves with the {@link SendResponse}.
*/
invokeHttp2RequestHandlerForSendResponse(host, path, requestData, http2SessionHandler) {
const request = {
method: FIREBASE_MESSAGING_HTTP_METHOD,
url: `https://${host}${path}`,
data: requestData,
headers: LEGACY_FIREBASE_MESSAGING_HEADERS,
timeout: FIREBASE_MESSAGING_TIMEOUT,
http2SessionHandler: http2SessionHandler
};
return this.http2Client.send(request).then((response) => {
return this.buildSendResponse(response);
})
.catch((err) => {
if (err instanceof api_request_1.RequestResponseError) {
return this.buildSendResponseFromError(err);
}
// Re-throw the error if it already has the proper format.
throw err;
});
}
/**
* Sends the given array of sub requests as a single batch to FCM, and parses the result into
* a BatchResponse object.
* a `BatchResponse` object.
*

@@ -141,3 +170,3 @@ * @param requests - An array of sub requests to send.

}).catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
throw (0, messaging_errors_internal_1.createFirebaseError)(err);

@@ -157,3 +186,3 @@ }

else {
result.error = (0, messaging_errors_internal_1.createFirebaseError)(new api_request_1.HttpError(response));
result.error = (0, messaging_errors_internal_1.createFirebaseError)(new api_request_1.RequestResponseError(response));
}

@@ -160,0 +189,0 @@ return result;

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -17,12 +17,12 @@ * Copyright 2019 Google Inc.

*/
import { HttpError } from '../utils/api-request';
import { RequestResponseError } from '../utils/api-request';
import { FirebaseMessagingError } from '../utils/error';
/**
* Creates a new FirebaseMessagingError by extracting the error code, message and other relevant
* details from an HTTP error response.
* Creates a new `FirebaseMessagingError` by extracting the error code, message and other relevant
* details from a `RequestResponseError` response.
*
* @param err - The HttpError to convert into a Firebase error
* @param err - The `RequestResponseError` to convert into a Firebase error
* @returns A Firebase error that can be returned to the user.
*/
export declare function createFirebaseError(err: HttpError): FirebaseMessagingError;
export declare function createFirebaseError(err: RequestResponseError): FirebaseMessagingError;
/**

@@ -29,0 +29,0 @@ * @param response - The response to check for errors.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -23,6 +23,6 @@ /*!

/**
* Creates a new FirebaseMessagingError by extracting the error code, message and other relevant
* details from an HTTP error response.
* Creates a new `FirebaseMessagingError` by extracting the error code, message and other relevant
* details from a `RequestResponseError` response.
*
* @param err - The HttpError to convert into a Firebase error
* @param err - The `RequestResponseError` to convert into a Firebase error
* @returns A Firebase error that can be returned to the user.

@@ -29,0 +29,0 @@ */

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -27,2 +27,3 @@ * @license

private readonly messagingRequestHandler;
private useLegacyTransport;
/**

@@ -39,2 +40,16 @@ * The {@link firebase-admin.app#App} associated with the current `Messaging` service

/**
* Enables the use of legacy HTTP/1.1 transport for `sendEach()` and `sendEachForMulticast()`.
*
* @example
* ```javascript
* const messaging = getMessaging(app);
* messaging.enableLegacyTransport();
* messaging.sendEach(messages);
* ```
*
* @deprecated This will be removed when the HTTP/2 transport implementation reaches the same
* stability as the legacy HTTP/1.1 implementation.
*/
enableLegacyHttpTransport(): void;
/**
* Sends the given message via FCM.

@@ -41,0 +56,0 @@ *

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -27,2 +27,3 @@ /*!

const messaging_api_request_internal_1 = require("./messaging-api-request-internal");
const api_request_1 = require("../utils/api-request");
// FCM endpoints

@@ -80,7 +81,7 @@ const FCM_SEND_HOST = 'fcm.googleapis.com';

/**
* Maps a raw FCM server response to a MessagingDevicesResponse object.
* Maps a raw FCM server response to a `MessagingDevicesResponse` object.
*
* @param response - The raw FCM server response to map.
*
* @returns The mapped MessagingDevicesResponse object.
* @returns The mapped `MessagingDevicesResponse` object.
*/

@@ -103,7 +104,7 @@ function mapRawResponseToDevicesResponse(response) {

/**
* Maps a raw FCM server response to a MessagingDeviceGroupResponse object.
* Maps a raw FCM server response to a `MessagingDeviceGroupResponse` object.
*
* @param response - The raw FCM server response to map.
*
* @returns The mapped MessagingDeviceGroupResponse object.
* @returns The mapped `MessagingDeviceGroupResponse` object.
*/

@@ -119,7 +120,7 @@ function mapRawResponseToDeviceGroupResponse(response) {

/**
* Maps a raw FCM server response to a MessagingTopicManagementResponse object.
* Maps a raw FCM server response to a `MessagingTopicManagementResponse` object.
*
* @param {object} response The raw FCM server response to map.
*
* @returns {MessagingTopicManagementResponse} The mapped MessagingTopicManagementResponse object.
* @returns {MessagingTopicManagementResponse} The mapped `MessagingTopicManagementResponse` object.
*/

@@ -159,2 +160,3 @@ function mapRawResponseToTopicManagementResponse(response) {

constructor(app) {
this.useLegacyTransport = false;
if (!validator.isNonNullObject(app) || !('options' in app)) {

@@ -179,2 +181,18 @@ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.messaging() must be a valid Firebase app instance.');

/**
* Enables the use of legacy HTTP/1.1 transport for `sendEach()` and `sendEachForMulticast()`.
*
* @example
* ```javascript
* const messaging = getMessaging(app);
* messaging.enableLegacyTransport();
* messaging.sendEach(messages);
* ```
*
* @deprecated This will be removed when the HTTP/2 transport implementation reaches the same
* stability as the legacy HTTP/1.1 implementation.
*/
enableLegacyHttpTransport() {
this.useLegacyTransport = true;
}
/**
* Sends the given message via FCM.

@@ -242,2 +260,3 @@ *

}
const http2SessionHandler = this.useLegacyTransport ? undefined : new api_request_1.Http2SessionHandler(`https://${FCM_SEND_HOST}`);
return this.getUrlPath()

@@ -251,6 +270,10 @@ .then((urlPath) => {

}
return this.messagingRequestHandler.invokeRequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request);
if (http2SessionHandler) {
return this.messagingRequestHandler.invokeHttp2RequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request, http2SessionHandler);
}
return this.messagingRequestHandler.invokeHttpRequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request);
});
return Promise.allSettled(requests);
}).then((results) => {
})
.then((results) => {
const responses = [];

@@ -271,2 +294,7 @@ results.forEach(result => {

};
})
.finally(() => {
if (http2SessionHandler) {
http2SessionHandler.close();
}
});

@@ -273,0 +301,0 @@ }

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -256,3 +256,3 @@ /*!

if (!response.isJson()) {
throw new api_request_1.HttpError(response);
throw new api_request_1.RequestResponseError(response);
}

@@ -262,3 +262,3 @@ return response.data;

.catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
ProjectManagementRequestHandler.wrapAndRethrowHttpError(err.response.status, err.response.text);

@@ -265,0 +265,0 @@ }

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2018 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2024 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -22,3 +22,2 @@ * Copyright 2024 Google Inc.

const farmhash = require("farmhash-modern");
const long = require("long");
/**

@@ -106,18 +105,12 @@ * Encapsulates condition evaluation logic to simplify organization and

const stringToHash = `${seedPrefix}${context.randomizationId}`;
// Using a 64-bit long for consistency with the Remote Config fetch endpoint.
let hash64 = long.fromString(farmhash.fingerprint64(stringToHash).toString());
// Negate the hash if its value is less than 0. We handle this manually because the
// Long library doesn't provided an absolute value method.
if (hash64.lt(0)) {
hash64 = hash64.negate();
}
const instanceMicroPercentile = hash64.mod(100 * 1000000);
const hash64 = ConditionEvaluator.hashSeededRandomizationId(stringToHash);
const instanceMicroPercentile = hash64 % BigInt(100 * 1000000);
switch (percentOperator) {
case remote_config_api_1.PercentConditionOperator.LESS_OR_EQUAL:
return instanceMicroPercentile.lte(normalizedMicroPercent);
return instanceMicroPercentile <= normalizedMicroPercent;
case remote_config_api_1.PercentConditionOperator.GREATER_THAN:
return instanceMicroPercentile.gt(normalizedMicroPercent);
return instanceMicroPercentile > normalizedMicroPercent;
case remote_config_api_1.PercentConditionOperator.BETWEEN:
return instanceMicroPercentile.gt(normalizedMicroPercentLowerBound)
&& instanceMicroPercentile.lte(normalizedMicroPercentUpperBound);
return instanceMicroPercentile > normalizedMicroPercentLowerBound
&& instanceMicroPercentile <= normalizedMicroPercentUpperBound;
case remote_config_api_1.PercentConditionOperator.UNKNOWN:

@@ -130,4 +123,17 @@ default:

}
// Visible for testing
static hashSeededRandomizationId(seededRandomizationId) {
// For consistency with the Remote Config fetch endpoint's percent condition behavior
// we use Farmhash's fingerprint64 algorithm and interpret the resulting unsigned value
// as a signed value.
let hash64 = BigInt.asIntN(64, farmhash.fingerprint64(seededRandomizationId));
// Manually negate the hash if its value is less than 0, since Math.abs doesn't
// support BigInt.
if (hash64 < 0) {
hash64 = -hash64;
}
return hash64;
}
}
exports.ConditionEvaluator = ConditionEvaluator;
ConditionEvaluator.MAX_CONDITION_RECURSION_DEPTH = 10;

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2024 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2024 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2019 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2019 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2019 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2020 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
import { File } from '@google-cloud/storage';

@@ -3,0 +3,0 @@ export interface FirebaseMetadata {

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -21,4 +21,6 @@ * @license

/// <reference types="node" />
/// <reference types="node" />
import { FirebaseApp } from '../app/firebase-app';
import http = require('http');
import http2 = require('http2');
import { EventEmitter } from 'events';

@@ -30,5 +32,5 @@ /** Http method type definition. */

/**
* Configuration for constructing a new HTTP request.
* Base configuration for constructing a new request.
*/
export interface HttpRequestConfig {
export interface BaseRequestConfig {
method: HttpMethod;

@@ -43,8 +45,20 @@ /** Target URL of the request. Should be a well-formed URL including protocol, hostname, port and path. */

timeout?: number;
}
/**
* Configuration for constructing a new HTTP request.
*/
export interface HttpRequestConfig extends BaseRequestConfig {
httpAgent?: http.Agent;
}
/**
* Represents an HTTP response received from a remote server.
* Configuration for constructing a new HTTP/2 request.
*/
export interface HttpResponse {
export interface Http2RequestConfig extends BaseRequestConfig {
http2SessionHandler: Http2SessionHandler;
}
type RequestConfig = HttpRequestConfig | Http2RequestConfig;
/**
* Represents an HTTP or HTTP/2 response received from a remote server.
*/
export interface RequestResponse {
readonly status: number;

@@ -64,8 +78,39 @@ readonly headers: any;

}
export declare class HttpError extends Error {
readonly response: HttpResponse;
constructor(response: HttpResponse);
interface BaseLowLevelResponse {
status: number;
data?: string;
multipart?: Buffer[];
}
interface LowLevelHttpResponse extends BaseLowLevelResponse {
headers: http.IncomingHttpHeaders;
request: http.ClientRequest | null;
config: HttpRequestConfig;
}
type IncomingHttp2Headers = http2.IncomingHttpHeaders & http2.IncomingHttpStatusHeader;
interface LowLevelHttp2Response extends BaseLowLevelResponse {
headers: IncomingHttp2Headers;
request: http2.ClientHttp2Stream | null;
config: Http2RequestConfig;
}
type LowLevelResponse = LowLevelHttpResponse | LowLevelHttp2Response;
interface BaseLowLevelError extends Error {
code?: string;
}
interface LowLevelHttpError extends BaseLowLevelError {
config: HttpRequestConfig;
request?: http.ClientRequest;
response?: LowLevelHttpResponse;
}
interface LowLevelHttp2Error extends BaseLowLevelError {
config: Http2RequestConfig;
request?: http2.ClientHttp2Stream;
response?: LowLevelHttp2Response;
}
type LowLevelError = LowLevelHttpError | LowLevelHttp2Error;
export declare class RequestResponseError extends Error {
readonly response: RequestResponse;
constructor(response: RequestResponse);
}
/**
* Specifies how failing HTTP requests should be retried.
* Specifies how failing HTTP and HTTP/2 requests should be retried.
*/

@@ -75,3 +120,3 @@ export interface RetryConfig {

maxRetries: number;
/** HTTP status codes that should be retried. */
/** Response status codes that should be retried. */
statusCodes?: number[];

@@ -82,4 +127,4 @@ /** Low-level I/O error codes that should be retried. */

* The multiplier for exponential back off. The retry delay is calculated in seconds using the formula
* `(2^n) * backOffFactor`, where n is the number of retries performed so far. When the backOffFactor is set
* to 0, retries are not delayed. When the backOffFactor is 1, retry duration is doubled each iteration.
* `(2^n) * backOffFactor`, where n is the number of retries performed so far. When the `backOffFactor` is set
* to 0, retries are not delayed. When the `backOffFactor` is 1, retry duration is doubled each iteration.
*/

@@ -91,15 +136,38 @@ backOffFactor?: number;

/**
* Default retry configuration for HTTP requests. Retries up to 4 times on connection reset and timeout errors
* as well as HTTP 503 errors. Exposed as a function to ensure that every HttpClient gets its own RetryConfig
* Default retry configuration for HTTP and HTTP/2 requests. Retries up to 4 times on connection reset and timeout
* errors as well as 503 errors. Exposed as a function to ensure that every `RequestClient` gets its own `RetryConfig`
* instance.
*/
export declare function defaultRetryConfig(): RetryConfig;
export declare class HttpClient {
private readonly retry;
export declare class RequestClient {
protected readonly retry: RetryConfig;
constructor(retry?: RetryConfig | null);
protected createRequestResponse(resp: LowLevelResponse): RequestResponse;
protected waitForRetry(delayMillis: number): Promise<void>;
/**
* Checks if a failed request is eligible for a retry, and if so returns the duration to wait before initiating
* the retry.
*
* @param retryAttempts - Number of retries completed up to now.
* @param err - The last encountered error.
* @returns A 2-tuple where the 1st element is the duration to wait before another retry, and the
* 2nd element is a boolean indicating whether the request is eligible for a retry or not.
*/
protected getRetryDelayMillis(retryAttempts: number, err: LowLevelError): [number, boolean];
protected isRetryEligible(retryAttempts: number, err: LowLevelError): boolean;
/**???
* Parses the Retry-After header as a milliseconds value. Return value is negative if the Retry-After header
* contains an expired timestamp or otherwise malformed.
*/
protected parseRetryAfterIntoMillis(retryAfter: string): number;
protected backOffDelayMillis(retryAttempts: number): number;
}
export declare class HttpClient extends RequestClient {
constructor(retry?: RetryConfig | null);
/**
* Sends an HTTP request to a remote server. If the server responds with a successful response (2xx), the returned
* promise resolves with an HttpResponse. If the server responds with an error (3xx, 4xx, 5xx), the promise rejects
* with an HttpError. In case of all other errors, the promise rejects with a FirebaseAppError. If a request fails
* due to a low-level network error, transparently retries the request once before rejecting the promise.
* promise resolves with an `RequestResponse`. If the server responds with an error (3xx, 4xx, 5xx), the promise
* rejects with an `RequestResponseError`. In case of all other errors, the promise rejects with a `FirebaseAppError`.
* If a request fails due to a low-level network error, the client transparently retries the request once before
* rejecting the promise.
*

@@ -114,6 +182,6 @@ * If the request data is specified as an object, it will be serialized into a JSON string. The application/json

*/
send(config: HttpRequestConfig): Promise<HttpResponse>;
send(config: HttpRequestConfig): Promise<RequestResponse>;
/**
* Sends an HTTP request. In the event of an error, retries the HTTP request according to the
* RetryConfig set on the HttpClient.
* `RetryConfig` set on the `HttpClient`.
*

@@ -125,36 +193,51 @@ * @param config - HTTP request to be sent.

private sendWithRetry;
private createHttpResponse;
private waitForRetry;
}
export declare class Http2Client extends RequestClient {
constructor(retry?: RetryConfig | null);
/**
* Checks if a failed request is eligible for a retry, and if so returns the duration to wait before initiating
* the retry.
* Sends an HTTP/2 request to a remote server. If the server responds with a successful response (2xx), the returned
* promise resolves with an `RequestResponse`. If the server responds with an error (3xx, 4xx, 5xx), the promise
* rejects with an `RequestResponseError`. In case of all other errors, the promise rejects with a `FirebaseAppError`.
* If a request fails due to a low-level network error, the client transparently retries the request once before
* rejecting the promise.
*
* @param retryAttempts - Number of retries completed up to now.
* @param err - The last encountered error.
* @returns A 2-tuple where the 1st element is the duration to wait before another retry, and the
* 2nd element is a boolean indicating whether the request is eligible for a retry or not.
* If the request data is specified as an object, it will be serialized into a JSON string. The application/json
* content-type header will also be automatically set in this case. For all other payload types, the content-type
* header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
* and pass as a string or a Buffer along with the appropriate content-type header.
*
* @param config - HTTP/2 request to be sent.
* @returns A promise that resolves with the response details.
*/
private getRetryDelayMillis;
private isRetryEligible;
send(config: Http2RequestConfig): Promise<RequestResponse>;
/**
* Parses the Retry-After HTTP header as a milliseconds value. Return value is negative if the Retry-After header
* contains an expired timestamp or otherwise malformed.
* Sends an HTTP/2 request. In the event of an error, retries the HTTP/2 request according to the
* `RetryConfig` set on the `Http2Client`.
*
* @param config - HTTP/2 request to be sent.
* @param retryAttempts - Number of retries performed up to now.
* @returns A promise that resolves with the response details.
*/
private parseRetryAfterIntoMillis;
private backOffDelayMillis;
private sendWithRetry;
}
/**
* Parses a full HTTP response message containing both a header and a body.
* Parses a full HTTP or HTTP/2 response message containing both a header and a body.
*
* @param response - The HTTP response to be parsed.
* @param config - The request configuration that resulted in the HTTP response.
* @returns An object containing the parsed HTTP status, headers and the body.
* @param response - The HTTP or HTTP/2 response to be parsed.
* @param config - The request configuration that resulted in the HTTP or HTTP/2 response.
* @returns An object containing the response's parsed status, headers and the body.
*/
export declare function parseHttpResponse(response: string | Buffer, config: HttpRequestConfig): HttpResponse;
export declare function parseHttpResponse(response: string | Buffer, config: RequestConfig): RequestResponse;
export declare class AuthorizedHttpClient extends HttpClient {
private readonly app;
constructor(app: FirebaseApp);
send(request: HttpRequestConfig): Promise<HttpResponse>;
send(request: HttpRequestConfig): Promise<RequestResponse>;
protected getToken(): Promise<string>;
}
export declare class AuthorizedHttp2Client extends Http2Client {
private readonly app;
constructor(app: FirebaseApp);
send(request: Http2RequestConfig): Promise<RequestResponse>;
protected getToken(): Promise<string>;
}
/**

@@ -164,3 +247,3 @@ * Class that defines all the settings for the backend API endpoint.

* @param endpoint - The Firebase Auth backend endpoint.
* @param httpMethod - The http method for that endpoint.
* @param httpMethod - The HTTP method for that endpoint.
* @constructor

@@ -243,1 +326,10 @@ */

}
export declare class Http2SessionHandler {
private http2Session;
constructor(url: string);
createSession(url: string): http2.ClientHttp2Session;
get session(): http2.ClientHttp2Session;
get isClosed(): boolean;
close(): void;
}
export {};

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -20,3 +20,3 @@ /*!

Object.defineProperty(exports, "__esModule", { value: true });
exports.ExponentialBackoffPoller = exports.ApiSettings = exports.AuthorizedHttpClient = exports.parseHttpResponse = exports.HttpClient = exports.defaultRetryConfig = exports.HttpError = void 0;
exports.Http2SessionHandler = exports.ExponentialBackoffPoller = exports.ApiSettings = exports.AuthorizedHttp2Client = exports.AuthorizedHttpClient = exports.parseHttpResponse = exports.Http2Client = exports.HttpClient = exports.RequestClient = exports.defaultRetryConfig = exports.RequestResponseError = void 0;
const error_1 = require("./error");

@@ -26,7 +26,8 @@ const validator = require("./validator");

const https = require("https");
const http2 = require("http2");
const url = require("url");
const events_1 = require("events");
class DefaultHttpResponse {
class DefaultRequestResponse {
/**
* Constructs a new HttpResponse from the given LowLevelResponse.
* Constructs a new `RequestResponse` from the given `LowLevelResponse`.
*/

@@ -62,6 +63,6 @@ constructor(resp) {

/**
* Represents a multipart HTTP response. Parts that constitute the response body can be accessed
* Represents a multipart HTTP or HTTP/2 response. Parts that constitute the response body can be accessed
* via the multipart getter. Getters for text and data throw errors.
*/
class MultipartHttpResponse {
class MultipartRequestResponse {
constructor(resp) {

@@ -82,3 +83,3 @@ this.status = resp.status;

}
class HttpError extends Error {
class RequestResponseError extends Error {
constructor(response) {

@@ -89,9 +90,9 @@ super(`Server responded with status ${response.status}.`);

// See: https://github.com/Microsoft/TypeScript/issues/13965
Object.setPrototypeOf(this, HttpError.prototype);
Object.setPrototypeOf(this, RequestResponseError.prototype);
}
}
exports.HttpError = HttpError;
exports.RequestResponseError = RequestResponseError;
/**
* Default retry configuration for HTTP requests. Retries up to 4 times on connection reset and timeout errors
* as well as HTTP 503 errors. Exposed as a function to ensure that every HttpClient gets its own RetryConfig
* Default retry configuration for HTTP and HTTP/2 requests. Retries up to 4 times on connection reset and timeout
* errors as well as 503 errors. Exposed as a function to ensure that every `RequestClient` gets its own `RetryConfig`
* instance.

@@ -110,3 +111,3 @@ */

/**
* Ensures that the given RetryConfig object is valid.
* Ensures that the given `RetryConfig` object is valid.
*

@@ -134,60 +135,14 @@ * @param retry - The configuration to be validated.

}
class HttpClient {
class RequestClient {
constructor(retry = defaultRetryConfig()) {
this.retry = retry;
if (this.retry) {
if (retry) {
this.retry = retry;
validateRetryConfig(this.retry);
}
}
/**
* Sends an HTTP request to a remote server. If the server responds with a successful response (2xx), the returned
* promise resolves with an HttpResponse. If the server responds with an error (3xx, 4xx, 5xx), the promise rejects
* with an HttpError. In case of all other errors, the promise rejects with a FirebaseAppError. If a request fails
* due to a low-level network error, transparently retries the request once before rejecting the promise.
*
* If the request data is specified as an object, it will be serialized into a JSON string. The application/json
* content-type header will also be automatically set in this case. For all other payload types, the content-type
* header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
* and pass as a string or a Buffer along with the appropriate content-type header.
*
* @param config - HTTP request to be sent.
* @returns A promise that resolves with the response details.
*/
send(config) {
return this.sendWithRetry(config);
}
/**
* Sends an HTTP request. In the event of an error, retries the HTTP request according to the
* RetryConfig set on the HttpClient.
*
* @param config - HTTP request to be sent.
* @param retryAttempts - Number of retries performed up to now.
* @returns A promise that resolves with the response details.
*/
sendWithRetry(config, retryAttempts = 0) {
return AsyncHttpCall.invoke(config)
.then((resp) => {
return this.createHttpResponse(resp);
})
.catch((err) => {
const [delayMillis, canRetry] = this.getRetryDelayMillis(retryAttempts, err);
if (canRetry && this.retry && delayMillis <= this.retry.maxDelayInMillis) {
return this.waitForRetry(delayMillis).then(() => {
return this.sendWithRetry(config, retryAttempts + 1);
});
}
if (err.response) {
throw new HttpError(this.createHttpResponse(err.response));
}
if (err.code === 'ETIMEDOUT') {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_TIMEOUT, `Error while making request: ${err.message}.`);
}
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, `Error while making request: ${err.message}. Error code: ${err.code}`);
});
}
createHttpResponse(resp) {
createRequestResponse(resp) {
if (resp.multipart) {
return new MultipartHttpResponse(resp);
return new MultipartRequestResponse(resp);
}
return new DefaultHttpResponse(resp);
return new DefaultRequestResponse(resp);
}

@@ -241,4 +196,4 @@ waitForRetry(delayMillis) {

}
/**
* Parses the Retry-After HTTP header as a milliseconds value. Return value is negative if the Retry-After header
/**???
* Parses the Retry-After header as a milliseconds value. Return value is negative if the Retry-After header
* contains an expired timestamp or otherwise malformed.

@@ -269,9 +224,115 @@ */

}
exports.RequestClient = RequestClient;
class HttpClient extends RequestClient {
constructor(retry) {
super(retry);
}
/**
* Sends an HTTP request to a remote server. If the server responds with a successful response (2xx), the returned
* promise resolves with an `RequestResponse`. If the server responds with an error (3xx, 4xx, 5xx), the promise
* rejects with an `RequestResponseError`. In case of all other errors, the promise rejects with a `FirebaseAppError`.
* If a request fails due to a low-level network error, the client transparently retries the request once before
* rejecting the promise.
*
* If the request data is specified as an object, it will be serialized into a JSON string. The application/json
* content-type header will also be automatically set in this case. For all other payload types, the content-type
* header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
* and pass as a string or a Buffer along with the appropriate content-type header.
*
* @param config - HTTP request to be sent.
* @returns A promise that resolves with the response details.
*/
send(config) {
return this.sendWithRetry(config);
}
/**
* Sends an HTTP request. In the event of an error, retries the HTTP request according to the
* `RetryConfig` set on the `HttpClient`.
*
* @param config - HTTP request to be sent.
* @param retryAttempts - Number of retries performed up to now.
* @returns A promise that resolves with the response details.
*/
sendWithRetry(config, retryAttempts = 0) {
return AsyncHttpCall.invoke(config)
.then((resp) => {
return this.createRequestResponse(resp);
})
.catch((err) => {
const [delayMillis, canRetry] = this.getRetryDelayMillis(retryAttempts, err);
if (canRetry && this.retry && delayMillis <= this.retry.maxDelayInMillis) {
return this.waitForRetry(delayMillis).then(() => {
return this.sendWithRetry(config, retryAttempts + 1);
});
}
if (err.response) {
throw new RequestResponseError(this.createRequestResponse(err.response));
}
if (err.code === 'ETIMEDOUT') {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_TIMEOUT, `Error while making request: ${err.message}.`);
}
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, `Error while making request: ${err.message}. Error code: ${err.code}`);
});
}
}
exports.HttpClient = HttpClient;
class Http2Client extends RequestClient {
constructor(retry = defaultRetryConfig()) {
super(retry);
}
/**
* Sends an HTTP/2 request to a remote server. If the server responds with a successful response (2xx), the returned
* promise resolves with an `RequestResponse`. If the server responds with an error (3xx, 4xx, 5xx), the promise
* rejects with an `RequestResponseError`. In case of all other errors, the promise rejects with a `FirebaseAppError`.
* If a request fails due to a low-level network error, the client transparently retries the request once before
* rejecting the promise.
*
* If the request data is specified as an object, it will be serialized into a JSON string. The application/json
* content-type header will also be automatically set in this case. For all other payload types, the content-type
* header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
* and pass as a string or a Buffer along with the appropriate content-type header.
*
* @param config - HTTP/2 request to be sent.
* @returns A promise that resolves with the response details.
*/
send(config) {
return this.sendWithRetry(config);
}
/**
* Sends an HTTP/2 request. In the event of an error, retries the HTTP/2 request according to the
* `RetryConfig` set on the `Http2Client`.
*
* @param config - HTTP/2 request to be sent.
* @param retryAttempts - Number of retries performed up to now.
* @returns A promise that resolves with the response details.
*/
sendWithRetry(config, retryAttempts = 0) {
return AsyncHttp2Call.invoke(config)
.then((resp) => {
return this.createRequestResponse(resp);
})
.catch((err) => {
const [delayMillis, canRetry] = this.getRetryDelayMillis(retryAttempts, err);
if (canRetry && this.retry && delayMillis <= this.retry.maxDelayInMillis) {
return this.waitForRetry(delayMillis).then(() => {
return this.sendWithRetry(config, retryAttempts + 1);
});
}
if (err.response) {
throw new RequestResponseError(this.createRequestResponse(err.response));
}
if (err.code === 'ETIMEDOUT') {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_TIMEOUT, `Error while making request: ${err.message}.`);
}
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, `Error while making request: ${err.message}. Error code: ${err.code}`);
});
}
}
exports.Http2Client = Http2Client;
/**
* Parses a full HTTP response message containing both a header and a body.
* Parses a full HTTP or HTTP/2 response message containing both a header and a body.
*
* @param response - The HTTP response to be parsed.
* @param config - The request configuration that resulted in the HTTP response.
* @returns An object containing the parsed HTTP status, headers and the body.
* @param response - The HTTP or HTTP/2 response to be parsed.
* @param config - The request configuration that resulted in the HTTP or HTTP/2 response.
* @returns An object containing the response's parsed status, headers and the body.
*/

@@ -309,79 +370,13 @@ function parseHttpResponse(response, config) {

}
return new DefaultHttpResponse(lowLevelResponse);
return new DefaultRequestResponse(lowLevelResponse);
}
exports.parseHttpResponse = parseHttpResponse;
/**
* A helper class for sending HTTP requests over the wire. This is a wrapper around the standard
* http and https packages of Node.js, providing content processing, timeouts and error handling.
* A helper class for common functionality needed to send requests over the wire.
* It also wraps the callback API of the Node.js standard library in a more flexible Promise API.
*/
class AsyncHttpCall {
/**
* Sends an HTTP request based on the provided configuration.
*/
static invoke(config) {
return new AsyncHttpCall(config).promise;
class AsyncRequestCall {
constructor(configImpl) {
this.configImpl = configImpl;
}
constructor(config) {
try {
this.config = new HttpRequestConfigImpl(config);
this.options = this.config.buildRequestOptions();
this.entity = this.config.buildEntity(this.options.headers);
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.execute();
});
}
catch (err) {
this.promise = Promise.reject(this.enhanceError(err, null));
}
}
execute() {
const transport = this.options.protocol === 'https:' ? https : http;
const req = transport.request(this.options, (res) => {
this.handleResponse(res, req);
});
// Handle errors
req.on('error', (err) => {
if (req.aborted) {
return;
}
this.enhanceAndReject(err, null, req);
});
const timeout = this.config.timeout;
const timeoutCallback = () => {
req.abort();
this.rejectWithError(`timeout of ${timeout}ms exceeded`, 'ETIMEDOUT', req);
};
if (timeout) {
// Listen to timeouts and throw an error.
req.setTimeout(timeout, timeoutCallback);
}
// Send the request
req.end(this.entity);
}
handleResponse(res, req) {
if (req.aborted) {
return;
}
if (!res.statusCode) {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'Expected a statusCode on the response from a ClientRequest');
}
const response = {
status: res.statusCode,
headers: res.headers,
request: req,
data: undefined,
config: this.config,
};
const boundary = this.getMultipartBoundary(res.headers);
const respStream = this.uncompressResponse(res);
if (boundary) {
this.handleMultipartResponse(response, respStream, boundary);
}
else {
this.handleRegularResponse(response, respStream);
}
}
/**

@@ -414,15 +409,2 @@ * Extracts multipart boundary from the HTTP header. The content-type header of a multipart

}
uncompressResponse(res) {
// Uncompress the response body transparently if required.
let respStream = res;
const encodings = ['gzip', 'compress', 'deflate'];
if (res.headers['content-encoding'] && encodings.indexOf(res.headers['content-encoding']) !== -1) {
// Add the unzipper to the body stream processing pipeline.
const zlib = require('zlib'); // eslint-disable-line @typescript-eslint/no-var-requires
respStream = respStream.pipe(zlib.createUnzip());
// Remove the content-encoding in order to not confuse downstream operations.
delete res.headers['content-encoding'];
}
return respStream;
}
handleMultipartResponse(response, respStream, boundary) {

@@ -455,3 +437,3 @@ const busboy = require('@fastify/busboy'); // eslint-disable-line @typescript-eslint/no-var-requires

const req = response.request;
if (req && req.aborted) {
if (req && req.destroyed) {
return;

@@ -467,3 +449,3 @@ }

/**
* Finalizes the current HTTP call in-flight by either resolving or rejecting the associated
* Finalizes the current request call in-flight by either resolving or rejecting the associated
* promise. In the event of an error, adds additional useful information to the returned error.

@@ -481,3 +463,3 @@ */

* Creates a new error from the given message, and enhances it with other information available.
* Then the promise associated with this HTTP call is rejected with the resulting error.
* Then the promise associated with this request call is rejected with the resulting error.
*/

@@ -492,7 +474,7 @@ rejectWithError(message, code, request, response) {

/**
* Enhances the given error by adding more information to it. Specifically, the HttpRequestConfig,
* Enhances the given error by adding more information to it. Specifically, the request config,
* the underlying request and response will be attached to the error.
*/
enhanceError(error, code, request, response) {
error.config = this.config;
error.config = this.configImpl;
if (code) {

@@ -507,7 +489,187 @@ error.code = code;

/**
* An adapter class for extracting options and entity data from an HttpRequestConfig.
* A helper class for sending HTTP requests over the wire. This is a wrapper around the standard
* http and https packages of Node.js, providing content processing, timeouts and error handling.
* It also wraps the callback API of the Node.js standard library in a more flexible Promise API.
*/
class HttpRequestConfigImpl {
class AsyncHttpCall extends AsyncRequestCall {
/**
* Sends an HTTP request based on the provided configuration.
*/
static invoke(config) {
return new AsyncHttpCall(config).promise;
}
constructor(config) {
const httpConfigImpl = new HttpRequestConfigImpl(config);
super(httpConfigImpl);
try {
this.httpConfigImpl = httpConfigImpl;
this.options = this.httpConfigImpl.buildRequestOptions();
this.entity = this.httpConfigImpl.buildEntity(this.options.headers);
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.execute();
});
}
catch (err) {
this.promise = Promise.reject(this.enhanceError(err, null));
}
}
execute() {
const transport = this.options.protocol === 'https:' ? https : http;
const req = transport.request(this.options, (res) => {
this.handleResponse(res, req);
});
// Handle errors
req.on('error', (err) => {
if (req.aborted) {
return;
}
this.enhanceAndReject(err, null, req);
});
const timeout = this.httpConfigImpl.timeout;
const timeoutCallback = () => {
req.destroy();
this.rejectWithError(`timeout of ${timeout}ms exceeded`, 'ETIMEDOUT', req);
};
if (timeout) {
// Listen to timeouts and throw an error.
req.setTimeout(timeout, timeoutCallback);
}
// Send the request
req.end(this.entity);
}
handleResponse(res, req) {
if (req.aborted) {
return;
}
if (!res.statusCode) {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'Expected a statusCode on the response from a ClientRequest');
}
const response = {
status: res.statusCode,
headers: res.headers,
request: req,
data: undefined,
config: this.httpConfigImpl,
};
const boundary = this.getMultipartBoundary(res.headers);
const respStream = this.uncompressResponse(res);
if (boundary) {
this.handleMultipartResponse(response, respStream, boundary);
}
else {
this.handleRegularResponse(response, respStream);
}
}
uncompressResponse(res) {
// Uncompress the response body transparently if required.
let respStream = res;
const encodings = ['gzip', 'compress', 'deflate'];
if (res.headers['content-encoding'] && encodings.indexOf(res.headers['content-encoding']) !== -1) {
// Add the unzipper to the body stream processing pipeline.
const zlib = require('zlib'); // eslint-disable-line @typescript-eslint/no-var-requires
respStream = respStream.pipe(zlib.createUnzip());
// Remove the content-encoding in order to not confuse downstream operations.
delete res.headers['content-encoding'];
}
return respStream;
}
}
class AsyncHttp2Call extends AsyncRequestCall {
/**
* Sends an HTTP2 request based on the provided configuration.
*/
static invoke(config) {
return new AsyncHttp2Call(config).promise;
}
constructor(config) {
const http2ConfigImpl = new Http2RequestConfigImpl(config);
super(http2ConfigImpl);
try {
this.http2ConfigImpl = http2ConfigImpl;
this.options = this.http2ConfigImpl.buildRequestOptions();
this.entity = this.http2ConfigImpl.buildEntity(this.options.headers);
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.execute();
});
}
catch (err) {
this.promise = Promise.reject(this.enhanceError(err, null));
}
}
execute() {
const req = this.http2ConfigImpl.http2SessionHandler.session.request({
':method': this.options.method,
':scheme': this.options.protocol,
':path': this.options.path,
...this.options.headers
});
req.on('response', (headers) => {
this.handleHttp2Response(headers, req);
});
// Handle errors
req.on('error', (err) => {
if (req.aborted) {
return;
}
this.enhanceAndReject(err, null, req);
});
const timeout = this.http2ConfigImpl.timeout;
const timeoutCallback = () => {
req.destroy();
this.rejectWithError(`timeout of ${timeout}ms exceeded`, 'ETIMEDOUT', req);
};
if (timeout) {
// Listen to timeouts and throw an error.
req.setTimeout(timeout, timeoutCallback);
}
req.end(this.entity);
}
handleHttp2Response(headers, stream) {
if (stream.aborted) {
return;
}
if (!headers[':status']) {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'Expected a statusCode on the response from a ClientRequest');
}
const response = {
status: headers[':status'],
headers: headers,
request: stream,
data: undefined,
config: this.http2ConfigImpl,
};
const boundary = this.getMultipartBoundary(headers);
const respStream = this.uncompressResponse(headers, stream);
if (boundary) {
this.handleMultipartResponse(response, respStream, boundary);
}
else {
this.handleRegularResponse(response, respStream);
}
}
uncompressResponse(headers, stream) {
// Uncompress the response body transparently if required.
let respStream = stream;
const encodings = ['gzip', 'compress', 'deflate'];
if (headers['content-encoding'] && encodings.indexOf(headers['content-encoding']) !== -1) {
// Add the unzipper to the body stream processing pipeline.
const zlib = require('zlib'); // eslint-disable-line @typescript-eslint/no-var-requires
respStream = respStream.pipe(zlib.createUnzip());
// Remove the content-encoding in order to not confuse downstream operations.
delete headers['content-encoding'];
}
return respStream;
}
}
/**
* An adapter class with common functionality needed to extract options and entity data from a `RequestConfig`.
*/
class BaseRequestConfigImpl {
constructor(config) {
this.config = config;
this.config = config;
}

@@ -529,23 +691,2 @@ get method() {

}
get httpAgent() {
return this.config.httpAgent;
}
buildRequestOptions() {
const parsed = this.buildUrl();
const protocol = parsed.protocol;
let port = parsed.port;
if (!port) {
const isHttps = protocol === 'https:';
port = isHttps ? '443' : '80';
}
return {
protocol,
hostname: parsed.hostname,
port,
path: parsed.path,
method: this.method,
agent: this.httpAgent,
headers: Object.assign({}, this.headers),
};
}
buildEntity(headers) {

@@ -608,2 +749,54 @@ let data;

}
/**
* An adapter class for extracting options and entity data from an `HttpRequestConfig`.
*/
class HttpRequestConfigImpl extends BaseRequestConfigImpl {
constructor(httpConfig) {
super(httpConfig);
this.httpConfig = httpConfig;
}
get httpAgent() {
return this.httpConfig.httpAgent;
}
buildRequestOptions() {
const parsed = this.buildUrl();
const protocol = parsed.protocol;
let port = parsed.port;
if (!port) {
const isHttps = protocol === 'https:';
port = isHttps ? '443' : '80';
}
return {
protocol,
hostname: parsed.hostname,
port,
path: parsed.path,
method: this.method,
agent: this.httpAgent,
headers: Object.assign({}, this.headers),
};
}
}
/**
* An adapter class for extracting options and entity data from an `Http2RequestConfig`.
*/
class Http2RequestConfigImpl extends BaseRequestConfigImpl {
constructor(http2Config) {
super(http2Config);
this.http2Config = http2Config;
}
get http2SessionHandler() {
return this.http2Config.http2SessionHandler;
}
buildRequestOptions() {
const parsed = this.buildUrl();
const protocol = parsed.protocol;
return {
protocol,
path: parsed.path,
method: this.method,
headers: Object.assign({}, this.headers),
};
}
}
class AuthorizedHttpClient extends HttpClient {

@@ -633,8 +826,26 @@ constructor(app) {

return this.app.INTERNAL.getToken()
.then((accessTokenObj) => {
return accessTokenObj.accessToken;
.then((accessTokenObj) => accessTokenObj.accessToken);
}
}
exports.AuthorizedHttpClient = AuthorizedHttpClient;
class AuthorizedHttp2Client extends Http2Client {
constructor(app) {
super();
this.app = app;
}
send(request) {
return this.getToken().then((token) => {
const requestCopy = Object.assign({}, request);
requestCopy.headers = Object.assign({}, request.headers);
const authHeader = 'Authorization';
requestCopy.headers[authHeader] = `Bearer ${token}`;
return super.send(requestCopy);
});
}
getToken() {
return this.app.INTERNAL.getToken()
.then((accessTokenObj) => accessTokenObj.accessToken);
}
}
exports.AuthorizedHttpClient = AuthorizedHttpClient;
exports.AuthorizedHttp2Client = AuthorizedHttp2Client;
/**

@@ -644,3 +855,3 @@ * Class that defines all the settings for the backend API endpoint.

* @param endpoint - The Firebase Auth backend endpoint.
* @param httpMethod - The http method for that endpoint.
* @param httpMethod - The HTTP method for that endpoint.
* @constructor

@@ -790,1 +1001,34 @@ */

exports.ExponentialBackoffPoller = ExponentialBackoffPoller;
class Http2SessionHandler {
constructor(url) {
this.http2Session = this.createSession(url);
}
createSession(url) {
if (!this.http2Session || this.isClosed) {
const opts = {
// Set local max concurrent stream limit to respect backend limit
peerMaxConcurrentStreams: 100,
ALPNProtocols: ['h2']
};
const http2Session = http2.connect(url, opts);
http2Session.on('goaway', (errorCode, _, opaqueData) => {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, `Error while making requests: GOAWAY - ${opaqueData.toString()}, Error code: ${errorCode}`);
});
http2Session.on('error', (error) => {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, `Error while making requests: ${error}`);
});
return http2Session;
}
return this.http2Session;
}
get session() {
return this.http2Session;
}
get isClosed() {
return this.http2Session.closed;
}
close() {
this.http2Session.close();
}
}
exports.Http2SessionHandler = Http2SessionHandler;

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -103,3 +103,3 @@ /*!

}).catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
throw new CryptoSignerError({

@@ -106,0 +106,0 @@ code: CryptoSignerErrorCode.SERVER_ERROR,

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * Copyright 2021 Google Inc.

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -113,3 +113,3 @@ /*!

// error responses.
throw new api_request_1.HttpError(resp);
throw new api_request_1.RequestResponseError(resp);
}

@@ -132,3 +132,3 @@ // reset expire at from previous set of keys.

}).catch((err) => {
if (err instanceof api_request_1.HttpError) {
if (err instanceof api_request_1.RequestResponseError) {
let errorMessage = 'Error fetching public keys for Google certs: ';

@@ -135,0 +135,0 @@ const resp = err.response;

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
/*!

@@ -3,0 +3,0 @@ * @license

@@ -1,2 +0,2 @@

/*! firebase-admin v12.2.0 */
/*! firebase-admin v12.3.0 */
"use strict";

@@ -3,0 +3,0 @@ /*!

{
"name": "firebase-admin",
"version": "12.2.0",
"version": "12.3.0",
"description": "Firebase admin SDK for Node.js",

@@ -199,3 +199,3 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"dependencies": {
"@fastify/busboy": "^2.1.0",
"@fastify/busboy": "^3.0.0",
"@firebase/database-compat": "^1.0.2",

@@ -207,3 +207,2 @@ "@firebase/database-types": "^1.0.0",

"jwks-rsa": "^3.1.0",
"long": "^5.2.3",
"node-forge": "^1.3.1",

@@ -235,3 +234,3 @@ "uuid": "^10.0.0"

"@types/sinon-chai": "^3.0.0",
"@types/uuid": "^9.0.1",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",

@@ -259,3 +258,3 @@ "@typescript-eslint/parser": "^5.62.0",

"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"nyc": "^17.0.0",
"request": "^2.75.0",

@@ -262,0 +261,0 @@ "request-promise": "^4.1.1",

Sorry, the diff of this file is too big to display

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