-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfingerprint.ts
More file actions
44 lines (41 loc) · 1.28 KB
/
fingerprint.ts
File metadata and controls
44 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as Clipboard from 'expo-clipboard';
import * as Localization from 'expo-localization';
import { Dimensions, PixelRatio, Platform } from 'react-native';
import DeviceInfo from 'react-native-device-info';
type ProbabilisticFingerprint = {
platform: string;
model: string;
manufacturer: string;
systemVersion: string;
screenWidth: number;
screenHeight: number;
scale: number;
locale: Localization.Locale[];
timezone: string | null | undefined;
userAgent: string;
appVersion: string;
timestamp: number;
pastedLink?: string;
};
export const getProbabilisticFingerprint = async (
shouldUseClipboard: boolean
): Promise<ProbabilisticFingerprint> => {
const { width, height } = Dimensions.get('window');
return {
platform: Platform.OS,
model: DeviceInfo.getModel(),
manufacturer: await DeviceInfo.getManufacturer(),
systemVersion: DeviceInfo.getSystemVersion(),
screenWidth: width,
screenHeight: height,
scale: PixelRatio.get(),
locale: Localization.getLocales(),
timezone: Localization.getCalendars()[0]?.timeZone,
userAgent: await DeviceInfo.getUserAgent(),
appVersion: DeviceInfo.getVersion(),
timestamp: Date.now(),
pastedLink: shouldUseClipboard
? await Clipboard.getStringAsync()
: undefined,
};
};