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

Add FXIOS-5694 [v111] credit card autofill / capture PoC #12787

Merged
merged 14 commits into from
Feb 3, 2023

Conversation

issammani
Copy link
Collaborator

@issammani issammani commented Dec 22, 2022

This PR:

✅ Adds two way communication between ios and js.
✅ Adds webpack plugin to resolve custom resource uris.
✅ Extracts necessary logic from desktop to capture credit card fields.

⚠️ NOTE1:
Client/Assets/CC_Script/CreditCardAutofill.js and Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/CreditCardHelper.js contain minimal custom code extracted from desktop to make the poc work. These will eventually be replaced to use shared code from desktop. All other files in Assets/CC_Script are shared as is from desktop, so eventually we can pull these using the github action.

⚠️ NOTE2: The [corresponding phabricator patches]( still a WIP ):

⚠️ NOTE3:
The code will not work with all credit card forms. We need to migrate fathom eventually to iOS to test things properly. But for now I used this [https://mozilla.github.io/form-fill-examples/basic_cc.html] for testing and I think it's enough for a PoC.

Current State of the PoC

@nbhasin2 will eventually add a UI to select credit cards, but for now I just fill a mock credit card in the form.

Screen.Recording.2023-01-17.at.12.15.26.mov

@nbhasin2
Copy link
Contributor

nbhasin2 commented Jan 4, 2023

@issammani is this ready for review as I see WIP but is not a draft?

@issammani issammani changed the title [WIP] Credit card capture PoC Credit card autofill/capture PoC Jan 17, 2023
@issammani
Copy link
Collaborator Author

@nbhasin2 @galich this PR is ready for review now. I will open a follow up PR to address some further work. But I think this should be enough for a PoC.

@lmarceau
Copy link
Contributor

FYI, build failed due to swiftlint errors described here.

@lmarceau lmarceau changed the title Credit card autofill/capture PoC Add [v111] Credit card autofill/capture PoC Jan 17, 2023
Comment on lines 28 to 36
let response: [String: Any] = [
"data": [
"cc-name": "Jane Doe",
"cc-number": "5555555555554444",
"cc-exp-month": "05",
"cc-exp-year": "2028",
],
"id": request["id"]!,
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a POC we should leave this empty and fill it in when we are actually testing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commented and added a todo in 3c9d580

@@ -1768,6 +1768,9 @@ extension BrowserViewController: TabDelegate {
tab.addContentScript(logins, name: LoginsHelper.name())
}

let creditCardHelper = CreditCardHelper(tab: tab)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should wrap this around a feature flag as this is a POC and shouldn't get merged directly to Firefox iOS unless its feature is complete.

Since it might take multiple PRs to reach there I would recommend adding a comment with Jira ticket and commenting out this piece of code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commented and added a todo in 3c9d580

@nbhasin2
Copy link
Contributor

I also didn't see the use of userscript manager was that because of webpack compatibility issue?

Copy link
Contributor

@nbhasin2 nbhasin2 left a comment

Choose a reason for hiding this comment

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

Thanks for the POC @issammani Although this is good but let's clean this up so it's mergeable.

Ideally, we should add a component to encapsulate all details into a single area if possible but I understand that it might not be feasible in this PR.

I would also recommend moving the POC over to SwiftFox where you can test your scripts much more freely as compared to Firefox iOS

Will ping you in slack for further discussion.

@issammani
Copy link
Collaborator Author

@nbhasin2 following our discussion on the webpack plugin. This is needed for desktop imports that use uris. For instance, in this file:

import { FormAutofillUtilsShared } from "resource://gre/modules/FormAutofillUtils.shared.mjs";
import { CreditCard } from "resource://gre/modules/CreditCard.sys.mjs";
import { LabelUtils } from "resource://gre/modules/LabelUtils.mjs";
import { FieldScanner } from "resource://gre/modules/FieldScanner.mjs";

Copy link
Contributor

@nbhasin2 nbhasin2 left a comment

Choose a reason for hiding this comment

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

@issammani Skipped the js files as those will get updated later on but added a few nits to streamline the code

You can either take my suggestions or modify it yourself and after BR is green we are good to push :)

@nbhasin2 nbhasin2 closed this Feb 1, 2023
@nbhasin2 nbhasin2 reopened this Feb 1, 2023
@nbhasin2
Copy link
Contributor

nbhasin2 commented Feb 1, 2023

image

This is green but going to rerun one more time for suggested additions

@issammani
Copy link
Collaborator Author

@issammani Skipped the js files as those will get updated later on but added a few nits to streamline the code

You can either take my suggestions or modify it yourself and after BR is green we are good to push :)

@nbhasin2 thanks for the suggestions and updating the PR. Looks good from my side. BR is failing though. I am tempted to push an empty commit just to have run once again. Do we have a better way to do so ?

@nbhasin2
Copy link
Contributor

nbhasin2 commented Feb 1, 2023

@issammani https://app.bitrise.io/build/54a6820e-666f-413d-997c-0310b39c3ade

I started another build, no idea why it failed 🤷🏼‍♂️

Try if you can run it locally as this passed before.

@isabelrios
Copy link
Contributor

Messages
📖 Project coverage: 29.03%
📖 Edited 3 files
📖 Created 9 files

Client.app: Coverage: 25.72

File Coverage
CreditCardHelper.swift 0.0% ⚠️
BrowserViewController.swift 20.61% ⚠️

Generated by 🚫 Danger Swift against a7476f3

@nbhasin2
Copy link
Contributor

nbhasin2 commented Feb 2, 2023

The failed test has nothing to do with this PR.

Will look into it tomorrow but most likely merge it in as it could be a random failure from BR

@nbhasin2 nbhasin2 changed the title Add [v111] Credit card autofill/capture PoC Add FXIOS-5694 [v111] credit card autofill / capture PoC Feb 3, 2023
@nbhasin2 nbhasin2 merged commit 5c95161 into mozilla-mobile:main Feb 3, 2023
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