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

API design question around getting low, high, (low+high) entropy values #233

Open
miketaylr opened this issue May 12, 2021 · 2 comments
Open

Comments

@miketaylr
Copy link
Collaborator

Some feedback we got from @mikewest, in a blink-dev I2P:

Including low-entropy hints along with high-entropy hints in UADataValues seems like a reasonable thing to do, giving developers a clear way of requesting "UA Stuff", which seems like the way folks would be expected to use getHighEntropyValues(). There's something of a question there around API design (should we have a getAllValues() instead? Or a getJustLowEntropyValues()?) that seems like it would benefit from broader circulation.

The rationale for returning low-entropy hints along with high-entropy hints from getHighEntropyValues() is captured in #222 (comment), but essentially, if values change from high to low, we risk breaking deployed code.

Currently we have getHighEntropyValues(), and if you want low-entropy values, you'll have to grab those off of the NavigatorUAData interface directly.

There's a few scenarios where what Mike is proposing may be useful, and probably more that I'm not thinking about:

  1. you want all the data (this assumes the UA is willing to give it to you), in a single API call
  2. a hint has somehow transitioned from high to low entropy, or from low to high (we have half a solution for this)
  3. you want a promise-y API to collect all the low entropy hints (otherwise you have to iterate over NavigatorUAData yourself and return your own promise)

I'm curious if other folks have thoughts here. @erik-anderson @amtunlimited @rowan-m @othermaciej

(This may also be an area where it's useful for some developers to get more familiar with the API so they can comment on ergonomics).

@rowan-m
Copy link

rowan-m commented May 13, 2021

  1. you want all the data (this assumes the UA is willing to give it to you), in a single API call

I'm trying to think of a use case for this beyond wanting to get a signature / fingerprint. As in, a call like this would presumably return any new hints that got added in the future. If I need that information for something functional, I should be explicitly requesting the token.

Something like option 3 seems kind of nice to me. Leave the default low-entropy values available as simple attributes so I don't need to mess around with a Promise, but likewise give me a general getValues() or similar that will accept all valid tokens. e.g.

navigator.userAgentData
.getValues(["architecture", "mobile"])
.then(ua => { console.log(ua) });
{
  "architecture": "x86",
  "mobile": false
}

@amtunlimited
Copy link
Contributor

Yeah, I like the ergo of having everything in one function if you need to do something Promise-y anyways. My worry is trying to turn a low entropy hint back into a high one.

I'd almost be tempted to get rid of the non-Promise getters and say promises for everything if it wasn't so insanely disruptive to switch to async

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

No branches or pull requests

3 participants