Skip to content
Source
Sign inSign up
Open History to see the last commit

authClientMetadata.ts

23 lines916 Bytes

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 label: "T3 Code Mobile",
11 deviceType:
12 Device.deviceType === Device.DeviceType.TABLET
13 ? "tablet"
14 : Device.deviceType === Device.DeviceType.PHONE
15 ? "mobile"
16 : "unknown",
17 ...(Platform.OS === "ios" ? { os: "iOS" } : Platform.OS === "android" ? { os: "Android" } : {}),
18 ...(Number.isFinite(osMajorVersion) && osMajorVersion > 0 ? { osMajorVersion } : {}),
19 ...(deviceModel ? { deviceModel } : {}),
20 surface: "mobile",
21 ...(appVersion ? { appVersion } : {}),
22 };