@adv-ui/boros-tcf
Version:
Adevinta GDPR - Transparency and Consent Framework - API
190 lines (145 loc) • 7.63 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TcfApiInitializer = void 0;
var _brusc = _interopRequireDefault(require("brusc"));
var _ioc = require("../../core/ioc/ioc");
var _PingUseCase = require("../../application/services/ping/PingUseCase");
var _GetVendorListUseCase = require("../../application/services/vendorlist/GetVendorListUseCase");
var _LoadUserConsentUseCase = require("../../application/services/vendorconsent/LoadUserConsentUseCase");
var _SaveUserConsentUseCase = require("../../application/services/vendorconsent/SaveUserConsentUseCase");
var _TcfApiRegistryService = require("../service/TcfApiRegistryService");
var _TcfApiController = require("../controller/TcfApiController");
var _BorosTcf = require("../../application/BorosTcf");
var _VendorListRepository = require("../../domain/vendorlist/VendorListRepository");
var _ConsentRepository = require("../../domain/consent/ConsentRepository");
var _CookieConsentRepository = require("../repository/CookieConsentRepository");
var _BrowserCookieStorage = require("../repository/cookie/BrowserCookieStorage");
var _ConsentEncoderService = require("../../domain/consent/ConsentEncoderService");
var _IABConsentEncoderService = require("../service/IABConsentEncoderService");
var _ConsentDecoderService = require("../../domain/consent/ConsentDecoderService");
var _IABConsentDecoderService = require("../service/IABConsentDecoderService");
var _LoadConsentService = require("../../domain/consent/LoadConsentService");
var _ConsentFactory = require("../../domain/consent/ConsentFactory");
var _IABVendorListRepository = require("../repository/iab/IABVendorListRepository");
var _GVLFactory = require("../repository/iab/GVLFactory");
var _GetTCDataUseCase = require("../../application/services/tcdata/GetTCDataUseCase");
var _AddEventListenerUseCase = require("../../application/services/event/AddEventListenerUseCase");
var _DomainEventBus = require("../../domain/service/DomainEventBus");
var _ChangeUiVisibleUseCase = require("../../application/services/ui/ChangeUiVisibleUseCase");
var _RemoveEventListenerUseCase = require("../../application/services/event/RemoveEventListenerUseCase");
var _EventStatusService = require("../../domain/service/EventStatusService");
var _StatusRepository = require("../../domain/status/StatusRepository");
var _InMemoryStatusRepository = require("../../infrastructure/status/InMemoryStatusRepository");
var _TcfApiV = require("../../application/TcfApiV2");
var _ObservableFactory = require("../../domain/service/ObservableFactory");
var _tcfInstanceAdapter = require("../adapter/tcfInstanceAdapter");
var _UseCaseAdapterFactory = require("../adapter/UseCaseAdapterFactory");
var _constants = require("../../core/constants");
var TcfApiInitializer = /*#__PURE__*/function () {
function TcfApiInitializer() {}
TcfApiInitializer.init = function init(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
language = _ref.language,
reporter = _ref.reporter,
scope = _ref.scope;
if (typeof window !== 'undefined' && window.__tcfapi_boros) {
return window.__tcfapi_boros;
}
_brusc["default"].define(_ioc.inject) // Application Facades
.singleton(_TcfApiController.TcfApiController, function () {
return new _TcfApiController.TcfApiController();
}).singleton(_TcfApiV.TcfApiV2, function () {
return new _TcfApiV.TcfApiV2();
}) // Use Cases
.singleton(_AddEventListenerUseCase.AddEventListenerUseCase, function () {
return new _AddEventListenerUseCase.AddEventListenerUseCase();
}).singleton(_ChangeUiVisibleUseCase.ChangeUiVisibleUseCase, function () {
return new _ChangeUiVisibleUseCase.ChangeUiVisibleUseCase();
}).singleton(_GetTCDataUseCase.GetTCDataUseCase, function () {
return new _GetTCDataUseCase.GetTCDataUseCase();
}).singleton(_GetVendorListUseCase.GetVendorListUseCase, function () {
return new _GetVendorListUseCase.GetVendorListUseCase();
}).singleton(_LoadUserConsentUseCase.LoadUserConsentUseCase, function () {
return new _LoadUserConsentUseCase.LoadUserConsentUseCase();
}).singleton(_PingUseCase.PingUseCase, function () {
return new _PingUseCase.PingUseCase();
}).singleton(_RemoveEventListenerUseCase.RemoveEventListenerUseCase, function () {
return new _RemoveEventListenerUseCase.RemoveEventListenerUseCase();
}).singleton(_SaveUserConsentUseCase.SaveUserConsentUseCase, function () {
return new _SaveUserConsentUseCase.SaveUserConsentUseCase();
}) // Services
.singleton(_ConsentDecoderService.ConsentDecoderService, function () {
return new _IABConsentDecoderService.IABConsentDecoderService();
}).singleton(_ConsentEncoderService.ConsentEncoderService, function () {
return new _IABConsentEncoderService.IABConsentEncoderService();
}).singleton(_DomainEventBus.DomainEventBus, function () {
return new _DomainEventBus.DomainEventBus({
reporter: reporter
});
}).singleton(_EventStatusService.EventStatusService, function () {
return new _EventStatusService.EventStatusService();
}).singleton(_LoadConsentService.LoadConsentService, function () {
return new _LoadConsentService.LoadConsentService();
}) // Repositories
.singleton(_ConsentRepository.ConsentRepository, function () {
return new _CookieConsentRepository.CookieConsentRepository({
window: window,
scope: scope
});
}).singleton(_StatusRepository.StatusRepository, function () {
return new _InMemoryStatusRepository.InMemoryStatusRepository();
}).singleton(_VendorListRepository.VendorListRepository, function () {
return new _IABVendorListRepository.IABVendorListRepository();
}) // Factories
.singleton(_ConsentFactory.ConsentFactory, function () {
return new _ConsentFactory.ConsentFactory({
scope: scope
});
}).singleton(_GVLFactory.GVLFactory, function () {
return new _GVLFactory.GVLFactory({
language: language
});
}).singleton(_ObservableFactory.ObservableFactory, function () {
return new _ObservableFactory.ObservableFactory();
}).singleton(_UseCaseAdapterFactory.UseCaseAdapterFactory, function () {
return new _UseCaseAdapterFactory.UseCaseAdapterFactory();
}) // Tooling & Helpers
.singleton('euconsentCookieStorage', function () {
return new _BrowserCookieStorage.BrowserCookieStorage({
domain: window.location.hostname,
window: window,
cookieName: _constants.VENDOR_CONSENT_COOKIE_NAME
});
}).singleton('borosTcfCookieStorage', function () {
return new _BrowserCookieStorage.BrowserCookieStorage({
domain: window.location.hostname,
window: window,
cookieName: _constants.BOROS_CONSENT_COOKIE_NAME
});
}).adapter({
name: 'UseCaseAdatper',
match: function match() {
return true;
},
adapt: _tcfInstanceAdapter.tcfInstanceAdapter
}).create();
var registryService = new _TcfApiRegistryService.TcfApiRegistryService();
var borosTcf = new _BorosTcf.BorosTcf();
registryService.register({
borosTcf: borosTcf
});
borosTcf.ready();
borosTcf.loadUserConsent({
notify: true
});
if (typeof window !== 'undefined') {
window.__tcfapi_boros = borosTcf;
}
return borosTcf;
};
return TcfApiInitializer;
}();
exports.TcfApiInitializer = TcfApiInitializer;