Socket
Socket
Sign inDemoInstall

@adv-ui/vendor-by-consents-loader

Package Overview
Dependencies
38
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

1

lib/utils.js
export var loadScript = function loadScript(src) {
if (!src) return Promise.resolve();
return new Promise(function (resolve) {

@@ -3,0 +4,0 @@ var script = document.createElement('script');

2

package.json
{
"name": "@adv-ui/vendor-by-consents-loader",
"version": "1.2.0",
"version": "1.3.0",
"description": "Load vendors according to the allowed user's consents",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -7,6 +7,11 @@ # Vendor by Consents Loader

**🔴 IMPORTANT:** Before following the README, be sure you're loading the [Stub from Boros TCF](https://github.mpi-internal.com/scmspain/frontend-adit--uilib-boros-tcf/blob/master/components/stub/core/SCRIPT.md) as it's required.
## Loading list of vendors
```js
import {initVendorConsentsLoader, addVendorLoadedEventListener} from '@adv-ui/vendor-by-consents-loader'
import {
initVendorConsentsLoader,
addVendorLoadedEventListener
} from '@adv-ui/vendor-by-consents-loader'

@@ -43,3 +48,6 @@ const OPTIMIZELY_KEY = 'optimizely'

```js
import {loadSingleVendorByConsent, addVendorLoadedEventListener} from '@adv-ui/vendor-by-consents-loader'
import {
loadSingleVendorByConsent,
addVendorLoadedEventListener
} from '@adv-ui/vendor-by-consents-loader'

@@ -61,2 +69,24 @@ const GOOGLE_ADSENSE_KEY = 'google_adsense'

You can also set a vendor configuration without an specific `script` in case the vendor doesn't require it to work:
```js
import {
loadSingleVendorByConsent,
addVendorLoadedEventListener
} from '@adv-ui/vendor-by-consents-loader'
const RTB_HOUSE_KEY = 'rtb_house'
loadSingleVendorByConsent({
name: RTB_HOUSE_KEY,
consents: {
purposes: [2, 6]
}
})
addVendorLoadedEventListener(({vendor}) => {
vendor === RTB_HOUSE_KEY && console.log('RTB House is ready')
})
```
## Loading specific vendors

@@ -98,3 +128,3 @@

}
},
}
}

@@ -116,5 +146,4 @@ })

})
//
//
</script>
```

@@ -125,24 +154,28 @@

**Purposes**:
* 1 - Store and/or access information on a device
* 2 - Select basic ads
* 3 - Create a personalised ads profile
* 4 - Select personalised ads
* 5 - Create a personalised content profile
* 6 - Select personalised content
* 7 - Measure ad performance
* 8 - Measure content performance
* 9 - Apply market research to generate audience insights
* 10 - Develop and improve products
- 1 - Store and/or access information on a device
- 2 - Select basic ads
- 3 - Create a personalised ads profile
- 4 - Select personalised ads
- 5 - Create a personalised content profile
- 6 - Select personalised content
- 7 - Measure ad performance
- 8 - Measure content performance
- 9 - Apply market research to generate audience insights
- 10 - Develop and improve products
**Special Purposes**
* SP1 - Ensure security, prevent fraud, and debug
* SP2 - Technically deliver ads or content
- SP1 - Ensure security, prevent fraud, and debug
- SP2 - Technically deliver ads or content
**Features**
* F1 - Match and combine offline data sources
* F2 - Link different devices
* F3 - Receive and use automatically-sent device characteristics for identification
- F1 - Match and combine offline data sources
- F2 - Link different devices
- F3 - Receive and use automatically-sent device characteristics for identification
**Special Features**
* SF1 - Use precise geolocation data
* SF2 - Actively scan device characteristics for identification
- SF1 - Use precise geolocation data
- SF2 - Actively scan device characteristics for identification

@@ -1,1 +0,1 @@

!function(n){var e={};function o(t){if(e[t])return e[t].exports;var r=e[t]={i:t,l:!1,exports:{}};return n[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=n,o.c=e,o.d=function(n,e,t){o.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},o.r=function(n){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"===typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)o.d(t,r,function(e){return n[e]}.bind(null,r));return t},o.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return o.d(e,"a",e),e},o.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},o.p="true",o(o.s="phIc")}({phIc:function(n,e,o){"use strict";o.r(e);var t=function(n){return new Promise((function(e){var o=document.createElement("script");o.src=n,o.defer=!0,document.head.appendChild(o),o.addEventListener("load",e)}))},r=function(){return"undefined"!==typeof window},i={VENDOR_LOADED:"__mpi_vendor_loaded"};function u(n){var e=n.vendor;!function(n){var e,o=n.eventName,t=n.detail,r=void 0===t?{}:t;window.CustomEvent&&"function"===typeof window.CustomEvent?e=new window.CustomEvent(o,{detail:r}):(e=document.createEvent("CustomEvent")).initCustomEvent(o,!0,!0,r),window.document.dispatchEvent(e)}({eventName:i.VENDOR_LOADED,detail:{vendor:e}})}var d="loading",s={LOADED:"tcloaded",USER_ACTION_COMPLETE:"useractioncomplete",UI_SHOWN:"cmpuishown"},c=[s.USER_ACTION_COMPLETE,s.LOADED],a=function(){var n=r()&&!!window.__tcfapi;return!n&&console.warn("window.__tcfapi is not available"),n},v=function(n){var e=n.userConsents;return n.neededConsentsIds.every((function(n){return!0===e[n]}))},f=function(n){var e=void 0===n?{}:n,o=e.allowInconclusiveConsents,t=void 0!==o&&o,r=e.once,i=void 0!==r&&r;return function(n){var e;e=function(e,o){if(d!==e.cmpStatus){var r=e.eventStatus,u=e.listenerId,v=e.purpose.consents,f=t?Object.values(s):c;o&&f.includes(r)&&(n({purposeConsents:v}),i&&function(n){a()&&window.__tcfapi("removeEventListener",2,!1,n)}(u))}},a()&&window.__tcfapi("addEventListener",2,e)}},l=function(n){r()&&f()((function(e){var o=e.purposeConsents;n.map((function(n){var e=n.vendorConfig,t=n.vendorName;return function(n){var e=n.purposeConsents,o=n.vendorConfig,t=n.vendorName,r=o.consents.purposes;return v({userConsents:e,neededConsentsIds:void 0===r?[]:r})?[t,o]:[]}({purposeConsents:o,vendorConfig:e,vendorName:t})})).filter((function(n){return n.length})).forEach((function(n){var e=n[0],o=n[1].script;t(o).then((function(){return u({vendor:e})}))}))}))};function p(){return(p=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(n[t]=o[t])}return n}).apply(this,arguments)}var m={c1:"2",cs_ucfr:"1"},w=[1,7,9,10],C=window;C.sui=C.sui||{},C.sui.vendors=C.sui.vendors||{addVendorLoadedEventListener:function(n,e){var o=(void 0===e?{}:e).once,t=void 0!==o&&o;if(r)return window.document.addEventListener(i.VENDOR_LOADED,u),d;function u(e){n(e.detail),t&&d()}function d(){window.document.removeEventListener(i.VENDOR_LOADED,u)}console.warn("Tried to call addVendorLoadedEventListener but you are not on the client")},initVendorConsentsLoader:function(n){var e,o,t=(void 0===n?{}:n).vendors;if(r()){if(t=t||(null==(e=window.__mpi)||null==(o=e.vendorByConsentsLoader)?void 0:o.vendors)){var i=Object.entries(t).map((function(n){var e=n[0];return{vendorConfig:n[1],vendorName:e}}));return l(i)}console.error("vendorByConsentsLoader not provided. Pass it by parameter or use window.__mpi config with vendorByConsentsLoader property.")}},loadSingleVendorByConsent:function(n){var e=n.name,o=function(n,e){if(null==n)return{};var o,t,r={},i=Object.keys(n);for(t=0;t<i.length;t++)o=i[t],e.indexOf(o)>=0||(r[o]=n[o]);return r}(n,["name"]);return l([{vendorConfig:o,vendorName:e}])},loadComscore:function(n){var e=n.comscoreClientId;r?f({once:!0})((function(n){var o=n.purposeConsents;if(v({userConsents:o,neededConsentsIds:w}))return window._comscore=[p({},m,{c2:e})],t("https://sb.scorecardresearch.com/beacon.js").then((function(){return u({vendor:"comscore"}),!0}))})):console.warn("[vendor-by-consents-loader]: You can't loadComscore from the server")}}}});
!function(n){var e={};function o(t){if(e[t])return e[t].exports;var r=e[t]={i:t,l:!1,exports:{}};return n[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=n,o.c=e,o.d=function(n,e,t){o.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},o.r=function(n){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"===typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)o.d(t,r,function(e){return n[e]}.bind(null,r));return t},o.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return o.d(e,"a",e),e},o.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},o.p="true",o(o.s="phIc")}({phIc:function(n,e,o){"use strict";o.r(e);var t=function(n){return n?new Promise((function(e){var o=document.createElement("script");o.src=n,o.defer=!0,document.head.appendChild(o),o.addEventListener("load",e)})):Promise.resolve()},r=function(){return"undefined"!==typeof window},i={VENDOR_LOADED:"__mpi_vendor_loaded"};function u(n){var e=n.vendor;!function(n){var e,o=n.eventName,t=n.detail,r=void 0===t?{}:t;window.CustomEvent&&"function"===typeof window.CustomEvent?e=new window.CustomEvent(o,{detail:r}):(e=document.createEvent("CustomEvent")).initCustomEvent(o,!0,!0,r),window.document.dispatchEvent(e)}({eventName:i.VENDOR_LOADED,detail:{vendor:e}})}var d="loading",s={LOADED:"tcloaded",USER_ACTION_COMPLETE:"useractioncomplete",UI_SHOWN:"cmpuishown"},c=[s.USER_ACTION_COMPLETE,s.LOADED],a=function(){var n=r()&&!!window.__tcfapi;return!n&&console.warn("window.__tcfapi is not available"),n},v=function(n){var e=n.userConsents;return n.neededConsentsIds.every((function(n){return!0===e[n]}))},f=function(n){var e=void 0===n?{}:n,o=e.allowInconclusiveConsents,t=void 0!==o&&o,r=e.once,i=void 0!==r&&r;return function(n){var e;e=function(e,o){if(d!==e.cmpStatus){var r=e.eventStatus,u=e.listenerId,v=e.purpose.consents,f=t?Object.values(s):c;o&&f.includes(r)&&(n({purposeConsents:v}),i&&function(n){a()&&window.__tcfapi("removeEventListener",2,!1,n)}(u))}},a()&&window.__tcfapi("addEventListener",2,e)}},l=function(n){r()&&f()((function(e){var o=e.purposeConsents;n.map((function(n){var e=n.vendorConfig,t=n.vendorName;return function(n){var e=n.purposeConsents,o=n.vendorConfig,t=n.vendorName,r=o.consents.purposes;return v({userConsents:e,neededConsentsIds:void 0===r?[]:r})?[t,o]:[]}({purposeConsents:o,vendorConfig:e,vendorName:t})})).filter((function(n){return n.length})).forEach((function(n){var e=n[0],o=n[1].script;t(o).then((function(){return u({vendor:e})}))}))}))};function p(){return(p=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(n[t]=o[t])}return n}).apply(this,arguments)}var m={c1:"2",cs_ucfr:"1"},w=[1,7,9,10],C=window;C.sui=C.sui||{},C.sui.vendors=C.sui.vendors||{addVendorLoadedEventListener:function(n,e){var o=(void 0===e?{}:e).once,t=void 0!==o&&o;if(r)return window.document.addEventListener(i.VENDOR_LOADED,u),d;function u(e){n(e.detail),t&&d()}function d(){window.document.removeEventListener(i.VENDOR_LOADED,u)}console.warn("Tried to call addVendorLoadedEventListener but you are not on the client")},initVendorConsentsLoader:function(n){var e,o,t=(void 0===n?{}:n).vendors;if(r()){if(t=t||(null==(e=window.__mpi)||null==(o=e.vendorByConsentsLoader)?void 0:o.vendors)){var i=Object.entries(t).map((function(n){var e=n[0];return{vendorConfig:n[1],vendorName:e}}));return l(i)}console.error("vendorByConsentsLoader not provided. Pass it by parameter or use window.__mpi config with vendorByConsentsLoader property.")}},loadSingleVendorByConsent:function(n){var e=n.name,o=function(n,e){if(null==n)return{};var o,t,r={},i=Object.keys(n);for(t=0;t<i.length;t++)o=i[t],e.indexOf(o)>=0||(r[o]=n[o]);return r}(n,["name"]);return l([{vendorConfig:o,vendorName:e}])},loadComscore:function(n){var e=n.comscoreClientId;r?f({once:!0})((function(n){var o=n.purposeConsents;if(v({userConsents:o,neededConsentsIds:w}))return window._comscore=[p({},m,{c2:e})],t("https://sb.scorecardresearch.com/beacon.js").then((function(){return u({vendor:"comscore"}),!0}))})):console.warn("[vendor-by-consents-loader]: You can't loadComscore from the server")}}}});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc