Skip to content

Commit 7c10c6f

Browse files
committed
chore: integrate main
Signed-off-by: Timo Glastra <[email protected]>
1 parent 43becf8 commit 7c10c6f

11 files changed

+47
-28
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"style:check": "biome check --unsafe",
2424
"style:fix": "biome check --write --unsafe",
2525
"build": "tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
26-
"test": "jest --verbose"
26+
"test": "vitest"
2727
},
2828
"dependencies": {
2929
"compare-versions": "^6.1.1"

src/__tests__/__snapshots__/diagnostic.tests.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`diagnostic info should return the version 1`] = `
3+
exports[`diagnostic info > should return the version 1`] = `
44
{
55
"attributes": [
66
{
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import assert from 'node:assert'
2-
import { describe, it } from 'node:test'
3-
import { hexToUint8Array, uint8ArrayToHex } from '../../u-hex'
4-
import { DeviceRequest } from './device-request'
1+
import { hexToUint8Array, uint8ArrayToHex } from '../u-hex'
2+
import { DeviceRequest } from '../mdoc/model/device-request'
3+
import { describe, expect, it } from 'vitest'
54

65
export const cbor =
76
'a26776657273696f6e63312e306b646f63526571756573747381a26c6974656d7352657175657374d8185893a267646f6354797065756f72672e69736f2e31383031332e352e312e6d444c6a6e616d65537061636573a1716f72672e69736f2e31383031332e352e31a66b66616d696c795f6e616d65f56f646f63756d656e745f6e756d626572f57264726976696e675f70726976696c65676573f56a69737375655f64617465f56b6578706972795f64617465f568706f727472616974f46a726561646572417574688443a10126a118215901b7308201b330820158a00302010202147552715f6add323d4934a1ba175dc945755d8b50300a06082a8648ce3d04030230163114301206035504030c0b72656164657220726f6f74301e170d3230313030313030303030305a170d3233313233313030303030305a3011310f300d06035504030c067265616465723059301306072a8648ce3d020106082a8648ce3d03010703420004f8912ee0f912b6be683ba2fa0121b2630e601b2b628dff3b44f6394eaa9abdbcc2149d29d6ff1a3e091135177e5c3d9c57f3bf839761eed02c64dd82ae1d3bbfa38188308185301c0603551d1f041530133011a00fa00d820b6578616d706c652e636f6d301d0603551d0e04160414f2dfc4acafc5f30b464fada20bfcd533af5e07f5301f0603551d23041830168014cfb7a881baea5f32b6fb91cc29590c50dfac416e300e0603551d0f0101ff04040302078030150603551d250101ff040b3009060728818c5d050106300a06082a8648ce3d0403020349003046022100fb9ea3b686fd7ea2f0234858ff8328b4efef6a1ef71ec4aae4e307206f9214930221009b94f0d739dfa84cca29efed529dd4838acfd8b6bee212dc6320c46feb839a35f658401f3400069063c189138bdcd2f631427c589424113fc9ec26cebcacacfcdb9695d28e99953becabc4e30ab4efacc839a81f9159933d192527ee91b449bb7f80bf'
@@ -13,6 +12,6 @@ void describe('device-request', () => {
1312
const encoded = deviceRequest.encode()
1413
const hexres = uint8ArrayToHex(encoded)
1514
const deviceRequest2 = DeviceRequest.parse(hexToUint8Array(hexres))
16-
assert.deepEqual(deviceRequest, deviceRequest2)
15+
expect(deviceRequest).toStrictEqual(deviceRequest2)
1716
})
1817
})

src/__tests__/example/__snapshots__/example4.tests.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`example 4: device response with device attributes should get the right diagnostic info 1`] = `
3+
exports[`example 4: device response with device attributes > should get the right diagnostic info 1`] = `
44
{
55
"attributes": [
66
{

src/__tests__/issuing/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const deviceRequest = DeviceRequest.from('1.0', [
110110
docType: 'org.iso.18013.5.1.mDL',
111111
nameSpaces: {
112112
'org.iso.18013.5.1': {
113-
family_name: true,
113+
family_name: false,
114114
given_name: true,
115115
birth_date: true,
116116
issue_date: true,

src/__tests__/issuing/device-response.tests.ts

+21
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ describe('issuing a device response', () => {
292292
const eReaderKeyBytes: Buffer = randomFillSync(Buffer.alloc(32))
293293
const readerEngagementBytes = randomFillSync(Buffer.alloc(32))
294294
const deviceEngagementBytes = randomFillSync(Buffer.alloc(32))
295+
let encodedDeviceResponse: Uint8Array
295296

296297
const getSessionTranscriptBytes = (rdrEngtBytes: Buffer, devEngtBytes: Buffer, eRdrKeyBytes: Buffer) =>
297298
cborEncode(
@@ -386,6 +387,26 @@ describe('issuing a device response', () => {
386387
expect(validityInfo.expectedUpdate).toBeUndefined()
387388
})
388389

390+
it('should contain all requested claims', () => {
391+
const namespaces = parsedDocument.allIssuerSignedNamespaces
392+
expect(namespaces).toStrictEqual({
393+
'org.iso.18013.5.1': {
394+
family_name: 'Jones',
395+
birth_date: '2007-03-25',
396+
document_number: '01-856-5050',
397+
given_name: 'Ava',
398+
driving_privileges: [expect.any(Map)],
399+
expiry_date: '2028-09-30',
400+
issue_date: '2023-09-01',
401+
issuing_authority: 'NY DMV',
402+
issuing_country: 'US',
403+
issuing_jurisdiction: 'New York',
404+
portrait: 'bstr',
405+
un_distinguishing_sign: 'tbd-us.ny.dmv',
406+
},
407+
})
408+
})
409+
389410
it('should contain the device namespaces', () => {
390411
expect(parsedDocument.getDeviceNameSpace('com.foobar-device')).toEqual({
391412
test: 1234,

src/__tests__/parser/__snapshots__/device-response.tests.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`parse DeviceResponse Example 1 parse should decoded protected headers 1`] = `
3+
exports[`parse DeviceResponse Example 1 > parse > should decoded protected headers 1`] = `
44
Map {
55
1 => -7,
66
4 => {
@@ -548,7 +548,7 @@ Map {
548548
}
549549
`;
550550

551-
exports[`parse DeviceResponse Example 1 parse should match the snapshot 1`] = `
551+
exports[`parse DeviceResponse Example 1 > parse > should match the snapshot 1`] = `
552552
MDoc {
553553
"documentErrors": [],
554554
"documents": [

src/__tests__/parser/__snapshots__/device-response2.tests.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`parse DeviceResponse Example 2 parse should decoded protected headers 1`] = `
3+
exports[`parse DeviceResponse Example 2 > parse > should decoded protected headers 1`] = `
44
Map {
55
1 => -7,
66
}
77
`;
88

9-
exports[`parse DeviceResponse Example 2 parse should match the snapshot 1`] = `
9+
exports[`parse DeviceResponse Example 2 > parse > should match the snapshot 1`] = `
1010
MDoc {
1111
"documentErrors": [],
1212
"documents": [

src/__tests__/parser/__snapshots__/issuer-signed.tests.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`parse an issuer signed mdoc should match the snapshot 1`] = `
3+
exports[`parse an issuer signed mdoc > should match the snapshot 1`] = `
44
MDoc {
55
"documentErrors": [],
66
"documents": [

src/mdoc/model/pex-limit-disclosure.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ export const limitDisclosureToDeviceRequestNameSpaces = (
1313

1414
for (const [nameSpace, nameSpaceFields] of Object.entries(deviceRequestNameSpaces)) {
1515
const nsAttrs = mdoc.issuerSigned.nameSpaces[nameSpace] ?? []
16-
const digests = Object.entries(nameSpaceFields)
17-
.filter(([_, disclose]) => disclose)
18-
.map(([elementIdentifier, _]) => {
19-
const digest = prepareDigest(elementIdentifier, nsAttrs)
20-
if (!digest) {
21-
throw new Error(`No matching field found for '${elementIdentifier}'`)
22-
}
23-
return digest
24-
})
16+
const digests = Object.entries(nameSpaceFields).map(([elementIdentifier, _]) => {
17+
const digest = prepareDigest(elementIdentifier, nsAttrs)
18+
if (!digest) {
19+
throw new Error(`No matching field found for '${elementIdentifier}'`)
20+
}
21+
return digest
22+
})
2523

2624
nameSpaces[nameSpace] = digests
2725
}

vite.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
test: {
33
watch: false,
4+
include: ['**/*.{test,tests}.ts']
45
},
56
}

0 commit comments

Comments
 (0)