Skip to content

Commit

Permalink
feat: add dc api response params
Browse files Browse the repository at this point in the history
  • Loading branch information
auer-martin committed Feb 17, 2025
1 parent 6c0ac2e commit 99cdec6
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dateToSeconds } from '@openid4vc/utils'
import { addSecondsToDate } from '../../../utils/src/date'
import type { Openid4vpAuthorizationRequest } from '../authorization-request/z-authorization-request'
import type { Openid4vpAuthorizationRequestDcApi } from '../authorization-request/z-authorization-request-dc-api'
import { isOpenid4vpAuthorizationRequestDcApi } from '../authorization-request/z-authorization-request-dc-api'
import { createJarmAuthResponse } from '../jarm/jarm-auth-response-create'
import { extractJwksFromClientMetadata } from '../jarm/jarm-extract-jwks'
import { isJarmResponseMode } from '../jarm/jarm-response-mode'
Expand Down Expand Up @@ -32,6 +33,7 @@ export async function createOpenid4vpAuthorizationResponse(
): Promise<{
responseParams: Openid4vpAuthorizationResponse | Openid4vpAuthorizationResponseDcApi['data']
jarm?: { responseJwt: string }
dcApiResponseParams?: Openid4vpAuthorizationResponseDcApi
}> {
const { requestParams, responseParams, jarm, callbacks } = options
const openid4vpAuthResponseParams = {
Expand All @@ -46,7 +48,15 @@ export async function createOpenid4vpAuthorizationResponse(
}

if (!jarm) {
return { responseParams: openid4vpAuthResponseParams }
return {
responseParams: openid4vpAuthResponseParams,
...(isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
dcApiResponseParams: {
protocol: 'openid4vp',
data: openid4vpAuthResponseParams,
},
}),
}
}

if (!requestParams.client_metadata) {
Expand Down Expand Up @@ -117,5 +127,11 @@ export async function createOpenid4vpAuthorizationResponse(
return {
responseParams: jarmResponseParams,
jarm: { responseJwt: result.jarmAuthResponseJwt },
...(isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
dcApiResponseParams: {
protocol: 'openid4vp',
data: jarmResponseParams,
},
}),
}
}

0 comments on commit 99cdec6

Please sign in to comment.