Skip to content

Commit b3ace06

Browse files
committed
Add authz response parsing to ISO 18013-7 test.
1 parent f405e30 commit b3ace06

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @digitalbazaar/oid4-client Changelog
22

3+
## 5.1.0 - 2025-mm-dd
4+
5+
### Added
6+
- Add `oid4vp.verifier.parseAuthorizationResponse()` helper that OID4VP
7+
verifiers can use to parse authorization responses.
8+
39
## 5.0.0 - 2025-08-30
410

511
### Added

lib/oid4vp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export * as authzRequest from './authorizationRequest.js';
55
export * as authzResponse from './authorizationResponse.js';
66
export * as convert from './convert.js';
7+
export * as verifier from './verifier.js';
78

89
// backwards compatibility APIs
910
export {

tests/unit/iso18013-7.spec.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* Copyright (c) 2022-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
//import * as base64url from 'base64url-universal';
4+
import * as base64url from 'base64url-universal';
55
import * as mdlUtils from '../mdlUtils.js';
66
import {exportJWK, generateKeyPair} from 'jose';
77
import {oid4vp, signJWT} from '../../lib/index.js';
@@ -158,20 +158,54 @@ describe('ISO 18013-7', () => {
158158
});
159159

160160
// set `vpToken` to base64url-no-pad-encoded device response
161-
//const vpToken = base64url.encode(deviceResponse);
162-
163-
// FIXME: create authz response
161+
const vpToken = base64url.encode(deviceResponse);
162+
163+
// create authz response
164+
const presentationSubmission = {
165+
id: `urn:uuid:${crypto.randomUUID()}`,
166+
definition_id: presentationDefinition.id,
167+
descriptor_map: [{
168+
id: 'org.iso.18013.5.1.mDL',
169+
format: 'mso_mdoc',
170+
path: '$'
171+
}]
172+
};
173+
const {authorizationResponse} = await oid4vp.authzResponse.create({
174+
presentationSubmission,
175+
authorizationRequest,
176+
vpToken,
177+
encryptionOptions: {
178+
mdl: {
179+
sessionTranscript
180+
}
181+
}
182+
});
164183

165-
// FIXME: parse authz response
184+
// parse authz response into device response
185+
let parsedDeviceResponse;
186+
{
187+
const {
188+
responseMode, parsed
189+
} = await oid4vp.verifier.parseAuthorizationResponse({
190+
body: authorizationResponse,
191+
getDecryptParameters() {
192+
const keys = [kakPrivateKeyJwk];
193+
return {keys};
194+
}
195+
});
196+
expect(responseMode).to.eql('direct_post.jwt');
197+
parsedDeviceResponse = base64url.decode(parsed.vpToken);
198+
}
166199

167-
// FIXME: verify presentation
200+
// verify presentation...
168201

169202
// can currently only be tested in node.js because karma isn't mapping the
170203
// right version of `jose` for `@auth0/mdl`
171204
const isNode = globalThis.process !== undefined;
172205
if(isNode) {
173206
const result = await mdlUtils.verifyPresentation({
174-
deviceResponse, sessionTranscript,
207+
deviceResponse: parsedDeviceResponse,
208+
sessionTranscript,
175209
trustedCertificates: [
176210
issuerCertChainEntities.intermediate.pemCertificate
177211
]

0 commit comments

Comments
 (0)