Skip to content
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
4 changes: 4 additions & 0 deletions modules/cmpapi/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
"./test/encoder/section/UsDe.test.ts",
"./test/encoder/section/UsFl.test.ts",
"./test/encoder/section/UsIa.test.ts",
"./test/encoder/section/UsIn.test.ts",
"./test/encoder/section/UsKy.test.ts",
"./test/encoder/section/UsMd.test.ts",
"./test/encoder/section/UsMn.test.ts",
"./test/encoder/section/UsMt.test.ts",
"./test/encoder/section/UsNat.test.ts",
"./test/encoder/section/UsNe.test.ts",
"./test/encoder/section/UsNh.test.ts",
"./test/encoder/section/UsNj.test.ts",
"./test/encoder/section/UsOr.test.ts",
"./test/encoder/section/UsRi.test.ts",
"./test/encoder/section/UsTn.test.ts",
"./test/encoder/section/UsTx.test.ts",
"./test/encoder/section/UsUt.test.ts",
Expand Down
40 changes: 40 additions & 0 deletions modules/cmpapi/src/encoder/GppModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import { UsNh } from "./section/UsNh.js";
import { UsNj } from "./section/UsNj.js";
import { UsTn } from "./section/UsTn.js";
import { UsMn } from "./section/UsMn.js";
import { UsMd } from "./section/UsMd.js";
import { UsIn } from "./section/UsIn.js";
import { UsKy } from "./section/UsKy.js";
import { UsRi } from "./section/UsRi.js";

export class GppModel {
private sections = new Map<string, EncodableSection>();
Expand Down Expand Up @@ -107,6 +111,18 @@ export class GppModel {
} else if (sectionName === UsMn.NAME) {
section = new UsMn();
this.sections.set(UsMn.NAME, section);
} else if (sectionName === UsMd.NAME) {
section = new UsMd();
this.sections.set(UsMd.NAME, section);
} else if (sectionName === UsIn.NAME) {
section = new UsIn();
this.sections.set(UsIn.NAME, section);
} else if (sectionName === UsKy.NAME) {
section = new UsKy();
this.sections.set(UsKy.NAME, section);
} else if (sectionName === UsRi.NAME) {
section = new UsRi();
this.sections.set(UsRi.NAME, section);
}
} else {
section = this.sections.get(sectionName);
Expand Down Expand Up @@ -342,6 +358,18 @@ export class GppModel {
} else if (sectionIds[i] === UsMn.ID) {
let section = new UsMn(encodedSections[i + 1]);
sections.set(UsMn.NAME, section);
} else if (sectionIds[i] === UsMd.ID) {
let section = new UsMd(encodedSections[i + 1]);
sections.set(UsMd.NAME, section);
} else if (sectionIds[i] === UsIn.ID) {
let section = new UsIn(encodedSections[i + 1]);
sections.set(UsIn.NAME, section);
} else if (sectionIds[i] === UsKy.ID) {
let section = new UsKy(encodedSections[i + 1]);
sections.set(UsKy.NAME, section);
} else if (sectionIds[i] === UsRi.ID) {
let section = new UsRi(encodedSections[i + 1]);
sections.set(UsRi.NAME, section);
}
}
}
Expand Down Expand Up @@ -450,6 +478,18 @@ export class GppModel {
} else if (sectionName === UsMn.NAME) {
section = new UsMn();
this.sections.set(UsMn.NAME, section);
} else if (sectionName === UsMd.NAME) {
section = new UsMd();
this.sections.set(UsMd.NAME, section);
} else if (sectionName === UsIn.NAME) {
section = new UsIn();
this.sections.set(UsIn.NAME, section);
} else if (sectionName === UsKy.NAME) {
section = new UsKy();
this.sections.set(UsKy.NAME, section);
} else if (sectionName === UsRi.NAME) {
section = new UsRi();
this.sections.set(UsRi.NAME, section);
}
} else {
section = this.sections.get(sectionName);
Expand Down
29 changes: 29 additions & 0 deletions modules/cmpapi/src/encoder/field/UsInField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum UsInField {
MSPA_VERSION = "MspaVersion",
MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction",
MSPA_MODE = "MspaMode",
PROCESSING_NOTICE = "ProcessingNotice",
SALE_OPT_OUT_NOTICE = "SaleOptOutNotice",
TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice",
SALE_OPT_OUT = "SaleOptOut",
TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut",
KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents",
ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent",
SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing",
SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded",
}

export const UsIn_CORE_SEGMENT_FIELD_NAMES = [
UsInField.MSPA_VERSION,
UsInField.MSPA_COVERED_TRANSACTION,
UsInField.MSPA_MODE,
UsInField.PROCESSING_NOTICE,
UsInField.SALE_OPT_OUT_NOTICE,
UsInField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsInField.SALE_OPT_OUT,
UsInField.TARGETED_ADVERTISING_OPT_OUT,
UsInField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsInField.ADDITIONAL_DATA_PROCESSING_CONSENT,
];

export const UsIn_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = [UsInField.SENSITIVE_DATA_PROCESSING];
29 changes: 29 additions & 0 deletions modules/cmpapi/src/encoder/field/UsKyField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum UsKyField {
MSPA_VERSION = "MspaVersion",
MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction",
MSPA_MODE = "MspaMode",
PROCESSING_NOTICE = "ProcessingNotice",
SALE_OPT_OUT_NOTICE = "SaleOptOutNotice",
TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice",
SALE_OPT_OUT = "SaleOptOut",
TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut",
KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents",
ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent",
SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing",
SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded",
}

export const UsKy_CORE_SEGMENT_FIELD_NAMES = [
UsKyField.MSPA_VERSION,
UsKyField.MSPA_COVERED_TRANSACTION,
UsKyField.MSPA_MODE,
UsKyField.PROCESSING_NOTICE,
UsKyField.SALE_OPT_OUT_NOTICE,
UsKyField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsKyField.SALE_OPT_OUT,
UsKyField.TARGETED_ADVERTISING_OPT_OUT,
UsKyField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsKyField.ADDITIONAL_DATA_PROCESSING_CONSENT,
];

export const UsKy_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = [UsKyField.SENSITIVE_DATA_PROCESSING];
29 changes: 29 additions & 0 deletions modules/cmpapi/src/encoder/field/UsMdField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum UsMdField {
MSPA_VERSION = "MspaVersion",
MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction",
MSPA_MODE = "MspaMode",
PROCESSING_NOTICE = "ProcessingNotice",
SALE_OPT_OUT_NOTICE = "SaleOptOutNotice",
TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice",
SALE_OPT_OUT = "SaleOptOut",
TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut",
ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent",

GPC_SEGMENT_TYPE = "GpcSegmentType",
GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded",
GPC = "Gpc",
}

export const UsMd_CORE_SEGMENT_FIELD_NAMES = [
UsMdField.MSPA_VERSION,
UsMdField.MSPA_COVERED_TRANSACTION,
UsMdField.MSPA_MODE,
UsMdField.PROCESSING_NOTICE,
UsMdField.SALE_OPT_OUT_NOTICE,
UsMdField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsMdField.SALE_OPT_OUT,
UsMdField.TARGETED_ADVERTISING_OPT_OUT,
UsMdField.ADDITIONAL_DATA_PROCESSING_CONSENT,
];

export const UsMd_GPC_SEGMENT_FIELD_NAMES = [UsMdField.GPC_SEGMENT_TYPE, UsMdField.GPC];
29 changes: 29 additions & 0 deletions modules/cmpapi/src/encoder/field/UsRiField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum UsRiField {
MSPA_VERSION = "MspaVersion",
MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction",
MSPA_MODE = "MspaMode",
PROCESSING_NOTICE = "ProcessingNotice",
SALE_OPT_OUT_NOTICE = "SaleOptOutNotice",
TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice",
SALE_OPT_OUT = "SaleOptOut",
TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut",
KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents",
ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent",
SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing",
SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded",
}

export const UsRi_CORE_SEGMENT_FIELD_NAMES = [
UsRiField.MSPA_VERSION,
UsRiField.MSPA_COVERED_TRANSACTION,
UsRiField.MSPA_MODE,
UsRiField.PROCESSING_NOTICE,
UsRiField.SALE_OPT_OUT_NOTICE,
UsRiField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsRiField.SALE_OPT_OUT,
UsRiField.TARGETED_ADVERTISING_OPT_OUT,
UsRiField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsRiField.ADDITIONAL_DATA_PROCESSING_CONSENT,
];

export const UsRi_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = [UsRiField.SENSITIVE_DATA_PROCESSING];
4 changes: 4 additions & 0 deletions modules/cmpapi/src/encoder/field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ export * from "./UsCtField.js";
export * from "./UsDeField.js";
export * from "./UsFlField.js";
export * from "./UsIaField.js";
export * from "./UsInField.js";
export * from "./UsKyField.js";
export * from "./UsMdField.js";
export * from "./UsMnField.js";
export * from "./UsMtField.js";
export * from "./UsNatField.js";
export * from "./UsNeField.js";
export * from "./UsNhField.js";
export * from "./UsNjField.js";
export * from "./UsOrField.js";
export * from "./UsRiField.js";
export * from "./UsTnField.js";
export * from "./UsTxField.js";
export * from "./UsUtField.js";
Expand Down
14 changes: 13 additions & 1 deletion modules/cmpapi/src/encoder/section/Sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import { UsNh } from "./UsNh.js";
import { UsNj } from "./UsNj.js";
import { UsTn } from "./UsTn.js";
import { UsMn } from "./UsMn.js";
import { UsMd } from "./UsMd.js";
import { UsIn } from "./UsIn.js";
import { UsKy } from "./UsKy.js";
import { UsRi } from "./UsRi.js";

export class Sections {
public static SECTION_ID_NAME_MAP = new Map([
Expand All @@ -41,6 +45,10 @@ export class Sections {
[UsNj.ID, UsNj.NAME],
[UsTn.ID, UsTn.NAME],
[UsMn.ID, UsMn.NAME],
[UsMd.ID, UsMd.NAME],
[UsIn.ID, UsIn.NAME],
[UsKy.ID, UsKy.NAME],
[UsRi.ID, UsRi.NAME],
]);
public static SECTION_ORDER = [
TcfEuV2.NAME,
Expand All @@ -62,6 +70,10 @@ export class Sections {
UsNh.NAME,
UsNj.NAME,
UsTn.NAME,
UsMn.NAME
UsMn.NAME,
UsMd.NAME,
UsIn.NAME,
UsKy.NAME,
UsRi.NAME
];
}
77 changes: 77 additions & 0 deletions modules/cmpapi/src/encoder/section/UsIn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { UsInField } from "../field/UsInField.js";
import { EncodableSegment } from "../segment/EncodableSegment.js";
import { UsInCoreSegment } from "../segment/UsInCoreSegment.js";
import { UsInSensitiveDataConsentSegment } from "../segment/UsInSensitiveDataConsentSegment.js";
import { AbstractLazilyEncodableSection } from "./AbstractLazilyEncodableSection.js";

export class UsIn extends AbstractLazilyEncodableSection {
public static readonly ID = 25;
public static readonly VERSION = 1;
public static readonly NAME = "usin";

constructor(encodedString?: string) {
super();
if (encodedString && encodedString.length > 0) {
this.decode(encodedString);
}
}

//Overriden
public getId(): number {
return UsIn.ID;
}

//Overriden
public getName(): string {
return UsIn.NAME;
}

//Override
public getVersion(): number {
return UsIn.VERSION;
}

//Overriden
protected initializeSegments(): EncodableSegment[] {
let segments: EncodableSegment[] = [];
segments.push(new UsInCoreSegment());
segments.push(new UsInSensitiveDataConsentSegment());
return segments;
}

//Overriden
protected decodeSection(encodedString: string): EncodableSegment[] {
let segments: EncodableSegment[] = this.initializeSegments();

if (encodedString != null && encodedString.length !== 0) {
let encodedSegments = encodedString.split(".");

if (encodedSegments.length > 0) {
segments[0].decode(encodedSegments[0]);
}

if (encodedSegments.length > 1) {
segments[1].setFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED, true);
segments[1].decode(encodedSegments[1]);
} else {
segments[1].setFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED, false);
}
}

return segments;
}

// Overriden
protected encodeSection(segments: EncodableSegment[]): string {
let encodedSegments: string[] = [];

if (segments.length >= 1) {
encodedSegments.push(segments[0].encode());
if (segments.length >= 2 && segments[1].getFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED) === true) {
encodedSegments.push(segments[1].encode());
}
}

return encodedSegments.join(".");
}
}
Loading