1 | /*! firebase-admin v13.0.1 */
|
2 | /*!
|
3 | * @license
|
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 | import { Agent } from 'http';
|
19 | import { Credential } from './credential';
|
20 | /**
|
21 | * Available options to pass to {@link firebase-admin.app#initializeApp}.
|
22 | */
|
23 | export interface AppOptions {
|
24 | /**
|
25 | * A {@link firebase-admin.app#Credential} object used to
|
26 | * authenticate the Admin SDK.
|
27 | *
|
28 | * See {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
|
29 | * for detailed documentation and code samples.
|
30 | */
|
31 | credential?: Credential;
|
32 | /**
|
33 | * The object to use as the {@link https://firebase.google.com/docs/reference/security/database/#auth | auth}
|
34 | * variable in your Realtime Database Rules when the Admin SDK reads from or
|
35 | * writes to the Realtime Database. This allows you to downscope the Admin SDK
|
36 | * from its default full read and write privileges.
|
37 | *
|
38 | * You can pass `null` to act as an unauthenticated client.
|
39 | *
|
40 | * See
|
41 | * {@link https://firebase.google.com/docs/database/admin/start#authenticate-with-limited-privileges |
|
42 | * Authenticate with limited privileges}
|
43 | * for detailed documentation and code samples.
|
44 | */
|
45 | databaseAuthVariableOverride?: object | null;
|
46 | /**
|
47 | * The URL of the Realtime Database from which to read and write data.
|
48 | */
|
49 | databaseURL?: string;
|
50 | /**
|
51 | * The ID of the service account to be used for signing custom tokens. This
|
52 | * can be found in the `client_email` field of a service account JSON file.
|
53 | */
|
54 | serviceAccountId?: string;
|
55 | /**
|
56 | * The name of the Google Cloud Storage bucket used for storing application data.
|
57 | * Use only the bucket name without any prefixes or additions (do *not* prefix
|
58 | * the name with "gs://").
|
59 | */
|
60 | storageBucket?: string;
|
61 | /**
|
62 | * The ID of the Google Cloud project associated with the App.
|
63 | */
|
64 | projectId?: string;
|
65 | /**
|
66 | * An {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
|
67 | * to be used when making outgoing HTTP calls. This Agent instance is used
|
68 | * by all services that make REST calls (e.g. `auth`, `messaging`,
|
69 | * `projectManagement`).
|
70 | *
|
71 | * Realtime Database and Firestore use other means of communicating with
|
72 | * the backend servers, so they do not use this HTTP Agent. `Credential`
|
73 | * instances also do not use this HTTP Agent, but instead support
|
74 | * specifying an HTTP Agent in the corresponding factory methods.
|
75 | */
|
76 | httpAgent?: Agent;
|
77 | }
|
78 | /**
|
79 | * A Firebase app holds the initialization information for a collection of
|
80 | * services.
|
81 | */
|
82 | export interface App {
|
83 | /**
|
84 | * The (read-only) name for this app.
|
85 | *
|
86 | * The default app's name is `"[DEFAULT]"`.
|
87 | *
|
88 | * @example
|
89 | * ```javascript
|
90 | * // The default app's name is "[DEFAULT]"
|
91 | * initializeApp(defaultAppConfig);
|
92 | * console.log(admin.app().name); // "[DEFAULT]"
|
93 | * ```
|
94 | *
|
95 | * @example
|
96 | * ```javascript
|
97 | * // A named app's name is what you provide to initializeApp()
|
98 | * const otherApp = initializeApp(otherAppConfig, "other");
|
99 | * console.log(otherApp.name); // "other"
|
100 | * ```
|
101 | */
|
102 | name: string;
|
103 | /**
|
104 | * The (read-only) configuration options for this app. These are the original
|
105 | * parameters given in {@link firebase-admin.app#initializeApp}.
|
106 | *
|
107 | * @example
|
108 | * ```javascript
|
109 | * const app = initializeApp(config);
|
110 | * console.log(app.options.credential === config.credential); // true
|
111 | * console.log(app.options.databaseURL === config.databaseURL); // true
|
112 | * ```
|
113 | */
|
114 | options: AppOptions;
|
115 | }
|
116 | /**
|
117 | * `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
|
118 | * addition to a message string and stack trace, it contains a string code.
|
119 | */
|
120 | export interface FirebaseError {
|
121 | /**
|
122 | * Error codes are strings using the following format: `"service/string-code"`.
|
123 | * Some examples include `"auth/invalid-uid"` and
|
124 | * `"messaging/invalid-recipient"`.
|
125 | *
|
126 | * While the message for a given error can change, the code will remain the same
|
127 | * between backward-compatible versions of the Firebase SDK.
|
128 | */
|
129 | code: string;
|
130 | /**
|
131 | * An explanatory message for the error that just occurred.
|
132 | *
|
133 | * This message is designed to be helpful to you, the developer. Because
|
134 | * it generally does not convey meaningful information to end users,
|
135 | * this message should not be displayed in your application.
|
136 | */
|
137 | message: string;
|
138 | /**
|
139 | * A string value containing the execution backtrace when the error originally
|
140 | * occurred.
|
141 | *
|
142 | * This information can be useful for troubleshooting the cause of the error with
|
143 | * {@link https://firebase.google.com/support | Firebase Support}.
|
144 | */
|
145 | stack?: string;
|
146 | /**
|
147 | * Returns a JSON-serializable object representation of this error.
|
148 | *
|
149 | * @returns A JSON-serializable representation of this object.
|
150 | */
|
151 | toJSON(): object;
|
152 | }
|
153 | /**
|
154 | * Composite type which includes both a `FirebaseError` object and an index
|
155 | * which can be used to get the errored item.
|
156 | *
|
157 | * @example
|
158 | * ```javascript
|
159 | * var registrationTokens = [token1, token2, token3];
|
160 | * admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
|
161 | * .then(function(response) {
|
162 | * if (response.failureCount > 0) {
|
163 | * console.log("Following devices unsucessfully subscribed to topic:");
|
164 | * response.errors.forEach(function(error) {
|
165 | * var invalidToken = registrationTokens[error.index];
|
166 | * console.log(invalidToken, error.error);
|
167 | * });
|
168 | * } else {
|
169 | * console.log("All devices successfully subscribed to topic:", response);
|
170 | * }
|
171 | * })
|
172 | * .catch(function(error) {
|
173 | * console.log("Error subscribing to topic:", error);
|
174 | * });
|
175 | *```
|
176 | */
|
177 | export interface FirebaseArrayIndexError {
|
178 | /**
|
179 | * The index of the errored item within the original array passed as part of the
|
180 | * called API method.
|
181 | */
|
182 | index: number;
|
183 | /**
|
184 | * The error object.
|
185 | */
|
186 | error: FirebaseError;
|
187 | }
|