Skip to content

Commit aee6866

Browse files
committed
did some formatting
1 parent 7aaa8b9 commit aee6866

File tree

6 files changed

+152
-122
lines changed

6 files changed

+152
-122
lines changed

packages/auth/karma.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ function getTestFiles(argv) {
5454
}
5555

5656
function getTestBrowsers(argv) {
57-
let browsers = ["ChromeHeadless"];
57+
let browsers = ['ChromeHeadless'];
5858
if (process.env?.BROWSERS && argv.unit) {
5959
browsers = process.env?.BROWSERS?.split(',');
60-
}
60+
}
6161
return browsers;
6262
}
6363

packages/auth/src/core/util/version.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ describe('core/util/_getClientVersion', () => {
4242
context('worker', () => {
4343
it('should set the correct version', () => {
4444
expect(_getClientVersion(ClientPlatform.WORKER)).to.eq(
45-
`${_getBrowserName(getUA())}-Worker/JsCore/${SDK_VERSION}/FirebaseCore-web`
45+
`${_getBrowserName(
46+
getUA()
47+
)}-Worker/JsCore/${SDK_VERSION}/FirebaseCore-web`
4648
);
4749
});
4850
});
+69-54
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,75 @@
1-
2-
import { TotpSecret } from "../../platform_browser/mfa/assertions/totp";
3-
import { TotpMultiFactorAssertion } from "../../model/public_types";
4-
import {FactorId} from "../../model/enum_maps"
5-
import { MultiFactorSession } from "../../model/public_types";
1+
/**
2+
* @license
3+
* Copyright 2022 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import { TotpSecret } from '../../platform_browser/mfa/assertions/totp';
18+
import { TotpMultiFactorAssertion } from '../../model/public_types';
19+
import { FactorId } from '../../model/enum_maps';
20+
import { MultiFactorSession } from '../../model/public_types';
621
/**
722
* Provider for generating a {@link TotpMultiFactorAssertion}.
823
*
924
* @public
1025
*/
11-
12-
export class TotpMultiFactorGenerator {
13-
/**
14-
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the totp(Time-based One Time Password) second factor.
15-
* This assertion is used to complete enrollment in TOTP second factor.
16-
*
17-
* @param secret {@link TotpSecret}.
18-
* @param oneTimePassword One-time password from TOTP App.
19-
* @returns A {@link TotpMultiFactorAssertion} which can be used with
20-
* {@link MultiFactorUser.enroll}.
21-
*/
22-
23-
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion { return null as any}
24-
25-
/**
26-
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the totp second factor.
27-
* This assertion is used to complete signIn with TOTP as the second factor.
28-
*
29-
* @param enrollmentId identifies the enrolled TOTP second factor.
30-
* @param otp One-time password from TOTP App.
31-
* @returns A {@link TotpMultiFactorAssertion} which can be used with
32-
* {@link MultiFactorResolver.resolveSignIn}.
33-
*/
34-
35-
static assertionForSignIn(enrollmentId: string, otp: string): TotpMultiFactorAssertion {return null as any}
36-
37-
/**
38-
* Returns a promise to {@link TOTPSecret} which contains the TOTP shared secret key and other parameters.
39-
* Creates a TOTP secret as part of enrolling a TOTP second factor.
40-
* Used for generating a QRCode URL or inputting into a TOTP App.
41-
* This method uses the auth instance corresponding to the user in the multiFactorSession.
42-
*
43-
* @param session A link to {@MultiFactorSession}.
44-
* @returns A promise to {@link TotpSecret}.
45-
*/
46-
static async generateSecret(session: MultiFactorSession): Promise<TotpSecret> {
47-
return new Promise<TotpSecret>((resolve,reject)=>{
48-
49-
})}
50-
51-
52-
/**
53-
* The identifier of the phone second factor: `totp`.
54-
*/
55-
static FACTOR_ID = FactorId.TOTP;
56-
57-
26+
export class TotpMultiFactorGenerator {
27+
/**
28+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the totp(Time-based One Time Password) second factor.
29+
* This assertion is used to complete enrollment in TOTP second factor.
30+
*
31+
* @param secret {@link TotpSecret}.
32+
* @param oneTimePassword One-time password from TOTP App.
33+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
34+
* {@link MultiFactorUser.enroll}.
35+
*/
36+
static assertionForEnrollment(
37+
secret: TotpSecret,
38+
oneTimePassword: string
39+
): TotpMultiFactorAssertion {
40+
throw new Error('Unimplemented');
41+
}
42+
/**
43+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the totp second factor.
44+
* This assertion is used to complete signIn with TOTP as the second factor.
45+
*
46+
* @param enrollmentId identifies the enrolled TOTP second factor.
47+
* @param otp One-time password from TOTP App.
48+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
49+
* {@link MultiFactorResolver.resolveSignIn}.
50+
*/
51+
static assertionForSignIn(
52+
enrollmentId: string,
53+
otp: string
54+
): TotpMultiFactorAssertion {
55+
throw new Error('Unimplemented');
56+
}
57+
/**
58+
* Returns a promise to {@link TOTPSecret} which contains the TOTP shared secret key and other parameters.
59+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
60+
* Used for generating a QRCode URL or inputting into a TOTP App.
61+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
62+
*
63+
* @param session A link to {@MultiFactorSession}.
64+
* @returns A promise to {@link TotpSecret}.
65+
*/
66+
static async generateSecret(
67+
session: MultiFactorSession
68+
): Promise<TotpSecret> {
69+
throw new Error('Unimplemented');
5870
}
59-
60-
71+
/**
72+
* The identifier of the phone second factor: `totp`.
73+
*/
74+
static FACTOR_ID = FactorId.TOTP;
75+
}
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,80 @@
1+
/**
2+
* @license
3+
* Copyright 2022 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
/**
219
* Stores the shared secret key and other parameters to generate time-based OTPs.
320
* Implements methods to retrieve the shared secret key, generate a QRCode URL.
421
*/
522

6-
export class TotpSecret {
23+
export class TotpSecret {
24+
constructor(
25+
readonly secretKey: string,
26+
readonly hashingAlgorithm: string,
27+
readonly codeLength: number,
28+
readonly codeIntervalSeconds: number
29+
) {}
30+
/**
31+
* Returns the shared secret key/seed used to generate time-based one-time passwords.
32+
*
33+
* @returns Shared secret key/seed used for enrolling in TOTP MFA and generating otps.
34+
*/
35+
sharedSecretKey(): string {
36+
return this.secretKey;
37+
}
38+
39+
/**
40+
* Returns the hashing algorithm used to generate time-based one-time passwords.
41+
*
42+
* @returns Hashing algorithm used.
43+
*/
44+
getHashingAlgorithm(): string {
45+
return this.hashingAlgorithm;
46+
}
47+
48+
/**
49+
* Returns the length of the OTP codes to be generated.
50+
*
51+
* @returns Length of the one-time passwords to be generated.
52+
*/
53+
getCodeLength(): number {
54+
return this.codeLength;
55+
}
56+
57+
/**
58+
* Returns the interval(in seconds) when the OTP codes should change.
59+
*
60+
* @returns The interval (in seconds) when the OTP codes should change.
61+
*/
62+
getCodeIntervalSeconds(): number {
63+
return this.codeIntervalSeconds;
64+
}
765

8-
secretKey: string
9-
hashingAlgorithm: string
10-
codeLength: number
11-
codeIntervalSeconds: number
12-
constructor(secretKey: string, hashingAlgorithm: string, codeLength: number,
13-
codeIntervalSeconds: number){
66+
/**
67+
* Returns a QRCode URL as described in
68+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
69+
* This can be displayed to the user as a QRCode to be scanned into a TOTP App like Google Authenticator.
70+
* If the optional parameters are unspecified, an accountName of "<firebaseAppName>:<userEmail> and issuer of <firebaseAppName> are used.
71+
*
72+
* @param accountName the name of the account/app along with a user identifier.
73+
* @param issuer issuer of the TOTP(likely the app name).
74+
* @returns A QRCode URL string.
75+
*/
1476

15-
this.secretKey = secretKey
16-
this.hashingAlgorithm = hashingAlgorithm
17-
this.codeLength = codeLength
18-
this.codeIntervalSeconds = codeIntervalSeconds
19-
}
20-
/**
21-
* Returns the shared secret key/seed used to generate time-based one-time passwords.
22-
*
23-
* @returns Shared secret key/seed used for enrolling in TOTP MFA and generating otps.
24-
*/
25-
sharedSecretKey(): string {
26-
return this.secretKey;
27-
}
28-
29-
/**
30-
* Returns the hashing algorithm used to generate time-based one-time passwords.
31-
*
32-
* @returns Hashing algorithm used.
33-
*/
34-
getHashingAlgorithm(): string {
35-
return this.hashingAlgorithm;
36-
}
37-
38-
/**
39-
* Returns the length of the OTP codes to be generated.
40-
*
41-
* @returns Length of the one-time passwords to be generated.
42-
*/
43-
getCodeLength(): number {
44-
return this.codeLength;
45-
}
46-
47-
/**
48-
* Returns the interval(in seconds) when the OTP codes should change.
49-
*
50-
* @returns The interval (in seconds) when the OTP codes should change.
51-
*/
52-
getCodeIntervalSeconds(): number {
53-
return this.codeIntervalSeconds;
54-
}
55-
56-
/**
57-
* Returns a QRCode URL as described in
58-
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
59-
* This can be displayed to the user as a QRCode to be scanned into a TOTP App like Google Authenticator.
60-
* If the optional parameters are unspecified, an accountName of "<firebaseAppName>:<userEmail> and issuer of <firebaseAppName> are used.
61-
*
62-
* @param accountName the name of the account/app along with a user identifier.
63-
* @param issuer issuer of the TOTP(likely the app name).
64-
* @returns A QRCode URL string.
65-
*/
66-
67-
generateQrCodeUrl(accountName?: string, issuer?: string): string { return null as any}
77+
generateQrCodeUrl(accountName?: string, issuer?: string): string {
78+
return null as any;
6879
}
69-
80+
}

packages/auth/src/platform_browser/persistence/session_storage.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ describe('platform_browser/persistence/session_storage', () => {
6666
afterEach(() => sinon.restore());
6767

6868
it('should emit false if sessionStorage setItem throws', async () => {
69-
sinon.stub(Storage.prototype, 'setItem').throws(new Error('nope'));
70-
expect(await persistence._isAvailable()).to.be.false;
69+
sinon.stub(Storage.prototype, 'setItem').throws(new Error('nope'));
70+
expect(await persistence._isAvailable()).to.be.false;
7171
});
7272

7373
it('should emit false if sessionStorage removeItem throws', async () => {

packages/auth/src/platform_cordova/popup_redirect/events.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ describe('platform_cordova/popup_redirect/events', () => {
7373
const spy = sinon.spy(Storage.prototype, 'setItem');
7474
const event = _generateNewEvent(auth, AuthEventType.REAUTH_VIA_REDIRECT);
7575
await _savePartialEvent(auth, event);
76-
expect(spy).to.have.been.calledWith('firebase:authEvent:test-api-key:test-app',
77-
JSON.stringify(event));
76+
expect(spy).to.have.been.calledWith(
77+
'firebase:authEvent:test-api-key:test-app',
78+
JSON.stringify(event)
79+
);
7880
});
7981
});
8082

0 commit comments

Comments
 (0)