Skip to content

Support rendering URLs inside sync barcodes #5944

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

CDRussell
Copy link
Member

@CDRussell CDRussell commented Apr 21, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/608920331025315/task/1209921184459923?focus=true

Description

Allows sync setup codes which appear in the QR barcode to be URL-based.

  • Note, this is disabled by default.
  • Note, this PR doesn’t handle scanning a URL-based barcode which will be in a higher branch on this stack.

Steps to test this PR

Get two devices (or one device + one emulator) as you’ll need to scan barcodes.

Feature disabled, everything works as normal

  • The feature is disabled by default, so just fresh install the app from this branch on both devices
  • For each of the following scenarios, make sure you can set up sync AND ensure that the “code to include” in logcat is NOT a URL:
    • Scanning barcode when both devices signed out
    • Scanning barcode when both devices signed in
    • Scanning barcode when scanning device is the only one signed out
    • Scanning barcode when scanning device is the only one signed in
    • Manually entering codes for the same scenarios…

Feature enabled

  • Enable syncSetupBarcodeIsUrlBased feature flag on a device. Note, we expect the URL to be in the barcode but the other device won’t be able to scan it successfully (implemented in a higher branch on this stack) so don’t worry about that part.
  • Repeat the scenarios above,
    • ensuring the barcode is a URL when showing the barcode (e.g., scan it from system camera app and inspect it). URL should match the spec from the tech design.
    • ensuring when manually sharing the code it does NOT use a URL

Copy link
Member Author

CDRussell commented Apr 21, 2025

@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 6 times, most recently from c1e559b to b3a3796 Compare April 24, 2025 16:38
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 2 times, most recently from a1b61b8 to 4ff8eae Compare April 25, 2025 12:42
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 6 times, most recently from 1dc1ad0 to 2ada4fb Compare April 25, 2025 15:42
@CDRussell CDRussell changed the title Support URLs inside sync barcodes Support rendering URLs inside sync barcodes Apr 25, 2025
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 2 times, most recently from 1072477 to 444943d Compare April 25, 2025 16:18
@CDRussell CDRussell marked this pull request as ready for review April 25, 2025 16:23
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 3 times, most recently from 860b063 to 61a59a3 Compare April 29, 2025 09:50
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch from 61a59a3 to 61eaf09 Compare May 5, 2025 12:25
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 2 times, most recently from 68e00fa to 3e35d17 Compare May 5, 2025 12:37
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

LGTM

I would like to discuss if possible the responsibility of SyncBarcodeDecorator, and how feasible do you see moving the logic inside SyncAccountRepository. If you are ok and prefer to do it later in the stack, I'm fine with that.

@CDRussell
Copy link
Member Author

how feasible do you see moving the logic inside SyncAccountRepository

Will take a look at this and ping back with thoughts

@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 3 times, most recently from eb3b7ad to e832503 Compare May 7, 2025 13:13
@CDRussell CDRussell requested a review from cmonfortep May 7, 2025 13:15
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 3 times, most recently from 488f371 to 9d657cb Compare May 7, 2025 13:58
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

All good, thanks for the addressing the comments 👍

@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch 2 times, most recently from 65d96d9 to 0b84d73 Compare May 12, 2025 14:23
@CDRussell CDRussell force-pushed the feature/craig/sync_barcode_url_support branch from 0b84d73 to b3e468f Compare May 13, 2025 10:35
Copy link
Member Author

CDRussell commented May 13, 2025

Merge activity

  • May 13, 9:42 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • May 13, 9:42 AM EDT: @CDRussell merged this pull request with Graphite.

@CDRussell CDRussell merged commit a891cc9 into develop May 13, 2025
6 checks passed
@CDRussell CDRussell deleted the feature/craig/sync_barcode_url_support branch May 13, 2025 13:42
CDRussell added a commit that referenced this pull request May 13, 2025
Task/Issue URL: https://app.asana.com/1/137249556945/project/72649045549333/task/1209921186465304?focus=true 

### Description

#5944 allows the barcodes to be rendered as URL-based; this PR is the other side of the coin in adding support for scanning URL-based sync setup barcodes.

#### A note on feature flagging

For feature flagging around URL-based barcodes, I’ve separated out the ability to render them vs the ability to scan them. I think this will help the logistics around rolling it out, but sense-check that for me.

| Feature flag | Description | Default state |
|--------|--------|--------|
|`syncSetupBarcodeIsUrlBased` | Whether to render URL-based or plain barcodes  | Off by default |
| `canScanUrlBasedSyncSetupBarcodes` | Whether we can scan URL-based codes | On by default (it’s a kill-switch |


### Steps to test this PR

You’ll need two devices, at least one of them being a real device so you can scan the barcode using its camera.

#### Scanning a `connect` code

- [x] Log out of sync on both devices
- [x] Choose `Sync with another device` on both
- [x] Scan the barcode **using the system camera** first, to verify you are dealing with a URL-based barcode
- [x] Scan the barcode from inside sync settings; verify sync sets up correctly


#### Scanning an `exchange` code

- [x] Log out of sync on a physical device; stay logged in on the other
- [x] Choose `Sync with another device` on both
- [x] Using physical device, scan the barcode **using the system camera** first, to verify you are dealing with a URL-based barcode
- [x] Using physical device, scan the barcode from inside sync settings; verify sync sets up correctly



#### Scanning a plaintext `recovery` code

- [x] Log out of sync on a physical device; stay logged in on the other
- [x] On the logged-in device, disable `exchangeKeysToSyncWithAnotherDevice`
- [x] Choose `Sync with another device` on both devices
- [x] Using physical device, scan the barcode **using the system camera** first, and verify you are **not** dealing with a URL-based barcode; this should be just the b64-encoded recovery code (recovery codes aren’t allowed in URLs, so disabling `exchangeKeysToSyncWithAnotherDevice` means URL-based codes won’t show either)
- [x] Using physical device, scan the barcode from inside sync settings; verify sync sets up correctly


#### Scanning a URL-based `recovery` code
This isn’t acceptable so we won’t generate URLs containing recovery codes, but let’s test what happens if one is scanned. [Barcode for testing what happens if you scan a recovery code inside a URL](https://app.asana.com/1/137249556945/task/1210110837732281?focus=true)

- [x] Log out of sync on a physical device (don’t need the other device for this test)
- [x] Choose `Sync with another device` on the physical device
- [x] Using physical device, scan the barcode linked above from inside sync settings; verify sync is **not** set up and you see an error message. In the logs, you’ll see `Recovery code found inside a URL which is not acceptable`
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.

2 participants