Skip to content

Commit 16976a0

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 5beee59 commit 16976a0

File tree

9 files changed

+60
-68
lines changed

9 files changed

+60
-68
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { OperationType, ProviderId, SignInMethod } from '@firebase/auth-types-exp';
1819
import { expect } from 'chai';
1920
import { mockEndpoint } from '../../../test/api/helper';
20-
import { mockAuth } from "../../../test/mock_auth";
21+
import { mockAuth } from '../../../test/mock_auth';
2122
import * as mockFetch from '../../../test/mock_fetch';
2223
import { Endpoint } from '../../api';
23-
import { OperationType } from '../../model/user_credential';
24-
import { ProviderId, SignInMethod } from '../providers';
25-
import { signInAnonymously } from './anonymous';
2624
import { APIUserInfo } from '../../api/account_management/account';
25+
import { signInAnonymously } from './anonymous';
2726

2827
describe('core/strategies/anonymous', () => {
2928
const serverUser: APIUserInfo = {
30-
localId: 'local-id',
29+
localId: 'local-id'
3130
};
3231

3332
beforeEach(() => {
@@ -46,20 +45,18 @@ describe('core/strategies/anonymous', () => {
4645

4746
describe('signInAnonymously', () => {
4847
it('should sign in an anonymous user', async () => {
49-
const { credential, user, operationType } = await signInAnonymously(mockAuth);
48+
const { credential, user, operationType } = await signInAnonymously(
49+
mockAuth
50+
);
5051
expect(credential?.providerId).to.eq(ProviderId.ANONYMOUS);
5152
expect(credential?.signInMethod).to.eq(SignInMethod.ANONYMOUS);
5253
expect(operationType).to.eq(OperationType.SIGN_IN);
5354
expect(user.uid).to.eq(serverUser.localId);
5455
expect(user.isAnonymous).to.be.true;
5556
});
5657

57-
context('already signed in anonymousl', () => {
58-
59-
});
60-
61-
context('already signed in with a non-anonymous account', () => {
58+
context('already signed in anonymousl', () => {});
6259

63-
});
60+
context('already signed in with a non-anonymous account', () => {});
6461
});
65-
});
62+
});

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Auth } from '../../model/auth';
19-
import { OperationType, UserCredential } from '../../model/user_credential';
20-
import { AnonymousProvider } from '../providers/anonymous';
18+
import * as externs from '@firebase/auth-types-exp';
19+
import { AnonymousProvider } from '../../../test/anonymous';
2120
import { UserCredentialImpl } from '../user/user_credential_impl';
2221
import { signInWithCredential } from './credential';
23-
export async function signInAnonymously(auth: Auth): Promise<UserCredential> {
22+
import { Auth } from '../../model/auth';
23+
24+
export async function signInAnonymously(externAuth: externs.Auth): Promise<externs.UserCredential> {
25+
const auth = externAuth as Auth;
2426
const credential = AnonymousProvider.credential();
2527
if (auth.currentUser?.isAnonymous) {
2628
// If an anonymous user is already signed in, no need to sign them in again.
2729
return new UserCredentialImpl(
2830
auth.currentUser,
2931
credential,
30-
OperationType.SIGN_IN
32+
externs.OperationType.SIGN_IN
3133
);
3234
}
3335
return signInWithCredential(auth, credential);
34-
}
36+
}

packages-exp/auth-exp/src/core/user/reload.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { UserInfo, ProviderId } from '@firebase/auth-types-exp';
2424

2525
import { mockEndpoint } from '../../../test/api/helper';
2626
import { testUser } from '../../../test/mock_auth';
27-
import * as mockFetch from '../../../test/mock_fetch';
27+
import * as fetch from '../../../test/mock_fetch';
2828
import { Endpoint } from '../../api';
2929
import {
3030
APIUserInfo,
@@ -54,8 +54,8 @@ const BASIC_PROVIDER_USER_INFO: ProviderUserInfo = {
5454
};
5555

5656
describe('core/user/reload', () => {
57-
beforeEach(mockFetch.setUp);
58-
afterEach(mockFetch.tearDown);
57+
beforeEach(fetch.setUp);
58+
afterEach(fetch.tearDown);
5959

6060
it('sets all the new properties', async () => {
6161
const serverUser: APIUserInfo = {

packages-exp/auth-exp/src/core/user/user_impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export class UserImpl implements User {
5959
tenantId = null;
6060
metadata = {};
6161
providerData = [];
62-
isAnonymous = false;
6362

6463
// Optional fields from UserInfo
6564
displayName: string | null;

packages-exp/auth-exp/src/model/user.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export interface User extends externs.User {
3434
tenantId: string | null;
3535
providerData: externs.UserInfo[];
3636
metadata: externs.UserMetadata;
37-
isAnonymous: boolean;
3837

3938
getIdToken(forceRefresh?: boolean): Promise<string>;
4039
getIdTokenResult(forceRefresh?: boolean): Promise<externs.IdTokenResult>;

packages-exp/auth-exp/test/anonymous.test.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { ProviderId, SignInMethod } from '@firebase/auth-types-exp';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { ProviderId, SignInMethod } from '.';
21-
import { mockAuth } from '../../../test/mock_auth';
22-
import { AnonymousCredential, AnonymousProvider } from "./anonymous";
21+
import { AnonymousCredential, AnonymousProvider } from './anonymous';
22+
import { mockAuth } from './mock_auth';
2323

2424
use(chaiAsPromised);
2525

2626
describe('core/providers/anonymous', () => {
2727
describe('AnonymousCredential', () => {
2828
const credential = new AnonymousCredential();
29-
29+
3030
it('should have an anonymous provider', () => {
3131
expect(credential.providerId).to.eq(ProviderId.ANONYMOUS);
3232
});
@@ -38,25 +38,31 @@ describe('core/providers/anonymous', () => {
3838
describe('#toJSON', () => {
3939
it('throws', () => {
4040
expect(credential.toJSON).to.throw(Error);
41-
});
41+
});
4242
});
4343

4444
describe('#_getIdTokenResponse', () => {
4545
it('throws', async () => {
46-
await expect(credential._getIdTokenResponse(mockAuth)).to.be.rejectedWith(Error);
47-
});
46+
await expect(
47+
credential._getIdTokenResponse(mockAuth)
48+
).to.be.rejectedWith(Error);
49+
});
4850
});
4951

5052
describe('#_linkToIdToken', () => {
5153
it('throws', async () => {
52-
await expect(credential._linkToIdToken(mockAuth,'id-token')).to.be.rejectedWith(Error);
53-
});
54+
await expect(
55+
credential._linkToIdToken(mockAuth, 'id-token')
56+
).to.be.rejectedWith(Error);
57+
});
5458
});
5559

5660
describe('#_matchIdTokenWithUid', () => {
5761
it('throws', () => {
58-
expect(() => credential._matchIdTokenWithUid(mockAuth, 'other-uid')).to.throw(Error);
59-
});
62+
expect(() =>
63+
credential._matchIdTokenWithUid(mockAuth, 'other-uid')
64+
).to.throw(Error);
65+
});
6066
});
6167
});
6268

@@ -69,4 +75,4 @@ describe('core/providers/anonymous', () => {
6975
});
7076
});
7177
});
72-
});
78+
});

packages-exp/auth-exp/test/anonymous.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { AuthProvider, ProviderId, SignInMethod } from '.';
19-
import { signUp } from '../../api/authentication/sign_up';
20-
import { Auth } from '../../model/auth';
21-
import { AuthCredential } from '../../model/auth_credential';
22-
import { IdTokenResponse } from '../../model/id_token';
23-
import { debugFail } from '../util/assert';
18+
import { AuthCredential, ProviderId, SignInMethod, AuthProvider } from "@firebase/auth-types-exp";
19+
import { signUp } from '../src/api/authentication/sign_up';
20+
import { debugFail } from '../src/core/util/assert';
21+
import { Auth } from '../src/model/auth';
22+
import { IdTokenResponse } from "../src/model/id_token";
2423

2524
export class AnonymousCredential implements AuthCredential {
2625
providerId = ProviderId.ANONYMOUS;
2726
signInMethod = SignInMethod.ANONYMOUS;
28-
27+
2928
toJSON(): never {
3029
debugFail('Method not implemented.');
3130
}
32-
31+
32+
fromJSON(): never {
33+
debugFail('Method not implemented');
34+
}
35+
3336
async _getIdTokenResponse(auth: Auth): Promise<IdTokenResponse> {
3437
return signUp(auth, {
3538
returnSecureToken: true
3639
});
3740
}
38-
41+
3942
async _linkToIdToken(_auth: Auth, _idToken: string): Promise<never> {
4043
debugFail("Can't link to an anonymous credential");
4144
}
@@ -47,8 +50,8 @@ export class AnonymousCredential implements AuthCredential {
4750

4851
export class AnonymousProvider implements AuthProvider {
4952
providerId = ProviderId.ANONYMOUS;
50-
53+
5154
static credential(): AnonymousCredential {
5255
return new AnonymousCredential();
5356
}
54-
}
57+
}

packages-exp/auth-exp/test/jwt.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,3 @@ export function makeJWT(claims: object): string {
2121
const payload = base64Encode(JSON.stringify(claims));
2222
return `algorithm.${payload}.signature`;
2323
}
24-
25-
/**
26-
* Supported sign in methods
27-
*/
28-
export enum SignInMethod {
29-
ANONYMOUS = 'anonymous',
30-
EMAIL_LINK = 'emailLink',
31-
EMAIL_PASSWORD = 'password',
32-
FACEBOOK = 'facebook.com',
33-
GITHUB = 'github.com',
34-
GOOGLE = 'google.com',
35-
PHONE = 'phone',
36-
TWITTER = 'twitter.com'
37-
}
38-
39-
/**
40-
* A provider for generating credentials
41-
*/
42-
export interface AuthProvider {
43-
readonly providerId: ProviderId;
44-
}

packages-exp/auth-types-exp/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,10 @@ export interface UserCredential {
215215
credential: AuthCredential | null;
216216
operationType: OperationType;
217217
}
218+
219+
/**
220+
* A provider for generating credentials
221+
*/
222+
export interface AuthProvider {
223+
readonly providerId: ProviderId;
224+
}

0 commit comments

Comments
 (0)