diff --git a/packages/openid4vc/tests/openid4vc.e2e.test.ts b/packages/openid4vc/tests/openid4vc.e2e.test.ts index 6cad2cfeab..56c83311cc 100644 --- a/packages/openid4vc/tests/openid4vc.e2e.test.ts +++ b/packages/openid4vc/tests/openid4vc.e2e.test.ts @@ -16,6 +16,8 @@ import { W3cCredentialSubject, w3cDate, W3cIssuer, + X509Module, + KeyType, Jwt, Jwk, } from '@credo-ts/core' @@ -57,6 +59,7 @@ describe('OpenId4Vc', () => { let issuer: AgentType<{ openId4VcIssuer: OpenId4VcIssuerModule tenants: TenantsModule<{ openId4VcIssuer: OpenId4VcIssuerModule }> + x509: X509Module }> let issuer1: TenantType let issuer2: TenantType @@ -80,6 +83,7 @@ describe('OpenId4Vc', () => { issuer = (await createAgentFromModules( 'issuer', { + x509: new X509Module(), openId4VcIssuer: new OpenId4VcIssuerModule({ baseUrl: issuanceBaseUrl, endpoints: { @@ -130,6 +134,7 @@ describe('OpenId4Vc', () => { openId4VcHolder: new OpenId4VcHolderModule(), askar: new AskarModule(askarModuleConfig), tenants: new TenantsModule(), + x509: new X509Module(), }, '96213c3d7fc8d4d6754c7a0fd969598e' )) as unknown as typeof holder @@ -703,10 +708,7 @@ describe('OpenId4Vc', () => { const openIdVerifier = await verifier.agent.modules.openId4VcVerifier.createVerifier() const signedSdJwtVc = await issuer.agent.sdJwtVc.sign({ - holder: { - method: 'did', - didUrl: holder.kid, - }, + holder: { method: 'did', didUrl: holder.kid }, issuer: { method: 'did', didUrl: issuer.kid, @@ -722,8 +724,17 @@ describe('OpenId4Vc', () => { }, }) + const certificate = await verifier.agent.x509.createSelfSignedCertificate({ + key: await verifier.agent.wallet.createKey({ keyType: KeyType.Ed25519 }), + extensions: [[{ type: 'dns', value: 'example.com' }]], + }) + + const rawCertificate = certificate.toString('base64') await holder.agent.sdJwtVc.store(signedSdJwtVc.compact) + await holder.agent.x509.addTrustedCertificate(rawCertificate) + await verifier.agent.x509.addTrustedCertificate(rawCertificate) + const presentationDefinition = { id: 'OpenBadgeCredential', input_descriptors: [ @@ -756,9 +767,11 @@ describe('OpenId4Vc', () => { const { authorizationRequest, verificationSession } = await verifier.agent.modules.openId4VcVerifier.createAuthorizationRequest({ verifierId: openIdVerifier.verifierId, + requestSigner: { - method: 'did', - didUrl: verifier.kid, + method: 'x5c', + x5c: [rawCertificate], + issuer: 'https://example.com/hakuna/matadata', }, presentationExchange: { definition: presentationDefinition, diff --git a/packages/openid4vc/tests/utils.ts b/packages/openid4vc/tests/utils.ts index cb63da0ec6..d076e4b65c 100644 --- a/packages/openid4vc/tests/utils.ts +++ b/packages/openid4vc/tests/utils.ts @@ -4,7 +4,7 @@ import type { OpenId4VcVerificationSessionState, OpenId4VcVerificationSessionStateChangedEvent, } from '../src' -import type { BaseEvent, ModulesMap } from '@credo-ts/core' +import type { BaseEvent, ModulesMap, X509Module } from '@credo-ts/core' import type { TenantsModule } from '@credo-ts/tenants' import type { Observable } from 'rxjs' @@ -44,7 +44,7 @@ export async function createAgentFromModules(label: strin export type AgentType = Awaited>> // eslint-disable-next-line @typescript-eslint/no-explicit-any -type AgentWithTenantsModule = Agent<{ tenants: TenantsModule }> +type AgentWithTenantsModule = Agent<{ tenants: TenantsModule; x509: X509Module }> export async function createTenantForAgent( // FIXME: we need to make some improvements on the agent typing. It'a quite hard