Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TcfEuv2 decode issue #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/cmpapi/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"],
"spec": [
"./test/GppModel.test.ts",
"./test/Gvl.test.ts",
"./test/encoder/datatype/EncodableBoolean.test.ts",
"./test/encoder/datatype/EncodableDatetime.test.ts",
"./test/encoder/datatype/EncodableFibonacciInteger.test.ts",
Expand Down
11 changes: 6 additions & 5 deletions modules/cmpapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
"test": "npx mocha"
},
"devDependencies": {
"typescript": "^4.7.4",
"terser": "^5.14.1",
"@iabtcf/core": "^1.5.5",
"@types/jest": "^28.1.6",
"chai": "^4.3.6",
"jsdom": "^20.0.0",
"jsdom-global": "^3.0.2",
"mocha": "^10.0.0",
"sinon": "^14.0.0",
"terser": "^5.14.1",
"ts-node": "^10.9.1",
"jsdom": "^20.0.0",
"jsdom-global": "^3.0.2",
"@types/jest": "^28.1.6"
"typescript": "^4.7.4"
}
}
35 changes: 35 additions & 0 deletions modules/cmpapi/test/encoder/section/TcfEuV2.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from "chai";
import { TcfEuV2 } from "../../../src/encoder/section/TcfEuV2";

import { TCString } from "@iabtcf/core";

describe("manifest.section.TcfEuV2", (): void => {
it("encode defaults", (): void => {
let tcfEuV2 = new TcfEuV2();
Expand Down Expand Up @@ -322,4 +324,37 @@ describe("manifest.section.TcfEuV2", (): void => {
expect(vendorsDisclosed[vendorsDisclosed.length - 2]).to.eql(790);
expect(vendorsDisclosed[vendorsDisclosed.length - 1]).to.eql(791);
});

it("should decode this actual TcfEuv2 string", (): void => {
const actualConsentString = 'CPi8wgAPi8wgAAOACBENCuCoAP_AAEfAACiQJHNd_H__bX9n-f7_6ft0eY1f9_r37uQzDhfNk-8F3L_W_LwX_2E7NF36tq4KmR4ku1LBIUNtHMnUDUmxaokVrzHsak2cpzNKJ_BkknsZe2dYGF9vm5tj-QKZ7_5_d3f52T_9_9v-39z33913v3d93-_13LjdV5_9H_v9fR_b8_Kf9_5-_4v8_____3_e______8AEEggCTDVuIAuxLHAm0DCKBECMKwkKoFABBQDC0QGADg4KdlYBPrCBAAgFAEYEQIcAUYEAgAAAgCQiACQIsEAAAIgEAAIAEQiEABAwCCgAsDAIAAQDQMUQoABAkIMiAiKUwICIEggJbKhBKC6Q0wgCrLACgkRsFAAiAAAUgACAsHAMESAlYsECTFG-QAjBCgFEqFaAGGgAwABBI4RABgACCRwqADAAEEjgA';

let decodedWithPublicLibrary = TCString.decode(actualConsentString);
expect(decodedWithPublicLibrary.cmpId).to.equal(14);

// Currently this fails with "DecodingError: Undecodable Boolean ''".
let decodedWithThisLibrary = new TcfEuV2(actualConsentString);
expect(decodedWithThisLibrary.getFieldValue('CmpId')).to.equal(14);
});

it("should decode this other actual TcfEuv2 string", (): void => {
const actualConsentString = 'CPgA5EAPgA5EAAOACBENCuCoAP_AAEfAACiQI0Nd_H__bX9n-f7_6Pt0cY1f9_r3ruQzDhfFk-8F3L_W3LwX32E7NF36pq4KmR4ku1LBIQFtHMnUDUmxaokVrzHsak2cpyNKI7BkknsZe2dYGF9Pm5lD-QKZ7_5_d3f52T_9_9v-39z339V3v3d93-_12PjdV599H_v9fR_b8_Kf9_5-_4v8___4IQAAAAQQ_AJMNW4gC7EscCbQMIoAQIwrCQqAUAEFAMLRAYAODgpmVgEusIEACAUARgRAhxBRgQCAAACAJCIAJAiwQAIAiAQAAgARAIQAEDAIKACwMAgABANAxACgAECQgyICIpTAgIgSCAlsqEEoKpDTCAKssAKARGwUACIAABSAAICwcAwRICViwQJMUbwAw0AGAAIJHCIAMAAQSOFQAYAAgkcA';

let decodedWithPublicLibrary = TCString.decode(actualConsentString);
expect(decodedWithPublicLibrary.cmpId).to.equal(14);

// Currently this fails with "DecodingError: Undecodable Boolean ''".
let decodedWithThisLibrary = new TcfEuV2(actualConsentString);
expect(decodedWithThisLibrary.getFieldValue('CmpId')).to.equal(14);
});

it("should decode this 3rd test TcfEuv2 string", (): void => {
const consentString = 'COv_eg6Ov_eg6AOADBENAaCgAP_AAH_AACiQAVEUQQoAIQAqIoghAAQgAA.YAAAAAAAAAAAAAAAAAA';

let decodedWithPublicLibrary = TCString.decode(consentString);
expect(decodedWithPublicLibrary.cmpId).to.equal(14);

// Currently this fails with "DecodingError: Undecodable Boolean ''".
let decodedWithThisLibrary = new TcfEuV2(consentString);
expect(decodedWithThisLibrary.getFieldValue('CmpId')).to.equal(14);
});
});
Loading