Skip to content

Commit ba87e8e

Browse files
committedOct 3, 2022
feat: Update device-helper interface
Used in flagshipapp and consumers

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed
 

‎packages/cozy-device-helper/src/flagship.ts

+16-28
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,34 @@ export enum FlagshipRoutes {
88
Stack = 'stack'
99
}
1010

11-
export enum BiometryType {
12-
Face = 'Face',
13-
FaceID = 'FaceID',
14-
Fingerprint = 'Fingerprint',
15-
Iris = 'Iris',
16-
TouchID = 'TouchID'
17-
}
11+
export type BiometryType = 'TouchID' | 'FaceID' | 'Biometrics'
1812

1913
export interface FlagshipMetadata {
20-
capabilities?: {
21-
biometryType?: BiometryType
22-
}
23-
hasBiometry?: boolean
14+
biometry_available?: boolean
15+
biometry_type?: BiometryType
2416
immersive?: boolean
2517
navbarHeight?: number
2618
platform?: Record<string, unknown>
2719
route?: FlagshipRoutes
28-
settings?: {
29-
PINEnabled?: boolean
30-
autoLockDelay?: number
31-
autoLockEnabled?: boolean
32-
biometryEnabled?: boolean
33-
}
20+
settings_PINEnabled?: boolean
21+
settings_autoLockDelay?: number
22+
settings_autoLockEnabled?: boolean
23+
settings_biometryEnabled?: boolean
3424
statusBarHeight?: number
3525
version?: string
3626
}
3727

38-
const getGlobalWindow = (): Window => {
39-
if (typeof window !== 'undefined') return window
40-
else {
41-
log(
42-
'error',
43-
`"window" is not defined. This means that getGlobalWindow() shouldn't have been called and investigation should be done to prevent this call`
44-
)
45-
return undefined
46-
}
47-
}
28+
const getGlobalWindow = (): (Window & typeof globalThis) | undefined =>
29+
typeof window !== 'undefined'
30+
? window
31+
: (log(
32+
'error',
33+
`"window" is not defined. This means that getGlobalWindow() shouldn't have been called and investigation should be done to prevent this call`
34+
),
35+
undefined)
4836

4937
export const getFlagshipMetadata = (): FlagshipMetadata =>
50-
getGlobalWindow()?.cozy?.flagship || {}
38+
getGlobalWindow()?.cozy?.flagship ?? {}
5139

5240
export const isFlagshipApp = (): boolean =>
5341
getGlobalWindow()?.cozy?.flagship !== undefined

0 commit comments

Comments
 (0)
Please sign in to comment.