Skip to content

Commit 129e65f

Browse files
committed
Formatting, License
1 parent d692c45 commit 129e65f

File tree

7 files changed

+66
-18
lines changed

7 files changed

+66
-18
lines changed

packages-exp/auth-exp/src/core/strategies/redirect.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ describe('core/strategies/redirect', () => {
198198

199199
it('bypasses initialization if no key set', async () => {
200200
await reInitAuthWithRedirectUser(MATCHING_EVENT_ID);
201-
const resolverInstance = _getInstance<PopupRedirectResolverInternal>(resolver);
201+
const resolverInstance = _getInstance<PopupRedirectResolverInternal>(
202+
resolver
203+
);
202204

203205
sinon.spy(resolverInstance, '_initialize');
204206
redirectPersistence.hasPendingRedirect = false;
205-
207+
206208
expect(await redirectAction.execute()).to.eq(null);
207209
expect(await redirectAction.execute()).to.eq(null);
208210
expect(resolverInstance._initialize).not.to.have.been.called;

packages-exp/auth-exp/src/core/strategies/redirect.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ export class RedirectAction extends AbstractPopupRedirectOperation {
6666
let readyOutcome = redirectOutcomeMap.get(this.auth._key());
6767
if (!readyOutcome) {
6868
try {
69-
const hasPendingRedirect = await _getAndClearPendingRedirectStatus(this.resolver, this.auth);
69+
const hasPendingRedirect = await _getAndClearPendingRedirectStatus(
70+
this.resolver,
71+
this.auth
72+
);
7073
const result = hasPendingRedirect ? await super.execute() : null;
7174
readyOutcome = () => Promise.resolve(result);
7275
} catch (e) {
@@ -104,25 +107,38 @@ export class RedirectAction extends AbstractPopupRedirectOperation {
104107
cleanUp(): void {}
105108
}
106109

107-
export async function _getAndClearPendingRedirectStatus(resolver: PopupRedirectResolverInternal, auth: AuthInternal): Promise<boolean> {
110+
export async function _getAndClearPendingRedirectStatus(
111+
resolver: PopupRedirectResolverInternal,
112+
auth: AuthInternal
113+
): Promise<boolean> {
108114
const key = pendingRedirectKey(auth);
109-
const hasPendingRedirect = await resolverPersistence(resolver)._get(key) === 'true';
115+
const hasPendingRedirect =
116+
(await resolverPersistence(resolver)._get(key)) === 'true';
110117
await resolverPersistence(resolver)._remove(key);
111118
return hasPendingRedirect;
112119
}
113120

114-
export async function _setPendingRedirectStatus(resolver: PopupRedirectResolverInternal, auth: AuthInternal): Promise<void> {
121+
export async function _setPendingRedirectStatus(
122+
resolver: PopupRedirectResolverInternal,
123+
auth: AuthInternal
124+
): Promise<void> {
115125
return resolverPersistence(resolver)._set(pendingRedirectKey(auth), 'true');
116126
}
117127

118128
export function _clearRedirectOutcomes(): void {
119129
redirectOutcomeMap.clear();
120130
}
121131

122-
function resolverPersistence(resolver: PopupRedirectResolverInternal): PersistenceInternal {
132+
function resolverPersistence(
133+
resolver: PopupRedirectResolverInternal
134+
): PersistenceInternal {
123135
return _getInstance(resolver._redirectPersistence);
124136
}
125137

126138
function pendingRedirectKey(auth: AuthInternal): string {
127-
return _persistenceKeyName(PENDING_REDIRECT_KEY, auth.config.apiKey, auth.name);
128-
}
139+
return _persistenceKeyName(
140+
PENDING_REDIRECT_KEY,
141+
auth.config.apiKey,
142+
auth.name
143+
);
144+
}

packages-exp/auth-exp/src/platform_browser/auth.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ describe('core/auth/initializeAuth', () => {
194194

195195
it('does not early-initialize the resolver', async () => {
196196
const popupRedirectResolver = makeMockPopupRedirectResolver();
197-
const resolverInternal: PopupRedirectResolverInternal = _getInstance(popupRedirectResolver);
197+
const resolverInternal: PopupRedirectResolverInternal = _getInstance(
198+
popupRedirectResolver
199+
);
198200
sinon.stub(resolverInternal, '_shouldInitProactively').value(false);
199201
sinon.spy(resolverInternal, '_initialize');
200202
await initAndWait(inMemoryPersistence, popupRedirectResolver);
@@ -203,7 +205,9 @@ describe('core/auth/initializeAuth', () => {
203205

204206
it('does early-initialize the resolver', async () => {
205207
const popupRedirectResolver = makeMockPopupRedirectResolver();
206-
const resolverInternal: PopupRedirectResolverInternal = _getInstance(popupRedirectResolver);
208+
const resolverInternal: PopupRedirectResolverInternal = _getInstance(
209+
popupRedirectResolver
210+
);
207211
sinon.stub(resolverInternal, '_shouldInitProactively').value(true);
208212
sinon.spy(resolverInternal, '_initialize');
209213
await initAndWait(inMemoryPersistence, popupRedirectResolver);

packages-exp/auth-exp/src/platform_browser/strategies/redirect.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ describe('platform_browser/strategies/redirect', () => {
8383
)._redirectPersistence = RedirectPersistence;
8484
auth = await testAuth(resolver);
8585
idpStubs = sinon.stub(idpTasks);
86-
_getInstance<RedirectPersistence>(RedirectPersistence).hasPendingRedirect = true;
86+
_getInstance<RedirectPersistence>(
87+
RedirectPersistence
88+
).hasPendingRedirect = true;
8789
});
8890

8991
afterEach(() => {
@@ -425,7 +427,9 @@ describe('platform_browser/strategies/redirect', () => {
425427
type: AuthEventType.LINK_VIA_REDIRECT
426428
});
427429
expect(await promise).to.eq(cred);
428-
expect(redirectPersistence._remove).to.have.been.calledWith('firebase:redirectUser:test-api-key:test-app');
430+
expect(redirectPersistence._remove).to.have.been.calledWith(
431+
'firebase:redirectUser:test-api-key:test-app'
432+
);
429433
expect(auth._currentUser?._redirectEventId).to.be.undefined;
430434
expect(auth.persistenceLayer.lastObjectSet?._redirectEventId).to.be
431435
.undefined;
@@ -449,7 +453,9 @@ describe('platform_browser/strategies/redirect', () => {
449453
type: AuthEventType.LINK_VIA_REDIRECT
450454
});
451455
expect(await promise).to.eq(cred);
452-
expect(redirectPersistence._remove).not.to.have.been.calledWith('firebase:redirectUser:test-api-key:test-app');
456+
expect(redirectPersistence._remove).not.to.have.been.calledWith(
457+
'firebase:redirectUser:test-api-key:test-app'
458+
);
453459
expect(auth._currentUser?._redirectEventId).not.to.be.undefined;
454460
expect(auth.persistenceLayer.lastObjectSet?._redirectEventId).not.to.be
455461
.undefined;

packages-exp/auth-exp/src/platform_browser/strategies/redirect.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ import { _generateEventId } from '../../core/util/event_id';
3232
import { AuthEventType } from '../../model/popup_redirect';
3333
import { UserInternal } from '../../model/user';
3434
import { _withDefaultResolver } from '../../core/util/resolver';
35-
import { RedirectAction, _setPendingRedirectStatus } from '../../core/strategies/redirect';
35+
import {
36+
RedirectAction,
37+
_setPendingRedirectStatus
38+
} from '../../core/strategies/redirect';
3639

3740
/**
3841
* Authenticates a Firebase client using a full-page redirect flow.

packages-exp/auth-exp/src/platform_cordova/popup_redirect/popup_redirect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const INITIAL_EVENT_TIMEOUT_MS = 500;
5252

5353
class CordovaPopupRedirectResolver implements PopupRedirectResolverInternal {
5454
readonly _redirectPersistence = browserSessionPersistence;
55-
readonly _shouldInitProactively = true; // This is lightweight for Cordova
55+
readonly _shouldInitProactively = true; // This is lightweight for Cordova
5656
private readonly eventManagers = new Map<string, CordovaAuthEventManager>();
5757

5858
_completeRedirectFn = _getRedirectResult;

packages-exp/auth-exp/test/helpers/redirect_persistence.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
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+
*/
17+
118
import { PersistenceValue } from '../../src/core/persistence';
219
import { InMemoryPersistence } from '../../src/core/persistence/in_memory';
320

421
/** Helper class for handling redirect persistence */
522
export class RedirectPersistence extends InMemoryPersistence {
623
hasPendingRedirect = false;
7-
redirectUser: object|null = null;
24+
redirectUser: object | null = null;
825

9-
async _get<T extends PersistenceValue>(key: string): Promise<T|null> {
26+
async _get<T extends PersistenceValue>(key: string): Promise<T | null> {
1027
if (key.includes('pendingRedirect')) {
1128
return this.hasPendingRedirect.toString() as T;
1229
}

0 commit comments

Comments
 (0)