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,81 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2021 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 installations.Installations `Installations`} service for the
|
|
20
|
+
* default app or a given app.
|
|
21
|
+
*
|
|
22
|
+
* `admin.installations()` can be called with no arguments to access the default
|
|
23
|
+
* app's {@link installations.Installations `Installations`} service or as
|
|
24
|
+
* `admin.installations(app)` to access the
|
|
25
|
+
* {@link installations.Installations `Installations`} service associated with a
|
|
26
|
+
* specific app.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```javascript
|
|
30
|
+
* // Get the Installations service for the default app
|
|
31
|
+
* var defaultInstallations = admin.installations();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```javascript
|
|
36
|
+
* // Get the Installations service for a given app
|
|
37
|
+
* var otherInstallations = admin.installations(otherApp);
|
|
38
|
+
*```
|
|
39
|
+
*
|
|
40
|
+
* @param app Optional app whose `Installations` service to
|
|
41
|
+
* return. If not provided, the default `Installations` service is
|
|
42
|
+
* returned.
|
|
43
|
+
*
|
|
44
|
+
* @return The default `Installations` service if
|
|
45
|
+
* no app is provided or the `Installations` service associated with the
|
|
46
|
+
* provided app.
|
|
47
|
+
*/
|
|
48
|
+
export declare function installations(app?: app.App): installations.Installations;
|
|
49
|
+
export declare namespace installations {
|
|
50
|
+
/**
|
|
51
|
+
* Gets the {@link Installations `Installations`} service for the
|
|
52
|
+
* current app.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```javascript
|
|
56
|
+
* var installations = app.installations();
|
|
57
|
+
* // The above is shorthand for:
|
|
58
|
+
* // var installations = admin.installations(app);
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @return The `Installations` service for the
|
|
62
|
+
* current app.
|
|
63
|
+
*/
|
|
64
|
+
interface Installations {
|
|
65
|
+
app: app.App;
|
|
66
|
+
/**
|
|
67
|
+
* Deletes the specified installation ID and the associated data from Firebase.
|
|
68
|
+
*
|
|
69
|
+
* Note that Google Analytics for Firebase uses its own form of Instance ID to
|
|
70
|
+
* keep track of analytics data. Therefore deleting a Firebase installation ID does
|
|
71
|
+
* not delete Analytics data. See
|
|
72
|
+
* [Delete a Firebase installation](/docs/projects/manage-installations#delete-installation)
|
|
73
|
+
* for more information.
|
|
74
|
+
*
|
|
75
|
+
* @param fid The Firebase installation ID to be deleted.
|
|
76
|
+
*
|
|
77
|
+
* @return A promise fulfilled when the installation ID is deleted.
|
|
78
|
+
*/
|
|
79
|
+
deleteInstallation(fid: string): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2021 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 });
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2021 Google Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.FirebaseInstallationsRequestHandler = void 0;
|
|
21
|
+
var error_1 = require("../utils/error");
|
|
22
|
+
var api_request_1 = require("../utils/api-request");
|
|
23
|
+
var utils = require("../utils/index");
|
|
24
|
+
var validator = require("../utils/validator");
|
|
25
|
+
/** Firebase IID backend host. */
|
|
26
|
+
var FIREBASE_IID_HOST = 'console.firebase.google.com';
|
|
27
|
+
/** Firebase IID backend path. */
|
|
28
|
+
var FIREBASE_IID_PATH = '/v1/';
|
|
29
|
+
/** Firebase IID request timeout duration in milliseconds. */
|
|
30
|
+
var FIREBASE_IID_TIMEOUT = 10000;
|
|
31
|
+
/** HTTP error codes raised by the backend server. */
|
|
32
|
+
var ERROR_CODES = {
|
|
33
|
+
400: 'Malformed installation ID argument.',
|
|
34
|
+
401: 'Request not authorized.',
|
|
35
|
+
403: 'Project does not match installation ID or the client does not have sufficient privileges.',
|
|
36
|
+
404: 'Failed to find the installation ID.',
|
|
37
|
+
409: 'Already deleted.',
|
|
38
|
+
429: 'Request throttled out by the backend server.',
|
|
39
|
+
500: 'Internal server error.',
|
|
40
|
+
503: 'Backend servers are over capacity. Try again later.',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Class that provides mechanism to send requests to the FIS backend endpoints.
|
|
44
|
+
*/
|
|
45
|
+
var FirebaseInstallationsRequestHandler = /** @class */ (function () {
|
|
46
|
+
/**
|
|
47
|
+
* @param app The app used to fetch access tokens to sign API requests.
|
|
48
|
+
*
|
|
49
|
+
* @constructor
|
|
50
|
+
*/
|
|
51
|
+
function FirebaseInstallationsRequestHandler(app) {
|
|
52
|
+
this.app = app;
|
|
53
|
+
this.host = FIREBASE_IID_HOST;
|
|
54
|
+
this.timeout = FIREBASE_IID_TIMEOUT;
|
|
55
|
+
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
|
|
56
|
+
}
|
|
57
|
+
FirebaseInstallationsRequestHandler.prototype.deleteInstallation = function (fid) {
|
|
58
|
+
if (!validator.isNonEmptyString(fid)) {
|
|
59
|
+
return Promise.reject(new error_1.FirebaseInstallationsError(error_1.InstallationsClientErrorCode.INVALID_INSTALLATION_ID, 'Installation ID must be a non-empty string.'));
|
|
60
|
+
}
|
|
61
|
+
return this.invokeRequestHandler(new api_request_1.ApiSettings(fid, 'DELETE'));
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Invokes the request handler based on the API settings object passed.
|
|
65
|
+
*
|
|
66
|
+
* @param apiSettings The API endpoint settings to apply to request and response.
|
|
67
|
+
* @return A promise that resolves when the request is complete.
|
|
68
|
+
*/
|
|
69
|
+
FirebaseInstallationsRequestHandler.prototype.invokeRequestHandler = function (apiSettings) {
|
|
70
|
+
var _this = this;
|
|
71
|
+
return this.getPathPrefix()
|
|
72
|
+
.then(function (path) {
|
|
73
|
+
var req = {
|
|
74
|
+
url: "https://" + _this.host + path + apiSettings.getEndpoint(),
|
|
75
|
+
method: apiSettings.getHttpMethod(),
|
|
76
|
+
timeout: _this.timeout,
|
|
77
|
+
};
|
|
78
|
+
return _this.httpClient.send(req);
|
|
79
|
+
})
|
|
80
|
+
.then(function () {
|
|
81
|
+
// return nothing on success
|
|
82
|
+
})
|
|
83
|
+
.catch(function (err) {
|
|
84
|
+
if (err instanceof api_request_1.HttpError) {
|
|
85
|
+
var response = err.response;
|
|
86
|
+
var errorMessage = (response.isJson() && 'error' in response.data) ?
|
|
87
|
+
response.data.error : response.text;
|
|
88
|
+
var template = ERROR_CODES[response.status];
|
|
89
|
+
var message = template ?
|
|
90
|
+
"Installation ID \"" + apiSettings.getEndpoint() + "\": " + template : errorMessage;
|
|
91
|
+
throw new error_1.FirebaseInstallationsError(error_1.InstallationsClientErrorCode.API_ERROR, message);
|
|
92
|
+
}
|
|
93
|
+
// In case of timeouts and other network errors, the HttpClient returns a
|
|
94
|
+
// FirebaseError wrapped in the response. Simply throw it here.
|
|
95
|
+
throw err;
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
FirebaseInstallationsRequestHandler.prototype.getPathPrefix = function () {
|
|
99
|
+
var _this = this;
|
|
100
|
+
if (this.path) {
|
|
101
|
+
return Promise.resolve(this.path);
|
|
102
|
+
}
|
|
103
|
+
return utils.findProjectId(this.app)
|
|
104
|
+
.then(function (projectId) {
|
|
105
|
+
if (!validator.isNonEmptyString(projectId)) {
|
|
106
|
+
// Assert for an explicit projct ID (either via AppOptions or the cert itself).
|
|
107
|
+
throw new error_1.FirebaseInstallationsError(error_1.InstallationsClientErrorCode.INVALID_PROJECT_ID, 'Failed to determine project ID for Installations. Initialize the '
|
|
108
|
+
+ 'SDK with service account credentials or set project ID as an app option. '
|
|
109
|
+
+ 'Alternatively set the GOOGLE_CLOUD_PROJECT environment variable.');
|
|
110
|
+
}
|
|
111
|
+
_this.path = FIREBASE_IID_PATH + ("project/" + projectId + "/instanceId/");
|
|
112
|
+
return _this.path;
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
return FirebaseInstallationsRequestHandler;
|
|
116
|
+
}());
|
|
117
|
+
exports.FirebaseInstallationsRequestHandler = FirebaseInstallationsRequestHandler;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2021 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.Installations = void 0;
|
|
20
|
+
var error_1 = require("../utils/error");
|
|
21
|
+
var installations_request_handler_1 = require("./installations-request-handler");
|
|
22
|
+
var validator = require("../utils/validator");
|
|
23
|
+
/**
|
|
24
|
+
* The `Installations` service for the current app.
|
|
25
|
+
*/
|
|
26
|
+
var Installations = /** @class */ (function () {
|
|
27
|
+
/**
|
|
28
|
+
* @param app The app for this Installations service.
|
|
29
|
+
* @constructor
|
|
30
|
+
*/
|
|
31
|
+
function Installations(app) {
|
|
32
|
+
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
33
|
+
throw new error_1.FirebaseInstallationsError(error_1.InstallationsClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.installations() must be a valid Firebase app instance.');
|
|
34
|
+
}
|
|
35
|
+
this.app_ = app;
|
|
36
|
+
this.requestHandler = new installations_request_handler_1.FirebaseInstallationsRequestHandler(app);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Deletes the specified installation ID and the associated data from Firebase.
|
|
40
|
+
*
|
|
41
|
+
* @param fid The Firebase installation ID to be deleted.
|
|
42
|
+
*
|
|
43
|
+
* @return A promise fulfilled when the installation ID is deleted.
|
|
44
|
+
*/
|
|
45
|
+
Installations.prototype.deleteInstallation = function (fid) {
|
|
46
|
+
return this.requestHandler.deleteInstallation(fid);
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(Installations.prototype, "app", {
|
|
49
|
+
/**
|
|
50
|
+
* Returns the app associated with this Installations instance.
|
|
51
|
+
*
|
|
52
|
+
* @return The app associated with this Installations instance.
|
|
53
|
+
*/
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.app_;
|
|
56
|
+
},
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
return Installations;
|
|
61
|
+
}());
|
|
62
|
+
exports.Installations = Installations;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 instanceId.InstanceId `InstanceId`} service for the
|
|
20
|
+
* default app or a given app.
|
|
21
|
+
*
|
|
22
|
+
* `admin.instanceId()` can be called with no arguments to access the default
|
|
23
|
+
* app's {@link instanceId.InstanceId `InstanceId`} service or as
|
|
24
|
+
* `admin.instanceId(app)` to access the
|
|
25
|
+
* {@link instanceId.InstanceId `InstanceId`} service associated with a
|
|
26
|
+
* specific app.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```javascript
|
|
30
|
+
* // Get the Instance ID service for the default app
|
|
31
|
+
* var defaultInstanceId = admin.instanceId();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```javascript
|
|
36
|
+
* // Get the Instance ID service for a given app
|
|
37
|
+
* var otherInstanceId = admin.instanceId(otherApp);
|
|
38
|
+
*```
|
|
39
|
+
*
|
|
40
|
+
* This API is deprecated. Developers are advised to use the `admin.installations()`
|
|
41
|
+
* API to delete their instance IDs and Firebase installation IDs.
|
|
42
|
+
*
|
|
43
|
+
* @param app Optional app whose `InstanceId` service to
|
|
44
|
+
* return. If not provided, the default `InstanceId` service will be
|
|
45
|
+
* returned.
|
|
46
|
+
*
|
|
47
|
+
* @return The default `InstanceId` service if
|
|
48
|
+
* no app is provided or the `InstanceId` service associated with the
|
|
49
|
+
* provided app.
|
|
50
|
+
*
|
|
51
|
+
* @deprecated
|
|
52
|
+
*/
|
|
53
|
+
export declare function instanceId(app?: app.App): instanceId.InstanceId;
|
|
54
|
+
export declare namespace instanceId {
|
|
55
|
+
/**
|
|
56
|
+
* The {@link InstanceId `InstanceId`} service for the
|
|
57
|
+
* current app.
|
|
58
|
+
*
|
|
59
|
+
* @deprecated
|
|
60
|
+
*/
|
|
61
|
+
interface InstanceId {
|
|
62
|
+
app: app.App;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes the specified instance ID and the associated data from Firebase.
|
|
65
|
+
*
|
|
66
|
+
* Note that Google Analytics for Firebase uses its own form of Instance ID to
|
|
67
|
+
* keep track of analytics data. Therefore deleting a Firebase Instance ID does
|
|
68
|
+
* not delete Analytics data. See
|
|
69
|
+
* [Delete an Instance ID](/support/privacy/manage-iids#delete_an_instance_id)
|
|
70
|
+
* for more information.
|
|
71
|
+
*
|
|
72
|
+
* This API is deprecated. Developers are advised to use the `Installations.deleteInstallation()`
|
|
73
|
+
* API instead.
|
|
74
|
+
*
|
|
75
|
+
* @param instanceId The instance ID to be deleted.
|
|
76
|
+
*
|
|
77
|
+
* @return A promise fulfilled when the instance ID is deleted.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated
|
|
80
|
+
*/
|
|
81
|
+
deleteInstanceId(instanceId: string): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 });
|
|
@@ -0,0 +1,87 @@
|
|
|
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.InstanceId = void 0;
|
|
20
|
+
var error_1 = require("../utils/error");
|
|
21
|
+
var validator = require("../utils/validator");
|
|
22
|
+
/**
|
|
23
|
+
* Gets the {@link InstanceId `InstanceId`} service for the
|
|
24
|
+
* current app.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```javascript
|
|
28
|
+
* var instanceId = app.instanceId();
|
|
29
|
+
* // The above is shorthand for:
|
|
30
|
+
* // var instanceId = admin.instanceId(app);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @return The `InstanceId` service for the
|
|
34
|
+
* current app.
|
|
35
|
+
*/
|
|
36
|
+
var InstanceId = /** @class */ (function () {
|
|
37
|
+
/**
|
|
38
|
+
* @param app The app for this InstanceId service.
|
|
39
|
+
* @constructor
|
|
40
|
+
*/
|
|
41
|
+
function InstanceId(app) {
|
|
42
|
+
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
43
|
+
throw new error_1.FirebaseInstanceIdError(error_1.InstanceIdClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.instanceId() must be a valid Firebase app instance.');
|
|
44
|
+
}
|
|
45
|
+
this.app_ = app;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deletes the specified instance ID and the associated data from Firebase.
|
|
49
|
+
*
|
|
50
|
+
* Note that Google Analytics for Firebase uses its own form of Instance ID to
|
|
51
|
+
* keep track of analytics data. Therefore deleting a Firebase Instance ID does
|
|
52
|
+
* not delete Analytics data. See
|
|
53
|
+
* [Delete an Instance ID](/support/privacy/manage-iids#delete_an_instance_id)
|
|
54
|
+
* for more information.
|
|
55
|
+
*
|
|
56
|
+
* @param instanceId The instance ID to be deleted.
|
|
57
|
+
*
|
|
58
|
+
* @return A promise fulfilled when the instance ID is deleted.
|
|
59
|
+
*/
|
|
60
|
+
InstanceId.prototype.deleteInstanceId = function (instanceId) {
|
|
61
|
+
return this.app.installations().deleteInstallation(instanceId)
|
|
62
|
+
.catch(function (err) {
|
|
63
|
+
if (err instanceof error_1.FirebaseInstallationsError) {
|
|
64
|
+
var code = err.code.replace('installations/', '');
|
|
65
|
+
if (code === error_1.InstallationsClientErrorCode.INVALID_INSTALLATION_ID.code) {
|
|
66
|
+
code = error_1.InstanceIdClientErrorCode.INVALID_INSTANCE_ID.code;
|
|
67
|
+
}
|
|
68
|
+
throw new error_1.FirebaseInstanceIdError({ code: code, message: err.message });
|
|
69
|
+
}
|
|
70
|
+
throw err;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(InstanceId.prototype, "app", {
|
|
74
|
+
/**
|
|
75
|
+
* Returns the app associated with this InstanceId instance.
|
|
76
|
+
*
|
|
77
|
+
* @return The app associated with this InstanceId instance.
|
|
78
|
+
*/
|
|
79
|
+
get: function () {
|
|
80
|
+
return this.app_;
|
|
81
|
+
},
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
85
|
+
return InstanceId;
|
|
86
|
+
}());
|
|
87
|
+
exports.InstanceId = InstanceId;
|