Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gdpr-guard

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gdpr-guard - npm Package Compare versions

Comparing version 1.2.3 to 1.3.0

dist/serde/GdprSavior.d.ts

1

dist/gdpr_guard.d.ts

@@ -7,1 +7,2 @@ export { makeGuard } from "./GdprGuard";

export { GdprDeserializer } from "./serde/GdprDeserializer";
export { GdprSaviorAdapter } from "./serde/GdprSavior";

2

dist/gdpr_guard.js

@@ -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()}(window,(function(){return function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=7)}([function(r,t,e){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!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"}(n||(n={})),t.GdprStorage=n},function(r,t,e){"use strict";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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(o(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var u=e(0),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,d=o(u.value,2);d[0];if((a=d[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(this.bindings).map((function(r){var t=o(r,2);t[0];return t[1].raw()})),r},r}();t.GdprGuardGroup=a},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0);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))}}}},function(r,t,e){"use strict";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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(o(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var u=e(1),a=e(0),d=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);a[0];if(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),d=(a[0],a[1]);if(d.hasGuard(r))return d.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),d=a[0],s=a[1];if(d===r)return s}}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(this.groups).map((function(r){var t=o(r,2);t[0];return t[1].raw()})),r},r}();t.GdprManager=d},function(r,t,e){"use strict";function n(r){for(var e in r)t.hasOwnProperty(e)||(t[e]=r[e])}Object.defineProperty(t,"__esModule",{value:!0}),n(e(5)),n(e(6)),n(e(8))},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0),o=e(2),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=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},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0),o=e(3),i=e(4),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},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(2);t.makeGuard=n.makeGuard;var o=e(1);t.GdprGuardGroup=o.GdprGuardGroup;var i=e(3);t.GdprManager=i.GdprManager;var u=e(0);t.GdprStorage=u.GdprStorage;var a=e(4);t.GdprManagerBuilder=a.GdprManagerBuilder;var d=e(9);t.GdprDeserializer=d.GdprDeserializer},function(r,t,e){"use strict";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)t.hasOwnProperty(e)&&(r[e]=t[e])})(r,t)},function(r,t){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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(i(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var a=e(0),d=e(6),s=e(1),p=e(5),l=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=s.GdprGuardGroup.for(this.name,this.description,r,this.require);return u(this.guards,this.groups).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),p.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}(d.GdprManagerBuilder);t.GdprGroupBuilder=l},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(3),o=e(0),i=e(1),u=e(2),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?u.makeGuard(r.name,r.description,r.storage,!!r.required,!!r.enabled):null},r}();t.GdprDeserializer=a}])}));
!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()}(window,(function(){return function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=7)}([function(r,t,e){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!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"}(n||(n={})),t.GdprStorage=n},function(r,t,e){"use strict";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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(o(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var u=e(0),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);s[0];if((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(this.bindings).map((function(r){var t=o(r,2);t[0];return t[1].raw()})),r},r}();t.GdprGuardGroup=a},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0);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))}}}},function(r,t,e){"use strict";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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(o(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var u=e(1),a=e(0),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);a[0];if(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(this.groups).map((function(r){var t=o(r,2);t[0];return t[1].raw()})),r},r}();t.GdprManager=s},function(r,t,e){"use strict";function n(r){for(var e in r)t.hasOwnProperty(e)||(t[e]=r[e])}Object.defineProperty(t,"__esModule",{value:!0}),n(e(5)),n(e(6)),n(e(8))},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0),o=e(2),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=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},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(0),o=e(3),i=e(4),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},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(2);t.makeGuard=n.makeGuard;var o=e(1);t.GdprGuardGroup=o.GdprGuardGroup;var i=e(3);t.GdprManager=i.GdprManager;var u=e(0);t.GdprStorage=u.GdprStorage;var a=e(4);t.GdprManagerBuilder=a.GdprManagerBuilder;var s=e(9);t.GdprDeserializer=s.GdprDeserializer;var d=e(10);t.GdprSaviorAdapter=d.GdprSaviorAdapter},function(r,t,e){"use strict";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)t.hasOwnProperty(e)&&(r[e]=t[e])})(r,t)},function(r,t){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.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(i(arguments[t]));return r};Object.defineProperty(t,"__esModule",{value:!0});var a=e(0),s=e(6),d=e(1),c=e(5),l=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(this.guards,this.groups).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),c.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=l},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(3),o=e(0),i=e(1),u=e(2),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?u.makeGuard(r.name,r.description,r.storage,!!r.required,!!r.enabled):null},r}();t.GdprDeserializer=a},function(r,t,e){"use strict";var n=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())}))},o=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});var i=function(){function r(){}return r.prototype.exists=function(r){return void 0===r&&(r=!0),n(this,void 0,void 0,(function(){return o(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 n(this,void 0,void 0,(function(){return o(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 n(this,void 0,void 0,(function(){var t,e;return o(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 n(this,void 0,void 0,(function(){var r=this;return o(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=i}])}));
{
"name": "gdpr-guard",
"version": "1.2.3",
"version": "1.3.0",
"author": "Voltra <ludwig.guerin.98@gmx.fr>",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/Voltra/gdpr-guard#readme",

# gdpr-guard
> Simple GDPR manager
<center><img src="https://github.com/Voltra/gdpr-guard/raw/master/gdpr-guard.png" alt="Logo" width="250px"/></center>
This library helps you build a GPDR compliant system by providing you easy to manipulate interfaces.

@@ -22,2 +24,3 @@

GdprSerializer,
GdprSaviorAdapter,
} from "gdpr-guard"

@@ -39,2 +42,3 @@ ```

GdprSerializer,
GdprSaviorAdapter,
} = require("gdpr-guard");

@@ -56,2 +60,3 @@ ```

GdprSerializer,
GdprSaviorAdapter,
} = gdprGuard;

@@ -182,2 +187,40 @@ ```

declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard;
```
```
<<<<<<< HEAD
### GdprSaviorAdapter
A class that implements most of the behavior for the Savior API.
```typescript
abstract class GdprSaviorAdapter implements GdprSavior{
public abstract restore(shouldUpdate?: boolean): Promise<GdprManager|null>;
public abstract store(manager: GdprManager): Promise<boolean>;
public abstract updateSharedManager(manager: GdprManager): Promise<void>;
}
```
## 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 is the interface:
```typescript
interface GdprSavior{
restore(shouldUpdate?: boolean): Promise<GdprManager|null>;
exists(shouldUpdate?: boolean): Promise<boolean>;
restoreOrCreate(factory: GdprManagerFactory): Promise<GdprManager>;
store(manager: GdprManager): Promise<boolean>;
storeIfNotExists(manager: GdprManager): Promise<boolean>;
updateSharedManager(manager: GdprManager): Promise<void>;
check(): Promise<void>;
}
```
=======
>>>>>>> 6fe41a4d027101058825697f27c26b44bfab5ea7
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc