Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
avolkovi committed May 27, 2020
1 parent 2daba6b commit a050969
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 64 deletions.
7 changes: 3 additions & 4 deletions packages-exp/auth-exp/src/core/strategies/credential.test.ts
Expand Up @@ -15,18 +15,17 @@
* limitations under the License.
*/

import { ProviderId, SignInMethod } from '@firebase/auth-types-exp';
import { OperationType, ProviderId, SignInMethod } from '@firebase/auth-types-exp';
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { mockEndpoint } from '../../../test/api/helper';
import { mockAuth } from '../../../test/mock_auth';
import { MockAuthCredential } from '../../../test/mock_auth_credential';
import * as mockFetch from '../../../test/mock_fetch';
import { Endpoint } from '../../api';
import { APIUserInfo } from '../../api/account_management/account';
import { IdTokenResponse } from '../../model/id_token';
import { signInWithCredential } from './credential';
import { mockEndpoint } from '../../../test/api/helper';
import { Endpoint } from '../../api';
import { OperationType } from '../../model/user_credential';

use(chaiAsPromised);

Expand Down
5 changes: 3 additions & 2 deletions packages-exp/auth-exp/src/core/strategies/credential.ts
Expand Up @@ -15,9 +15,10 @@
* limitations under the License.
*/

import { OperationType, UserCredential } from '@firebase/auth-types-exp';
import { Auth } from '../../model/auth';
import { AuthCredential } from '../../model/auth_credential';
import { OperationType, UserCredential } from '../../model/user_credential';
import { User } from '../../model/user';
import { UserCredentialImpl } from '../user/user_credential_impl';

export async function signInWithCredential(
Expand All @@ -32,6 +33,6 @@ export async function signInWithCredential(
OperationType.SIGN_IN,
response
);
await auth.updateCurrentUser(userCredential.user);
await auth.updateCurrentUser(userCredential.user as User);
return userCredential;
}
10 changes: 0 additions & 10 deletions packages-exp/auth-exp/src/core/user/id_token_result.test.ts
Expand Up @@ -62,16 +62,6 @@ describe('/core/user/id_token_result', () => {
const encodedStr = makeJWT(token);
setup(encodedStr);
const result = await getIdTokenResult(user);
console.log(JSON.stringify(result));
console.log(JSON.stringify({
claims: token,
token: encodedStr,
issuedAtTime: MAY_1.toUTCString(),
authTime: MAY_2.toUTCString(),
expirationTime: MAY_3.toUTCString(),
signInProvider: null,
signInSecondFactor: null
}));
expect(result).to.eql({
claims: token,
token: encodedStr,
Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ProviderId, SignInMethod } from '@firebase/auth-types-exp';
import { OperationType, ProviderId, SignInMethod } from '@firebase/auth-types-exp';
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as sinon from 'sinon';
Expand All @@ -28,7 +28,6 @@ import { Endpoint } from '../../api';
import { APIUserInfo } from '../../api/account_management/account';
import { AuthCredential } from '../../model/auth_credential';
import { IdTokenResponse } from '../../model/id_token';
import { OperationType } from '../../model/user_credential';
import { UserCredentialImpl } from './user_credential_impl';

use(chaiAsPromised);
Expand Down
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

import { OperationType, UserCredential } from '@firebase/auth-types-exp';
import { Auth } from '../../model/auth';
import { AuthCredential } from '../../model/auth_credential';
import { IdTokenResponse } from '../../model/id_token';
import { User } from '../../model/user';
import { OperationType, UserCredential } from '../../model/user_credential';
import { UserImpl } from './user_impl';

export class UserCredentialImpl implements UserCredential {
Expand Down
8 changes: 1 addition & 7 deletions packages-exp/auth-exp/src/model/auth_credential.d.ts
Expand Up @@ -28,10 +28,4 @@ export interface AuthCredential extends externs.AuthCredential {
_getIdTokenResponse(auth: Auth): Promise<PhoneOrOauthTokenResponse>;
_linkToIdToken(auth: Auth, idToken: string): Promise<IdTokenResponse>;
_matchIdTokenWithUid(auth: Auth, uid: string): Promise<IdTokenResponse>;
}

export interface OAuthCredential extends externs.AuthCredential {
readonly idToken?: string;
readonly accessToken?: string;
readonly secret?: string;
}
}
31 changes: 0 additions & 31 deletions packages-exp/auth-exp/src/model/user_credential.ts

This file was deleted.

26 changes: 19 additions & 7 deletions packages-exp/auth-types-exp/index.d.ts
Expand Up @@ -148,12 +148,12 @@ export interface ActionCodeURL {
}

type ActionCodeOperationType =
'PASSWORD_RESET'
| 'RECOVER_EMAIL'
| 'EMAIL_SIGNIN'
| 'VERIFY_EMAIL'
| 'VERIFY_AND_CHANGE_EMAIL'
| 'REVERT_SECOND_FACTOR_ADDITION'
'PASSWORD_RESET'
| 'RECOVER_EMAIL'
| 'EMAIL_SIGNIN'
| 'VERIFY_EMAIL'
| 'VERIFY_AND_CHANGE_EMAIL'
| 'REVERT_SECOND_FACTOR_ADDITION';

/**
* Supported providers
Expand Down Expand Up @@ -202,4 +202,16 @@ export class OAuthCredential implements AuthCredential {

toJSON(): object;
fromJSON(json: object | string): OAuthCredential | null;
}
}

export const enum OperationType {
LINK = 'link',
REAUTHENTICATE = 'reauthenticate',
SIGN_IN = 'signIn'
}

export interface UserCredential {
user: User;
credential: AuthCredential | null;
operationType: OperationType;
}

0 comments on commit a050969

Please sign in to comment.