@didomi/react
Advanced tools
Comparing version 1.6.0 to 1.7.0
454
es/index.js
@@ -1,125 +0,180 @@ | ||
var _class, _temp; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
import { Component } from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import set from 'dset'; | ||
var DidomiSDK = (_temp = _class = function (_Component) { | ||
_inherits(DidomiSDK, _Component); | ||
var DidomiSDK = function DidomiSDK(_ref) { | ||
var _ref$apiKey = _ref.apiKey, | ||
apiKeyProp = _ref$apiKey === undefined ? null : _ref$apiKey, | ||
_ref$iabVersion = _ref.iabVersion, | ||
iabVersion = _ref$iabVersion === undefined ? 2 : _ref$iabVersion, | ||
_ref$noticeId = _ref.noticeId, | ||
noticeId = _ref$noticeId === undefined ? null : _ref$noticeId, | ||
_ref$config = _ref.config, | ||
config = _ref$config === undefined ? {} : _ref$config, | ||
_ref$gdprAppliesGloba = _ref.gdprAppliesGlobally, | ||
gdprAppliesGloballyProp = _ref$gdprAppliesGloba === undefined ? true : _ref$gdprAppliesGloba, | ||
onReady = _ref.onReady, | ||
onConsentChanged = _ref.onConsentChanged, | ||
onNoticeShown = _ref.onNoticeShown, | ||
onNoticeHidden = _ref.onNoticeHidden, | ||
onNoticeBackdropclick = _ref.onNoticeBackdropclick, | ||
onNoticeClickAgree = _ref.onNoticeClickAgree, | ||
onNoticeClickMoreInfo = _ref.onNoticeClickMoreInfo, | ||
onPreferencesClickAgreeToAll = _ref.onPreferencesClickAgreeToAll, | ||
onPreferencesClickDisagreeToAll = _ref.onPreferencesClickDisagreeToAll, | ||
onPreferencesClickPurposeAgree = _ref.onPreferencesClickPurposeAgree, | ||
onPreferencesClickPurposeDisagree = _ref.onPreferencesClickPurposeDisagree, | ||
onPreferencesClickViewVendors = _ref.onPreferencesClickViewVendors, | ||
onPreferencesClickSaveChoices = _ref.onPreferencesClickSaveChoices, | ||
onPreferencesClickVendorAgree = _ref.onPreferencesClickVendorAgree, | ||
onPreferencesClickVendorDisagree = _ref.onPreferencesClickVendorDisagree, | ||
onPreferencesClickVendorSaveChoices = _ref.onPreferencesClickVendorSaveChoices, | ||
_ref$sdkPath = _ref.sdkPath, | ||
sdkPath = _ref$sdkPath === undefined ? 'https://sdk.privacy-center.org/' : _ref$sdkPath, | ||
_ref$embedTCFStub = _ref.embedTCFStub, | ||
embedTCFStub = _ref$embedTCFStub === undefined ? true : _ref$embedTCFStub; | ||
function DidomiSDK() { | ||
_classCallCheck(this, DidomiSDK); | ||
return _possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
/** | ||
* Called once the Didomi SDK is ready and loaded | ||
* @param {*} Didomi | ||
* Set all the Didomi event listeners from the props | ||
*/ | ||
DidomiSDK.prototype.didomiOnReady = function didomiOnReady(Didomi) { | ||
this.props.onReady(Didomi); | ||
this.setEvents(Didomi); | ||
}; | ||
var setEvents = function setEvents() { | ||
if (onReady) { | ||
window.didomiOnReady = window.didomiOnReady || []; | ||
window.didomiOnReady.push(onReady); | ||
} | ||
/** | ||
* Set all the Didomi events the return the callbacks from the props | ||
* @param {*} Didomi | ||
*/ | ||
window.didomiEventListeners = window.didomiEventListeners || []; | ||
DidomiSDK.prototype.setEvents = function setEvents(Didomi) { | ||
var _this2 = this; | ||
if (this.props.onConsentChanged) { | ||
Didomi.on('consent.changed', function (e) { | ||
_this2.props.onConsentChanged(e.consentToken); | ||
if (onConsentChanged) { | ||
window.didomiEventListeners.push({ | ||
event: 'consent.changed', | ||
listener: function listener(e) { | ||
onConsentChanged(e.consentToken); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeShown) { | ||
Didomi.on('notice.shown', function (e) { | ||
_this2.props.onNoticeShown(); | ||
if (onNoticeShown) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.shown', | ||
listener: function listener() { | ||
return onNoticeShown(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeHidden) { | ||
Didomi.on('notice.hidden', function (e) { | ||
_this2.props.onNoticeHidden(); | ||
if (onNoticeHidden) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.hidden', | ||
listener: function listener() { | ||
return onNoticeHidden(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeBackdropclick) { | ||
Didomi.on('notice.backdropclick', function (e) { | ||
_this2.props.onNoticeBackdropclick(); | ||
if (onNoticeBackdropclick) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.backdropclick', | ||
listener: function listener() { | ||
return onNoticeBackdropclick(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeClickAgree) { | ||
Didomi.on('notice.clickagree', function (e) { | ||
_this2.props.onNoticeClickAgree(); | ||
if (onNoticeClickAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.clickagree', | ||
listener: function listener() { | ||
return onNoticeClickAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeClickMoreInfo) { | ||
Didomi.on('notice.clickmoreinfo', function (e) { | ||
_this2.props.onNoticeClickMoreInfo(); | ||
if (onNoticeClickMoreInfo) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.clickmoreinfo', | ||
listener: function listener() { | ||
return onNoticeClickMoreInfo(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickAgreeToAll) { | ||
Didomi.on('preferences.clickagreetoall', function (e) { | ||
_this2.props.onPreferencesClickAgreeToAll(); | ||
if (onPreferencesClickAgreeToAll) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickagreetoall', | ||
listener: function listener() { | ||
return onPreferencesClickAgreeToAll(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickDisagreeToAll) { | ||
Didomi.on('preferences.clickdisagreetoall', function (e) { | ||
_this2.props.onPreferencesClickDisagreeToAll(); | ||
if (onPreferencesClickDisagreeToAll) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickdisagreetoall', | ||
listener: function listener() { | ||
return onPreferencesClickDisagreeToAll(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickPurposeAgree) { | ||
Didomi.on('preferences.clickpurposeagree', function (e) { | ||
_this2.props.onPreferencesClickPurposeAgree(e.purposeId); | ||
if (onPreferencesClickPurposeAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickpurposeagree', | ||
listener: function listener() { | ||
return onPreferencesClickPurposeAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickPurposeDisagree) { | ||
Didomi.on('preferences.clickpurposedisagree', function (e) { | ||
_this2.props.onPreferencesClickPurposeDisagree(e.purposeId); | ||
if (onPreferencesClickPurposeDisagree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickpurposedisagree', | ||
listener: function listener() { | ||
return onPreferencesClickPurposeDisagree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickViewVendors) { | ||
Didomi.on('preferences.clickviewvendors', function (e) { | ||
_this2.props.onPreferencesClickViewVendors(); | ||
if (onPreferencesClickViewVendors) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickviewvendors', | ||
listener: function listener() { | ||
return onPreferencesClickViewVendors(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickSaveChoices) { | ||
Didomi.on('preferences.clicksavechoices', function (e) { | ||
_this2.props.onPreferencesClickSaveChoices(); | ||
if (onPreferencesClickSaveChoices) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clicksavechoices', | ||
listener: function listener() { | ||
return onPreferencesClickSaveChoices(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorAgree) { | ||
Didomi.on('preferences.clickvendoragree', function (e) { | ||
_this2.props.onPreferencesClickVendorAgree(e.vendorId); | ||
if (onPreferencesClickVendorAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendoragree', | ||
listener: function listener() { | ||
return onPreferencesClickVendorAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorDisagree) { | ||
Didomi.on('preferences.clickvendordisagree', function (e) { | ||
_this2.props.onPreferencesClickVendorDisagree(e.vendorId); | ||
if (onPreferencesClickVendorDisagree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendordisagree', | ||
listener: function listener() { | ||
return onPreferencesClickVendorDisagree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorSaveChoices) { | ||
Didomi.on('preferences.clickvendorsavechoices', function (e) { | ||
_this2.props.onPreferencesClickVendorSaveChoices(); | ||
if (onPreferencesClickVendorSaveChoices) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendorsavechoices', | ||
listener: function listener() { | ||
return onPreferencesClickVendorSaveChoices(); | ||
} | ||
}); | ||
@@ -132,10 +187,8 @@ } | ||
*/ | ||
DidomiSDK.prototype.getApiKey = function getApiKey() { | ||
var getApiKey = function getApiKey() { | ||
var apiKey = void 0; | ||
if (this.props.config.app && this.props.config.app.apiKey) { | ||
apiKey = this.props.config.app.apiKey; | ||
if (config.app && config.app.apiKey) { | ||
apiKey = config.app.apiKey; | ||
} | ||
return this.props.apiKey || apiKey; | ||
return apiKeyProp || apiKey; | ||
}; | ||
@@ -146,57 +199,107 @@ | ||
*/ | ||
var init = function init() { | ||
var loaderParams = void 0; | ||
var apiKey = getApiKey(); | ||
var gdprAppliesGlobally = gdprAppliesGloballyProp === false ? false : true; | ||
window.didomiConfig = config || {}; | ||
// Set the SDK path | ||
window.didomiConfig.sdkPath = sdkPath; | ||
DidomiSDK.prototype.init = function init() { | ||
var loaderParams = void 0; | ||
var apiKey = this.getApiKey(); | ||
var gdprAppliesGlobally = this.props.gdprAppliesGlobally === false ? false : true; | ||
window.didomiConfig = this.props.config || {}; | ||
// Embed the Didomi SDK on the page | ||
window.gdprAppliesGlobally = gdprAppliesGlobally; | ||
if (this.props.noticeId) { | ||
loaderParams = 'target_type=notice&target=' + this.props.noticeId; | ||
if (noticeId) { | ||
loaderParams = 'target_type=notice&target=' + noticeId; | ||
} else { | ||
loaderParams = 'target=' + document.location.hostname; | ||
} | ||
if (this.props.iabVersion === 2) { | ||
// TCF v2 | ||
(function () { | ||
function a(e) { | ||
if (!window.frames[e]) { | ||
if (document.body && document.body.firstChild) { | ||
var t = document.body;var n = document.createElement("iframe");n.style.display = "none";n.name = e;n.title = e;t.insertBefore(n, t.firstChild); | ||
} else { | ||
setTimeout(function () { | ||
a(e); | ||
}, 5); | ||
// Embed the TCF stub | ||
if (embedTCFStub) { | ||
if (iabVersion === 2) { | ||
// TCF v2 | ||
// prettier-ignore | ||
(function () { | ||
function a(e) { | ||
if (!window.frames[e]) { | ||
if (document.body && document.body.firstChild) { | ||
var t = document.body;var n = document.createElement("iframe");n.style.display = "none";n.name = e;n.title = e;t.insertBefore(n, t.firstChild); | ||
} else { | ||
setTimeout(function () { | ||
a(e); | ||
}, 5); | ||
} | ||
} | ||
} | ||
}function e(n, r, o, c, s) { | ||
function e(e, t, n, a) { | ||
if (typeof n !== "function") { | ||
}function e(n, r, o, c, s) { | ||
function e(e, t, n, a) { | ||
if (typeof n !== "function") { | ||
return; | ||
}if (!window[r]) { | ||
window[r] = []; | ||
}var i = false;if (s) { | ||
i = s(e, t, n); | ||
}if (!i) { | ||
window[r].push({ command: e, parameter: t, callback: n, version: a }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window[n] || window[n].stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var i = typeof a.data === "string";var e;try { | ||
e = i ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e[o]) { | ||
var r = e[o];window[n](r.command, r.parameter, function (e, t) { | ||
var n = {};n[c] = { returnValue: e, success: t, callId: r.callId };a.source.postMessage(i ? JSON.stringify(n) : n, "*"); | ||
}, r.version); | ||
} | ||
}if (typeof window[n] !== "function") { | ||
window[n] = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
} else { | ||
window.attachEvent("onmessage", t); | ||
} | ||
} | ||
}e("__tcfapi", "__tcfapiBuffer", "__tcfapiCall", "__tcfapiReturn");a("__tcfapiLocator"); | ||
})(); | ||
} else { | ||
// TCF v1 | ||
// prettier-ignore | ||
(function () { | ||
function r() { | ||
if (!window.frames.__cmpLocator) { | ||
if (document.body && document.body.firstChild) { | ||
var e = document.body;var t = document.createElement("iframe");t.style.display = "none";t.name = "__cmpLocator";t.title = "cmpLocator";e.insertBefore(t, e.firstChild); | ||
} else { | ||
setTimeout(r, 5); | ||
} | ||
} | ||
}function e(e, t, r) { | ||
if (typeof r !== "function") { | ||
return; | ||
}if (!window[r]) { | ||
window[r] = []; | ||
}var i = false;if (s) { | ||
i = s(e, t, n); | ||
}if (!i) { | ||
window[r].push({ command: e, parameter: t, callback: n, version: a }); | ||
}if (!window.__cmpBuffer) { | ||
window.__cmpBuffer = []; | ||
}if (e === "ping") { | ||
r({ gdprAppliesGlobally: window.gdprAppliesGlobally, cmpLoaded: false }, true); | ||
} else { | ||
window.__cmpBuffer.push({ command: e, parameter: t, callback: r }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window[n] || window[n].stub !== true) { | ||
if (!window.__cmp || window.__cmp.stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var i = typeof a.data === "string";var e;try { | ||
e = i ? JSON.parse(a.data) : a.data; | ||
}var n = typeof a.data === "string";var e;try { | ||
e = n ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e[o]) { | ||
var r = e[o];window[n](r.command, r.parameter, function (e, t) { | ||
var n = {};n[c] = { returnValue: e, success: t, callId: r.callId };a.source.postMessage(i ? JSON.stringify(n) : n, "*"); | ||
}, r.version); | ||
}if (e.__cmpCall) { | ||
var o = e.__cmpCall;window.__cmp(o.command, o.parameter, function (e, t) { | ||
var r = { __cmpReturn: { returnValue: e, success: t, callId: o.callId } };a.source.postMessage(n ? JSON.stringify(r) : r, "*"); | ||
}); | ||
} | ||
}if (typeof window[n] !== "function") { | ||
window[n] = e;if (window.addEventListener) { | ||
}if (typeof window.__cmp !== "function") { | ||
window.__cmp = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
@@ -206,92 +309,28 @@ } else { | ||
} | ||
} | ||
}e("__tcfapi", "__tcfapiBuffer", "__tcfapiCall", "__tcfapiReturn");a("__tcfapiLocator");(function (e) { | ||
var t = document.createElement("script");t.id = "spcloader";t.type = "text/javascript";t.async = true;t.src = "https://sdk.privacy-center.org/" + e + "/loader.js?" + loaderParams;t.charset = "utf-8";var n = document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t, n); | ||
})(apiKey); | ||
})(); | ||
} else { | ||
// TCF v1 | ||
(function () { | ||
function r() { | ||
if (!window.frames.__cmpLocator) { | ||
if (document.body && document.body.firstChild) { | ||
var e = document.body;var t = document.createElement("iframe");t.style.display = "none";t.name = "__cmpLocator";t.title = "cmpLocator";e.insertBefore(t, e.firstChild); | ||
} else { | ||
setTimeout(r, 5); | ||
} | ||
} | ||
}function e(e, t, r) { | ||
if (typeof r !== "function") { | ||
return; | ||
}if (!window.__cmpBuffer) { | ||
window.__cmpBuffer = []; | ||
}if (e === "ping") { | ||
r({ gdprAppliesGlobally: window.gdprAppliesGlobally, cmpLoaded: false }, true); | ||
} else { | ||
window.__cmpBuffer.push({ command: e, parameter: t, callback: r }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window.__cmp || window.__cmp.stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var n = typeof a.data === "string";var e;try { | ||
e = n ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e.__cmpCall) { | ||
var o = e.__cmpCall;window.__cmp(o.command, o.parameter, function (e, t) { | ||
var r = { __cmpReturn: { returnValue: e, success: t, callId: o.callId } };a.source.postMessage(n ? JSON.stringify(r) : r, "*"); | ||
}); | ||
} | ||
}if (typeof window.__cmp !== "function") { | ||
window.__cmp = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
} else { | ||
window.attachEvent("onmessage", t); | ||
} | ||
}r(); | ||
})();(function (e) { | ||
var t = e ? e + "/" : "";var r = document.createElement("script");r.id = "spcloader";r.type = "text/javascript";r.async = true;r.src = "https://sdk.privacy-center.org/" + t + "loader.js?" + loaderParams;r.charset = "utf-8";var a = document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r, a); | ||
})(apiKey); | ||
}r(); | ||
})(); | ||
} | ||
} | ||
}; | ||
DidomiSDK.prototype.componentDidMount = function componentDidMount() { | ||
this.init(); | ||
// Embed the SDK | ||
var loaderScript = document.createElement('script'); | ||
loaderScript.id = 'spcloader'; | ||
loaderScript.type = 'text/javascript'; | ||
loaderScript.async = true; | ||
loaderScript.src = sdkPath + apiKey + '/loader.js?' + loaderParams; | ||
loaderScript.charset = 'utf-8'; | ||
if (this.props.onReady) { | ||
window.didomiOnReady = window.didomiOnReady || []; | ||
window.didomiOnReady.push(this.didomiOnReady.bind(this)); | ||
} | ||
var firstScriptTagInDocument = document.getElementsByTagName('script')[0]; | ||
firstScriptTagInDocument.parentNode.insertBefore(loaderScript, firstScriptTagInDocument); | ||
}; | ||
DidomiSDK.prototype.render = function render() { | ||
return null; | ||
}; | ||
React.useEffect(function () { | ||
setEvents(); | ||
init(); | ||
}, []); | ||
return DidomiSDK; | ||
}(Component), _class.defaultProps = { | ||
apiKey: null, | ||
iabVersion: 1, | ||
noticeId: null, | ||
config: {}, | ||
gdprAppliesGlobally: true, | ||
onReady: function onReady() {}, | ||
onConsentChanged: function onConsentChanged() {}, | ||
onNoticeShown: function onNoticeShown() {}, | ||
onNoticeHidden: function onNoticeHidden() {}, | ||
onNoticeBackdropclick: function onNoticeBackdropclick() {}, | ||
onNoticeClickAgree: function onNoticeClickAgree() {}, | ||
onNoticeClickMoreInfo: function onNoticeClickMoreInfo() {}, | ||
onPreferencesClickAgreeToAll: function onPreferencesClickAgreeToAll() {}, | ||
onPreferencesClickDisagreeToAll: function onPreferencesClickDisagreeToAll() {}, | ||
onPreferencesClickPurposeAgree: function onPreferencesClickPurposeAgree() {}, | ||
onPreferencesClickPurposeDisagree: function onPreferencesClickPurposeDisagree() {}, | ||
onPreferencesClickViewVendors: function onPreferencesClickViewVendors() {}, | ||
onPreferencesClickSaveChoices: function onPreferencesClickSaveChoices() {}, | ||
onPreferencesClickVendorAgree: function onPreferencesClickVendorAgree() {}, | ||
onPreferencesClickVendorDisagree: function onPreferencesClickVendorDisagree() {}, | ||
onPreferencesClickVendorSaveChoices: function onPreferencesClickVendorSaveChoices() {} }, _temp); | ||
DidomiSDK.propTypes = process.env.NODE_ENV !== "production" ? { | ||
return null; | ||
}; | ||
DidomiSDK.propTypes = { | ||
apiKey: PropTypes.string, | ||
@@ -317,6 +356,7 @@ iabVersion: PropTypes.number, | ||
onPreferencesClickVendorDisagree: PropTypes.func, | ||
onPreferencesClickVendorSaveChoices: PropTypes.func | ||
} : {}; | ||
; | ||
onPreferencesClickVendorSaveChoices: PropTypes.func, | ||
sdkPath: PropTypes.string, | ||
embedTCFStub: PropTypes.bool | ||
}; | ||
export { DidomiSDK }; |
@@ -67,2 +67,3 @@ // Type definitions for @didomi/react 1.2.2 | ||
getTranslationAsHTML(): any; | ||
getUserStatus(): any; | ||
getUserConsentStatusForAll(): any; | ||
@@ -115,2 +116,4 @@ getUserConsentToken(): any; | ||
gdprAppliesGlobally?: boolean; | ||
sdkPath?: string; | ||
embedTCFStub?: boolean; | ||
onReady?: OnReadyFunction; | ||
@@ -117,0 +120,0 @@ onConsentChanged?: OnConsentChangedFunction; |
455
lib/index.js
@@ -6,6 +6,6 @@ 'use strict'; | ||
var _class, _temp; | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
@@ -15,123 +15,183 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _dset = require('dset'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _dset2 = _interopRequireDefault(_dset); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var DidomiSDK = function DidomiSDK(_ref) { | ||
var _ref$apiKey = _ref.apiKey, | ||
apiKeyProp = _ref$apiKey === undefined ? null : _ref$apiKey, | ||
_ref$iabVersion = _ref.iabVersion, | ||
iabVersion = _ref$iabVersion === undefined ? 2 : _ref$iabVersion, | ||
_ref$noticeId = _ref.noticeId, | ||
noticeId = _ref$noticeId === undefined ? null : _ref$noticeId, | ||
_ref$config = _ref.config, | ||
config = _ref$config === undefined ? {} : _ref$config, | ||
_ref$gdprAppliesGloba = _ref.gdprAppliesGlobally, | ||
gdprAppliesGloballyProp = _ref$gdprAppliesGloba === undefined ? true : _ref$gdprAppliesGloba, | ||
onReady = _ref.onReady, | ||
onConsentChanged = _ref.onConsentChanged, | ||
onNoticeShown = _ref.onNoticeShown, | ||
onNoticeHidden = _ref.onNoticeHidden, | ||
onNoticeBackdropclick = _ref.onNoticeBackdropclick, | ||
onNoticeClickAgree = _ref.onNoticeClickAgree, | ||
onNoticeClickMoreInfo = _ref.onNoticeClickMoreInfo, | ||
onPreferencesClickAgreeToAll = _ref.onPreferencesClickAgreeToAll, | ||
onPreferencesClickDisagreeToAll = _ref.onPreferencesClickDisagreeToAll, | ||
onPreferencesClickPurposeAgree = _ref.onPreferencesClickPurposeAgree, | ||
onPreferencesClickPurposeDisagree = _ref.onPreferencesClickPurposeDisagree, | ||
onPreferencesClickViewVendors = _ref.onPreferencesClickViewVendors, | ||
onPreferencesClickSaveChoices = _ref.onPreferencesClickSaveChoices, | ||
onPreferencesClickVendorAgree = _ref.onPreferencesClickVendorAgree, | ||
onPreferencesClickVendorDisagree = _ref.onPreferencesClickVendorDisagree, | ||
onPreferencesClickVendorSaveChoices = _ref.onPreferencesClickVendorSaveChoices, | ||
_ref$sdkPath = _ref.sdkPath, | ||
sdkPath = _ref$sdkPath === undefined ? 'https://sdk.privacy-center.org/' : _ref$sdkPath, | ||
_ref$embedTCFStub = _ref.embedTCFStub, | ||
embedTCFStub = _ref$embedTCFStub === undefined ? true : _ref$embedTCFStub; | ||
var DidomiSDK = (_temp = _class = function (_Component) { | ||
_inherits(DidomiSDK, _Component); | ||
function DidomiSDK() { | ||
_classCallCheck(this, DidomiSDK); | ||
return _possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
/** | ||
* Called once the Didomi SDK is ready and loaded | ||
* @param {*} Didomi | ||
* Set all the Didomi event listeners from the props | ||
*/ | ||
DidomiSDK.prototype.didomiOnReady = function didomiOnReady(Didomi) { | ||
this.props.onReady(Didomi); | ||
this.setEvents(Didomi); | ||
}; | ||
var setEvents = function setEvents() { | ||
if (onReady) { | ||
window.didomiOnReady = window.didomiOnReady || []; | ||
window.didomiOnReady.push(onReady); | ||
} | ||
/** | ||
* Set all the Didomi events the return the callbacks from the props | ||
* @param {*} Didomi | ||
*/ | ||
window.didomiEventListeners = window.didomiEventListeners || []; | ||
DidomiSDK.prototype.setEvents = function setEvents(Didomi) { | ||
var _this2 = this; | ||
if (this.props.onConsentChanged) { | ||
Didomi.on('consent.changed', function (e) { | ||
_this2.props.onConsentChanged(e.consentToken); | ||
if (onConsentChanged) { | ||
window.didomiEventListeners.push({ | ||
event: 'consent.changed', | ||
listener: function listener(e) { | ||
onConsentChanged(e.consentToken); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeShown) { | ||
Didomi.on('notice.shown', function (e) { | ||
_this2.props.onNoticeShown(); | ||
if (onNoticeShown) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.shown', | ||
listener: function listener() { | ||
return onNoticeShown(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeHidden) { | ||
Didomi.on('notice.hidden', function (e) { | ||
_this2.props.onNoticeHidden(); | ||
if (onNoticeHidden) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.hidden', | ||
listener: function listener() { | ||
return onNoticeHidden(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeBackdropclick) { | ||
Didomi.on('notice.backdropclick', function (e) { | ||
_this2.props.onNoticeBackdropclick(); | ||
if (onNoticeBackdropclick) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.backdropclick', | ||
listener: function listener() { | ||
return onNoticeBackdropclick(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeClickAgree) { | ||
Didomi.on('notice.clickagree', function (e) { | ||
_this2.props.onNoticeClickAgree(); | ||
if (onNoticeClickAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.clickagree', | ||
listener: function listener() { | ||
return onNoticeClickAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onNoticeClickMoreInfo) { | ||
Didomi.on('notice.clickmoreinfo', function (e) { | ||
_this2.props.onNoticeClickMoreInfo(); | ||
if (onNoticeClickMoreInfo) { | ||
window.didomiEventListeners.push({ | ||
event: 'notice.clickmoreinfo', | ||
listener: function listener() { | ||
return onNoticeClickMoreInfo(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickAgreeToAll) { | ||
Didomi.on('preferences.clickagreetoall', function (e) { | ||
_this2.props.onPreferencesClickAgreeToAll(); | ||
if (onPreferencesClickAgreeToAll) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickagreetoall', | ||
listener: function listener() { | ||
return onPreferencesClickAgreeToAll(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickDisagreeToAll) { | ||
Didomi.on('preferences.clickdisagreetoall', function (e) { | ||
_this2.props.onPreferencesClickDisagreeToAll(); | ||
if (onPreferencesClickDisagreeToAll) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickdisagreetoall', | ||
listener: function listener() { | ||
return onPreferencesClickDisagreeToAll(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickPurposeAgree) { | ||
Didomi.on('preferences.clickpurposeagree', function (e) { | ||
_this2.props.onPreferencesClickPurposeAgree(e.purposeId); | ||
if (onPreferencesClickPurposeAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickpurposeagree', | ||
listener: function listener() { | ||
return onPreferencesClickPurposeAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickPurposeDisagree) { | ||
Didomi.on('preferences.clickpurposedisagree', function (e) { | ||
_this2.props.onPreferencesClickPurposeDisagree(e.purposeId); | ||
if (onPreferencesClickPurposeDisagree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickpurposedisagree', | ||
listener: function listener() { | ||
return onPreferencesClickPurposeDisagree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickViewVendors) { | ||
Didomi.on('preferences.clickviewvendors', function (e) { | ||
_this2.props.onPreferencesClickViewVendors(); | ||
if (onPreferencesClickViewVendors) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickviewvendors', | ||
listener: function listener() { | ||
return onPreferencesClickViewVendors(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickSaveChoices) { | ||
Didomi.on('preferences.clicksavechoices', function (e) { | ||
_this2.props.onPreferencesClickSaveChoices(); | ||
if (onPreferencesClickSaveChoices) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clicksavechoices', | ||
listener: function listener() { | ||
return onPreferencesClickSaveChoices(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorAgree) { | ||
Didomi.on('preferences.clickvendoragree', function (e) { | ||
_this2.props.onPreferencesClickVendorAgree(e.vendorId); | ||
if (onPreferencesClickVendorAgree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendoragree', | ||
listener: function listener() { | ||
return onPreferencesClickVendorAgree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorDisagree) { | ||
Didomi.on('preferences.clickvendordisagree', function (e) { | ||
_this2.props.onPreferencesClickVendorDisagree(e.vendorId); | ||
if (onPreferencesClickVendorDisagree) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendordisagree', | ||
listener: function listener() { | ||
return onPreferencesClickVendorDisagree(); | ||
} | ||
}); | ||
} | ||
if (this.props.onPreferencesClickVendorSaveChoices) { | ||
Didomi.on('preferences.clickvendorsavechoices', function (e) { | ||
_this2.props.onPreferencesClickVendorSaveChoices(); | ||
if (onPreferencesClickVendorSaveChoices) { | ||
window.didomiEventListeners.push({ | ||
event: 'preferences.clickvendorsavechoices', | ||
listener: function listener() { | ||
return onPreferencesClickVendorSaveChoices(); | ||
} | ||
}); | ||
@@ -144,10 +204,8 @@ } | ||
*/ | ||
DidomiSDK.prototype.getApiKey = function getApiKey() { | ||
var getApiKey = function getApiKey() { | ||
var apiKey = void 0; | ||
if (this.props.config.app && this.props.config.app.apiKey) { | ||
apiKey = this.props.config.app.apiKey; | ||
if (config.app && config.app.apiKey) { | ||
apiKey = config.app.apiKey; | ||
} | ||
return this.props.apiKey || apiKey; | ||
return apiKeyProp || apiKey; | ||
}; | ||
@@ -158,57 +216,107 @@ | ||
*/ | ||
var init = function init() { | ||
var loaderParams = void 0; | ||
var apiKey = getApiKey(); | ||
var gdprAppliesGlobally = gdprAppliesGloballyProp === false ? false : true; | ||
window.didomiConfig = config || {}; | ||
// Set the SDK path | ||
window.didomiConfig.sdkPath = sdkPath; | ||
DidomiSDK.prototype.init = function init() { | ||
var loaderParams = void 0; | ||
var apiKey = this.getApiKey(); | ||
var gdprAppliesGlobally = this.props.gdprAppliesGlobally === false ? false : true; | ||
window.didomiConfig = this.props.config || {}; | ||
// Embed the Didomi SDK on the page | ||
window.gdprAppliesGlobally = gdprAppliesGlobally; | ||
if (this.props.noticeId) { | ||
loaderParams = 'target_type=notice&target=' + this.props.noticeId; | ||
if (noticeId) { | ||
loaderParams = 'target_type=notice&target=' + noticeId; | ||
} else { | ||
loaderParams = 'target=' + document.location.hostname; | ||
} | ||
if (this.props.iabVersion === 2) { | ||
// TCF v2 | ||
(function () { | ||
function a(e) { | ||
if (!window.frames[e]) { | ||
if (document.body && document.body.firstChild) { | ||
var t = document.body;var n = document.createElement("iframe");n.style.display = "none";n.name = e;n.title = e;t.insertBefore(n, t.firstChild); | ||
} else { | ||
setTimeout(function () { | ||
a(e); | ||
}, 5); | ||
// Embed the TCF stub | ||
if (embedTCFStub) { | ||
if (iabVersion === 2) { | ||
// TCF v2 | ||
// prettier-ignore | ||
(function () { | ||
function a(e) { | ||
if (!window.frames[e]) { | ||
if (document.body && document.body.firstChild) { | ||
var t = document.body;var n = document.createElement("iframe");n.style.display = "none";n.name = e;n.title = e;t.insertBefore(n, t.firstChild); | ||
} else { | ||
setTimeout(function () { | ||
a(e); | ||
}, 5); | ||
} | ||
} | ||
} | ||
}function e(n, r, o, c, s) { | ||
function e(e, t, n, a) { | ||
if (typeof n !== "function") { | ||
}function e(n, r, o, c, s) { | ||
function e(e, t, n, a) { | ||
if (typeof n !== "function") { | ||
return; | ||
}if (!window[r]) { | ||
window[r] = []; | ||
}var i = false;if (s) { | ||
i = s(e, t, n); | ||
}if (!i) { | ||
window[r].push({ command: e, parameter: t, callback: n, version: a }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window[n] || window[n].stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var i = typeof a.data === "string";var e;try { | ||
e = i ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e[o]) { | ||
var r = e[o];window[n](r.command, r.parameter, function (e, t) { | ||
var n = {};n[c] = { returnValue: e, success: t, callId: r.callId };a.source.postMessage(i ? JSON.stringify(n) : n, "*"); | ||
}, r.version); | ||
} | ||
}if (typeof window[n] !== "function") { | ||
window[n] = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
} else { | ||
window.attachEvent("onmessage", t); | ||
} | ||
} | ||
}e("__tcfapi", "__tcfapiBuffer", "__tcfapiCall", "__tcfapiReturn");a("__tcfapiLocator"); | ||
})(); | ||
} else { | ||
// TCF v1 | ||
// prettier-ignore | ||
(function () { | ||
function r() { | ||
if (!window.frames.__cmpLocator) { | ||
if (document.body && document.body.firstChild) { | ||
var e = document.body;var t = document.createElement("iframe");t.style.display = "none";t.name = "__cmpLocator";t.title = "cmpLocator";e.insertBefore(t, e.firstChild); | ||
} else { | ||
setTimeout(r, 5); | ||
} | ||
} | ||
}function e(e, t, r) { | ||
if (typeof r !== "function") { | ||
return; | ||
}if (!window[r]) { | ||
window[r] = []; | ||
}var i = false;if (s) { | ||
i = s(e, t, n); | ||
}if (!i) { | ||
window[r].push({ command: e, parameter: t, callback: n, version: a }); | ||
}if (!window.__cmpBuffer) { | ||
window.__cmpBuffer = []; | ||
}if (e === "ping") { | ||
r({ gdprAppliesGlobally: window.gdprAppliesGlobally, cmpLoaded: false }, true); | ||
} else { | ||
window.__cmpBuffer.push({ command: e, parameter: t, callback: r }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window[n] || window[n].stub !== true) { | ||
if (!window.__cmp || window.__cmp.stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var i = typeof a.data === "string";var e;try { | ||
e = i ? JSON.parse(a.data) : a.data; | ||
}var n = typeof a.data === "string";var e;try { | ||
e = n ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e[o]) { | ||
var r = e[o];window[n](r.command, r.parameter, function (e, t) { | ||
var n = {};n[c] = { returnValue: e, success: t, callId: r.callId };a.source.postMessage(i ? JSON.stringify(n) : n, "*"); | ||
}, r.version); | ||
}if (e.__cmpCall) { | ||
var o = e.__cmpCall;window.__cmp(o.command, o.parameter, function (e, t) { | ||
var r = { __cmpReturn: { returnValue: e, success: t, callId: o.callId } };a.source.postMessage(n ? JSON.stringify(r) : r, "*"); | ||
}); | ||
} | ||
}if (typeof window[n] !== "function") { | ||
window[n] = e;if (window.addEventListener) { | ||
}if (typeof window.__cmp !== "function") { | ||
window.__cmp = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
@@ -218,92 +326,28 @@ } else { | ||
} | ||
} | ||
}e("__tcfapi", "__tcfapiBuffer", "__tcfapiCall", "__tcfapiReturn");a("__tcfapiLocator");(function (e) { | ||
var t = document.createElement("script");t.id = "spcloader";t.type = "text/javascript";t.async = true;t.src = "https://sdk.privacy-center.org/" + e + "/loader.js?" + loaderParams;t.charset = "utf-8";var n = document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t, n); | ||
})(apiKey); | ||
})(); | ||
} else { | ||
// TCF v1 | ||
(function () { | ||
function r() { | ||
if (!window.frames.__cmpLocator) { | ||
if (document.body && document.body.firstChild) { | ||
var e = document.body;var t = document.createElement("iframe");t.style.display = "none";t.name = "__cmpLocator";t.title = "cmpLocator";e.insertBefore(t, e.firstChild); | ||
} else { | ||
setTimeout(r, 5); | ||
} | ||
} | ||
}function e(e, t, r) { | ||
if (typeof r !== "function") { | ||
return; | ||
}if (!window.__cmpBuffer) { | ||
window.__cmpBuffer = []; | ||
}if (e === "ping") { | ||
r({ gdprAppliesGlobally: window.gdprAppliesGlobally, cmpLoaded: false }, true); | ||
} else { | ||
window.__cmpBuffer.push({ command: e, parameter: t, callback: r }); | ||
} | ||
}e.stub = true;function t(a) { | ||
if (!window.__cmp || window.__cmp.stub !== true) { | ||
return; | ||
}if (!a.data) { | ||
return; | ||
}var n = typeof a.data === "string";var e;try { | ||
e = n ? JSON.parse(a.data) : a.data; | ||
} catch (t) { | ||
return; | ||
}if (e.__cmpCall) { | ||
var o = e.__cmpCall;window.__cmp(o.command, o.parameter, function (e, t) { | ||
var r = { __cmpReturn: { returnValue: e, success: t, callId: o.callId } };a.source.postMessage(n ? JSON.stringify(r) : r, "*"); | ||
}); | ||
} | ||
}if (typeof window.__cmp !== "function") { | ||
window.__cmp = e;if (window.addEventListener) { | ||
window.addEventListener("message", t, false); | ||
} else { | ||
window.attachEvent("onmessage", t); | ||
} | ||
}r(); | ||
})();(function (e) { | ||
var t = e ? e + "/" : "";var r = document.createElement("script");r.id = "spcloader";r.type = "text/javascript";r.async = true;r.src = "https://sdk.privacy-center.org/" + t + "loader.js?" + loaderParams;r.charset = "utf-8";var a = document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r, a); | ||
})(apiKey); | ||
}r(); | ||
})(); | ||
} | ||
} | ||
}; | ||
DidomiSDK.prototype.componentDidMount = function componentDidMount() { | ||
this.init(); | ||
// Embed the SDK | ||
var loaderScript = document.createElement('script'); | ||
loaderScript.id = 'spcloader'; | ||
loaderScript.type = 'text/javascript'; | ||
loaderScript.async = true; | ||
loaderScript.src = sdkPath + apiKey + '/loader.js?' + loaderParams; | ||
loaderScript.charset = 'utf-8'; | ||
if (this.props.onReady) { | ||
window.didomiOnReady = window.didomiOnReady || []; | ||
window.didomiOnReady.push(this.didomiOnReady.bind(this)); | ||
} | ||
var firstScriptTagInDocument = document.getElementsByTagName('script')[0]; | ||
firstScriptTagInDocument.parentNode.insertBefore(loaderScript, firstScriptTagInDocument); | ||
}; | ||
DidomiSDK.prototype.render = function render() { | ||
return null; | ||
}; | ||
_react2.default.useEffect(function () { | ||
setEvents(); | ||
init(); | ||
}, []); | ||
return DidomiSDK; | ||
}(_react.Component), _class.defaultProps = { | ||
apiKey: null, | ||
iabVersion: 1, | ||
noticeId: null, | ||
config: {}, | ||
gdprAppliesGlobally: true, | ||
onReady: function onReady() {}, | ||
onConsentChanged: function onConsentChanged() {}, | ||
onNoticeShown: function onNoticeShown() {}, | ||
onNoticeHidden: function onNoticeHidden() {}, | ||
onNoticeBackdropclick: function onNoticeBackdropclick() {}, | ||
onNoticeClickAgree: function onNoticeClickAgree() {}, | ||
onNoticeClickMoreInfo: function onNoticeClickMoreInfo() {}, | ||
onPreferencesClickAgreeToAll: function onPreferencesClickAgreeToAll() {}, | ||
onPreferencesClickDisagreeToAll: function onPreferencesClickDisagreeToAll() {}, | ||
onPreferencesClickPurposeAgree: function onPreferencesClickPurposeAgree() {}, | ||
onPreferencesClickPurposeDisagree: function onPreferencesClickPurposeDisagree() {}, | ||
onPreferencesClickViewVendors: function onPreferencesClickViewVendors() {}, | ||
onPreferencesClickSaveChoices: function onPreferencesClickSaveChoices() {}, | ||
onPreferencesClickVendorAgree: function onPreferencesClickVendorAgree() {}, | ||
onPreferencesClickVendorDisagree: function onPreferencesClickVendorDisagree() {}, | ||
onPreferencesClickVendorSaveChoices: function onPreferencesClickVendorSaveChoices() {} }, _temp); | ||
DidomiSDK.propTypes = process.env.NODE_ENV !== "production" ? { | ||
return null; | ||
}; | ||
DidomiSDK.propTypes = { | ||
apiKey: _propTypes2.default.string, | ||
@@ -329,6 +373,7 @@ iabVersion: _propTypes2.default.number, | ||
onPreferencesClickVendorDisagree: _propTypes2.default.func, | ||
onPreferencesClickVendorSaveChoices: _propTypes2.default.func | ||
} : {}; | ||
; | ||
onPreferencesClickVendorSaveChoices: _propTypes2.default.func, | ||
sdkPath: _propTypes2.default.string, | ||
embedTCFStub: _propTypes2.default.bool | ||
}; | ||
exports.DidomiSDK = DidomiSDK; |
{ | ||
"name": "@didomi/react", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "didomi-react-test React component", | ||
@@ -21,7 +21,11 @@ "main": "lib/index.js", | ||
"test:coverage": "nwb test-react --coverage", | ||
"test:watch": "nwb test-react --server" | ||
"test:watch": "nwb test-react --server", | ||
"lint": "prettier --check src/ tests/", | ||
"lint:fix": "prettier --write src/ tests/" | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"dset": "^2.0.1" | ||
}, | ||
"peerDependencies": { | ||
"react": "16.x" | ||
"react": "^16.8.0 || ^17.0.0" | ||
}, | ||
@@ -31,7 +35,8 @@ "devDependencies": { | ||
"nwb": "0.23.x", | ||
"react": "^16.5.2", | ||
"react-dom": "^16.5.2" | ||
"prettier": "2.1.2", | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0" | ||
}, | ||
"author": "Didomi", | ||
"homepage": "https://www.didomi.io/fr/", | ||
"homepage": "https://www.didomi.io/", | ||
"license": "MIT", | ||
@@ -41,3 +46,3 @@ "keywords": [ | ||
"sdk", | ||
"dgpr", | ||
"gdpr", | ||
"react" | ||
@@ -44,0 +49,0 @@ ], |
@@ -21,3 +21,3 @@ | ||
We recommend instantiating the `DidomiSDK` component as early as possible in your React application. | ||
We recommend instantiating the `DidomiSDK` component as early as possible in your React application. | ||
The sooner you instantiate the component, the faster the banner will be displayed or the faster the consents will be shared with your partners and the ads displayed. | ||
@@ -35,5 +35,7 @@ | ||
apiKey="API_KEY" | ||
iabVersion={1} // If you want to support the TCF v2, don't forget to change this value, even if you selected the TCF v2 in the console. This parameter will load the correct stub in the React Component | ||
iabVersion={2} // If you want to support the TCF v1∏, don't forget to change this value, even if you selected the TCF v2 in the console. This parameter will load the correct stub in the React Component | ||
noticeId="NOTICE_ID" // If you want to target the notice by ID and not by domain | ||
gdprAppliesGlobally={true} | ||
sdkPath="https://sdk.privacy-center.org/" | ||
embedTCFStub={true} | ||
onReady={didomi => console.log('Didomi SDK is loaded and ready', didomi)} | ||
@@ -84,5 +86,7 @@ onConsentChanged={cwtToken => console.log('A consent has been given/withdrawn', cwtToken)} | ||
config={didomiConfig} | ||
iabVersion={1} // If you want to support the TCF v2, don't forget to change this value. This parameter will load the correct stub in the React Component | ||
iabVersion={2} // If you want to support the TCF v1, don't forget to change this value. This parameter will load the correct stub in the React Component | ||
noticeId="NOTICE_ID" // If you want to target the notice by ID and not by domain | ||
gdprAppliesGlobally={true} | ||
sdkPath="https://sdk.privacy-center.org/" | ||
embedTCFStub={true} | ||
onReady={didomi => console.log('Didomi SDK is loaded and ready', didomi)} | ||
@@ -153,2 +157,14 @@ onConsentChanged={cwtToken => console.log('A consent has been given/withdrawn', cwtToken)} | ||
<tr> | ||
<td>sdkPath</td> | ||
<td>string</td> | ||
<td>https://sdk.privacy-center.org/</td> | ||
<td>Path to load the SDK from. This can be used to load the Didomi SDK from your own custom domain after <a href="https://developers.didomi.io/cmp/web-sdk/self-hosting">setting up a reverse proxy</a>. The property must start with <code>http://</code>, <code>https://</code>, or <code>//</code>. It must also end with a final <code>/</code>.</td> | ||
</tr> | ||
<tr> | ||
<td>embedTCFStub</td> | ||
<td>boolean</td> | ||
<td><code>true</code></td> | ||
<td>Define whether the IAB TCF stub is embedded on the page before loading the SDK. If your consent notice uses the IAB TCF, we recommend embedding the IAB TCF stub to optimize the communication with vendors.</td> | ||
</tr> | ||
<tr> | ||
<td>onReady</td> | ||
@@ -264,6 +280,7 @@ <td>function</td> | ||
### Configuration object (Optional) | ||
### Configuration object | ||
The notice is usually configured through the Didomi Console. If you choose to manage the configuration via a configuration object, the `config` prop allows you to pass configuration options that override the configuration from the Console and is optional. | ||
This is the structure of the configuration object passed to the `config` prop. For more information, please visit our [SDK documentation](https://developers.didomi.io/cmp/web-sdk/getting-started) | ||
This is the structure of the configuration object passed to the `config` prop. For more information, please visit our [SDK documentation](https://developers.didomi.io/cmp/web-sdk/getting-started). | ||
@@ -487,3 +504,3 @@ ```js | ||
``` | ||
## Customize the notice | ||
@@ -525,4 +542,4 @@ | ||
const didomiConfig = { | ||
app: { | ||
apiKey: '<Your API key>', | ||
app: { | ||
apiKey: '<Your API key>', | ||
notice: { | ||
@@ -553,4 +570,4 @@ content: { | ||
const didomiConfig = { | ||
app: { | ||
apiKey: '<Your API key>', | ||
app: { | ||
apiKey: '<Your API key>', | ||
notice: { | ||
@@ -570,3 +587,3 @@ content: { | ||
``` | ||
### Didomi SDK Documentation | ||
@@ -573,0 +590,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
48922
784
586
0
2
5
+ Addeddset@^2.0.1
+ Addeddset@2.1.0(transitive)
+ Addedreact@17.0.2(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-is@16.13.1(transitive)