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

feat: OOB Connectionless Flow #973

Merged
merged 3 commits into from
Sep 27, 2023
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
4 changes: 2 additions & 2 deletions packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ const RootStack: React.FC = () => {

try {
// Try connection based
const connectionRecord = await connectFromInvitation(deepLink, agent)
const receivedInvitation = await connectFromInvitation(deepLink, agent)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { connectionId: connectionRecord.id },
params: { connectionId: receivedInvitation?.connectionRecord?.id },
})
} catch {
try {
Expand Down
21 changes: 16 additions & 5 deletions packages/legacy/core/App/screens/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,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 },
})
const receivedInvitation = await connectFromInvitation(value, agent)
if (receivedInvitation?.connectionRecord?.id) {
// not connectionless
navigation.getParent()?.navigate(Stacks.ConnectionStack, {
screen: Screens.Connection,
params: { connectionId: receivedInvitation.connectionRecord.id },
})
} else {
//connectionless
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { threadId: receivedInvitation?.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 @@ -548,12 +548,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