-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-11941] Migrate TOTP Generator to use SDK #12987
base: main
Are you sure you want to change the base?
Conversation
Fixed strict typescript issues
New Issues (13)Checkmarx found the following issues in this Pull Request
Fixed Issues (4)Great job! The following issues were fixed in this Pull Request
|
apps/browser/src/autofill/browser/context-menu-clicked-handler.ts
Outdated
Show resolved
Hide resolved
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.
I think this PR is good for approval but you'll need to merge the SDK PR first and then update package.json
in this PR to point to pull in the new TOTP functionality. Re-request a review from me then and I'll approve this PR 👍
/** | ||
* Represents TOTP information including display formatting and timing | ||
*/ | ||
export type TotpInfo = { |
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.
question(non-blocking): are we defining the type here but not using it here? It seems the implementation for mapping TotpResponse
to TotpInfo
is in view.component.ts
?
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.
totp-countdown.component.ts
also uses it
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.
LGTM 👍
await this.totpService.getCode(cipher.login.totp), | ||
); | ||
const totpResponse = await firstValueFrom(this.totpService.getCode$(cipher.login.totp)); | ||
this.platformUtilsService.copyToClipboard(totpResponse.code); |
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.
Is totpResponse
guaranteed to have a code
property in this scenario (and elsewhere)?
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.
I think this is a similar question to this #12987 (comment), it is not guaranteed. How would you prefer errors in this scenario to be handled in the autofill context?
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.
Naively, I'd probably do something like
const totpResponse = await firstValueFrom(this.totpService.getCode$(cipher.login.totp));
if (totpResponse?.code) {
this.platformUtilsService.copyToClipboard();
} else {
/*
let the user know the copy didn't happen in whatever way
makes sense for the context (toast, console error, etc)
*/
}
let totpValue = ( | ||
await firstValueFrom(this.totpService.getCode$(options.cipher.login.totp)) | ||
).code; |
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.
readability nit:
let totpValue = ( | |
await firstValueFrom(this.totpService.getCode$(options.cipher.login.totp)) | |
).code; | |
const totpResponse = await firstValueFrom( | |
this.totpService.getCode$(options.cipher.login.totp), | |
); | |
let totpValue = totpResponse.code; |
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.
Thanks
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.
One small question, otherwise LGTM for Autofill concerns
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-11941
📔 Objective
Migrate Totp Generation service to use sdk. This PR depends on bitwarden/sdk-internal#126
📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes