Skip to content

Commit

Permalink
fix: incorporate parts of the feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
auer-martin committed Jul 26, 2024
1 parent 8765c0b commit cb3e749
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ export class OpenId4VciHolderService {

if (!dPoPSigningAlgValuesSupported) return undefined

const alg = dPoPSigningAlgValuesSupported
.flatMap((alg) => alg)
.find((alg) => getJwkClassFromJwaSignatureAlgorithm(alg))
const alg = dPoPSigningAlgValuesSupported.find((alg) => getJwkClassFromJwaSignatureAlgorithm(alg))

const JwkClass = alg ? getJwkClassFromJwaSignatureAlgorithm(alg) : undefined

Expand Down Expand Up @@ -323,7 +321,6 @@ export class OpenId4VciHolderService {
const createDPoPOptions = await this.getCreateDPoPOptions(agentContext, metadata)
const dPoPJwk = createDPoPOptions ? getJwkFromJson(createDPoPOptions.jwtIssuer.jwk) : undefined

resolvedCredentialOffer.metadata.credentialIssuerMetadata
if (resolvedAuthorizationRequest) {
const { codeVerifier, redirectUri } = resolvedAuthorizationRequest
accessTokenResponse = await accessTokenClient.acquireAccessToken({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import type { AgentContext } from '@credo-ts/core'
import type { AccessTokenRequest, JWK, JWTSignerCallback, SigningAlgo } from '@sphereon/oid4vci-common'
import type { NextFunction, Response, Router } from 'express'

import { getJwkFromKey, CredoError, JwsService, JwtPayload, getJwkClassFromKeyType, Key } from '@credo-ts/core'
import {
getJwkFromKey,
CredoError,
JwsService,
JwtPayload,
getJwkClassFromKeyType,
Key,
joinUriParts,
Jwt,

Check failure on line 14 in packages/openid4vc/src/openid4vc-issuer/router/accessTokenEndpoint.ts

View workflow job for this annotation

GitHub Actions / Validate

'Jwt' is defined but never used
} from '@credo-ts/core'
import {
GrantTypes,
IssueStatus,
Expand All @@ -17,6 +26,7 @@ import { assertValidAccessTokenRequest, createAccessTokenResponse } from '@spher

import { getRequestContext, sendErrorResponse } from '../../shared/router'
import { getVerifyJwtCallback } from '../../shared/utils'
import { OpenId4VcIssuerModuleConfig } from '../OpenId4VcIssuerModuleConfig'
import { OpenId4VcIssuerService } from '../OpenId4VcIssuerService'
import { OpenId4VcCNonceStateManager } from '../repository/OpenId4VcCNonceStateManager'
import { OpenId4VcCredentialOfferSessionStateManager } from '../repository/OpenId4VcCredentialOfferSessionStateManager'
Expand Down Expand Up @@ -125,7 +135,9 @@ export function handleTokenRequest(config: OpenId4VciAccessTokenEndpointConfig)
let dPoPJwk: JWK | undefined
if (request.headers.dpop) {
try {
const fullUrl = request.protocol + '://' + request.get('host') + request.originalUrl
const issuerConfig = agentContext.dependencyManager.resolve(OpenId4VcIssuerModuleConfig)
const fullUrl = joinUriParts(issuerConfig.baseUrl, [requestContext.issuer.issuerId, request.url])

dPoPJwk = await verifyDPoP(
{ method: request.method, headers: request.headers, fullUrl },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import type { OpenId4VcIssuerRecord } from '../repository'
import type { AgentContext } from '@credo-ts/core'
import type { SigningAlgo } from '@sphereon/oid4vci-common'

import { CredoError, JwsService, Jwt } from '@credo-ts/core'
import { CredoError, joinUriParts, JwsService, Jwt } from '@credo-ts/core'
import { verifyResourceDPoP } from '@sphereon/oid4vci-common'

Check failure on line 7 in packages/openid4vc/src/openid4vc-issuer/router/verifyResourceRequest.ts

View workflow job for this annotation

GitHub Actions / Validate

Unable to resolve path to module '@sphereon/oid4vci-common'

import { getVerifyJwtCallback } from '../../shared/utils'
import { OpenId4VcIssuerModuleConfig } from '../OpenId4VcIssuerModuleConfig'
import { OpenId4VcIssuerService } from '../OpenId4VcIssuerService'

export async function verifyResourceRequest(
Expand Down Expand Up @@ -36,7 +37,8 @@ export async function verifyResourceRequest(
},
})

const fullUrl = request.protocol + '://' + request.get('host') + request.originalUrl
const issuerConfig = agentContext.dependencyManager.resolve(OpenId4VcIssuerModuleConfig)
const fullUrl = joinUriParts(issuerConfig.baseUrl, [issuer.issuerId, request.url])
await verifyResourceDPoP(
{ method: request.method, headers: request.headers, fullUrl },
{
Expand Down
4 changes: 2 additions & 2 deletions packages/openid4vc/tests/openid4vc.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('OpenId4Vc', () => {
const issuerTenant2 = await issuer.agent.modules.tenants.getTenantAgent({ tenantId: issuer2.tenantId })

const openIdIssuerTenant1 = await issuerTenant1.modules.openId4VcIssuer.createIssuer({
dPoPSigningAlgValuesSupported: ['EdDSA'],
dPoPSigningAlgValuesSupported: [JwaSignatureAlgorithm.EdDSA],
credentialConfigurationsSupported: {
universityDegree: universityDegreeCredentialConfigurationSupported,
},
Expand Down Expand Up @@ -223,7 +223,7 @@ describe('OpenId4Vc', () => {
},
})
const openIdIssuerTenant2 = await issuerTenant2.modules.openId4VcIssuer.createIssuer({
dPoPSigningAlgValuesSupported: ['EdDSA'],
dPoPSigningAlgValuesSupported: [JwaSignatureAlgorithm.EdDSA],
credentialsSupported: [universityDegreeCredentialSdJwt2],
})

Expand Down

0 comments on commit cb3e749

Please sign in to comment.