initial commit

This commit is contained in:
2025-09-01 22:12:29 +02:00
parent b1873f9c1d
commit 02a54f61c0
5598 changed files with 903558 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2018 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.
*/
import { AppMetadata, AppPlatform } from './app-metadata';
/**
* Metadata about a Firebase Android App.
*/
export interface AndroidAppMetadata extends AppMetadata {
platform: AppPlatform.ANDROID;
/**
* The canonical package name of the Android App, as would appear in the Google Play Developer
* Console.
*
* @example
* ```javascript
* var packageName = androidAppMetadata.packageName;
* ```
*/
packageName: string;
}
/**
* A reference to a Firebase Android app.
*
* Do not call this constructor directly. Instead, use {@link ProjectManagement.androidApp}.
*/
export declare class AndroidApp {
readonly appId: string;
private readonly requestHandler;
private readonly resourceName;
/**
* Retrieves metadata about this Android app.
*
* @returns A promise that resolves to the retrieved metadata about this Android app.
*/
getMetadata(): Promise<AndroidAppMetadata>;
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName - The new display name to set.
*
* @returns A promise that resolves when the display name has been set.
*/
setDisplayName(newDisplayName: string): Promise<void>;
/**
* Gets the list of SHA certificates associated with this Android app in Firebase.
*
* @returns The list of SHA-1 and SHA-256 certificates associated with this Android app in
* Firebase.
*/
getShaCertificates(): Promise<ShaCertificate[]>;
/**
* Adds the given SHA certificate to this Android app.
*
* @param certificateToAdd - The SHA certificate to add.
*
* @returns A promise that resolves when the given certificate
* has been added to the Android app.
*/
addShaCertificate(certificateToAdd: ShaCertificate): Promise<void>;
/**
* Deletes the specified SHA certificate from this Android app.
*
* @param certificateToDelete - The SHA certificate to delete.
*
* @returns A promise that resolves when the specified
* certificate has been removed from the Android app.
*/
deleteShaCertificate(certificateToDelete: ShaCertificate): Promise<void>;
/**
* Gets the configuration artifact associated with this app.
*
* @returns 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.
*/
getConfig(): Promise<string>;
}
/**
* A SHA-1 or SHA-256 certificate.
*
* Do not call this constructor directly. Instead, use
* [`projectManagement.shaCertificate()`](projectManagement.ProjectManagement#shaCertificate).
*/
export declare class ShaCertificate {
readonly shaHash: string;
readonly resourceName?: string | undefined;
/**
* The SHA certificate type.
*
* @example
* ```javascript
* var certType = shaCertificate.certType;
* ```
*/
readonly certType: ('sha1' | 'sha256');
}

View File

@@ -0,0 +1,183 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2018 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.ShaCertificate = exports.AndroidApp = void 0;
const error_1 = require("../utils/error");
const validator = require("../utils/validator");
const project_management_api_request_internal_1 = require("./project-management-api-request-internal");
const app_metadata_1 = require("./app-metadata");
/**
* A reference to a Firebase Android app.
*
* Do not call this constructor directly. Instead, use {@link ProjectManagement.androidApp}.
*/
class AndroidApp {
/**
* @internal
*/
constructor(appId, requestHandler) {
this.appId = appId;
this.requestHandler = requestHandler;
if (!validator.isNonEmptyString(appId)) {
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'appId must be a non-empty string.');
}
this.resourceName = `projects/-/androidApps/${appId}`;
}
/**
* Retrieves metadata about this Android app.
*
* @returns A promise that resolves to the retrieved metadata about this Android app.
*/
getMetadata() {
return this.requestHandler.getResource(this.resourceName)
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
const requiredFieldsList = ['name', 'appId', 'projectId', 'packageName'];
requiredFieldsList.forEach((requiredField) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(responseData[requiredField]), responseData, `getMetadata()'s responseData.${requiredField} must be a non-empty string.`);
});
const metadata = {
platform: app_metadata_1.AppPlatform.ANDROID,
resourceName: responseData.name,
appId: responseData.appId,
displayName: responseData.displayName || null,
projectId: responseData.projectId,
packageName: responseData.packageName,
};
return metadata;
});
}
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName - The new display name to set.
*
* @returns A promise that resolves when the display name has been set.
*/
setDisplayName(newDisplayName) {
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
}
/**
* Gets the list of SHA certificates associated with this Android app in Firebase.
*
* @returns The list of SHA-1 and SHA-256 certificates associated with this Android app in
* Firebase.
*/
getShaCertificates() {
return this.requestHandler.getAndroidShaCertificates(this.resourceName)
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'getShaCertificates()\'s responseData must be a non-null object.');
if (!responseData.certificates) {
return [];
}
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isArray(responseData.certificates), responseData, '"certificates" field must be present in the getShaCertificates() response data.');
const requiredFieldsList = ['name', 'shaHash'];
return responseData.certificates.map((certificateJson) => {
requiredFieldsList.forEach((requiredField) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(certificateJson[requiredField]), responseData, `getShaCertificates()'s responseData.certificates[].${requiredField} must be a `
+ 'non-empty string.');
});
return new ShaCertificate(certificateJson.shaHash, certificateJson.name);
});
});
}
/**
* Adds the given SHA certificate to this Android app.
*
* @param certificateToAdd - The SHA certificate to add.
*
* @returns A promise that resolves when the given certificate
* has been added to the Android app.
*/
addShaCertificate(certificateToAdd) {
return this.requestHandler.addAndroidShaCertificate(this.resourceName, certificateToAdd);
}
/**
* Deletes the specified SHA certificate from this Android app.
*
* @param certificateToDelete - The SHA certificate to delete.
*
* @returns A promise that resolves when the specified
* certificate has been removed from the Android app.
*/
deleteShaCertificate(certificateToDelete) {
if (!certificateToDelete.resourceName) {
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'Specified certificate does not include a resourceName. (Use AndroidApp.getShaCertificates() to retrieve ' +
'certificates with a resourceName.');
}
return this.requestHandler.deleteResource(certificateToDelete.resourceName);
}
/**
* Gets the configuration artifact associated with this app.
*
* @returns 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.
*/
getConfig() {
return this.requestHandler.getConfig(this.resourceName)
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
const base64ConfigFileContents = responseData.configFileContents;
(0, 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');
});
}
}
exports.AndroidApp = AndroidApp;
/**
* A SHA-1 or SHA-256 certificate.
*
* Do not call this constructor directly. Instead, use
* [`projectManagement.shaCertificate()`](projectManagement.ProjectManagement#shaCertificate).
*/
class ShaCertificate {
/**
* Creates a ShaCertificate using the given hash. The ShaCertificate's type (eg. 'sha256') is
* automatically determined from the hash itself.
*
* @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;
* ```
*
* @internal
*/
constructor(shaHash, resourceName) {
this.shaHash = shaHash;
this.resourceName = resourceName;
if (/^[a-fA-F0-9]{40}$/.test(shaHash)) {
this.certType = 'sha1';
}
else if (/^[a-fA-F0-9]{64}$/.test(shaHash)) {
this.certType = 'sha256';
}
else {
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'shaHash must be either a sha256 hash or a sha1 hash.');
}
}
}
exports.ShaCertificate = ShaCertificate;

View File

@@ -0,0 +1,85 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2021 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.
*/
/**
* Platforms with which a Firebase App can be associated.
*/
export declare enum AppPlatform {
/**
* Unknown state. This is only used for distinguishing unset values.
*/
PLATFORM_UNKNOWN = "PLATFORM_UNKNOWN",
/**
* The Firebase App is associated with iOS.
*/
IOS = "IOS",
/**
* The Firebase App is associated with Android.
*/
ANDROID = "ANDROID"
}
/**
* Metadata about a Firebase app.
*/
export interface AppMetadata {
/**
* The globally unique, Firebase-assigned identifier of the app.
*
* @example
* ```javascript
* var appId = appMetadata.appId;
* ```
*/
appId: string;
/**
* The optional user-assigned display name of the app.
*
* @example
* ```javascript
* var displayName = appMetadata.displayName;
* ```
*/
displayName?: string;
/**
* The development platform of the app. Supporting Android and iOS app platforms.
*
* @example
* ```javascript
* var platform = AppPlatform.ANDROID;
* ```
*/
platform: AppPlatform;
/**
* The globally unique, user-assigned ID of the parent project for the app.
*
* @example
* ```javascript
* var projectId = appMetadata.projectId;
* ```
*/
projectId: string;
/**
* The fully-qualified resource name that identifies this app.
*
* This is useful when manually constructing requests for Firebase's public API.
*
* @example
* ```javascript
* var resourceName = androidAppMetadata.resourceName;
* ```
*/
resourceName: string;
}

View File

@@ -0,0 +1,37 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2021 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.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 = AppPlatform = {}));

View File

@@ -0,0 +1,54 @@
/*! firebase-admin v13.5.0 */
/*!
* 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.
*/
/**
* Firebase project management.
*
* @packageDocumentation
*/
import { App } from '../app';
import { ProjectManagement } from './project-management';
export { AppMetadata, AppPlatform } from './app-metadata';
export { ProjectManagement } from './project-management';
export { AndroidApp, AndroidAppMetadata, ShaCertificate } from './android-app';
export { IosApp, IosAppMetadata } from './ios-app';
/**
* Gets the {@link ProjectManagement} service for the default app or a given app.
*
* `getProjectManagement()` can be called with no arguments to access the
* default app's `ProjectManagement` service, or as `getProjectManagement(app)` to access
* the `ProjectManagement` service associated with a specific app.
*
* @example
* ```javascript
* // Get the ProjectManagement service for the default app
* const defaultProjectManagement = getProjectManagement();
* ```
*
* @example
* ```javascript
* // Get the ProjectManagement service for a given app
* const otherProjectManagement = getProjectManagement(otherApp);
* ```
*
* @param app - Optional app whose `ProjectManagement` service
* to return. If not provided, the default `ProjectManagement` service will
* be returned. *
* @returns The default `ProjectManagement` service if no app is provided or the
* `ProjectManagement` service associated with the provided app.
*/
export declare function getProjectManagement(app?: App): ProjectManagement;
export { FirebaseProjectManagementError, ProjectManagementErrorCode } from '../utils/error';

View File

@@ -0,0 +1,70 @@
/*! firebase-admin v13.5.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.FirebaseProjectManagementError = exports.IosApp = exports.ShaCertificate = exports.AndroidApp = exports.ProjectManagement = exports.AppPlatform = void 0;
exports.getProjectManagement = getProjectManagement;
/**
* Firebase project management.
*
* @packageDocumentation
*/
const app_1 = require("../app");
const project_management_1 = require("./project-management");
var app_metadata_1 = require("./app-metadata");
Object.defineProperty(exports, "AppPlatform", { enumerable: true, get: function () { return app_metadata_1.AppPlatform; } });
var project_management_2 = require("./project-management");
Object.defineProperty(exports, "ProjectManagement", { enumerable: true, get: function () { return project_management_2.ProjectManagement; } });
var android_app_1 = require("./android-app");
Object.defineProperty(exports, "AndroidApp", { enumerable: true, get: function () { return android_app_1.AndroidApp; } });
Object.defineProperty(exports, "ShaCertificate", { enumerable: true, get: function () { return android_app_1.ShaCertificate; } });
var ios_app_1 = require("./ios-app");
Object.defineProperty(exports, "IosApp", { enumerable: true, get: function () { return ios_app_1.IosApp; } });
/**
* Gets the {@link ProjectManagement} service for the default app or a given app.
*
* `getProjectManagement()` can be called with no arguments to access the
* default app's `ProjectManagement` service, or as `getProjectManagement(app)` to access
* the `ProjectManagement` service associated with a specific app.
*
* @example
* ```javascript
* // Get the ProjectManagement service for the default app
* const defaultProjectManagement = getProjectManagement();
* ```
*
* @example
* ```javascript
* // Get the ProjectManagement service for a given app
* const otherProjectManagement = getProjectManagement(otherApp);
* ```
*
* @param app - Optional app whose `ProjectManagement` service
* to return. If not provided, the default `ProjectManagement` service will
* be returned. *
* @returns The default `ProjectManagement` service if no app is provided or the
* `ProjectManagement` service associated with the provided app.
*/
function getProjectManagement(app) {
if (typeof app === 'undefined') {
app = (0, app_1.getApp)();
}
const firebaseApp = app;
return firebaseApp.getOrInitService('projectManagement', (app) => new project_management_1.ProjectManagement(app));
}
var error_1 = require("../utils/error");
Object.defineProperty(exports, "FirebaseProjectManagementError", { enumerable: true, get: function () { return error_1.FirebaseProjectManagementError; } });

View File

@@ -0,0 +1,66 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2018 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.
*/
import { AppMetadata, AppPlatform } from './app-metadata';
/**
* Metadata about a Firebase iOS App.
*/
export interface IosAppMetadata extends AppMetadata {
platform: AppPlatform.IOS;
/**
* The canonical bundle ID of the iOS App as it would appear in the iOS App Store.
*
* @example
* ```javascript
* var bundleId = iosAppMetadata.bundleId;
*```
*/
bundleId: string;
}
/**
* A reference to a Firebase iOS app.
*
* Do not call this constructor directly. Instead, use {@link ProjectManagement.iosApp}.
*/
export declare class IosApp {
readonly appId: string;
private readonly requestHandler;
private readonly resourceName;
/**
* Retrieves metadata about this iOS app.
*
* @returns A promise that
* resolves to the retrieved metadata about this iOS app.
*/
getMetadata(): Promise<IosAppMetadata>;
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName - The new display name to set.
*
* @returns A promise that resolves when the display name has
* been set.
*/
setDisplayName(newDisplayName: string): Promise<void>;
/**
* Gets the configuration artifact associated with this app.
*
* @returns 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.
*/
getConfig(): Promise<string>;
}

View File

@@ -0,0 +1,94 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2018 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.IosApp = void 0;
const error_1 = require("../utils/error");
const validator = require("../utils/validator");
const project_management_api_request_internal_1 = require("./project-management-api-request-internal");
const app_metadata_1 = require("./app-metadata");
/**
* A reference to a Firebase iOS app.
*
* Do not call this constructor directly. Instead, use {@link ProjectManagement.iosApp}.
*/
class IosApp {
/**
* @internal
*/
constructor(appId, requestHandler) {
this.appId = appId;
this.requestHandler = requestHandler;
if (!validator.isNonEmptyString(appId)) {
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'appId must be a non-empty string.');
}
this.resourceName = `projects/-/iosApps/${appId}`;
}
/**
* Retrieves metadata about this iOS app.
*
* @returns A promise that
* resolves to the retrieved metadata about this iOS app.
*/
getMetadata() {
return this.requestHandler.getResource(this.resourceName)
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
const requiredFieldsList = ['name', 'appId', 'projectId', 'bundleId'];
requiredFieldsList.forEach((requiredField) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(responseData[requiredField]), responseData, `getMetadata()'s responseData.${requiredField} must be a non-empty string.`);
});
const metadata = {
platform: app_metadata_1.AppPlatform.IOS,
resourceName: responseData.name,
appId: responseData.appId,
displayName: responseData.displayName || null,
projectId: responseData.projectId,
bundleId: responseData.bundleId,
};
return metadata;
});
}
/**
* Sets the optional user-assigned display name of the app.
*
* @param newDisplayName - The new display name to set.
*
* @returns A promise that resolves when the display name has
* been set.
*/
setDisplayName(newDisplayName) {
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
}
/**
* Gets the configuration artifact associated with this app.
*
* @returns 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.
*/
getConfig() {
return this.requestHandler.getConfig(this.resourceName)
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
const base64ConfigFileContents = responseData.configFileContents;
(0, 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');
});
}
}
exports.IosApp = IosApp;

View File

@@ -0,0 +1,17 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2018 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.
*/
export declare function assertServerResponse(condition: boolean, responseData: object, message: string): void;

View File

@@ -0,0 +1,268 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2018 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.ProjectManagementRequestHandler = void 0;
exports.assertServerResponse = assertServerResponse;
const api_request_1 = require("../utils/api-request");
const error_1 = require("../utils/error");
const index_1 = require("../utils/index");
const validator = require("../utils/validator");
/** Project management backend host and port. */
const PROJECT_MANAGEMENT_HOST_AND_PORT = 'firebase.googleapis.com:443';
/** Project management backend path. */
const PROJECT_MANAGEMENT_PATH = '/v1/';
/** Project management beta backend path. */
const PROJECT_MANAGEMENT_BETA_PATH = '/v1beta1/';
/** Project management request header. */
const PROJECT_MANAGEMENT_HEADERS = {
'X-Client-Version': `Node/Admin/${(0, index_1.getSdkVersion)()}`,
};
/** Project management request timeout duration in milliseconds. */
const PROJECT_MANAGEMENT_TIMEOUT_MILLIS = 10000;
const LIST_APPS_MAX_PAGE_SIZE = 100;
const CERT_TYPE_API_MAP = {
sha1: 'SHA_1',
sha256: 'SHA_256',
};
function assertServerResponse(condition, responseData, message) {
if (!condition) {
throw new error_1.FirebaseProjectManagementError('invalid-server-response', `${message} Response data: ${JSON.stringify(responseData, null, 2)}`);
}
}
/**
* Class that provides mechanism to send requests to the Firebase project management backend
* endpoints.
*
* @internal
*/
class ProjectManagementRequestHandler {
static wrapAndRethrowHttpError(errStatusCode, errText) {
let errorCode;
let errorMessage;
switch (errStatusCode) {
case 400:
errorCode = 'invalid-argument';
errorMessage = 'Invalid argument provided.';
break;
case 401:
case 403:
errorCode = 'authentication-error';
errorMessage = 'An error occurred when trying to authenticate. Make sure the credential '
+ 'used to authenticate this SDK has the proper permissions. See '
+ 'https://firebase.google.com/docs/admin/setup for setup instructions.';
break;
case 404:
errorCode = 'not-found';
errorMessage = 'The specified entity could not be found.';
break;
case 409:
errorCode = 'already-exists';
errorMessage = 'The specified entity already exists.';
break;
case 500:
errorCode = 'internal-error';
errorMessage = 'An internal error has occurred. Please retry the request.';
break;
case 503:
errorCode = 'service-unavailable';
errorMessage = 'The server could not process the request in time. See the error '
+ 'documentation for more details.';
break;
default:
errorCode = 'unknown-error';
errorMessage = 'An unknown server error was returned.';
}
if (!errText) {
errText = '<missing>';
}
throw new error_1.FirebaseProjectManagementError(errorCode, `${errorMessage} Status code: ${errStatusCode}. Raw server response: "${errText}".`);
}
/**
* @param app - The app used to fetch access tokens to sign API requests.
* @constructor
*/
constructor(app) {
this.baseUrl = `https://${PROJECT_MANAGEMENT_HOST_AND_PORT}${PROJECT_MANAGEMENT_PATH}`;
this.baseBetaUrl = `https://${PROJECT_MANAGEMENT_HOST_AND_PORT}${PROJECT_MANAGEMENT_BETA_PATH}`;
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
}
/**
* @param parentResourceName - Fully-qualified resource name of the project whose Android
* apps you want to list.
*/
listAndroidApps(parentResourceName) {
return this.invokeRequestHandler('GET', `${parentResourceName}/androidApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
/* requestData */ null, 'v1beta1');
}
/**
* @param parentResourceName - Fully-qualified resource name of the project whose iOS apps
* you want to list.
*/
listIosApps(parentResourceName) {
return this.invokeRequestHandler('GET', `${parentResourceName}/iosApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
/* requestData */ null, 'v1beta1');
}
/**
* @param parentResourceName - Fully-qualified resource name of the project whose iOS apps
* you want to list.
*/
listAppMetadata(parentResourceName) {
return this.invokeRequestHandler('GET', `${parentResourceName}:searchApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
/* requestData */ null, 'v1beta1');
}
/**
* @param parentResourceName - Fully-qualified resource name of the project that you want
* to create the Android app within.
*/
createAndroidApp(parentResourceName, packageName, displayName) {
const requestData = {
packageName,
};
if (validator.isNonEmptyString(displayName)) {
requestData.displayName = displayName;
}
return this
.invokeRequestHandler('POST', `${parentResourceName}/androidApps`, requestData, 'v1beta1')
.then((responseData) => {
assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp\'s responseData must be a non-null object.');
assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createAndroidApp\'s responseData.name must be a non-empty string.');
return this.pollRemoteOperationWithExponentialBackoff(responseData.name);
});
}
/**
* @param parentResourceName - Fully-qualified resource name of the project that you want
* to create the iOS app within.
*/
createIosApp(parentResourceName, bundleId, displayName) {
const requestData = {
bundleId,
};
if (validator.isNonEmptyString(displayName)) {
requestData.displayName = displayName;
}
return this
.invokeRequestHandler('POST', `${parentResourceName}/iosApps`, requestData, 'v1beta1')
.then((responseData) => {
assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp\'s responseData must be a non-null object.');
assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createIosApp\'s responseData.name must be a non-empty string.');
return this.pollRemoteOperationWithExponentialBackoff(responseData.name);
});
}
/**
* @param resourceName - Fully-qualified resource name of the entity whose display name you
* want to set.
*/
setDisplayName(resourceName, newDisplayName) {
const requestData = {
displayName: newDisplayName,
};
return this
.invokeRequestHandler('PATCH', `${resourceName}?update_mask=display_name`, requestData, 'v1beta1')
.then(() => undefined);
}
/**
* @param parentResourceName - Fully-qualified resource name of the Android app whose SHA
* certificates you want to get.
*/
getAndroidShaCertificates(parentResourceName) {
return this.invokeRequestHandler('GET', `${parentResourceName}/sha`, /* requestData */ null, 'v1beta1');
}
/**
* @param parentResourceName - Fully-qualified resource name of the Android app that you
* want to add the given SHA certificate to.
*/
addAndroidShaCertificate(parentResourceName, certificate) {
const requestData = {
shaHash: certificate.shaHash,
certType: CERT_TYPE_API_MAP[certificate.certType],
};
return this
.invokeRequestHandler('POST', `${parentResourceName}/sha`, requestData, 'v1beta1')
.then(() => undefined);
}
/**
* @param parentResourceName - Fully-qualified resource name of the app whose config you
* want to get.
*/
getConfig(parentResourceName) {
return this.invokeRequestHandler('GET', `${parentResourceName}/config`, /* requestData */ null, 'v1beta1');
}
/**
* @param parentResourceName - Fully-qualified resource name of the entity that you want to
* get.
*/
getResource(parentResourceName) {
return this.invokeRequestHandler('GET', parentResourceName, /* requestData */ null, 'v1beta1');
}
/**
* @param resourceName - Fully-qualified resource name of the entity that you want to
* delete.
*/
deleteResource(resourceName) {
return this
.invokeRequestHandler('DELETE', resourceName, /* requestData */ null, 'v1beta1')
.then(() => undefined);
}
pollRemoteOperationWithExponentialBackoff(operationResourceName) {
const poller = new api_request_1.ExponentialBackoffPoller();
return poller.poll(() => {
return this.invokeRequestHandler('GET', operationResourceName, /* requestData */ null)
.then((responseData) => {
if (responseData.error) {
const errStatusCode = responseData.error.code || 500;
const errText = responseData.error.message || JSON.stringify(responseData.error);
ProjectManagementRequestHandler.wrapAndRethrowHttpError(errStatusCode, errText);
}
if (!responseData.done) {
// Continue polling.
return null;
}
// Polling complete. Resolve with operation response JSON.
return responseData.response;
});
});
}
/**
* Invokes the request handler with the provided request data.
*/
invokeRequestHandler(method, path, requestData, apiVersion = 'v1') {
const baseUrlToUse = (apiVersion === 'v1') ? this.baseUrl : this.baseBetaUrl;
const request = {
method,
url: `${baseUrlToUse}${path}`,
headers: PROJECT_MANAGEMENT_HEADERS,
data: requestData,
timeout: PROJECT_MANAGEMENT_TIMEOUT_MILLIS,
};
return this.httpClient.send(request)
.then((response) => {
// Send non-JSON responses to the catch() below, where they will be treated as errors.
if (!response.isJson()) {
throw new api_request_1.RequestResponseError(response);
}
return response.data;
})
.catch((err) => {
if (err instanceof api_request_1.RequestResponseError) {
ProjectManagementRequestHandler.wrapAndRethrowHttpError(err.response.status, err.response.text);
}
throw err;
});
}
}
exports.ProjectManagementRequestHandler = ProjectManagementRequestHandler;

View File

@@ -0,0 +1,82 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2021 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.
*/
import { App } from '../app';
import { AppMetadata as TAppMetadata, AppPlatform as TAppPlatform } from './app-metadata';
import { ProjectManagement as TProjectManagement } from './project-management';
import { AndroidApp as TAndroidApp, AndroidAppMetadata as TAndroidAppMetadata, ShaCertificate as TShaCertificate } from './android-app';
import { IosApp as TIosApp, IosAppMetadata as TIosAppMetadata } from './ios-app';
/**
* Gets the {@link firebase-admin.project-management#ProjectManagement} service for the
* default app or a given app.
*
* `admin.projectManagement()` can be called with no arguments to access the
* default app's `ProjectManagement` service, or as `admin.projectManagement(app)` to access
* the `ProjectManagement` service associated with a specific app.
*
* @example
* ```javascript
* // Get the ProjectManagement service for the default app
* var defaultProjectManagement = admin.projectManagement();
* ```
*
* @example
* ```javascript
* // Get the ProjectManagement service for a given app
* var otherProjectManagement = admin.projectManagement(otherApp);
* ```
*
* @param app - Optional app whose `ProjectManagement` service
* to return. If not provided, the default `ProjectManagement` service will
* be returned. *
* @returns The default `ProjectManagement` service if no app is provided or the
* `ProjectManagement` service associated with the provided app.
*/
export declare function projectManagement(app?: App): projectManagement.ProjectManagement;
export declare namespace projectManagement {
/**
* Type alias to {@link firebase-admin.project-management#AppMetadata}.
*/
type AppMetadata = TAppMetadata;
/**
* Type alias to {@link firebase-admin.project-management#AppPlatform}.
*/
type AppPlatform = TAppPlatform;
/**
* Type alias to {@link firebase-admin.project-management#ProjectManagement}.
*/
type ProjectManagement = TProjectManagement;
/**
* Type alias to {@link firebase-admin.project-management#IosApp}.
*/
type IosApp = TIosApp;
/**
* Type alias to {@link firebase-admin.project-management#IosAppMetadata}.
*/
type IosAppMetadata = TIosAppMetadata;
/**
* Type alias to {@link firebase-admin.project-management#AndroidApp}.
*/
type AndroidApp = TAndroidApp;
/**
* Type alias to {@link firebase-admin.project-management#AndroidAppMetadata}.
*/
type AndroidAppMetadata = TAndroidAppMetadata;
/**
* Type alias to {@link firebase-admin.project-management#ShaCertificate}.
*/
type ShaCertificate = TShaCertificate;
}

View File

@@ -0,0 +1,18 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2021 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 });

View File

@@ -0,0 +1,115 @@
/*! firebase-admin v13.5.0 */
/*!
* Copyright 2018 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.
*/
import { App } from '../app';
import { AndroidApp, ShaCertificate } from './android-app';
import { IosApp } from './ios-app';
import { AppMetadata } from './app-metadata';
/**
* The Firebase ProjectManagement service interface.
*/
export declare class ProjectManagement {
readonly app: App;
private readonly requestHandler;
private projectId;
/**
* Lists up to 100 Firebase Android apps associated with this Firebase project.
*
* @returns The list of Android apps.
*/
listAndroidApps(): Promise<AndroidApp[]>;
/**
* Lists up to 100 Firebase iOS apps associated with this Firebase project.
*
* @returns The list of iOS apps.
*/
listIosApps(): Promise<IosApp[]>;
/**
* 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.
*
* @returns An `AndroidApp` object that references the specified Firebase Android app.
*/
androidApp(appId: string): AndroidApp;
/**
* 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.
*
* @returns An `iOSApp` object that references the specified Firebase iOS app.
*/
iosApp(appId: string): IosApp;
/**
* Creates a `ShaCertificate` object.
*
* This method does not perform an RPC.
*
* @param shaHash - The SHA-1 or SHA-256 hash for this certificate.
*
* @returns A `ShaCertificate` object contains the specified SHA hash.
*/
shaCertificate(shaHash: string): ShaCertificate;
/**
* 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.
*
* @returns A promise that resolves to the newly created Android app.
*/
createAndroidApp(packageName: string, displayName?: string): Promise<AndroidApp>;
/**
* 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.
*
* @returns A promise that resolves to the newly created iOS app.
*/
createIosApp(bundleId: string, displayName?: string): Promise<IosApp>;
/**
* Lists up to 100 Firebase apps associated with this Firebase project.
*
* @returns A promise that resolves to the metadata list of the apps.
*/
listAppMetadata(): Promise<AppMetadata[]>;
/**
* Update the display name of this Firebase project.
*
* @param newDisplayName - The new display name to be updated.
*
* @returns A promise that resolves when the project display name has been updated.
*/
setDisplayName(newDisplayName: string): Promise<void>;
private transformResponseToAppMetadata;
private getResourceName;
private getProjectId;
/**
* Lists up to 100 Firebase apps for a specified platform, associated with this Firebase project.
*/
private listPlatformApps;
private assertListAppsResponseData;
}

View File

@@ -0,0 +1,244 @@
/*! firebase-admin v13.5.0 */
"use strict";
/*!
* Copyright 2018 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.ProjectManagement = void 0;
const error_1 = require("../utils/error");
const utils = require("../utils/index");
const validator = require("../utils/validator");
const android_app_1 = require("./android-app");
const ios_app_1 = require("./ios-app");
const project_management_api_request_internal_1 = require("./project-management-api-request-internal");
const app_metadata_1 = require("./app-metadata");
/**
* The Firebase ProjectManagement service interface.
*/
class ProjectManagement {
/**
* @param app - The app for this ProjectManagement service.
* @constructor
* @internal
*/
constructor(app) {
this.app = app;
if (!validator.isNonNullObject(app) || !('options' in app)) {
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'First argument passed to admin.projectManagement() must be a valid Firebase app '
+ 'instance.');
}
this.requestHandler = new project_management_api_request_internal_1.ProjectManagementRequestHandler(app);
}
/**
* Lists up to 100 Firebase Android apps associated with this Firebase project.
*
* @returns The list of Android apps.
*/
listAndroidApps() {
return this.listPlatformApps('android', 'listAndroidApps()');
}
/**
* Lists up to 100 Firebase iOS apps associated with this Firebase project.
*
* @returns The list of iOS apps.
*/
listIosApps() {
return this.listPlatformApps('ios', 'listIosApps()');
}
/**
* 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.
*
* @returns An `AndroidApp` object that references the specified Firebase Android app.
*/
androidApp(appId) {
return new android_app_1.AndroidApp(appId, this.requestHandler);
}
/**
* 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.
*
* @returns An `iOSApp` object that references the specified Firebase iOS app.
*/
iosApp(appId) {
return new ios_app_1.IosApp(appId, this.requestHandler);
}
/**
* Creates a `ShaCertificate` object.
*
* This method does not perform an RPC.
*
* @param shaHash - The SHA-1 or SHA-256 hash for this certificate.
*
* @returns A `ShaCertificate` object contains the specified SHA hash.
*/
shaCertificate(shaHash) {
return new android_app_1.ShaCertificate(shaHash);
}
/**
* 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.
*
* @returns A promise that resolves to the newly created Android app.
*/
createAndroidApp(packageName, displayName) {
return this.getResourceName()
.then((resourceName) => {
return this.requestHandler.createAndroidApp(resourceName, packageName, displayName);
})
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
(0, 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);
});
}
/**
* 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.
*
* @returns A promise that resolves to the newly created iOS app.
*/
createIosApp(bundleId, displayName) {
return this.getResourceName()
.then((resourceName) => {
return this.requestHandler.createIosApp(resourceName, bundleId, displayName);
})
.then((responseData) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
(0, 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);
});
}
/**
* Lists up to 100 Firebase apps associated with this Firebase project.
*
* @returns A promise that resolves to the metadata list of the apps.
*/
listAppMetadata() {
return this.getResourceName()
.then((resourceName) => {
return this.requestHandler.listAppMetadata(resourceName);
})
.then((responseData) => {
return this.getProjectId()
.then((projectId) => {
return this.transformResponseToAppMetadata(responseData, projectId);
});
});
}
/**
* Update the display name of this Firebase project.
*
* @param newDisplayName - The new display name to be updated.
*
* @returns A promise that resolves when the project display name has been updated.
*/
setDisplayName(newDisplayName) {
return this.getResourceName()
.then((resourceName) => {
return this.requestHandler.setDisplayName(resourceName, newDisplayName);
});
}
transformResponseToAppMetadata(responseData, projectId) {
this.assertListAppsResponseData(responseData, 'listAppMetadata()');
if (!responseData.apps) {
return [];
}
return responseData.apps.map((appJson) => {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(appJson.appId), responseData, '"apps[].appId" field must be present in the listAppMetadata() response data.');
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(appJson.platform), responseData, '"apps[].platform" field must be present in the listAppMetadata() response data.');
const metadata = {
appId: appJson.appId,
platform: app_metadata_1.AppPlatform[appJson.platform] || app_metadata_1.AppPlatform.PLATFORM_UNKNOWN,
projectId,
resourceName: appJson.name,
};
if (appJson.displayName) {
metadata.displayName = appJson.displayName;
}
return metadata;
});
}
getResourceName() {
return this.getProjectId()
.then((projectId) => {
return `projects/${projectId}`;
});
}
getProjectId() {
if (this.projectId) {
return Promise.resolve(this.projectId);
}
return utils.findProjectId(this.app)
.then((projectId) => {
// Assert that a specific project ID was provided within the app.
if (!validator.isNonEmptyString(projectId)) {
throw new error_1.FirebaseProjectManagementError('invalid-project-id', '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.projectId = projectId;
return this.projectId;
});
}
/**
* Lists up to 100 Firebase apps for a specified platform, associated with this Firebase project.
*/
listPlatformApps(platform, callerName) {
return this.getResourceName()
.then((resourceName) => {
return (platform === 'android') ?
this.requestHandler.listAndroidApps(resourceName)
: this.requestHandler.listIosApps(resourceName);
})
.then((responseData) => {
this.assertListAppsResponseData(responseData, callerName);
if (!responseData.apps) {
return [];
}
return responseData.apps.map((appJson) => {
(0, 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') {
return new android_app_1.AndroidApp(appJson.appId, this.requestHandler);
}
else {
return new ios_app_1.IosApp(appJson.appId, this.requestHandler);
}
});
});
}
assertListAppsResponseData(responseData, callerName) {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, `${callerName}'s responseData must be a non-null object.`);
if (responseData.apps) {
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isArray(responseData.apps), responseData, `"apps" field must be present in the ${callerName} response data.`);
}
}
}
exports.ProjectManagement = ProjectManagement;