Skip to content

Commit

Permalink
fix: For self trusted anchor rendering and client metadata for x509 (#…
Browse files Browse the repository at this point in the history
…240)

Signed-off-by: Tom Lanser <[email protected]>
  • Loading branch information
Tommylans authored Nov 26, 2024
1 parent cd9ea4c commit a2025d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
14 changes: 10 additions & 4 deletions apps/easypid/src/features/receive/slides/VerifyPartySlide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export const VerifyPartySlide = ({
setIsLoading(false)
}

const entityIsTrustAnchor = trustedEntities?.some((entity) => entity.entity_id === entityId)

const trustedEntitiesWithoutSelf = trustedEntities?.filter((entity) => entity.entity_id !== entityId)

const onPressVerifiedIssuer = withHaptics(() => {
router.push(
`/federation?name=${encodeURIComponent(name ?? '')}&logo=${encodeURIComponent(logo?.url ?? '')}&entityId=${encodeURIComponent(entityId)}&trustedEntities=${encodeURIComponent(JSON.stringify(trustedEntities ?? []))}`
`/federation?name=${encodeURIComponent(name ?? '')}&logo=${encodeURIComponent(logo?.url ?? '')}&entityId=${encodeURIComponent(entityId)}&trustedEntities=${encodeURIComponent(JSON.stringify(trustedEntitiesWithoutSelf ?? []))}`
)
})

Expand Down Expand Up @@ -95,11 +99,13 @@ export const VerifyPartySlide = ({
</YStack>

<YStack gap="$4">
{trustedEntities && trustedEntities.length > 0 ? (
{trustedEntitiesWithoutSelf && (trustedEntitiesWithoutSelf.length > 0 || entityIsTrustAnchor) ? (
<InfoButton
variant="info"
variant={entityIsTrustAnchor ? 'positive' : 'info'}
title="Recognized organisation"
description={`Approved by ${trustedEntities.length} organisations`}
description={`Approved by ${trustedEntitiesWithoutSelf.length} organisation${
trustedEntitiesWithoutSelf.length === 1 ? '' : 's'
}`}
onPress={onPressVerifiedIssuer}
/>
) : (
Expand Down
30 changes: 14 additions & 16 deletions apps/easypid/src/features/wallet/FunkeFederationDetailScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,21 @@ export function FunkeFederationDetailScreen({
</Paragraph>
</YStack>
<YStack gap="$2">
{trustedEntities.map((entity) => {
return (
<XStack ai="center" key={entity.entity_id} br="$8" p="$3.5" gap="$3" bg="$grey-100">
{entity.logo_uri && (
<Circle overflow="hidden" size="$4" bg="$grey-50">
<Image src={entity.logo_uri} height="100%" width="100%" />
</Circle>
)}
<XStack gap="$1" f={1} justifyContent="space-between" ai="center">
<Heading f={1} numberOfLines={2} variant="h2">
{entity.organization_name}
</Heading>
<IconContainer icon={<HeroIcons.CheckCircleFilled size={30} color="$positive-500" />} />
</XStack>
{trustedEntities.map((entity) => (
<XStack ai="center" key={entity.entity_id} br="$8" p="$3.5" gap="$3" bg="$grey-100">
{entity.logo_uri && (
<Circle overflow="hidden" size="$4" bg="$grey-50">
<Image src={entity.logo_uri} height="100%" width="100%" />
</Circle>
)}
<XStack gap="$1" f={1} justifyContent="space-between" ai="center">
<Heading f={1} numberOfLines={2} variant="h2">
{entity.organization_name}
</Heading>
<IconContainer icon={<HeroIcons.CheckCircleFilled size={30} color="$positive-500" />} />
</XStack>
)
})}
</XStack>
))}
</YStack>
</YStack>
</YStack>
Expand Down
12 changes: 6 additions & 6 deletions packages/agent/src/invitation/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,14 @@ export const getCredentialsForProofRequest = async ({
...(entityId ? { federation: { trustedEntityIds: [entityId] } } : {}),
})

// TODO: Remove me when the new credo-ts version is used
if (resolved.authorizationRequest.payload) {
resolved.authorizationRequest.payload.client_metadata =
resolved.authorizationRequest.authorizationRequestPayload.client_metadata
}

let trustedEntities: Array<TrustedEntity> = []
if (entityId) {
// TODO: Remove me when the new credo-ts version is used
if (resolved.authorizationRequest.payload) {
resolved.authorizationRequest.payload.client_metadata =
resolved.authorizationRequest.authorizationRequestPayload.client_metadata
}

const resolvedChains = await agent.modules.openId4VcHolder.resolveOpenIdFederationChains({
entityId: entityId,
trustAnchorEntityIds: TRUSTED_ENTITIES,
Expand Down

0 comments on commit a2025d7

Please sign in to comment.