Skip to content
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-14219] Add service for new device verification notice #11988

Merged
merged 6 commits into from
Nov 19, 2024

Conversation

Jingo88
Copy link
Contributor

@Jingo88 Jingo88 commented Nov 13, 2024

🎟️ Tracking

PM-14219

📔 Objective

Added service for New Device Verification Notice. Components and Routeguards that will use this are being implement next.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

noticeState$: Observable<NewDeviceVerificationNotice>;

constructor(private stateProvider: StateProvider) {
this.noticeState = this.stateProvider.getActive(NEW_DEVICE_VERIFICATION_NOTICE_KEY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ We're moving away from ActiveUserState and should require a userId for service methods/state. Something like

noticeState$(userId: userId) {
  return this.stateProvider.getUser(userId, NEW_DEVICE_VERIFICATION_NOTICE_KEY).state$;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reference this

} from "@bitwarden/common/platform/state";

export type NewDeviceVerificationNotice = {
last_dismissal: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ What type of values will last_dismissal hold? Is it a date?

NEW_DEVICE_VERIFICATION_NOTICE,
} from "@bitwarden/common/platform/state";

export type NewDeviceVerificationNotice = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 We should add some documentation on what these values represent / how they're expected to be used.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.

Project coverage is 33.49%. Comparing base (d55c871) to head (106cd59).
Report is 25 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...services/new-device-verification-notice.service.ts 81.25% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11988   +/-   ##
=======================================
  Coverage   33.48%   33.49%           
=======================================
  Files        2846     2847    +1     
  Lines       89214    89231   +17     
  Branches    17006    17009    +3     
=======================================
+ Hits        29872    29886   +14     
- Misses      56989    56991    +2     
- Partials     2353     2354    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

github-actions bot commented Nov 13, 2024

Logo
Checkmarx One – Scan Summary & Details31c9a9e6-6d42-45c4-817b-45b3d4d4db7c

Fixed Issues

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 55
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 35
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /libs/vault/src/components/totp-countdown/totp-countdown.component.ts: 14
MEDIUM Client_Privacy_Violation /libs/vault/src/components/totp-countdown/totp-countdown.component.ts: 15
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /libs/components/src/avatar/avatar.component.ts: 80
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /apps/desktop/src/app/components/avatar.component.ts: 75
LOW Client_Hardcoded_Domain /apps/web/src/app/billing/shared/payment/payment.component.ts: 73
LOW Client_Hardcoded_Domain /apps/web/src/app/billing/shared/payment/payment.component.ts: 73
LOW Client_JQuery_Deprecated_Symbols /apps/cli/src/service-container/service-container.ts: 876
LOW Client_JQuery_Deprecated_Symbols /libs/importer/src/services/import.service.ts: 467

coroiu
coroiu previously approved these changes Nov 14, 2024
Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State definition looks ok

return this.stateProvider.getUser(userId, NEW_DEVICE_VERIFICATION_NOTICE_KEY);
}

noticeState$(userId$: Observable<UserId>): Observable<NewDeviceVerificationNotice> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 I think we may want to just accept a single UserId instead of Observable<UserId>. For reference there is some recent discussion on this here.

But, from my understanding, by accepting an observable, there is a greater chance we run into the same issue we're trying to avoid by moving away from ActiveUserState (race conditions with different userIds during account switching or lock/logout).

cc: @justindbaur In case you have any more insight here.

@Jingo88 Jingo88 requested a review from shane-melton November 15, 2024 16:10
@Jingo88 Jingo88 requested a review from coroiu November 18, 2024 17:20
Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes to platform code, approving!

@Jingo88 Jingo88 merged commit 2185559 into main Nov 19, 2024
71 checks passed
@Jingo88 Jingo88 deleted the PM-14219-new-verification-state-provider branch November 19, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants