Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deep links #2287

Merged
merged 5 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
initLanguages,
ContainerProvider,
MainContainer,
InactivityWrapper,
ActivityProvider,
OpenIDCredentialRecordProvider,
} from '@hyperledger/aries-bifold-core'
import { useNavigation } from '@react-navigation/native'
Expand Down Expand Up @@ -71,7 +71,7 @@ const App = () => {
<AnimatedComponentsProvider value={animatedComponents}>
<AuthProvider>
<NetworkProvider>
<InactivityWrapper>
<ActivityProvider>
<StatusBar
barStyle="light-content"
hidden={false}
Expand All @@ -97,7 +97,7 @@ const App = () => {
<RootStack />
</TourProvider>
<Toast topOffset={15} config={toastConfig} />
</InactivityWrapper>
</ActivityProvider>
</NetworkProvider>
</AuthProvider>
</AnimatedComponentsProvider>
Expand Down
5 changes: 2 additions & 3 deletions app/container-imp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ export class AppContainer implements Container {
unified.birthdate = new Date(Date.parse(unified.birthdate))
}

const state: BCState = {
...initialState,
const state = {
loginAttempt: { ...initialState.loginAttempt, ...loginAttempt },
preferences: { ...initialState.preferences, ...preferences },
migration: { ...initialState.migration, ...migration },
Expand All @@ -399,7 +398,7 @@ export class AppContainer implements Container {
enableAltPersonFlow,
},
unified: { ...initialState.unified, ...unified },
}
} as BCState

const { enabledAt, sessionId } = state.developer.remoteDebugging
if (enabledAt && sessionId) {
Expand Down
4 changes: 2 additions & 2 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ PODS:
- React-jsinspector (0.72.5)
- React-logger (0.72.5):
- glog
- "react-native-attestation (1.0.0-alpha.370+498de1ea)":
- "react-native-attestation (1.0.0-alpha.371+9484bf84)":
- RCT-Folly (= 2021.07.22.00)
- React-Core
- react-native-config (1.5.0):
Expand Down Expand Up @@ -936,7 +936,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: ff70a72027dea5cc7d71cfcc6fad7f599f63987a
React-jsinspector: aef73cbd43b70675f572214d10fa438c89bf11ba
React-logger: 2e4aee3e11b3ec4fa6cfd8004610bbb3b8d6cca4
react-native-attestation: d69a5a13040f0803d0cd45ce86289cf347250258
react-native-attestation: e349eb06dd827fe44fcbe309689312473e425635
react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
react-native-date-picker: 06a4d96ab525a163c7a90bccd68833d136b0bb13
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
Expand Down
10 changes: 5 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
"@formatjs/intl-relativetimeformat": "9.3.1",
"@hyperledger/anoncreds-react-native": "0.2.4",
"@hyperledger/aries-askar-react-native": "0.2.3",
"@hyperledger/aries-bifold-core": "1.0.0-alpha.370",
"@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.370",
"@hyperledger/aries-bifold-verifier": "1.0.0-alpha.370",
"@hyperledger/aries-oca": "1.0.0-alpha.370",
"@hyperledger/aries-react-native-attestation": "1.0.0-alpha.370",
"@hyperledger/aries-bifold-core": "1.0.0-alpha.371",
"@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.371",
"@hyperledger/aries-bifold-verifier": "1.0.0-alpha.371",
"@hyperledger/aries-oca": "1.0.0-alpha.371",
"@hyperledger/aries-react-native-attestation": "1.0.0-alpha.371",
"@hyperledger/indy-vdr-react-native": "0.2.2",
"@hyperledger/indy-vdr-shared": "0.2.2",
"@react-native-async-storage/async-storage": "1.15.11",
Expand Down
58 changes: 8 additions & 50 deletions app/src/hooks/initialize-agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Agent, HttpOutboundTransport, MediatorPickupStrategy, WsOutboundTransport, WalletError } from '@credo-ts/core'
import { Agent, HttpOutboundTransport, MediatorPickupStrategy, WsOutboundTransport } from '@credo-ts/core'
import { IndyVdrPoolConfig, IndyVdrPoolService } from '@credo-ts/indy-vdr/build/pool'
import { useAgent } from '@credo-ts/react-hooks'
import { agentDependencies } from '@credo-ts/react-native'
import {
BifoldError,
DispatchAction,
useAuth,
useStore,
Expand Down Expand Up @@ -32,7 +31,7 @@ const loadCachedLedgers = async (): Promise<IndyVdrPoolConfig[] | undefined> =>
}

const useInitializeBCAgent = () => {
const { agent, setAgent } = useAgent()
const { setAgent } = useAgent()
const [store, dispatch] = useStore<BCState>()
const { walletSecret } = useAuth()
const [logger, indyLedgers, attestationMonitor, credDefs, schemas] = useServices([
Expand All @@ -43,40 +42,6 @@ const useInitializeBCAgent = () => {
TOKENS.CACHE_SCHEMAS,
])

const restartExistingAgent = useCallback(async () => {
if (!walletSecret?.id || !walletSecret.key || !agent) {
return
}

logger.info('Agent already initialized, restarting...')

try {
await agent.wallet.open({
id: walletSecret.id,
key: walletSecret.key!,
})
} catch (error) {
// Credo does not use error codes but this will be in the
// the error message if the wallet is already open
const catchPhrase = 'instance already opened'

if (error instanceof WalletError && error.message.includes(catchPhrase)) {
logger.warn('Wallet already open, nothing to do')
} else {
logger.error('Error opening existing wallet:', error as Error)

throw new BifoldError(
'Wallet Service',
'There was a problem unlocking the wallet.',
(error as Error).message,
1047
)
}

await agent.mediationRecipient.initiateMessagePickup()
}
}, [walletSecret, agent, logger])

const createNewAgent = useCallback(
async (ledgers: IndyVdrPoolConfig[]): Promise<Agent | undefined> => {
if (!walletSecret?.id || !walletSecret.key) {
Expand Down Expand Up @@ -203,11 +168,6 @@ const useInitializeBCAgent = () => {
return
}

if (agent) {
await restartExistingAgent()
return agent
}

const cachedLedgers = await loadCachedLedgers()
const ledgers = cachedLedgers ?? indyLedgers

Expand All @@ -227,25 +187,23 @@ const useInitializeBCAgent = () => {

logger.info('Creating link secret if required...')
await createLinkSecretIfRequired(newAgent)

logger.info('Setting new agent...')
setAgent(newAgent)


if (store.preferences.usePushNotifications) {
logger.info('Activating push notifications...')
activate(newAgent)
await activate(newAgent)
}

// In case the old attestationMonitor is still active, stop it and start a new one
logger.info('Starting attestation monitor...')
attestationMonitor?.stop()
attestationMonitor?.start(newAgent)

logger.info('Setting new agent...')
setAgent(newAgent)

return newAgent
}, [
agent,
setAgent,
restartExistingAgent,
createNewAgent,
migrateIfRequired,
warmUpCache,
Expand Down
4 changes: 2 additions & 2 deletions app/src/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ const Splash = () => {
await (ocaBundleResolver as RemoteOCABundleResolver).checkForUpdates?.()

setStep(4)
const newAgent = await initializeAgent()
if (!newAgent) {
const agent = await initializeAgent()
if (!agent) {
initializing.current = false
return
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/services/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class AttestationMonitor implements AttestationMonitorI {
return this._shouldHandleProofRequestAutomatically
}

public async start(agent: Agent): Promise<void> {
public start(agent: Agent): void {
this.agent = agent

this.proofSubscription = this.agent?.events
Expand Down Expand Up @@ -376,8 +376,6 @@ export class AttestationMonitor implements AttestationMonitorI {
try {
// 1. Is the proof requesting an attestation credential
if (!(await isProofRequestingAttestation(proof, this.agent, AttestationRestrictions))) {
this.log?.info('Proof nope!!!!')

return
}

Expand Down
50 changes: 25 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3253,9 +3253,9 @@ __metadata:
languageName: node
linkType: hard

"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.370":
version: 1.0.0-alpha.370
resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.371":
version: 1.0.0-alpha.371
resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.371"
peerDependencies:
"@credo-ts/anoncreds": 0.5.11
"@credo-ts/askar": 0.5.11
Expand Down Expand Up @@ -3331,57 +3331,57 @@ __metadata:
uuid: ^9.0.0
bin:
bifold: bin/bifold
checksum: 51af00fcd6452db44a354c032dd9f702fcc1d4630831e0dfabdbeaecc65a838513d8e3c410b3ce78e095c85244f474fa8362f3a576efa30c1a2da5dee37a61c2
checksum: 9e603224d642beea5b0982b74e21018f89165df19eaecfabbc48ddd2fc91090874a8eab57b068e7f3b39eb3655c60587f0b032779a1598b9a1055d6f452d7948
languageName: node
linkType: hard

"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.370":
version: 1.0.0-alpha.370
resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.371":
version: 1.0.0-alpha.371
resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.371"
peerDependencies:
"@credo-ts/core": 0.5.11
axios: ^1.4.0
buffer: ^6.0.3
react: ^18.2.0
react-native: ^0.72.5
react-native-logs: ^5.1.0
checksum: 04e795d12e2143b8b60dd748966a121682e71d9b496646dcbd546aaf2d9f8d2c1481d67ea68f8371824649f3cef531da62734299073f72be183b98e02489f74f
checksum: 267b89b3d4ed28cb2af40a351d48b5c0c14c51447a2a5a046a16a998d4ccaa97976beaa4b1a69145ee3fc7921c56338c24ad845f8bd1c3893f998bb9e0a708b8
languageName: node
linkType: hard

"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.370":
version: 1.0.0-alpha.370
resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.371":
version: 1.0.0-alpha.371
resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.371"
peerDependencies:
"@credo-ts/anoncreds": 0.5.11
"@credo-ts/core": 0.5.11
"@credo-ts/react-hooks": ^0.6.0
"@hyperledger/anoncreds-shared": 0.2.4
react: ^18.2.0
checksum: 164c61e1dc8ee0f5e77fa5cfb140d58302b40992bf70d91cd5c17dcf5d05d66ba0ac210f58571177825e5db0bef0c0d8c8758545ce4e5879d109cabddba48d9f
checksum: d085b93dfe79177215d605f60b1337233881896b115549ee1398d60f46fc1e047d40d145e497c3aaebb13ca2d26d18afa3bf7a35ae8df5982211524840949c19
languageName: node
linkType: hard

"@hyperledger/aries-oca@npm:1.0.0-alpha.370":
version: 1.0.0-alpha.370
resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.370"
"@hyperledger/aries-oca@npm:1.0.0-alpha.371":
version: 1.0.0-alpha.371
resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.371"
dependencies:
"@credo-ts/anoncreds": "npm:0.5.11"
"@credo-ts/core": "npm:0.5.11"
axios: "npm:^1.4.0"
lodash.startcase: "npm:^4.4.0"
react-native-fs: "npm:^2.16.6"
checksum: f830121a05046d594d4487de0bcc639f60e749ff4b46ff6f810f75199e3fa533b3366fabaf534e57d931dcabd26b2e41f9ffc97e9ff900e660e7ab38f1d5ce6e
checksum: 18fa603733a26decc0375a013d7adb3077c6f440e02cae189e969b8bb0fd8f7d78f38f9b3e8f7b1bf1088125c052f166508b603d24d31c34d4ac084c9e183518
languageName: node
linkType: hard

"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.370":
version: 1.0.0-alpha.370
resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.370"
"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.371":
version: 1.0.0-alpha.371
resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.371"
peerDependencies:
react: "*"
react-native: "*"
checksum: 5430262831acddaa29d430015def9c5ceb591e7b804b673ae3d65b15132e1a4bdd51af4f5f5cd515667d4c1bfc016325ca0eb263360aa34e17eb4585c2f833e3
checksum: 63b0daedc62584d125b8d5262a7afc98f0b614af9b62c869dddff5cb7d828f4c060fe6ae86c6b4a9a08cd49445bf2ba00bc590a950e3322b9eaffab378706fc9
languageName: node
linkType: hard

Expand Down Expand Up @@ -8292,11 +8292,11 @@ __metadata:
"@formatjs/intl-relativetimeformat": "npm:9.3.1"
"@hyperledger/anoncreds-react-native": "npm:0.2.4"
"@hyperledger/aries-askar-react-native": "npm:0.2.3"
"@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.370"
"@hyperledger/aries-oca": "npm:1.0.0-alpha.370"
"@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.370"
"@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.371"
"@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.371"
"@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.371"
"@hyperledger/aries-oca": "npm:1.0.0-alpha.371"
"@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.371"
"@hyperledger/indy-vdr-react-native": "npm:0.2.2"
"@hyperledger/indy-vdr-shared": "npm:0.2.2"
"@react-native-async-storage/async-storage": "npm:1.15.11"
Expand Down
Loading