diff --git a/package.json b/package.json index 59f4975..bbc1dbb 100644 --- a/package.json +++ b/package.json @@ -161,7 +161,7 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "cborg": "^1.6.0", + "cborg": "^1.10.0", "multiformats": "^11.0.0" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index 2c07412..cdc058f 100644 --- a/src/index.js +++ b/src/index.js @@ -93,6 +93,7 @@ const decodeOptions = { // safe-integer range, which may surprise users strict: true, useMaps: false, + rejectDuplicateMapKeys: true, /** @type {import('cborg').TagDecoder[]} */ tags: [] } diff --git a/test/test-basics.spec.js b/test/test-basics.spec.js index aeefdda..20ecb4a 100644 --- a/test/test-basics.spec.js +++ b/test/test-basics.spec.js @@ -176,4 +176,9 @@ describe('dag-cbor', () => { decoded = decode(encoded) same({ foo: 'bar', baz: null }, decoded) }) + + test('reject duplicate map keys', () => { + const encoded = bytes.fromHex('a3636261720363666f6f0163666f6f02') + assert.throws(() => decode(encoded), /CBOR decode error: found repeat map key "foo"/) + }) })