MentraOS / mobile /src /utils /pairing /securePairingFeature.ts
Anirudh1950's picture
Add files using upload-large-folder tool
68465df verified
Raw History Blame Contribute Delete
706 Bytes
/**
* Expo Router stores route params as strings, so a legacy advertisement's
* `false` arrives as `"false"`. Missing means the scan did not say.
*/
export const parseOptionalBoolean = (value: unknown): boolean | undefined => {
if (typeof value === "boolean") return value
if (value === "true") return true
if (value === "false") return false
return undefined
}
/**
* Prefer the device payload. JSON keeps the original boolean when the separate
* route flag is dropped or stringified.
*/
export const advertisedSecurePairingCapable = (routeValue: unknown, deviceValue: unknown): boolean | undefined =>
parseOptionalBoolean(deviceValue) ?? parseOptionalBoolean(routeValue)