Skip to content

Commit 726ed28

Browse files
authored
feat: Add subject handling for IDP page (#2181)
Add subject handling for IDP page
1 parent 65df9b1 commit 726ed28

2 files changed

Lines changed: 50 additions & 21 deletions

File tree

  • packages/wallet

packages/wallet/frontend/src/pages/grant-interactions/index.tsx

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const GrantInteractionPage = ({
2222
grant,
2323
interactionId,
2424
nonce,
25-
clientName
25+
clientName,
26+
grantWalletAddress
2627
}: GrantInteractionPageProps) => {
2728
const [openDialog, closeDialog] = useDialog()
2829
const router = useRouter()
@@ -66,30 +67,41 @@ const GrantInteractionPage = ({
6667
width={500}
6768
height={150}
6869
/>
69-
<div className="mt-20 text-base">
70-
{grant.access.length === 1 ? (
70+
{grantWalletAddress.length > 0 ? (
71+
<div className="mt-20 text-base">
7172
<div>
72-
{client} is requesting access to make payments to an amount of{' '}
73-
{grant.access[0]?.limits?.debitAmount?.formattedAmount}.
73+
<span className="font-semibold">{grant.client}</span> is
74+
requesting you to confirm ownership of the following wallet
75+
address(es):&nbsp;
76+
{grantWalletAddress.join(', ')}
7477
</div>
75-
) : (
78+
</div>
79+
) : (
80+
<div className="mt-20 text-base">
81+
{grant.access.length === 1 ? (
82+
<div>
83+
{client} is requesting access to make payments to an amount of{' '}
84+
{grant.access[0]?.limits?.debitAmount?.formattedAmount}.
85+
</div>
86+
) : (
87+
<div>
88+
{client} is requesting access to make payments on the following
89+
amounts:{' '}
90+
{grant.access
91+
.map(
92+
(accessItem) =>
93+
accessItem.limits?.debitAmount?.formattedAmount
94+
)
95+
.join(', ')}
96+
.
97+
</div>
98+
)}
7699
<div>
77-
{client} is requesting access to make payments on the following
78-
amounts:{' '}
79-
{grant.access
80-
.map(
81-
(accessItem) =>
82-
accessItem.limits?.debitAmount?.formattedAmount
83-
)
84-
.join(', ')}
85-
.
100+
Wallet Address client:{' '}
101+
<span className="font-semibold">{grant.client}</span>
86102
</div>
87-
)}
88-
<div>
89-
Wallet Address client:{' '}
90-
<span className="font-semibold">{grant.client}</span>
91103
</div>
92-
</div>
104+
)}
93105
<div className="mx-auto mt-10 flex w-full max-w-xl justify-evenly">
94106
<Button
95107
aria-label="accept"
@@ -168,6 +180,7 @@ export const getServerSideProps: GetServerSideProps<{
168180
interactionId: string
169181
nonce: string
170182
clientName: string
183+
grantWalletAddress: string[]
171184
}> = async (ctx) => {
172185
const result = querySchema.safeParse(ctx.query)
173186
if (!result.success) {
@@ -217,12 +230,18 @@ export const getServerSideProps: GetServerSideProps<{
217230
})
218231
grantInteractionResponse.result.client = result.data.clientUri
219232

233+
const walletAddressList: string[] = []
234+
grantInteractionResponse.result.subject?.sub_ids.map((subID) =>
235+
walletAddressList.push(subID.id)
236+
)
237+
220238
return {
221239
props: {
222240
grant: grantInteractionResponse.result,
223241
interactionId: result.data.interactId,
224242
nonce: result.data.nonce,
225-
clientName: result.data.clientName
243+
clientName: result.data.clientName,
244+
grantWalletAddress: walletAddressList
226245
}
227246
}
228247
}

packages/wallet/shared/src/types/grant.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ type Access = {
3333
} | null
3434
}
3535

36+
type Subject = {
37+
sub_ids: [
38+
{
39+
id: string
40+
format: string
41+
}
42+
]
43+
}
44+
3645
export interface GrantResponse {
3746
id: string
3847
client: string
3948
state: GrantState
4049
createdAt: string
4150
access: Access[]
4251
finalizationReason?: GrantFinalization
52+
subject?: Subject
4353
}
4454

4555
type GrantNode = {

0 commit comments

Comments
 (0)