firebase-admin 9.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +90 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check.js +79 -0
- package/lib/app-check/index.d.ts +160 -0
- package/lib/app-check/index.js +19 -0
- package/lib/app-check/token-generator.js +161 -0
- package/lib/app-check/token-verifier.js +152 -0
- package/lib/auth/action-code-settings-builder.js +118 -0
- package/lib/auth/auth-api-request.js +1856 -0
- package/lib/auth/auth-config.js +636 -0
- package/lib/auth/auth.js +836 -0
- package/lib/auth/identifier.js +40 -0
- package/lib/auth/index.d.ts +1927 -0
- package/lib/auth/index.js +18 -0
- package/lib/auth/tenant-manager.js +140 -0
- package/lib/auth/tenant.js +171 -0
- package/lib/auth/token-generator.js +200 -0
- package/lib/auth/token-verifier.js +259 -0
- package/lib/auth/user-import-builder.js +387 -0
- package/lib/auth/user-record.js +346 -0
- package/lib/credential/credential-internal.js +391 -0
- package/lib/credential/credential.js +44 -0
- package/lib/credential/index.d.ts +169 -0
- package/lib/credential/index.js +23 -0
- package/lib/database/database-internal.js +266 -0
- package/lib/database/index.d.ts +89 -0
- package/lib/database/index.js +31 -0
- package/lib/default-namespace.js +31 -0
- package/lib/firebase-app.js +349 -0
- package/lib/firebase-namespace-api.d.ts +243 -0
- package/lib/firebase-namespace-api.js +18 -0
- package/lib/firebase-namespace.d.ts +31 -0
- package/lib/firebase-namespace.js +417 -0
- package/lib/firestore/firestore-internal.js +105 -0
- package/lib/firestore/index.d.ts +50 -0
- package/lib/firestore/index.js +47 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +27 -0
- package/lib/installations/index.d.ts +81 -0
- package/lib/installations/index.js +18 -0
- package/lib/installations/installations-request-handler.js +117 -0
- package/lib/installations/installations.js +62 -0
- package/lib/instance-id/index.d.ts +83 -0
- package/lib/instance-id/index.js +18 -0
- package/lib/instance-id/instance-id.js +87 -0
- package/lib/machine-learning/index.d.ts +249 -0
- package/lib/machine-learning/index.js +18 -0
- package/lib/machine-learning/machine-learning-api-client.js +304 -0
- package/lib/machine-learning/machine-learning-utils.js +62 -0
- package/lib/machine-learning/machine-learning.js +364 -0
- package/lib/messaging/batch-request-internal.js +129 -0
- package/lib/messaging/index.d.ts +1174 -0
- package/lib/messaging/index.js +18 -0
- package/lib/messaging/messaging-api-request-internal.js +128 -0
- package/lib/messaging/messaging-errors-internal.js +106 -0
- package/lib/messaging/messaging-internal.js +484 -0
- package/lib/messaging/messaging.js +846 -0
- package/lib/project-management/android-app.js +176 -0
- package/lib/project-management/index.d.ts +363 -0
- package/lib/project-management/index.js +41 -0
- package/lib/project-management/ios-app.js +88 -0
- package/lib/project-management/project-management-api-request-internal.js +273 -0
- package/lib/project-management/project-management.js +254 -0
- package/lib/remote-config/index.d.ts +369 -0
- package/lib/remote-config/index.js +18 -0
- package/lib/remote-config/remote-config-api-client-internal.js +407 -0
- package/lib/remote-config/remote-config.js +304 -0
- package/lib/security-rules/index.d.ts +216 -0
- package/lib/security-rules/index.js +18 -0
- package/lib/security-rules/security-rules-api-client-internal.js +237 -0
- package/lib/security-rules/security-rules-internal.js +41 -0
- package/lib/security-rules/security-rules.js +310 -0
- package/lib/storage/index.d.ts +60 -0
- package/lib/storage/index.js +18 -0
- package/lib/storage/storage.js +123 -0
- package/lib/utils/api-request.js +845 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.js +78 -0
- package/lib/utils/error.js +1063 -0
- package/lib/utils/index.js +217 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.js +271 -0
- package/package.json +122 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2018 Google Inc.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.ShaCertificate = exports.AndroidApp = void 0;
|
|
20
|
+
var error_1 = require("../utils/error");
|
|
21
|
+
var validator = require("../utils/validator");
|
|
22
|
+
var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
|
|
23
|
+
var index_1 = require("./index");
|
|
24
|
+
var AppPlatform = index_1.projectManagement.AppPlatform;
|
|
25
|
+
var AndroidApp = /** @class */ (function () {
|
|
26
|
+
function AndroidApp(appId, requestHandler) {
|
|
27
|
+
this.appId = appId;
|
|
28
|
+
this.requestHandler = requestHandler;
|
|
29
|
+
if (!validator.isNonEmptyString(appId)) {
|
|
30
|
+
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'appId must be a non-empty string.');
|
|
31
|
+
}
|
|
32
|
+
this.resourceName = "projects/-/androidApps/" + appId;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves metadata about this Android app.
|
|
36
|
+
*
|
|
37
|
+
* @return A promise that resolves to the retrieved metadata about this Android app.
|
|
38
|
+
*/
|
|
39
|
+
AndroidApp.prototype.getMetadata = function () {
|
|
40
|
+
return this.requestHandler.getResource(this.resourceName)
|
|
41
|
+
.then(function (responseData) {
|
|
42
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
|
|
43
|
+
var requiredFieldsList = ['name', 'appId', 'projectId', 'packageName'];
|
|
44
|
+
requiredFieldsList.forEach(function (requiredField) {
|
|
45
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
|
|
46
|
+
});
|
|
47
|
+
var metadata = {
|
|
48
|
+
platform: AppPlatform.ANDROID,
|
|
49
|
+
resourceName: responseData.name,
|
|
50
|
+
appId: responseData.appId,
|
|
51
|
+
displayName: responseData.displayName || null,
|
|
52
|
+
projectId: responseData.projectId,
|
|
53
|
+
packageName: responseData.packageName,
|
|
54
|
+
};
|
|
55
|
+
return metadata;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Sets the optional user-assigned display name of the app.
|
|
60
|
+
*
|
|
61
|
+
* @param newDisplayName The new display name to set.
|
|
62
|
+
*
|
|
63
|
+
* @return A promise that resolves when the display name has been set.
|
|
64
|
+
*/
|
|
65
|
+
AndroidApp.prototype.setDisplayName = function (newDisplayName) {
|
|
66
|
+
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Gets the list of SHA certificates associated with this Android app in Firebase.
|
|
70
|
+
*
|
|
71
|
+
* @return The list of SHA-1 and SHA-256 certificates associated with this Android app in
|
|
72
|
+
* Firebase.
|
|
73
|
+
*/
|
|
74
|
+
AndroidApp.prototype.getShaCertificates = function () {
|
|
75
|
+
return this.requestHandler.getAndroidShaCertificates(this.resourceName)
|
|
76
|
+
.then(function (responseData) {
|
|
77
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getShaCertificates()\'s responseData must be a non-null object.');
|
|
78
|
+
if (!responseData.certificates) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isArray(responseData.certificates), responseData, '"certificates" field must be present in the getShaCertificates() response data.');
|
|
82
|
+
var requiredFieldsList = ['name', 'shaHash'];
|
|
83
|
+
return responseData.certificates.map(function (certificateJson) {
|
|
84
|
+
requiredFieldsList.forEach(function (requiredField) {
|
|
85
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(certificateJson[requiredField]), responseData, "getShaCertificates()'s responseData.certificates[]." + requiredField + " must be a "
|
|
86
|
+
+ 'non-empty string.');
|
|
87
|
+
});
|
|
88
|
+
return new ShaCertificate(certificateJson.shaHash, certificateJson.name);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Adds the given SHA certificate to this Android app.
|
|
94
|
+
*
|
|
95
|
+
* @param certificateToAdd The SHA certificate to add.
|
|
96
|
+
*
|
|
97
|
+
* @return A promise that resolves when the given certificate
|
|
98
|
+
* has been added to the Android app.
|
|
99
|
+
*/
|
|
100
|
+
AndroidApp.prototype.addShaCertificate = function (certificateToAdd) {
|
|
101
|
+
return this.requestHandler.addAndroidShaCertificate(this.resourceName, certificateToAdd);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Deletes the specified SHA certificate from this Android app.
|
|
105
|
+
*
|
|
106
|
+
* @param certificateToDelete The SHA certificate to delete.
|
|
107
|
+
*
|
|
108
|
+
* @return A promise that resolves when the specified
|
|
109
|
+
* certificate has been removed from the Android app.
|
|
110
|
+
*/
|
|
111
|
+
AndroidApp.prototype.deleteShaCertificate = function (certificateToDelete) {
|
|
112
|
+
if (!certificateToDelete.resourceName) {
|
|
113
|
+
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'Specified certificate does not include a resourceName. (Use AndroidApp.getShaCertificates() to retrieve ' +
|
|
114
|
+
'certificates with a resourceName.');
|
|
115
|
+
}
|
|
116
|
+
return this.requestHandler.deleteResource(certificateToDelete.resourceName);
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Gets the configuration artifact associated with this app.
|
|
120
|
+
*
|
|
121
|
+
* @return A promise that resolves to the Android app's
|
|
122
|
+
* Firebase config file, in UTF-8 string format. This string is typically
|
|
123
|
+
* intended to be written to a JSON file that gets shipped with your Android
|
|
124
|
+
* app.
|
|
125
|
+
*/
|
|
126
|
+
AndroidApp.prototype.getConfig = function () {
|
|
127
|
+
return this.requestHandler.getConfig(this.resourceName)
|
|
128
|
+
.then(function (responseData) {
|
|
129
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
|
|
130
|
+
var base64ConfigFileContents = responseData.configFileContents;
|
|
131
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, 'getConfig()\'s responseData.configFileContents must be a base64 string.');
|
|
132
|
+
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
return AndroidApp;
|
|
136
|
+
}());
|
|
137
|
+
exports.AndroidApp = AndroidApp;
|
|
138
|
+
/**
|
|
139
|
+
* A SHA-1 or SHA-256 certificate.
|
|
140
|
+
*
|
|
141
|
+
* Do not call this constructor directly. Instead, use
|
|
142
|
+
* [`projectManagement.shaCertificate()`](projectManagement.ProjectManagement#shaCertificate).
|
|
143
|
+
*/
|
|
144
|
+
var ShaCertificate = /** @class */ (function () {
|
|
145
|
+
/**
|
|
146
|
+
* Creates a ShaCertificate using the given hash. The ShaCertificate's type (eg. 'sha256') is
|
|
147
|
+
* automatically determined from the hash itself.
|
|
148
|
+
*
|
|
149
|
+
* @param shaHash The sha256 or sha1 hash for this certificate.
|
|
150
|
+
* @example
|
|
151
|
+
* ```javascript
|
|
152
|
+
* var shaHash = shaCertificate.shaHash;
|
|
153
|
+
* ```
|
|
154
|
+
* @param resourceName The Firebase resource name for this certificate. This does not need to be
|
|
155
|
+
* set when creating a new certificate.
|
|
156
|
+
* @example
|
|
157
|
+
* ```javascript
|
|
158
|
+
* var resourceName = shaCertificate.resourceName;
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
function ShaCertificate(shaHash, resourceName) {
|
|
162
|
+
this.shaHash = shaHash;
|
|
163
|
+
this.resourceName = resourceName;
|
|
164
|
+
if (/^[a-fA-F0-9]{40}$/.test(shaHash)) {
|
|
165
|
+
this.certType = 'sha1';
|
|
166
|
+
}
|
|
167
|
+
else if (/^[a-fA-F0-9]{64}$/.test(shaHash)) {
|
|
168
|
+
this.certType = 'sha256';
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'shaHash must be either a sha256 hash or a sha1 hash.');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return ShaCertificate;
|
|
175
|
+
}());
|
|
176
|
+
exports.ShaCertificate = ShaCertificate;
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { app } from '../firebase-namespace-api';
|
|
18
|
+
/**
|
|
19
|
+
* Gets the {@link projectManagement.ProjectManagement
|
|
20
|
+
* `ProjectManagement`} service for the default app or a given app.
|
|
21
|
+
*
|
|
22
|
+
* `admin.projectManagement()` can be called with no arguments to access the
|
|
23
|
+
* default app's {@link projectManagement.ProjectManagement
|
|
24
|
+
* `ProjectManagement`} service, or as `admin.projectManagement(app)` to access
|
|
25
|
+
* the {@link projectManagement.ProjectManagement `ProjectManagement`}
|
|
26
|
+
* service associated with a specific app.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```javascript
|
|
30
|
+
* // Get the ProjectManagement service for the default app
|
|
31
|
+
* var defaultProjectManagement = admin.projectManagement();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```javascript
|
|
36
|
+
* // Get the ProjectManagement service for a given app
|
|
37
|
+
* var otherProjectManagement = admin.projectManagement(otherApp);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param app Optional app whose `ProjectManagement` service
|
|
41
|
+
* to return. If not provided, the default `ProjectManagement` service will
|
|
42
|
+
* be returned. *
|
|
43
|
+
* @return The default `ProjectManagement` service if no app is provided or the
|
|
44
|
+
* `ProjectManagement` service associated with the provided app.
|
|
45
|
+
*/
|
|
46
|
+
export declare function projectManagement(app?: app.App): projectManagement.ProjectManagement;
|
|
47
|
+
export declare namespace projectManagement {
|
|
48
|
+
/**
|
|
49
|
+
* Metadata about a Firebase Android App.
|
|
50
|
+
*/
|
|
51
|
+
interface AndroidAppMetadata extends AppMetadata {
|
|
52
|
+
platform: AppPlatform.ANDROID;
|
|
53
|
+
/**
|
|
54
|
+
* The canonical package name of the Android App, as would appear in the Google Play Developer
|
|
55
|
+
* Console.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```javascript
|
|
59
|
+
* var packageName = androidAppMetadata.packageName;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
packageName: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Metadata about a Firebase app.
|
|
66
|
+
*/
|
|
67
|
+
interface AppMetadata {
|
|
68
|
+
/**
|
|
69
|
+
* The globally unique, Firebase-assigned identifier of the app.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```javascript
|
|
73
|
+
* var appId = appMetadata.appId;
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
appId: string;
|
|
77
|
+
/**
|
|
78
|
+
* The optional user-assigned display name of the app.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```javascript
|
|
82
|
+
* var displayName = appMetadata.displayName;
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
displayName?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The development platform of the app. Supporting Android and iOS app platforms.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```javascript
|
|
91
|
+
* var platform = AppPlatform.ANDROID;
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
platform: AppPlatform;
|
|
95
|
+
/**
|
|
96
|
+
* The globally unique, user-assigned ID of the parent project for the app.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```javascript
|
|
100
|
+
* var projectId = appMetadata.projectId;
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
projectId: string;
|
|
104
|
+
/**
|
|
105
|
+
* The fully-qualified resource name that identifies this app.
|
|
106
|
+
*
|
|
107
|
+
* This is useful when manually constructing requests for Firebase's public API.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```javascript
|
|
111
|
+
* var resourceName = androidAppMetadata.resourceName;
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
resourceName: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Platforms with which a Firebase App can be associated.
|
|
118
|
+
*/
|
|
119
|
+
enum AppPlatform {
|
|
120
|
+
/**
|
|
121
|
+
* Unknown state. This is only used for distinguishing unset values.
|
|
122
|
+
*/
|
|
123
|
+
PLATFORM_UNKNOWN = "PLATFORM_UNKNOWN",
|
|
124
|
+
/**
|
|
125
|
+
* The Firebase App is associated with iOS.
|
|
126
|
+
*/
|
|
127
|
+
IOS = "IOS",
|
|
128
|
+
/**
|
|
129
|
+
* The Firebase App is associated with Android.
|
|
130
|
+
*/
|
|
131
|
+
ANDROID = "ANDROID"
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Metadata about a Firebase iOS App.
|
|
135
|
+
*/
|
|
136
|
+
interface IosAppMetadata extends AppMetadata {
|
|
137
|
+
platform: AppPlatform.IOS;
|
|
138
|
+
/**
|
|
139
|
+
* The canonical bundle ID of the iOS App as it would appear in the iOS App Store.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```javascript
|
|
143
|
+
* var bundleId = iosAppMetadata.bundleId;
|
|
144
|
+
*```
|
|
145
|
+
*/
|
|
146
|
+
bundleId: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A reference to a Firebase Android app.
|
|
150
|
+
*
|
|
151
|
+
* Do not call this constructor directly. Instead, use
|
|
152
|
+
* [`projectManagement.androidApp()`](projectManagement.ProjectManagement#androidApp).
|
|
153
|
+
*/
|
|
154
|
+
interface AndroidApp {
|
|
155
|
+
appId: string;
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves metadata about this Android app.
|
|
158
|
+
*
|
|
159
|
+
* @return A promise that resolves to the retrieved metadata about this Android app.
|
|
160
|
+
*/
|
|
161
|
+
getMetadata(): Promise<AndroidAppMetadata>;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the optional user-assigned display name of the app.
|
|
164
|
+
*
|
|
165
|
+
* @param newDisplayName The new display name to set.
|
|
166
|
+
*
|
|
167
|
+
* @return A promise that resolves when the display name has been set.
|
|
168
|
+
*/
|
|
169
|
+
setDisplayName(newDisplayName: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the list of SHA certificates associated with this Android app in Firebase.
|
|
172
|
+
*
|
|
173
|
+
* @return The list of SHA-1 and SHA-256 certificates associated with this Android app in
|
|
174
|
+
* Firebase.
|
|
175
|
+
*/
|
|
176
|
+
getShaCertificates(): Promise<ShaCertificate[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Adds the given SHA certificate to this Android app.
|
|
179
|
+
*
|
|
180
|
+
* @param certificateToAdd The SHA certificate to add.
|
|
181
|
+
*
|
|
182
|
+
* @return A promise that resolves when the given certificate
|
|
183
|
+
* has been added to the Android app.
|
|
184
|
+
*/
|
|
185
|
+
addShaCertificate(certificateToAdd: ShaCertificate): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Deletes the specified SHA certificate from this Android app.
|
|
188
|
+
*
|
|
189
|
+
* @param certificateToDelete The SHA certificate to delete.
|
|
190
|
+
*
|
|
191
|
+
* @return A promise that resolves when the specified
|
|
192
|
+
* certificate has been removed from the Android app.
|
|
193
|
+
*/
|
|
194
|
+
deleteShaCertificate(certificateToRemove: ShaCertificate): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Gets the configuration artifact associated with this app.
|
|
197
|
+
*
|
|
198
|
+
* @return A promise that resolves to the Android app's
|
|
199
|
+
* Firebase config file, in UTF-8 string format. This string is typically
|
|
200
|
+
* intended to be written to a JSON file that gets shipped with your Android
|
|
201
|
+
* app.
|
|
202
|
+
*/
|
|
203
|
+
getConfig(): Promise<string>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A reference to a Firebase iOS app.
|
|
207
|
+
*
|
|
208
|
+
* Do not call this constructor directly. Instead, use
|
|
209
|
+
* [`projectManagement.iosApp()`](projectManagement.ProjectManagement#iosApp).
|
|
210
|
+
*/
|
|
211
|
+
interface IosApp {
|
|
212
|
+
appId: string;
|
|
213
|
+
/**
|
|
214
|
+
* Retrieves metadata about this iOS app.
|
|
215
|
+
*
|
|
216
|
+
* @return {!Promise<admin.projectManagement.IosAppMetadata>} A promise that
|
|
217
|
+
* resolves to the retrieved metadata about this iOS app.
|
|
218
|
+
*/
|
|
219
|
+
getMetadata(): Promise<IosAppMetadata>;
|
|
220
|
+
/**
|
|
221
|
+
* Sets the optional user-assigned display name of the app.
|
|
222
|
+
*
|
|
223
|
+
* @param newDisplayName The new display name to set.
|
|
224
|
+
*
|
|
225
|
+
* @return A promise that resolves when the display name has
|
|
226
|
+
* been set.
|
|
227
|
+
*/
|
|
228
|
+
setDisplayName(newDisplayName: string): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Gets the configuration artifact associated with this app.
|
|
231
|
+
*
|
|
232
|
+
* @return A promise that resolves to the iOS app's Firebase
|
|
233
|
+
* config file, in UTF-8 string format. This string is typically intended to
|
|
234
|
+
* be written to a plist file that gets shipped with your iOS app.
|
|
235
|
+
*/
|
|
236
|
+
getConfig(): Promise<string>;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A SHA-1 or SHA-256 certificate.
|
|
240
|
+
*
|
|
241
|
+
* Do not call this constructor directly. Instead, use
|
|
242
|
+
* [`projectManagement.shaCertificate()`](projectManagement.ProjectManagement#shaCertificate).
|
|
243
|
+
*/
|
|
244
|
+
interface ShaCertificate {
|
|
245
|
+
/**
|
|
246
|
+
* The SHA certificate type.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```javascript
|
|
250
|
+
* var certType = shaCertificate.certType;
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
certType: ('sha1' | 'sha256');
|
|
254
|
+
/**
|
|
255
|
+
* The SHA-1 or SHA-256 hash for this certificate.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```javascript
|
|
259
|
+
* var shaHash = shaCertificate.shaHash;
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
shaHash: string;
|
|
263
|
+
/**
|
|
264
|
+
* The fully-qualified resource name that identifies this sha-key.
|
|
265
|
+
*
|
|
266
|
+
* This is useful when manually constructing requests for Firebase's public API.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```javascript
|
|
270
|
+
* var resourceName = shaCertificate.resourceName;
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
resourceName?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The Firebase ProjectManagement service interface.
|
|
277
|
+
*
|
|
278
|
+
* Do not call this constructor directly. Instead, use
|
|
279
|
+
* [`admin.projectManagement()`](projectManagement#projectManagement).
|
|
280
|
+
*/
|
|
281
|
+
interface ProjectManagement {
|
|
282
|
+
app: app.App;
|
|
283
|
+
/**
|
|
284
|
+
* Lists up to 100 Firebase apps associated with this Firebase project.
|
|
285
|
+
*
|
|
286
|
+
* @return A promise that resolves to the metadata list of the apps.
|
|
287
|
+
*/
|
|
288
|
+
listAppMetadata(): Promise<AppMetadata[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Lists up to 100 Firebase Android apps associated with this Firebase project.
|
|
291
|
+
*
|
|
292
|
+
* @return The list of Android apps.
|
|
293
|
+
*/
|
|
294
|
+
listAndroidApps(): Promise<AndroidApp[]>;
|
|
295
|
+
/**
|
|
296
|
+
* Lists up to 100 Firebase iOS apps associated with this Firebase project.
|
|
297
|
+
*
|
|
298
|
+
* @return The list of iOS apps.
|
|
299
|
+
*/
|
|
300
|
+
listIosApps(): Promise<IosApp[]>;
|
|
301
|
+
/**
|
|
302
|
+
* Creates an `AndroidApp` object, referencing the specified Android app within
|
|
303
|
+
* this Firebase project.
|
|
304
|
+
*
|
|
305
|
+
* This method does not perform an RPC.
|
|
306
|
+
*
|
|
307
|
+
* @param appId The `appId` of the Android app to reference.
|
|
308
|
+
*
|
|
309
|
+
* @return An `AndroidApp` object that references the specified Firebase Android app.
|
|
310
|
+
*/
|
|
311
|
+
androidApp(appId: string): AndroidApp;
|
|
312
|
+
/**
|
|
313
|
+
* Update the display name of this Firebase project.
|
|
314
|
+
*
|
|
315
|
+
* @param newDisplayName The new display name to be updated.
|
|
316
|
+
*
|
|
317
|
+
* @return A promise that resolves when the project display name has been updated.
|
|
318
|
+
*/
|
|
319
|
+
setDisplayName(newDisplayName: string): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Creates an `iOSApp` object, referencing the specified iOS app within
|
|
322
|
+
* this Firebase project.
|
|
323
|
+
*
|
|
324
|
+
* This method does not perform an RPC.
|
|
325
|
+
*
|
|
326
|
+
* @param appId The `appId` of the iOS app to reference.
|
|
327
|
+
*
|
|
328
|
+
* @return An `iOSApp` object that references the specified Firebase iOS app.
|
|
329
|
+
*/
|
|
330
|
+
iosApp(appId: string): IosApp;
|
|
331
|
+
/**
|
|
332
|
+
* Creates a `ShaCertificate` object.
|
|
333
|
+
*
|
|
334
|
+
* This method does not perform an RPC.
|
|
335
|
+
*
|
|
336
|
+
* @param shaHash The SHA-1 or SHA-256 hash for this certificate.
|
|
337
|
+
*
|
|
338
|
+
* @return A `ShaCertificate` object contains the specified SHA hash.
|
|
339
|
+
*/
|
|
340
|
+
shaCertificate(shaHash: string): ShaCertificate;
|
|
341
|
+
/**
|
|
342
|
+
* Creates a new Firebase Android app associated with this Firebase project.
|
|
343
|
+
*
|
|
344
|
+
* @param packageName The canonical package name of the Android App,
|
|
345
|
+
* as would appear in the Google Play Developer Console.
|
|
346
|
+
* @param displayName An optional user-assigned display name for this
|
|
347
|
+
* new app.
|
|
348
|
+
*
|
|
349
|
+
* @return A promise that resolves to the newly created Android app.
|
|
350
|
+
*/
|
|
351
|
+
createAndroidApp(packageName: string, displayName?: string): Promise<AndroidApp>;
|
|
352
|
+
/**
|
|
353
|
+
* Creates a new Firebase iOS app associated with this Firebase project.
|
|
354
|
+
*
|
|
355
|
+
* @param bundleId The iOS app bundle ID to use for this new app.
|
|
356
|
+
* @param displayName An optional user-assigned display name for this
|
|
357
|
+
* new app.
|
|
358
|
+
*
|
|
359
|
+
* @return A promise that resolves to the newly created iOS app.
|
|
360
|
+
*/
|
|
361
|
+
createIosApp(bundleId: string, displayName?: string): Promise<IosApp>;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2020 Google Inc.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.projectManagement = void 0;
|
|
20
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
21
|
+
var projectManagement;
|
|
22
|
+
(function (projectManagement) {
|
|
23
|
+
/**
|
|
24
|
+
* Platforms with which a Firebase App can be associated.
|
|
25
|
+
*/
|
|
26
|
+
var AppPlatform;
|
|
27
|
+
(function (AppPlatform) {
|
|
28
|
+
/**
|
|
29
|
+
* Unknown state. This is only used for distinguishing unset values.
|
|
30
|
+
*/
|
|
31
|
+
AppPlatform["PLATFORM_UNKNOWN"] = "PLATFORM_UNKNOWN";
|
|
32
|
+
/**
|
|
33
|
+
* The Firebase App is associated with iOS.
|
|
34
|
+
*/
|
|
35
|
+
AppPlatform["IOS"] = "IOS";
|
|
36
|
+
/**
|
|
37
|
+
* The Firebase App is associated with Android.
|
|
38
|
+
*/
|
|
39
|
+
AppPlatform["ANDROID"] = "ANDROID";
|
|
40
|
+
})(AppPlatform = projectManagement.AppPlatform || (projectManagement.AppPlatform = {}));
|
|
41
|
+
})(projectManagement = exports.projectManagement || (exports.projectManagement = {}));
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2018 Google Inc.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.IosApp = void 0;
|
|
20
|
+
var error_1 = require("../utils/error");
|
|
21
|
+
var validator = require("../utils/validator");
|
|
22
|
+
var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
|
|
23
|
+
var index_1 = require("./index");
|
|
24
|
+
var AppPlatform = index_1.projectManagement.AppPlatform;
|
|
25
|
+
var IosApp = /** @class */ (function () {
|
|
26
|
+
function IosApp(appId, requestHandler) {
|
|
27
|
+
this.appId = appId;
|
|
28
|
+
this.requestHandler = requestHandler;
|
|
29
|
+
if (!validator.isNonEmptyString(appId)) {
|
|
30
|
+
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'appId must be a non-empty string.');
|
|
31
|
+
}
|
|
32
|
+
this.resourceName = "projects/-/iosApps/" + appId;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves metadata about this iOS app.
|
|
36
|
+
*
|
|
37
|
+
* @return {!Promise<admin.projectManagement.IosAppMetadata>} A promise that
|
|
38
|
+
* resolves to the retrieved metadata about this iOS app.
|
|
39
|
+
*/
|
|
40
|
+
IosApp.prototype.getMetadata = function () {
|
|
41
|
+
return this.requestHandler.getResource(this.resourceName)
|
|
42
|
+
.then(function (responseData) {
|
|
43
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getMetadata()\'s responseData must be a non-null object.');
|
|
44
|
+
var requiredFieldsList = ['name', 'appId', 'projectId', 'bundleId'];
|
|
45
|
+
requiredFieldsList.forEach(function (requiredField) {
|
|
46
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData[requiredField]), responseData, "getMetadata()'s responseData." + requiredField + " must be a non-empty string.");
|
|
47
|
+
});
|
|
48
|
+
var metadata = {
|
|
49
|
+
platform: AppPlatform.IOS,
|
|
50
|
+
resourceName: responseData.name,
|
|
51
|
+
appId: responseData.appId,
|
|
52
|
+
displayName: responseData.displayName || null,
|
|
53
|
+
projectId: responseData.projectId,
|
|
54
|
+
bundleId: responseData.bundleId,
|
|
55
|
+
};
|
|
56
|
+
return metadata;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Sets the optional user-assigned display name of the app.
|
|
61
|
+
*
|
|
62
|
+
* @param newDisplayName The new display name to set.
|
|
63
|
+
*
|
|
64
|
+
* @return A promise that resolves when the display name has
|
|
65
|
+
* been set.
|
|
66
|
+
*/
|
|
67
|
+
IosApp.prototype.setDisplayName = function (newDisplayName) {
|
|
68
|
+
return this.requestHandler.setDisplayName(this.resourceName, newDisplayName);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Gets the configuration artifact associated with this app.
|
|
72
|
+
*
|
|
73
|
+
* @return A promise that resolves to the iOS app's Firebase
|
|
74
|
+
* config file, in UTF-8 string format. This string is typically intended to
|
|
75
|
+
* be written to a plist file that gets shipped with your iOS app.
|
|
76
|
+
*/
|
|
77
|
+
IosApp.prototype.getConfig = function () {
|
|
78
|
+
return this.requestHandler.getConfig(this.resourceName)
|
|
79
|
+
.then(function (responseData) {
|
|
80
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'getConfig()\'s responseData must be a non-null object.');
|
|
81
|
+
var base64ConfigFileContents = responseData.configFileContents;
|
|
82
|
+
project_management_api_request_internal_1.assertServerResponse(validator.isBase64String(base64ConfigFileContents), responseData, 'getConfig()\'s responseData.configFileContents must be a base64 string.');
|
|
83
|
+
return Buffer.from(base64ConfigFileContents, 'base64').toString('utf8');
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
return IosApp;
|
|
87
|
+
}());
|
|
88
|
+
exports.IosApp = IosApp;
|