@pubtech-ai/core 1.6.5 → 1.7.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SemanticPreEncoder=void 0;var index_js_1=require("../errors/index.js"),index_js_2=require("../model/index.js"),SemanticPreEncoder=function(){function e(){}return e.process=function(e,s){var r=e.gvl;if(!r)throw new index_js_1.EncodingError("Unable to encode TCModel without a GVL");if(!r.isReady)throw new index_js_1.EncodingError("Unable to encode TCModel tcModel.gvl.readyPromise is not resolved");(e=e.clone()).consentLanguage=r.language.slice(0,2).toUpperCase(),(null==s?void 0:s.version)>0&&(null==s?void 0:s.version)<=this.processor.length?e.version=s.version:e.version=this.processor.length;var n=e.version-1;if(!this.processor[n])throw new index_js_1.EncodingError("Invalid version: ".concat(e.version));return this.processor[n](e,r)},e.processor=[function(e){return e},function(e,s){e.publisherRestrictions.gvl=s,e.purposeLegitimateInterests.unset([1,3,4,5,6]);var r=new Map;return r.set("legIntPurposes",e.vendorLegitimateInterests),r.set("purposes",e.vendorConsents),r.forEach((function(r,n){r.forEach((function(o,i){if(o){var t=s.vendors[i];if(!t||t.deletedDate)r.unset(i);else if(0===t[n].length)if("legIntPurposes"===n&&0===t.purposes.length&&0===t.legIntPurposes.length&&t.specialPurposes.length>0);else if(e.isServiceSpecific)if(0===t.flexiblePurposes.length)r.unset(i);else{for(var c=e.publisherRestrictions.getRestrictions(i),l=!1,d=0,u=c.length;d<u&&!l;d++)l=c[d].restrictionType===index_js_2.RestrictionType.REQUIRE_CONSENT&&"purposes"===n||c[d].restrictionType===index_js_2.RestrictionType.REQUIRE_LI&&"legIntPurposes"===n;l||r.unset(i)}else r.unset(i)}}))})),e.vendorsDisclosed.set(s.vendors),e}],e}();exports.SemanticPreEncoder=SemanticPreEncoder;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SemanticPreEncoder=void 0;var index_js_1=require("../errors/index.js"),index_js_2=require("../model/index.js"),SemanticPreEncoder=function(){function e(){}return e.process=function(e,s){var r=e.gvl;if(!r)throw new index_js_1.EncodingError("Unable to encode TCModel without a GVL");if(!r.isReady)throw new index_js_1.EncodingError("Unable to encode TCModel tcModel.gvl.readyPromise is not resolved");e.consentLanguage=r.language.slice(0,2).toUpperCase(),(null==s?void 0:s.version)>0&&(null==s?void 0:s.version)<=this.processor.length?e.version=s.version:e.version=this.processor.length;var n=e.version-1;if(!this.processor[n])throw new index_js_1.EncodingError("Invalid version: ".concat(e.version));return this.processor[n](e,r)},e.processor=[function(e){return e},function(e,s){e.publisherRestrictions.gvl=s,e.purposeLegitimateInterests.unset([1,3,4,5,6]);var r=new Map;return r.set("legIntPurposes",e.vendorLegitimateInterests),r.set("purposes",e.vendorConsents),r.forEach((function(r,n){r.forEach((function(o,i){if(o){var t=s.vendors[i];if(!t||t.deletedDate)r.unset(i);else if(0===t[n].length)if("legIntPurposes"===n&&0===t.purposes.length&&0===t.legIntPurposes.length&&t.specialPurposes.length>0);else if(e.isServiceSpecific)if(0===t.flexiblePurposes.length)r.unset(i);else{for(var c=e.publisherRestrictions.getRestrictions(i),l=!1,d=0,u=c.length;d<u&&!l;d++)l=c[d].restrictionType===index_js_2.RestrictionType.REQUIRE_CONSENT&&"purposes"===n||c[d].restrictionType===index_js_2.RestrictionType.REQUIRE_LI&&"legIntPurposes"===n;l||r.unset(i)}else r.unset(i)}}))})),e.vendorsDisclosed.set(s.vendors),e}],e}();exports.SemanticPreEncoder=SemanticPreEncoder;
@@ -1 +1 @@
1
- "use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConsentLanguages=void 0;var ConsentLanguages=function(){function e(){}return e.prototype.has=function(t){return e.langSet.has(t)},e.prototype.parseLanguage=function(t){var n,r;if(t.length>=2){var o=(t=t.toUpperCase()).split("-")[0];try{for(var a=__values(e.langSet),u=a.next();!u.done;u=a.next()){var i=u.value;if(i==o)return o;if(-1!==i.indexOf(t))return i}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}throw new Error("unsupported language ".concat(t))},e.prototype.forEach=function(t){e.langSet.forEach(t)},Object.defineProperty(e.prototype,"size",{get:function(){return e.langSet.size},enumerable:!1,configurable:!0}),e.langSet=new Set(["AR","BG","BS","CA","CS","DA","DE","EL","EN","ES","ET","EU","FI","FR","GL","HR","HU","IT","JA","LT","LV","MT","NL","NO","PL","PT-BR","PT-PT","RO","RU","SK","SL","SR-CYRL","SR-LATN","SV","TR","ZH"]),e}();exports.ConsentLanguages=ConsentLanguages;
1
+ "use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConsentLanguages=void 0;var ConsentLanguages=function(){function e(){}return e.prototype.has=function(t){return e.langSet.has(t)},e.prototype.parseLanguage=function(t){var n,r,o=(t=t.toUpperCase()).split("-")[0];if(t.length>=2&&2==o.length){if(e.langSet.has(t))return t;if(e.langSet.has(o))return o;var a=o+"-"+o;if(e.langSet.has(a))return a;try{for(var u=__values(e.langSet),i=u.next();!i.done;i=u.next()){var l=i.value;if(-1!==l.indexOf(t)||-1!==l.indexOf(o))return l}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}throw new Error("unsupported language ".concat(t))},e.prototype.forEach=function(t){e.langSet.forEach(t)},Object.defineProperty(e.prototype,"size",{get:function(){return e.langSet.size},enumerable:!1,configurable:!0}),e.langSet=new Set(["AR","BG","BS","CA","CS","DA","DE","EL","EN","ES","ET","EU","FI","FR","GL","HR","HU","IT","JA","LT","LV","MT","NL","NO","PL","PT-BR","PT-PT","RO","RU","SK","SL","SR-CYRL","SR-LATN","SV","TR","ZH"]),e}();exports.ConsentLanguages=ConsentLanguages;
@@ -113,7 +113,8 @@ export class SemanticPreEncoder {
113
113
  if (!gvl.isReady) {
114
114
  throw new EncodingError('Unable to encode TCModel tcModel.gvl.readyPromise is not resolved');
115
115
  }
116
- tcModel = tcModel.clone();
116
+ // CS: PC_IMPROVEMENT_CONSUME_TC_MODEL
117
+ // tcModel = tcModel.clone();
117
118
  tcModel.consentLanguage = gvl.language.slice(0, 2).toUpperCase();
118
119
  if (options?.version > 0 && options?.version <= this.processor.length) {
119
120
  tcModel.version = options.version;
@@ -41,14 +41,21 @@ export class ConsentLanguages {
41
41
  return ConsentLanguages.langSet.has(key);
42
42
  }
43
43
  parseLanguage(lang) {
44
- if (lang.length >= 2) {
45
- lang = lang.toUpperCase();
46
- const primaryLanguage = lang.split('-')[0];
44
+ lang = lang.toUpperCase();
45
+ const primaryLanguage = lang.split('-')[0];
46
+ if (lang.length >= 2 && primaryLanguage.length == 2) {
47
+ if (ConsentLanguages.langSet.has(lang)) {
48
+ return lang;
49
+ }
50
+ else if (ConsentLanguages.langSet.has(primaryLanguage)) {
51
+ return primaryLanguage;
52
+ }
53
+ const fullPrimaryLang = primaryLanguage + '-' + primaryLanguage;
54
+ if (ConsentLanguages.langSet.has(fullPrimaryLang)) {
55
+ return fullPrimaryLang;
56
+ }
47
57
  for (const supportedLang of ConsentLanguages.langSet) {
48
- if (supportedLang == primaryLanguage) {
49
- return primaryLanguage;
50
- }
51
- if (supportedLang.indexOf(lang) !== -1) {
58
+ if (supportedLang.indexOf(lang) !== -1 || supportedLang.indexOf(primaryLanguage) !== -1) {
52
59
  return supportedLang;
53
60
  }
54
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubtech-ai/core",
3
- "version": "1.6.5",
3
+ "version": "1.7.0",
4
4
  "description": "Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).",
5
5
  "author": "Mayank Mishra <mayank@iabtechlab.com>",
6
6
  "homepage": "https://iabtcf.com/",
@@ -28,7 +28,7 @@
28
28
  "test-cov": "rm -rf coverage; nyc --reporter=html mocha"
29
29
  },
30
30
  "devDependencies": {
31
- "@pubtech-ai/testing": "1.6.5",
31
+ "@pubtech-ai/testing": "1.7.0",
32
32
  "@istanbuljs/nyc-config-typescript": "^0.1.3",
33
33
  "@types/sinon": "^10.0.11",
34
34
  "@types/sinon-chai": "3.2.8",