1 | /*! firebase-admin v10.0.0 */
|
2 | ;
|
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 installations_1 = require("../installations");
|
21 | var error_1 = require("../utils/error");
|
22 | var validator = require("../utils/validator");
|
23 | /**
|
24 | * The `InstanceId` service enables deleting the Firebase instance IDs
|
25 | * associated with Firebase client app instances.
|
26 | *
|
27 | * @deprecated Use {@link firebase-admin.installations#Installations} instead.
|
28 | */
|
29 | var InstanceId = /** @class */ (function () {
|
30 | /**
|
31 | * @param app - The app for this InstanceId service.
|
32 | * @constructor
|
33 | * @internal
|
34 | */
|
35 | function InstanceId(app) {
|
36 | if (!validator.isNonNullObject(app) || !('options' in app)) {
|
37 | throw new error_1.FirebaseInstanceIdError(error_1.InstanceIdClientErrorCode.INVALID_ARGUMENT, 'First argument passed to instanceId() must be a valid Firebase app instance.');
|
38 | }
|
39 | this.app_ = app;
|
40 | }
|
41 | /**
|
42 | * Deletes the specified instance ID and the associated data from Firebase.
|
43 | *
|
44 | * Note that Google Analytics for Firebase uses its own form of Instance ID to
|
45 | * keep track of analytics data. Therefore deleting a Firebase Instance ID does
|
46 | * not delete Analytics data. See
|
47 | * {@link https://firebase.google.com/support/privacy/manage-iids#delete_an_instance_id |
|
48 | * Delete an Instance ID}
|
49 | * for more information.
|
50 | *
|
51 | * @param instanceId - The instance ID to be deleted.
|
52 | *
|
53 | * @returns A promise fulfilled when the instance ID is deleted.
|
54 | */
|
55 | InstanceId.prototype.deleteInstanceId = function (instanceId) {
|
56 | return installations_1.getInstallations(this.app).deleteInstallation(instanceId)
|
57 | .catch(function (err) {
|
58 | if (err instanceof error_1.FirebaseInstallationsError) {
|
59 | var code = err.code.replace('installations/', '');
|
60 | if (code === error_1.InstallationsClientErrorCode.INVALID_INSTALLATION_ID.code) {
|
61 | code = error_1.InstanceIdClientErrorCode.INVALID_INSTANCE_ID.code;
|
62 | }
|
63 | throw new error_1.FirebaseInstanceIdError({ code: code, message: err.message });
|
64 | }
|
65 | throw err;
|
66 | });
|
67 | };
|
68 | Object.defineProperty(InstanceId.prototype, "app", {
|
69 | /**
|
70 | * Returns the app associated with this InstanceId instance.
|
71 | *
|
72 | * @returns The app associated with this InstanceId instance.
|
73 | */
|
74 | get: function () {
|
75 | return this.app_;
|
76 | },
|
77 | enumerable: false,
|
78 | configurable: true
|
79 | });
|
80 | return InstanceId;
|
81 | }());
|
82 | exports.InstanceId = InstanceId;
|