Skip to content

Commit 994acee

Browse files
committed
Fix compat
1 parent db9112c commit 994acee

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

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

+12-10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
import { unwrap, Wrapper } from './wrap';
3838

3939
const PERSISTENCE_KEY = 'persistence';
40+
const _assert: typeof impl._assert = impl._assert;
4041

4142
export class Auth
4243
implements compat.FirebaseAuth, Wrapper<externs.Auth>, _FirebaseService {
@@ -59,10 +60,12 @@ export class Auth
5960
const hierarchy = persistences.map<impl.Persistence>(impl._getInstance);
6061

6162
// TODO: platform needs to be determined using heuristics
62-
impl.assertFn(apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
63+
_assert(apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
6364
appName: app.name
6465
});
6566

67+
this.auth._updateErrorMap(impl.verboseErrorMap);
68+
6669
// This promise is intended to float; auth initialization happens in the
6770
// background, meanwhile the auth object may be used by the app.
6871
// eslint-disable-next-line @typescript-eslint/no-floating-promises
@@ -128,10 +131,10 @@ export class Auth
128131
return impl.isSignInWithEmailLink(this.auth, emailLink);
129132
}
130133
async getRedirectResult(): Promise<compat.UserCredential> {
131-
impl.assertFn(
134+
_assert(
132135
_isPopupRedirectSupported(),
136+
this.auth,
133137
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
134-
{ appName: this.app.name }
135138
);
136139
const credential = await impl.getRedirectResult(
137140
this.auth,
@@ -201,7 +204,7 @@ export class Auth
201204
case Persistence.NONE:
202205
return impl.inMemoryPersistence;
203206
default:
204-
return impl.fail(impl.AuthErrorCode.ARGUMENT_ERROR, {
207+
return impl._fail(impl.AuthErrorCode.ARGUMENT_ERROR, {
205208
appName: auth.name
206209
});
207210
}
@@ -266,10 +269,10 @@ export class Auth
266269
async signInWithPopup(
267270
provider: compat.AuthProvider
268271
): Promise<compat.UserCredential> {
269-
impl.assertFn(
272+
_assert(
270273
_isPopupRedirectSupported(),
274+
this.auth,
271275
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
272-
{ appName: this.app.name }
273276
);
274277
return convertCredential(
275278
this.auth,
@@ -281,11 +284,10 @@ export class Auth
281284
);
282285
}
283286
async signInWithRedirect(provider: compat.AuthProvider): Promise<void> {
284-
impl.assertFn(
287+
_assert(
285288
_isPopupRedirectSupported(),
286-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
287-
{ appName: this.app.name }
288-
);
289+
this.auth,
290+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED);
289291
this.savePersistenceForRedirect();
290292
return impl.signInWithRedirect(
291293
this.auth,

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { assertFn, AuthErrorCode } from '@firebase/auth-exp/internal';
18+
import { _assert, AuthErrorCode } from '@firebase/auth-exp/internal';
1919
import * as externs from '@firebase/auth-types-exp';
2020
import { isIndexedDBAvailable, isNode, isReactNative } from '@firebase/util';
2121
import { _isWebStorageSupported, _isWorker } from './platform';
@@ -34,45 +34,45 @@ export function _validatePersistenceArgument(
3434
auth: externs.Auth,
3535
persistence: string
3636
): void {
37-
assertFn(
37+
_assert(
3838
Object.values(Persistence).includes(persistence),
39+
auth,
3940
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.
45-
assertFn(
45+
_assert(
4646
persistence !== Persistence.SESSION,
47+
auth,
4748
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
48-
{ appName: auth.name }
4949
);
5050
return;
5151
}
5252
if (isNode()) {
5353
// Only none is supported in Node.js.
54-
assertFn(
54+
_assert(
5555
persistence === Persistence.NONE,
56+
auth,
5657
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
57-
{ appName: auth.name }
5858
);
5959
return;
6060
}
6161
if (_isWorker()) {
6262
// In a worker environment, either LOCAL or NONE are supported.
6363
// If indexedDB not supported and LOCAL provided, throw an error
64-
assertFn(
64+
_assert(
6565
persistence === Persistence.NONE ||
6666
(persistence === Persistence.LOCAL && isIndexedDBAvailable()),
67+
auth,
6768
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
68-
{ appName: auth.name }
6969
);
7070
return;
7171
}
7272
// This is restricted by what the browser supports.
73-
assertFn(
73+
_assert(
7474
persistence === Persistence.NONE || _isWebStorageSupported(),
75+
auth,
7576
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
76-
{ appName: auth.name }
7777
);
7878
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import * as compat from '@firebase/auth-types';
2222
import * as externs from '@firebase/auth-types-exp';
2323
import { unwrap, Wrapper } from './wrap';
2424

25+
const _assert: typeof impl._assert = impl._assert;
26+
2527
export class RecaptchaVerifier
2628
implements compat.RecaptchaVerifier, Wrapper<externs.ApplicationVerifier> {
2729
readonly verifier: externs.RecaptchaVerifier;
@@ -32,7 +34,7 @@ export class RecaptchaVerifier
3234
app: FirebaseApp = firebase.app()
3335
) {
3436
// API key is required for web client RPC calls.
35-
impl.assertFn(app.options?.apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
37+
_assert(app.options?.apiKey, impl.AuthErrorCode.INVALID_API_KEY, {
3638
appName: app.name
3739
});
3840
this.verifier = new impl.RecaptchaVerifier(

0 commit comments

Comments
 (0)