mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 17:06:00 +00:00
Modules
This commit is contained in:
122
node_modules/firebase-admin/lib/project-management/android-app.js
generated
vendored
Normal file
122
node_modules/firebase-admin/lib/project-management/android-app.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
/*! firebase-admin v8.9.2 */
|
||||
"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 });
|
||||
var error_1 = require("../utils/error");
|
||||
var validator = require("../utils/validator");
|
||||
var project_management_api_request_1 = require("./project-management-api-request");
|
||||
var app_metadata_1 = require("./app-metadata");
|
||||
var AndroidApp = /** @class */ (function () {
|
||||
function AndroidApp(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;
|
||||
}
|
||||
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.');
|
||||
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.");
|
||||
});
|
||||
var 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;
|
||||
});
|
||||
};
|
||||
AndroidApp.prototype.setDisplayName = function (newDisplayName) {
|
||||
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
|
||||
};
|
||||
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.');
|
||||
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.');
|
||||
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 "
|
||||
+ "non-empty string.");
|
||||
});
|
||||
return new ShaCertificate(certificateJson.shaHash, certificateJson.name);
|
||||
});
|
||||
});
|
||||
};
|
||||
AndroidApp.prototype.addShaCertificate = function (certificateToAdd) {
|
||||
return this.requestHandler.addAndroidShaCertificate(this.resourceName, certificateToAdd);
|
||||
};
|
||||
AndroidApp.prototype.deleteShaCertificate = function (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);
|
||||
};
|
||||
/**
|
||||
* @return {Promise<string>} A promise that resolves to a UTF-8 JSON string, typically intended to
|
||||
* be written to a JSON file.
|
||||
*/
|
||||
AndroidApp.prototype.getConfig = function () {
|
||||
return this.requestHandler.getConfig(this.resourceName)
|
||||
.then(function (responseData) {
|
||||
project_management_api_request_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.");
|
||||
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');
|
||||
});
|
||||
};
|
||||
return AndroidApp;
|
||||
}());
|
||||
exports.AndroidApp = AndroidApp;
|
||||
var ShaCertificate = /** @class */ (function () {
|
||||
/**
|
||||
* 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.
|
||||
* @param resourceName The Firebase resource name for this certificate. This does not need to be
|
||||
* set when creating a new certificate.
|
||||
*/
|
||||
function ShaCertificate(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.');
|
||||
}
|
||||
}
|
||||
return ShaCertificate;
|
||||
}());
|
||||
exports.ShaCertificate = ShaCertificate;
|
24
node_modules/firebase-admin/lib/project-management/app-metadata.js
generated
vendored
Normal file
24
node_modules/firebase-admin/lib/project-management/app-metadata.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! firebase-admin v8.9.2 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2019 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 });
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
AppPlatform["PLATFORM_UNKNOWN"] = "PLATFORM_UNKNOWN";
|
||||
AppPlatform["IOS"] = "IOS";
|
||||
AppPlatform["ANDROID"] = "ANDROID";
|
||||
})(AppPlatform = exports.AppPlatform || (exports.AppPlatform = {}));
|
69
node_modules/firebase-admin/lib/project-management/ios-app.js
generated
vendored
Normal file
69
node_modules/firebase-admin/lib/project-management/ios-app.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/*! firebase-admin v8.9.2 */
|
||||
"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 });
|
||||
var error_1 = require("../utils/error");
|
||||
var validator = require("../utils/validator");
|
||||
var project_management_api_request_1 = require("./project-management-api-request");
|
||||
var app_metadata_1 = require("./app-metadata");
|
||||
var IosApp = /** @class */ (function () {
|
||||
function IosApp(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;
|
||||
}
|
||||
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.');
|
||||
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.");
|
||||
});
|
||||
var 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;
|
||||
});
|
||||
};
|
||||
IosApp.prototype.setDisplayName = function (newDisplayName) {
|
||||
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.
|
||||
*/
|
||||
IosApp.prototype.getConfig = function () {
|
||||
return this.requestHandler.getConfig(this.resourceName)
|
||||
.then(function (responseData) {
|
||||
project_management_api_request_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.");
|
||||
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');
|
||||
});
|
||||
};
|
||||
return IosApp;
|
||||
}());
|
||||
exports.IosApp = IosApp;
|
271
node_modules/firebase-admin/lib/project-management/project-management-api-request.js
generated
vendored
Normal file
271
node_modules/firebase-admin/lib/project-management/project-management-api-request.js
generated
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
/*! firebase-admin v8.9.2 */
|
||||
"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 });
|
||||
var api_request_1 = require("../utils/api-request");
|
||||
var error_1 = require("../utils/error");
|
||||
var validator = require("../utils/validator");
|
||||
/** Project management backend host and port. */
|
||||
var PROJECT_MANAGEMENT_HOST_AND_PORT = 'firebase.googleapis.com:443';
|
||||
/** Project management backend path. */
|
||||
var PROJECT_MANAGEMENT_PATH = '/v1/';
|
||||
/** Project management beta backend path. */
|
||||
var PROJECT_MANAGEMENT_BETA_PATH = '/v1beta1/';
|
||||
/** Project management request header. */
|
||||
var PROJECT_MANAGEMENT_HEADERS = {
|
||||
'X-Client-Version': 'Node/Admin/8.9.2',
|
||||
};
|
||||
/** Project management request timeout duration in milliseconds. */
|
||||
var PROJECT_MANAGEMENT_TIMEOUT_MILLIS = 10000;
|
||||
var LIST_APPS_MAX_PAGE_SIZE = 100;
|
||||
var 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));
|
||||
}
|
||||
}
|
||||
exports.assertServerResponse = assertServerResponse;
|
||||
/**
|
||||
* Class that provides mechanism to send requests to the Firebase project management backend
|
||||
* endpoints.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var ProjectManagementRequestHandler = /** @class */ (function () {
|
||||
/**
|
||||
* @param {FirebaseApp} app The app used to fetch access tokens to sign API requests.
|
||||
* @constructor
|
||||
*/
|
||||
function ProjectManagementRequestHandler(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);
|
||||
}
|
||||
ProjectManagementRequestHandler.wrapAndRethrowHttpError = function (errStatusCode, errText) {
|
||||
var errorCode;
|
||||
var 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 {string} parentResourceName Fully-qualified resource name of the project whose Android
|
||||
* apps you want to list.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.listAndroidApps = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName + "/androidApps?page_size=" + LIST_APPS_MAX_PAGE_SIZE,
|
||||
/* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the project whose iOS apps
|
||||
* you want to list.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.listIosApps = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName + "/iosApps?page_size=" + LIST_APPS_MAX_PAGE_SIZE,
|
||||
/* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the project whose iOS apps
|
||||
* you want to list.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.listAppMetadata = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName + ":searchApps?page_size=" + LIST_APPS_MAX_PAGE_SIZE,
|
||||
/* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the project that you want
|
||||
* to create the Android app within.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.createAndroidApp = function (parentResourceName, packageName, displayName) {
|
||||
var _this = this;
|
||||
var requestData = {
|
||||
packageName: packageName,
|
||||
};
|
||||
if (validator.isNonEmptyString(displayName)) {
|
||||
requestData.displayName = displayName;
|
||||
}
|
||||
return this
|
||||
.invokeRequestHandler('POST', parentResourceName + "/androidApps", requestData, 'v1beta1')
|
||||
.then(function (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 {string} parentResourceName Fully-qualified resource name of the project that you want
|
||||
* to create the iOS app within.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.createIosApp = function (parentResourceName, bundleId, displayName) {
|
||||
var _this = this;
|
||||
var requestData = {
|
||||
bundleId: bundleId,
|
||||
};
|
||||
if (validator.isNonEmptyString(displayName)) {
|
||||
requestData.displayName = displayName;
|
||||
}
|
||||
return this
|
||||
.invokeRequestHandler('POST', parentResourceName + "/iosApps", requestData, 'v1beta1')
|
||||
.then(function (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 {string} resourceName Fully-qualified resource name of the entity whose display name you
|
||||
* want to set.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.setDisplayName = function (resourceName, newDisplayName) {
|
||||
var requestData = {
|
||||
displayName: newDisplayName,
|
||||
};
|
||||
return this
|
||||
.invokeRequestHandler('PATCH', resourceName + "?update_mask=display_name", requestData, 'v1beta1')
|
||||
.then(function () { return undefined; });
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the Android app whose SHA
|
||||
* certificates you want to get.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.getAndroidShaCertificates = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName + "/sha", /* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the Android app that you
|
||||
* want to add the given SHA certificate to.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.addAndroidShaCertificate = function (parentResourceName, certificate) {
|
||||
var requestData = {
|
||||
shaHash: certificate.shaHash,
|
||||
certType: CERT_TYPE_API_MAP[certificate.certType],
|
||||
};
|
||||
return this
|
||||
.invokeRequestHandler('POST', parentResourceName + "/sha", requestData, 'v1beta1')
|
||||
.then(function () { return undefined; });
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the app whose config you
|
||||
* want to get.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.getConfig = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName + "/config", /* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} parentResourceName Fully-qualified resource name of the entity that you want to
|
||||
* get.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.getResource = function (parentResourceName) {
|
||||
return this.invokeRequestHandler('GET', parentResourceName, /* requestData */ null, 'v1beta1');
|
||||
};
|
||||
/**
|
||||
* @param {string} resourceName Fully-qualified resource name of the entity that you want to
|
||||
* delete.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.deleteResource = function (resourceName) {
|
||||
return this
|
||||
.invokeRequestHandler('DELETE', resourceName, /* requestData */ null, 'v1beta1')
|
||||
.then(function () { return undefined; });
|
||||
};
|
||||
ProjectManagementRequestHandler.prototype.pollRemoteOperationWithExponentialBackoff = function (operationResourceName) {
|
||||
var _this = this;
|
||||
var poller = new api_request_1.ExponentialBackoffPoller();
|
||||
return poller.poll(function () {
|
||||
return _this.invokeRequestHandler('GET', operationResourceName, /* requestData */ null)
|
||||
.then(function (responseData) {
|
||||
if (responseData.error) {
|
||||
var errStatusCode = responseData.error.code || 500;
|
||||
var 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.
|
||||
*/
|
||||
ProjectManagementRequestHandler.prototype.invokeRequestHandler = function (method, path, requestData, apiVersion) {
|
||||
if (apiVersion === void 0) { apiVersion = 'v1'; }
|
||||
var baseUrlToUse = (apiVersion === 'v1') ? this.baseUrl : this.baseBetaUrl;
|
||||
var request = {
|
||||
method: method,
|
||||
url: "" + baseUrlToUse + path,
|
||||
headers: PROJECT_MANAGEMENT_HEADERS,
|
||||
data: requestData,
|
||||
timeout: PROJECT_MANAGEMENT_TIMEOUT_MILLIS,
|
||||
};
|
||||
return this.httpClient.send(request)
|
||||
.then(function (response) {
|
||||
// Send non-JSON responses to the catch() below, where they will be treated as errors.
|
||||
if (!response.isJson()) {
|
||||
throw new api_request_1.HttpError(response);
|
||||
}
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (err) {
|
||||
if (err instanceof api_request_1.HttpError) {
|
||||
ProjectManagementRequestHandler.wrapAndRethrowHttpError(err.response.status, err.response.text);
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
return ProjectManagementRequestHandler;
|
||||
}());
|
||||
exports.ProjectManagementRequestHandler = ProjectManagementRequestHandler;
|
224
node_modules/firebase-admin/lib/project-management/project-management.js
generated
vendored
Normal file
224
node_modules/firebase-admin/lib/project-management/project-management.js
generated
vendored
Normal file
@ -0,0 +1,224 @@
|
||||
/*! firebase-admin v8.9.2 */
|
||||
"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 });
|
||||
var error_1 = require("../utils/error");
|
||||
var utils = require("../utils/index");
|
||||
var validator = require("../utils/validator");
|
||||
var android_app_1 = require("./android-app");
|
||||
var ios_app_1 = require("./ios-app");
|
||||
var project_management_api_request_1 = require("./project-management-api-request");
|
||||
var app_metadata_1 = require("./app-metadata");
|
||||
/**
|
||||
* Internals of a Project Management instance.
|
||||
*/
|
||||
var ProjectManagementInternals = /** @class */ (function () {
|
||||
function ProjectManagementInternals() {
|
||||
}
|
||||
/**
|
||||
* Deletes the service and its associated resources.
|
||||
*
|
||||
* @return {Promise<void>} An empty Promise that will be resolved when the service is deleted.
|
||||
*/
|
||||
ProjectManagementInternals.prototype.delete = function () {
|
||||
// There are no resources to clean up.
|
||||
return Promise.resolve();
|
||||
};
|
||||
return ProjectManagementInternals;
|
||||
}());
|
||||
/**
|
||||
* ProjectManagement service bound to the provided app.
|
||||
*/
|
||||
var ProjectManagement = /** @class */ (function () {
|
||||
/**
|
||||
* @param {object} app The app for this ProjectManagement service.
|
||||
* @constructor
|
||||
*/
|
||||
function ProjectManagement(app) {
|
||||
this.app = app;
|
||||
this.INTERNAL = new ProjectManagementInternals();
|
||||
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_1.ProjectManagementRequestHandler(app);
|
||||
}
|
||||
/**
|
||||
* Lists up to 100 Firebase Android apps associated with this Firebase project.
|
||||
*/
|
||||
ProjectManagement.prototype.listAndroidApps = function () {
|
||||
return this.listPlatformApps('android', 'listAndroidApps()');
|
||||
};
|
||||
/**
|
||||
* Lists up to 100 Firebase iOS apps associated with this Firebase project.
|
||||
*/
|
||||
ProjectManagement.prototype.listIosApps = function () {
|
||||
return this.listPlatformApps('ios', 'listIosApps()');
|
||||
};
|
||||
/**
|
||||
* Returns an AndroidApp object for the given appId. No RPC is made.
|
||||
*/
|
||||
ProjectManagement.prototype.androidApp = function (appId) {
|
||||
return new android_app_1.AndroidApp(appId, this.requestHandler);
|
||||
};
|
||||
/**
|
||||
* Returns an IosApp object for the given appId. No RPC is made.
|
||||
*/
|
||||
ProjectManagement.prototype.iosApp = function (appId) {
|
||||
return new ios_app_1.IosApp(appId, this.requestHandler);
|
||||
};
|
||||
/**
|
||||
* Returns a ShaCertificate object for the given shaHash. No RPC is made.
|
||||
*/
|
||||
ProjectManagement.prototype.shaCertificate = function (shaHash) {
|
||||
return new android_app_1.ShaCertificate(shaHash);
|
||||
};
|
||||
/**
|
||||
* Creates a new Firebase Android app, associated with this Firebase project.
|
||||
*/
|
||||
ProjectManagement.prototype.createAndroidApp = function (packageName, displayName) {
|
||||
var _this = this;
|
||||
return this.getResourceName()
|
||||
.then(function (resourceName) {
|
||||
return _this.requestHandler.createAndroidApp(resourceName, 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.");
|
||||
return new android_app_1.AndroidApp(responseData.appId, _this.requestHandler);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Creates a new Firebase iOS app, associated with this Firebase project.
|
||||
*/
|
||||
ProjectManagement.prototype.createIosApp = function (bundleId, displayName) {
|
||||
var _this = this;
|
||||
return this.getResourceName()
|
||||
.then(function (resourceName) {
|
||||
return _this.requestHandler.createIosApp(resourceName, 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.");
|
||||
return new ios_app_1.IosApp(responseData.appId, _this.requestHandler);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Lists up to 100 Firebase apps associated with this Firebase project.
|
||||
*/
|
||||
ProjectManagement.prototype.listAppMetadata = function () {
|
||||
var _this = this;
|
||||
return this.getResourceName()
|
||||
.then(function (resourceName) {
|
||||
return _this.requestHandler.listAppMetadata(resourceName);
|
||||
})
|
||||
.then(function (responseData) {
|
||||
return _this.getProjectId()
|
||||
.then(function (projectId) {
|
||||
return _this.transformResponseToAppMetadata(responseData, projectId);
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Update display name of the project
|
||||
*/
|
||||
ProjectManagement.prototype.setDisplayName = function (newDisplayName) {
|
||||
var _this = this;
|
||||
return this.getResourceName()
|
||||
.then(function (resourceName) {
|
||||
return _this.requestHandler.setDisplayName(resourceName, newDisplayName);
|
||||
});
|
||||
};
|
||||
ProjectManagement.prototype.transformResponseToAppMetadata = function (responseData, projectId) {
|
||||
this.assertListAppsResponseData(responseData, 'listAppMetadata()');
|
||||
if (!responseData.apps) {
|
||||
return [];
|
||||
}
|
||||
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.");
|
||||
var metadata = {
|
||||
appId: appJson.appId,
|
||||
platform: app_metadata_1.AppPlatform[appJson.platform] || app_metadata_1.AppPlatform.PLATFORM_UNKNOWN,
|
||||
projectId: projectId,
|
||||
resourceName: appJson.name,
|
||||
};
|
||||
if (appJson.displayName) {
|
||||
metadata.displayName = appJson.displayName;
|
||||
}
|
||||
return metadata;
|
||||
});
|
||||
};
|
||||
ProjectManagement.prototype.getResourceName = function () {
|
||||
return this.getProjectId()
|
||||
.then(function (projectId) {
|
||||
return "projects/" + projectId;
|
||||
});
|
||||
};
|
||||
ProjectManagement.prototype.getProjectId = function () {
|
||||
var _this = this;
|
||||
if (this.projectId) {
|
||||
return Promise.resolve(this.projectId);
|
||||
}
|
||||
return utils.findProjectId(this.app)
|
||||
.then(function (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.
|
||||
*/
|
||||
ProjectManagement.prototype.listPlatformApps = function (platform, callerName) {
|
||||
var _this = this;
|
||||
return this.getResourceName()
|
||||
.then(function (resourceName) {
|
||||
return (platform === 'android') ?
|
||||
_this.requestHandler.listAndroidApps(resourceName)
|
||||
: _this.requestHandler.listIosApps(resourceName);
|
||||
})
|
||||
.then(function (responseData) {
|
||||
_this.assertListAppsResponseData(responseData, callerName);
|
||||
if (!responseData.apps) {
|
||||
return [];
|
||||
}
|
||||
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.");
|
||||
if (platform === 'android') {
|
||||
return new android_app_1.AndroidApp(appJson.appId, _this.requestHandler);
|
||||
}
|
||||
else {
|
||||
return new ios_app_1.IosApp(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.");
|
||||
if (responseData.apps) {
|
||||
project_management_api_request_1.assertServerResponse(validator.isArray(responseData.apps), responseData, "\"apps\" field must be present in the " + callerName + " response data.");
|
||||
}
|
||||
};
|
||||
return ProjectManagement;
|
||||
}());
|
||||
exports.ProjectManagement = ProjectManagement;
|
Reference in New Issue
Block a user