-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(2fa): Add two-factor
lib
#17937
base: main
Are you sure you want to change the base?
Conversation
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
export const generateBackupCodes = (count: number): string[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A factory like this should be named BackupCodeFactory
. Typically factories should be for complex types rather than simple types like the below, since they should always be TypeNameFactory.
getBackupCodes(userId: string): string[]; | ||
} | ||
|
||
export class BackupCodeManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these intended to be consumed by NestJS? If so, we should add the @Injectable decorator
export class BackupCodeManager { | ||
constructor(private readonly backupCodeRepository: BackupCodeRepository) {} | ||
|
||
hasBackupCodes(userId: string): { hasBackupCodes: boolean; count: number } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename to getCountForUserId
? This method is implicitly part of the BackupCodeManager class so doesn't need the name of the class within the class.
backup-code
libstwo-factor
lib
eaeeea8
to
68b233f
Compare
Because
This pull request
BackupCodeManager
classhasRecoveryCodes
Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-10332
Checklist
Notes
The linked issue mentions the nx lib should be
2fa
, but nx wont let you create a lib starting with a number. Opted fortwo-factor
instead.