diff --git a/app/container-imp.ts b/app/container-imp.ts index aa950cbbf..a54d05ae7 100644 --- a/app/container-imp.ts +++ b/app/container-imp.ts @@ -121,7 +121,7 @@ export class AppContainer implements Container { let onboarding = initialState.onboarding let personCredOfferDissmissed = initialState.dismissPersonCredentialOffer let environment = initialState.developer.environment - let remoteDebugging = initialState.remoteDebugging + let remoteDebugging = initialState.developer.remoteDebugging await Promise.all([ loadLoginAttempt().then((data) => { @@ -151,22 +151,30 @@ export class AppContainer implements Container { developer: { ...initialState.developer, environment, + remoteDebugging, }, - remoteDebugging: { ...initialState.remoteDebugging, ...remoteDebugging }, } - const { enabledAt } = state.remoteDebugging + const { enabledAt, sessionId } = state.developer.remoteDebugging if (enabledAt) { const autoDisableRemoteLoggingMinutesAgo = new Date( new Date().getTime() - autoDisableRemoteLoggingIntervalInMinutes * 60000 ) const isOlderThanAutoDisableInterval = enabledAt < autoDisableRemoteLoggingMinutesAgo - logger.info( - `Remote logging ${isOlderThanAutoDisableInterval ? 'expired' : 'enabled'}, last enabled at ${enabledAt}` - ) + if (!isOlderThanAutoDisableInterval) { + logger.remoteLoggingEnabled = !isOlderThanAutoDisableInterval + logger.sessionId = sessionId - logger.remoteLoggingEnabled = !isOlderThanAutoDisableInterval + logger.info( + `Remote logging enabled, last enabled at ${enabledAt}, session id: ${logger.sessionId}, ${sessionId}` + ) + } + // logger.info( + // `Remote logging ${ + // isOlderThanAutoDisableInterval ? 'expired' : 'enabled' + // }, last enabled at ${enabledAt}, session id: ${sessionId}` + // ) } dispatch({ type: DispatchAction.STATE_DISPATCH, payload: [state] }) diff --git a/app/package.json b/app/package.json index f37c373ab..b87d81f88 100644 --- a/app/package.json +++ b/app/package.json @@ -61,11 +61,11 @@ "@formatjs/intl-relativetimeformat": "9.3.1", "@hyperledger/anoncreds-react-native": "0.2.2", "@hyperledger/aries-askar-react-native": "0.2.1", - "@hyperledger/aries-bifold-core": "1.0.0-alpha.261", - "@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.261", - "@hyperledger/aries-bifold-verifier": "1.0.0-alpha.261", - "@hyperledger/aries-oca": "1.0.0-alpha.261", - "@hyperledger/aries-react-native-attestation": "1.0.0-alpha.261", + "@hyperledger/aries-bifold-core": "1.0.0-alpha.265", + "@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.265", + "@hyperledger/aries-bifold-verifier": "1.0.0-alpha.265", + "@hyperledger/aries-oca": "1.0.0-alpha.265", + "@hyperledger/aries-react-native-attestation": "1.0.0-alpha.265", "@hyperledger/indy-vdr-react-native": "0.2.2", "@react-native-async-storage/async-storage": "1.15.11", "@react-native-community/masked-view": "0.1.11", @@ -171,4 +171,4 @@ "react-test-renderer": "18.2.0", "typescript": "5.2.2" } -} \ No newline at end of file +} diff --git a/app/src/screens/Developer.tsx b/app/src/screens/Developer.tsx index 60151d771..ef9641b3d 100644 --- a/app/src/screens/Developer.tsx +++ b/app/src/screens/Developer.tsx @@ -222,7 +222,7 @@ const Settings: React.FC = () => { DeviceEventEmitter.emit(RemoteLoggerEventTypes.ENABLE_REMOTE_LOGGING, remoteLoggingEnabled) dispatch({ type: BCDispatchAction.ENABLE_REMOTE_DEBUGGING, - payload: [{ enabledAt: new Date() }], + payload: [{ enabledAt: new Date(), sessionId: logger.sessionId }], }) setRemoteLoggingEnabled(remoteLoggingEnabled) diff --git a/app/src/store.tsx b/app/src/store.tsx index 26437e9e8..b37344dd2 100644 --- a/app/src/store.tsx +++ b/app/src/store.tsx @@ -13,22 +13,23 @@ export interface IASEnvironment { iasPortalUrl: string attestationInviteUrl: string } + +export type RemoteDebuggingState = { + enabledAt?: Date + sessionId?: number +} export interface Developer { environment: IASEnvironment + remoteDebugging: RemoteDebuggingState } export interface DismissPersonCredentialOffer { personCredentialOfferDismissed: boolean } -export type RemoteDebuggingState = { - enabledAt: Date | undefined -} - export interface BCState extends BifoldState { developer: Developer dismissPersonCredentialOffer: DismissPersonCredentialOffer - remoteDebugging: RemoteDebuggingState } enum DeveloperDispatchAction { @@ -81,18 +82,20 @@ export const iasEnvironments: Array = [ }, ] +const remoteDebuggingState: RemoteDebuggingState = { + enabledAt: undefined, + sessionId: undefined, +} + const developerState: Developer = { environment: iasEnvironments[0], + remoteDebugging: remoteDebuggingState, } const dismissPersonCredentialOfferState: DismissPersonCredentialOffer = { personCredentialOfferDismissed: false, } -const remoteDebuggingState: RemoteDebuggingState = { - enabledAt: undefined, -} - export enum BCLocalStorageKeys { PersonCredentialOfferDismissed = 'PersonCredentialOfferDismissed', Environment = 'Environment', @@ -104,17 +107,20 @@ export const initialState: BCState = { ...defaultState, developer: developerState, dismissPersonCredentialOffer: dismissPersonCredentialOfferState, - remoteDebugging: remoteDebuggingState, } const bcReducer = (state: BCState, action: ReducerAction): BCState => { switch (action.type) { case RemoteDebuggingDispatchAction.ENABLE_REMOTE_DEBUGGING: { - const { enabledAt } = (action.payload || []).pop() - const remoteDebugging = { ...state.remoteDebugging, enabledAt } - const newState = { ...state, remoteDebugging } - - AsyncStorage.setItem(BCLocalStorageKeys.RemoteDebugging, JSON.stringify(remoteDebugging)) + const { enabledAt, sessionId } = (action.payload || []).pop() + const developer = { ...state.developer, remoteDebugging: { enabledAt, sessionId } } + const newState = { ...state, developer } + + if (enabledAt) { + AsyncStorage.setItem(BCLocalStorageKeys.RemoteDebugging, JSON.stringify(developer.remoteDebugging)) + } else { + AsyncStorage.removeItem(BCLocalStorageKeys.RemoteDebugging) + } return newState } diff --git a/yarn.lock b/yarn.lock index 9011f3d0a..1d8050ce3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4321,9 +4321,9 @@ __metadata: languageName: node linkType: hard -"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.261": - version: 1.0.0-alpha.261 - resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.261" +"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.265": + version: 1.0.0-alpha.265 + resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.265" peerDependencies: "@credo-ts/anoncreds": 0.5.3 "@credo-ts/askar": 0.5.3 @@ -4356,7 +4356,6 @@ __metadata: "@react-navigation/native": 6.0.6 "@react-navigation/stack": 6.0.11 axios: ^1.4.0 - credo-ts-indy-vdr-proxy-client: 0.1.2 i18next: ^21.4.0 lodash.flatten: ^4.4.0 lodash.startcase: ^4.4.0 @@ -4397,13 +4396,13 @@ __metadata: uuid: ^9.0.0 bin: bifold: bin/bifold - checksum: 02cb5ec8e28769aac9c64ded6576a0dfe7c8017e1bc2517a160ac2bf96831ba079d7bf49b42c37b7081992dc6841971b25b92589f297bb15069c88c5a2685ef9 + checksum: 7cab0c05e62db8186adc7045822cafda698fa79d6ec929301977c9ac52c16a8cc8704467d323fb02bd550983b5501c535ce250a7b8615ed732dccc5fa9a00d73 languageName: node linkType: hard -"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.261": - version: 1.0.0-alpha.261 - resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.261" +"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.265": + version: 1.0.0-alpha.265 + resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.265" peerDependencies: "@credo-ts/core": 0.5.3 axios: ^1.4.0 @@ -4411,43 +4410,43 @@ __metadata: react: ^18.2.0 react-native: ^0.72.5 react-native-logs: ^5.1.0 - checksum: 6f03210915aa111ef5a94b23800566771d2184780c983bf5f09bdc6bbea70c35ff229b5194d28f0cbd5905311572ab2bced5adfd934167fb14a5c6367c25714e + checksum: a24c8012a0a095616ef4d362fe7b8eec60c278830db48b1e2bb501cc2b08b94a48aa7a6fdf89b52e3fe0b3bb8134e58894d4ac29150c00e54a6c29e19e4964a1 languageName: node linkType: hard -"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.261": - version: 1.0.0-alpha.261 - resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.261" +"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.265": + version: 1.0.0-alpha.265 + resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.265" peerDependencies: "@credo-ts/anoncreds": 0.5.3 "@credo-ts/core": 0.5.3 "@credo-ts/react-hooks": ^0.6.0 "@hyperledger/anoncreds-shared": 0.2.2 react: ^18.2.0 - checksum: 1245e7f80fce3128295002f95dd67320ad4f9648a7ffba93e194e730ff4d388d3db783cd4ea3ce711e7e92aa6159a18c4e94d02c4a40bf0db2c60b6bc98c126b + checksum: 2ab593f4b39cdf89bf1631627461d78294863455081c6ae20f46191e96a919271c64fe7fbf3999e20e7f4496f739c0d128f06728d4eeda03f1ade41e6250a54c languageName: node linkType: hard -"@hyperledger/aries-oca@npm:1.0.0-alpha.261": - version: 1.0.0-alpha.261 - resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.261" +"@hyperledger/aries-oca@npm:1.0.0-alpha.265": + version: 1.0.0-alpha.265 + resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.265" dependencies: "@credo-ts/anoncreds": "npm:0.5.3" "@credo-ts/core": "npm:0.5.3" axios: "npm:^1.4.0" lodash.startcase: "npm:^4.4.0" react-native-fs: "npm:^2.16.6" - checksum: 4d1eed767fb99482fff12569cb8b21988353015583392fa0bda4cf9f577bb8ebaa818182c9b39d91e3a40c88d2dfa22e8ff2e1989366e9b00369575638694ec3 + checksum: 45df8826bf41c2122ff1debb858c335d572257a09b8101806dd6c183f0f7b6a83a747e39dee7e49d55e5eebe0d47d6214aec33e299f81269d3b0535ac225a6e8 languageName: node linkType: hard -"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.261": - version: 1.0.0-alpha.261 - resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.261" +"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.265": + version: 1.0.0-alpha.265 + resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.265" peerDependencies: react: "*" react-native: "*" - checksum: d167fca02e77b4db73ffd3535a99fcde83703d904619ece10016abff906271bdd2a047d6cde20394442f472c291ce7a13aaa7bb3a4da4470de03e0f959cf1d59 + checksum: 4313ec6c33a768b7287380d3783e9cd6868b392651701e818805de37b3ba61a89e50b25556605946468e8763b5f77d48984d9b14c2aa8b408521424d3a249283 languageName: node linkType: hard @@ -8962,11 +8961,11 @@ __metadata: "@formatjs/intl-relativetimeformat": "npm:9.3.1" "@hyperledger/anoncreds-react-native": "npm:0.2.2" "@hyperledger/aries-askar-react-native": "npm:0.2.1" - "@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.261" - "@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.261" - "@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.261" - "@hyperledger/aries-oca": "npm:1.0.0-alpha.261" - "@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.261" + "@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.265" + "@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.265" + "@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.265" + "@hyperledger/aries-oca": "npm:1.0.0-alpha.265" + "@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.265" "@hyperledger/indy-vdr-react-native": "npm:0.2.2" "@react-native-async-storage/async-storage": "npm:1.15.11" "@react-native-community/masked-view": "npm:0.1.11"