@adv-ui/boros-tcf
Version:
Adevinta GDPR - Transparency and Consent Framework - API
144 lines (121 loc) • 3.79 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Status = void 0;
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
var _ioc = require("../../core/ioc/ioc");
var _ConsentRepository = require("../consent/ConsentRepository");
var _ConsentDecoderService = require("../consent/ConsentDecoderService");
var Status = /*#__PURE__*/function () {
/**
* cmpStatus: CMP not yet loaded – stub still in place
*/
/**
* cmpStatus: CMP is loading
*/
/**
* cmpStatus: CMP is finished loading
*/
/**
* cmpStatus: CMP is in an error state.
* A CMP shall not respond to any other API requests if this cmpStatus is present.
* A CMP may set this status if, for any reason, it is unable to perform the operations
* in compliance with the TCF.
*/
/**
* displayStatus: User interface is currently displayed
*/
/**
* displayStatus: User interface is not yet or no longer displayed
*/
/**
* displayStatus: User interface will not show
* (e.g. GDPR does not apply or TC data is current and does not need renewal)
*/
/**
*
* @param {Object} param
* @param {ConsentRepository} param.consentRepository
* @param {ConsentDecoderService} param.consentDecoderService
*/
function Status(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$consentRepositor = _ref.consentRepository,
consentRepository = _ref$consentRepositor === void 0 ? (0, _ioc.inject)(_ConsentRepository.ConsentRepository) : _ref$consentRepositor,
_ref$consentDecoderSe = _ref.consentDecoderService,
consentDecoderService = _ref$consentDecoderSe === void 0 ? (0, _ioc.inject)(_ConsentDecoderService.ConsentDecoderService) : _ref$consentDecoderSe;
this._consentRepository = consentRepository;
this._consentDecoderService = consentDecoderService;
this._cmpStatus = Status.CMPSTATUS_LOADING;
this._displayStatus = Status.DISPLAYSTATUS_DISABLED;
this._eventStatus = null;
}
/**
* @returns {Boolean}
*/
(0, _createClass2["default"])(Status, [{
key: "loaded",
get: function get() {
return true;
}
/**
* @returns {String}
*/
}, {
key: "cmpStatus",
get: function get() {
return this._cmpStatus;
},
set: function set(cmpStatus) {
this._cmpStatus = cmpStatus;
}
}, {
key: "displayStatus",
get: function get() {
return this._displayStatus;
},
set: function set(displayStatus) {
this._displayStatus = displayStatus;
}
}, {
key: "eventStatus",
get: function get() {
return this._eventStatus;
},
set: function set(eventStatus) {
this._eventStatus = eventStatus;
}
/**
* Returns gvlVersion. undefined if no consent
*
* @readonly
* @returns {Number | undefined}
*/
}, {
key: "gvlVersion",
get: function get() {
var encodedConsent = this._consentRepository.loadUserConsent();
if (!encodedConsent) {
return undefined;
}
var decodedConsent = this._consentDecoderService.decode({
encodedConsent: encodedConsent
});
return decodedConsent.vendorListVersion;
}
}]);
return Status;
}();
exports.Status = Status;
Status.CMPSTATUS_STUB = 'stub';
Status.CMPSTATUS_LOADING = 'loading';
Status.CMPSTATUS_LOADED = 'loaded';
Status.CMPSTATUS_ERROR = 'error';
Status.DISPLAYSTATUS_VISIBLE = 'visible';
Status.DISPLAYSTATUS_HIDDEN = 'hidden';
Status.DISPLAYSTATUS_DISABLED = 'disabled';
Status.USERACTIONCOMPLETE = 'useractioncomplete';
Status.CMPUISHOWN = 'cmpuishown';
Status.TCLOADED = 'tcloaded';