Skip to content

Fix v9 Auth types #5260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions common/api-review/auth-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
export interface Auth {
readonly config: Config;
readonly currentUser: User | null;
// Warning: (ae-forgotten-export) The symbol "EmulatorConfig" needs to be exported by the entry point index.d.ts
readonly emulatorConfig: EmulatorConfig | null;
languageCode: string | null;
readonly name: string;
Expand Down Expand Up @@ -328,6 +327,16 @@ export class EmailAuthProvider implements AuthProvider {
readonly providerId: "password";
}

// @public
export interface EmulatorConfig {
readonly host: string;
readonly options: {
readonly disableWarnings: boolean;
};
readonly port: number | null;
readonly protocol: string;
}

export { ErrorFn }

// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -463,6 +472,8 @@ export interface MultiFactorUser {
unenroll(option: MultiFactorInfo | string): Promise<void>;
}

export { NextFn }

// @public
export type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;

Expand Down Expand Up @@ -634,12 +645,17 @@ export function reauthenticateWithPopup(user: User, provider: AuthProvider, reso
// @public
export function reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;

// @public
export interface RecaptchaParameters {
// (undocumented)
[key: string]: any;
}

// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.d.ts
//
// @public
export class RecaptchaVerifier implements ApplicationVerifierInternal {
// Warning: (ae-forgotten-export) The symbol "Parameters" needs to be exported by the entry point index.d.ts
constructor(containerOrId: HTMLElement | string, parameters: Parameters_2, authExtern: Auth);
constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
clear(): void;
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts
//
Expand Down
41 changes: 1 addition & 40 deletions packages-exp/auth-exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,7 @@ import { browserPopupRedirectResolver } from './src/platform_browser/popup_redir
import { Auth } from './src/model/public_types';

// Public types
export {
// Interfaces
ActionCodeInfo,
ActionCodeSettings,
AdditionalUserInfo,
ApplicationVerifier,
Auth,
AuthError,
AuthErrorMap,
AuthProvider,
AuthSettings,
Config,
ConfirmationResult,
IdTokenResult,
MultiFactorAssertion,
MultiFactorError,
MultiFactorInfo,
MultiFactorResolver,
MultiFactorSession,
MultiFactorUser,
ParsedToken,
Persistence,
PhoneMultiFactorAssertion,
PhoneMultiFactorEnrollInfoOptions,
PhoneMultiFactorSignInInfoOptions,
PhoneSingleFactorInfoOptions,
PopupRedirectResolver,
ReactNativeAsyncStorage,
User,
UserCredential,
UserInfo,
UserMetadata,
UserProfile,
PhoneInfoOptions,
Dependencies,
NextOrObserver,
ErrorFn,
CompleteFn,
Unsubscribe
} from './src/model/public_types';
export * from './src/model/public_types';

// Helper maps (not used internally)
export {
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"test:node:integration": "node ./scripts/run-node-tests.js --integration",
"test:node:integration:local": "node ./scripts/run-node-tests.js --integration --local",
"test:webdriver": "rollup -c test/integration/webdriver/static/rollup.config.js && node ./scripts/run-node-tests.js --webdriver",
"api-report": "api-extractor run --local --verbose",
"api-report": "api-extractor run --local --verbose && ts-node-script ../../repo-scripts/prune-dts/prune-dts.ts --input dist/auth-exp-public.d.ts --output dist/auth-exp-public.d.ts",
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs",
"build:doc": "yarn build && yarn doc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

import { ProviderId } from '../../model/public_types';
import { ProviderId } from '../../model/enums';
import { FirebaseError } from '@firebase/util';

import { Endpoint, HttpHeader } from '../';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

import { ProviderId } from '../../model/public_types';
import { ProviderId } from '../../model/enums';
import { FirebaseError } from '@firebase/util';

import { Endpoint, HttpHeader } from '../';
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/src/api/authentication/sms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

import { ProviderId } from '../../model/public_types';
import { ProviderId } from '../../model/enums';
import { FirebaseError } from '@firebase/util';

import { Endpoint, HttpHeader } from '../';
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/src/core/credentials/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ProviderId, SignInMethod } from '../../model/public_types';
import { ProviderId, SignInMethod } from '../../model/enums';

import { updateEmailPassword } from '../../api/account_management/email_and_password';
import { signInWithPassword } from '../../api/authentication/email_and_password';
Expand Down
18 changes: 5 additions & 13 deletions packages-exp/auth-exp/src/core/credentials/phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ProviderId, SignInMethod } from '../../model/public_types';
import { ProviderId, SignInMethod } from '../../model/enums';

import { PhoneOrOauthTokenResponse } from '../../api/authentication/mfa';
import {
Expand Down Expand Up @@ -84,12 +84,8 @@ export class PhoneAuthCredential extends AuthCredential {

/** @internal */
_makeVerificationRequest(): SignInWithPhoneNumberRequest {
const {
temporaryProof,
phoneNumber,
verificationId,
verificationCode
} = this.params;
const { temporaryProof, phoneNumber, verificationId, verificationCode } =
this.params;
if (temporaryProof && phoneNumber) {
return { temporaryProof, phoneNumber };
}
Expand Down Expand Up @@ -127,12 +123,8 @@ export class PhoneAuthCredential extends AuthCredential {
json = JSON.parse(json);
}

const {
verificationId,
verificationCode,
phoneNumber,
temporaryProof
} = json as { [key: string]: string };
const { verificationId, verificationCode, phoneNumber, temporaryProof } =
json as { [key: string]: string };
if (
!verificationCode &&
!verificationId &&
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/providers/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
* limitations under the License.
*/

import {
ProviderId,
SignInMethod,
AuthProvider
} from '../../model/public_types';
import { ProviderId, SignInMethod } from '../../model/enums';
import { AuthProvider } from '../../model/public_types';

import { ActionCodeURL } from '../action_code_url';
import { EmailAuthCredential } from '../credentials/email';
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/providers/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
* limitations under the License.
*/

import {
ProviderId,
SignInMethod,
UserCredential
} from '../../model/public_types';
import { UserCredential } from '../../model/public_types';
import { FirebaseError } from '@firebase/util';

import { TaggedWithTokenResponse } from '../../model/id_token';
import { UserCredentialInternal } from '../../model/user';
import { OAuthCredential } from '../credentials/oauth';
import { BaseOAuthProvider } from './oauth';
import { ProviderId, SignInMethod } from '../../model/enums';

/**
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.FACEBOOK.
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/providers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
* limitations under the License.
*/

import {
ProviderId,
SignInMethod,
UserCredential
} from '../../model/public_types';
import { UserCredential } from '../../model/public_types';
import { FirebaseError } from '@firebase/util';

import { TaggedWithTokenResponse } from '../../model/id_token';
import { UserCredentialInternal } from '../../model/user';
import { OAuthCredential } from '../credentials/oauth';
import { BaseOAuthProvider } from './oauth';
import { ProviderId, SignInMethod } from '../../model/enums';

/**
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GITHUB.
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/providers/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
* limitations under the License.
*/

import {
ProviderId,
SignInMethod,
UserCredential
} from '../../model/public_types';
import { UserCredential } from '../../model/public_types';
import { FirebaseError } from '@firebase/util';

import { SignInWithIdpResponse } from '../../api/authentication/idp';
import { TaggedWithTokenResponse } from '../../model/id_token';
import { UserCredentialInternal } from '../../model/user';
import { OAuthCredential } from '../credentials/oauth';
import { BaseOAuthProvider } from './oauth';
import { ProviderId, SignInMethod } from '../../model/enums';

/**
* Provider for generating an an {@link OAuthCredential} for {@link ProviderId}.GOOGLE.
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/providers/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@
* limitations under the License.
*/

import {
ProviderId,
SignInMethod,
UserCredential
} from '../../model/public_types';
import { UserCredential } from '../../model/public_types';
import { FirebaseError } from '@firebase/util';

import { SignInWithIdpResponse } from '../../api/authentication/idp';
import { TaggedWithTokenResponse } from '../../model/id_token';
import { UserCredentialInternal } from '../../model/user';
import { OAuthCredential } from '../credentials/oauth';
import { BaseOAuthProvider } from './oauth';
import { ProviderId, SignInMethod } from '../../model/enums';

/**
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
Expand Down
3 changes: 2 additions & 1 deletion packages-exp/auth-exp/src/core/strategies/anonymous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* limitations under the License.
*/

import { Auth, OperationType, UserCredential } from '../../model/public_types';
import { Auth, UserCredential } from '../../model/public_types';
import { signUp } from '../../api/authentication/sign_up';
import { UserInternal } from '../../model/user';
import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { OperationType } from '../../model/enums';

/**
* Asynchronously signs in as an anonymous user.
Expand Down
8 changes: 2 additions & 6 deletions packages-exp/auth-exp/src/core/strategies/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
* limitations under the License.
*/

import {
OperationType,
UserCredential,
Auth,
User
} from '../../model/public_types';
import { UserCredential, Auth, User } from '../../model/public_types';

import { _processCredentialSavingMfaContextIfNecessary } from '../../mfa/mfa_error';
import { AuthInternal } from '../../model/auth';
Expand All @@ -31,6 +26,7 @@ import { _reauthenticate } from '../user/reauthenticate';
import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { getModularInstance } from '@firebase/util';
import { OperationType } from '../../model/enums';

export async function _signInWithCredential(
auth: AuthInternal,
Expand Down
3 changes: 2 additions & 1 deletion packages-exp/auth-exp/src/core/strategies/custom_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
* limitations under the License.
*/

import { Auth, OperationType, UserCredential } from '../../model/public_types';
import { Auth, UserCredential } from '../../model/public_types';

import { signInWithCustomToken as getIdTokenResponse } from '../../api/authentication/custom_token';
import { IdTokenResponse } from '../../model/id_token';
import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { OperationType } from '../../model/enums';

/**
* Asynchronously signs in using a custom token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
ActionCodeOperation,
ActionCodeSettings,
Auth,
OperationType,
UserCredential
} from '../../model/public_types';

Expand All @@ -36,6 +35,7 @@ import { signInWithCredential } from './credential';
import { _castAuth } from '../auth/auth_impl';
import { AuthErrorCode } from '../errors';
import { getModularInstance } from '@firebase/util';
import { OperationType } from '../../model/enums';

/**
* Sends a password reset email to the given email address.
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/src/core/strategies/idp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { ProviderId } from '../../model/public_types';
import {
signInWithIdp,
SignInWithIdpRequest
Expand All @@ -30,6 +29,7 @@ import { _reauthenticate } from '../user/reauthenticate';
import { _assert } from '../util/assert';
import { _signInWithCredential } from './credential';
import { AuthErrorCode } from '../errors';
import { ProviderId } from '../../model/enums';

export interface IdpTaskParams {
auth: AuthInternal;
Expand Down
3 changes: 2 additions & 1 deletion packages-exp/auth-exp/src/core/user/account_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ProviderId, User } from '../../model/public_types';
import { User } from '../../model/public_types';

import {
updateEmailPassword as apiUpdateEmailPassword,
Expand All @@ -25,6 +25,7 @@ import { updateProfile as apiUpdateProfile } from '../../api/account_management/
import { UserInternal } from '../../model/user';
import { _logoutIfInvalidated } from './invalidation';
import { getModularInstance } from '@firebase/util';
import { ProviderId } from '../../model/enums';

/**
* Updates a user's profile data.
Expand Down
7 changes: 2 additions & 5 deletions packages-exp/auth-exp/src/core/user/additional_user_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
* limitations under the License.
*/

import {
AdditionalUserInfo,
ProviderId,
UserCredential
} from '../../model/public_types';
import { AdditionalUserInfo, UserCredential } from '../../model/public_types';
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
import { _parseToken } from './id_token_result';
import { UserCredentialInternal } from '../../model/user';
import { ProviderId } from '../../model/enums';

/**
* Parse the `AdditionalUserInfo` from the ID token response.
Expand Down
Loading