Open History to see the last commit
1import type { AuthClientPresentationMetadata } from "@t3tools/contracts";
2import * as Device from "expo-device";
3import { Platform } from "react-native";
4
5export function authClientMetadata(appVersion?: string): AuthClientPresentationMetadata {
6 const osMajorVersion = Number.parseInt(Device.osVersion?.split(".")[0] ?? "", 10);
7 const deviceModel = Device.modelName?.trim();
8
9 return {
10 // oxlint-disable-next-line t3code/no-untranslated-copy -- product name
11 label: "T3 Code Mobile",
12 deviceType:
13 Device.deviceType === Device.DeviceType.TABLET
14 ? "tablet"
15 : Device.deviceType === Device.DeviceType.PHONE
16 ? "mobile"
17 : "unknown",
18 ...(Platform.OS === "ios" ? { os: "iOS" } : Platform.OS === "android" ? { os: "Android" } : {}),
19 ...(Number.isFinite(osMajorVersion) && osMajorVersion > 0 ? { osMajorVersion } : {}),
20 ...(deviceModel ? { deviceModel } : {}),
21 surface: "mobile",
22 ...(appVersion ? { appVersion } : {}),
23 };
24}