UNPKG

5.43 kBTypeScriptView Raw
1/*! firebase-admin v10.0.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 */
17import { Credential as TCredential, applicationDefault as applicationDefaultFn, cert as certFn, refreshToken as refreshTokenFn } from '../app/index';
18export { ServiceAccount, GoogleOAuthAccessToken } from '../app/index';
19export declare namespace credential {
20 /**
21 * Interface that provides Google OAuth2 access tokens used to authenticate
22 * with Firebase services.
23 *
24 * In most cases, you will not need to implement this yourself and can instead
25 * use the default implementations provided by the `admin.credential` namespace.
26 */
27 type Credential = TCredential;
28 /**
29 * Returns a credential created from the
30 * {@link https://developers.google.com/identity/protocols/application-default-credentials |
31 * Google Application Default Credentials}
32 * that grants admin access to Firebase services. This credential can be used
33 * in the call to {@link firebase-admin.app#initializeApp}.
34 *
35 * Google Application Default Credentials are available on any Google
36 * infrastructure, such as Google App Engine and Google Compute Engine.
37 *
38 * See
39 * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
40 * for more details.
41 *
42 * @example
43 * ```javascript
44 * admin.initializeApp({
45 * credential: admin.credential.applicationDefault(),
46 * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
47 * });
48 * ```
49 *
50 * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
51 * to be used when retrieving access tokens from Google token servers.
52 *
53 * @returns A credential authenticated via Google
54 * Application Default Credentials that can be used to initialize an app.
55 */
56 const applicationDefault: typeof applicationDefaultFn;
57 /**
58 * Returns a credential created from the provided service account that grants
59 * admin access to Firebase services. This credential can be used in the call
60 * to {@link firebase-admin.app#initializeApp}.
61 *
62 * See
63 * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
64 * for more details.
65 *
66 * @example
67 * ```javascript
68 * // Providing a path to a service account key JSON file
69 * var serviceAccount = require("path/to/serviceAccountKey.json");
70 * admin.initializeApp({
71 * credential: admin.credential.cert(serviceAccount),
72 * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
73 * });
74 * ```
75 *
76 * @example
77 * ```javascript
78 * // Providing a service account object inline
79 * admin.initializeApp({
80 * credential: admin.credential.cert({
81 * projectId: "<PROJECT_ID>",
82 * clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
83 * privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
84 * }),
85 * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
86 * });
87 * ```
88 *
89 * @param serviceAccountPathOrObject - The path to a service
90 * account key JSON file or an object representing a service account key.
91 * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
92 * to be used when retrieving access tokens from Google token servers.
93 *
94 * @returns A credential authenticated via the
95 * provided service account that can be used to initialize an app.
96 */
97 const cert: typeof certFn;
98 /**
99 * Returns a credential created from the provided refresh token that grants
100 * admin access to Firebase services. This credential can be used in the call
101 * to {@link firebase-admin.app#initializeApp}.
102 *
103 * See
104 * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
105 * for more details.
106 *
107 * @example
108 * ```javascript
109 * // Providing a path to a refresh token JSON file
110 * var refreshToken = require("path/to/refreshToken.json");
111 * admin.initializeApp({
112 * credential: admin.credential.refreshToken(refreshToken),
113 * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
114 * });
115 * ```
116 *
117 * @param refreshTokenPathOrObject - The path to a Google
118 * OAuth2 refresh token JSON file or an object representing a Google OAuth2
119 * refresh token.
120 * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
121 * to be used when retrieving access tokens from Google token servers.
122 *
123 * @returns A credential authenticated via the
124 * provided service account that can be used to initialize an app.
125 */
126 const refreshToken: typeof refreshTokenFn;
127}