MCPcopy
hub / github.com/fingerprintjs/fingerprintjs / getUserAgentData

Function getUserAgentData

src/sources/user_agent_data.ts:53–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51 * @see https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API
52 */
53export default async function getUserAgentData(): Promise<StableUserAgentData | undefined> {
54 const uaData = (navigator as unknown as { userAgentData?: NavigatorUAData }).userAgentData
55
56 if (!uaData) {
57 return undefined
58 }
59
60 const filteredBrands = uaData.brands.filter(({ brand }) => !isGreaseBrand(brand)).map(({ brand }) => brand)
61
62 const brands = filteredBrands.length > 1 ? filteredBrands.filter((b) => b !== 'Chromium') : filteredBrands
63
64 const result: StableUserAgentData = {
65 brands,
66 mobile: uaData.mobile,
67 platform: uaData.platform,
68 }
69
70 if (uaData.getHighEntropyValues) {
71 try {
72 const highEntropy = await uaData.getHighEntropyValues(['architecture', 'bitness', 'model', 'platformVersion'])
73 result.architecture = highEntropy.architecture
74 result.bitness = highEntropy.bitness
75 result.model = highEntropy.model
76 result.platformVersion = highEntropy.platformVersion
77 } catch (error) {
78 if (error instanceof DOMException && error.name === 'NotAllowedError') {
79 result.highEntropyStatus = HighEntropyStatus.NotAllowed
80 } else {
81 throw error
82 }
83 }
84 }
85
86 return result
87}

Callers 1

Calls 2

isGreaseBrandFunction · 0.85
getHighEntropyValuesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…