@bifold/core 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/inputs/BiometryControl.js +14 -4
- package/lib/commonjs/components/inputs/BiometryControl.js.map +1 -1
- package/lib/commonjs/hooks/useBifoldAgentSetup.js +31 -3
- package/lib/commonjs/hooks/useBifoldAgentSetup.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/localization/en/en.json +928 -0
- package/lib/commonjs/localization/en/index.js +3 -932
- package/lib/commonjs/localization/en/index.js.map +1 -1
- package/lib/commonjs/localization/fr/fr.json +910 -0
- package/lib/commonjs/localization/fr/index.js +3 -912
- package/lib/commonjs/localization/fr/index.js.map +1 -1
- package/lib/commonjs/localization/pt-br/index.js +3 -889
- package/lib/commonjs/localization/pt-br/index.js.map +1 -1
- package/lib/commonjs/localization/pt-br/pt-br.json +887 -0
- package/lib/commonjs/services/keychain.js +4 -0
- package/lib/commonjs/services/keychain.js.map +1 -1
- package/lib/module/components/inputs/BiometryControl.js +14 -4
- package/lib/module/components/inputs/BiometryControl.js.map +1 -1
- package/lib/module/hooks/useBifoldAgentSetup.js +33 -5
- package/lib/module/hooks/useBifoldAgentSetup.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/localization/en/en.json +928 -0
- package/lib/module/localization/en/index.js +2 -932
- package/lib/module/localization/en/index.js.map +1 -1
- package/lib/module/localization/fr/fr.json +910 -0
- package/lib/module/localization/fr/index.js +2 -912
- package/lib/module/localization/fr/index.js.map +1 -1
- package/lib/module/localization/pt-br/index.js +2 -889
- package/lib/module/localization/pt-br/index.js.map +1 -1
- package/lib/module/localization/pt-br/pt-br.json +887 -0
- package/lib/module/services/keychain.js +4 -0
- package/lib/module/services/keychain.js.map +1 -1
- package/lib/typescript/src/components/inputs/BiometryControl.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useBifoldAgentSetup.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/en/index.d.ts +2 -929
- package/lib/typescript/src/localization/en/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/fr/index.d.ts +2 -911
- package/lib/typescript/src/localization/fr/index.d.ts.map +1 -1
- package/lib/typescript/src/localization/pt-br/index.d.ts +2 -888
- package/lib/typescript/src/localization/pt-br/index.d.ts.map +1 -1
- package/lib/typescript/src/services/keychain.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/inputs/BiometryControl.tsx +16 -5
- package/src/hooks/useBifoldAgentSetup.ts +40 -7
- package/src/index.ts +2 -1
- package/src/localization/en/en.json +928 -0
- package/src/localization/en/index.ts +2 -930
- package/src/localization/fr/fr.json +910 -0
- package/src/localization/fr/index.ts +2 -912
- package/src/localization/pt-br/index.ts +2 -889
- package/src/localization/pt-br/pt-br.json +887 -0
- package/src/services/keychain.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/localization/pt-br/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/localization/pt-br/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,cAAc,CAAA;AAE7B,eAAe,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../../src/services/keychain.ts"],"names":[],"mappings":"AACA,OAAO,QAAsC,MAAM,uBAAuB,CAAA;AAG1E,OAAO,EAAY,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAO7C,MAAM,WAAW,UAAU;IACzB,E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1.4",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/core": "^7.20.0",
|
|
35
35
|
"@babel/runtime": "^7.20.0",
|
|
36
|
-
"@bifold/oca": "2.1.
|
|
37
|
-
"@bifold/verifier": "2.1.
|
|
36
|
+
"@bifold/oca": "2.1.4",
|
|
37
|
+
"@bifold/verifier": "2.1.4",
|
|
38
38
|
"@commitlint/cli": "^11.0.0",
|
|
39
39
|
"@credo-ts/anoncreds": "0.5.13",
|
|
40
40
|
"@credo-ts/askar": "0.5.13",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"react-native-localize": "^2.2.4",
|
|
121
121
|
"react-native-logs": "^5.1.0",
|
|
122
122
|
"react-native-orientation-locker": "^1.6.0",
|
|
123
|
-
"react-native-permissions": "^4.0
|
|
123
|
+
"react-native-permissions": "^5.4.0",
|
|
124
124
|
"react-native-qrcode-svg": "6.2.0",
|
|
125
125
|
"react-native-safe-area-context": "^4.8.2",
|
|
126
126
|
"react-native-scalable-image": "^1.1.0",
|
|
@@ -10,6 +10,7 @@ import { ThemedText } from '../texts/ThemedText'
|
|
|
10
10
|
import { useAuth } from '../../contexts/auth'
|
|
11
11
|
import { useTheme } from '../../contexts/theme'
|
|
12
12
|
import { testIdWithKey } from '../../utils/testable'
|
|
13
|
+
import { getSupportedBiometryType, BIOMETRY_TYPE } from 'react-native-keychain'
|
|
13
14
|
|
|
14
15
|
const BIOMETRY_PERMISSION = PERMISSIONS.IOS.FACE_ID
|
|
15
16
|
|
|
@@ -43,7 +44,7 @@ const BiometryControl: React.FC<BiometryControlProps> = ({ biometryEnabled, onBi
|
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
useEffect(() => {
|
|
46
|
-
isBiometricsActive().then((result) => {
|
|
47
|
+
isBiometricsActive().then((result: boolean) => {
|
|
47
48
|
setBiometryAvailable(result)
|
|
48
49
|
})
|
|
49
50
|
}, [isBiometricsActive])
|
|
@@ -97,6 +98,8 @@ const BiometryControl: React.FC<BiometryControlProps> = ({ biometryEnabled, onBi
|
|
|
97
98
|
// If the user is turning it on, they need
|
|
98
99
|
// to first authenticate the OS biometrics before this action is accepted
|
|
99
100
|
const permissionResult: PermissionStatus = await onCheckSystemBiometrics()
|
|
101
|
+
const supported_type = await getSupportedBiometryType()
|
|
102
|
+
|
|
100
103
|
switch (permissionResult) {
|
|
101
104
|
case RESULTS.GRANTED:
|
|
102
105
|
case RESULTS.LIMITED:
|
|
@@ -104,10 +107,18 @@ const BiometryControl: React.FC<BiometryControlProps> = ({ biometryEnabled, onBi
|
|
|
104
107
|
onBiometryToggle(newValue)
|
|
105
108
|
break
|
|
106
109
|
case RESULTS.UNAVAILABLE:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// Permission is unavailable/ not supported on this device
|
|
111
|
+
if (Platform.OS === 'ios' && supported_type === BIOMETRY_TYPE.TOUCH_ID) {
|
|
112
|
+
// if available, access to touch id can be granted without a request
|
|
113
|
+
onBiometryToggle(newValue)
|
|
114
|
+
} else {
|
|
115
|
+
// Not in iOS or no touch id available for iOS, send user to settings
|
|
116
|
+
// to enable biometrics
|
|
117
|
+
setSettingsPopupConfig({
|
|
118
|
+
title: t('Biometry.SetupBiometricsTitle'),
|
|
119
|
+
description: t('Biometry.SetupBiometricsDesc'),
|
|
120
|
+
})
|
|
121
|
+
}
|
|
111
122
|
break
|
|
112
123
|
case RESULTS.BLOCKED:
|
|
113
124
|
// Previously denied
|
|
@@ -2,16 +2,16 @@ import { Agent, HttpOutboundTransport, WsOutboundTransport } from '@credo-ts/cor
|
|
|
2
2
|
import { IndyVdrPoolService } from '@credo-ts/indy-vdr/build/pool'
|
|
3
3
|
import { agentDependencies } from '@credo-ts/react-native'
|
|
4
4
|
import { GetCredentialDefinitionRequest, GetSchemaRequest } from '@hyperledger/indy-vdr-shared'
|
|
5
|
-
import { useCallback, useState } from 'react'
|
|
5
|
+
import { useCallback, useRef, useState } from 'react'
|
|
6
6
|
import { Config } from 'react-native-config'
|
|
7
7
|
import { CachesDirectoryPath } from 'react-native-fs'
|
|
8
8
|
|
|
9
9
|
import { TOKENS, useServices } from '../container-api'
|
|
10
10
|
import { DispatchAction } from '../contexts/reducers/store'
|
|
11
11
|
import { useStore } from '../contexts/store'
|
|
12
|
-
import { getAgentModules, createLinkSecretIfRequired } from '../utils/agent'
|
|
13
|
-
import { migrateToAskar } from '../utils/migration'
|
|
14
12
|
import { WalletSecret } from '../types/security'
|
|
13
|
+
import { createLinkSecretIfRequired, getAgentModules } from '../utils/agent'
|
|
14
|
+
import { migrateToAskar } from '../utils/migration'
|
|
15
15
|
|
|
16
16
|
export type AgentSetupReturnType = {
|
|
17
17
|
agent: Agent | null
|
|
@@ -21,6 +21,7 @@ export type AgentSetupReturnType = {
|
|
|
21
21
|
|
|
22
22
|
const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
23
23
|
const [agent, setAgent] = useState<Agent | null>(null)
|
|
24
|
+
const agentInstanceRef = useRef<Agent | null>(null)
|
|
24
25
|
const [store, dispatch] = useStore()
|
|
25
26
|
const [cacheSchemas, cacheCredDefs, logger, indyLedgers] = useServices([
|
|
26
27
|
TOKENS.CACHE_SCHEMAS,
|
|
@@ -29,6 +30,26 @@ const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
|
29
30
|
TOKENS.UTIL_LEDGERS,
|
|
30
31
|
])
|
|
31
32
|
|
|
33
|
+
const restartExistingAgent = useCallback(
|
|
34
|
+
async (agent: Agent, walletSecret: WalletSecret): Promise<Agent | undefined> => {
|
|
35
|
+
try {
|
|
36
|
+
await agent.wallet.open({
|
|
37
|
+
id: walletSecret.id,
|
|
38
|
+
key: walletSecret.key,
|
|
39
|
+
})
|
|
40
|
+
await agent.initialize()
|
|
41
|
+
} catch (error) {
|
|
42
|
+
logger.warn(`Agent restart failed with error ${error}`)
|
|
43
|
+
// if the existing agents wallet cannot be opened or initialize() fails it was
|
|
44
|
+
// again not a clean shutdown and the agent should be replaced, not restarted
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return agent
|
|
49
|
+
},
|
|
50
|
+
[logger]
|
|
51
|
+
)
|
|
52
|
+
|
|
32
53
|
const createNewAgent = useCallback(
|
|
33
54
|
async (walletSecret: WalletSecret): Promise<Agent> => {
|
|
34
55
|
const newAgent = new Agent({
|
|
@@ -97,7 +118,18 @@ const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
|
97
118
|
|
|
98
119
|
const initializeAgent = useCallback(
|
|
99
120
|
async (walletSecret: WalletSecret): Promise<void> => {
|
|
100
|
-
logger.info('
|
|
121
|
+
logger.info('Checking for existing agent...')
|
|
122
|
+
if (agentInstanceRef.current) {
|
|
123
|
+
const restartedAgent = await restartExistingAgent(agentInstanceRef.current, walletSecret)
|
|
124
|
+
if (restartedAgent) {
|
|
125
|
+
logger.info('Successfully restarted existing agent...')
|
|
126
|
+
agentInstanceRef.current = restartedAgent
|
|
127
|
+
setAgent(restartedAgent)
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
logger.info('Creating new agent...')
|
|
101
133
|
const newAgent = await createNewAgent(walletSecret)
|
|
102
134
|
|
|
103
135
|
logger.info('Migrating if required...')
|
|
@@ -113,9 +145,10 @@ const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
|
113
145
|
await warmUpCache(newAgent)
|
|
114
146
|
|
|
115
147
|
logger.info('Agent initialized successfully')
|
|
148
|
+
agentInstanceRef.current = newAgent
|
|
116
149
|
setAgent(newAgent)
|
|
117
150
|
},
|
|
118
|
-
[logger, createNewAgent, migrateIfRequired, warmUpCache]
|
|
151
|
+
[logger, restartExistingAgent, createNewAgent, migrateIfRequired, warmUpCache]
|
|
119
152
|
)
|
|
120
153
|
|
|
121
154
|
const shutdownAndClearAgentIfExists = useCallback(async () => {
|
|
@@ -124,10 +157,10 @@ const useBifoldAgentSetup = (): AgentSetupReturnType => {
|
|
|
124
157
|
await agent.shutdown()
|
|
125
158
|
} catch (error) {
|
|
126
159
|
logger.error(`Error shutting down agent with shutdownAndClearAgentIfExists: ${error}`)
|
|
160
|
+
} finally {
|
|
161
|
+
setAgent(null)
|
|
127
162
|
}
|
|
128
163
|
}
|
|
129
|
-
|
|
130
|
-
setAgent(null)
|
|
131
164
|
}, [agent, logger])
|
|
132
165
|
|
|
133
166
|
return { agent, initializeAgent, shutdownAndClearAgentIfExists }
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ import Splash from './screens/Splash'
|
|
|
51
51
|
import Terms from './screens/Terms'
|
|
52
52
|
import UpdateAvailable from './screens/UpdateAvailable'
|
|
53
53
|
import Biometry from './screens/Biometry'
|
|
54
|
-
import { loadLoginAttempt } from './services/keychain'
|
|
54
|
+
import { loadLoginAttempt, isBiometricsActive } from './services/keychain'
|
|
55
55
|
import { BifoldLogger } from './services/logger'
|
|
56
56
|
import * as types from './types'
|
|
57
57
|
import Scan from './screens/Scan'
|
|
@@ -216,6 +216,7 @@ export {
|
|
|
216
216
|
Text,
|
|
217
217
|
ThemedText,
|
|
218
218
|
loadLoginAttempt,
|
|
219
|
+
isBiometricsActive,
|
|
219
220
|
Button,
|
|
220
221
|
BifoldLogger,
|
|
221
222
|
LimitedTextInput,
|