UNPKG

2.97 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC
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 { AuthInternal } from '../../model/auth';
18import { IdTokenResponse } from '../../model/id_token';
19import { AuthCredential } from './auth_credential';
20export interface OAuthCredentialParams {
21 idToken?: string | null;
22 accessToken?: string | null;
23 oauthToken?: string;
24 secret?: string;
25 oauthTokenSecret?: string;
26 nonce?: string;
27 pendingToken?: string;
28 providerId: string;
29 signInMethod: string;
30}
31/**
32 * Represents the OAuth credentials returned by an {@link OAuthProvider}.
33 *
34 * @remarks
35 * Implementations specify the details about each auth provider's credential requirements.
36 *
37 * @public
38 */
39export declare class OAuthCredential extends AuthCredential {
40 /**
41 * The OAuth ID token associated with the credential if it belongs to an OIDC provider,
42 * such as `google.com`.
43 * @readonly
44 */
45 idToken?: string;
46 /**
47 * The OAuth access token associated with the credential if it belongs to an
48 * {@link OAuthProvider}, such as `facebook.com`, `twitter.com`, etc.
49 * @readonly
50 */
51 accessToken?: string;
52 /**
53 * The OAuth access token secret associated with the credential if it belongs to an OAuth 1.0
54 * provider, such as `twitter.com`.
55 * @readonly
56 */
57 secret?: string;
58 private nonce?;
59 private pendingToken;
60 /** @internal */
61 static _fromParams(params: OAuthCredentialParams): OAuthCredential;
62 /** {@inheritdoc AuthCredential.toJSON} */
63 toJSON(): object;
64 /**
65 * Static method to deserialize a JSON representation of an object into an
66 * {@link AuthCredential}.
67 *
68 * @param json - Input can be either Object or the stringified representation of the object.
69 * When string is provided, JSON.parse would be called first.
70 *
71 * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
72 */
73 static fromJSON(json: string | object): OAuthCredential | null;
74 /** @internal */
75 _getIdTokenResponse(auth: AuthInternal): Promise<IdTokenResponse>;
76 /** @internal */
77 _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
78 /** @internal */
79 _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
80 private buildRequest;
81}