Skip to content

Basic browser detection and setting as query param in deeplink#746

Merged
esune merged 12 commits intoopenwallet-foundation:mainfrom
Gavinok:detect-browser
Mar 31, 2025
Merged

Basic browser detection and setting as query param in deeplink#746
esune merged 12 commits intoopenwallet-foundation:mainfrom
Gavinok:detect-browser

Conversation

@Gavinok
Copy link
Contributor

@Gavinok Gavinok commented Mar 19, 2025

This is intended to resolve help resolve #731
It simply appends a query param browser to the deeplink giving the name of the current browser. Here is an example where the name was Mobile Safari

bcwallet://aries_proof-request?c_i=eyJAaWQiOiAiZTN...aW9uIiwgInByaW9yaXR5IjogMH1dLCAiaGFuZHNoYWtlX3Byb3RvY29scyI6IFtdfQ==/?browser=Mobile%20Safari 

We can also integrate the new ua parser to detect the browser type as either mobile or desktop if we decide to go forward with this approach

Here are all the user options we can support matching against https://github.com/faisalman/ua-parser-js/blob/af8acf9078e5952a496d395464af8178ad55ccaf/src/enums/ua-parser-enums.js#L10-L163

Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
@coveralls
Copy link

coveralls commented Mar 19, 2025

Pull Request Test Coverage Report for Build 14137165330

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 85.272%

Totals Coverage Status
Change from base Build 14112189798: 0.0%
Covered Lines: 689
Relevant Lines: 808

💛 - Coveralls

@Gavinok Gavinok requested review from esune and loneil March 19, 2025 18:23
@loneil
Copy link
Contributor

loneil commented Mar 19, 2025

Note passing browser=Mobile%20Safari doesn't inform the BC Wallet which deeplink prefix to use so somewhere would need to be a mapping for the actual app deeplink prefixes (for every single browser app?)

Also this wouldn't cover a case where a calling app (like the Google app) doesn't have it's own UA app identifier. IE on that what, from what I can tell, you'd just get "Chrome" and not know to deeplink back to the Google search app.

Maybe this limited support for major browsers would be fine...?

@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 19, 2025

@esune
Copy link
Member

esune commented Mar 19, 2025

Note passing browser=Mobile%20Safari doesn't inform the BC Wallet which deeplink prefix to use so somewhere would need to be a mapping for the actual app deeplink prefixes (for every single browser app?)

Also this wouldn't cover a case where a calling app (like the Google app) doesn't have it's own UA app identifier. IE on that what, from what I can tell, you'd just get "Chrome" and not know to deeplink back to the Google search app.

Maybe this limited support for major browsers would be fine...?

I don't think the mapping should live in VC-AuthN since the browsers support is ultimately dependent on the app and which browsers are on the device.

Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
Gavinok and others added 2 commits March 20, 2025 09:56
Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
@Gavinok Gavinok requested a review from loneil March 20, 2025 18:25
@loneil
Copy link
Contributor

loneil commented Mar 20, 2025

Get an error trying the deep link on the wallet

image

Probably the encoded space ?browser=Mobile%20Safari

but we likely shouldn't be passing that display name anyhow since it won't mean anything to the wallet, the wallet will have to know the custom URI for every browser it can go back to with this pattern anyways, so it would need to maintain some mapping (unless it's determined that URI mapping should be done in VCAuth but I don't think it's appropriate for the browser to be handling that). So if we go with this solution I would just use the key instead of the value of that mapping object (IE SAFARI_MOBILE for example)

@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 20, 2025

Ya as far as I know we are going to have to wait on this one to be supported by the wallet for it to work. I agree the mapping would likely be better just using the enum entry rather than the string. Due to the interdependence I still question if this is the best approach but don't have any better solution as of now

@loneil
Copy link
Contributor

loneil commented Mar 20, 2025

Ok regardless of that we can't do the display name with a space in it I don't think, is there a way to access the key from that object instead of the value? "SAFARI_MOBILE" instead of "Mobile Safari", if I try that it doesn't blow up the wallet, it's just an unused parameter.

@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 20, 2025

Sure thing I'll change that now

@loneil
Copy link
Contributor

loneil commented Mar 21, 2025

For thought later... since this is a specific pattern we are trying with BC implementation (might not be standard?) we could consider only putting this code in the BC gov template page and not the basic generic VCAtuth version, as someone can run VCAuth with a different deep link prefix that doesn't call the BC Wallet.

@esune
Copy link
Member

esune commented Mar 24, 2025

For thought later... since this is a specific pattern we are trying with BC implementation (might not be standard?) we could consider only putting this code in the BC gov template page and not the basic generic VCAtuth version, as someone can run VCAuth with a different deep link prefix that doesn't call the BC Wallet.

That is a good point. The benefit of pushing it out in this repo is that we are more likely to get visibility/feedback from other users who may be facing (and resolving) the same problem already?

Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@google.com>
@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 25, 2025

I could not get the object from UAParser since it is not in the minified js, but I was able to replicate what is needed to get the browser. I removed the mobile info since, as of now, it seems unnecessary. I also added the info to the debugging element

@Gavinok Gavinok requested a review from loneil March 26, 2025 19:07
Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@google.com>
@esune esune self-requested a review March 27, 2025 18:46
Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@google.com>
@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 27, 2025

found an edge case with Opera Mobile but it is fixed now. If any identifiers will contain a space we now simply go for the first word

esune
esune previously approved these changes Mar 28, 2025
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

I think this works, we'll have to do more testing in conjunction with the wallet team to validate

Copy link
Contributor

@loneil loneil left a comment

Choose a reason for hiding this comment

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

Getting error on 1.0.23 called from iPad chrome right now, looking into but shouldn't merge at the momment

image

@Gavinok
Copy link
Contributor Author

Gavinok commented Mar 28, 2025

@loneil Any idea what the user agent was?

Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@google.com>
@loneil
Copy link
Contributor

loneil commented Mar 28, 2025

@loneil Any idea what the user agent was?

This happens on anything iOS, the URL format is invalid URL with the 2 ?s in it

Signed-off-by: Gavin Jaeger-Freeborn <gavinfreeborn@google.com>
@Gavinok Gavinok requested a review from loneil March 28, 2025 20:35
Copy link
Contributor

@loneil loneil left a comment

Choose a reason for hiding this comment

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

Think this looks good now. Opening in the BC Wallet it just sends the new unused browser query param around and it doesn't cause any errors. I forced a exception in the handling code and it worked as expected.

So think we can add this to the BC Gov template and deploy that to the dev env. Can coordinate with the BC Wallet team to see what can happen with that param.

Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

👍🏻 let's do some extra testing once merged!

@esune esune merged commit 55fc9c9 into openwallet-foundation:main Mar 31, 2025
6 checks passed
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.

Same-device flow return hint

4 participants