Skip to content

Commit accf5de

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 3c461d0 commit accf5de

File tree

4 files changed

+77
-49
lines changed

4 files changed

+77
-49
lines changed

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

+23-13
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ import * as mockFetch from '../../../test/mock_fetch';
2525
import { Endpoint } from '../../api';
2626
import { ServerError } from '../../api/errors';
2727
import { Operation } from '../../model/action_code_info';
28-
import {
29-
sendSignInLinkToEmail,
30-
isSignInWithEmailLink
31-
} from './email_link';
28+
import { sendSignInLinkToEmail, isSignInWithEmailLink } from './email_link';
3229

3330
use(chaiAsPromised);
3431
use(sinonChai);
@@ -127,12 +124,14 @@ describe('sendSignInLinkToEmail', () => {
127124
describe('isSignInWithEmailLink', () => {
128125
context('simple links', () => {
129126
it('should recognize sign in links', () => {
130-
const link = 'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
127+
const link =
128+
'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
131129
expect(isSignInWithEmailLink(mockAuth, link)).to.be.true;
132130
});
133131

134132
it('should not recognize other email links', () => {
135-
const link = 'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode&apiKey=API_KEY';
133+
const link =
134+
'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode&apiKey=API_KEY';
136135
expect(isSignInWithEmailLink(mockAuth, link)).to.be.false;
137136
});
138137

@@ -144,26 +143,37 @@ describe('isSignInWithEmailLink', () => {
144143

145144
context('deep links', () => {
146145
it('should recognize valid links', () => {
147-
const deepLink = 'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
148-
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(deepLink)}`;
146+
const deepLink =
147+
'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
148+
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(
149+
deepLink
150+
)}`;
149151
expect(isSignInWithEmailLink(mockAuth, link)).to.be.true;
150152
});
151153

152154
it('should recognize valid links with deep_link_id', () => {
153-
const deepLink = 'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
154-
const link = `somexampleiosurl://google/link?deep_link_id=${encodeURIComponent(deepLink)}`;
155+
const deepLink =
156+
'https://www.example.com/action?mode=signIn&oobCode=oobCode&apiKey=API_KEY';
157+
const link = `somexampleiosurl://google/link?deep_link_id=${encodeURIComponent(
158+
deepLink
159+
)}`;
155160
expect(isSignInWithEmailLink(mockAuth, link)).to.be.true;
156161
});
157162

158163
it('should reject other email links', () => {
159-
const deepLink = 'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode&apiKey=API_KEY';
160-
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(deepLink)}`;
164+
const deepLink =
165+
'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode&apiKey=API_KEY';
166+
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(
167+
deepLink
168+
)}`;
161169
expect(isSignInWithEmailLink(mockAuth, link)).to.be.false;
162170
});
163171

164172
it('should reject invalid links', () => {
165173
const deepLink = 'https://www.example.com/action?mode=signIn';
166-
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(deepLink)}`;
174+
const link = `https://example.app.goo.gl/?link=${encodeURIComponent(
175+
deepLink
176+
)}`;
167177
expect(isSignInWithEmailLink(mockAuth, link)).to.be.false;
168178
});
169179
});

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
import * as api from '../../api/authentication/email_and_password';
1919
import { Operation } from '../../model/action_code_info';
20-
import { ActionCodeSettings, setActionCodeSettingsOnRequest } from '../../model/action_code_settings';
20+
import {
21+
ActionCodeSettings,
22+
setActionCodeSettingsOnRequest
23+
} from '../../model/action_code_settings';
2124
import { ActionCodeURL } from '../../model/action_code_url';
2225
import { Auth } from '../../model/auth';
2326

@@ -40,4 +43,4 @@ export async function sendSignInLinkToEmail(
4043
export function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean {
4144
const actionCodeUrl = ActionCodeURL._fromLink(auth, emailLink);
4245
return actionCodeUrl?.operation === Operation.EMAIL_SIGNIN;
43-
}
46+
}

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

+46-28
Original file line numberDiff line numberDiff line change
@@ -23,73 +23,86 @@ import { Operation } from './action_code_info';
2323
describe('ActionCodeURL', () => {
2424
describe('_fromLink', () => {
2525
it('should parse correctly formatted links', () => {
26-
const continueUrl = 'https://www.example.com/path/to/file?a=1&b=2#c=3';
27-
const actionLink = 'https://www.example.com/finishSignIn?' +
28-
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
29-
'continueUrl=' + encodeURIComponent(continueUrl) +
30-
'&languageCode=en&tenantId=TENANT_ID&state=bla';
31-
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
32-
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
33-
expect(actionCodeUrl!.code).to.eq('CODE');
34-
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
35-
// ContinueUrl should be decoded.
36-
expect(actionCodeUrl!.continueUrl).to.eq(continueUrl);
37-
expect(actionCodeUrl!.tenantId).to.eq('TENANT_ID');
38-
expect(actionCodeUrl!.languageCode).to.eq('en');
26+
const continueUrl = 'https://www.example.com/path/to/file?a=1&b=2#c=3';
27+
const actionLink =
28+
'https://www.example.com/finishSignIn?' +
29+
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
30+
'continueUrl=' +
31+
encodeURIComponent(continueUrl) +
32+
'&languageCode=en&tenantId=TENANT_ID&state=bla';
33+
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
34+
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
35+
expect(actionCodeUrl!.code).to.eq('CODE');
36+
expect(actionCodeUrl!.apiKey).to.eq('API_KEY');
37+
// ContinueUrl should be decoded.
38+
expect(actionCodeUrl!.continueUrl).to.eq(continueUrl);
39+
expect(actionCodeUrl!.tenantId).to.eq('TENANT_ID');
40+
expect(actionCodeUrl!.languageCode).to.eq('en');
3941
});
4042

4143
context('operation', () => {
4244
it('should identitfy EMAIL_SIGNIN', () => {
43-
const actionLink = 'https://www.example.com/finishSignIn?' +
45+
const actionLink =
46+
'https://www.example.com/finishSignIn?' +
4447
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
4548
'languageCode=en';
4649
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
4750
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
4851
});
4952

5053
it('should identitfy VERIFY_AND_CHANGE_EMAIL', () => {
51-
const actionLink = 'https://www.example.com/finishSignIn?' +
54+
const actionLink =
55+
'https://www.example.com/finishSignIn?' +
5256
'oobCode=CODE&mode=verifyAndChangeEmail&apiKey=API_KEY&' +
5357
'languageCode=en';
5458
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
55-
expect(actionCodeUrl!.operation).to.eq(Operation.VERIFY_AND_CHANGE_EMAIL);
59+
expect(actionCodeUrl!.operation).to.eq(
60+
Operation.VERIFY_AND_CHANGE_EMAIL
61+
);
5662
});
5763

5864
it('should identitfy VERIFY_EMAIL', () => {
59-
const actionLink = 'https://www.example.com/finishSignIn?' +
65+
const actionLink =
66+
'https://www.example.com/finishSignIn?' +
6067
'oobCode=CODE&mode=verifyEmail&apiKey=API_KEY&' +
6168
'languageCode=en';
6269
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
6370
expect(actionCodeUrl!.operation).to.eq(Operation.VERIFY_EMAIL);
6471
});
6572

6673
it('should identitfy RECOVER_EMAIL', () => {
67-
const actionLink = 'https://www.example.com/finishSignIn?' +
74+
const actionLink =
75+
'https://www.example.com/finishSignIn?' +
6876
'oobCode=CODE&mode=recoverEmail&apiKey=API_KEY&' +
6977
'languageCode=en';
7078
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
7179
expect(actionCodeUrl!.operation).to.eq(Operation.RECOVER_EMAIL);
7280
});
7381

7482
it('should identitfy PASSWORD_RESET', () => {
75-
const actionLink = 'https://www.example.com/finishSignIn?' +
83+
const actionLink =
84+
'https://www.example.com/finishSignIn?' +
7685
'oobCode=CODE&mode=resetPassword&apiKey=API_KEY&' +
7786
'languageCode=en';
7887
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
7988
expect(actionCodeUrl!.operation).to.eq(Operation.PASSWORD_RESET);
8089
});
8190

8291
it('should identitfy REVERT_SECOND_FACTOR_ADDITION', () => {
83-
const actionLink = 'https://www.example.com/finishSignIn?' +
92+
const actionLink =
93+
'https://www.example.com/finishSignIn?' +
8494
'oobCode=CODE&mode=revertSecondFactorAddition&apiKey=API_KEY&' +
8595
'languageCode=en';
8696
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
87-
expect(actionCodeUrl!.operation).to.eq(Operation.REVERT_SECOND_FACTOR_ADDITION);
97+
expect(actionCodeUrl!.operation).to.eq(
98+
Operation.REVERT_SECOND_FACTOR_ADDITION
99+
);
88100
});
89101
});
90102

91103
it('should work if there is a port number in the URL', () => {
92-
const actionLink = 'https://www.example.com:8080/finishSignIn?' +
104+
const actionLink =
105+
'https://www.example.com:8080/finishSignIn?' +
93106
'oobCode=CODE&mode=signIn&apiKey=API_KEY&state=bla';
94107
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
95108
expect(actionCodeUrl!.operation).to.eq(Operation.EMAIL_SIGNIN);
@@ -101,7 +114,8 @@ describe('ActionCodeURL', () => {
101114
});
102115

103116
it('should ignore parameters after anchor', () => {
104-
const actionLink = 'https://www.example.com/finishSignIn?' +
117+
const actionLink =
118+
'https://www.example.com/finishSignIn?' +
105119
'oobCode=CODE1&mode=signIn&apiKey=API_KEY1&state=bla' +
106120
'#oobCode=CODE2&mode=signIn&apiKey=API_KEY2&state=bla';
107121
const actionCodeUrl = ActionCodeURL._fromLink(mockAuth, actionLink);
@@ -120,24 +134,28 @@ describe('ActionCodeURL', () => {
120134
});
121135

122136
it('should handle invalid mode', () => {
123-
const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&mode=INVALID_MODE&apiKey=API_KEY';
137+
const actionLink =
138+
'https://www.example.com/finishSignIn?oobCode=CODE&mode=INVALID_MODE&apiKey=API_KEY';
124139
expect(ActionCodeURL._fromLink(mockAuth, actionLink)).to.be.null;
125140
});
126141

127142
it('should handle missing code', () => {
128-
const actionLink = 'https://www.example.com/finishSignIn?mode=signIn&apiKey=API_KEY';
143+
const actionLink =
144+
'https://www.example.com/finishSignIn?mode=signIn&apiKey=API_KEY';
129145
expect(ActionCodeURL._fromLink(mockAuth, actionLink)).to.be.null;
130146
});
131147

132148
it('should handle missing API key', () => {
133-
const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&mode=signIn';
149+
const actionLink =
150+
'https://www.example.com/finishSignIn?oobCode=CODE&mode=signIn';
134151
expect(ActionCodeURL._fromLink(mockAuth, actionLink)).to.be.null;
135152
});
136153

137154
it('should handle missing mode', () => {
138-
const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&apiKey=API_KEY';
155+
const actionLink =
156+
'https://www.example.com/finishSignIn?oobCode=CODE&apiKey=API_KEY';
139157
expect(ActionCodeURL._fromLink(mockAuth, actionLink)).to.be.null;
140158
});
141159
});
142-
});
160+
});
143161
});

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum QueryField {
3535
/**
3636
* Map from mode string in action code URL to Action Code Info operation.
3737
*/
38-
const _ModeToOperationMap: { [key: string]: Operation; } = {
38+
const _ModeToOperationMap: { [key: string]: Operation } = {
3939
'recoverEmail': Operation.RECOVER_EMAIL,
4040
'resetPassword': Operation.PASSWORD_RESET,
4141
'signIn': Operation.EMAIL_SIGNIN,
@@ -92,15 +92,12 @@ export class ActionCodeURL {
9292
return this;
9393
}
9494

95-
static _fromLink(
96-
auth: Auth,
97-
link: string
98-
): ActionCodeURL | null {
95+
static _fromLink(auth: Auth, link: string): ActionCodeURL | null {
9996
const actionLink = _parseDeepLink(link);
10097
try {
10198
return new ActionCodeURL(auth, actionLink);
10299
} catch (e) {
103100
return null;
104101
}
105102
}
106-
}
103+
}

0 commit comments

Comments
 (0)