diff --git a/agent/src/endpoints.ts b/agent/src/endpoints.ts index 5229de1..0871894 100644 --- a/agent/src/endpoints.ts +++ b/agent/src/endpoints.ts @@ -135,6 +135,7 @@ apiRouter.post('/offers/receive', async (request: Request, response: Response) = const zCreatePresentationRequestBody = z.object({ presentationDefinition: z.record(z.string(), z.any()), requestScheme: z.string(), + responseMode: z.enum(['direct_post.jwt', 'direct_post']), }) apiRouter.post('/requests/create', async (request: Request, response: Response) => { @@ -166,7 +167,7 @@ apiRouter.post('/requests/create', async (request: Request, response: Response) definition: definition as any, }, additionalPayloadClaims, - responseMode: 'direct_post.jwt', + responseMode: createPresentationRequestBody.responseMode, }) console.log(authorizationRequest) diff --git a/app/components/VerifyBlock.tsx b/app/components/VerifyBlock.tsx index 6089c42..d887a85 100644 --- a/app/components/VerifyBlock.tsx +++ b/app/components/VerifyBlock.tsx @@ -16,6 +16,7 @@ import { TypographyH3, TypographyH4 } from './ui/typography' export type CredentialType = 'mdoc' | 'sdjwt' export type RequestType = 'name_age_over_21' | 'city' | 'age_birth_family_name' +export type ResponseMode = 'direct_post' | 'direct_post.jwt' type VerifyBlockProps = { flowName: string @@ -24,10 +25,12 @@ type VerifyBlockProps = { credentialType, requestType, requestScheme, + responseMode, }: { credentialType: CredentialType requestType: RequestType requestScheme: string + responseMode: ResponseMode }) => Promise<{ verificationSessionId: string authorizationRequestUri: string @@ -45,6 +48,7 @@ export const VerifyBlock: React.FC = ({ createRequest, flowNam definition?: Record presentations?: Array> }>() + const [responseMode, setResponseMode] = useState('direct_post.jwt') const enabled = verificationSessionId !== undefined && @@ -77,7 +81,7 @@ export const VerifyBlock: React.FC = ({ createRequest, flowNam setVerificationSessionId(undefined) setRequestStatus(undefined) - const request = await createRequest({ credentialType, requestType, requestScheme }) + const request = await createRequest({ credentialType, requestType, requestScheme, responseMode }) setVerificationSessionId(request.verificationSessionId) setAuthorizationRequestUri(request.authorizationRequestUri) @@ -154,6 +158,29 @@ export const VerifyBlock: React.FC = ({ createRequest, flowNam onChange={({ target }) => setRequestScheme(target.value)} /> +
+ + +
{!hasResponse && (
{authorizationRequestUriHasBeenFetched ? ( diff --git a/app/components/VerifyTab.tsx b/app/components/VerifyTab.tsx index 6d0f50f..b665737 100644 --- a/app/components/VerifyTab.tsx +++ b/app/components/VerifyTab.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import { createRequest, getIssuer, getX509Certificate } from '../lib/api' -import { type CredentialType, type RequestType, VerifyBlock } from './VerifyBlock' +import { type CredentialType, type RequestType, type ResponseMode, VerifyBlock } from './VerifyBlock' const randomId = () => (Math.random() + 1).toString(36).substring(7) @@ -11,6 +11,7 @@ export function VerifyTab() { credentialType: CredentialType requestType: RequestType requestScheme: string + responseMode: ResponseMode }) => { const issuer = (await getIssuer()).availableX509Certificates[0] return await createRequest({ @@ -19,6 +20,7 @@ export function VerifyTab() { options.credentialType === 'sdjwt' ? getSdJwtPresentationDefinition(issuer, options.requestType) : getMdocPresentationDefinition(options.requestType), + responseMode: options.responseMode, }) } diff --git a/app/lib/api.ts b/app/lib/api.ts index 794036d..71eed49 100644 --- a/app/lib/api.ts +++ b/app/lib/api.ts @@ -66,9 +66,11 @@ export async function receiveOffer(offerUri: string) { export async function createRequest({ presentationDefinition, requestScheme, + responseMode, }: { presentationDefinition: any requestScheme: string + responseMode: 'direct_post' | 'direct_post.jwt' }) { const response = await fetch(`${NEXT_PUBLIC_API_URL}/api/requests/create`, { method: 'POST', @@ -78,6 +80,7 @@ export async function createRequest({ body: JSON.stringify({ presentationDefinition, requestScheme, + responseMode, }), })