diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers | |
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers')
8 files changed, 741 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/email.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/email.d.ts new file mode 100644 index 0000000..be276ad --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/email.d.ts @@ -0,0 +1,83 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AuthProvider } from '../../model/public_types'; +import { EmailAuthCredential } from '../credentials/email'; +/** + * Provider for generating {@link EmailAuthCredential}. + * + * @public + */ +export declare class EmailAuthProvider implements AuthProvider { + /** + * Always set to {@link ProviderId}.PASSWORD, even for email link. + */ + static readonly PROVIDER_ID: 'password'; + /** + * Always set to {@link SignInMethod}.EMAIL_PASSWORD. + */ + static readonly EMAIL_PASSWORD_SIGN_IN_METHOD: 'password'; + /** + * Always set to {@link SignInMethod}.EMAIL_LINK. + */ + static readonly EMAIL_LINK_SIGN_IN_METHOD: 'emailLink'; + /** + * Always set to {@link ProviderId}.PASSWORD, even for email link. + */ + readonly providerId: "password"; + /** + * Initialize an {@link AuthCredential} using an email and password. + * + * @example + * ```javascript + * const authCredential = EmailAuthProvider.credential(email, password); + * const userCredential = await signInWithCredential(auth, authCredential); + * ``` + * + * @example + * ```javascript + * const userCredential = await signInWithEmailAndPassword(auth, email, password); + * ``` + * + * @param email - Email address. + * @param password - User account password. + * @returns The auth provider credential. + */ + static credential(email: string, password: string): EmailAuthCredential; + /** + * Initialize an {@link AuthCredential} using an email and an email link after a sign in with + * email link operation. + * + * @example + * ```javascript + * const authCredential = EmailAuthProvider.credentialWithLink(auth, email, emailLink); + * const userCredential = await signInWithCredential(auth, authCredential); + * ``` + * + * @example + * ```javascript + * await sendSignInLinkToEmail(auth, email); + * // Obtain emailLink from user. + * const userCredential = await signInWithEmailLink(auth, email, emailLink); + * ``` + * + * @param auth - The {@link Auth} instance used to verify the link. + * @param email - Email address. + * @param emailLink - Sign-in email link. + * @returns - The auth provider credential. + */ + static credentialWithLink(email: string, emailLink: string): EmailAuthCredential; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/facebook.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/facebook.d.ts new file mode 100644 index 0000000..cd8feca --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/facebook.d.ts @@ -0,0 +1,93 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UserCredential } from '../../model/public_types'; +import { FirebaseError } from '@firebase/util'; +import { OAuthCredential } from '../credentials/oauth'; +import { BaseOAuthProvider } from './oauth'; +/** + * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.FACEBOOK. + * + * @example + * ```javascript + * // Sign in using a redirect. + * const provider = new FacebookAuthProvider(); + * // Start a sign in process for an unauthenticated user. + * provider.addScope('user_birthday'); + * await signInWithRedirect(auth, provider); + * // This will trigger a full page redirect away from your app + * + * // After returning from the redirect when your app initializes you can obtain the result + * const result = await getRedirectResult(auth); + * if (result) { + * // This is the signed-in user + * const user = result.user; + * // This gives you a Facebook Access Token. + * const credential = FacebookAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * } + * ``` + * + * @example + * ```javascript + * // Sign in using a popup. + * const provider = new FacebookAuthProvider(); + * provider.addScope('user_birthday'); + * const result = await signInWithPopup(auth, provider); + * + * // The signed-in user info. + * const user = result.user; + * // This gives you a Facebook Access Token. + * const credential = FacebookAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * ``` + * + * @public + */ +export declare class FacebookAuthProvider extends BaseOAuthProvider { + /** Always set to {@link SignInMethod}.FACEBOOK. */ + static readonly FACEBOOK_SIGN_IN_METHOD: 'facebook.com'; + /** Always set to {@link ProviderId}.FACEBOOK. */ + static readonly PROVIDER_ID: 'facebook.com'; + constructor(); + /** + * Creates a credential for Facebook. + * + * @example + * ```javascript + * // `event` from the Facebook auth.authResponseChange callback. + * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken); + * const result = await signInWithCredential(credential); + * ``` + * + * @param accessToken - Facebook access token. + */ + static credential(accessToken: string): OAuthCredential; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}. + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): OAuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): OAuthCredential | null; + private static credentialFromTaggedObject; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/federated.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/federated.d.ts new file mode 100644 index 0000000..91d38b1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/federated.d.ts @@ -0,0 +1,64 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AuthProvider } from '../../model/public_types'; +/** + * Map of OAuth Custom Parameters. + * + * @public + */ +export type CustomParameters = Record<string, string>; +/** + * The base class for all Federated providers (OAuth (including OIDC), SAML). + * + * This class is not meant to be instantiated directly. + * + * @public + */ +export declare abstract class FederatedAuthProvider implements AuthProvider { + readonly providerId: string; + /** @internal */ + defaultLanguageCode: string | null; + /** @internal */ + private customParameters; + /** + * Constructor for generic OAuth providers. + * + * @param providerId - Provider for which credentials should be generated. + */ + constructor(providerId: string); + /** + * Set the language gode. + * + * @param languageCode - language code + */ + setDefaultLanguage(languageCode: string | null): void; + /** + * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in + * operations. + * + * @remarks + * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`, + * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored. + * + * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request. + */ + setCustomParameters(customOAuthParameters: CustomParameters): AuthProvider; + /** + * Retrieve the current list of {@link CustomParameters}. + */ + getCustomParameters(): CustomParameters; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/github.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/github.d.ts new file mode 100644 index 0000000..b8b3ee9 --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/github.d.ts @@ -0,0 +1,89 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UserCredential } from '../../model/public_types'; +import { FirebaseError } from '@firebase/util'; +import { OAuthCredential } from '../credentials/oauth'; +import { BaseOAuthProvider } from './oauth'; +/** + * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GITHUB. + * + * @remarks + * GitHub requires an OAuth 2.0 redirect, so you can either handle the redirect directly, or use + * the {@link signInWithPopup} handler: + * + * @example + * ```javascript + * // Sign in using a redirect. + * const provider = new GithubAuthProvider(); + * // Start a sign in process for an unauthenticated user. + * provider.addScope('repo'); + * await signInWithRedirect(auth, provider); + * // This will trigger a full page redirect away from your app + * + * // After returning from the redirect when your app initializes you can obtain the result + * const result = await getRedirectResult(auth); + * if (result) { + * // This is the signed-in user + * const user = result.user; + * // This gives you a GitHub Access Token. + * const credential = GithubAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * } + * ``` + * + * @example + * ```javascript + * // Sign in using a popup. + * const provider = new GithubAuthProvider(); + * provider.addScope('repo'); + * const result = await signInWithPopup(auth, provider); + * + * // The signed-in user info. + * const user = result.user; + * // This gives you a GitHub Access Token. + * const credential = GithubAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * ``` + * @public + */ +export declare class GithubAuthProvider extends BaseOAuthProvider { + /** Always set to {@link SignInMethod}.GITHUB. */ + static readonly GITHUB_SIGN_IN_METHOD: 'github.com'; + /** Always set to {@link ProviderId}.GITHUB. */ + static readonly PROVIDER_ID: 'github.com'; + constructor(); + /** + * Creates a credential for GitHub. + * + * @param accessToken - GitHub access token. + */ + static credential(accessToken: string): OAuthCredential; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}. + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): OAuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): OAuthCredential | null; + private static credentialFromTaggedObject; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/google.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/google.d.ts new file mode 100644 index 0000000..25d74c8 --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/google.d.ts @@ -0,0 +1,96 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UserCredential } from '../../model/public_types'; +import { FirebaseError } from '@firebase/util'; +import { OAuthCredential } from '../credentials/oauth'; +import { BaseOAuthProvider } from './oauth'; +/** + * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GOOGLE. + * + * @example + * ```javascript + * // Sign in using a redirect. + * const provider = new GoogleAuthProvider(); + * // Start a sign in process for an unauthenticated user. + * provider.addScope('profile'); + * provider.addScope('email'); + * await signInWithRedirect(auth, provider); + * // This will trigger a full page redirect away from your app + * + * // After returning from the redirect when your app initializes you can obtain the result + * const result = await getRedirectResult(auth); + * if (result) { + * // This is the signed-in user + * const user = result.user; + * // This gives you a Google Access Token. + * const credential = GoogleAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * } + * ``` + * + * @example + * ```javascript + * // Sign in using a popup. + * const provider = new GoogleAuthProvider(); + * provider.addScope('profile'); + * provider.addScope('email'); + * const result = await signInWithPopup(auth, provider); + * + * // The signed-in user info. + * const user = result.user; + * // This gives you a Google Access Token. + * const credential = GoogleAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * ``` + * + * @public + */ +export declare class GoogleAuthProvider extends BaseOAuthProvider { + /** Always set to {@link SignInMethod}.GOOGLE. */ + static readonly GOOGLE_SIGN_IN_METHOD: 'google.com'; + /** Always set to {@link ProviderId}.GOOGLE. */ + static readonly PROVIDER_ID: 'google.com'; + constructor(); + /** + * Creates a credential for Google. At least one of ID token and access token is required. + * + * @example + * ```javascript + * // \`googleUser\` from the onsuccess Google Sign In callback. + * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token); + * const result = await signInWithCredential(credential); + * ``` + * + * @param idToken - Google ID token. + * @param accessToken - Google access token. + */ + static credential(idToken?: string | null, accessToken?: string | null): OAuthCredential; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}. + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): OAuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): OAuthCredential | null; + private static credentialFromTaggedObject; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/oauth.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/oauth.d.ts new file mode 100644 index 0000000..3e8e664 --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/oauth.d.ts @@ -0,0 +1,151 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AuthProvider, UserCredential } from '../../model/public_types'; +import { OAuthCredential } from '../credentials/oauth'; +import { FirebaseError } from '@firebase/util'; +import { FederatedAuthProvider } from './federated'; +/** + * Defines the options for initializing an {@link OAuthCredential}. + * + * @remarks + * For ID tokens with nonce claim, the raw nonce has to also be provided. + * + * @public + */ +export interface OAuthCredentialOptions { + /** + * The OAuth ID token used to initialize the {@link OAuthCredential}. + */ + idToken?: string; + /** + * The OAuth access token used to initialize the {@link OAuthCredential}. + */ + accessToken?: string; + /** + * The raw nonce associated with the ID token. + * + * @remarks + * It is required when an ID token with a nonce field is provided. The SHA-256 hash of the + * raw nonce must match the nonce field in the ID token. + */ + rawNonce?: string; +} +/** + * Common code to all OAuth providers. This is separate from the + * {@link OAuthProvider} so that child providers (like + * {@link GoogleAuthProvider}) don't inherit the `credential` instance method. + * Instead, they rely on a static `credential` method. + */ +export declare abstract class BaseOAuthProvider extends FederatedAuthProvider implements AuthProvider { + /** @internal */ + private scopes; + /** + * Add an OAuth scope to the credential. + * + * @param scope - Provider OAuth scope to add. + */ + addScope(scope: string): AuthProvider; + /** + * Retrieve the current list of OAuth scopes. + */ + getScopes(): string[]; +} +/** + * Provider for generating generic {@link OAuthCredential}. + * + * @example + * ```javascript + * // Sign in using a redirect. + * const provider = new OAuthProvider('google.com'); + * // Start a sign in process for an unauthenticated user. + * provider.addScope('profile'); + * provider.addScope('email'); + * await signInWithRedirect(auth, provider); + * // This will trigger a full page redirect away from your app + * + * // After returning from the redirect when your app initializes you can obtain the result + * const result = await getRedirectResult(auth); + * if (result) { + * // This is the signed-in user + * const user = result.user; + * // This gives you a OAuth Access Token for the provider. + * const credential = provider.credentialFromResult(auth, result); + * const token = credential.accessToken; + * } + * ``` + * + * @example + * ```javascript + * // Sign in using a popup. + * const provider = new OAuthProvider('google.com'); + * provider.addScope('profile'); + * provider.addScope('email'); + * const result = await signInWithPopup(auth, provider); + * + * // The signed-in user info. + * const user = result.user; + * // This gives you a OAuth Access Token for the provider. + * const credential = provider.credentialFromResult(auth, result); + * const token = credential.accessToken; + * ``` + * @public + */ +export declare class OAuthProvider extends BaseOAuthProvider { + /** + * Creates an {@link OAuthCredential} from a JSON string or a plain object. + * @param json - A plain object or a JSON string + */ + static credentialFromJSON(json: object | string): OAuthCredential; + /** + * Creates a {@link OAuthCredential} from a generic OAuth provider's access token or ID token. + * + * @remarks + * The raw nonce is required when an ID token with a nonce field is provided. The SHA-256 hash of + * the raw nonce must match the nonce field in the ID token. + * + * @example + * ```javascript + * // `googleUser` from the onsuccess Google Sign In callback. + * // Initialize a generate OAuth provider with a `google.com` providerId. + * const provider = new OAuthProvider('google.com'); + * const credential = provider.credential({ + * idToken: googleUser.getAuthResponse().id_token, + * }); + * const result = await signInWithCredential(credential); + * ``` + * + * @param params - Either the options object containing the ID token, access token and raw nonce + * or the ID token string. + */ + credential(params: OAuthCredentialOptions): OAuthCredential; + /** An internal credential method that accepts more permissive options */ + private _credential; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}. + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): OAuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): OAuthCredential | null; + private static oauthCredentialFromTaggedObject; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/saml.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/saml.d.ts new file mode 100644 index 0000000..6017bfe --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/saml.d.ts @@ -0,0 +1,62 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FirebaseError } from '@firebase/util'; +import { UserCredential } from '../../model/public_types'; +import { AuthCredential } from '../credentials'; +import { FederatedAuthProvider } from './federated'; +/** + * An {@link AuthProvider} for SAML. + * + * @public + */ +export declare class SAMLAuthProvider extends FederatedAuthProvider { + /** + * Constructor. The providerId must start with "saml." + * @param providerId - SAML provider ID. + */ + constructor(providerId: string); + /** + * Generates an {@link AuthCredential} from a {@link UserCredential} after a + * successful SAML flow completes. + * + * @remarks + * + * For example, to get an {@link AuthCredential}, you could write the + * following code: + * + * ```js + * const userCredential = await signInWithPopup(auth, samlProvider); + * const credential = SAMLAuthProvider.credentialFromResult(userCredential); + * ``` + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): AuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): AuthCredential | null; + /** + * Creates an {@link AuthCredential} from a JSON string or a plain object. + * @param json - A plain object or a JSON string + */ + static credentialFromJSON(json: string | object): AuthCredential; + private static samlCredentialFromTaggedObject; +} diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/twitter.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/twitter.d.ts new file mode 100644 index 0000000..612913d --- /dev/null +++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/core/providers/twitter.d.ts @@ -0,0 +1,103 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @license + * Copyright 2020 Twitter LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UserCredential } from '../../model/public_types'; +import { FirebaseError } from '@firebase/util'; +import { OAuthCredential } from '../credentials/oauth'; +import { BaseOAuthProvider } from './oauth'; +/** + * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER. + * + * @example + * ```javascript + * // Sign in using a redirect. + * const provider = new TwitterAuthProvider(); + * // Start a sign in process for an unauthenticated user. + * await signInWithRedirect(auth, provider); + * // This will trigger a full page redirect away from your app + * + * // After returning from the redirect when your app initializes you can obtain the result + * const result = await getRedirectResult(auth); + * if (result) { + * // This is the signed-in user + * const user = result.user; + * // This gives you a Twitter Access Token and Secret. + * const credential = TwitterAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * const secret = credential.secret; + * } + * ``` + * + * @example + * ```javascript + * // Sign in using a popup. + * const provider = new TwitterAuthProvider(); + * const result = await signInWithPopup(auth, provider); + * + * // The signed-in user info. + * const user = result.user; + * // This gives you a Twitter Access Token and Secret. + * const credential = TwitterAuthProvider.credentialFromResult(result); + * const token = credential.accessToken; + * const secret = credential.secret; + * ``` + * + * @public + */ +export declare class TwitterAuthProvider extends BaseOAuthProvider { + /** Always set to {@link SignInMethod}.TWITTER. */ + static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com'; + /** Always set to {@link ProviderId}.TWITTER. */ + static readonly PROVIDER_ID: 'twitter.com'; + constructor(); + /** + * Creates a credential for Twitter. + * + * @param token - Twitter access token. + * @param secret - Twitter secret. + */ + static credential(token: string, secret: string): OAuthCredential; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}. + * + * @param userCredential - The user credential. + */ + static credentialFromResult(userCredential: UserCredential): OAuthCredential | null; + /** + * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was + * thrown during a sign-in, link, or reauthenticate operation. + * + * @param userCredential - The user credential. + */ + static credentialFromError(error: FirebaseError): OAuthCredential | null; + private static credentialFromTaggedObject; +} |
