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

Manage Private Email Addresses #396

Merged
merged 97 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
9f7e7ec
Private Email Status, Activation & Deactivation
afterxleep Jun 2, 2023
930c3a8
Cancel Active URLSession Task on delegate and add a notFound error
afterxleep Jun 6, 2023
396a849
Error handling in Request Delegate
afterxleep Jun 7, 2023
3fb664c
Merge branch 'main' into daniel/manage-private-duck-address
afterxleep Jun 7, 2023
62d3f30
Return Email Alias Status
afterxleep Jun 9, 2023
025110b
Merge branch 'main' into daniel/manage-private-duck-address
afterxleep Jun 12, 2023
134a7df
Use Staging API’s and update request methods for activate/deactivate …
afterxleep Jun 16, 2023
91b8677
Move endpoints to prod
afterxleep Jun 20, 2023
a929ae4
Update Login URL
afterxleep Jun 21, 2023
1c40295
Updated Service URL
afterxleep Jun 21, 2023
83e082f
Fixed Tests
afterxleep Jun 26, 2023
e1ebf2c
Removed unnecesary tests
afterxleep Jun 26, 2023
d44ec9f
Merge branch 'daniel/manage-email-integration' into daniel/manage-pri…
afterxleep Jun 26, 2023
c27a6f9
Create/Update Auto-generated emails and passwords
afterxleep Jun 29, 2023
d986a0a
Clean partial account after submission
afterxleep Jun 29, 2023
d8b5ad8
Lowercase user domain for comparison
afterxleep Jun 29, 2023
dd5b8cd
Merge branch 'daniel/manage-private-duck-address' into daniel/private…
afterxleep Jun 29, 2023
d775412
Us Correct Autofill branch
afterxleep Jun 29, 2023
41c7f87
Account Saving Updates
afterxleep Jun 29, 2023
3fd5756
Updated more logic
afterxleep Jun 29, 2023
b75647e
Recreate partial account if deleted by user
afterxleep Jun 30, 2023
e71c932
Comment
afterxleep Jun 30, 2023
3868722
Private Email Status, Activation & Deactivation
afterxleep Jun 2, 2023
8505bb8
Cancel Active URLSession Task on delegate and add a notFound error
afterxleep Jun 6, 2023
e5dfdb2
Error handling in Request Delegate
afterxleep Jun 7, 2023
c4582b8
Return Email Alias Status
afterxleep Jun 9, 2023
889a306
Use Staging API’s and update request methods for activate/deactivate …
afterxleep Jun 16, 2023
a0553ec
Move endpoints to prod
afterxleep Jun 20, 2023
677fb0e
Update Login URL
afterxleep Jun 21, 2023
8743bab
Updated Service URL
afterxleep Jun 21, 2023
de32eba
Fixed Tests
afterxleep Jun 26, 2023
86e2898
Removed unnecesary tests
afterxleep Jun 26, 2023
88ed9eb
Create/Update Auto-generated emails and passwords
afterxleep Jun 29, 2023
0ebf977
Clean partial account after submission
afterxleep Jun 29, 2023
1771177
Lowercase user domain for comparison
afterxleep Jun 29, 2023
321f481
Us Correct Autofill branch
afterxleep Jun 29, 2023
085c8cf
Account Saving Updates
afterxleep Jun 29, 2023
982ce92
Updated more logic
afterxleep Jun 29, 2023
ef2ef58
Recreate partial account if deleted by user
afterxleep Jun 30, 2023
e44c9d7
Comment
afterxleep Jun 30, 2023
436f299
Merge branch 'daniel/private-email-autofill' of github.com:duckduckgo…
afterxleep Jun 30, 2023
d2dfc7c
Do not override password when generating new email
afterxleep Jul 3, 2023
8e9266e
Updated first batch of tests
afterxleep Jul 3, 2023
b94c80d
Removed unwanted tests
afterxleep Jul 3, 2023
67ddb89
Remove unwanted code
afterxleep Jul 4, 2023
6fa9477
Minor update to Bitwarden logic
afterxleep Jul 4, 2023
20d488c
Merge branch 'main' into daniel/private-email-autofill
afterxleep Jul 5, 2023
20015ec
Revert change for offering generated passwords on iOS
afterxleep Jul 5, 2023
0080cc8
Remove comment
afterxleep Jul 5, 2023
df6f7cf
Update the tests and re-enable
afterxleep Jul 5, 2023
e3a3eef
Email Alias update
afterxleep Jul 7, 2023
0083386
Prompt to update usernames on empty username accounts
afterxleep Jul 11, 2023
9c257db
Delete partial account if a form submission is detected
afterxleep Jul 12, 2023
d6244aa
Update Autofill branch
afterxleep Jul 12, 2023
c9fcfe6
Update API calls to use parameters
afterxleep Jul 12, 2023
ddd1af0
Fixes Autosaving for generated logins
afterxleep Jul 13, 2023
7776896
Added Test
afterxleep Jul 13, 2023
0a2508b
Added tests for autosaving generated credentials
afterxleep Jul 13, 2023
262c052
Cleanup
afterxleep Jul 13, 2023
6a57bea
Only consider Private emails as auto-generated
afterxleep Jul 14, 2023
76ea12c
Comment
afterxleep Jul 14, 2023
0ac444f
Autosaving
afterxleep Jul 17, 2023
84e0baa
Add autosave option to emailManager delegate
afterxleep Jul 17, 2023
8bcff7e
Removed test
afterxleep Jul 17, 2023
6471607
Merge branch 'main' into daniel/private-email-autofill
afterxleep Jul 17, 2023
c1e45d0
Fix conflicts
afterxleep Jul 17, 2023
e75398a
Fix tests
afterxleep Jul 17, 2023
49ab364
Merge branch 'main' into daniel/private-email-autofill
afterxleep Jul 19, 2023
3a07261
Lowercase Emails (#424)
afterxleep Jul 19, 2023
a9c5365
Update autosave logic to properly trust autogenerated fields from JS …
afterxleep Jul 20, 2023
437ab74
Updated comment
afterxleep Jul 20, 2023
f855183
Update Tests
afterxleep Jul 20, 2023
d0834e7
Updated tests
afterxleep Jul 20, 2023
0b92c93
Validate autosaveAccount add test, do not uodate autogenerated if alr…
afterxleep Jul 20, 2023
83ebb3c
Bump autofill to 8.0.0
afterxleep Jul 21, 2023
70466fd
Updated logic
afterxleep Jul 27, 2023
b93cf42
Added logic and test for empty usernames
afterxleep Jul 28, 2023
5f5af9c
Autosave username when generating password
afterxleep Jul 31, 2023
6b06eac
Update tests, move temp account deletion to main function
afterxleep Aug 1, 2023
cec87f4
Clear up creds when navigating away
afterxleep Aug 1, 2023
9047be0
Updated tests for clarity
afterxleep Aug 1, 2023
85067ae
Update autogenerated values independently
afterxleep Aug 1, 2023
83a1d2b
Updated Test
afterxleep Aug 1, 2023
cba2a98
Address PR feedback
afterxleep Aug 2, 2023
8fad8f0
Fix publisher, add option to override internal user state in debug (…
bwaresiak Jul 19, 2023
d3e8c82
replace assertion in assertObjectDeallocated with sigint (#428)
mallexxx Jul 21, 2023
d5c6373
Add support for per-model Sync Data Providers initialization (#433)
ayoy Jul 26, 2023
9f5fb53
disable trailing_comma (#434)
mallexxx Jul 26, 2023
9a0e112
Fire Window (#420)
tomasstrba Jul 27, 2023
ba46fc9
Extract SecureVault code into SecureStorage module (#430)
samsymons Jul 28, 2023
89ec4fb
Attribution pixel (#432)
jaceklyp Jul 28, 2023
a6e1ab8
bump CSS to 4.30.0 for messageHandlers fix (#439)
shakyShane Jul 31, 2023
36d2840
De-flake pinger tests (#436)
graeme Aug 1, 2023
7c5a0bc
os_log fixes (#437)
mallexxx Aug 2, 2023
a5d33aa
Add concurrency extension, refactor Connection Tester to use AsyncSeq…
mallexxx Aug 2, 2023
5206c6d
Merge branch 'main' into daniel/private-email-autofill
afterxleep Aug 2, 2023
80e0d6f
Revert "Merge branch 'main' into daniel/private-email-autofill"
afterxleep Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "44cd844b6bb5d8ccfefbd6e025817d800c26ad76",
"version" : "7.2.0"
"branch" : "8.0.0",
"revision" : "b1160df954eea20cd4cdf9356afc369751981b16"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ let package = Package(
.library(name: "NetworkProtection", targets: ["NetworkProtection"]),
.library(name: "SecureStorage", targets: ["SecureStorage"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/duckduckgo-autofill.git", exact: "7.2.0"),
dependencies: [
.package(url: "https://github.com/duckduckgo/duckduckgo-autofill.git", branch: "8.0.0"),
.package(url: "https://github.com/duckduckgo/GRDB.swift.git", exact: "2.2.0"),
.package(url: "https://github.com/duckduckgo/TrackerRadarKit.git", exact: "1.2.1"),
.package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "1.2.1"),
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.2.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "2.1.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "4.30.0"),
Expand Down
29 changes: 20 additions & 9 deletions Sources/BrowserServicesKit/Autofill/AutofillUserScript+Email.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public protocol AutofillEmailDelegate: AnyObject {
func autofillUserScript(_: AutofillUserScript,
didRequestAliasAndRequiresUserPermission requiresUserPermission: Bool,
shouldConsumeAliasIfProvided: Bool,
completionHandler: @escaping AliasCompletion)
completionHandler: @escaping AliasAutosaveCompletion)
func autofillUserScriptDidRequestRefreshAlias(_ : AutofillUserScript)
func autofillUserScript(_: AutofillUserScript, didRequestStoreToken token: String, username: String, cohort: String?)
func autofillUserScriptDidRequestUsernameAndAlias(_ : AutofillUserScript, completionHandler: @escaping UsernameAndAliasCompletion)
Expand Down Expand Up @@ -66,17 +66,28 @@ extension AutofillUserScript {
guard let dict = message.messageBody as? [String: Any],
let requiresUserPermission = dict["requiresUserPermission"] as? Bool,
let shouldConsumeAliasIfProvided = dict["shouldConsumeAliasIfProvided"] as? Bool else { return }

emailDelegate?.autofillUserScript(self,
didRequestAliasAndRequiresUserPermission: requiresUserPermission,
shouldConsumeAliasIfProvided: shouldConsumeAliasIfProvided) { alias, _ in
guard let alias = alias else { return }

replyHandler("""
{
"alias": "\(alias)"
shouldConsumeAliasIfProvided: shouldConsumeAliasIfProvided) { alias, autosave, _ in
guard let alias = alias else { return }
let domain = self.hostProvider.hostForMessage(message)

// Fetch the data in order to validate whether the alias is the personal email adress or not
self.emailDelegate?.autofillUserScriptDidRequestUserData(self) { username, _, _, _ in
if let username = username {
let autogenerated = alias != username && autosave // Only consider private emails as autogenerated
let credentials = AutofillUserScript.IncomingCredentials(username: "\(alias)@\(EmailManager.emailDomain)", password: nil, autogenerated: autogenerated)
let data = DetectedAutofillData(identity: nil, credentials: credentials, creditCard: nil, trigger: .emailProtection)
self.vaultDelegate?.autofillUserScript(self, didRequestStoreDataForDomain: domain, data: data)

replyHandler("""
{
"alias": "\(alias)"
}
""")
}
}
""")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,23 @@ extension AutofillUserScript {
}

let username: String?
let password: String
let autogenerated: Bool
let password: String?
var autogenerated: Bool

init(username: String?, password: String, autogenerated: Bool = false) {
init(username: String?, password: String?, autogenerated: Bool = false) {
self.username = username
self.password = password
self.autogenerated = autogenerated
}

init?(autofillDictionary: [String: Any]) {
guard let credentialsDictionary = autofillDictionary[Constants.credentialsKey] as? [String: Any],
let password = credentialsDictionary[Constants.passwordKey] as? String else {
return nil
}
guard let credentialsDictionary = autofillDictionary[Constants.credentialsKey] as? [String: Any] else {
return nil
}

// Usernames are optional, as the Autofill script can pass a generated password through without a corresponding username.
self.init(username: credentialsDictionary[Constants.usernameKey] as? String,
password: password,
password: credentialsDictionary[Constants.passwordKey] as? String,
autogenerated: (credentialsDictionary[Constants.autogeneratedKey] as? Bool) ?? false)
}

Expand All @@ -229,11 +228,11 @@ extension AutofillUserScript {
}

public let identity: SecureVaultModels.Identity?
public let credentials: IncomingCredentials?
public var credentials: IncomingCredentials?
public let creditCard: SecureVaultModels.CreditCard?
public let trigger: GetTriggerType?

var hasAutogeneratedPassword: Bool {
var hasAutogeneratedCredentials: Bool {
return credentials?.autogenerated ?? false
}

Expand Down Expand Up @@ -468,6 +467,7 @@ extension AutofillUserScript {
case autoprompt
case formSubmission
case passwordGeneration
case emailProtection
}

// https://github.com/duckduckgo/duckduckgo-autofill/blob/main/src/deviceApiCalls/schemas/getAutofillData.params.json
Expand All @@ -483,11 +483,8 @@ extension AutofillUserScript {
}

let domain = hostForMessage(message)

if request.mainType == .credentials, request.subType == .password, let generatedPassword = request.generatedPassword?.value, !generatedPassword.isEmpty {
afterxleep marked this conversation as resolved.
Show resolved Hide resolved
vaultDelegate?.autofillUserScriptDidOfferGeneratedPassword(self,
password: generatedPassword) { useGeneratedPassword in

vaultDelegate?.autofillUserScriptDidOfferGeneratedPassword(self, password: generatedPassword) { useGeneratedPassword in
let action = useGeneratedPassword ? RequestGeneratedPasswordResponse.GeneratedPasswordResponseAction.acceptGeneratedPassword : RequestGeneratedPasswordResponse.GeneratedPasswordResponseAction.rejectGeneratedPassword
let response = RequestGeneratedPasswordResponse(success: RequestGeneratedPasswordResponse.GeneratedPasswordResponseContents(action: action))
if let json = try? JSONEncoder().encode(response), let jsonString = String(data: json, encoding: .utf8) {
Expand Down
Loading