Skip to content

Commit 1b1dbb7

Browse files
authored
Allow Credential to auto-generate typings, separate internal vs external APIs (#1012)
1 parent 2424335 commit 1b1dbb7

21 files changed

+556
-506
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var paths = {
5454

5555
curatedTypings: [
5656
'src/*.d.ts',
57+
'!src/credential.d.ts',
5758
'!src/database.d.ts',
5859
'!src/instance-id.d.ts',
5960
'!src/security-rules.d.ts',

src/auth/token-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { FirebaseApp } from '../firebase-app';
18-
import { ServiceAccountCredential } from '../credential/credential';
18+
import { ServiceAccountCredential } from '../credential/credential-internal';
1919
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
2020
import { AuthorizedHttpClient, HttpError, HttpRequestConfig, HttpClient } from '../utils/api-request';
2121

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*!
2+
* Copyright 2020 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// TODO: According to the typings this is part of the Firebase Namespace today
18+
// and not credential; it will need to be moved accordingly.
19+
/**
20+
* Interface for Google OAuth 2.0 access tokens.
21+
*/
22+
export interface GoogleOAuthAccessToken {
23+
/* tslint:disable:variable-name */
24+
access_token: string;
25+
expires_in: number;
26+
/* tslint:enable:variable-name */
27+
}
28+
29+
/**
30+
* Interface that provides Google OAuth2 access tokens used to authenticate
31+
* with Firebase services.
32+
*
33+
* In most cases, you will not need to implement this yourself and can instead
34+
* use the default implementations provided by
35+
* {@link admin.credential `admin.credential`}.
36+
*/
37+
export interface Credential {
38+
/**
39+
* Returns a Google OAuth2 access token object used to authenticate with
40+
* Firebase services.
41+
*
42+
* This object contains the following properties:
43+
* * `access_token` (`string`): The actual Google OAuth2 access token.
44+
* * `expires_in` (`number`): The number of seconds from when the token was
45+
* issued that it expires.
46+
*
47+
* @return A Google OAuth2 access token object.
48+
*/
49+
getAccessToken(): Promise<GoogleOAuthAccessToken>;
50+
}

0 commit comments

Comments
 (0)