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: show oob label when no connection #80

Merged
merged 1 commit into from
Nov 15, 2023
Merged
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
16 changes: 14 additions & 2 deletions packages/agent/src/hooks/useInboxNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ export const usePreFetchInboxDisplayMetadata = () => {
? connections.find((connection) => record.connectionId === connection.id)
: undefined

// Extract label from out-of-band invitation if no connection associated
const outOfBandRecord =
!connection && record.parentThreadId
? await agent.oob.findByReceivedInvitationId(record.parentThreadId)
: undefined

const formatData = await agent.credentials.getFormatData(record.id)
const offer = formatData.offer?.anoncreds ?? formatData.offer?.indy
// We just return here, so the rest can still continue
if (!offer) return

const schemaId = offer.schema_id

const issuerName = connection?.theirLabel
const issuerName = connection?.theirLabel ?? outOfBandRecord?.outOfBandInvitation.label
const schemaResult = await agent.modules.anoncreds.getSchema(schemaId)
const schemaName = schemaResult.schema?.name

Expand All @@ -75,13 +81,19 @@ export const usePreFetchInboxDisplayMetadata = () => {
? connections.find((connection) => record.connectionId === connection.id)
: undefined

// Extract label from out-of-band invitation if no connection associated
const outOfBandRecord =
!connection && record.parentThreadId
? await agent.oob.findByReceivedInvitationId(record.parentThreadId)
: undefined

const formatData = await agent.proofs.getFormatData(record.id)
const request = formatData.request?.anoncreds ?? formatData.request?.indy

// We just return here, so the rest can still continue
if (!request) return

const verifierName = connection?.theirLabel
const verifierName = connection?.theirLabel ?? outOfBandRecord?.outOfBandInvitation.label
const proofName = request.name

// Update the metadata on the record for future use
Expand Down