gdpr-guard
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -13,7 +13,6 @@ import { GdprStorage } from "../GdprStorage"; | ||
protected constructor(parent: GdprManagerBuilder, name: string, description: string, storage: GdprStorage, enable: boolean, require: boolean); | ||
static create(mb: GdprManagerBuilder, name: string, description?: string, storage?: GdprStorage | null, enabled?: boolean, required?: boolean): GdprGroupBuilder; | ||
startGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; | ||
startRequiredGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; | ||
static create(mb: GdprManagerBuilder, name: string, description?: string, storage?: GdprStorage | null, enabled?: boolean, required?: boolean): GdprGroupBuilder; | ||
endGroup(): GdprManagerBuilder; | ||
protected edit(cb: (builder: GdprGroupBuilder) => any): GdprGroupBuilder; | ||
withName(name: string): GdprGroupBuilder; | ||
@@ -29,3 +28,4 @@ withDescription(description: string): GdprGroupBuilder; | ||
withDisabledGuard(name: string, description?: string, storage?: GdprStorage | null): GdprGroupBuilder; | ||
protected edit(cb: (builder: GdprGroupBuilder) => any): GdprGroupBuilder; | ||
} | ||
export { GdprGroupBuilder, }; |
@@ -13,3 +13,2 @@ import { GdprGroupBuilder } from "./builders"; | ||
endGuard(): GdprGroupBuilder; | ||
protected edit(edit: (builder: GdprGuardBuilder) => any): GdprGuardBuilder; | ||
withName(name: string): GdprGuardBuilder; | ||
@@ -21,3 +20,4 @@ withDescription(description: string): GdprGuardBuilder; | ||
required(): GdprGuardBuilder; | ||
protected edit(edit: (builder: GdprGuardBuilder) => any): GdprGuardBuilder; | ||
} | ||
export { GdprGuardBuilder, }; |
@@ -8,3 +8,5 @@ import { GdprGuardGroup } from "../GdprGuardGroup"; | ||
groups: GdprGuardGroup[]; | ||
bannerWasShown: boolean; | ||
static make(): GdprManagerBuilder; | ||
withBannerShown(wasShown?: boolean): void; | ||
startGroup(storage?: GdprStorage | null, name?: string, description?: string, enabled?: boolean): GdprGroupBuilder; | ||
@@ -11,0 +13,0 @@ startRequiredGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; |
@@ -5,4 +5,5 @@ export * from "./GdprGuard"; | ||
export * from "./GdprStorage"; | ||
export * from "./visitor"; | ||
export * from "./builders/builders"; | ||
export * from "./serde/GdprDeserializer"; | ||
export * from "./serde/GdprSavior"; |
@@ -1,1 +0,1 @@ | ||
!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("gdprGuard",[],t):"object"==typeof exports?exports.gdprGuard=t():r.gdprGuard=t()}(self,(function(){return(()=>{"use strict";var r={315:(r,t,e)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.makeGuard=void 0;var n=e(670);t.makeGuard=function(r,t,e,o,i){return void 0===e&&(e=n.GdprStorage.Cookie),void 0===o&&(o=!1),void 0===i&&(i=null),{name:r,description:t,storage:e,required:o,enabled:null===i?o:i,enable:function(){return this.enabled||this.toggle(),this},disable:function(){return this.enabled&&this.toggle(),this},toggle:function(){return this.required||(this.enabled=!this.enabled),this},makeRequired:function(){return this.required=!0,this.enabled=!0,this},isEnabled:function(r){return this.name===r&&this.enabled},enableForStorage:function(r){return this.enabled||this.toggleForStorage(r),this},disableForStorage:function(r){return this.enabled&&this.toggleForStorage(r),this},toggleForStorage:function(r){return this.storage!=r||this.required||this.toggle(),this},raw:function(){return JSON.parse(JSON.stringify(this))}}}},822:function(r,t,e){var n=this&&this.__values||function(r){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__read||function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,o,i=e.call(r),u=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spreadArray||function(r,t,e){if(e||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return r.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.GdprGuardGroup=void 0;var u=e(670),a=function(){function r(r,t,e,n){void 0===t&&(t=""),void 0===e&&(e=!1),void 0===n&&(n=!1),this.name=r,this.description=t,this.enabled=e,this.required=n,this.bindings=new Map,this.storage=u.GdprStorage.None,this.required&&(this.enabled=!0)}return r.for=function(t,e,n,o){return void 0===e&&(e=""),void 0===n&&(n=!1),void 0===o&&(o=!1),new r(t,e,n,o)},r.prototype.addGuard=function(r){return this.bindings.set(r.name,r),this},r.prototype.hasGuard=function(r){return this.name===r||this.bindings.has(r)},r.prototype.getGuard=function(r){return this.name===r?this:this.bindings.get(r)||null},r.prototype.doForEachGuard=function(r){return this.bindings.forEach((function(t){return r(t)})),this},r.prototype.isEnabled=function(r){var t,e;if(this.hasGuard(r)&&null!==(a=this.getGuard(r)))return a.enabled;try{for(var i=n(this.bindings),u=i.next();!u.done;u=i.next()){var a,s=o(u.value,2);if(s[0],(a=s[1]).isEnabled(r))return!0}}catch(r){t={error:r}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return!1},r.prototype.enable=function(){return this.required?this:(this.enabled=!0,this.doForEachGuard((function(r){return r.enable()})))},r.prototype.disable=function(){return this.required?this:(this.enabled=!1,this.doForEachGuard((function(r){return r.disable()})))},r.prototype.toggle=function(){return this.enabled?this.disable():this.enable()},r.prototype.makeRequired=function(){return this.required=!0,this.enabled=!0,this.doForEachGuard((function(r){return r.makeRequired()}))},r.prototype.enableForStorage=function(r){return this.doForEachGuard((function(t){t.storage&r&&t.enable()}))},r.prototype.disableForStorage=function(r){return this.doForEachGuard((function(t){t.storage&r&&t.disable()}))},r.prototype.toggleForStorage=function(r){return this.doForEachGuard((function(t){if(t.storage&r)return t.toggle()}))},r.prototype.raw=function(){var r={name:this.name,description:this.description,enabled:this.enabled,required:this.required,storage:this.storage,guards:[]};return r.guards=i([],o(this.bindings),!1).map((function(r){var t=o(r,2);return t[0],t[1].raw()})),r},r}();t.GdprGuardGroup=a},777:function(r,t,e){var n=this&&this.__values||function(r){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__read||function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,o,i=e.call(r),u=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spreadArray||function(r,t,e){if(e||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return r.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.GdprManager=void 0;var u=e(822),a=e(670),s=function(){function r(){this.groups=new Map,this.name="manager",this.description="Manager of GDPR guard groups",this.enabled=!0,this.storage=a.GdprStorage.None,this.required=!1}return r.create=function(t){void 0===t&&(t=[]);var e=new r;return t.forEach((function(r){return e.addGroup(r)})),e},r.prototype.createGroup=function(r,t){return void 0===t&&(t=""),this.addGroup(u.GdprGuardGroup.for(r,t))},r.prototype.addGroup=function(r){return this.groups.set(r.name,r),this},r.prototype.reduceGroupsPred=function(r){var t,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2);if(a[0],r(a[1]))return!0}}catch(r){t={error:r}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return!1},r.prototype.forEachGroup=function(r){return this.groups.forEach((function(t){return r(t)})),this},r.prototype.hasGuard=function(r){return this.reduceGroupsPred((function(t){return t.hasGuard(r)}))},r.prototype.getGuard=function(r){var t,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2),s=(a[0],a[1]);if(s.hasGuard(r))return s.getGuard(r)}}catch(r){t={error:r}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return null},r.prototype.hasGroup=function(r){return this.reduceGroupsPred((function(t){return t.name===r}))},r.prototype.getGroup=function(r){var t,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2),s=a[0],d=a[1];if(s===r)return d}}catch(r){t={error:r}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return null},r.prototype.isEnabled=function(r){return this.reduceGroupsPred((function(t){return t.isEnabled(r)}))},r.prototype.enable=function(){return this.enabled=!0,this.forEachGroup((function(r){return r.enable()}))},r.prototype.disable=function(){return this.enabled=!1,this.forEachGroup((function(r){return r.disable()}))},r.prototype.toggle=function(){return this.enabled?this.disable():this.enable()},r.prototype.makeRequired=function(){return this},r.prototype.enableForStorage=function(r){return this.forEachGroup((function(t){return t.enableForStorage(r)}))},r.prototype.disableForStorage=function(r){return this.forEachGroup((function(t){return t.disableForStorage(r)}))},r.prototype.toggleForStorage=function(r){return this.forEachGroup((function(t){return t.toggleForStorage(r)}))},r.prototype.raw=function(){var r={enabled:this.enabled,groups:[]};return r.groups=i([],o(this.groups),!1).map((function(r){var t=o(r,2);return t[0],t[1].raw()})),r},r}();t.GdprManager=s},670:(r,t)=>{var e;Object.defineProperty(t,"__esModule",{value:!0}),t.GdprStorage=void 0,function(r){r[r.None=1]="None",r[r.Cookie=2]="Cookie",r[r.LocalStorage=4]="LocalStorage",r[r.SessionStorage=8]="SessionStorage",r[r.IndexedDb=16]="IndexedDb",r[r.FileSystem=16]="FileSystem",r[r.ServerStorage=16]="ServerStorage",r[r.All=30]="All"}(e||(e={})),t.GdprStorage=e},860:function(r,t,e){var n,o=this&&this.__extends||(n=function(r,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])},n(r,t)},function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=r}n(r,t),r.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),i=this&&this.__read||function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,o,i=e.call(r),u=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__spreadArray||function(r,t,e){if(e||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return r.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.GdprGroupBuilder=void 0;var a=e(670),s=e(237),d=e(822),l=e(890),c=function(r){function t(t,e,n,o,i,u){var a=r.call(this)||this;return a.parent=t,a.name=e,a.description=n,a.enable=i,a.require=u,a.guards=[],a.storage=o,u&&(a.enable=!0),a}return o(t,r),t.prototype.startGroup=function(t,e,n){return void 0===t&&(t=null),void 0===e&&(e=""),void 0===n&&(n=""),r.prototype.startGroup.call(this,t||this.parent.storage,e,n)},t.prototype.startRequiredGroup=function(r,t,e){return void 0===r&&(r=null),void 0===t&&(t=""),void 0===e&&(e=""),this.startGroup(r,t,e).required()},t.create=function(r,e,n,o,i,u){return void 0===n&&(n=""),void 0===o&&(o=null),void 0===i&&(i=!0),void 0===u&&(u=!1),new t(r,e,n,o||a.GdprStorage.Cookie,i,u)},t.prototype.endGroup=function(){var r=this.require||this.enable,t=d.GdprGuardGroup.for(this.name,this.description,r,this.require);return u(u([],i(this.guards),!1),i(this.groups),!1).forEach((function(r){return t.addGuard(r)})),this.require&&t.makeRequired(),this.parent.groups.push(t),this.parent},t.prototype.edit=function(r){return r(this),this},t.prototype.withName=function(r){return this.edit((function(t){return t.name=r}))},t.prototype.withDescription=function(r){return this.edit((function(t){return t.description=r}))},t.prototype.storedIn=function(r){return this.edit((function(t){return t.storage=r}))},t.prototype.enabled=function(){return this.edit((function(r){return r.enable=!0}))},t.prototype.disabled=function(){return this.edit((function(r){return r.enable=!1}))},t.prototype.required=function(){return this.edit((function(r){return r.require=!0}))},t.prototype.startGuard=function(r){return void 0===r&&(r=null),l.GdprGuardBuilder.create(this,r||this.storage,this.enable)},t.prototype.startRequiredGuard=function(r){return this.startGuard(r).required()},t.prototype.withEnabledGuard=function(r,t,e){return void 0===t&&(t=""),void 0===e&&(e=null),this.startGuard(e).withName(r).withDescription(t).enabled().endGuard()},t.prototype.withDisabledGuard=function(r,t,e){return void 0===t&&(t=""),void 0===e&&(e=null),this.startGuard(e).withName(r).withDescription(t).disabled().endGuard()},t}(s.GdprManagerBuilder);t.GdprGroupBuilder=c},890:(r,t,e)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GdprGuardBuilder=void 0;var n=e(670),o=e(315),i=function(){function r(r,t,e,n){this.parent=r,this.storage=t,this.enable=e,this.require=n,this.name="",this.description="",n&&(this.enable=!0)}return r.create=function(t,e,o,i){return void 0===e&&(e=n.GdprStorage.Cookie),void 0===o&&(o=!1),void 0===i&&(i=!1),new r(t,e,o,i)},r.prototype.endGuard=function(){var r=this.require||this.enable,t=(0,o.makeGuard)(this.name,this.description,this.storage,this.require,r);return this.require&&t.makeRequired(),this.parent.guards.push(t),this.parent},r.prototype.edit=function(r){return r(this),this},r.prototype.withName=function(r){return this.edit((function(t){return t.name=r}))},r.prototype.withDescription=function(r){return this.edit((function(t){return t.description=r}))},r.prototype.enabled=function(){return this.edit((function(r){return r.enable=!0}))},r.prototype.disabled=function(){return this.edit((function(r){return r.enable=!1}))},r.prototype.storedIn=function(r){return this.edit((function(t){return t.storage=r}))},r.prototype.required=function(){return this.edit((function(r){return r.require=!0}))},r}();t.GdprGuardBuilder=i},237:(r,t,e)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GdprManagerBuilder=void 0;var n=e(670),o=e(777),i=e(171),u=function(){function r(){this.storage=n.GdprStorage.Cookie,this.groups=[]}return r.make=function(){return new r},r.prototype.startGroup=function(r,t,e,n){return void 0===r&&(r=null),void 0===t&&(t=""),void 0===e&&(e=""),void 0===n&&(n=!0),i.GdprGroupBuilder.create(this,t,e,r,n,!1)},r.prototype.startRequiredGroup=function(r,t,e){return void 0===r&&(r=null),void 0===t&&(t=""),void 0===e&&(e=""),this.startEnabledGroup(r,t,e).required()},r.prototype.startEnabledGroup=function(r,t,e){return void 0===r&&(r=null),void 0===t&&(t=""),void 0===e&&(e=""),this.startGroup(r,t,e,!0).enabled()},r.prototype.startDisabledGroup=function(r,t,e){return void 0===r&&(r=null),void 0===t&&(t=""),void 0===e&&(e=""),this.startGroup(r,t,e,!1).disabled()},r.prototype.build=function(){return o.GdprManager.create(this.groups)},r.prototype.endGroup=function(){return this},r}();t.GdprManagerBuilder=u},171:function(r,t,e){var n=this&&this.__createBinding||(Object.create?function(r,t,e,n){void 0===n&&(n=e),Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,n){void 0===n&&(n=e),r[n]=t[e]}),o=this&&this.__exportStar||function(r,t){for(var e in r)"default"===e||Object.prototype.hasOwnProperty.call(t,e)||n(t,r,e)};Object.defineProperty(t,"__esModule",{value:!0}),o(e(890),t),o(e(237),t),o(e(860),t)},93:function(r,t,e){var n=this&&this.__createBinding||(Object.create?function(r,t,e,n){void 0===n&&(n=e),Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,n){void 0===n&&(n=e),r[n]=t[e]}),o=this&&this.__exportStar||function(r,t){for(var e in r)"default"===e||Object.prototype.hasOwnProperty.call(t,e)||n(t,r,e)};Object.defineProperty(t,"__esModule",{value:!0}),o(e(315),t),o(e(822),t),o(e(777),t),o(e(670),t),o(e(171),t),o(e(562),t),o(e(344),t)},562:(r,t,e)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GdprDeserializer=void 0;var n=e(777),o=e(670),i=e(822),u=e(315),a=function(){function r(){}return r.manager=function(r){var t=this;if(!["enabled","groups"].every((function(t){return t in r}))||"boolean"!=typeof r.enabled||!Array.isArray(r.groups))return null;var e=r.groups.map((function(r){return t.group(r)})).filter((function(r){return null!==r})),o=n.GdprManager.create([]);return o.enabled=!!r.enabled,e.length?(e.forEach((function(r){return o.addGroup(r)})),o):null},r.group=function(r){var t=this,e=this.guard(r);if(null===e)return null;var n=["guards"];if(!n.every((function(t){return t in r}))||!Array.isArray(r.guards))return null;var o=i.GdprGuardGroup.for(e.name,e.description,e.enabled,e.required),u=r.guards.map((function(r){return n.every((function(t){return t in r}))?t.group(r):t.guard(r)})).filter((function(r){return null!==r}));return u.length?(u.forEach((function(r){return o.addGuard(r)})),o):null},r.guard=function(r){return["name","enabled","required","description","storage"].every((function(t){return t in r}))&&"string"==typeof r.name&&"boolean"==typeof r.enabled&&"boolean"==typeof r.required&&"string"==typeof r.description&&"number"==typeof r.storage&&r.storage in o.GdprStorage?(0,u.makeGuard)(r.name,r.description,r.storage,!!r.required,!!r.enabled):null},r}();t.GdprDeserializer=a},344:function(r,t){var e=this&&this.__awaiter||function(r,t,e,n){return new(e||(e=Promise))((function(o,i){function u(r){try{s(n.next(r))}catch(r){i(r)}}function a(r){try{s(n.throw(r))}catch(r){i(r)}}function s(r){var t;r.done?o(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(u,a)}s((n=n.apply(r,t||[])).next())}))},n=this&&this.__generator||function(r,t){var e,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(r,u)}catch(r){i=[6,r],n=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.GdprSaviorAdapter=void 0;var o=function(){function r(){}return r.prototype.exists=function(r){return void 0===r&&(r=!0),e(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,this.restore(r)];case 1:return[2,null!==t.sent()]}}))}))},r.prototype.storeIfNotExists=function(r){return e(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,this.exists()];case 1:return[2,!!t.sent()||this.store(r)]}}))}))},r.prototype.restoreOrCreate=function(r){return e(this,void 0,void 0,(function(){var t,e;return n(this,(function(n){switch(n.label){case 0:return[4,this.restore()];case 1:return(t=n.sent())?[3,3]:[4,r()];case 2:return e=n.sent(),this.updateSharedManager(e),[2,e];case 3:return[2,t]}}))}))},r.prototype.check=function(){return e(this,void 0,void 0,(function(){var r=this;return n(this,(function(t){switch(t.label){case 0:return[4,Promise.resolve()];case 1:return t.sent(),setTimeout((function(){r.exists(!0)}),100),[2]}}))}))},r}();t.GdprSaviorAdapter=o}},t={};return function e(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return r[n].call(i.exports,i,i.exports,e),i.exports}(93)})()})); | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("gdprGuard",[],r):"object"==typeof exports?exports.gdprGuard=r():t.gdprGuard=r()}(self,(function(){return(()=>{"use strict";var t={315:(t,r,e)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.makeGuard=void 0;var n=e(670);r.makeGuard=function(t,r,e,o,i){return void 0===e&&(e=n.GdprStorage.Cookie),void 0===o&&(o=!1),void 0===i&&(i=null),{name:t,description:r,storage:e,required:o,enabled:null===i?o:i,enable:function(){return this.enabled||this.toggle(),this},disable:function(){return this.enabled&&this.toggle(),this},toggle:function(){return this.required||(this.enabled=!this.enabled),this},makeRequired:function(){return this.required=!0,this.enabled=!0,this},isEnabled:function(t){return this.name===t&&this.enabled},enableForStorage:function(t){return this.enabled||this.toggleForStorage(t),this},disableForStorage:function(t){return this.enabled&&this.toggleForStorage(t),this},toggleForStorage:function(t){return this.storage!=t||this.required||this.toggle(),this},raw:function(){return JSON.parse(JSON.stringify(this))}}}},822:function(t,r,e){var n=this&&this.__values||function(t){var r="function"==typeof Symbol&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__read||function(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,i=e.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return t.concat(n||Array.prototype.slice.call(r))};Object.defineProperty(r,"__esModule",{value:!0}),r.GdprGuardGroup=void 0;var u=e(670),a=function(){function t(t,r,e,n){void 0===r&&(r=""),void 0===e&&(e=!1),void 0===n&&(n=!1),this.name=t,this.description=r,this.enabled=e,this.required=n,this.storage=u.GdprStorage.None,this.bindings=new Map,this.required&&(this.enabled=!0)}return t.for=function(r,e,n,o){return void 0===e&&(e=""),void 0===n&&(n=!1),void 0===o&&(o=!1),new t(r,e,n,o)},t.prototype.addGuard=function(t){return this.bindings.set(t.name,t),this},t.prototype.hasGuard=function(t){return this.name===t||this.bindings.has(t)},t.prototype.getGuard=function(t){return this.name===t?this:this.bindings.get(t)||null},t.prototype.isEnabled=function(t){var r,e;if(this.hasGuard(t)&&null!==(a=this.getGuard(t)))return a.enabled;try{for(var i=n(this.bindings),u=i.next();!u.done;u=i.next()){var a,s=o(u.value,2);if(s[0],(a=s[1]).isEnabled(t))return!0}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return!1},t.prototype.enable=function(){return this.required?this:(this.enabled=!0,this.doForEachGuard((function(t){return t.enable()})))},t.prototype.disable=function(){return this.required?this:(this.enabled=!1,this.doForEachGuard((function(t){return t.disable()})))},t.prototype.toggle=function(){return this.enabled?this.disable():this.enable()},t.prototype.makeRequired=function(){return this.required=!0,this.enabled=!0,this.doForEachGuard((function(t){return t.makeRequired()}))},t.prototype.enableForStorage=function(t){return this.doForEachGuard((function(r){r.storage&t&&r.enable()}))},t.prototype.disableForStorage=function(t){return this.doForEachGuard((function(r){r.storage&t&&r.disable()}))},t.prototype.toggleForStorage=function(t){return this.doForEachGuard((function(r){if(r.storage&t)return r.toggle()}))},t.prototype.raw=function(){var t={name:this.name,description:this.description,enabled:this.enabled,required:this.required,storage:this.storage,guards:[]};return t.guards=i([],o(this.bindings),!1).map((function(t){var r=o(t,2);return r[0],r[1].raw()})),t},t.prototype.doForEachGuard=function(t){return this.bindings.forEach((function(r){return t(r)})),this},t.prototype.getGuards=function(){return i([],o(this.bindings.values()),!1)},t}();r.GdprGuardGroup=a},777:function(t,r,e){var n=this&&this.__values||function(t){var r="function"==typeof Symbol&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__read||function(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,i=e.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return t.concat(n||Array.prototype.slice.call(r))};Object.defineProperty(r,"__esModule",{value:!0}),r.GdprManager=void 0;var u=e(822),a=e(670),s=e(554),d=e(779),c=function(){function t(){this.bannerWasShown=!1,this.enabled=!0,this.events=new s.GdprManagerEventHub,this.groups=new Map,this.name="manager",this.description="Manager of GDPR guard groups",this.storage=a.GdprStorage.None,this.required=!1}return t.create=function(r){void 0===r&&(r=[]);var e=new t;return r.forEach((function(t){return e.addGroup(t)})),e},t.prototype.closeBanner=function(){var t=this;this.bannerWasShown=!0,(0,d.visitGdpr)(this,{onEach:function(r){r.enabled?t.events.enable(r.name):t.events.disable(r.name)}})},t.prototype.resetAndShowBanner=function(){this.bannerWasShown=!1},t.prototype.createGroup=function(t,r){return void 0===r&&(r=""),this.addGroup(u.GdprGuardGroup.for(t,r))},t.prototype.addGroup=function(t){return this.groups.set(t.name,t),this},t.prototype.hasGuard=function(t){return this.reduceGroupsPred((function(r){return r.hasGuard(t)}))},t.prototype.getGuard=function(t){var r,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2),s=(a[0],a[1]);if(s.hasGuard(t))return s.getGuard(t)}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return null},t.prototype.hasGroup=function(t){return this.reduceGroupsPred((function(r){return r.name===t}))},t.prototype.getGroup=function(t){var r,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2),s=a[0],d=a[1];if(s===t)return d}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return null},t.prototype.isEnabled=function(t){return this.reduceGroupsPred((function(r){return r.isEnabled(t)}))},t.prototype.enable=function(){return this.enabled=!0,this.forEachGroup((function(t){return t.enable()}))},t.prototype.disable=function(){return this.enabled=!1,this.forEachGroup((function(t){return t.disable()}))},t.prototype.toggle=function(){return this.enabled?this.disable():this.enable()},t.prototype.makeRequired=function(){return this},t.prototype.enableForStorage=function(t){return this.forEachGroup((function(r){return r.enableForStorage(t)}))},t.prototype.disableForStorage=function(t){return this.forEachGroup((function(r){return r.disableForStorage(t)}))},t.prototype.toggleForStorage=function(t){return this.forEachGroup((function(r){return r.toggleForStorage(t)}))},t.prototype.raw=function(){var t={bannerWasShown:this.bannerWasShown,enabled:this.enabled,groups:[]};return t.groups=i([],o(this.groups.values()),!1).map((function(t){return t.raw()})),t},t.prototype.reduceGroupsPred=function(t){var r,e;try{for(var i=n(this.groups),u=i.next();!u.done;u=i.next()){var a=o(u.value,2);if(a[0],t(a[1]))return!0}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return!1},t.prototype.forEachGroup=function(t){return this.groups.forEach((function(r){return t(r)})),this},t.prototype.getGroups=function(){return i([],o(this.groups.values()),!1)},t}();r.GdprManager=c},554:(t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.GdprManagerEventHub=void 0;var e=function(){function t(){this.eventMap={}}return t.prototype.onEnable=function(t,r){return this.addListener("enable",t,r),this},t.prototype.onDisable=function(t,r){return this.addListener("disable",t,r),this},t.prototype.enable=function(t){return this.executeListeners("enable",t),this},t.prototype.disable=function(t){return this.executeListeners("disable",t),this},t.prototype.tagFor=function(t,r){return"".concat(t,"--").concat(r)},t.prototype.addListener=function(t,r,e){var n=this.tagFor(t,r);n in this.eventMap||(this.eventMap[n]=[]),this.eventMap[n].push(e)},t.prototype.executeListeners=function(t,r){var e,n=this.tagFor(t,r);null===(e=this.eventMap[n])||void 0===e||e.forEach((function(t){return t()}))},t}();r.GdprManagerEventHub=e},670:(t,r)=>{var e;Object.defineProperty(r,"__esModule",{value:!0}),r.GdprStorage=void 0,function(t){t[t.None=1]="None",t[t.Cookie=2]="Cookie",t[t.LocalStorage=4]="LocalStorage",t[t.SessionStorage=8]="SessionStorage",t[t.IndexedDb=16]="IndexedDb",t[t.FileSystem=16]="FileSystem",t[t.ServerStorage=16]="ServerStorage",t[t.All=30]="All"}(e||(e={})),r.GdprStorage=e},860:function(t,r,e){var n,o=this&&this.__extends||(n=function(t,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])},n(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),i=this&&this.__read||function(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,i=e.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return t.concat(n||Array.prototype.slice.call(r))};Object.defineProperty(r,"__esModule",{value:!0}),r.GdprGroupBuilder=void 0;var a=e(670),s=e(237),d=e(822),c=e(890),p=function(t){function r(r,e,n,o,i,u){var a=t.call(this)||this;return a.parent=r,a.name=e,a.description=n,a.enable=i,a.require=u,a.guards=[],a.storage=o,u&&(a.enable=!0),a}return o(r,t),r.create=function(t,e,n,o,i,u){return void 0===n&&(n=""),void 0===o&&(o=null),void 0===i&&(i=!0),void 0===u&&(u=!1),new r(t,e,n,o||a.GdprStorage.Cookie,i,u)},r.prototype.startGroup=function(r,e,n){return void 0===r&&(r=null),void 0===e&&(e=""),void 0===n&&(n=""),t.prototype.startGroup.call(this,r||this.parent.storage,e,n)},r.prototype.startRequiredGroup=function(t,r,e){return void 0===t&&(t=null),void 0===r&&(r=""),void 0===e&&(e=""),this.startGroup(t,r,e).required()},r.prototype.endGroup=function(){var t=this.require||this.enable,r=d.GdprGuardGroup.for(this.name,this.description,t,this.require);return u(u([],i(this.guards),!1),i(this.groups),!1).forEach((function(t){return r.addGuard(t)})),this.require&&r.makeRequired(),this.parent.groups.push(r),this.parent},r.prototype.withName=function(t){return this.edit((function(r){return r.name=t}))},r.prototype.withDescription=function(t){return this.edit((function(r){return r.description=t}))},r.prototype.storedIn=function(t){return this.edit((function(r){return r.storage=t}))},r.prototype.enabled=function(){return this.edit((function(t){return t.enable=!0}))},r.prototype.disabled=function(){return this.edit((function(t){return t.enable=!1}))},r.prototype.required=function(){return this.edit((function(t){return t.require=!0}))},r.prototype.startGuard=function(t){return void 0===t&&(t=null),c.GdprGuardBuilder.create(this,t||this.storage,this.enable)},r.prototype.startRequiredGuard=function(t){return this.startGuard(t).required()},r.prototype.withEnabledGuard=function(t,r,e){return void 0===r&&(r=""),void 0===e&&(e=null),this.startGuard(e).withName(t).withDescription(r).enabled().endGuard()},r.prototype.withDisabledGuard=function(t,r,e){return void 0===r&&(r=""),void 0===e&&(e=null),this.startGuard(e).withName(t).withDescription(r).disabled().endGuard()},r.prototype.edit=function(t){return t(this),this},r}(s.GdprManagerBuilder);r.GdprGroupBuilder=p},890:(t,r,e)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.GdprGuardBuilder=void 0;var n=e(670),o=e(315),i=function(){function t(t,r,e,n){this.parent=t,this.storage=r,this.enable=e,this.require=n,this.name="",this.description="",n&&(this.enable=!0)}return t.create=function(r,e,o,i){return void 0===e&&(e=n.GdprStorage.Cookie),void 0===o&&(o=!1),void 0===i&&(i=!1),new t(r,e,o,i)},t.prototype.endGuard=function(){var t=this.require||this.enable,r=(0,o.makeGuard)(this.name,this.description,this.storage,this.require,t);return this.require&&r.makeRequired(),this.parent.guards.push(r),this.parent},t.prototype.withName=function(t){return this.edit((function(r){return r.name=t}))},t.prototype.withDescription=function(t){return this.edit((function(r){return r.description=t}))},t.prototype.enabled=function(){return this.edit((function(t){return t.enable=!0}))},t.prototype.disabled=function(){return this.edit((function(t){return t.enable=!1}))},t.prototype.storedIn=function(t){return this.edit((function(r){return r.storage=t}))},t.prototype.required=function(){return this.edit((function(t){return t.require=!0}))},t.prototype.edit=function(t){return t(this),this},t}();r.GdprGuardBuilder=i},237:(t,r,e)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.GdprManagerBuilder=void 0;var n=e(670),o=e(777),i=e(171),u=function(){function t(){this.storage=n.GdprStorage.Cookie,this.groups=[],this.bannerWasShown=!1}return t.make=function(){return new t},t.prototype.withBannerShown=function(t){void 0===t&&(t=!0),this.bannerWasShown=t},t.prototype.startGroup=function(t,r,e,n){return void 0===t&&(t=null),void 0===r&&(r=""),void 0===e&&(e=""),void 0===n&&(n=!0),i.GdprGroupBuilder.create(this,r,e,t,n,!1)},t.prototype.startRequiredGroup=function(t,r,e){return void 0===t&&(t=null),void 0===r&&(r=""),void 0===e&&(e=""),this.startEnabledGroup(t,r,e).required()},t.prototype.startEnabledGroup=function(t,r,e){return void 0===t&&(t=null),void 0===r&&(r=""),void 0===e&&(e=""),this.startGroup(t,r,e,!0).enabled()},t.prototype.startDisabledGroup=function(t,r,e){return void 0===t&&(t=null),void 0===r&&(r=""),void 0===e&&(e=""),this.startGroup(t,r,e,!1).disabled()},t.prototype.build=function(){var t=o.GdprManager.create(this.groups);return t.bannerWasShown=this.bannerWasShown,t},t.prototype.endGroup=function(){return this},t}();r.GdprManagerBuilder=u},171:function(t,r,e){var n=this&&this.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e);var o=Object.getOwnPropertyDescriptor(r,e);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[e]}}),Object.defineProperty(t,n,o)}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),o=this&&this.__exportStar||function(t,r){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(r,e)||n(r,t,e)};Object.defineProperty(r,"__esModule",{value:!0}),o(e(890),r),o(e(237),r),o(e(860),r)},93:function(t,r,e){var n=this&&this.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e);var o=Object.getOwnPropertyDescriptor(r,e);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[e]}}),Object.defineProperty(t,n,o)}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),o=this&&this.__exportStar||function(t,r){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(r,e)||n(r,t,e)};Object.defineProperty(r,"__esModule",{value:!0}),o(e(315),r),o(e(822),r),o(e(777),r),o(e(670),r),o(e(779),r),o(e(171),r),o(e(562),r),o(e(344),r)},562:(t,r,e)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.GdprDeserializer=void 0;var n=e(777),o=e(670),i=e(822),u=e(315),a=function(){function t(){}return t.manager=function(t){var r=this;if(!["enabled","groups"].every((function(r){return r in t}))||"boolean"!=typeof t.enabled||!Array.isArray(t.groups))return null;var e=t.groups.map((function(t){return r.group(t)})).filter((function(t){return null!==t})),o=n.GdprManager.create([]);return o.enabled=!!t.enabled,o.bannerWasShown=!!t.bannerWasShown,e.length?(e.forEach((function(t){return o.addGroup(t)})),o):null},t.group=function(t){var r=this,e=this.guard(t);if(null===e)return null;var n=["guards"];if(!n.every((function(r){return r in t}))||!Array.isArray(t.guards))return null;var o=i.GdprGuardGroup.for(e.name,e.description,e.enabled,e.required),u=t.guards.map((function(t){return n.every((function(r){return r in t}))?r.group(t):r.guard(t)})).filter((function(t){return null!==t}));return u.length?(u.forEach((function(t){return o.addGuard(t)})),o):null},t.guard=function(t){return["name","enabled","required","description","storage"].every((function(r){return r in t}))&&"string"==typeof t.name&&"boolean"==typeof t.enabled&&"boolean"==typeof t.required&&"string"==typeof t.description&&"number"==typeof t.storage&&t.storage in o.GdprStorage?(0,u.makeGuard)(t.name,t.description,t.storage,!!t.required,!!t.enabled):null},t}();r.GdprDeserializer=a},344:function(t,r){var e=this&&this.__awaiter||function(t,r,e,n){return new(e||(e=Promise))((function(o,i){function u(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?o(t.value):(r=t.value,r instanceof e?r:new e((function(t){t(r)}))).then(u,a)}s((n=n.apply(t,r||[])).next())}))},n=this&&this.__generator||function(t,r){var e,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=r.call(t,u)}catch(t){i=[6,t],n=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(r,"__esModule",{value:!0}),r.GdprSaviorAdapter=void 0;var o=function(){function t(){}return t.prototype.exists=function(t){return void 0===t&&(t=!0),e(this,void 0,void 0,(function(){return n(this,(function(r){switch(r.label){case 0:return[4,this.restore(t)];case 1:return[2,null!==r.sent()]}}))}))},t.prototype.storeIfNotExists=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(r){switch(r.label){case 0:return[4,this.exists()];case 1:return[2,!!r.sent()||this.store(t)]}}))}))},t.prototype.restoreOrCreate=function(t){return e(this,void 0,void 0,(function(){var r,e;return n(this,(function(n){switch(n.label){case 0:return[4,this.restore()];case 1:return(r=n.sent())?[3,3]:[4,t()];case 2:return e=n.sent(),this.updateSharedManager(e),[2,e];case 3:return[2,r]}}))}))},t.prototype.check=function(){return e(this,void 0,void 0,(function(){var t=this;return n(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve()];case 1:return r.sent(),setTimeout((function(){t.exists(!0)}),100),[2]}}))}))},t}();r.GdprSaviorAdapter=o},779:(t,r,e)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.visitGdpr=void 0;var n=e(777),o=e(822);r.visitGdpr=function(t,e){var i=void 0===e?{}:e,u=i.onManager,a=void 0===u?function(){}:u,s=i.onGroup,d=void 0===s?function(){}:s,c=i.onGuard,p=void 0===c?function(){}:c,l=i.onEach,f=void 0===l?function(){}:l,h={onManager:a,onGroup:d,onGuard:p,onEach:f};t instanceof n.GdprManager?(a(t),f(t),t.getGroups().forEach((function(t){return(0,r.visitGdpr)(t,h)}))):t instanceof o.GdprGuardGroup?(d(t),f(t),t.getGuards().forEach((function(t){return(0,r.visitGdpr)(t,h)}))):(p(t),f(t))}}},r={};return function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n].call(i.exports,i,i.exports,e),i.exports}(93)})()})); |
import { GdprStorage } from "./GdprStorage"; | ||
interface GdprGuard { | ||
export interface GdprRawInto<RawRepr> { | ||
raw(): RawRepr | object; | ||
} | ||
export interface GdprGuardRaw { | ||
name: string; | ||
enabled: boolean; | ||
required: boolean; | ||
description: string; | ||
storage: GdprStorage; | ||
} | ||
export interface GdprGuard extends GdprRawInto<GdprGuardRaw> { | ||
readonly name: string; | ||
@@ -18,10 +28,2 @@ enabled: boolean; | ||
} | ||
interface GdprGuardRaw { | ||
name: string; | ||
enabled: boolean; | ||
required: boolean; | ||
description: string; | ||
storage: GdprStorage; | ||
} | ||
declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard; | ||
export { GdprGuard, GdprGuardRaw, makeGuard, }; | ||
export declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard; |
import { GdprGuard } from "./GdprGuard"; | ||
interface GdprGuardCollection extends GdprGuard { | ||
export interface GdprGuardCollection extends GdprGuard { | ||
hasGuard(name: string): boolean; | ||
getGuard(name: string): GdprGuard | null; | ||
} | ||
export { GdprGuardCollection, }; |
@@ -1,8 +0,8 @@ | ||
import { GdprGuard, GdprGuardRaw } from "./GdprGuard"; | ||
import { GdprGuard, GdprGuardRaw, GdprRawInto } from "./GdprGuard"; | ||
import { GdprStorage } from "./GdprStorage"; | ||
import { GdprGuardCollection } from "./GdprGuardCollection"; | ||
interface GdprGuardGroupRaw extends GdprGuardRaw { | ||
export interface GdprGuardGroupRaw extends GdprGuardRaw { | ||
guards: GdprGuardRaw[]; | ||
} | ||
declare class GdprGuardGroup implements GdprGuardCollection { | ||
export declare class GdprGuardGroup implements GdprGuardCollection, GdprRawInto<GdprGuardGroupRaw> { | ||
name: string; | ||
@@ -12,4 +12,4 @@ description: string; | ||
required: boolean; | ||
readonly storage: GdprStorage; | ||
protected bindings: Map<string, GdprGuard>; | ||
readonly storage: GdprStorage; | ||
constructor(name: string, description?: string, enabled?: boolean, required?: boolean); | ||
@@ -20,3 +20,2 @@ static for(name: string, description?: string, enabled?: boolean, required?: boolean): GdprGuardGroup; | ||
getGuard(name: string): GdprGuard | null; | ||
protected doForEachGuard(cb: (guard: GdprGuard) => any): GdprGuardGroup; | ||
isEnabled(name: string): boolean; | ||
@@ -31,3 +30,4 @@ enable(): GdprGuardGroup; | ||
raw(): GdprGuardGroupRaw; | ||
protected doForEachGuard(cb: (guard: GdprGuard) => any): GdprGuardGroup; | ||
getGuards(): GdprGuard[]; | ||
} | ||
export { GdprGuardGroup, GdprGuardGroupRaw, }; |
@@ -1,14 +0,18 @@ | ||
import { GdprGuard } from "./GdprGuard"; | ||
import { GdprGuard, GdprRawInto } from "./GdprGuard"; | ||
import { GdprGuardGroup, GdprGuardGroupRaw } from "./GdprGuardGroup"; | ||
import { GdprGuardCollection } from "./GdprGuardCollection"; | ||
import { GdprStorage } from "./GdprStorage"; | ||
interface GdprManagerRaw { | ||
import { GdprManagerEventHub } from "./GdprManagerEventHub"; | ||
export interface GdprManagerRaw { | ||
bannerWasShown: boolean; | ||
enabled: boolean; | ||
groups: GdprGuardGroupRaw[]; | ||
} | ||
declare class GdprManager implements GdprGuardCollection { | ||
export declare class GdprManager implements GdprGuardCollection, GdprRawInto<GdprManagerRaw> { | ||
bannerWasShown: boolean; | ||
enabled: boolean; | ||
events: GdprManagerEventHub; | ||
protected groups: Map<string, GdprGuardGroup>; | ||
readonly name: string; | ||
readonly description: string; | ||
enabled: boolean; | ||
readonly storage: GdprStorage; | ||
@@ -18,6 +22,6 @@ required: boolean; | ||
static create(groups?: GdprGuardGroup[]): GdprManager; | ||
closeBanner(): void; | ||
resetAndShowBanner(): void; | ||
createGroup(name: string, description?: string): GdprManager; | ||
addGroup(category: GdprGuardGroup): GdprManager; | ||
protected reduceGroupsPred(pred: (group: GdprGuardCollection) => boolean): boolean; | ||
protected forEachGroup(cb: (group: GdprGuardCollection) => any): GdprManager; | ||
hasGuard(name: string): boolean; | ||
@@ -36,3 +40,5 @@ getGuard(name: string): GdprGuard | null; | ||
raw(): GdprManagerRaw; | ||
protected reduceGroupsPred(pred: (group: GdprGuardCollection) => boolean): boolean; | ||
protected forEachGroup(cb: (group: GdprGuardCollection) => any): GdprManager; | ||
getGroups(): GdprGuardGroup[]; | ||
} | ||
export { GdprManager, GdprManagerRaw, }; |
@@ -1,2 +0,2 @@ | ||
import { GdprManagerRaw, GdprManager } from "../GdprManager"; | ||
import { GdprManager, GdprManagerRaw } from "../GdprManager"; | ||
declare type GdprManagerFactory = () => Promise<GdprManager>; | ||
@@ -3,0 +3,0 @@ interface GdprSavior { |
{ | ||
"name": "gdpr-guard", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"author": "Voltra <ludwig.guerin.98@gmx.fr>", | ||
@@ -21,3 +21,6 @@ "homepage": "https://github.com/Voltra/gdpr-guard#readme", | ||
"clean": "rm -rf dist", | ||
"docs": "([[ -d ./docs ]] && rm -rf ./docs); typedoc --options typedoc.config.js" | ||
"predocs": "[[ -d ./docs ]] && rm -rf ./docs", | ||
"docs": "typedoc --options typedoc.config.js", | ||
"predeploy:docs": "npm run docs", | ||
"deploy:docs": "gh-pages -d docs" | ||
}, | ||
@@ -29,2 +32,3 @@ "license": "MIT", | ||
"eledoc": "^0.2.1", | ||
"gh-pages": "^3.2.3", | ||
"ts-loader": "^9.2.6", | ||
@@ -31,0 +35,0 @@ "ts-node": "^10.4.0", |
202
README.md
# gdpr-guard | ||
> Simple GDPR manager | ||
@@ -8,19 +9,23 @@ | ||
If you need any help, you're more than welcome on my [official Discord server](https://discordapp.com/invite/JtWAjbw) dedicated to my open-source projects. | ||
If you need any help, you're more than welcome on my [official Discord server](https://discordapp.com/invite/JtWAjbw) | ||
dedicated to my open-source projects. | ||
## How to import | ||
Using ES6-style imports: | ||
```javascript | ||
import { | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//helpers | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
//helpers | ||
makeGuard, | ||
visitGdpr, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
} from "gdpr-guard" | ||
@@ -30,15 +35,17 @@ ``` | ||
Using node style require: | ||
```javascript | ||
const { | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//helpers | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
//helpers | ||
makeGuard, | ||
visitGdpr, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
} = require("gdpr-guard"); | ||
@@ -48,15 +55,17 @@ ``` | ||
Directly from your browser: | ||
```javascript | ||
const { | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//most useful | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
GdprDeserializer, | ||
//helpers | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
//helpers | ||
makeGuard, | ||
visitGdpr, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprSerializer, | ||
GdprSaviorAdapter, | ||
} = gdprGuard; | ||
@@ -66,2 +75,3 @@ ``` | ||
## What are the essential design choices to keep in mind | ||
The `name` used for guards and groups ***must*** be unique! This is the identifier/key that binds it. | ||
@@ -76,2 +86,3 @@ | ||
### GdprStorage | ||
This is an enum-like type that lists the available storage options, these include: | ||
@@ -89,24 +100,29 @@ | ||
### GdprManagerBuilder | ||
`GdprManagerBuilder` provides a nice and easy to write/read way to create a `GdprManager` object from the groun up. | ||
For instance you can use it like this: | ||
```javascript | ||
const manager = GdprManagerBuilder.make() | ||
.startRequiredGroup(GdprStorage.Cookie, "Functionalities", "Information purely used for the user's experience") | ||
// This is a group that by default uses cookies for storage, every option and the group itself is required | ||
.withEnabledGuard("PHP_SESSID", "Server session identifier") | ||
.startGuard() | ||
.withName("theme") | ||
.withDescription("User's current colors' theme") | ||
.storedIn(GdprStorage.LocalStorage) | ||
.endGuard() | ||
.endGroup() | ||
.startGroup(GdprStorage.Cookie, "Advertisement", "Tracking-based avertisement informations") | ||
.startGroup(GdprStorage.Cookie, "Advertisement : Local", "Sitewide advertisement informations") | ||
// [...] | ||
.endGroup() | ||
.startGroup(GdprStorage.Cookie, "Advertisement : 3rd-party", "3rd-party advertisement informations") | ||
// [...] | ||
.endGroup() | ||
.build(); | ||
const manager = GdprManagerBuilder | ||
.make() | ||
.withBannerShown(!!localStorage.getItem("gdpr_banner")) | ||
.startRequiredGroup(GdprStorage.Cookie, "Functionalities", "Information purely used for the user's experience") | ||
// This is a group that by default uses cookies for storage, every option and the group itself is required | ||
.withEnabledGuard("PHP_SESSID", "Server session identifier") | ||
.startGuard() | ||
.withName("theme") | ||
.withDescription("User's current colors' theme") | ||
.storedIn(GdprStorage.LocalStorage) | ||
.endGuard() | ||
.endGroup() | ||
.startGroup(GdprStorage.Cookie, "Advertisement", "Tracking-based avertisement informations") | ||
.startGroup(GdprStorage.Cookie, "Advertisement : Local", "Sitewide advertisement informations") | ||
// [...] | ||
.endGroup() | ||
.startGroup(GdprStorage.Cookie, "Advertisement : 3rd-party", "3rd-party advertisement informations") | ||
// [...] | ||
.endGroup() | ||
.endGroup() | ||
.build(); | ||
@@ -116,4 +132,2 @@ console.log(manager.raw()); // inspect useful information | ||
### GdprDeserializer | ||
@@ -130,3 +144,3 @@ | ||
// [...] | ||
.build(); | ||
.build(); | ||
@@ -138,5 +152,5 @@ const raw = manager.raw(); | ||
const manager = GdprDeserializer.manager(raw); | ||
if(manager === null){ //failed deserialization | ||
//handle error | ||
return; | ||
if (manager === null) { //failed deserialization | ||
//handle error | ||
return; | ||
} | ||
@@ -147,4 +161,2 @@ | ||
### GdprManager | ||
@@ -168,7 +180,6 @@ | ||
### GdprGuardGroup | ||
A `GdprGuardGroup` manages a list of `GdprGuard` (which includes raw guards, `GdprGuardGroup` and `GdprManager` although one would not recommend to put managers inside managers). | ||
A `GdprGuardGroup` manages a list of `GdprGuard` (which includes raw guards, `GdprGuardGroup` and `GdprManager` although | ||
one would not recommend to put managers inside managers). | ||
@@ -202,5 +213,7 @@ You can: | ||
```typescript | ||
abstract class GdprSaviorAdapter implements GdprSavior{ | ||
public abstract restore(shouldUpdate?: boolean): Promise<GdprManager|null>; | ||
abstract class GdprSaviorAdapter implements GdprSavior { | ||
public abstract restore(shouldUpdate?: boolean): Promise<GdprManager | null>; | ||
public abstract store(manager: GdprManagerRaw): Promise<boolean>; | ||
public abstract updateSharedManager(manager: GdprManager): Promise<void>; | ||
@@ -210,9 +223,6 @@ } | ||
## Savior API | ||
This API helps saving and restoring the manager state. It is exposed mainly for library authors as it helps creating various bindings for frameworks. | ||
This API helps saving and restoring the manager state. It is exposed mainly for library authors as it helps creating | ||
various bindings for frameworks. | ||
@@ -222,11 +232,65 @@ This is the interface: | ||
```typescript | ||
interface GdprSavior{ | ||
restore(shouldUpdate?: boolean): Promise<GdprManager|null>; | ||
interface GdprSavior { | ||
restore(shouldUpdate?: boolean): Promise<GdprManager | null>; | ||
exists(shouldUpdate?: boolean): Promise<boolean>; | ||
restoreOrCreate(factory: GdprManagerFactory): Promise<GdprManager>; | ||
store(manager: GdprManagerRaw): Promise<boolean>; | ||
storeIfNotExists(manager: GdprManagerRaw): Promise<boolean>; | ||
updateSharedManager(manager: GdprManager): Promise<void>; | ||
check(): Promise<void>; | ||
} | ||
``` | ||
## Events API | ||
This API helps reacting to the user confirming their choices from a GDPR banner. | ||
```typescript | ||
type GdprManagerEventHandler = () => void; | ||
interface GdprManagerEventHub { | ||
onEnable(guardName: string, callback: GdprManagerEventHandler): this; | ||
onDisable(guardName: string, callback: GdprManagerEventHandler): this; | ||
enable(guardName: string): this; | ||
disable(guardName: string): this; | ||
} | ||
interface GdprManager { | ||
bannerWasShown: boolean; | ||
events: GdprManagerEventHub; | ||
resetAndShowBanner(): void; | ||
closeBanner(); | ||
} | ||
``` | ||
The goal is to call `Manager#closeBanner` when the user confirm their choices from the banner, which in turn will | ||
trigger the appropriate events (so you can load scripts dynamically for instance). | ||
## Visitor API | ||
This API allows you to visit your manager's entire guard tree easily. | ||
```typescript | ||
interface GdprVisitor { | ||
onManager(manager: GdprManager): void; | ||
onGroup(group: GdprGuardGroup): void; | ||
onGuard(guard: GdprGuard): void; | ||
onEach(guard: GdprGuard): void; | ||
} | ||
declare function visitGdpr(guard: GdprGuard, visitor?: Partial<GdprVisitor>); | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4063346
25
251
283
11
1