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

BIT-1003: Generate plus addressed emails #129

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

matt-livefront
Copy link
Collaborator

🎟️ Tracking

BIT-1003

🚧 Type of change

  • 🚀 New feature development

📔 Objective

This adds generating of plus addressed emails.

📋 Code changes

  • Constants.swift: Adds a constant for the default generation value (-) to return if there isn't enough information to generate a value.
  • GeneratorRepository.swift: Adds a method to generate plus addressed emails.
  • CryptoService.swift: Add a method for generating a random string of a specified length.
  • RandomNumberGenerator.swift: A protocol and implementation for securely generating a random number.
  • GeneratorProcessor.swift: Generates a new plus address email when the email field loses focus or the refresh button is tapped.
  • GeneratorView.swift: Uses @FocusState to determine when a text field has or loses focus.

📸 Screenshots

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-11-03.at.15.11.37.mp4

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation 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

Copy link
Contributor

github-actions bot commented Nov 7, 2023

1 Warning
⚠️ BitwardenShared/Core/Tools/Services/RandomNumberGenerator.swift has less than 80% code coverage

Bitwarden code coverage

Total coverage: 81.19%

File Coverage
BitwardenShared/Core/Tools/Repositories/GeneratorRepository.swift 100.00%
BitwardenShared/Core/Tools/Services/CryptoService.swift 100.00%
BitwardenShared/Core/Tools/Services/RandomNumberGenerator.swift 0.00%
BitwardenShared/UI/Tools/Generator/Generator/GeneratorAction.swift 94.12%
BitwardenShared/UI/Tools/Generator/Generator/GeneratorProcessor.swift 93.75%
BitwardenShared/UI/Tools/Generator/Generator/GeneratorView.swift 90.27%

Powered by Slather

Generated by 🚫 Danger

Copy link
Member

@fedemkr fedemkr left a comment

Choose a reason for hiding this comment

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

🤔 I just wanted to let you know that there are some open PRs on the SDK repo for Password/Passphrase/Username generation so not sure if it's worth you add the logic for that given it's going to be replaced afterwards for the SDK version once it's merged.
Username Generator
Passphrase Generator
Password Generator

Comment on lines +73 to +78
guard let atIndex = email.firstIndex(of: "@"),
// Ensure '@' symbol isn't the first or last character.
atIndex > email.startIndex,
atIndex < email.index(before: email.endIndex) else {
return email
}
Copy link
Member

Choose a reason for hiding this comment

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

🤔 What do you think of moving this to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you proposing replacing this entire guard with the isValidEmail check? I think these do slightly different, yet similar things. But if we're trying to match the Xamarin app which has been driving our requirements, the isValidEmail only checks that the string contains an @ symbol and doesn't check that it isn't the first or last character.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, for matching purposes we can leave it like this and refactor in the future. Cause IMO wherever isValidEmail is used, when checking if it has a @ it shouldn't be neither the start nor the end of the string so if we'd replace the current isValidEmail logic it'd be an improvement. However you're right and let's leave it like this so it's equal to the Xamarin app.

@matt-livefront matt-livefront force-pushed the matt/BIT-410-generator-catch-all-email-ui branch from faac7b9 to 496c260 Compare November 7, 2023 20:30
@matt-livefront
Copy link
Collaborator Author

🤔 I just wanted to let you know that there are some open PRs on the SDK repo for Password/Passphrase/Username generation so not sure if it's worth you add the logic for that given it's going to be replaced afterwards for the SDK version once it's merged. Username Generator Passphrase Generator Password Generator

Ah, I didn't realize this. The document that I have only lists password and passphrase generation as being implemented for us by the SDK. But that's great if we'll be getting username generation too. I think we can keep this for now and replace it once it's in the SDK.

@matt-livefront matt-livefront force-pushed the matt/BIT-1003-generate-plus-email branch from bbedf1a to 078d4ab Compare November 10, 2023 15:37
Base automatically changed from matt/BIT-410-generator-catch-all-email-ui to main November 10, 2023 21:28
@matt-livefront matt-livefront force-pushed the matt/BIT-1003-generate-plus-email branch from 078d4ab to 0441168 Compare November 10, 2023 21:30
@bitwarden-bot
Copy link

Logo
Checkmarx One – Scan Summary & Detailsb4b23162-0612-456d-81e6-3029ff7be7cc

No New Or Fixed Issues Found

Copy link
Contributor

@nathan-livefront nathan-livefront left a comment

Choose a reason for hiding this comment

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

This looks awesome!

@matt-livefront matt-livefront merged commit 0af1bf1 into main Nov 13, 2023
2 checks passed
@matt-livefront matt-livefront deleted the matt/BIT-1003-generate-plus-email branch November 13, 2023 15:37
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