Extract TCF core metadata decoder into VG-Core protocol layer
Dieser Commit ist enthalten in:
@@ -37,6 +37,7 @@
|
|||||||
"src/background/request-observer.js",
|
"src/background/request-observer.js",
|
||||||
"src/background/gvl-service.js",
|
"src/background/gvl-service.js",
|
||||||
"src/core/binary-utils.js",
|
"src/core/binary-utils.js",
|
||||||
|
"src/core/tcf-core-metadata-decoder.js",
|
||||||
"src/background.js"
|
"src/background.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -502,43 +502,3 @@ async function persistObservedRequest(observedRequest) {
|
|||||||
tx.onerror = () => reject(tx.error);
|
tx.onerror = () => reject(tx.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function decodeTcStringCoreMetadata(tcString) {
|
|
||||||
if (!tcString || typeof tcString !== "string") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const coreSegment = tcString.split(".")[0];
|
|
||||||
|
|
||||||
try {
|
|
||||||
const bits = base64UrlToBits(coreSegment);
|
|
||||||
|
|
||||||
return {
|
|
||||||
version: bitsToInt(bits, 0, 6),
|
|
||||||
cmpId: bitsToInt(bits, 78, 12),
|
|
||||||
cmpVersion: bitsToInt(bits, 90, 12),
|
|
||||||
consentScreen: bitsToInt(bits, 102, 6),
|
|
||||||
consentLanguage: bitsToString(bits, 108, 12),
|
|
||||||
vendorListVersion: bitsToInt(bits, 120, 12),
|
|
||||||
tcfPolicyVersion: bitsToInt(bits, 132, 6),
|
|
||||||
isServiceSpecific: bitsToBoolean(bits, 138),
|
|
||||||
useNonStandardStacks: bitsToBoolean(bits, 139),
|
|
||||||
purposeOneTreatment: bitsToBoolean(bits, 200),
|
|
||||||
publisherCC: bitsToString(bits, 201, 12)
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("VG-Observe could not decode TC string core metadata", error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function bitsToString(bits, start, length) {
|
|
||||||
let result = "";
|
|
||||||
|
|
||||||
for (let index = start; index < start + length; index += 6) {
|
|
||||||
const charCode = bitsToInt(bits, index, 6) + 65;
|
|
||||||
result += String.fromCharCode(charCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
function decodeTcStringCoreMetadata(tcString) {
|
||||||
|
if (!tcString || typeof tcString !== "string") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const coreSegment = tcString.split(".")[0];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const bits = base64UrlToBits(coreSegment);
|
||||||
|
|
||||||
|
return {
|
||||||
|
version: bitsToInt(bits, 0, 6),
|
||||||
|
cmpId: bitsToInt(bits, 78, 12),
|
||||||
|
cmpVersion: bitsToInt(bits, 90, 12),
|
||||||
|
consentScreen: bitsToInt(bits, 102, 6),
|
||||||
|
consentLanguage: bitsToString(bits, 108, 12),
|
||||||
|
vendorListVersion: bitsToInt(bits, 120, 12),
|
||||||
|
tcfPolicyVersion: bitsToInt(bits, 132, 6),
|
||||||
|
isServiceSpecific: bitsToBoolean(bits, 138),
|
||||||
|
useNonStandardStacks: bitsToBoolean(bits, 139),
|
||||||
|
purposeOneTreatment: bitsToBoolean(bits, 200),
|
||||||
|
publisherCC: bitsToString(bits, 201, 12)
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("VG-Observe could not decode TC string core metadata", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bitsToString(bits, start, length) {
|
||||||
|
let result = "";
|
||||||
|
|
||||||
|
for (let index = start; index < start + length; index += 6) {
|
||||||
|
const charCode = bitsToInt(bits, index, 6) + 65;
|
||||||
|
result += String.fromCharCode(charCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
In neuem Issue referenzieren
Einen Benutzer sperren