UNPKG

@adv-ui/boros-tcf

Version:

Adevinta GDPR - Transparency and Consent Framework - API

83 lines (67 loc) 2.72 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.IABConsentDecoderService = void 0; var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inheritsLoose")); var _ConsentDecoderService = require("../../domain/consent/ConsentDecoderService"); var _core = require("@iabtcf/core"); var IABConsentDecoderService = /*#__PURE__*/function (_ConsentDecoderServic) { (0, _inheritsLoose2["default"])(IABConsentDecoderService, _ConsentDecoderServic); function IABConsentDecoderService() { return _ConsentDecoderServic.apply(this, arguments) || this; } var _proto = IABConsentDecoderService.prototype; /** * * @param {Object} param * @param {String} param.encodedConsent */ _proto.decode = function decode(_ref) { var encodedConsent = _ref.encodedConsent; var mapToModel = function mapToModel(vector) { var _vector$maxId = vector.maxId, maxId = _vector$maxId === void 0 ? 0 : _vector$maxId; var model = {}; for (var i = 1; i <= maxId; i++) { model[i] = vector.has(i); } return model; }; var tcModel = _core.TCString.decode(encodedConsent); var model = { cmpId: tcModel.cmpId, cmpVersion: tcModel.cmpVersion, created: tcModel.created, lastUpdated: tcModel.lastUpdated, isServiceSpecific: tcModel.isServiceSpecific, useNonStandardStacks: tcModel.useNonStandardStacks, publisherCC: tcModel.publisherCountryCode, vendorListVersion: tcModel.vendorListVersion, policyVersion: tcModel.policyVersion, purposeOneTreatment: tcModel.purposeOneTreatment, vendor: { consents: mapToModel(tcModel.vendorConsents), legitimateInterests: mapToModel(tcModel.vendorLegitimateInterests) }, purpose: { consents: mapToModel(tcModel.purposeConsents), legitimateInterests: mapToModel(tcModel.purposeLegitimateInterests) }, specialFeatures: mapToModel(tcModel.specialFeatureOptins), publisher: { consents: mapToModel(tcModel.publisherConsents), customPurpose: { consents: mapToModel(tcModel.publisherCustomConsents), legitimateInterests: mapToModel(tcModel.publisherCustomLegitimateInterests) }, legitimateInterests: mapToModel(tcModel.publisherLegitimateInterests), restrictions: mapToModel(tcModel.publisherRestrictions) } }; return model; }; return IABConsentDecoderService; }(_ConsentDecoderService.ConsentDecoderService); exports.IABConsentDecoderService = IABConsentDecoderService;