Skip to content

Commit

Permalink
Merge branch 'main' into sandbox/moscd3/openID-OCA-details-offer
Browse files Browse the repository at this point in the history
  • Loading branch information
MosCD3 committed Jan 8, 2025
2 parents af402b1 + f72c911 commit 06e41b9
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

* @hyperledger/aries-mobile-agent-react-native-committers
* @openwallet-foundation/bifold-wallet-maintainers
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ To better understand the technical aspects of the Bifold project including how t
The organizations or jurisdictions listed below have either deployed a project based on Bifold, are currently assessing the technology, or are actively developing a solution. If you want your organization to be included in this list, please submit a Pull Request against this README.md.

- [BC Wallet](https://apps.apple.com/us/app/bc-wallet/id1587380443)
The BC Wallet is a digital wallet app developed by the Government of British Columbia.

The BC Wallet is a digital wallet app developed by the Government of British Columbia.

[contributor-guide]: ./CONTRIBUTING
[developers-guide]: ./DEVELOPER.md
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"packages/legacy/app"
],
"repository": {
"url": "https://github.com/hyperledger/aries-mobile-agent-react-native",
"url": "https://github.com/openwallet-foundation/bifold-wallet/",
"type": "git"
},
"homepage": "https://github.com/openwallet-foundation/bifold-wallet/",
"scripts": {
"clean": "lerna run clean",
"build": "lerna run build",
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/container-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const defaultConfig: Config = {
supportedLanguages: [Locales.en, Locales.fr, Locales.ptBr],
showPreface: false,
disableOnboardingSkip: false,
disableContactsInSettings: false,
whereToUseWalletUrl: 'https://example.com',
showScanHelp: true,
showScanButton: true,
Expand Down
30 changes: 26 additions & 4 deletions packages/legacy/core/App/screens/PINEnter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigation, CommonActions } from '@react-navigation/native'
import React, { useCallback, useEffect, useState } from 'react'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Keyboard, StyleSheet, Text, View, DeviceEventEmitter, InteractionManager } from 'react-native'
import { Keyboard, StyleSheet, Text, View, DeviceEventEmitter, InteractionManager, Pressable } from 'react-native'

import Button, { ButtonType } from '../components/buttons/Button'
import PINInput from '../components/inputs/PINInput'
Expand Down Expand Up @@ -50,7 +50,9 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
const [biometricsEnrollmentChange, setBiometricsEnrollmentChange] = useState<boolean>(false)
const { ColorPallet, TextTheme, Assets, PINEnterTheme } = useTheme()
const { ButtonLoading } = useAnimatedComponents()
const [logger] = useServices([TOKENS.UTIL_LOGGER])
const [logger, { enableHiddenDevModeTrigger }] = useServices([TOKENS.UTIL_LOGGER, TOKENS.CONFIG])
const developerOptionCount = useRef(0)
const touchCountToEnableBiometrics = 9
const [inlineMessageField, setInlineMessageField] = useState<InlineMessageProps>()
const [inlineMessages] = useServices([TOKENS.INLINE_ERRORS])
const [alertModalMessage, setAlertModalMessage] = useState('')
Expand Down Expand Up @@ -104,6 +106,20 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
},
})

const incrementDeveloperMenuCounter = useCallback(() => {
if (developerOptionCount.current >= touchCountToEnableBiometrics) {
developerOptionCount.current = 0
dispatch({
type: DispatchAction.ENABLE_DEVELOPER_MODE,
payload: [true],
})
navigation.navigate(Screens.Developer as never)
return
}

developerOptionCount.current = developerOptionCount.current + 1
}, [dispatch, navigation])

const gotoPostAuthScreens = useCallback(() => {
if (store.onboarding.postAuthScreens.length) {
const screen = store.onboarding.postAuthScreens[0]
Expand Down Expand Up @@ -461,7 +477,13 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
<KeyboardView>
<View style={style.screenContainer}>
<View style={style.contentContainer}>
{displayHelpText()}
{usage === PINEntryUsage.WalletUnlock && enableHiddenDevModeTrigger ? (
<Pressable onPress={incrementDeveloperMenuCounter} testID={testIdWithKey('DeveloperCounter')}>
{displayHelpText()}
</Pressable>
) : (
displayHelpText()
)}
<Text style={style.subText}>{t('PINEnter.EnterPIN')}</Text>
<PINInput
onPINChanged={(p: string) => {
Expand Down
7 changes: 6 additions & 1 deletion packages/legacy/core/App/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
const [store, dispatch] = useStore()
const developerOptionCount = useRef(0)
const { SettingsTheme, TextTheme, ColorPallet, Assets } = useTheme()
const [{ settings, enableTours, enablePushNotifications }, historyEnabled] = useServices([
const [{ settings, enableTours, enablePushNotifications, disableContactsInSettings }, historyEnabled] = useServices([
TOKENS.CONFIG,
TOKENS.HISTORY_ENABLED,
])
Expand Down Expand Up @@ -167,6 +167,11 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
},
...(settings || []),
]

// Remove the Contact section from Setting per TOKENS.CONFIG
if (disableContactsInSettings) {
settingsSections.shift();
}

// add optional push notifications menu to settings
if (enablePushNotifications) {
Expand Down
2 changes: 2 additions & 0 deletions packages/legacy/core/App/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Config {
enableTours?: boolean
enableImplicitInvitations?: boolean
enableReuseConnections?: boolean
enableHiddenDevModeTrigger?: boolean
showPreface?: boolean
showPINExplainer?: boolean
disableOnboardingSkip?: boolean
Expand All @@ -35,6 +36,7 @@ export interface Config {
contactHideList?: string[]
contactDetailsOptions?: ContactDetailsOptionsParams
credentialHideList?: string[]
disableContactsInSettings?: boolean
}

export interface HistoryEventsLoggerConfig {
Expand Down
36 changes: 36 additions & 0 deletions packages/legacy/core/__tests__/screens/Settings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { useNavigation } from '@react-navigation/native'
import { render } from '@testing-library/react-native'
import React from 'react'
import { container } from 'tsyringe'

import { StoreContext } from '../../App'
import Settings from '../../App/screens/Settings'
import { testIdWithKey } from '../../App/utils/testable'
import { testDefaultState } from '../contexts/store'
import { BasicAppContext } from '../helpers/app'
import { CustomBasicAppContext } from '../helpers/app'
import { TOKENS } from '../../App/container-api'
import { MainContainer } from '../../App/container-impl'

describe('Settings Screen', () => {
beforeEach(() => {
Expand Down Expand Up @@ -127,4 +131,36 @@ describe('Settings Screen', () => {
const proofButton = tree.getByTestId(testIdWithKey('ProofRequests'))
expect(proofButton).not.toBeNull()
})

test('If disableContactsInSettings is true, the Contacts section is not shown', async () => {
const customState = {
...testDefaultState,
preferences: {
...testDefaultState.preferences,
developerModeEnabled: true,
walletName: 'My Wallet',
},
}

const context = new MainContainer(container.createChildContainer()).init()
const config = context.resolve(TOKENS.CONFIG)
context.container.registerInstance(TOKENS.CONFIG, { ...config, disableContactsInSettings: true})

const tree = render(
<StoreContext.Provider
value={[
customState,
() => {
return
},
]}
>
<CustomBasicAppContext container={context}>
<Settings navigation={useNavigation()} route={{} as any} />
</CustomBasicAppContext>
</StoreContext.Provider>
)
const contactsSection = tree.queryByTestId(testIdWithKey('Contacts'))
expect(contactsSection).toBeNull()
})
})

0 comments on commit 06e41b9

Please sign in to comment.