ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

New User-Agent Client Hints

Open zxlin opened this issue 4 years ago • 9 comments

W3C has put out a draft for new user-agent hints: https://wicg.github.io/ua-client-hints/

Also reference: https://tools.ietf.org/html/draft-west-ua-client-hints-00

Is there a plan to support these in the upcoming months? It looks like Chrome is going to freeze User-Agent strings this year.

  • Chrome 81 (mid-March 2020) - Google plans to show warnings in the Chrome console for web pages that read the UA string, so developers can adjust their website code.
  • Chrome 83 (early June 2020) - Google will freeze the Chrome browser version in the UA string and unify OS versions
  • Chrome 85 (mid-September 2020) - Google will unify the UA desktop OS string as a common value for desktop browsers. Google will also unify mobile OS/device strings as a similarly common value.

https://www.zdnet.com/article/google-to-phase-out-user-agent-strings-in-chrome/

zxlin avatar Jan 15 '20 18:01 zxlin

User-Agent Client Hints spec define HTTP request header and JavaScript DOM API. Latest spec and Chrome 82+(canary) remove navigation.getUserAgent() JavaScript API and introduce navigation.userAgentData object.

NavigatorUAData return low entropy values synchronously, On the one hand, NavigatorUAData return high entropy values asynchronously.

// Low Entropy Values
console.log(navigator.userAgentData.mobile); // false
copy(navigator.userAgentData.uaList); // [{ "brand": "Google Chrome", "version": "82" }]

// High Entropy Values
navigator.userAgentData.getHighEntropyValues(["platform", "platformVersion", "architecture", "model"]).then(res => console.log(res)); 
/* {architecture: "Intel", model: "", platform: "Mac OS X", platformVersion: "10_15_3", uaFullVersion: ""} */

Refs:

azu avatar Mar 16 '20 12:03 azu

@faisalman any plan to incorporate this into the lib?

ghost avatar Mar 27 '20 17:03 ghost

^ Ditto

pardoman avatar Dec 03 '20 02:12 pardoman

As of Feb 24 2021, this is the status of Chrome freezing the UA string

No, the UA string will not be frozen in Chrome 89. We've yet to release a firm timeline.

jpodwys avatar Apr 01 '21 16:04 jpodwys

Hello, the Blink / Chromium team has recently released an official communication with timeline details on the reduction of the User-Agent:

sandrolain avatar May 20 '21 05:05 sandrolain

I'd also be interested in this. Are there any plans to add support?

beatrizz avatar Jun 30 '21 14:06 beatrizz

Chrome now reports

A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.

To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.

Note that for performance reasons, only the first access to one of the properties is shown

UCS-Kris avatar Nov 09 '21 14:11 UCS-Kris

Is there any support planned? UA strings are the same now with Chrome 95+ between Windows 10 and 11 and between MacOS 10, 11 and 12.

szbotms avatar Nov 17 '21 13:11 szbotms

+1 on this

kozmanbalint avatar Jun 22 '22 04:06 kozmanbalint

Screenshot_2022-12-01-14-01-50-888_com chrome can

Already taken affect on Chrome 110

tiamed avatar Dec 01 '22 06:12 tiamed

+1 on this 👍

munepom avatar Dec 08 '22 08:12 munepom

+1 on this too

victorresola avatar Mar 07 '23 09:03 victorresola

Starting from version 2.0, user-agent client hints can be used as an addition to existing user-agent by explicitly calls withClientHints() method.

faisalman avatar Apr 03 '23 01:04 faisalman