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