|
1 | 1 | /*! |
2 | 2 | * Copyright (c) 2022-2025 Digital Bazaar, Inc. All rights reserved. |
3 | 3 | */ |
4 | | -//import * as base64url from 'base64url-universal'; |
| 4 | +import * as base64url from 'base64url-universal'; |
5 | 5 | import * as mdlUtils from '../mdlUtils.js'; |
6 | 6 | import {exportJWK, generateKeyPair} from 'jose'; |
7 | 7 | import {oid4vp, signJWT} from '../../lib/index.js'; |
@@ -158,20 +158,54 @@ describe('ISO 18013-7', () => { |
158 | 158 | }); |
159 | 159 |
|
160 | 160 | // 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 | + }); |
164 | 183 |
|
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 | + } |
166 | 199 |
|
167 | | - // FIXME: verify presentation |
| 200 | + // verify presentation... |
168 | 201 |
|
169 | 202 | // can currently only be tested in node.js because karma isn't mapping the |
170 | 203 | // right version of `jose` for `@auth0/mdl` |
171 | 204 | const isNode = globalThis.process !== undefined; |
172 | 205 | if(isNode) { |
173 | 206 | const result = await mdlUtils.verifyPresentation({ |
174 | | - deviceResponse, sessionTranscript, |
| 207 | + deviceResponse: parsedDeviceResponse, |
| 208 | + sessionTranscript, |
175 | 209 | trustedCertificates: [ |
176 | 210 | issuerCertChainEntities.intermediate.pemCertificate |
177 | 211 | ] |
|
0 commit comments