Skip to content

Commit adb60da

Browse files
authored
Merge 8ec6f1e into f1de10e
2 parents f1de10e + 8ec6f1e commit adb60da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+674
-775
lines changed

packages-exp/auth-compat-exp/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import '@firebase/installations';
2828
import { version } from './package.json';
2929
import { Auth } from './src/auth';
3030
import { RecaptchaVerifier } from './src/recaptcha_verifier';
31-
import { EmailAuthProvider } from './src/email_auth_provider';
3231
import { Persistence } from './src/persistence';
3332

3433
const AUTH_TYPE = 'auth';
@@ -58,7 +57,7 @@ function registerAuth(instance: _FirebaseNamespace): void {
5857
VERIFY_EMAIL: externs.Operation.VERIFY_EMAIL
5958
}
6059
},
61-
EmailAuthProvider,
60+
EmailAuthProvider: impl.EmailAuthProvider,
6261
FacebookAuthProvider: impl.FacebookAuthProvider,
6362
GithubAuthProvider: impl.GithubAuthProvider,
6463
GoogleAuthProvider: impl.GoogleAuthProvider,
@@ -70,8 +69,8 @@ function registerAuth(instance: _FirebaseNamespace): void {
7069
TwitterAuthProvider: impl.TwitterAuthProvider,
7170
Auth: {
7271
Persistence
73-
}
74-
// 'AuthCredential': fireauth.AuthCredential,
72+
},
73+
AuthCredential: impl.AuthCredential
7574
// 'Error': fireauth.AuthError
7675
})
7776
.setInstantiationMode(InstantiationMode.LAZY)

packages-exp/auth-compat-exp/src/auth.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class Auth extends impl.AuthImplCompat<User>
4747
);
4848

4949
// TODO: platform needs to be determined using heuristics
50-
impl.assertFn(apiKey, app.name, impl.AuthErrorCode.INVALID_API_KEY);
50+
impl.assertFn(apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
51+
appName: app.name
52+
});
5153
const config: externs.Config = {
5254
apiKey,
5355
authDomain,
@@ -108,8 +110,8 @@ export class Auth extends impl.AuthImplCompat<User>
108110
async getRedirectResult(): Promise<compat.UserCredential> {
109111
impl.assertFn(
110112
_isPopupRedirectSupported(),
111-
this.app.name,
112-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
113+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
114+
{ appName: this.app.name }
113115
);
114116
const credential = await impl.getRedirectResult(
115117
this._asExtern(),
@@ -181,7 +183,9 @@ export class Auth extends impl.AuthImplCompat<User>
181183
case Persistence.NONE:
182184
return impl.inMemoryPersistence;
183185
default:
184-
return impl.fail(auth.name, impl.AuthErrorCode.ARGUMENT_ERROR);
186+
return impl.fail(impl.AuthErrorCode.ARGUMENT_ERROR, {
187+
appName: auth.name
188+
});
185189
}
186190
}
187191

@@ -254,8 +258,8 @@ export class Auth extends impl.AuthImplCompat<User>
254258
): Promise<compat.UserCredential> {
255259
impl.assertFn(
256260
_isPopupRedirectSupported(),
257-
this.app.name,
258-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
261+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
262+
{ appName: this.app.name }
259263
);
260264
return convertCredential(
261265
this._asExtern(),
@@ -269,8 +273,8 @@ export class Auth extends impl.AuthImplCompat<User>
269273
async signInWithRedirect(provider: compat.AuthProvider): Promise<void> {
270274
impl.assertFn(
271275
_isPopupRedirectSupported(),
272-
this.app.name,
273-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
276+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
277+
{ appName: this.app.name }
274278
);
275279
return impl.signInWithRedirect(
276280
this._asExtern(),

packages-exp/auth-compat-exp/src/email_auth_provider.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages-exp/auth-compat-exp/src/persistence.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ export function _validatePersistenceArgument(
3636
): void {
3737
assertFn(
3838
Object.values(Persistence).includes(persistence),
39-
auth.name,
40-
AuthErrorCode.INVALID_PERSISTENCE
39+
AuthErrorCode.INVALID_PERSISTENCE,
40+
{ appName: auth.name }
4141
);
4242
// Validate if the specified type is supported in the current environment.
4343
if (isReactNative()) {
4444
// This is only supported in a browser.
4545
assertFn(
4646
persistence !== Persistence.SESSION,
47-
auth.name,
48-
AuthErrorCode.UNSUPPORTED_PERSISTENCE
47+
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
48+
{ appName: auth.name }
4949
);
5050
return;
5151
}
5252
if (isNode()) {
5353
// Only none is supported in Node.js.
5454
assertFn(
5555
persistence === Persistence.NONE,
56-
auth.name,
57-
AuthErrorCode.UNSUPPORTED_PERSISTENCE
56+
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
57+
{ appName: auth.name }
5858
);
5959
return;
6060
}
@@ -64,15 +64,15 @@ export function _validatePersistenceArgument(
6464
assertFn(
6565
persistence === Persistence.NONE ||
6666
(persistence === Persistence.LOCAL && isIndexedDBAvailable()),
67-
auth.name,
68-
AuthErrorCode.UNSUPPORTED_PERSISTENCE
67+
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
68+
{ appName: auth.name }
6969
);
7070
return;
7171
}
7272
// This is restricted by what the browser supports.
7373
assertFn(
7474
persistence === Persistence.NONE || _isWebStorageSupported(),
75-
auth.name,
76-
AuthErrorCode.UNSUPPORTED_PERSISTENCE
75+
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
76+
{ appName: auth.name }
7777
);
7878
}

packages-exp/auth-compat-exp/src/recaptcha_verifier.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ export class RecaptchaVerifier extends impl.RecaptchaVerifier
2929
app: FirebaseApp = firebase.app()
3030
) {
3131
// API key is required for web client RPC calls.
32-
impl.assertFn(
33-
app.options?.apiKey,
34-
app.name,
35-
impl.AuthErrorCode.INVALID_API_KEY
36-
);
32+
impl.assertFn(app.options?.apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
33+
appName: app.name
34+
});
3735
super(container, parameters, (app.auth!() as unknown) as externs.Auth);
3836
}
3937
}

packages-exp/auth-exp/src/api/account_management/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export async function deleteAccount(
3636
}
3737

3838
export interface ProviderUserInfo {
39+
providerId: string;
3940
rawId?: string;
40-
providerId?: string;
4141
email?: string;
4242
displayName?: string;
4343
photoUrl?: string;

packages-exp/auth-exp/src/api/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,19 @@ export async function _performFetchWithErrorHandling<V>(
142142

143143
const authError = errorMap[serverErrorCode];
144144
if (authError) {
145-
fail(auth.name, authError);
145+
fail(authError, { appName: auth.name });
146146
} else {
147147
// TODO probably should handle improperly formatted errors as well
148148
// If you see this, add an entry to SERVER_ERROR_MAP for the corresponding error
149149
console.error(`Unexpected API error: ${json.error.message}`);
150-
fail(auth.name, AuthErrorCode.INTERNAL_ERROR);
150+
fail(AuthErrorCode.INTERNAL_ERROR, { appName: auth.name });
151151
}
152152
}
153153
} catch (e) {
154154
if (e instanceof FirebaseError) {
155155
throw e;
156156
}
157-
fail(auth.name, AuthErrorCode.NETWORK_REQUEST_FAILED);
157+
fail(AuthErrorCode.NETWORK_REQUEST_FAILED, { appName: auth.name });
158158
}
159159
}
160160

packages-exp/auth-exp/src/core/action_code_url.test.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ import { expect } from 'chai';
1919

2020
import { Operation } from '@firebase/auth-types-exp';
2121

22-
import { testAuth, TestAuth } from '../../test/helpers/mock_auth';
2322
import { ActionCodeURL } from './action_code_url';
2423

2524
describe('core/action_code_url', () => {
26-
let auth: TestAuth;
27-
beforeEach(async () => {
28-
auth = await testAuth();
29-
});
30-
3125
describe('._fromLink', () => {
3226
it('should parse correctly formatted links', () => {
3327
const continueUrl = 'https://www.example.com/path/to/file?a=1&b=2#c=3';
@@ -37,7 +31,7 @@ describe('core/action_code_url', () => {
3731
'continueUrl=' +
3832
encodeURIComponent(continueUrl) +
3933
'&languageCode=en&tenantId=TENANT_ID&state=bla';
40-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
34+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
4135
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
4236
expect(actionCodeUrl!.code).to.eq('CODE');
4337
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
@@ -53,7 +47,7 @@ describe('core/action_code_url', () => {
5347
'https://www.example.com/finishSignIn?' +
5448
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
5549
'languageCode=en';
56-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
50+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
5751
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
5852
});
5953

@@ -62,7 +56,7 @@ describe('core/action_code_url', () => {
6256
'https://www.example.com/finishSignIn?' +
6357
'oobCode=CODE&mode=verifyAndChangeEmail&apiKey=API_KEY&' +
6458
'languageCode=en';
65-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
59+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
6660
expect(actionCodeUrl!.operation).to.eq(
6761
Operation.VERIFY_AND_CHANGE_EMAIL
6862
);
@@ -73,7 +67,7 @@ describe('core/action_code_url', () => {
7367
'https://www.example.com/finishSignIn?' +
7468
'oobCode=CODE&mode=verifyEmail&apiKey=API_KEY&' +
7569
'languageCode=en';
76-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
70+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
7771
expect(actionCodeUrl!.operation).to.eq(Operation.VERIFY_EMAIL);
7872
});
7973

@@ -82,7 +76,7 @@ describe('core/action_code_url', () => {
8276
'https://www.example.com/finishSignIn?' +
8377
'oobCode=CODE&mode=recoverEmail&apiKey=API_KEY&' +
8478
'languageCode=en';
85-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
79+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
8680
expect(actionCodeUrl!.operation).to.eq(Operation.RECOVER_EMAIL);
8781
});
8882

@@ -91,7 +85,7 @@ describe('core/action_code_url', () => {
9185
'https://www.example.com/finishSignIn?' +
9286
'oobCode=CODE&mode=resetPassword&apiKey=API_KEY&' +
9387
'languageCode=en';
94-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
88+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
9589
expect(actionCodeUrl!.operation).to.eq(Operation.PASSWORD_RESET);
9690
});
9791

@@ -100,7 +94,7 @@ describe('core/action_code_url', () => {
10094
'https://www.example.com/finishSignIn?' +
10195
'oobCode=CODE&mode=revertSecondFactorAddition&apiKey=API_KEY&' +
10296
'languageCode=en';
103-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
97+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
10498
expect(actionCodeUrl!.operation).to.eq(
10599
Operation.REVERT_SECOND_FACTOR_ADDITION
106100
);
@@ -111,7 +105,7 @@ describe('core/action_code_url', () => {
111105
const actionLink =
112106
'https://www.example.com:8080/finishSignIn?' +
113107
'oobCode=CODE&mode=signIn&apiKey=API_KEY&state=bla';
114-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
108+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
115109
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
116110
expect(actionCodeUrl!.code).to.eq('CODE');
117111
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
@@ -125,7 +119,7 @@ describe('core/action_code_url', () => {
125119
'https://www.example.com/finishSignIn?' +
126120
'oobCode=CODE1&mode=signIn&apiKey=API_KEY1&state=bla' +
127121
'#oobCode=CODE2&mode=signIn&apiKey=API_KEY2&state=bla';
128-
const actionCodeUrl = ActionCodeURL.parseLink(auth, actionLink);
122+
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
129123
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
130124
expect(actionCodeUrl!.code).to.eq('CODE1');
131125
expect(actionCodeUrl!.apiKey).to.eq('API_KEY1');
@@ -137,31 +131,31 @@ describe('core/action_code_url', () => {
137131
context('invalid links', () => {
138132
it('should handle missing API key, code & mode', () => {
139133
const actionLink = 'https://www.example.com/finishSignIn';
140-
expect(ActionCodeURL.parseLink(auth, actionLink)).to.be.null;
134+
expect(ActionCodeURL.parseLink(actionLink)).to.be.null;
141135
});
142136

143137
it('should handle invalid mode', () => {
144138
const actionLink =
145139
'https://www.example.com/finishSignIn?oobCode=CODE&mode=INVALID_MODE&apiKey=API_KEY';
146-
expect(ActionCodeURL.parseLink(auth, actionLink)).to.be.null;
140+
expect(ActionCodeURL.parseLink(actionLink)).to.be.null;
147141
});
148142

149143
it('should handle missing code', () => {
150144
const actionLink =
151145
'https://www.example.com/finishSignIn?mode=signIn&apiKey=API_KEY';
152-
expect(ActionCodeURL.parseLink(auth, actionLink)).to.be.null;
146+
expect(ActionCodeURL.parseLink(actionLink)).to.be.null;
153147
});
154148

155149
it('should handle missing API key', () => {
156150
const actionLink =
157151
'https://www.example.com/finishSignIn?oobCode=CODE&mode=signIn';
158-
expect(ActionCodeURL.parseLink(auth, actionLink)).to.be.null;
152+
expect(ActionCodeURL.parseLink(actionLink)).to.be.null;
159153
});
160154

161155
it('should handle missing mode', () => {
162156
const actionLink =
163157
'https://www.example.com/finishSignIn?oobCode=CODE&apiKey=API_KEY';
164-
expect(ActionCodeURL.parseLink(auth, actionLink)).to.be.null;
158+
expect(ActionCodeURL.parseLink(actionLink)).to.be.null;
165159
});
166160
});
167161
});

0 commit comments

Comments
 (0)