Skip to content

Commit e05a20c

Browse files
sam-gcscottcrossen
andauthored
Fix broken build (#3275)
* Fix some stuff * Formatting * fixed scott's broken test cases. Stupid scott Co-authored-by: Scott Crossen <[email protected]>
1 parent 05bd92d commit e05a20c

File tree

10 files changed

+44
-47
lines changed

10 files changed

+44
-47
lines changed

packages-exp/auth-exp/src/core/credentials/phone.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { testAuth } from '../../../test/mock_auth';
2222
import * as fetch from '../../../test/mock_fetch';
2323
import { Endpoint } from '../../api';
2424
import { Auth } from '../../model/auth';
25-
import { IdTokenResponse } from '../../model/id_token';
25+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
2626
import { PhoneAuthCredential } from '../credentials/phone';
2727

2828
describe('core/credentials/phone', () => {
@@ -41,7 +41,7 @@ describe('core/credentials/phone', () => {
4141
const response: IdTokenResponse = {
4242
idToken: '',
4343
refreshToken: '',
44-
kind: '',
44+
kind: IdTokenResponseKind.CreateAuthUri,
4545
expiresIn: '10',
4646
localId: ''
4747
};
@@ -81,7 +81,7 @@ describe('core/credentials/phone', () => {
8181
const response: IdTokenResponse = {
8282
idToken: '',
8383
refreshToken: '',
84-
kind: '',
84+
kind: IdTokenResponseKind.CreateAuthUri,
8585
expiresIn: '10',
8686
localId: 'uid'
8787
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as mockFetch from '../../../test/mock_fetch';
3333
import { Endpoint } from '../../api';
3434
import { APIUserInfo } from '../../api/account_management/account';
3535
import { Auth } from '../../model/auth';
36-
import { IdTokenResponse } from '../../model/id_token';
36+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
3737
import { User } from '../../model/user';
3838
import {
3939
linkWithCredential,
@@ -61,7 +61,7 @@ describe('core/strategies/credential', () => {
6161
refreshToken: 'my-refresh-token',
6262
expiresIn: '1234',
6363
localId: serverUser.localId!,
64-
kind: 'my-kind'
64+
kind: IdTokenResponseKind.CreateAuthUri
6565
};
6666

6767
const authCredential = new MockAuthCredential(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as mockFetch from '../../../test/mock_fetch';
2626
import { Endpoint } from '../../api';
2727
import { APIUserInfo } from '../../api/account_management/account';
2828
import { Auth } from '../../model/auth';
29-
import { IdTokenResponse } from '../../model/id_token';
29+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
3030
import { signInWithCustomToken } from './custom_token';
3131

3232
use(chaiAsPromised);
@@ -49,7 +49,7 @@ describe('core/strategies/signInWithCustomToken', () => {
4949
refreshToken: 'my-refresh-token',
5050
expiresIn: '1234',
5151
localId: serverUser.localId!,
52-
kind: 'my-kind'
52+
kind: IdTokenResponseKind.CreateAuthUri
5353
};
5454

5555
let auth: Auth;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import * as fetch from '../../../test/mock_fetch';
3030
import { Endpoint } from '../../api';
3131
import { ApplicationVerifier } from '../../model/application_verifier';
3232
import { Auth } from '../../model/auth';
33-
import { IdTokenResponse } from '../../model/id_token';
33+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
3434
import { User } from '../../model/user';
3535
import { RecaptchaVerifier } from '../../platform_browser/recaptcha/recaptcha_verifier';
3636
import {
@@ -87,7 +87,7 @@ describe('core/strategies/phone', () => {
8787
refreshToken: 'my-refresh-token',
8888
expiresIn: '1234',
8989
localId: 'uid',
90-
kind: 'my-kind'
90+
kind: IdTokenResponseKind.CreateAuthUri
9191
};
9292

9393
// This endpoint is called from within the callback, in
@@ -163,7 +163,7 @@ describe('core/strategies/phone', () => {
163163
refreshToken: 'my-refresh-token',
164164
expiresIn: '1234',
165165
localId: 'uid',
166-
kind: 'my-kind'
166+
kind: IdTokenResponseKind.CreateAuthUri
167167
};
168168

169169
// This endpoint is called from within the callback, in
@@ -227,7 +227,7 @@ describe('core/strategies/phone', () => {
227227
refreshToken: 'my-refresh-token',
228228
expiresIn: '1234',
229229
localId: 'uid',
230-
kind: 'my-kind'
230+
kind: IdTokenResponseKind.CreateAuthUri
231231
};
232232

233233
// This endpoint is called from within the callback, in
@@ -261,7 +261,7 @@ describe('core/strategies/phone', () => {
261261
refreshToken: 'my-refresh-token',
262262
expiresIn: '1234',
263263
localId: 'uid',
264-
kind: 'my-kind'
264+
kind: IdTokenResponseKind.CreateAuthUri
265265
};
266266
// This endpoint is called from within the callback, in
267267
// signInWithCredential

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google Inc.
3+
* Copyright 2019 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,12 +16,12 @@
1616
*/
1717

1818
import { expect } from 'chai';
19-
import { _fromIdTokenResponse } from './additional_user_info';
19+
20+
import { ProviderId, UserProfile } from '@firebase/auth-types-exp';
21+
2022
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
21-
import {
22-
UserProfile,
23-
ProviderId
24-
} from '@firebase/auth-types-exp';
23+
import { _fromIdTokenResponse } from './additional_user_info';
24+
import { base64Encode } from '@firebase/util';
2525

2626
describe('core/user/additional_user_info', () => {
2727
describe('_fromIdTokenResponse', () => {
@@ -48,8 +48,8 @@ describe('core/user/additional_user_info', () => {
4848
} = _fromIdTokenResponse(idResponse)!;
4949
expect(isNewUser).to.be.false;
5050
expect(providerId).to.eq(ProviderId.FACEBOOK);
51-
expect(username).to.be.null;
52-
expect(profile).to.eq(userProfileWithLogin);
51+
expect(username).to.be.undefined;
52+
expect(profile).to.eql(userProfileWithLogin);
5353
});
5454

5555
it('for GithubAdditionalUserInfo', () => {
@@ -66,7 +66,7 @@ describe('core/user/additional_user_info', () => {
6666
expect(isNewUser).to.be.false;
6767
expect(providerId).to.eq(ProviderId.GITHUB);
6868
expect(username).to.eq('scott');
69-
expect(profile).to.eq(userProfileWithLogin);
69+
expect(profile).to.eql(userProfileWithLogin);
7070
});
7171

7272
it('for GoogleAdditionalUserInfo', () => {
@@ -82,8 +82,8 @@ describe('core/user/additional_user_info', () => {
8282
} = _fromIdTokenResponse(idResponse)!;
8383
expect(isNewUser).to.be.false;
8484
expect(providerId).to.eq(ProviderId.GOOGLE);
85-
expect(username).to.be.null;
86-
expect(profile).to.eq(userProfileWithLogin);
85+
expect(username).to.be.undefined;
86+
expect(profile).to.eql(userProfileWithLogin);
8787
});
8888

8989
it('for TwitterAdditionalUserInfo', () => {
@@ -159,7 +159,7 @@ describe('core/user/additional_user_info', () => {
159159
} = _fromIdTokenResponse(idResponse)!;
160160
expect(isNewUser).to.be.false;
161161
expect(providerId).to.be.null;
162-
expect(username).to.be.null;
162+
expect(username).to.be.undefined;
163163
expect(profile).to.eq(profile);
164164
});
165165

@@ -176,22 +176,23 @@ describe('core/user/additional_user_info', () => {
176176
} = _fromIdTokenResponse(idResponse)!;
177177
expect(isNewUser).to.be.false;
178178
expect(providerId).to.be.null;
179-
expect(username).to.be.null;
179+
expect(username).to.be.undefined;
180180
expect(profile).to.eq(profile);
181181
});
182182

183183
it('for missing provider IDs in response but not in token', () => {
184+
const idToken = 'algorithm.' + base64Encode(JSON.stringify({'firebase': {'sign_in_provider': 'facebook.com'}})) + '.signature';
184185
const {
185186
isNewUser,
186187
providerId,
187188
username,
188189
profile
189190
} = _fromIdTokenResponse(
190-
idTokenResponse({ rawUserInfo: rawUserInfoWithLogin })
191+
idTokenResponse({ rawUserInfo: rawUserInfoWithLogin , idToken})
191192
)!;
192193
expect(isNewUser).to.be.false;
193194
expect(providerId).to.eq(ProviderId.FACEBOOK);
194-
expect(username).to.be.null;
195+
expect(username).to.be.undefined;
195196
expect(profile).to.eq(profile);
196197
});
197198
});
@@ -208,9 +209,9 @@ describe('core/user/additional_user_info', () => {
208209
function idTokenResponse(partial: Partial<IdTokenResponse>): IdTokenResponse {
209210
return {
210211
idToken: 'id-token',
211-
refreshToken: "refresh-token",
212-
expiresIn: "expires-in",
213-
localId: "local-id",
212+
refreshToken: 'refresh-token',
213+
expiresIn: 'expires-in',
214+
localId: 'local-id',
214215
kind: IdTokenResponseKind.CreateAuthUri,
215216
...partial
216217
};

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google Inc.
3+
* Copyright 2019 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import { _parseToken } from './id_token_result';
2626
* Parse the `AdditionalUserInfo` from the ID token response.
2727
*/
2828
export function _fromIdTokenResponse(
29-
idTokenResponse: IdTokenResponse,
29+
idTokenResponse: IdTokenResponse
3030
): AdditionalUserInfo | null {
3131
const { providerId } = idTokenResponse;
3232
const profile = idTokenResponse.rawUserInfo
@@ -68,26 +68,22 @@ export function _fromIdTokenResponse(
6868
case ProviderId.ANONYMOUS:
6969
return new GenericAdditionalUserInfo(isNewUser, null);
7070
default:
71-
return new FederatedAdditionalUserInfo(
72-
isNewUser,
73-
providerId,
74-
profile
75-
);
71+
return new FederatedAdditionalUserInfo(isNewUser, providerId, profile);
7672
}
7773
}
7874

7975
class GenericAdditionalUserInfo implements AdditionalUserInfo {
8076
constructor(
8177
readonly isNewUser: boolean,
82-
readonly providerId: ProviderId | null,
78+
readonly providerId: ProviderId | null
8379
) {}
8480
}
8581

8682
class FederatedAdditionalUserInfo extends GenericAdditionalUserInfo {
8783
constructor(
8884
isNewUser: boolean,
8985
providerId: ProviderId,
90-
readonly profile: UserProfile,
86+
readonly profile: UserProfile
9187
) {
9288
super(isNewUser, providerId);
9389
}
@@ -98,7 +94,7 @@ class FederatedAdditionalUserInfoWithUsername extends FederatedAdditionalUserInf
9894
isNewUser: boolean,
9995
providerId: ProviderId,
10096
profile: UserProfile,
101-
readonly username: string | null,
97+
readonly username: string | null
10298
) {
10399
super(isNewUser, providerId, profile);
104100
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { MockAuthCredential } from '../../../test/mock_auth_credential';
3333
import * as mockFetch from '../../../test/mock_fetch';
3434
import { Endpoint } from '../../api';
3535
import { APIUserInfo } from '../../api/account_management/account';
36-
import { IdTokenResponse } from '../../model/id_token';
36+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
3737
import { User } from '../../model/user';
3838
import { AuthCredential } from '../credentials';
3939
import { UserCredentialImpl } from './user_credential_impl';
@@ -71,7 +71,7 @@ describe('core/user/user_credential_impl', () => {
7171
refreshToken: 'my-refresh-token',
7272
expiresIn: '1234',
7373
localId: serverUser.localId!,
74-
kind: 'my-kind'
74+
kind: IdTokenResponseKind.CreateAuthUri
7575
};
7676

7777
const credential: AuthCredential = new MockAuthCredential(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import * as fetch from '../../../test/mock_fetch';
2929
import { Endpoint } from '../../api';
3030
import { APIUserInfo } from '../../api/account_management/account';
3131
import { Auth } from '../../model/auth';
32-
import { IdTokenResponse } from '../../model/id_token';
32+
import { IdTokenResponse, IdTokenResponseKind } from '../../model/id_token';
3333
import { StsTokenManager } from './token_manager';
3434
import { UserImpl } from './user_impl';
3535

@@ -197,7 +197,7 @@ describe('core/user/user_impl', () => {
197197
refreshToken: 'my-refresh-token',
198198
expiresIn: '1234',
199199
localId: 'local-id',
200-
kind: 'my-kind'
200+
kind: IdTokenResponseKind.CreateAuthUri
201201
};
202202

203203
const serverUser: APIUserInfo = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface IdTokenResponse {
6868
/**
6969
* The possible types of the `IdTokenResponse`
7070
*/
71-
export enum IdTokenResponseKind {
71+
export const enum IdTokenResponseKind {
7272
CreateAuthUri = 'identitytoolkit#CreateAuthUriResponse',
7373
DeleteAccount = 'identitytoolkit#DeleteAccountResponse',
7474
DownloadAccount = 'identitytoolkit#DownloadAccountResponse',

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

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

18-
import { IdTokenResponse } from '../src/model/id_token';
18+
import { IdTokenResponse, IdTokenResponseKind } from '../src/model/id_token';
1919
import { makeJWT } from './jwt';
2020

2121
export const TEST_ID_TOKEN_RESPONSE: IdTokenResponse = {
2222
idToken: makeJWT({}),
2323
refreshToken: 'refresh-token',
2424
expiresIn: '1000',
2525
localId: 'uid',
26-
kind: 'kind'
26+
kind: IdTokenResponseKind.CreateAuthUri
2727
};

0 commit comments

Comments
 (0)