@brndts/brndts-ads 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18883,8 +18883,8 @@ var defaults = {
18883
18883
  enabled: true,
18884
18884
  useLocalCache: false,
18885
18885
  presentation: {
18886
- duration: 5,
18887
- cooldown: 60
18886
+ duration: 2,
18887
+ cooldown: 10
18888
18888
  },
18889
18889
  regions: {
18890
18890
  useCache: true,
@@ -20563,6 +20563,8 @@ var KevelProvider = /*#__PURE__*/ function(ContentProvider) {
20563
20563
  return KevelProvider;
20564
20564
  }(ContentProvider);
20565
20565
  // src/Ads/Providers/SmartyAds/SmartyAdsSDK.ts
20566
+ var import_core12 = require("@iabtcf/core");
20567
+ import_core12.GVL.baseUrl = "https://vendor-list.consensu.org/v3/";
20566
20568
  var PARAMS = [
20567
20569
  "res",
20568
20570
  "m",
@@ -20593,38 +20595,119 @@ var SmartyadsSDK = /*#__PURE__*/ function() {
20593
20595
  }
20594
20596
  _create_class(SmartyadsSDK, [
20595
20597
  {
20596
- /**
20598
+ key: "generateTCString",
20599
+ value: function generateTCString() {
20600
+ var _this = this;
20601
+ return _async_to_generator(function() {
20602
+ var tcModel;
20603
+ return _ts_generator(this, function(_state) {
20604
+ switch(_state.label){
20605
+ case 0:
20606
+ if (!!_this.gdprConsent) return [
20607
+ 3,
20608
+ 2
20609
+ ];
20610
+ tcModel = new import_core12.TCModel(new import_core12.GVL());
20611
+ tcModel.vendorConsents.set(534);
20612
+ return [
20613
+ 4,
20614
+ tcModel.gvl.readyPromise
20615
+ ];
20616
+ case 1:
20617
+ _state.sent();
20618
+ _this.gdprConsent = import_core12.TCString.encode(tcModel);
20619
+ console.log(_this.gdprConsent);
20620
+ _state.label = 2;
20621
+ case 2:
20622
+ return [
20623
+ 2,
20624
+ _this.gdprConsent
20625
+ ];
20626
+ }
20627
+ });
20628
+ })();
20629
+ }
20630
+ },
20631
+ {
20632
+ key: "buildQueryParams",
20633
+ value: /**
20597
20634
  * Converts an object into a URL query string.
20598
20635
  *
20599
20636
  * @param params - The object to be converted into query parameters.
20600
20637
  * @returns The query string with URL encoding.
20601
- */ key: "buildQueryParams",
20602
- value: function buildQueryParams(params) {
20603
- var queryString = PARAMS.map(function(key) {
20604
- var value2 = params[key];
20605
- if (value2 === null || value2 === void 0) {
20606
- return "";
20607
- }
20608
- return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value2));
20609
- }).filter(function(part) {
20610
- return part.length > 0;
20611
- }).join("&");
20612
- return queryString;
20638
+ */ function buildQueryParams(params) {
20639
+ var _this = this;
20640
+ return _async_to_generator(function() {
20641
+ var queryString;
20642
+ return _ts_generator(this, function(_state) {
20643
+ switch(_state.label){
20644
+ case 0:
20645
+ if (!(params.gdpr === void 0)) return [
20646
+ 3,
20647
+ 2
20648
+ ];
20649
+ params.gdpr = 1;
20650
+ return [
20651
+ 4,
20652
+ _this.generateTCString()
20653
+ ];
20654
+ case 1:
20655
+ params.gdpr_consent = _state.sent();
20656
+ _state.label = 2;
20657
+ case 2:
20658
+ queryString = PARAMS.map(function(key) {
20659
+ var value2 = params[key];
20660
+ if (value2 === null || value2 === void 0) {
20661
+ return "";
20662
+ }
20663
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value2));
20664
+ }).filter(function(part) {
20665
+ return part.length > 0;
20666
+ }).join("&");
20667
+ return [
20668
+ 2,
20669
+ queryString
20670
+ ];
20671
+ }
20672
+ });
20673
+ })();
20613
20674
  }
20614
20675
  },
20615
20676
  {
20616
20677
  key: "request",
20617
20678
  value: function request(params) {
20618
- return fetch("https://n1.smartyads.com/?c=b&".concat(this.buildQueryParams(params))).then(function(response) {
20619
- if (!response.ok) {
20620
- throw new InternalError("Network response was not ok");
20621
- }
20622
- return response.json();
20623
- }).then(function(data) {
20624
- return data;
20625
- }).catch(function(error) {
20626
- throw error;
20627
- });
20679
+ var _this = this;
20680
+ return _async_to_generator(function() {
20681
+ var _, _1;
20682
+ return _ts_generator(this, function(_state) {
20683
+ switch(_state.label){
20684
+ case 0:
20685
+ _1 = (_ = "https://n1.smartyads.com/?c=b&").concat;
20686
+ return [
20687
+ 4,
20688
+ _this.buildQueryParams(params)
20689
+ ];
20690
+ case 1:
20691
+ return [
20692
+ 2,
20693
+ fetch.apply(void 0, [
20694
+ _1.apply(_, [
20695
+ _state.sent()
20696
+ ])
20697
+ ]).then(function(response) {
20698
+ if (!response.ok) {
20699
+ throw new InternalError("Network response was not ok");
20700
+ }
20701
+ return response.json();
20702
+ }).then(function(data) {
20703
+ return data;
20704
+ }).catch(function(error) {
20705
+ throw error;
20706
+ })
20707
+ ];
20708
+ }
20709
+ });
20710
+ })();
20628
20711
  }
20629
20712
  }
20630
20713
  ]);