UNPKG

5.35 kBTypeScriptView Raw
1/*! firebase-admin v12.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 private accountId?;
55 constructor(httpAgent?: Agent);
56 getAccessToken(): Promise<GoogleOAuthAccessToken>;
57 /**
58 * getIDToken returns a OIDC token from the compute metadata service
59 * that can be used to make authenticated calls to audience
60 * @param audience the URL the returned ID token will be used to call.
61 */
62 getIDToken(audience: string): Promise<string>;
63 getProjectId(): Promise<string>;
64 getServiceAccountEmail(): Promise<string>;
65 private buildRequest;
66}
67/**
68 * Implementation of Credential that gets access tokens from refresh tokens.
69 */
70export declare class RefreshTokenCredential implements Credential {
71 private readonly httpAgent?;
72 readonly implicit: boolean;
73 private readonly refreshToken;
74 private readonly httpClient;
75 /**
76 * Creates a new RefreshTokenCredential from the given parameters.
77 *
78 * @param refreshTokenPathOrObject - Refresh token json object or path to a refresh token
79 * (user credentials) json file.
80 * @param httpAgent - Optional http.Agent to use when calling the remote token server.
81 * @param implicit - An optinal boolean indicating whether this credential was implicitly
82 * discovered from the environment, as opposed to being explicitly specified by the developer.
83 *
84 * @constructor
85 */
86 constructor(refreshTokenPathOrObject: string | object, httpAgent?: Agent | undefined, implicit?: boolean);
87 getAccessToken(): Promise<GoogleOAuthAccessToken>;
88}
89/**
90 * Implementation of Credential that uses impersonated service account.
91 */
92export declare class ImpersonatedServiceAccountCredential implements Credential {
93 private readonly httpAgent?;
94 readonly implicit: boolean;
95 private readonly impersonatedServiceAccount;
96 private readonly httpClient;
97 /**
98 * Creates a new ImpersonatedServiceAccountCredential from the given parameters.
99 *
100 * @param impersonatedServiceAccountPathOrObject - Impersonated Service account json object or
101 * path to a service account json file.
102 * @param httpAgent - Optional http.Agent to use when calling the remote token server.
103 * @param implicit - An optional boolean indicating whether this credential was implicitly
104 * discovered from the environment, as opposed to being explicitly specified by the developer.
105 *
106 * @constructor
107 */
108 constructor(impersonatedServiceAccountPathOrObject: string | object, httpAgent?: Agent | undefined, implicit?: boolean);
109 getAccessToken(): Promise<GoogleOAuthAccessToken>;
110}
111/**
112 * Checks if the given credential was loaded via the application default credentials mechanism. This
113 * includes all ComputeEngineCredential instances, and the ServiceAccountCredential and RefreshTokenCredential
114 * instances that were loaded from well-known files or environment variables, rather than being explicitly
115 * instantiated.
116 *
117 * @param credential - The credential instance to check.
118 */
119export declare function isApplicationDefault(credential?: Credential): boolean;
120export declare function getApplicationDefault(httpAgent?: Agent): Credential;