Skip to content

Commit

Permalink
Fix OOB/Connectionless
Browse files Browse the repository at this point in the history
Signed-off-by: Clécio Varjão <[email protected]>
  • Loading branch information
cvarjao committed Sep 20, 2023
1 parent 1b3f5be commit 264d7db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const RootStack: React.FC = () => {
const connectionRecord = await connectFromInvitation(deepLink, agent)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { connectionId: connectionRecord.id },
params: { connectionId: connectionRecord?.connectionRecord?.id },
})
} catch {
try {
Expand Down
20 changes: 16 additions & 4 deletions packages/legacy/core/App/screens/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,23 @@ const Scan: React.FC<ScanProps> = ({ navigation, route }) => {
const handleInvitation = async (value: string): Promise<void> => {
try {
const connectionRecord = await connectFromInvitation(value, agent)
navigation.getParent()?.navigate(Stacks.ConnectionStack, {
screen: Screens.Connection,
params: { connectionId: connectionRecord.id },
})
if (connectionRecord?.connectionRecord?.id) {
// not connectionless
navigation.getParent()?.navigate(Stacks.ConnectionStack, {
screen: Screens.Connection,
params: { connectionId: connectionRecord.connectionRecord.id },
})
} else {
//connectionless
//const invitation = await agent?.oob.parseInvitation(value)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { threadId: connectionRecord?.outOfBandRecord.outOfBandInvitation.threadId },
})
}
} catch (err: unknown) {
// [Error: Connection does not have an ID]
// [AriesFrameworkError: An out of band record with invitation 05fe3693-2c12-4165-a3b6-370280ccd43b has already been received. Invitations should have a unique id.]
try {
// if scanned value is json -> pass into AFJ as is
const json = getJson(value)
Expand Down
6 changes: 1 addition & 5 deletions packages/legacy/core/App/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,8 @@ export const connectFromInvitation = async (uri: string, agent: Agent | undefine
}

const record = await agent?.oob.receiveInvitation(invitation)
const connectionRecord = record?.connectionRecord
if (!connectionRecord?.id) {
throw new Error('Connection does not have an ID')
}

return connectionRecord
return record
}

/**
Expand Down

0 comments on commit 264d7db

Please sign in to comment.