Skip to content

Commit

Permalink
style: formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Oct 8, 2024
1 parent ae51093 commit 340b831
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
"tslog": "^4.8.2",
"typescript": "~5.5.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { PartialSdJwtDecodedVerifiableCredential } from '@sphereon/pex/dist/main
export class DifPresentationExchangeService {
private pex = new PEX({ hasher: Hasher.hash })

public constructor(private w3cCredentialService: W3cCredentialService) { }
public constructor(private w3cCredentialService: W3cCredentialService) {}

public async getCredentialsForRequest(
agentContext: AgentContext,
Expand Down Expand Up @@ -244,7 +244,10 @@ export class DifPresentationExchangeService {

return {
verifiablePresentations: verifiablePresentationResultsWithFormat.map((resultWithFormat) =>
getVerifiablePresentationFromEncoded(agentContext, resultWithFormat.verifiablePresentationResult.verifiablePresentation)
getVerifiablePresentationFromEncoded(
agentContext,
resultWithFormat.verifiablePresentationResult.verifiablePresentation
)
),
presentationSubmission,
presentationSubmissionLocation:
Expand Down Expand Up @@ -611,8 +614,8 @@ export class DifPresentationExchangeService {
const w3cCredentialRecords =
w3cQuery.length > 0
? await w3cCredentialRepository.findByQuery(agentContext, {
$or: w3cQuery,
})
$or: w3cQuery,
})
: await w3cCredentialRepository.getAll(agentContext)

allRecords.push(...w3cCredentialRecords)
Expand All @@ -621,8 +624,8 @@ export class DifPresentationExchangeService {
const sdJwtVcRecords =
sdJwtVcQuery.length > 0
? await sdJwtVcApi.findAllByQuery({
$or: sdJwtVcQuery,
})
$or: sdJwtVcQuery,
})
: await sdJwtVcApi.getAll()

allRecords.push(...sdJwtVcRecords)
Expand Down
2 changes: 1 addition & 1 deletion packages/openid4vc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"rimraf": "^4.4.0",
"typescript": "~5.5.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class OpenId4VcSiopVerifierService {
private openId4VcVerifierRepository: OpenId4VcVerifierRepository,
private config: OpenId4VcVerifierModuleConfig,
private openId4VcVerificationSessionRepository: OpenId4VcVerificationSessionRepository
) { }
) {}

public async createAuthorizationRequest(
agentContext: AgentContext,
Expand All @@ -107,9 +107,9 @@ export class OpenId4VcSiopVerifierService {
const jwtIssuer =
options.requestSigner.method === 'x5c'
? await openIdTokenIssuerToJwtIssuer(agentContext, {
...options.requestSigner,
issuer: authorizationResponseUrl,
})
...options.requestSigner,
issuer: authorizationResponseUrl,
})
: await openIdTokenIssuerToJwtIssuer(agentContext, options.requestSigner)

let clientIdScheme: ClientIdScheme
Expand Down Expand Up @@ -363,18 +363,18 @@ export class OpenId4VcSiopVerifierService {
verifierId,
}:
| {
authorizationResponse?: never
authorizationResponseParams: {
state?: string
nonce?: string
authorizationResponse?: never
authorizationResponseParams: {
state?: string
nonce?: string
}
verifierId?: string
}
verifierId?: string
}
| {
authorizationResponse: OpenId4VcSiopAuthorizationResponsePayload
authorizationResponseParams?: never
verifierId?: string
}
authorizationResponse: OpenId4VcSiopAuthorizationResponsePayload
authorizationResponseParams?: never
verifierId?: string
}
) {
let nonce: string | undefined
let state: string | undefined
Expand Down Expand Up @@ -514,10 +514,10 @@ export class OpenId4VcSiopVerifierService {
const jarmClientMetadata: (JarmClientMetadata & { jwks: { keys: JarmEncryptionJwk[] } }) | undefined =
jarmEncryptionJwk
? {
jwks: { keys: [jarmEncryptionJwk] },
authorization_encrypted_response_alg: 'ECDH-ES',
authorization_encrypted_response_enc: 'A256GCM',
}
jwks: { keys: [jarmEncryptionJwk] },
authorization_encrypted_response_alg: 'ECDH-ES',
authorization_encrypted_response_enc: 'A256GCM',
}
: undefined

builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe('OpenId4VcVerifier', () => {

expect(
authorizationRequest.startsWith(
`openid4vp://?client_id=${encodeURIComponent(verifier.did)}&request_uri=http%3A%2F%2Fredirect-uri%2F${openIdVerifier.verifierId
`openid4vp://?client_id=${encodeURIComponent(verifier.did)}&request_uri=http%3A%2F%2Fredirect-uri%2F${
openIdVerifier.verifierId
}%2Fauthorization-requests%2F`
)
).toBe(true)
Expand Down Expand Up @@ -87,7 +88,8 @@ describe('OpenId4VcVerifier', () => {

expect(
authorizationRequest.startsWith(
`openid://?client_id=${encodeURIComponent(verifier.did)}&request_uri=http%3A%2F%2Fredirect-uri%2F${openIdVerifier.verifierId
`openid://?client_id=${encodeURIComponent(verifier.did)}&request_uri=http%3A%2F%2Fredirect-uri%2F${
openIdVerifier.verifierId
}%2Fauthorization-requests%2F`
)
).toBe(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class OpenId4VcRelyingPartyEventEmitter implements NativeEventEmitter {
private nativeEventEmitter: NativeEventEmitter,
private contextCorrelationId: string,
private verifierId: string
) { }
) {}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public emit(eventName: string | symbol, ...args: any[]): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export function configureAuthorizationEndpoint(router: Router, config: OpenId4Vc
try {
const openId4VcVerifierService = agentContext.dependencyManager.resolve(OpenId4VcSiopVerifierService)



let verificationSession: OpenId4VcVerificationSessionRecord | undefined
let authorizationResponsePayload: AuthorizationResponsePayload

Expand Down
5 changes: 4 additions & 1 deletion packages/openid4vc/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ export async function openIdTokenIssuerToJwtIssuer(
throw new CredoError('The X509 certificate issuer must be a HTTPS URI.')
}

if (!leafCertificate.sanUriNames?.includes(openId4VcTokenIssuer.issuer) && !leafCertificate.sanDnsNames?.includes(getDomainFromUrl(openId4VcTokenIssuer.issuer))) {
if (
!leafCertificate.sanUriNames?.includes(openId4VcTokenIssuer.issuer) &&
!leafCertificate.sanDnsNames?.includes(getDomainFromUrl(openId4VcTokenIssuer.issuer))
) {
throw new Error(
`The 'iss' claim in the payload does not match a 'SAN-URI' or 'SAN-DNS' name in the x5c certificate.`
)
Expand Down
12 changes: 7 additions & 5 deletions packages/openid4vc/tests/openid4vc.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,9 @@ describe('OpenId4Vc', () => {
verifier.agent.modules.openId4VcVerifier.config.options.baseUrl.replace('https://', 'http://')

expect(authorizationRequest.replace('https', 'http')).toEqual(
`openid4vp://?client_id=localhost%3A1234&request_uri=${encodeURIComponent(verificationSession.authorizationRequestUri)}`
`openid4vp://?client_id=localhost%3A1234&request_uri=${encodeURIComponent(
verificationSession.authorizationRequestUri
)}`
)

const resolvedAuthorizationRequest = await holder.agent.modules.openId4VcHolder.resolveSiopAuthorizationRequest(
Expand Down Expand Up @@ -1421,7 +1423,7 @@ describe('OpenId4Vc', () => {
iss: 'did:key:z6MkrzQPBr4pyqC776KKtrz13SchM5ePPbssuPuQZb5t4uKQ',
vct: 'OpenBadgeCredential2',
degree: 'bachelor2',
name: 'John Doe2'
name: 'John Doe2',
},
},
],
Expand Down Expand Up @@ -1566,7 +1568,7 @@ describe('OpenId4Vc', () => {
iat: expect.any(Number),
iss: 'did:key:z6MkrzQPBr4pyqC776KKtrz13SchM5ePPbssuPuQZb5t4uKQ',
vct: 'OpenBadgeCredential2',
degree: 'bachelor2'
degree: 'bachelor2',
},
prettyClaims: {
cnf: {
Expand All @@ -1576,10 +1578,10 @@ describe('OpenId4Vc', () => {
iss: 'did:key:z6MkrzQPBr4pyqC776KKtrz13SchM5ePPbssuPuQZb5t4uKQ',
vct: 'OpenBadgeCredential2',
name: 'John Doe2',
degree: 'bachelor2'
degree: 'bachelor2',
},
},
],
})
})
})
})

0 comments on commit 340b831

Please sign in to comment.