UNPKG

3.95 kBTypeScriptView Raw
1/*! firebase-admin v10.0.0 */
2/*!
3 * @license
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/// <reference types="node" />
19import { Agent } from 'http';
20import { Credential, GoogleOAuthAccessToken } from './credential';
21/**
22 * Implementation of Credential that uses a service account.
23 */
24export declare class ServiceAccountCredential implements Credential {
25 private readonly httpAgent?;
26 readonly implicit: boolean;
27 readonly projectId: string;
28 readonly privateKey: string;
29 readonly clientEmail: string;
30 private readonly httpClient;
31 /**
32 * Creates a new ServiceAccountCredential from the given parameters.
33 *
34 * @param serviceAccountPathOrObject - Service account json object or path to a service account json file.
35 * @param httpAgent - Optional http.Agent to use when calling the remote token server.
36 * @param implicit - An optinal boolean indicating whether this credential was implicitly discovered from the
37 * environment, as opposed to being explicitly specified by the developer.
38 *
39 * @constructor
40 */
41 constructor(serviceAccountPathOrObject: string | object, httpAgent?: Agent | undefined, implicit?: boolean);
42 getAccessToken(): Promise<GoogleOAuthAccessToken>;
43 private createAuthJwt_;
44}
45/**
46 * Implementation of Credential that gets access tokens from the metadata service available
47 * in the Google Cloud Platform. This authenticates the process as the default service account
48 * of an App Engine instance or Google Compute Engine machine.
49 */
50export declare class ComputeEngineCredential implements Credential {
51 private readonly httpClient;
52 private readonly httpAgent?;
53 private projectId?;
54 constructor(httpAgent?: Agent);
55 getAccessToken(): Promise<GoogleOAuthAccessToken>;
56 getProjectId(): Promise<string>;
57 private buildRequest;
58}
59/**
60 * Implementation of Credential that gets access tokens from refresh tokens.
61 */
62export declare class RefreshTokenCredential implements Credential {
63 private readonly httpAgent?;
64 readonly implicit: boolean;
65 private readonly refreshToken;
66 private readonly httpClient;
67 /**
68 * Creates a new RefreshTokenCredential from the given parameters.
69 *
70 * @param refreshTokenPathOrObject - Refresh token json object or path to a refresh token
71 * (user credentials) json file.
72 * @param httpAgent - Optional http.Agent to use when calling the remote token server.
73 * @param implicit - An optinal boolean indicating whether this credential was implicitly
74 * discovered from the environment, as opposed to being explicitly specified by the developer.
75 *
76 * @constructor
77 */
78 constructor(refreshTokenPathOrObject: string | object, httpAgent?: Agent | undefined, implicit?: boolean);
79 getAccessToken(): Promise<GoogleOAuthAccessToken>;
80}
81/**
82 * Checks if the given credential was loaded via the application default credentials mechanism. This
83 * includes all ComputeEngineCredential instances, and the ServiceAccountCredential and RefreshTokenCredential
84 * instances that were loaded from well-known files or environment variables, rather than being explicitly
85 * instantiated.
86 *
87 * @param credential - The credential instance to check.
88 */
89export declare function isApplicationDefault(credential?: Credential): boolean;
90export declare function getApplicationDefault(httpAgent?: Agent): Credential;