From 1f1ad3d93c666761147f2e6fe312766aba8a7491 Mon Sep 17 00:00:00 2001 From: Thiago Romano Date: Thu, 26 Oct 2023 14:37:42 -0300 Subject: [PATCH] Allowing implicit invites and reuse connections Signed-off-by: Thiago Romano --- packages/legacy/core/App/defaultConfiguration.ts | 1 + packages/legacy/core/App/navigators/RootStack.tsx | 10 ++++++++-- packages/legacy/core/App/navigators/TabStack.tsx | 10 ++++++++-- packages/legacy/core/App/screens/Scan.tsx | 10 +++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/legacy/core/App/defaultConfiguration.ts b/packages/legacy/core/App/defaultConfiguration.ts index 92d9248956..eabf31d4f8 100644 --- a/packages/legacy/core/App/defaultConfiguration.ts +++ b/packages/legacy/core/App/defaultConfiguration.ts @@ -49,4 +49,5 @@ export const defaultConfiguration: ConfigurationContext = { useCustomNotifications: useNotifications, proofRequestTemplates: useProofRequestTemplates, enableTours: false, + enableImplicitInvitations: true, } diff --git a/packages/legacy/core/App/navigators/RootStack.tsx b/packages/legacy/core/App/navigators/RootStack.tsx index bd01380bf3..63121af9e9 100644 --- a/packages/legacy/core/App/navigators/RootStack.tsx +++ b/packages/legacy/core/App/navigators/RootStack.tsx @@ -50,7 +50,8 @@ const RootStack: React.FC = () => { const theme = useTheme() const defaultStackOptions = createDefaultStackOptions(theme) const OnboardingTheme = theme.OnboardingTheme - const { pages, terms, splash, useBiometry, developer } = useConfiguration() + const { pages, terms, splash, useBiometry, developer, enableImplicitInvitations, enableReuseConnections } = + useConfiguration() useDeepLinks() // remove connection on mobile verifier proofs if proof is rejected regardless of if it has been opened @@ -96,7 +97,12 @@ const RootStack: React.FC = () => { try { // Try connection based - const receivedInvitation = await connectFromInvitation(deepLink, agent) + const receivedInvitation = await connectFromInvitation( + deepLink, + agent, + enableImplicitInvitations, + enableReuseConnections + ) navigation.navigate(Stacks.ConnectionStack as any, { screen: Screens.Connection, params: { connectionId: receivedInvitation?.connectionRecord?.id }, diff --git a/packages/legacy/core/App/navigators/TabStack.tsx b/packages/legacy/core/App/navigators/TabStack.tsx index da905c4baa..1b82ab2d2c 100644 --- a/packages/legacy/core/App/navigators/TabStack.tsx +++ b/packages/legacy/core/App/navigators/TabStack.tsx @@ -19,7 +19,7 @@ import HomeStack from './HomeStack' const TabStack: React.FC = () => { const { width, height } = useWindowDimensions() - const { useCustomNotifications } = useConfiguration() + const { useCustomNotifications, enableReuseConnections, enableImplicitInvitations } = useConfiguration() const { total } = useCustomNotifications() const { t } = useTranslation() const Tab = createBottomTabNavigator() @@ -160,7 +160,13 @@ const TabStack: React.FC = () => { if (!assertConnectedNetwork()) { return } - navigation.navigate(Stacks.ConnectStack, { screen: Screens.Scan }) + navigation.navigate(Stacks.ConnectStack, { + screen: Screens.Scan, + params: { + implicitInvitations: enableImplicitInvitations, + reuseConnections: enableReuseConnections, + }, + }) }, })} > diff --git a/packages/legacy/core/App/screens/Scan.tsx b/packages/legacy/core/App/screens/Scan.tsx index d2866f87a4..f64f13945e 100644 --- a/packages/legacy/core/App/screens/Scan.tsx +++ b/packages/legacy/core/App/screens/Scan.tsx @@ -32,10 +32,18 @@ const Scan: React.FC = ({ navigation, route }) => { if (route?.params && route.params['defaultToConnect']) { defaultToConnect = route.params['defaultToConnect'] } + let implicitInvitations = false + if (route?.params && route.params['implicitInvitations']) { + implicitInvitations = route.params['implicitInvitations'] + } + let reuseConnections = false + if (route?.params && route.params['reuseConnections']) { + reuseConnections = route.params['reuseConnections'] + } const handleInvitation = async (value: string): Promise => { try { - const receivedInvitation = await connectFromInvitation(value, agent) + const receivedInvitation = await connectFromInvitation(value, agent, implicitInvitations, reuseConnections) if (receivedInvitation?.connectionRecord?.id) { // not connectionless navigation.getParent()?.navigate(Stacks.ConnectionStack, {