Skip to content

Commit

Permalink
feat: adding MultUseInvitation verification (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
SophiaSales authored Feb 20, 2024
1 parent 5049770 commit 8c7b625
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/legacy/core/App/contexts/configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface ConfigurationContext {
getCredentialHelpDictionary?: GetCredentialHelpEntry[]
contactHideList?: string[]
credentialHideList?: string[]
enableUseMultUseInvitation?: boolean
}

export const ConfigurationContext = createContext<ConfigurationContext>(null as unknown as ConfigurationContext)
Expand Down
4 changes: 3 additions & 1 deletion packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const RootStack: React.FC = () => {
enableImplicitInvitations,
enableReuseConnections,
disableOnboardingSkip,
enableUseMultUseInvitation,
} = useConfiguration()
useDeepLinks()

Expand Down Expand Up @@ -111,7 +112,8 @@ const RootStack: React.FC = () => {
deepLink,
agent,
enableImplicitInvitations,
enableReuseConnections
enableReuseConnections,
enableUseMultUseInvitation
)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
Expand Down
4 changes: 3 additions & 1 deletion packages/legacy/core/App/navigators/TabStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import HomeStack from './HomeStack'

const TabStack: React.FC = () => {
const { fontScale } = useWindowDimensions()
const { useCustomNotifications, enableReuseConnections, enableImplicitInvitations } = useConfiguration()
const { useCustomNotifications, enableReuseConnections, enableImplicitInvitations, enableUseMultUseInvitation } =
useConfiguration()
const { total } = useCustomNotifications()
const { t } = useTranslation()
const Tab = createBottomTabNavigator<TabStackParams>()
Expand Down Expand Up @@ -168,6 +169,7 @@ const TabStack: React.FC = () => {
params: {
implicitInvitations: enableImplicitInvitations,
reuseConnections: enableReuseConnections,
useMultUseInvitation: enableUseMultUseInvitation,
},
})
},
Expand Down
12 changes: 11 additions & 1 deletion packages/legacy/core/App/screens/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ const Scan: React.FC<ScanProps> = ({ navigation, route }) => {
if (route?.params && route.params['reuseConnections']) {
reuseConnections = route.params['reuseConnections']
}
let useMultUseInvitation = false
if (route?.params && route.params['useMultUseInvitation']) {
useMultUseInvitation = route.params['useMultUseInvitation']
}

const handleInvitation = async (value: string): Promise<void> => {
try {
const receivedInvitation = await connectFromInvitation(value, agent, implicitInvitations, reuseConnections)
const receivedInvitation = await connectFromInvitation(
value,
agent,
implicitInvitations,
reuseConnections,
useMultUseInvitation
)
if (receivedInvitation?.connectionRecord?.id) {
// not connectionless
navigation.getParent()?.navigate(Stacks.ConnectionStack, {
Expand Down
7 changes: 5 additions & 2 deletions packages/legacy/core/App/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,8 @@ export const connectFromInvitation = async (
uri: string,
agent: Agent | undefined,
implicitInvitations: boolean = false,
reuseConnection: boolean = false
reuseConnection: boolean = false,
useMultUseInvitation: boolean = false
) => {
const invitation = await agent?.oob.parseInvitation(uri)

Expand All @@ -889,7 +890,9 @@ export const connectFromInvitation = async (
}

if (!record) {
await removeExistingInvitationIfRequired(agent, invitation.id)
if (useMultUseInvitation) {
await removeExistingInvitationIfRequired(agent, invitation.id)
}
record = await agent?.oob.receiveInvitation(invitation, { reuseConnection })
}

Expand Down

0 comments on commit 8c7b625

Please sign in to comment.