Skip to content

Commit 66a08d2

Browse files
committed
Bunch of signature updates for auth
1 parent 03e9070 commit 66a08d2

26 files changed

+116
-137
lines changed

common/api-review/auth-exp.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ActionCodeURL implements externs.ActionCodeURL {
2828
// (undocumented)
2929
readonly languageCode: string | null;
3030
// (undocumented)
31-
readonly operation: externs.Operation;
31+
readonly operation: externs.ActionCodeOperation;
3232
// (undocumented)
3333
static parseLink(link: string): externs.ActionCodeURL | null;
3434
// (undocumented)
@@ -247,10 +247,10 @@ export class OAuthProvider implements externs.AuthProvider {
247247
constructor(providerId: string);
248248
// (undocumented)
249249
addScope(scope: string): externs.AuthProvider;
250-
// Warning: (ae-forgotten-export) The symbol "CredentialParameters" needs to be exported by the entry point index.d.ts
250+
// Warning: (ae-forgotten-export) The symbol "OAuthCredentialOptions" needs to be exported by the entry point index.d.ts
251251
//
252252
// (undocumented)
253-
credential(params: CredentialParameters): externs.OAuthCredential;
253+
credential(params: OAuthCredentialOptions): externs.OAuthCredential;
254254
// (undocumented)
255255
static credentialFromJSON(json: object | string): externs.OAuthCredential;
256256
// (undocumented)

packages-exp/auth-exp/src/api/account_management/email_and_password.ts

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

18-
import { Operation, Auth } from '@firebase/auth-types-exp';
18+
import { ActionCodeOperation, Auth } from '@firebase/auth-types-exp';
1919

2020
import { Endpoint, HttpMethod, _performApiRequest } from '../index';
2121
import { IdTokenResponse } from '../../model/id_token';
@@ -29,7 +29,7 @@ export interface ResetPasswordRequest {
2929
export interface ResetPasswordResponse {
3030
email: string;
3131
newEmail?: string;
32-
requestType?: Operation;
32+
requestType?: ActionCodeOperation;
3333
mfaInfo?: MfaEnrollment;
3434
}
3535

packages-exp/auth-exp/src/api/authentication/email_and_password.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { expect, use } from 'chai';
1919
import * as chaiAsPromised from 'chai-as-promised';
2020

21-
import { Operation } from '@firebase/auth-types-exp';
21+
import { ActionCodeOperation } from '@firebase/auth-types-exp';
2222
import { FirebaseError } from '@firebase/util';
2323

2424
import { Endpoint, HttpHeader } from '../';
@@ -102,7 +102,7 @@ describe('api/authentication/signInWithPassword', () => {
102102

103103
describe('api/authentication/sendEmailVerification', () => {
104104
const request: VerifyEmailRequest = {
105-
requestType: Operation.VERIFY_EMAIL,
105+
requestType: ActionCodeOperation.VERIFY_EMAIL,
106106
idToken: 'my-token'
107107
};
108108

@@ -159,7 +159,7 @@ describe('api/authentication/sendEmailVerification', () => {
159159

160160
describe('api/authentication/sendPasswordResetEmail', () => {
161161
const request: PasswordResetRequest = {
162-
requestType: Operation.PASSWORD_RESET,
162+
requestType: ActionCodeOperation.PASSWORD_RESET,
163163
164164
};
165165

@@ -216,7 +216,7 @@ describe('api/authentication/sendPasswordResetEmail', () => {
216216

217217
describe('api/authentication/sendSignInLinkToEmail', () => {
218218
const request: EmailSignInRequest = {
219-
requestType: Operation.EMAIL_SIGNIN,
219+
requestType: ActionCodeOperation.EMAIL_SIGNIN,
220220
221221
};
222222

@@ -273,7 +273,7 @@ describe('api/authentication/sendSignInLinkToEmail', () => {
273273

274274
describe('api/authentication/verifyAndChangeEmail', () => {
275275
const request: VerifyAndChangeEmailRequest = {
276-
requestType: Operation.VERIFY_AND_CHANGE_EMAIL,
276+
requestType: ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL,
277277
idToken: 'id-token',
278278
newEmail: '[email protected]'
279279
};

packages-exp/auth-exp/src/api/authentication/email_and_password.ts

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

18-
import { Operation, Auth } from '@firebase/auth-types-exp';
18+
import { ActionCodeOperation, Auth } from '@firebase/auth-types-exp';
1919

2020
import {
2121
Endpoint,
@@ -61,24 +61,24 @@ export interface GetOobCodeRequest {
6161
}
6262

6363
export interface VerifyEmailRequest extends GetOobCodeRequest {
64-
requestType: Operation.VERIFY_EMAIL;
64+
requestType: ActionCodeOperation.VERIFY_EMAIL;
6565
idToken: IdToken;
6666
}
6767

6868
export interface PasswordResetRequest extends GetOobCodeRequest {
69-
requestType: Operation.PASSWORD_RESET;
69+
requestType: ActionCodeOperation.PASSWORD_RESET;
7070
email: string;
7171
captchaResp?: string;
7272
userIp?: string;
7373
}
7474

7575
export interface EmailSignInRequest extends GetOobCodeRequest {
76-
requestType: Operation.EMAIL_SIGNIN;
76+
requestType: ActionCodeOperation.EMAIL_SIGNIN;
7777
email: string;
7878
}
7979

8080
export interface VerifyAndChangeEmailRequest extends GetOobCodeRequest {
81-
requestType: Operation.VERIFY_AND_CHANGE_EMAIL;
81+
requestType: ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL;
8282
idToken: IdToken;
8383
newEmail: string;
8484
}

packages-exp/auth-exp/src/core/action_code_url.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { expect } from 'chai';
1919

20-
import { Operation } from '@firebase/auth-types-exp';
20+
import { ActionCodeOperation } from '@firebase/auth-types-exp';
2121

2222
import { ActionCodeURL } from './action_code_url';
2323

@@ -32,7 +32,7 @@ describe('core/action_code_url', () => {
3232
encodeURIComponent(continueUrl) +
3333
'&languageCode=en&tenantId=TENANT_ID&state=bla';
3434
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
35-
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
35+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.EMAIL_SIGNIN);
3636
expect(actionCodeUrl!.code).to.eq('CODE');
3737
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
3838
// ContinueUrl should be decoded.
@@ -48,7 +48,7 @@ describe('core/action_code_url', () => {
4848
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
4949
'languageCode=en';
5050
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
51-
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
51+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.EMAIL_SIGNIN);
5252
});
5353

5454
it('should identitfy VERIFY_AND_CHANGE_EMAIL', () => {
@@ -58,7 +58,7 @@ describe('core/action_code_url', () => {
5858
'languageCode=en';
5959
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
6060
expect(actionCodeUrl!.operation).to.eq(
61-
Operation.VERIFY_AND_CHANGE_EMAIL
61+
ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL
6262
);
6363
});
6464

@@ -68,7 +68,7 @@ describe('core/action_code_url', () => {
6868
'oobCode=CODE&mode=verifyEmail&apiKey=API_KEY&' +
6969
'languageCode=en';
7070
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
71-
expect(actionCodeUrl!.operation).to.eq(Operation.VERIFY_EMAIL);
71+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.VERIFY_EMAIL);
7272
});
7373

7474
it('should identitfy RECOVER_EMAIL', () => {
@@ -77,7 +77,7 @@ describe('core/action_code_url', () => {
7777
'oobCode=CODE&mode=recoverEmail&apiKey=API_KEY&' +
7878
'languageCode=en';
7979
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
80-
expect(actionCodeUrl!.operation).to.eq(Operation.RECOVER_EMAIL);
80+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.RECOVER_EMAIL);
8181
});
8282

8383
it('should identitfy PASSWORD_RESET', () => {
@@ -86,7 +86,7 @@ describe('core/action_code_url', () => {
8686
'oobCode=CODE&mode=resetPassword&apiKey=API_KEY&' +
8787
'languageCode=en';
8888
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
89-
expect(actionCodeUrl!.operation).to.eq(Operation.PASSWORD_RESET);
89+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.PASSWORD_RESET);
9090
});
9191

9292
it('should identitfy REVERT_SECOND_FACTOR_ADDITION', () => {
@@ -96,7 +96,7 @@ describe('core/action_code_url', () => {
9696
'languageCode=en';
9797
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
9898
expect(actionCodeUrl!.operation).to.eq(
99-
Operation.REVERT_SECOND_FACTOR_ADDITION
99+
ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION
100100
);
101101
});
102102
});
@@ -106,7 +106,7 @@ describe('core/action_code_url', () => {
106106
'https://www.example.com:8080/finishSignIn?' +
107107
'oobCode=CODE&mode=signIn&apiKey=API_KEY&state=bla';
108108
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
109-
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
109+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.EMAIL_SIGNIN);
110110
expect(actionCodeUrl!.code).to.eq('CODE');
111111
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
112112
expect(actionCodeUrl!.continueUrl).to.be.null;
@@ -120,7 +120,7 @@ describe('core/action_code_url', () => {
120120
'oobCode=CODE1&mode=signIn&apiKey=API_KEY1&state=bla' +
121121
'#oobCode=CODE2&mode=signIn&apiKey=API_KEY2&state=bla';
122122
const actionCodeUrl = ActionCodeURL.parseLink(actionLink);
123-
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
123+
expect(actionCodeUrl!.operation).to.eq(ActionCodeOperation.EMAIL_SIGNIN);
124124
expect(actionCodeUrl!.code).to.eq('CODE1');
125125
expect(actionCodeUrl!.apiKey).to.eq('API_KEY1');
126126
expect(actionCodeUrl!.continueUrl).to.be.null;

packages-exp/auth-exp/src/core/action_code_url.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ enum QueryField {
3838
*
3939
* @internal
4040
*/
41-
const MODE_TO_OPERATION_MAP: { [key: string]: externs.Operation } = {
42-
'recoverEmail': externs.Operation.RECOVER_EMAIL,
43-
'resetPassword': externs.Operation.PASSWORD_RESET,
44-
'signIn': externs.Operation.EMAIL_SIGNIN,
45-
'verifyEmail': externs.Operation.VERIFY_EMAIL,
46-
'verifyAndChangeEmail': externs.Operation.VERIFY_AND_CHANGE_EMAIL,
47-
'revertSecondFactorAddition': externs.Operation.REVERT_SECOND_FACTOR_ADDITION
41+
const MODE_TO_OPERATION_MAP: { [key: string]: externs.ActionCodeOperation } = {
42+
'recoverEmail': externs.ActionCodeOperation.RECOVER_EMAIL,
43+
'resetPassword': externs.ActionCodeOperation.PASSWORD_RESET,
44+
'signIn': externs.ActionCodeOperation.EMAIL_SIGNIN,
45+
'verifyEmail': externs.ActionCodeOperation.VERIFY_EMAIL,
46+
'verifyAndChangeEmail': externs.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL,
47+
'revertSecondFactorAddition': externs.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION
4848
};
4949

5050
/**
@@ -53,7 +53,7 @@ const MODE_TO_OPERATION_MAP: { [key: string]: externs.Operation } = {
5353
* @param mode
5454
* @internal
5555
*/
56-
function parseMode(mode: string | null): externs.Operation | null {
56+
function parseMode(mode: string | null): externs.ActionCodeOperation | null {
5757
return mode ? MODE_TO_OPERATION_MAP[mode] || null : null;
5858
}
5959

@@ -91,7 +91,7 @@ export class ActionCodeURL implements externs.ActionCodeURL {
9191
/** {@inheritDoc @firebase/auth-types-exp#ActionCodeURL.languageCode} */
9292
readonly languageCode: string | null;
9393
/** {@inheritDoc @firebase/auth-types-exp#ActionCodeURL.operation} */
94-
readonly operation: externs.Operation;
94+
readonly operation: externs.ActionCodeOperation;
9595
/** {@inheritDoc @firebase/auth-types-exp#ActionCodeURL.tenantId} */
9696
readonly tenantId: string | null;
9797

packages-exp/auth-exp/src/core/providers/oauth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { OAuthCredential } from '../credentials/oauth';
2424

2525
export type CustomParameters = Record<string, string>;
2626

27-
interface CredentialParameters {
27+
export interface OAuthCredentialOptions {
2828
idToken?: string;
2929
accessToken?: string;
3030
rawNonce?: string;
@@ -46,7 +46,7 @@ export class OAuthProvider implements externs.AuthProvider {
4646
return OAuthCredential._fromParams(obj);
4747
}
4848

49-
credential(params: CredentialParameters): externs.OAuthCredential {
49+
credential(params: OAuthCredentialOptions): externs.OAuthCredential {
5050
assert(
5151
params.idToken && params.accessToken,
5252
AuthErrorCode.ARGUMENT_ERROR,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ describe('core/strategies/credential', () => {
134134
const error = await expect(
135135
signInWithCredential(auth, authCredential)
136136
).to.be.rejectedWith(MultiFactorError);
137-
expect(error.credential).to.eq(authCredential);
138137
expect(error.operationType).to.eq(OperationType.SIGN_IN);
139138
expect(error.serverResponse).to.eql(serverResponse);
140139
expect(error.user).to.be.undefined;

0 commit comments

Comments
 (0)