Socket
Socket
Sign inDemoInstall

firebase-admin

Package Overview
Dependencies
187
Maintainers
5
Versions
131
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.0 to 9.1.0

lib/database/database-internal.js

2

lib/auth/action-code-settings-builder.js

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -19,7 +19,144 @@ /*!

Object.defineProperty(exports, "__esModule", { value: true });
exports.OIDCConfig = exports.SAMLConfig = exports.EmailSignInConfig = void 0;
exports.OIDCConfig = exports.SAMLConfig = exports.EmailSignInConfig = exports.validateTestPhoneNumbers = exports.MultiFactorAuthConfig = exports.AUTH_FACTOR_SERVER_TO_CLIENT_TYPE = exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE = exports.MAXIMUM_TEST_PHONE_NUMBERS = void 0;
var validator = require("../utils/validator");
var deep_copy_1 = require("../utils/deep-copy");
var error_1 = require("../utils/error");
/** A maximum of 10 test phone number / code pairs can be configured. */
exports.MAXIMUM_TEST_PHONE_NUMBERS = 10;
/** Client Auth factor type to server auth factor type mapping. */
exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE = {
phone: 'PHONE_SMS',
};
/** Server Auth factor type to client auth factor type mapping. */
exports.AUTH_FACTOR_SERVER_TO_CLIENT_TYPE = Object.keys(exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE)
.reduce(function (res, key) {
res[exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE[key]] = key;
return res;
}, {});
/**
* Defines the multi-factor config class used to convert client side MultiFactorConfig
* to a format that is understood by the Auth server.
*/
var MultiFactorAuthConfig = /** @class */ (function () {
/**
* The MultiFactorAuthConfig constructor.
*
* @param response The server side response used to initialize the
* MultiFactorAuthConfig object.
* @constructor
*/
function MultiFactorAuthConfig(response) {
var _this = this;
if (typeof response.state === 'undefined') {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor configuration response');
}
this.state = response.state;
this.factorIds = [];
(response.enabledProviders || []).forEach(function (enabledProvider) {
// Ignore unsupported types. It is possible the current admin SDK version is
// not up to date and newer backend types are supported.
if (typeof exports.AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider] !== 'undefined') {
_this.factorIds.push(exports.AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider]);
}
});
}
/**
* Static method to convert a client side request to a MultiFactorAuthServerConfig.
* Throws an error if validation fails.
*
* @param options The options object to convert to a server request.
* @return The resulting server request.
*/
MultiFactorAuthConfig.buildServerRequest = function (options) {
var request = {};
MultiFactorAuthConfig.validate(options);
if (Object.prototype.hasOwnProperty.call(options, 'state')) {
request.state = options.state;
}
if (Object.prototype.hasOwnProperty.call(options, 'factorIds')) {
(options.factorIds || []).forEach(function (factorId) {
if (typeof request.enabledProviders === 'undefined') {
request.enabledProviders = [];
}
request.enabledProviders.push(exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE[factorId]);
});
// In case an empty array is passed. Ensure it gets populated so the array is cleared.
if (options.factorIds && options.factorIds.length === 0) {
request.enabledProviders = [];
}
}
return request;
};
/**
* Validates the MultiFactorConfig options object. Throws an error on failure.
*
* @param options The options object to validate.
*/
MultiFactorAuthConfig.validate = function (options) {
var validKeys = {
state: true,
factorIds: true,
};
if (!validator.isNonNullObject(options)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"MultiFactorConfig" must be a non-null object.');
}
// Check for unsupported top level attributes.
for (var key in options) {
if (!(key in validKeys)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, "\"" + key + "\" is not a valid MultiFactorConfig parameter.");
}
}
// Validate content.
if (typeof options.state !== 'undefined' &&
options.state !== 'ENABLED' &&
options.state !== 'DISABLED') {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"MultiFactorConfig.state" must be either "ENABLED" or "DISABLED".');
}
if (typeof options.factorIds !== 'undefined') {
if (!validator.isArray(options.factorIds)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"MultiFactorConfig.factorIds" must be an array of valid "AuthFactorTypes".');
}
// Validate content of array.
options.factorIds.forEach(function (factorId) {
if (typeof exports.AUTH_FACTOR_CLIENT_TO_SERVER_TYPE[factorId] === 'undefined') {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, "\"" + factorId + "\" is not a valid \"AuthFactorType\".");
}
});
}
};
/** @return The plain object representation of the multi-factor config instance. */
MultiFactorAuthConfig.prototype.toJSON = function () {
return {
state: this.state,
factorIds: this.factorIds,
};
};
return MultiFactorAuthConfig;
}());
exports.MultiFactorAuthConfig = MultiFactorAuthConfig;
/**
* Validates the provided map of test phone number / code pairs.
* @param testPhoneNumbers The phone number / code pairs to validate.
*/
function validateTestPhoneNumbers(testPhoneNumbers) {
if (!validator.isObject(testPhoneNumbers)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"testPhoneNumbers" must be a map of phone number / code pairs.');
}
if (Object.keys(testPhoneNumbers).length > exports.MAXIMUM_TEST_PHONE_NUMBERS) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MAXIMUM_TEST_PHONE_NUMBER_EXCEEDED);
}
for (var phoneNumber in testPhoneNumbers) {
// Validate phone number.
if (!validator.isPhoneNumber(phoneNumber)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_TESTING_PHONE_NUMBER, "\"" + phoneNumber + "\" is not a valid E.164 standard compliant phone number.");
}
// Validate code.
if (!validator.isString(testPhoneNumbers[phoneNumber]) ||
!/^[\d]{6}$/.test(testPhoneNumbers[phoneNumber])) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_TESTING_PHONE_NUMBER, "\"" + testPhoneNumbers[phoneNumber] + "\" is not a valid 6 digit code string.");
}
}
}
exports.validateTestPhoneNumbers = validateTestPhoneNumbers;
/**
* Defines the email sign-in config class used to convert client side EmailSignInConfig

@@ -26,0 +163,0 @@ * to a format that is understood by the Auth server.

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var validator = require("../utils/validator");
var deep_copy_1 = require("../utils/deep-copy");
var error_1 = require("../utils/error");

@@ -31,3 +32,3 @@ var auth_config_1 = require("./auth-config");

*
* @param {any} response The server side response used to initialize the Tenant object.
* @param response The server side response used to initialize the Tenant object.
* @constructor

@@ -51,2 +52,8 @@ */

}
if (typeof response.mfaConfig !== 'undefined') {
this.multiFactorConfig = new auth_config_1.MultiFactorAuthConfig(response.mfaConfig);
}
if (typeof response.testPhoneNumbers !== 'undefined') {
this.testPhoneNumbers = deep_copy_1.deepCopy(response.testPhoneNumbers || {});
}
}

@@ -61,2 +68,3 @@ /**

Tenant.buildServerRequest = function (tenantOptions, createRequest) {
var _a;
Tenant.validate(tenantOptions, createRequest);

@@ -70,2 +78,9 @@ var request = {};

}
if (typeof tenantOptions.multiFactorConfig !== 'undefined') {
request.mfaConfig = auth_config_1.MultiFactorAuthConfig.buildServerRequest(tenantOptions.multiFactorConfig);
}
if (typeof tenantOptions.testPhoneNumbers !== 'undefined') {
// null will clear existing test phone numbers. Translate to empty object.
request.testPhoneNumbers = (_a = tenantOptions.testPhoneNumbers) !== null && _a !== void 0 ? _a : {};
}
return request;

@@ -97,2 +112,4 @@ };

emailSignInConfig: true,
multiFactorConfig: true,
testPhoneNumbers: true,
};

@@ -119,10 +136,34 @@ var label = createRequest ? 'CreateTenantRequest' : 'UpdateTenantRequest';

}
// Validate test phone numbers if provided.
if (typeof request.testPhoneNumbers !== 'undefined' &&
request.testPhoneNumbers !== null) {
auth_config_1.validateTestPhoneNumbers(request.testPhoneNumbers);
}
else if (request.testPhoneNumbers === null && createRequest) {
// null allowed only for update operations.
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "\"" + label + ".testPhoneNumbers\" must be a non-null object.");
}
// Validate multiFactorConfig type if provided.
if (typeof request.multiFactorConfig !== 'undefined') {
// This will throw an error if invalid.
auth_config_1.MultiFactorAuthConfig.buildServerRequest(request.multiFactorConfig);
}
};
/** @return {object} The plain object representation of the tenant. */
Tenant.prototype.toJSON = function () {
return {
var _a, _b;
var json = {
tenantId: this.tenantId,
displayName: this.displayName,
emailSignInConfig: this.emailSignInConfig && this.emailSignInConfig.toJSON(),
emailSignInConfig: (_a = this.emailSignInConfig) === null || _a === void 0 ? void 0 : _a.toJSON(),
multiFactorConfig: (_b = this.multiFactorConfig) === null || _b === void 0 ? void 0 : _b.toJSON(),
testPhoneNumbers: this.testPhoneNumbers,
};
if (typeof json.multiFactorConfig === 'undefined') {
delete json.multiFactorConfig;
}
if (typeof json.testPhoneNumbers === 'undefined') {
delete json.testPhoneNumbers;
}
return json;
};

@@ -129,0 +170,0 @@ return Tenant;

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

utils.addReadonlyGetter(this, 'factorId', factorId);
utils.addReadonlyGetter(this, 'displayName', response.displayName || null);
utils.addReadonlyGetter(this, 'displayName', response.displayName);
// Encoded using [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format.

@@ -119,0 +119,0 @@ // For example, "2017-01-15T01:30:15.01Z".

@@ -1,210 +0,22 @@

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";
/*!
* Copyright 2020 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseService = void 0;
var url_1 = require("url");
var path = require("path");
var error_1 = require("../utils/error");
var validator = require("../utils/validator");
var api_request_1 = require("../utils/api-request");
/**
* Internals of a Database instance.
*/
var DatabaseInternals = /** @class */ (function () {
function DatabaseInternals() {
this.databases = {};
}
/**
* Deletes the service and its associated resources.
*
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
*/
DatabaseInternals.prototype.delete = function () {
for (var _i = 0, _a = Object.keys(this.databases); _i < _a.length; _i++) {
var dbUrl = _a[_i];
var db = this.databases[dbUrl];
db.INTERNAL.delete();
}
return Promise.resolve(undefined);
};
return DatabaseInternals;
}());
var DatabaseService = /** @class */ (function () {
function DatabaseService(app) {
this.INTERNAL = new DatabaseInternals();
if (!validator.isNonNullObject(app) || !('options' in app)) {
throw new error_1.FirebaseDatabaseError({
code: 'invalid-argument',
message: 'First argument passed to admin.database() must be a valid Firebase app instance.',
});
}
this.appInternal = app;
}
Object.defineProperty(DatabaseService.prototype, "app", {
/**
* Returns the app associated with this DatabaseService instance.
*
* @return {FirebaseApp} The app associated with this DatabaseService instance.
*/
get: function () {
return this.appInternal;
},
enumerable: false,
configurable: true
});
DatabaseService.prototype.getDatabase = function (url) {
var dbUrl = this.ensureUrl(url);
if (!validator.isNonEmptyString(dbUrl)) {
throw new error_1.FirebaseDatabaseError({
code: 'invalid-argument',
message: 'Database URL must be a valid, non-empty URL string.',
});
}
var db = this.INTERNAL.databases[dbUrl];
if (typeof db === 'undefined') {
var rtdb = require('@firebase/database'); // eslint-disable-line @typescript-eslint/no-var-requires
var version = require('../../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
db = rtdb.initStandalone(this.appInternal, dbUrl, version).instance;
var rulesClient_1 = new DatabaseRulesClient(this.app, dbUrl);
db.getRules = function () {
return rulesClient_1.getRules();
};
db.getRulesJSON = function () {
return rulesClient_1.getRulesJSON();
};
db.setRules = function (source) {
return rulesClient_1.setRules(source);
};
this.INTERNAL.databases[dbUrl] = db;
}
return db;
};
DatabaseService.prototype.ensureUrl = function (url) {
if (typeof url !== 'undefined') {
return url;
}
else if (typeof this.appInternal.options.databaseURL !== 'undefined') {
return this.appInternal.options.databaseURL;
}
throw new error_1.FirebaseDatabaseError({
code: 'invalid-argument',
message: 'Can\'t determine Firebase Database URL.',
});
};
return DatabaseService;
}());
exports.DatabaseService = DatabaseService;
var RULES_URL_PATH = '.settings/rules.json';
/**
* A helper client for managing RTDB security rules.
*/
var DatabaseRulesClient = /** @class */ (function () {
function DatabaseRulesClient(app, dbUrl) {
var parsedUrl = new url_1.URL(dbUrl);
parsedUrl.pathname = path.join(parsedUrl.pathname, RULES_URL_PATH);
this.dbUrl = parsedUrl.toString();
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
}
/**
* Gets the currently applied security rules as a string. The return value consists of
* the rules source including comments.
*
* @return {Promise<string>} A promise fulfilled with the rules as a raw string.
*/
DatabaseRulesClient.prototype.getRules = function () {
var _this = this;
var req = {
method: 'GET',
url: this.dbUrl,
};
return this.httpClient.send(req)
.then(function (resp) {
if (!resp.text) {
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'HTTP response missing data.');
}
return resp.text;
})
.catch(function (err) {
throw _this.handleError(err);
});
};
/**
* Gets the currently applied security rules as a parsed JSON object. Any comments in
* the original source are stripped away.
*
* @return {Promise<object>} A promise fulfilled with the parsed rules source.
*/
DatabaseRulesClient.prototype.getRulesJSON = function () {
var _this = this;
var req = {
method: 'GET',
url: this.dbUrl,
data: { format: 'strict' },
};
return this.httpClient.send(req)
.then(function (resp) {
return resp.data;
})
.catch(function (err) {
throw _this.handleError(err);
});
};
/**
* Sets the specified rules on the Firebase Database instance. If the rules source is
* specified as a string or a Buffer, it may include comments.
*
* @param {string|Buffer|object} source Source of the rules to apply. Must not be `null`
* or empty.
* @return {Promise<void>} Resolves when the rules are set on the Database.
*/
DatabaseRulesClient.prototype.setRules = function (source) {
var _this = this;
if (!validator.isNonEmptyString(source) &&
!validator.isBuffer(source) &&
!validator.isNonNullObject(source)) {
var error = new error_1.FirebaseDatabaseError({
code: 'invalid-argument',
message: 'Source must be a non-empty string, Buffer or an object.',
});
return Promise.reject(error);
}
var req = {
method: 'PUT',
url: this.dbUrl,
data: source,
headers: {
'content-type': 'application/json; charset=utf-8',
},
};
return this.httpClient.send(req)
.then(function () {
return;
})
.catch(function (err) {
throw _this.handleError(err);
});
};
DatabaseRulesClient.prototype.handleError = function (err) {
if (err instanceof api_request_1.HttpError) {
return new error_1.FirebaseDatabaseError({
code: error_1.AppErrorCodes.INTERNAL_ERROR,
message: this.getErrorMessage(err),
});
}
return err;
};
DatabaseRulesClient.prototype.getErrorMessage = function (err) {
var intro = 'Error while accessing security rules';
try {
var body = err.response.data;
if (body && body.error) {
return intro + ": " + body.error.trim();
}
}
catch (_a) {
// Ignore parsing errors
}
return intro + ": " + err.response.text;
};
return DatabaseRulesClient;
}());
exports.Database = void 0;
// Required to perform module augmentation to FirebaseDatabase interface.
var database_types_1 = require("@firebase/database-types");
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_types_1.FirebaseDatabase; } });

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var service = this.ensureService_('database', function () {
var dbService = require('./database/database').DatabaseService;
var dbService = require('./database/database-internal').DatabaseService;
return new dbService(_this);

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

var service = this.ensureService_('firestore', function () {
var firestoreService = require('./firestore/firestore').FirestoreService;
var firestoreService = require('./firestore/firestore-internal').FirestoreService;
return new firestoreService(_this);

@@ -265,0 +265,0 @@ });

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var validator = require("./utils/validator");
var index_1 = require("./utils/index");
var DEFAULT_APP_NAME = '[DEFAULT]';

@@ -250,3 +251,3 @@ /**

this.credential = firebaseCredential;
this.SDK_VERSION = '9.0.0';
this.SDK_VERSION = index_1.getSdkVersion();
/* tslint:disable */

@@ -253,0 +254,0 @@ // TODO(jwenger): Database is the only consumer of firebase.Promise. We should update it to use

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
/*!

@@ -27,2 +27,3 @@ * Copyright 2017 Google Inc.

import * as _projectManagement from './project-management';
import * as _remoteConfig from './remote-config';
import * as _securityRules from './security-rules';

@@ -154,3 +155,3 @@

*/
databaseAuthVariableOverride?: Object | null;
databaseAuthVariableOverride?: object | null;

@@ -743,3 +744,3 @@ /**

*/
function refreshToken(refreshTokenPathOrObject: string | Object, httpAgent?: Agent): admin.credential.Credential;
function refreshToken(refreshTokenPathOrObject: string | object, httpAgent?: Agent): admin.credential.Credential;
}

@@ -854,347 +855,14 @@

declare namespace admin.remoteConfig {
/**
* Colors that are associated with conditions for display purposes.
*/
type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' |
'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';
/**
* Interface representing a Remote Config template.
*/
interface RemoteConfigTemplate {
/**
* A list of conditions in descending order by priority.
*/
conditions: RemoteConfigCondition[];
/**
* Map of parameter keys to their optional default values and optional conditional values.
*/
parameters: { [key: string]: RemoteConfigParameter };
/**
* Map of parameter group names to their parameter group objects.
* A group's name is mutable but must be unique among groups in the Remote Config template.
* The name is limited to 256 characters and intended to be human-readable. Any Unicode
* characters are allowed.
*/
parameterGroups: { [key: string]: RemoteConfigParameterGroup };
/**
* ETag of the current Remote Config template (readonly).
*/
readonly etag: string;
/**
* Version information for the current Remote Config template.
*/
version?: Version;
}
/**
* Interface representing a Remote Config parameter.
* At minimum, a `defaultValue` or a `conditionalValues` entry must be present for the
* parameter to have any effect.
*/
interface RemoteConfigParameter {
/**
* The value to set the parameter to, when none of the named conditions evaluate to `true`.
*/
defaultValue?: RemoteConfigParameterValue;
/**
* A `(condition name, value)` map. The condition name of the highest priority
* (the one listed first in the Remote Config template's conditions list) determines the value of
* this parameter.
*/
conditionalValues?: { [key: string]: RemoteConfigParameterValue };
/**
* A description for this parameter. Should not be over 100 characters and may contain any
* Unicode characters.
*/
description?: string;
}
/**
* Interface representing a Remote Config parameter group.
* Grouping parameters is only for management purposes and does not affect client-side
* fetching of parameter values.
*/
export interface RemoteConfigParameterGroup {
/**
* A description for the group. Its length must be less than or equal to 256 characters.
* A description may contain any Unicode characters.
*/
description?: string;
/**
* Map of parameter keys to their optional default values and optional conditional values for
* parameters that belong to this group. A parameter only appears once per
* Remote Config template. An ungrouped parameter appears at the top level, whereas a
* parameter organized within a group appears within its group's map of parameters.
*/
parameters: { [key: string]: RemoteConfigParameter };
}
/**
* Interface representing a Remote Config condition.
* A condition targets a specific group of users. A list of these conditions make up
* part of a Remote Config template.
*/
interface RemoteConfigCondition {
/**
* A non-empty and unique name of this condition.
*/
name: string;
/**
* The logic of this condition.
* See the documentation on
* {@link https://firebase.google.com/docs/remote-config/condition-reference condition expressions}
* for the expected syntax of this field.
*/
expression: string;
/**
* The color associated with this condition for display purposes in the Firebase Console.
* Not specifying this value results in the console picking an arbitrary color to associate
* with the condition.
*/
tagColor?: TagColor;
}
/**
* Interface representing an explicit parameter value.
*/
interface ExplicitParameterValue {
/**
* The `string` value that the parameter is set to.
*/
value: string;
}
/**
* Interface representing an in-app-default value.
*/
interface InAppDefaultValue {
/**
* If `true`, the parameter is omitted from the parameter values returned to a client.
*/
useInAppDefault: boolean;
}
/**
* Type representing a Remote Config parameter value.
* A `RemoteConfigParameterValue` could be either an `ExplicitParameterValue` or
* an `InAppDefaultValue`.
*/
type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
/**
* Interface representing a Remote Config template version.
* Output only, except for the version description. Contains metadata about a particular
* version of the Remote Config template. All fields are set at the time the specified Remote
* Config template is published. A version's description field may be specified in
* `publishTemplate` calls.
*/
export interface Version {
/**
* The version number of a Remote Config template.
*/
versionNumber?: string;
/**
* The timestamp of when this version of the Remote Config template was written to the
* Remote Config backend.
*/
updateTime?: string;
/**
* The origin of the template update action.
*/
updateOrigin?: ('REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED' | 'CONSOLE' |
'REST_API' | 'ADMIN_SDK_NODE');
/**
* The type of the template update action.
*/
updateType?: ('REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED' |
'INCREMENTAL_UPDATE' | 'FORCED_UPDATE' | 'ROLLBACK');
/**
* Aggregation of all metadata fields about the account that performed the update.
*/
updateUser?: RemoteConfigUser;
/**
* The user-provided description of the corresponding Remote Config template.
*/
description?: string;
/**
* The version number of the Remote Config template that has become the current version
* due to a rollback. Only present if this version is the result of a rollback.
*/
rollbackSource?: string;
/**
* Indicates whether this Remote Config template was published before version history was
* supported.
*/
isLegacy?: boolean;
}
/** Interface representing a list of Remote Config template versions. */
export interface ListVersionsResult {
/**
* A list of version metadata objects, sorted in reverse chronological order.
*/
versions: Version[];
/**
* Token to retrieve the next page of results, or empty if there are no more results
* in the list.
*/
nextPageToken?: string;
}
/** Interface representing options for Remote Config list versions operation. */
export interface ListVersionsOptions {
/**
* The maximum number of items to return per page.
*/
pageSize?: number;
/**
* The `nextPageToken` value returned from a previous list versions request, if any.
*/
pageToken?: string;
/**
* Specifies the newest version number to include in the results.
* If specified, must be greater than zero. Defaults to the newest version.
*/
endVersionNumber?: string | number;
/**
* Specifies the earliest update time to include in the results. Any entries updated before this
* time are omitted.
*/
startTime?: Date | string;
/**
* Specifies the latest update time to include in the results. Any entries updated on or after
* this time are omitted.
*/
endTime?: Date | string;
}
/** Interface representing a Remote Config user.*/
export interface RemoteConfigUser {
/**
* Email address. Output only.
*/
email: string;
/**
* Display name. Output only.
*/
name?: string;
/**
* Image URL. Output only.
*/
imageUrl?: string;
}
/**
* The Firebase `RemoteConfig` service interface.
*
* Do not call this constructor directly. Instead, use
* [`admin.remoteConfig()`](admin.remoteConfig#remoteConfig).
*/
interface RemoteConfig {
app: admin.app.App;
/**
* Gets the current active version of the {@link admin.remoteConfig.RemoteConfigTemplate
* `RemoteConfigTemplate`} of the project.
*
* @return A promise that fulfills with a `RemoteConfigTemplate`.
*/
getTemplate(): Promise<RemoteConfigTemplate>;
/**
* Gets the requested version of the {@link admin.remoteConfig.RemoteConfigTemplate
* `RemoteConfigTemplate`} of the project.
*
* @param versionNumber Version number of the Remote Config template to look up.
*
* @return A promise that fulfills with a `RemoteConfigTemplate`.
*/
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
/**
* Validates a {@link admin.remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
*
* @param template The Remote Config template to be validated.
* @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
*/
validateTemplate(template: RemoteConfigTemplate): Promise<RemoteConfigTemplate>;
/**
* Publishes a Remote Config template.
*
* @param template The Remote Config template to be published.
* @param options Optional options object when publishing a Remote Config template:
* - {boolean} `force` Setting this to `true` forces the Remote Config template to
* be updated and circumvent the ETag. This approach is not recommended
* because it risks causing the loss of updates to your Remote Config
* template if multiple clients are updating the Remote Config template.
* See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
* ETag usage and forced updates}.
*
* @return A Promise that fulfills with the published `RemoteConfigTemplate`.
*/
publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise<RemoteConfigTemplate>;
/**
* Rolls back a project's published Remote Config template to the specified version.
* A rollback is equivalent to getting a previously published Remote Config
* template and re-publishing it using a force update.
*
* @param versionNumber The version number of the Remote Config template to roll back to.
* The specified version number must be lower than the current version number, and not have
* been deleted due to staleness. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (that is, all except the
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
* @return A promise that fulfills with the published `RemoteConfigTemplate`.
*/
rollback(versionNumber: string | number): Promise<RemoteConfigTemplate>;
/**
* Gets a list of Remote Config template versions that have been published, sorted in reverse
* chronological order. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (that is, all except the
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
*
* @param options Optional {@link admin.remoteConfig.ListVersionsOptions `ListVersionsOptions`}
* object for getting a list of template versions.
* @return A promise that fulfills with a `ListVersionsResult`.
*/
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
/**
* Creates and returns a new Remote Config template from a JSON string.
*
* @param json The JSON string to populate a Remote Config template.
*
* @return A new template instance.
*/
createTemplateFromJSON(json: string): RemoteConfigTemplate;
}
export import TagColor = _remoteConfig.admin.remoteConfig.TagColor;
export import RemoteConfigTemplate = _remoteConfig.admin.remoteConfig.RemoteConfigTemplate;
export import RemoteConfigParameter = _remoteConfig.admin.remoteConfig.RemoteConfigParameter;
export import RemoteConfigParameterGroup = _remoteConfig.admin.remoteConfig.RemoteConfigParameterGroup;
export import RemoteConfigCondition = _remoteConfig.admin.remoteConfig.RemoteConfigCondition;
export import ExplicitParameterValue = _remoteConfig.admin.remoteConfig.ExplicitParameterValue;
export import InAppDefaultValue = _remoteConfig.admin.remoteConfig.InAppDefaultValue;
export import RemoteConfigParameterValue = _remoteConfig.admin.remoteConfig.RemoteConfigParameterValue;
export import Version = _remoteConfig.admin.remoteConfig.Version;
export import ListVersionsResult = _remoteConfig.admin.remoteConfig.ListVersionsResult;
export import RemoteConfigUser = _remoteConfig.admin.remoteConfig.RemoteConfigUser;
export import RemoteConfig = _remoteConfig.admin.remoteConfig.RemoteConfig;
}

@@ -1201,0 +869,0 @@

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

@@ -1,5 +0,4 @@

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
import * as _admin from './index.d';
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export namespace admin.instanceId {

@@ -6,0 +5,0 @@ /**

@@ -1,5 +0,5 @@

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";
/*!
* Copyright 2017 Google Inc.
* Copyright 2020 Google Inc.
*

@@ -21,3 +21,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var error_1 = require("../utils/error");
var instance_id_request_1 = require("./instance-id-request");
var instance_id_request_internal_1 = require("./instance-id-request-internal");
var validator = require("../utils/validator");

@@ -41,2 +41,16 @@ /**

}());
/**
* Gets the {@link InstanceId `InstanceId`} service for the
* current app.
*
* @example
* ```javascript
* var instanceId = app.instanceId();
* // The above is shorthand for:
* // var instanceId = admin.instanceId(app);
* ```
*
* @return The `InstanceId` service for the
* current app.
*/
var InstanceId = /** @class */ (function () {

@@ -53,11 +67,16 @@ /**

this.app_ = app;
this.requestHandler = new instance_id_request_1.FirebaseInstanceIdRequestHandler(app);
this.requestHandler = new instance_id_request_internal_1.FirebaseInstanceIdRequestHandler(app);
}
/**
* Deletes the specified instance ID from Firebase. This can be used to delete an instance ID
* and associated user data from a Firebase project, pursuant to the General Data Protection
* Regulation (GDPR).
* Deletes the specified instance ID and the associated data from Firebase.
*
* @param {string} instanceId The instance ID to be deleted
* @return {Promise<void>} A promise that resolves when the instance ID is successfully deleted.
* Note that Google Analytics for Firebase uses its own form of Instance ID to
* keep track of analytics data. Therefore deleting a Firebase Instance ID does
* not delete Analytics data. See
* [Delete an Instance ID](/support/privacy/manage-iids#delete_an_instance_id)
* for more information.
*
* @param instanceId The instance ID to be deleted.
*
* @return A promise fulfilled when the instance ID is deleted.
*/

@@ -64,0 +83,0 @@ InstanceId.prototype.deleteInstanceId = function (instanceId) {

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var FIREBASE_VERSION_HEADER = {
'X-Firebase-Client': 'fire-admin-node/9.0.0',
'X-Firebase-Client': "fire-admin-node/" + utils.getSdkVersion(),
};

@@ -30,0 +30,0 @@ /**

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

function Model(model) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
if (!validator.isNonNullObject(model) ||

@@ -240,3 +240,3 @@ !validator.isNonEmptyString(model.name) ||

}
if (model.tfliteModel) {
if ((_f = model.tfliteModel) === null || _f === void 0 ? void 0 : _f.gcsTfliteUri) {
this.tfliteModel = {

@@ -257,4 +257,3 @@ gcsTfliteUri: model.tfliteModel.gcsTfliteUri,

});
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
Model.prototype.waitForUnlocked = function (maxTimeSeconds) {
Model.prototype.waitForUnlocked = function (_maxTimeSeconds) {
// Backend does not currently return locked models.

@@ -261,0 +260,0 @@ // This will likely change in future.

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
import * as _admin from './index.d';

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -19,486 +19,1 @@ /*!

Object.defineProperty(exports, "__esModule", { value: true });
exports.validateMessage = void 0;
var index_1 = require("../utils/index");
var error_1 = require("../utils/error");
var validator = require("../utils/validator");
/**
* Checks if the given Message object is valid. Recursively validates all the child objects
* included in the message (android, apns, data etc.). If successful, transforms the message
* in place by renaming the keys to what's expected by the remote FCM service.
*
* @param {Message} Message An object to be validated.
*/
function validateMessage(message) {
if (!validator.isNonNullObject(message)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Message must be a non-null object');
}
var anyMessage = message;
if (anyMessage.topic) {
// If the topic name is prefixed, remove it.
if (anyMessage.topic.startsWith('/topics/')) {
anyMessage.topic = anyMessage.topic.replace(/^\/topics\//, '');
}
// Checks for illegal characters and empty string.
if (!/^[a-zA-Z0-9-_.~%]+$/.test(anyMessage.topic)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Malformed topic name');
}
}
var targets = [anyMessage.token, anyMessage.topic, anyMessage.condition];
if (targets.filter(function (v) { return validator.isNonEmptyString(v); }).length !== 1) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Exactly one of topic, token or condition is required');
}
validateStringMap(message.data, 'data');
validateAndroidConfig(message.android);
validateWebpushConfig(message.webpush);
validateApnsConfig(message.apns);
validateFcmOptions(message.fcmOptions);
validateNotification(message.notification);
}
exports.validateMessage = validateMessage;
/**
* Checks if the given object only contains strings as child values.
*
* @param {object} map An object to be validated.
* @param {string} label A label to be included in the errors thrown.
*/
function validateStringMap(map, label) {
if (typeof map === 'undefined') {
return;
}
else if (!validator.isNonNullObject(map)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, label + " must be a non-null object");
}
Object.keys(map).forEach(function (key) {
if (!validator.isString(map[key])) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, label + " must only contain string values");
}
});
}
/**
* Checks if the given WebpushConfig object is valid. The object must have valid headers and data.
*
* @param {WebpushConfig} config An object to be validated.
*/
function validateWebpushConfig(config) {
if (typeof config === 'undefined') {
return;
}
else if (!validator.isNonNullObject(config)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'webpush must be a non-null object');
}
validateStringMap(config.headers, 'webpush.headers');
validateStringMap(config.data, 'webpush.data');
}
/**
* Checks if the given ApnsConfig object is valid. The object must have valid headers and a
* payload.
*
* @param {ApnsConfig} config An object to be validated.
*/
function validateApnsConfig(config) {
if (typeof config === 'undefined') {
return;
}
else if (!validator.isNonNullObject(config)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns must be a non-null object');
}
validateStringMap(config.headers, 'apns.headers');
validateApnsPayload(config.payload);
validateApnsFcmOptions(config.fcmOptions);
}
/**
* Checks if the given ApnsFcmOptions object is valid.
*
* @param {ApnsFcmOptions} fcmOptions An object to be validated.
*/
function validateApnsFcmOptions(fcmOptions) {
if (typeof fcmOptions === 'undefined') {
return;
}
else if (!validator.isNonNullObject(fcmOptions)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
}
if (typeof fcmOptions.imageUrl !== 'undefined' &&
!validator.isURL(fcmOptions.imageUrl)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'imageUrl must be a valid URL string');
}
if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
}
var propertyMappings = {
imageUrl: 'image',
};
Object.keys(propertyMappings).forEach(function (key) {
if (key in fcmOptions && propertyMappings[key] in fcmOptions) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in ApnsFcmOptions");
}
});
index_1.renameProperties(fcmOptions, propertyMappings);
}
/**
* Checks if the given FcmOptions object is valid.
*
* @param {FcmOptions} fcmOptions An object to be validated.
*/
function validateFcmOptions(fcmOptions) {
if (typeof fcmOptions === 'undefined') {
return;
}
else if (!validator.isNonNullObject(fcmOptions)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
}
if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
}
}
/**
* Checks if the given Notification object is valid.
*
* @param {Notification} notification An object to be validated.
*/
function validateNotification(notification) {
if (typeof notification === 'undefined') {
return;
}
else if (!validator.isNonNullObject(notification)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'notification must be a non-null object');
}
if (typeof notification.imageUrl !== 'undefined' && !validator.isURL(notification.imageUrl)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'notification.imageUrl must be a valid URL string');
}
var propertyMappings = {
imageUrl: 'image',
};
Object.keys(propertyMappings).forEach(function (key) {
if (key in notification && propertyMappings[key] in notification) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in Notification");
}
});
index_1.renameProperties(notification, propertyMappings);
}
/**
* Checks if the given ApnsPayload object is valid. The object must have a valid aps value.
*
* @param {ApnsPayload} payload An object to be validated.
*/
function validateApnsPayload(payload) {
if (typeof payload === 'undefined') {
return;
}
else if (!validator.isNonNullObject(payload)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload must be a non-null object');
}
validateAps(payload.aps);
}
/**
* Checks if the given Aps object is valid. The object must have a valid alert. If the validation
* is successful, transforms the input object by renaming the keys to valid APNS payload keys.
*
* @param {Aps} aps An object to be validated.
*/
function validateAps(aps) {
if (typeof aps === 'undefined') {
return;
}
else if (!validator.isNonNullObject(aps)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps must be a non-null object');
}
validateApsAlert(aps.alert);
validateApsSound(aps.sound);
var propertyMappings = {
contentAvailable: 'content-available',
mutableContent: 'mutable-content',
threadId: 'thread-id',
};
Object.keys(propertyMappings).forEach(function (key) {
if (key in aps && propertyMappings[key] in aps) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in Aps");
}
});
index_1.renameProperties(aps, propertyMappings);
var contentAvailable = aps['content-available'];
if (typeof contentAvailable !== 'undefined' && contentAvailable !== 1) {
if (contentAvailable === true) {
aps['content-available'] = 1;
}
else {
delete aps['content-available'];
}
}
var mutableContent = aps['mutable-content'];
if (typeof mutableContent !== 'undefined' && mutableContent !== 1) {
if (mutableContent === true) {
aps['mutable-content'] = 1;
}
else {
delete aps['mutable-content'];
}
}
}
function validateApsSound(sound) {
if (typeof sound === 'undefined' || validator.isNonEmptyString(sound)) {
return;
}
else if (!validator.isNonNullObject(sound)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound must be a non-empty string or a non-null object');
}
if (!validator.isNonEmptyString(sound.name)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.name must be a non-empty string');
}
var volume = sound.volume;
if (typeof volume !== 'undefined') {
if (!validator.isNumber(volume)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be a number');
}
if (volume < 0 || volume > 1) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be in the interval [0, 1]');
}
}
var soundObject = sound;
var key = 'critical';
var critical = soundObject[key];
if (typeof critical !== 'undefined' && critical !== 1) {
if (critical === true) {
soundObject[key] = 1;
}
else {
delete soundObject[key];
}
}
}
/**
* Checks if the given alert object is valid. Alert could be a string or a complex object.
* If specified as an object, it must have valid localization parameters. If successful, transforms
* the input object by renaming the keys to valid APNS payload keys.
*
* @param {string | ApsAlert} alert An alert string or an object to be validated.
*/
function validateApsAlert(alert) {
if (typeof alert === 'undefined' || validator.isString(alert)) {
return;
}
else if (!validator.isNonNullObject(alert)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert must be a string or a non-null object');
}
var apsAlert = alert;
if (validator.isNonEmptyArray(apsAlert.locArgs) &&
!validator.isNonEmptyString(apsAlert.locKey)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.locKey is required when specifying locArgs');
}
if (validator.isNonEmptyArray(apsAlert.titleLocArgs) &&
!validator.isNonEmptyString(apsAlert.titleLocKey)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.titleLocKey is required when specifying titleLocArgs');
}
if (validator.isNonEmptyArray(apsAlert.subtitleLocArgs) &&
!validator.isNonEmptyString(apsAlert.subtitleLocKey)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.subtitleLocKey is required when specifying subtitleLocArgs');
}
var propertyMappings = {
locKey: 'loc-key',
locArgs: 'loc-args',
titleLocKey: 'title-loc-key',
titleLocArgs: 'title-loc-args',
subtitleLocKey: 'subtitle-loc-key',
subtitleLocArgs: 'subtitle-loc-args',
actionLocKey: 'action-loc-key',
launchImage: 'launch-image',
};
index_1.renameProperties(apsAlert, propertyMappings);
}
/**
* Checks if the given AndroidConfig object is valid. The object must have valid ttl, data,
* and notification fields. If successful, transforms the input object by renaming keys to valid
* Android keys. Also transforms the ttl value to the format expected by FCM service.
*
* @param {AndroidConfig} config An object to be validated.
*/
function validateAndroidConfig(config) {
if (typeof config === 'undefined') {
return;
}
else if (!validator.isNonNullObject(config)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android must be a non-null object');
}
if (typeof config.ttl !== 'undefined') {
if (!validator.isNumber(config.ttl) || config.ttl < 0) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'TTL must be a non-negative duration in milliseconds');
}
var duration = transformMillisecondsToSecondsString(config.ttl);
config.ttl = duration;
}
validateStringMap(config.data, 'android.data');
validateAndroidNotification(config.notification);
validateAndroidFcmOptions(config.fcmOptions);
var propertyMappings = {
collapseKey: 'collapse_key',
restrictedPackageName: 'restricted_package_name',
};
index_1.renameProperties(config, propertyMappings);
}
/**
* Checks if the given AndroidNotification object is valid. The object must have valid color and
* localization parameters. If successful, transforms the input object by renaming keys to valid
* Android keys.
*
* @param {AndroidNotification} notification An object to be validated.
*/
function validateAndroidNotification(notification) {
if (typeof notification === 'undefined') {
return;
}
else if (!validator.isNonNullObject(notification)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification must be a non-null object');
}
if (typeof notification.color !== 'undefined' && !/^#[0-9a-fA-F]{6}$/.test(notification.color)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.color must be in the form #RRGGBB');
}
if (validator.isNonEmptyArray(notification.bodyLocArgs) &&
!validator.isNonEmptyString(notification.bodyLocKey)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.bodyLocKey is required when specifying bodyLocArgs');
}
if (validator.isNonEmptyArray(notification.titleLocArgs) &&
!validator.isNonEmptyString(notification.titleLocKey)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.titleLocKey is required when specifying titleLocArgs');
}
if (typeof notification.imageUrl !== 'undefined' &&
!validator.isURL(notification.imageUrl)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.imageUrl must be a valid URL string');
}
if (typeof notification.eventTimestamp !== 'undefined') {
if (!(notification.eventTimestamp instanceof Date)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.eventTimestamp must be a valid `Date` object');
}
// Convert timestamp to RFC3339 UTC "Zulu" format, example "2014-10-02T15:01:23.045123456Z"
var zuluTimestamp = notification.eventTimestamp.toISOString();
notification.eventTimestamp = zuluTimestamp;
}
if (typeof notification.vibrateTimingsMillis !== 'undefined') {
if (!validator.isNonEmptyArray(notification.vibrateTimingsMillis)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be a non-empty array of numbers');
}
var vibrateTimings_1 = [];
notification.vibrateTimingsMillis.forEach(function (value) {
if (!validator.isNumber(value) || value < 0) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be non-negative durations in milliseconds');
}
var duration = transformMillisecondsToSecondsString(value);
vibrateTimings_1.push(duration);
});
notification.vibrateTimingsMillis = vibrateTimings_1;
}
if (typeof notification.priority !== 'undefined') {
var priority = 'PRIORITY_' + notification.priority.toUpperCase();
notification.priority = priority;
}
if (typeof notification.visibility !== 'undefined') {
var visibility = notification.visibility.toUpperCase();
notification.visibility = visibility;
}
validateLightSettings(notification.lightSettings);
var propertyMappings = {
clickAction: 'click_action',
bodyLocKey: 'body_loc_key',
bodyLocArgs: 'body_loc_args',
titleLocKey: 'title_loc_key',
titleLocArgs: 'title_loc_args',
channelId: 'channel_id',
imageUrl: 'image',
eventTimestamp: 'event_time',
localOnly: 'local_only',
priority: 'notification_priority',
vibrateTimingsMillis: 'vibrate_timings',
defaultVibrateTimings: 'default_vibrate_timings',
defaultSound: 'default_sound',
lightSettings: 'light_settings',
defaultLightSettings: 'default_light_settings',
notificationCount: 'notification_count',
};
index_1.renameProperties(notification, propertyMappings);
}
/**
* Checks if the given LightSettings object is valid. The object must have valid color and
* light on/off duration parameters. If successful, transforms the input object by renaming
* keys to valid Android keys.
*
* @param {LightSettings} lightSettings An object to be validated.
*/
function validateLightSettings(lightSettings) {
if (typeof lightSettings === 'undefined') {
return;
}
else if (!validator.isNonNullObject(lightSettings)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings must be a non-null object');
}
if (!validator.isNumber(lightSettings.lightOnDurationMillis) || lightSettings.lightOnDurationMillis < 0) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOnDurationMillis must be a non-negative duration in milliseconds');
}
var durationOn = transformMillisecondsToSecondsString(lightSettings.lightOnDurationMillis);
lightSettings.lightOnDurationMillis = durationOn;
if (!validator.isNumber(lightSettings.lightOffDurationMillis) || lightSettings.lightOffDurationMillis < 0) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOffDurationMillis must be a non-negative duration in milliseconds');
}
var durationOff = transformMillisecondsToSecondsString(lightSettings.lightOffDurationMillis);
lightSettings.lightOffDurationMillis = durationOff;
if (!validator.isString(lightSettings.color) ||
(!/^#[0-9a-fA-F]{6}$/.test(lightSettings.color) && !/^#[0-9a-fA-F]{8}$/.test(lightSettings.color))) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.color must be in the form #RRGGBB or #RRGGBBAA format');
}
var colorString = lightSettings.color.length === 7 ? lightSettings.color + 'FF' : lightSettings.color;
var rgb = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/i.exec(colorString);
if (!rgb || rgb.length < 4) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INTERNAL_ERROR, 'regex to extract rgba values from ' + colorString + ' failed.');
}
var color = {
red: parseInt(rgb[1], 16) / 255.0,
green: parseInt(rgb[2], 16) / 255.0,
blue: parseInt(rgb[3], 16) / 255.0,
alpha: parseInt(rgb[4], 16) / 255.0,
};
lightSettings.color = color;
var propertyMappings = {
lightOnDurationMillis: 'light_on_duration',
lightOffDurationMillis: 'light_off_duration',
};
index_1.renameProperties(lightSettings, propertyMappings);
}
/**
* Checks if the given AndroidFcmOptions object is valid.
*
* @param {AndroidFcmOptions} fcmOptions An object to be validated.
*/
function validateAndroidFcmOptions(fcmOptions) {
if (typeof fcmOptions === 'undefined') {
return;
}
else if (!validator.isNonNullObject(fcmOptions)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
}
if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
}
}
/**
* Transforms milliseconds to the format expected by FCM service.
* Returns the duration in seconds with up to nine fractional
* digits, terminated by 's'. Example: "3.5s".
*
* @param {number} milliseconds The duration in milliseconds.
* @return {string} The resulting formatted string in seconds with up to nine fractional
* digits, terminated by 's'.
*/
function transformMillisecondsToSecondsString(milliseconds) {
var duration;
var seconds = Math.floor(milliseconds / 1000);
var nanos = (milliseconds - seconds * 1000) * 1000000;
if (nanos > 0) {
var nanoString = nanos.toString();
while (nanoString.length < 9) {
nanoString = '0' + nanoString;
}
duration = seconds + "." + nanoString + "s";
}
else {
duration = seconds + "s";
}
return duration;
}

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Messaging = exports.BLACKLISTED_OPTIONS_KEYS = exports.BLACKLISTED_DATA_PAYLOAD_KEYS = void 0;
exports.Messaging = void 0;
var deep_copy_1 = require("../utils/deep-copy");
var messaging_types_1 = require("./messaging-types");
var messaging_api_request_1 = require("./messaging-api-request");
var messaging_internal_1 = require("./messaging-internal");
var messaging_api_request_internal_1 = require("./messaging-api-request-internal");
var error_1 = require("../utils/error");

@@ -79,8 +79,2 @@ var utils = require("../utils");

};
// Keys which are not allowed in the messaging data payload object.
exports.BLACKLISTED_DATA_PAYLOAD_KEYS = ['from'];
// Keys which are not allowed in the messaging options object.
exports.BLACKLISTED_OPTIONS_KEYS = [
'condition', 'data', 'notification', 'registrationIds', 'registration_ids', 'to',
];
/**

@@ -177,4 +171,13 @@ * Maps a raw FCM server response to a MessagingDevicesResponse object.

/**
* @param {FirebaseApp} app The app for this Messaging service.
* @constructor
* Gets the {@link admin.messaging.Messaging `Messaging`} service for the
* current app.
*
* @example
* ```javascript
* var messaging = app.messaging();
* // The above is shorthand for:
* // var messaging = admin.messaging(app);
* ```
*
* @return The `Messaging` service for the current app.
*/

@@ -187,3 +190,3 @@ function Messaging(app) {

this.appInternal = app;
this.messagingRequestHandler = new messaging_api_request_1.FirebaseMessagingRequestHandler(app);
this.messagingRequestHandler = new messaging_api_request_internal_1.FirebaseMessagingRequestHandler(app);
}

@@ -203,8 +206,10 @@ Object.defineProperty(Messaging.prototype, "app", {

/**
* Sends a message via Firebase Cloud Messaging (FCM).
* Sends the given message via FCM.
*
* @param {Message} message The message to be sent.
* @param {boolean=} dryRun Whether to send the message in the dry-run (validation only) mode.
*
* @return {Promise<string>} A Promise fulfilled with a message ID string.
* @param message The message payload.
* @param dryRun Whether to send the message in the dry-run
* (validation only) mode.
* @return A promise fulfilled with a unique message ID
* string after the message has been successfully handed off to the FCM
* service for delivery.
*/

@@ -214,3 +219,3 @@ Messaging.prototype.send = function (message, dryRun) {

var copy = deep_copy_1.deepCopy(message);
messaging_types_1.validateMessage(copy);
messaging_internal_1.validateMessage(copy);
if (typeof dryRun !== 'undefined' && !validator.isBoolean(dryRun)) {

@@ -232,15 +237,19 @@ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');

/**
* Sends all the messages in the given array via Firebase Cloud Messaging. Employs batching to
* send the entire list as a single RPC call. Compared to the send() method, this method is a
* significantly more efficient way to send multiple messages.
* Sends all the messages in the given array via Firebase Cloud Messaging.
* Employs batching to send the entire list as a single RPC call. Compared
* to the `send()` method, this method is a significantly more efficient way
* to send multiple messages.
*
* The responses list obtained from the return value corresponds to the order of input messages.
* An error from this method indicates a total failure -- i.e. none of the messages in the
* list could be sent. Partial failures are indicated by a BatchResponse return value.
* The responses list obtained from the return value
* corresponds to the order of tokens in the `MulticastMessage`. An error
* from this method indicates a total failure -- i.e. none of the messages in
* the list could be sent. Partial failures are indicated by a `BatchResponse`
* return value.
*
* @param {Message[]} messages A non-empty array containing up to 500 messages.
* @param {boolean=} dryRun Whether to send the message in the dry-run (validation only) mode.
*
* @return {Promise<BatchResponse>} A Promise fulfilled with an object representing the result
* of the send operation.
* @param messages A non-empty array
* containing up to 500 messages.
* @param dryRun Whether to send the messages in the dry-run
* (validation only) mode.
* @return A Promise fulfilled with an object representing the result of the
* send operation.
*/

@@ -268,3 +277,3 @@ Messaging.prototype.sendAll = function (messages, dryRun) {

var requests = copy.map(function (message) {
messaging_types_1.validateMessage(message);
messaging_internal_1.validateMessage(message);
var request = { message: message };

@@ -283,15 +292,18 @@ if (dryRun) {

/**
* Sends the given multicast message to all the FCM registration tokens specified in it.
* Sends the given multicast message to all the FCM registration tokens
* specified in it.
*
* This method uses the sendAll() API under the hood to send the given
* message to all the target recipients. The responses list obtained from the return value
* corresponds to the order of tokens in the MulticastMessage. An error from this method
* indicates a total failure -- i.e. none of the tokens in the list could be sent to. Partial
* failures are indicated by a BatchResponse return value.
* This method uses the `sendAll()` API under the hood to send the given
* message to all the target recipients. The responses list obtained from the
* return value corresponds to the order of tokens in the `MulticastMessage`.
* An error from this method indicates a total failure -- i.e. the message was
* not sent to any of the tokens in the list. Partial failures are indicated by
* a `BatchResponse` return value.
*
* @param {MulticastMessage} message A multicast message containing up to 500 tokens.
* @param {boolean=} dryRun Whether to send the message in the dry-run (validation only) mode.
*
* @return {Promise<BatchResponse>} A Promise fulfilled with an object representing the result
* of the send operation.
* @param message A multicast message
* containing up to 500 tokens.
* @param dryRun Whether to send the message in the dry-run
* (validation only) mode.
* @return A Promise fulfilled with an object representing the result of the
* send operation.
*/

@@ -323,11 +335,20 @@ Messaging.prototype.sendMulticast = function (message, dryRun) {

/**
* Sends an FCM message to a single device or an array of devices.
* Sends an FCM message to a single device corresponding to the provided
* registration token.
*
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of
* registration tokens for the device(s) to which to send the message.
* @param {MessagingPayload} payload The message payload.
* @param {MessagingOptions} [options = {}] Optional options to alter the message.
* See
* [Send to individual devices](/docs/cloud-messaging/admin/legacy-fcm#send_to_individual_devices)
* for code samples and detailed documentation. Takes either a
* `registrationToken` to send to a single device or a
* `registrationTokens` parameter containing an array of tokens to send
* to multiple devices.
*
* @return {Promise<MessagingDevicesResponse|MessagingDeviceGroupResponse>} A Promise fulfilled
* with the server's response after the message has been sent.
* @param registrationToken A device registration token or an array of
* device registration tokens to which the message should be sent.
* @param payload The message payload.
* @param options Optional options to
* alter the message.
*
* @return A promise fulfilled with the server's response after the message
* has been sent.
*/

@@ -373,11 +394,17 @@ Messaging.prototype.sendToDevice = function (registrationTokenOrTokens, payload, options) {

/**
* Sends an FCM message to a device group.
* Sends an FCM message to a device group corresponding to the provided
* notification key.
*
* @param {string} notificationKey The notification key representing the device group to which to
* send the message.
* @param {MessagingPayload} payload The message payload.
* @param {MessagingOptions} [options = {}] Optional options to alter the message.
* See
* [Send to a device group](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_device_group)
* for code samples and detailed documentation.
*
* @return {Promise<MessagingDeviceGroupResponse|MessagingDevicesResponse>} A Promise fulfilled
* with the server's response after the message has been sent.
* @param notificationKey The notification key for the device group to
* which to send the message.
* @param payload The message payload.
* @param options Optional options to
* alter the message.
*
* @return A promise fulfilled with the server's response after the message
* has been sent.
*/

@@ -436,8 +463,13 @@ Messaging.prototype.sendToDeviceGroup = function (notificationKey, payload, options) {

*
* @param {string} topic The name of the topic to which to send the message.
* @param {MessagingPayload} payload The message payload.
* @param {MessagingOptions} [options = {}] Optional options to alter the message.
* See
* [Send to a topic](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_topic)
* for code samples and detailed documentation.
*
* @return {Promise<MessagingTopicResponse>} A Promise fulfilled with the server's response after
* the message has been sent.
* @param topic The topic to which to send the message.
* @param payload The message payload.
* @param options Optional options to
* alter the message.
*
* @return A promise fulfilled with the server's response after the message
* has been sent.
*/

@@ -474,8 +506,14 @@ Messaging.prototype.sendToTopic = function (topic, payload, options) {

*
* @param {string} condition The condition to which to send the message.
* @param {MessagingPayload} payload The message payload.
* @param {MessagingOptions} [options = {}] Optional options to alter the message.
* See
* [Send to a condition](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_condition)
* for code samples and detailed documentation.
*
* @return {Promise<MessagingConditionResponse>} A Promise fulfilled with the server's response
* after the message has been sent.
* @param condition The condition determining to which topics to send
* the message.
* @param payload The message payload.
* @param options Optional options to
* alter the message.
*
* @return A promise fulfilled with the server's response after the message
* has been sent.
*/

@@ -514,10 +552,15 @@ Messaging.prototype.sendToCondition = function (condition, payload, options) {

/**
* Subscribes a single device or an array of devices to a topic.
* Subscribes a device to an FCM topic.
*
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of
* registration tokens to subscribe to the topic.
* @param {string} topic The topic to which to subscribe.
* See [Subscribe to a
* topic](/docs/cloud-messaging/manage-topics#suscribe_and_unsubscribe_using_the)
* for code samples and detailed documentation. Optionally, you can provide an
* array of tokens to subscribe multiple devices.
*
* @return {Promise<MessagingTopicManagementResponse>} A Promise fulfilled with the parsed FCM
* server response.
* @param registrationTokens A token or array of registration tokens
* for the devices to subscribe to the topic.
* @param topic The topic to which to subscribe.
*
* @return A promise fulfilled with the server's response after the device has been
* subscribed to the topic.
*/

@@ -528,10 +571,15 @@ Messaging.prototype.subscribeToTopic = function (registrationTokenOrTokens, topic) {

/**
* Unsubscribes a single device or an array of devices from a topic.
* Unsubscribes a device from an FCM topic.
*
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of
* registration tokens to unsubscribe from the topic.
* @param {string} topic The topic to which to subscribe.
* See [Unsubscribe from a
* topic](/docs/cloud-messaging/admin/manage-topic-subscriptions#unsubscribe_from_a_topic)
* for code samples and detailed documentation. Optionally, you can provide an
* array of tokens to unsubscribe multiple devices.
*
* @return {Promise<MessagingTopicManagementResponse>} A Promise fulfilled with the parsed FCM
* server response.
* @param registrationTokens A device registration token or an array of
* device registration tokens to unsubscribe from the topic.
* @param topic The topic from which to unsubscribe.
*
* @return A promise fulfilled with the server's response after the device has been
* unsubscribed from the topic.
*/

@@ -666,3 +714,3 @@ Messaging.prototype.unsubscribeFromTopic = function (registrationTokenOrTokens, topic) {

if ('data' in payloadCopy) {
exports.BLACKLISTED_DATA_PAYLOAD_KEYS.forEach(function (blacklistedKey) {
messaging_internal_1.BLACKLISTED_DATA_PAYLOAD_KEYS.forEach(function (blacklistedKey) {
if (blacklistedKey in payloadCopy.data) {

@@ -690,3 +738,3 @@ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Messaging payload contains the blacklisted \"data." + blacklistedKey + "\" property.");

// Validate the options object does not contain blacklisted properties
exports.BLACKLISTED_OPTIONS_KEYS.forEach(function (blacklistedKey) {
messaging_internal_1.BLACKLISTED_OPTIONS_KEYS.forEach(function (blacklistedKey) {
if (blacklistedKey in optionsCopy) {

@@ -693,0 +741,0 @@ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, "Messaging options contains the blacklisted \"" + blacklistedKey + "\" property.");

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
import * as _admin from './index.d';

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var validator = require("../utils/validator");
var project_management_api_request_1 = require("./project-management-api-request");
var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
var app_metadata_1 = require("./app-metadata");

@@ -34,9 +34,14 @@ var AndroidApp = /** @class */ (function () {

}
/**
* Retrieves metadata about this Android app.
*
* @return A promise that resolves to the retrieved metadata about this Android app.
*/
AndroidApp.prototype.getMetadata = function () {
return this.requestHandler.getResource(this.resourceName)
.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
var requiredFieldsList = ['name', 'appId', 'projectId', 'packageName'];
requiredFieldsList.forEach(function (requiredField) {
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
});

@@ -54,17 +59,30 @@ var metadata = {

};
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName The new display name to set.
*
* @return A promise that resolves when the display name has been set.
*/
AndroidApp.prototype.setDisplayName = function (newDisplayName) {
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
};
/**
* Gets the list of SHA certificates associated with this Android app in Firebase.
*
* @return The list of SHA-1 and SHA-256 certificates associated with this Android app in
* Firebase.
*/
AndroidApp.prototype.getShaCertificates = function () {
return this.requestHandler.getAndroidShaCertificates(this.resourceName)
.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getShaCertificates()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getShaCertificates()\'s responseData must be a non-null object.');
if (!responseData.certificates) {
return [];
}
project_management_api_request_1.assertServerResponse(validator.isArray(responseData.certificates), responseData, '"certificates" field must be present in the getShaCertificates() response data.');
project_management_api_request_internal_1.assertServerResponse(validator.isArray(responseData.certificates), responseData, '"certificates" field must be present in the getShaCertificates() response data.');
var requiredFieldsList = ['name', 'shaHash'];
return responseData.certificates.map(function (certificateJson) {
requiredFieldsList.forEach(function (requiredField) {
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(certificateJson[requiredField]), responseData, "getShaCertificates()'s responseData.certificates[]." + requiredField + " must be a "
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(certificateJson[requiredField]), responseData, "getShaCertificates()'s responseData.certificates[]." + requiredField + " must be a "
+ "non-empty string.");

@@ -76,5 +94,21 @@ });

};
/**
* Adds the given SHA certificate to this Android app.
*
* @param certificateToAdd The SHA certificate to add.
*
* @return A promise that resolves when the given certificate
* has been added to the Android app.
*/
AndroidApp.prototype.addShaCertificate = function (certificateToAdd) {
return this.requestHandler.addAndroidShaCertificate(this.resourceName, certificateToAdd);
};
/**
* Deletes the specified SHA certificate from this Android app.
*
* @param certificateToDelete The SHA certificate to delete.
*
* @return A promise that resolves when the specified
* certificate has been removed from the Android app.
*/
AndroidApp.prototype.deleteShaCertificate = function (certificateToDelete) {

@@ -88,4 +122,8 @@ if (!certificateToDelete.resourceName) {

/**
* @return {Promise<string>} A promise that resolves to a UTF-8 JSON string, typically intended to
* be written to a JSON file.
* Gets the configuration artifact associated with this app.
*
* @return A promise that resolves to the Android app's
* Firebase config file, in UTF-8 string format. This string is typically
* intended to be written to a JSON file that gets shipped with your Android
* app.
*/

@@ -95,5 +133,5 @@ AndroidApp.prototype.getConfig = function () {

.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
var base64ConfigFileContents = responseData.configFileContents;
project_management_api_request_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, "getConfig()'s responseData.configFileContents must be a base64 string.");
project_management_api_request_internal_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, "getConfig()'s responseData.configFileContents must be a base64 string.");
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');

@@ -105,2 +143,8 @@ });

exports.AndroidApp = AndroidApp;
/**
* A SHA-1 or SHA-256 certificate.
*
* Do not call this constructor directly. Instead, use
* [`projectManagement.shaCertificate()`](admin.projectManagement.ProjectManagement#shaCertificate).
*/
var ShaCertificate = /** @class */ (function () {

@@ -112,4 +156,12 @@ /**

* @param shaHash The sha256 or sha1 hash for this certificate.
* @example
* ```javascript
* var shaHash = shaCertificate.shaHash;
* ```
* @param resourceName The Firebase resource name for this certificate. This does not need to be
* set when creating a new certificate.
* @example
* ```javascript
* var resourceName = shaCertificate.resourceName;
* ```
*/

@@ -116,0 +168,0 @@ function ShaCertificate(shaHash, resourceName) {

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -20,7 +20,19 @@ /*!

exports.AppPlatform = void 0;
/**
* Platforms with which a Firebase App can be associated.
*/
var AppPlatform;
(function (AppPlatform) {
/**
* Unknown state. This is only used for distinguishing unset values.
*/
AppPlatform["PLATFORM_UNKNOWN"] = "PLATFORM_UNKNOWN";
/**
* The Firebase App is associated with iOS.
*/
AppPlatform["IOS"] = "IOS";
/**
* The Firebase App is associated with Android.
*/
AppPlatform["ANDROID"] = "ANDROID";
})(AppPlatform = exports.AppPlatform || (exports.AppPlatform = {}));

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var validator = require("../utils/validator");
var project_management_api_request_1 = require("./project-management-api-request");
var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
var app_metadata_1 = require("./app-metadata");

@@ -34,9 +34,15 @@ var IosApp = /** @class */ (function () {

}
/**
* Retrieves metadata about this iOS app.
*
* @return {!Promise<admin.projectManagement.IosAppMetadata>} A promise that
* resolves to the retrieved metadata about this iOS app.
*/
IosApp.prototype.getMetadata = function () {
return this.requestHandler.getResource(this.resourceName)
.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
var requiredFieldsList = ['name', 'appId', 'projectId', 'bundleId'];
requiredFieldsList.forEach(function (requiredField) {
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
});

@@ -54,2 +60,10 @@ var metadata = {

};
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName The new display name to set.
*
* @return A promise that resolves when the display name has
* been set.
*/
IosApp.prototype.setDisplayName = function (newDisplayName) {

@@ -59,4 +73,7 @@ return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);

/**
* @return {Promise<string>} A promise that resolves to a UTF-8 XML string, typically intended to
* be written to a plist file.
* Gets the configuration artifact associated with this app.
*
* @return A promise that resolves to the iOS app's Firebase
* config file, in UTF-8 string format. This string is typically intended to
* be written to a plist file that gets shipped with your iOS app.
*/

@@ -66,5 +83,5 @@ IosApp.prototype.getConfig = function () {

.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
var base64ConfigFileContents = responseData.configFileContents;
project_management_api_request_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, "getConfig()'s responseData.configFileContents must be a base64 string.");
project_management_api_request_internal_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, "getConfig()'s responseData.configFileContents must be a base64 string.");
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');

@@ -71,0 +88,0 @@ });

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

var ios_app_1 = require("./ios-app");
var project_management_api_request_1 = require("./project-management-api-request");
var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
var app_metadata_1 = require("./app-metadata");

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

/**
* ProjectManagement service bound to the provided app.
* The Firebase ProjectManagement service interface.
*
* Do not call this constructor directly. Instead, use
* [`admin.projectManagement()`](admin.projectManagement#projectManagement).
*/

@@ -61,6 +64,8 @@ var ProjectManagement = /** @class */ (function () {

}
this.requestHandler = new project_management_api_request_1.ProjectManagementRequestHandler(app);
this.requestHandler = new project_management_api_request_internal_1.ProjectManagementRequestHandler(app);
}
/**
* Lists up to 100 Firebase Android apps associated with this Firebase project.
*
* @return The list of Android apps.
*/

@@ -72,2 +77,4 @@ ProjectManagement.prototype.listAndroidApps = function () {

* Lists up to 100 Firebase iOS apps associated with this Firebase project.
*
* @return The list of iOS apps.
*/

@@ -78,3 +85,10 @@ ProjectManagement.prototype.listIosApps = function () {

/**
* Returns an AndroidApp object for the given appId. No RPC is made.
* Creates an `AndroidApp` object, referencing the specified Android app within
* this Firebase project.
*
* This method does not perform an RPC.
*
* @param appId The `appId` of the Android app to reference.
*
* @return An `AndroidApp` object that references the specified Firebase Android app.
*/

@@ -85,3 +99,10 @@ ProjectManagement.prototype.androidApp = function (appId) {

/**
* Returns an IosApp object for the given appId. No RPC is made.
* Creates an `iOSApp` object, referencing the specified iOS app within
* this Firebase project.
*
* This method does not perform an RPC.
*
* @param appId The `appId` of the iOS app to reference.
*
* @return An `iOSApp` object that references the specified Firebase iOS app.
*/

@@ -92,3 +113,9 @@ ProjectManagement.prototype.iosApp = function (appId) {

/**
* Returns a ShaCertificate object for the given shaHash. No RPC is made.
* Creates a `ShaCertificate` object.
*
* This method does not perform an RPC.
*
* @param shaHash The SHA-1 or SHA-256 hash for this certificate.
*
* @return A `ShaCertificate` object contains the specified SHA hash.
*/

@@ -99,3 +126,10 @@ ProjectManagement.prototype.shaCertificate = function (shaHash) {

/**
* Creates a new Firebase Android app, associated with this Firebase project.
* Creates a new Firebase Android app associated with this Firebase project.
*
* @param packageName The canonical package name of the Android App,
* as would appear in the Google Play Developer Console.
* @param displayName An optional user-assigned display name for this
* new app.
*
* @return A promise that resolves to the newly created Android app.
*/

@@ -109,4 +143,4 @@ ProjectManagement.prototype.createAndroidApp = function (packageName, displayName) {

.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createAndroidApp()'s response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createAndroidApp()'s response data.");
return new android_app_1.AndroidApp(responseData.appId, _this.requestHandler);

@@ -116,3 +150,9 @@ });

/**
* Creates a new Firebase iOS app, associated with this Firebase project.
* Creates a new Firebase iOS app associated with this Firebase project.
*
* @param bundleId The iOS app bundle ID to use for this new app.
* @param displayName An optional user-assigned display name for this
* new app.
*
* @return A promise that resolves to the newly created iOS app.
*/

@@ -126,4 +166,4 @@ ProjectManagement.prototype.createIosApp = function (bundleId, displayName) {

.then(function (responseData) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createIosApp()'s response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createIosApp()'s response data.");
return new ios_app_1.IosApp(responseData.appId, _this.requestHandler);

@@ -134,2 +174,4 @@ });

* Lists up to 100 Firebase apps associated with this Firebase project.
*
* @return A promise that resolves to the metadata list of the apps.
*/

@@ -150,3 +192,7 @@ ProjectManagement.prototype.listAppMetadata = function () {

/**
* Update display name of the project
* Update the display name of this Firebase project.
*
* @param newDisplayName The new display name to be updated.
*
* @return A promise that resolves when the project display name has been updated.
*/

@@ -166,4 +212,4 @@ ProjectManagement.prototype.setDisplayName = function (newDisplayName) {

return responseData.apps.map(function (appJson) {
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "\"apps[].appId\" field must be present in the listAppMetadata() response data.");
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(appJson.platform), responseData, "\"apps[].platform\" field must be present in the listAppMetadata() response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "\"apps[].appId\" field must be present in the listAppMetadata() response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.platform), responseData, "\"apps[].platform\" field must be present in the listAppMetadata() response data.");
var metadata = {

@@ -221,3 +267,3 @@ appId: appJson.appId,

return responseData.apps.map(function (appJson) {
project_management_api_request_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "\"apps[].appId\" field must be present in the " + callerName + " response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "\"apps[].appId\" field must be present in the " + callerName + " response data.");
if (platform === 'android') {

@@ -233,5 +279,5 @@ return new android_app_1.AndroidApp(appJson.appId, _this.requestHandler);

ProjectManagement.prototype.assertListAppsResponseData = function (responseData, callerName) {
project_management_api_request_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, callerName + "'s responseData must be a non-null object.");
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, callerName + "'s responseData must be a non-null object.");
if (responseData.apps) {
project_management_api_request_1.assertServerResponse(validator.isArray(responseData.apps), responseData, "\"apps\" field must be present in the " + callerName + " response data.");
project_management_api_request_internal_1.assertServerResponse(validator.isArray(responseData.apps), responseData, "\"apps\" field must be present in the " + callerName + " response data.");
}

@@ -238,0 +284,0 @@ };

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -18,31 +18,7 @@ /*!

*/
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoteConfigApiClient = exports.TagColor = void 0;
var api_request_1 = require("../utils/api-request");
var error_1 = require("../utils/error");
var remote_config_utils_1 = require("./remote-config-utils");
var utils = require("../utils/index");
var validator = require("../utils/validator");
var deep_copy_1 = require("../utils/deep-copy");
// Remote Config backend constants
var FIREBASE_REMOTE_CONFIG_V1_API = 'https://firebaseremoteconfig.googleapis.com/v1';
var FIREBASE_REMOTE_CONFIG_HEADERS = {
'X-Firebase-Client': 'fire-admin-node/9.0.0',
// There is a known issue in which the ETag is not properly returned in cases where the request
// does not specify a compression type. Currently, it is required to include the header
// `Accept-Encoding: gzip` or equivalent in all requests.
// https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
'Accept-Encoding': 'gzip',
};
exports.TagColor = void 0;
/**
* Colors that are associated with conditions for display purposes.
*/
var TagColor;

@@ -62,335 +38,1 @@ (function (TagColor) {

})(TagColor = exports.TagColor || (exports.TagColor = {}));
/**
* Class that facilitates sending requests to the Firebase Remote Config backend API.
*
* @private
*/
var RemoteConfigApiClient = /** @class */ (function () {
function RemoteConfigApiClient(app) {
this.app = app;
if (!validator.isNonNullObject(app) || !('options' in app)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'First argument passed to admin.remoteConfig() must be a valid Firebase app instance.');
}
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
}
RemoteConfigApiClient.prototype.getTemplate = function () {
var _this = this;
return this.getUrl()
.then(function (url) {
var request = {
method: 'GET',
url: url + "/remoteConfig",
headers: FIREBASE_REMOTE_CONFIG_HEADERS
};
return _this.httpClient.send(request);
})
.then(function (resp) {
return _this.toRemoteConfigTemplate(resp);
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.getTemplateAtVersion = function (versionNumber) {
var _this = this;
var data = { versionNumber: this.validateVersionNumber(versionNumber) };
return this.getUrl()
.then(function (url) {
var request = {
method: 'GET',
url: url + "/remoteConfig",
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
data: data
};
return _this.httpClient.send(request);
})
.then(function (resp) {
return _this.toRemoteConfigTemplate(resp);
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.validateTemplate = function (template) {
var _this = this;
template = this.validateInputRemoteConfigTemplate(template);
return this.sendPutRequest(template, template.etag, true)
.then(function (resp) {
// validating a template returns an etag with the suffix -0 means that your update
// was successfully validated. We set the etag back to the original etag of the template
// to allow future operations.
_this.validateEtag(resp.headers['etag']);
return _this.toRemoteConfigTemplate(resp, template.etag);
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.publishTemplate = function (template, options) {
var _this = this;
template = this.validateInputRemoteConfigTemplate(template);
var ifMatch = template.etag;
if (options && options.force == true) {
// setting `If-Match: *` forces the Remote Config template to be updated
// and circumvent the ETag, and the protection from that it provides.
ifMatch = '*';
}
return this.sendPutRequest(template, ifMatch)
.then(function (resp) {
return _this.toRemoteConfigTemplate(resp);
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.rollback = function (versionNumber) {
var _this = this;
var data = { versionNumber: this.validateVersionNumber(versionNumber) };
return this.getUrl()
.then(function (url) {
var request = {
method: 'POST',
url: url + "/remoteConfig:rollback",
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
data: data
};
return _this.httpClient.send(request);
})
.then(function (resp) {
return _this.toRemoteConfigTemplate(resp);
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.listVersions = function (options) {
var _this = this;
if (typeof options !== 'undefined') {
options = this.validateListVersionsOptions(options);
}
return this.getUrl()
.then(function (url) {
var request = {
method: 'GET',
url: url + "/remoteConfig:listVersions",
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
data: options
};
return _this.httpClient.send(request);
})
.then(function (resp) {
return resp.data;
})
.catch(function (err) {
throw _this.toFirebaseError(err);
});
};
RemoteConfigApiClient.prototype.sendPutRequest = function (template, etag, validateOnly) {
var _this = this;
var path = 'remoteConfig';
if (validateOnly) {
path += '?validate_only=true';
}
return this.getUrl()
.then(function (url) {
var request = {
method: 'PUT',
url: url + "/" + path,
headers: __assign(__assign({}, FIREBASE_REMOTE_CONFIG_HEADERS), { 'If-Match': etag }),
data: {
conditions: template.conditions,
parameters: template.parameters,
parameterGroups: template.parameterGroups,
version: template.version,
}
};
return _this.httpClient.send(request);
});
};
RemoteConfigApiClient.prototype.getUrl = function () {
return this.getProjectIdPrefix()
.then(function (projectIdPrefix) {
return FIREBASE_REMOTE_CONFIG_V1_API + "/" + projectIdPrefix;
});
};
RemoteConfigApiClient.prototype.getProjectIdPrefix = function () {
var _this = this;
if (this.projectIdPrefix) {
return Promise.resolve(this.projectIdPrefix);
}
return utils.findProjectId(this.app)
.then(function (projectId) {
if (!validator.isNonEmptyString(projectId)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('unknown-error', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
+ 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
+ 'environment variable.');
}
_this.projectIdPrefix = "projects/" + projectId;
return _this.projectIdPrefix;
});
};
RemoteConfigApiClient.prototype.toFirebaseError = function (err) {
if (err instanceof error_1.PrefixedFirebaseError) {
return err;
}
var response = err.response;
if (!response.isJson()) {
return new remote_config_utils_1.FirebaseRemoteConfigError('unknown-error', "Unexpected response with status: " + response.status + " and body: " + response.text);
}
var error = response.data.error || {};
var code = 'unknown-error';
if (error.status && error.status in ERROR_CODE_MAPPING) {
code = ERROR_CODE_MAPPING[error.status];
}
var message = error.message || "Unknown server error: " + response.text;
return new remote_config_utils_1.FirebaseRemoteConfigError(code, message);
};
/**
* Creates a RemoteConfigTemplate from the API response.
* If provided, customEtag is used instead of the etag returned in the API response.
*
* @param {HttpResponse} resp API response object.
* @param {string} customEtag A custom etag to replace the etag fom the API response (Optional).
*/
RemoteConfigApiClient.prototype.toRemoteConfigTemplate = function (resp, customEtag) {
var etag = (typeof customEtag == 'undefined') ? resp.headers['etag'] : customEtag;
this.validateEtag(etag);
return {
conditions: resp.data.conditions,
parameters: resp.data.parameters,
parameterGroups: resp.data.parameterGroups,
etag: etag,
version: resp.data.version,
};
};
/**
* Checks if the given RemoteConfigTemplate object is valid.
* The object must have valid parameters, parameter groups, conditions, and an etag.
* Removes output only properties from version metadata.
*
* @param {RemoteConfigTemplate} template A RemoteConfigTemplate object to be validated.
*
* @returns {RemoteConfigTemplate} The validated RemoteConfigTemplate object.
*/
RemoteConfigApiClient.prototype.validateInputRemoteConfigTemplate = function (template) {
var templateCopy = deep_copy_1.deepCopy(template);
if (!validator.isNonNullObject(templateCopy)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config template: " + JSON.stringify(templateCopy));
}
if (!validator.isNonEmptyString(templateCopy.etag)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'ETag must be a non-empty string.');
}
if (!validator.isNonNullObject(templateCopy.parameters)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
}
if (!validator.isNonNullObject(templateCopy.parameterGroups)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
}
if (!validator.isArray(templateCopy.conditions)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
}
if (typeof templateCopy.version !== 'undefined') {
// exclude output only properties and keep the only input property: description
templateCopy.version = { description: templateCopy.version.description };
}
return templateCopy;
};
/**
* Checks if a given version number is valid.
* A version number must be an integer or a string in int64 format.
* If valid, returns the string representation of the provided version number.
*
* @param {string|number} versionNumber A version number to be validated.
*
* @returns {string} The validated version number as a string.
*/
RemoteConfigApiClient.prototype.validateVersionNumber = function (versionNumber, propertyName) {
if (propertyName === void 0) { propertyName = 'versionNumber'; }
if (!validator.isNonEmptyString(versionNumber) &&
!validator.isNumber(versionNumber)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', propertyName + " must be a non-empty string in int64 format or a number");
}
if (!Number.isInteger(Number(versionNumber))) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', propertyName + " must be an integer or a string in int64 format");
}
return versionNumber.toString();
};
RemoteConfigApiClient.prototype.validateEtag = function (etag) {
if (!validator.isNonEmptyString(etag)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'ETag header is not present in the server response.');
}
};
/**
* Checks if a given `ListVersionsOptions` object is valid. If successful, creates a copy of the
* options object and convert `startTime` and `endTime` to RFC3339 UTC "Zulu" format, if present.
*
* @param {ListVersionsOptions} options An options object to be validated.
*
* @return {ListVersionsOptions} A copy of the provided options object with timestamps converted
* to UTC Zulu format.
*/
RemoteConfigApiClient.prototype.validateListVersionsOptions = function (options) {
var optionsCopy = deep_copy_1.deepCopy(options);
if (!validator.isNonNullObject(optionsCopy)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'ListVersionsOptions must be a non-null object.');
}
if (typeof optionsCopy.pageSize !== 'undefined') {
if (!validator.isNumber(optionsCopy.pageSize)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'pageSize must be a number.');
}
if (optionsCopy.pageSize < 1 || optionsCopy.pageSize > 300) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'pageSize must be a number between 1 and 300 (inclusive).');
}
}
if (typeof optionsCopy.pageToken !== 'undefined' && !validator.isNonEmptyString(optionsCopy.pageToken)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'pageToken must be a string value.');
}
if (typeof optionsCopy.endVersionNumber !== 'undefined') {
optionsCopy.endVersionNumber = this.validateVersionNumber(optionsCopy.endVersionNumber, 'endVersionNumber');
}
if (typeof optionsCopy.startTime !== 'undefined') {
if (!(optionsCopy.startTime instanceof Date) && !validator.isUTCDateString(optionsCopy.startTime)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'startTime must be a valid Date object or a UTC date string.');
}
// Convert startTime to RFC3339 UTC "Zulu" format.
if (optionsCopy.startTime instanceof Date) {
optionsCopy.startTime = optionsCopy.startTime.toISOString();
}
else {
optionsCopy.startTime = new Date(optionsCopy.startTime).toISOString();
}
}
if (typeof optionsCopy.endTime !== 'undefined') {
if (!(optionsCopy.endTime instanceof Date) && !validator.isUTCDateString(optionsCopy.endTime)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'endTime must be a valid Date object or a UTC date string.');
}
// Convert endTime to RFC3339 UTC "Zulu" format.
if (optionsCopy.endTime instanceof Date) {
optionsCopy.endTime = optionsCopy.endTime.toISOString();
}
else {
optionsCopy.endTime = new Date(optionsCopy.endTime).toISOString();
}
}
// Remove undefined fields from optionsCopy
Object.keys(optionsCopy).forEach(function (key) {
return (typeof optionsCopy[key] === 'undefined') && delete optionsCopy[key];
});
return optionsCopy;
};
return RemoteConfigApiClient;
}());
exports.RemoteConfigApiClient = RemoteConfigApiClient;
var ERROR_CODE_MAPPING = {
ABORTED: 'aborted',
ALREADY_EXISTS: "already-exists",
INVALID_ARGUMENT: 'invalid-argument',
INTERNAL: 'internal-error',
FAILED_PRECONDITION: 'failed-precondition',
NOT_FOUND: 'not-found',
OUT_OF_RANGE: 'out-of-range',
PERMISSION_DENIED: 'permission-denied',
RESOURCE_EXHAUSTED: 'resource-exhausted',
UNAUTHENTICATED: 'unauthenticated',
UNKNOWN: 'unknown-error',
};

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -21,4 +21,3 @@ /*!

var validator = require("../utils/validator");
var remote_config_utils_1 = require("./remote-config-utils");
var remote_config_api_client_1 = require("./remote-config-api-client");
var remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
/**

@@ -52,9 +51,10 @@ * Internals of an RemoteConfig service instance.

this.INTERNAL = new RemoteConfigInternals();
this.client = new remote_config_api_client_1.RemoteConfigApiClient(app);
this.client = new remote_config_api_client_internal_1.RemoteConfigApiClient(app);
}
/**
* Gets the current active version of the Remote Config template of the project.
*
* @return {Promise<RemoteConfigTemplate>} A Promise that fulfills when the template is available.
*/
* Gets the current active version of the {@link admin.remoteConfig.RemoteConfigTemplate
* `RemoteConfigTemplate`} of the project.
*
* @return A promise that fulfills with a `RemoteConfigTemplate`.
*/
RemoteConfig.prototype.getTemplate = function () {

@@ -67,8 +67,9 @@ return this.client.getTemplate()

/**
* Gets the requested version of the Remote Config template of the project.
*
* @param {number | string} versionNumber Version number of the Remote Config template to look up.
*
* @return {Promise<RemoteConfigTemplate>} A Promise that fulfills when the template is available.
*/
* Gets the requested version of the {@link admin.remoteConfig.RemoteConfigTemplate
* `RemoteConfigTemplate`} of the project.
*
* @param versionNumber Version number of the Remote Config template to look up.
*
* @return A promise that fulfills with a `RemoteConfigTemplate`.
*/
RemoteConfig.prototype.getTemplateAtVersion = function (versionNumber) {

@@ -81,7 +82,6 @@ return this.client.getTemplateAtVersion(versionNumber)

/**
* Validates a Remote Config template.
* Validates a {@link admin.remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
*
* @param {RemoteConfigTemplate} template The Remote Config template to be validated.
*
* @return {Promise<RemoteConfigTemplate>} A Promise that fulfills when a template is validated.
* @param template The Remote Config template to be validated.
* @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
*/

@@ -97,6 +97,12 @@ RemoteConfig.prototype.validateTemplate = function (template) {

*
* @param {RemoteConfigTemplate} template The Remote Config template to be validated.
* @param {any=} options Optional options object when publishing a Remote Config template.
* @param template The Remote Config template to be published.
* @param options Optional options object when publishing a Remote Config template:
* - {boolean} `force` Setting this to `true` forces the Remote Config template to
* be updated and circumvent the ETag. This approach is not recommended
* because it risks causing the loss of updates to your Remote Config
* template if multiple clients are updating the Remote Config template.
* See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
* ETag usage and forced updates}.
*
* @return {Promise<RemoteConfigTemplate>} A Promise that fulfills when a template is published.
* @return A Promise that fulfills with the published `RemoteConfigTemplate`.
*/

@@ -110,9 +116,12 @@ RemoteConfig.prototype.publishTemplate = function (template, options) {

/**
* Rollbacks a project's published Remote Config template to the specified version.
* Rolls back a project's published Remote Config template to the specified version.
* A rollback is equivalent to getting a previously published Remote Config
* template, and re-publishing it using a force update.
* template and re-publishing it using a force update.
*
* @param {number | string} versionNumber The version number of the Remote Config template
* to rollback to.
* @return {Promise<RemoteConfigTemplate>} A Promise that fulfills with the published template.
* @param versionNumber The version number of the Remote Config template to roll back to.
* The specified version number must be lower than the current version number, and not have
* been deleted due to staleness. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (that is, all except the
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
* @return A promise that fulfills with the published `RemoteConfigTemplate`.
*/

@@ -126,10 +135,10 @@ RemoteConfig.prototype.rollback = function (versionNumber) {

/**
* Gets a list of Remote Config template versions that have been published, sorted in reverse
* chronological order. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (i.e., all except the
* template that is being fetched by clients) are also deleted if they are older than 90 days.
*
* @param {ListVersionsOptions} options Optional options object for getting a list of versions.
* @return A promise that fulfills with a `ListVersionsResult`.
*/
* Gets a list of Remote Config template versions that have been published, sorted in reverse
* chronological order. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (i.e., all except the
* template that is being fetched by clients) are also deleted if they are older than 90 days.
*
* @param {ListVersionsOptions} options Optional options object for getting a list of versions.
* @return A promise that fulfills with a `ListVersionsResult`.
*/
RemoteConfig.prototype.listVersions = function (options) {

@@ -148,9 +157,9 @@ return this.client.listVersions(options)

*
* @param {string} json The JSON string to populate a Remote Config template.
* @param json The JSON string to populate a Remote Config template.
*
* @return {RemoteConfigTemplate} A new template instance.
* @return A new template instance.
*/
RemoteConfig.prototype.createTemplateFromJSON = function (json) {
if (!validator.isNonEmptyString(json)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
}

@@ -162,3 +171,3 @@ var template;

catch (e) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', "Failed to parse the JSON string: " + json + ". " + e);
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Failed to parse the JSON string: " + json + ". " + e);
}

@@ -177,3 +186,3 @@ return new RemoteConfigTemplateImpl(template);

!validator.isNonEmptyString(config.etag)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config template: " + JSON.stringify(config));
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config template: " + JSON.stringify(config));
}

@@ -183,3 +192,3 @@ this.etagInternal = config.etag;

if (!validator.isNonNullObject(config.parameters)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
}

@@ -193,3 +202,3 @@ this.parameters = config.parameters;

if (!validator.isNonNullObject(config.parameterGroups)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
}

@@ -203,3 +212,3 @@ this.parameterGroups = config.parameterGroups;

if (!validator.isArray(config.conditions)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
}

@@ -247,3 +256,3 @@ this.conditions = config.conditions;

if (!validator.isNonNullObject(version)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config version instance: " + JSON.stringify(version));
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config version instance: " + JSON.stringify(version));
}

@@ -253,6 +262,6 @@ if (typeof version.versionNumber !== 'undefined') {

!validator.isNumber(version.versionNumber)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be a non-empty string in int64 format or a number');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be a non-empty string in int64 format or a number');
}
if (!Number.isInteger(Number(version.versionNumber))) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be an integer or a string in int64 format');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be an integer or a string in int64 format');
}

@@ -263,3 +272,3 @@ this.versionNumber = version.versionNumber;

if (!validator.isNonEmptyString(version.updateOrigin)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version update origin must be a non-empty string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update origin must be a non-empty string');
}

@@ -270,3 +279,3 @@ this.updateOrigin = version.updateOrigin;

if (!validator.isNonEmptyString(version.updateType)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version update type must be a non-empty string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update type must be a non-empty string');
}

@@ -277,3 +286,3 @@ this.updateType = version.updateType;

if (!validator.isNonNullObject(version.updateUser)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version update user must be a non-null object');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update user must be a non-null object');
}

@@ -284,3 +293,3 @@ this.updateUser = version.updateUser;

if (!validator.isNonEmptyString(version.description)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version description must be a non-empty string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version description must be a non-empty string');
}

@@ -291,3 +300,3 @@ this.description = version.description;

if (!validator.isNonEmptyString(version.rollbackSource)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version rollback source must be a non-empty string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version rollback source must be a non-empty string');
}

@@ -298,3 +307,3 @@ this.rollbackSource = version.rollbackSource;

if (!validator.isBoolean(version.isLegacy)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version.isLegacy must be a boolean');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version.isLegacy must be a boolean');
}

@@ -309,3 +318,3 @@ this.isLegacy = version.isLegacy;

!validator.isUTCDateString(version.updateTime)) {
throw new remote_config_utils_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
}

@@ -312,0 +321,0 @@ if (validator.isISODateString(version.updateTime)) {

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
import * as _admin from './index.d';

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -21,8 +21,8 @@ /*!

var validator = require("../utils/validator");
var security_rules_api_client_1 = require("./security-rules-api-client");
var security_rules_utils_1 = require("./security-rules-utils");
var security_rules_api_client_internal_1 = require("./security-rules-api-client-internal");
var security_rules_internal_1 = require("./security-rules-internal");
var RulesetMetadataListImpl = /** @class */ (function () {
function RulesetMetadataListImpl(response) {
if (!validator.isNonNullObject(response) || !validator.isArray(response.rulesets)) {
throw new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', "Invalid ListRulesets response: " + JSON.stringify(response));
throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', "Invalid ListRulesets response: " + JSON.stringify(response));
}

@@ -50,3 +50,3 @@ this.rulesets = response.rulesets.map(function (rs) {

!validator.isNonNullObject(ruleset.source)) {
throw new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', "Invalid Ruleset response: " + JSON.stringify(ruleset));
throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', "Invalid Ruleset response: " + JSON.stringify(ruleset));
}

@@ -61,3 +61,6 @@ this.name = stripProjectIdPrefix(ruleset.name);

/**
* SecurityRules service bound to the provided app.
* The Firebase `SecurityRules` service interface.
*
* Do not call this constructor directly. Instead, use
* [`admin.securityRules()`](admin.securityRules#securityRules).
*/

@@ -72,3 +75,3 @@ var SecurityRules = /** @class */ (function () {

this.INTERNAL = new SecurityRulesInternals();
this.client = new security_rules_api_client_1.SecurityRulesApiClient(app);
this.client = new security_rules_api_client_internal_1.SecurityRulesApiClient(app);
}

@@ -191,12 +194,21 @@ /**

/**
* Creates a `RulesFile` with the given name and source. Throws if any of the arguments are invalid. This is a
* local operation, and does not involve any network API calls.
* Creates a {@link admin.securityRules.RulesFile `RuleFile`} with the given name
* and source. Throws an error if any of the arguments are invalid. This is a local
* operation, and does not involve any network API calls.
*
* @param {string} name Name to assign to the rules file.
* @param {string|Buffer} source Contents of the rules file.
* @returns {RulesFile} A new rules file instance.
* @example
* ```javascript
* const source = '// Some rules source';
* const rulesFile = admin.securityRules().createRulesFileFromSource(
* 'firestore.rules', source);
* ```
*
* @param name Name to assign to the rules file. This is usually a short file name that
* helps identify the file in a ruleset.
* @param source Contents of the rules file.
* @return A new rules file instance.
*/
SecurityRules.prototype.createRulesFileFromSource = function (name, source) {
if (!validator.isNonEmptyString(name)) {
throw new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', 'Name must be a non-empty string.');
throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Name must be a non-empty string.');
}

@@ -211,3 +223,3 @@ var content;

else {
throw new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', 'Source must be a non-empty string or a Buffer.');
throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Source must be a non-empty string or a Buffer.');
}

@@ -220,6 +232,7 @@ return {

/**
* Creates a new `Ruleset` from the given `RulesFile`.
* Creates a new {@link admin.securityRules.Ruleset `Ruleset`} from the given
* {@link admin.securityRules.RulesFile `RuleFile`}.
*
* @param {RulesFile} file Rules file to include in the new Ruleset.
* @returns {Promise<Ruleset>} A promise that fulfills with the newly created Ruleset.
* @param file Rules file to include in the new `Ruleset`.
* @returns A promise that fulfills with the newly created `Ruleset`.
*/

@@ -238,8 +251,10 @@ SecurityRules.prototype.createRuleset = function (file) {

/**
* Deletes the Ruleset identified by the given name. The input name should be the short name string without
* the project ID prefix. For example, to delete the `projects/project-id/rulesets/my-ruleset`, pass the
* short name "my-ruleset". Rejects with a `not-found` error if the specified Ruleset cannot be found.
* Deletes the {@link admin.securityRules.Ruleset `Ruleset`} identified by the given
* name. The input name should be the short name string without the project ID
* prefix. For example, to delete the `projects/project-id/rulesets/my-ruleset`,
* pass the short name "my-ruleset". Rejects with a `not-found` error if the
* specified `Ruleset` cannot be found.
*
* @param {string} name Name of the Ruleset to delete.
* @returns {Promise<Ruleset>} A promise that fulfills when the Ruleset is deleted.
* @param name Name of the `Ruleset` to delete.
* @return A promise that fulfills when the `Ruleset` is deleted.
*/

@@ -250,8 +265,9 @@ SecurityRules.prototype.deleteRuleset = function (name) {

/**
* Retrieves a page of rulesets.
* Retrieves a page of ruleset metadata.
*
* @param {number=} pageSize The page size, 100 if undefined. This is also the maximum allowed limit.
* @param {string=} nextPageToken The next page token. If not specified, returns rulesets starting
* without any offset.
* @returns {Promise<RulesetMetadataList>} A promise that fulfills a page of rulesets.
* @param pageSize The page size, 100 if undefined. This is also the maximum allowed
* limit.
* @param nextPageToken The next page token. If not specified, returns rulesets
* starting without any offset.
* @return A promise that fulfills with a page of rulesets.
*/

@@ -271,3 +287,3 @@ SecurityRules.prototype.listRulesetMetadata = function (pageSize, nextPageToken) {

if (!validator.isNonEmptyString(rulesetName)) {
throw new security_rules_utils_1.FirebaseSecurityRulesError('not-found', "Ruleset name not found for " + releaseName + ".");
throw new security_rules_internal_1.FirebaseSecurityRulesError('not-found', "Ruleset name not found for " + releaseName + ".");
}

@@ -280,3 +296,3 @@ return _this.getRuleset(stripProjectIdPrefix(rulesetName));

(!validator.isNonNullObject(ruleset) || !validator.isNonEmptyString(ruleset.name))) {
var err = new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', 'ruleset must be a non-empty name or a RulesetMetadata object.');
var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'ruleset must be a non-empty name or a RulesetMetadata object.');
return Promise.reject(err);

@@ -293,3 +309,3 @@ }

if (!validator.isNonEmptyString(bucketName)) {
throw new security_rules_utils_1.FirebaseSecurityRulesError('invalid-argument', 'Bucket name not specified or invalid. Specify a default bucket name via the ' +
throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Bucket name not specified or invalid. Specify a default bucket name via the ' +
'storageBucket option when initializing the app, or specify the bucket name ' +

@@ -296,0 +312,0 @@ 'explicitly when calling the rules API.');

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -547,2 +547,6 @@ /*!

};
AuthClientErrorCode.INVALID_TESTING_PHONE_NUMBER = {
code: 'invalid-testing-phone-number',
message: 'Invalid testing phone number or invalid test code provided.',
};
AuthClientErrorCode.INVALID_UID = {

@@ -611,2 +615,6 @@ code: 'invalid-uid',

};
AuthClientErrorCode.MAXIMUM_TEST_PHONE_NUMBER_EXCEEDED = {
code: 'test-phone-number-limit-exceeded',
message: 'The maximum allowed number of test phone number / code pairs has been exceeded.',
};
AuthClientErrorCode.MAXIMUM_USER_COUNT_EXCEEDED = {

@@ -883,2 +891,4 @@ code: 'maximum-user-count-exceeded',

INVALID_SERVICE_ACCOUNT: 'INVALID_SERVICE_ACCOUNT',
// Invalid testing phone number.
INVALID_TESTING_PHONE_NUMBER: 'INVALID_TESTING_PHONE_NUMBER',
// Invalid tenant type.

@@ -885,0 +895,0 @@ INVALID_TENANT_TYPE: 'INVALID_TENANT_TYPE',

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

@@ -19,5 +19,14 @@ /*!

Object.defineProperty(exports, "__esModule", { value: true });
exports.generateUpdateMask = exports.formatString = exports.toWebSafeBase64 = exports.findProjectId = exports.getExplicitProjectId = exports.addReadonlyGetter = exports.renameProperties = void 0;
exports.generateUpdateMask = exports.formatString = exports.toWebSafeBase64 = exports.findProjectId = exports.getExplicitProjectId = exports.addReadonlyGetter = exports.renameProperties = exports.getSdkVersion = void 0;
var credential_1 = require("../auth/credential");
var validator = require("./validator");
var sdkVersion;
function getSdkVersion() {
if (!sdkVersion) {
var version = require('../../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
sdkVersion = version;
}
return sdkVersion;
}
exports.getSdkVersion = getSdkVersion;
/**

@@ -140,6 +149,12 @@ * Renames properties on an object given a mapping from old to new property names.

*
* @param {[key: string]: any} obj The object to generate the update mask for.
* @return {Array<string>} The computed update mask list.
* @param obj The object to generate the update mask for.
* @param terminalPaths The optional map of keys for maximum paths to traverse.
* Nested objects beyond that path will be ignored. This is useful for
* keys with variable object values.
* @param root The path so far.
* @return The computed update mask list.
*/
function generateUpdateMask(obj) {
function generateUpdateMask(obj, terminalPaths, root) {
if (terminalPaths === void 0) { terminalPaths = []; }
if (root === void 0) { root = ''; }
var updateMask = [];

@@ -150,11 +165,20 @@ if (!validator.isNonNullObject(obj)) {

var _loop_1 = function (key) {
if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] !== 'undefined') {
var maskList = generateUpdateMask(obj[key]);
if (maskList.length > 0) {
maskList.forEach(function (mask) {
updateMask.push(key + "." + mask);
});
if (typeof obj[key] !== 'undefined') {
var nextPath = root ? root + "." + key : key;
// We hit maximum path.
// Consider switching to Set<string> if the list grows too large.
if (terminalPaths.indexOf(nextPath) !== -1) {
// Add key and stop traversing this branch.
updateMask.push(key);
}
else {
updateMask.push(key);
var maskList = generateUpdateMask(obj[key], terminalPaths, nextPath);
if (maskList.length > 0) {
maskList.forEach(function (mask) {
updateMask.push(key + "." + mask);
});
}
else {
updateMask.push(key);
}
}

@@ -161,0 +185,0 @@ }

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

/*! firebase-admin v9.0.0 */
/*! firebase-admin v9.1.0 */
"use strict";

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

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

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

"dependencies": {
"@firebase/database": "^0.6.0",
"@firebase/database": "^0.6.10",
"@firebase/database-types": "^0.5.2",
"@types/node": "^10.10.0",

@@ -69,5 +70,5 @@ "dicer": "^0.3.0",

"devDependencies": {
"@firebase/app": "^0.6.1",
"@firebase/auth": "^0.13.3",
"@firebase/auth-types": "^0.9.3",
"@firebase/app": "^0.6.9",
"@firebase/auth": "^0.14.9",
"@firebase/auth-types": "^0.10.1",
"@types/bcrypt": "^2.0.0",

@@ -97,2 +98,3 @@ "@types/chai": "^4.0.0",

"gulp": "^4.0.2",
"gulp-filter": "^6.0.0",
"gulp-header": "^1.8.8",

@@ -99,0 +101,0 @@ "gulp-replace": "^0.5.4",

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

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

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc