File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ declare module 'cozy-client' {
119119 }
120120 subdomain : 'flat' | 'nested'
121121 locale : string
122+ flags ?: Record < string , boolean , null >
122123 }
123124
124125 export const useClient = ( ) : CozyClient => CozyClient as CozyClient
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import CozyClient from 'cozy-client'
22import Minilog from 'cozy-minilog'
33
44import { LOCALSTORAGE_KEY_DELETING_DATA } from '@/consts'
5+
6+ import { ClientData } from '../common/DataProxyInterface'
57const log = Minilog ( '👷♂️ [Worker utils]' )
68
79interface SessionInfo {
@@ -16,12 +18,22 @@ interface SessionResponse {
1618}
1719
1820export const queryIsTrustedDevice = async (
19- client : CozyClient
21+ client : CozyClient ,
22+ clientData : ClientData
2023) : Promise < boolean > => {
2124 const resp : SessionResponse = await client
2225 . getStackClient ( )
2326 . fetchJSON ( 'GET' , '/settings/sessions/current' )
2427
28+ // Need to get the flag from clientData since cozy-flags are not fully initialized yet
29+ const flags = clientData . instanceOptions ?. flags as
30+ | Record < string , boolean >
31+ | undefined
32+
33+ if ( flags ?. [ 'dataproxy.force-trusted-device.enabled' ] ) {
34+ return true
35+ }
36+
2537 const isLongRun = resp ?. data ?. attributes ?. long_run
2638 const isUnDefined = isLongRun === undefined
2739
Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ const dataProxy: DataProxyWorker = {
132132
133133 // If the device is not trusted, we do not want to store any private data in Pouch
134134 // So use the PouchLink only if the user declared a trustful device for the given session
135- const isTrustedDevice = await queryIsTrustedDevice ( client )
135+ const isTrustedDevice = await queryIsTrustedDevice ( client , clientData )
136+ log . debug ( `Trusted Device: ${ isTrustedDevice } ` )
136137 // TODO: we should add the possibility to disable the pouchlink with a flag
137138 const links =
138139 isTrustedDevice && ! clientData . useRemoteData
You can’t perform that action at this time.
0 commit comments