gdpr-guard
Advanced tools
Comparing version 0.1.1 to 1.0.0
@@ -10,6 +10,8 @@ import { GdprStorage } from "../GdprStorage"; | ||
protected enable: boolean; | ||
protected require: boolean; | ||
guards: GdprGuard[]; | ||
protected constructor(parent: GdprManagerBuilder, name: string, description: string, storage: GdprStorage, enable: boolean); | ||
protected constructor(parent: GdprManagerBuilder, name: string, description: string, storage: GdprStorage, enable: boolean, require: boolean); | ||
startGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; | ||
static create(mb: GdprManagerBuilder, name: string, description?: string, storage?: GdprStorage | null, enabled?: boolean): 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; | ||
@@ -22,3 +24,5 @@ protected edit(cb: (builder: GdprGroupBuilder) => any): GdprGroupBuilder; | ||
disabled(): GdprGroupBuilder; | ||
startGuard(storage: GdprStorage | null): GdprGuardBuilder; | ||
required(): GdprGroupBuilder; | ||
startGuard(storage?: GdprStorage | null): GdprGuardBuilder; | ||
startRequiredGuard(storage: GdprStorage | null): GdprGuardBuilder; | ||
withEnabledGuard(name: string, description?: string, storage?: GdprStorage | null): GdprGroupBuilder; | ||
@@ -25,0 +29,0 @@ withDisabledGuard(name: string, description?: string, storage?: GdprStorage | null): GdprGroupBuilder; |
@@ -7,6 +7,7 @@ import { GdprGroupBuilder } from "./builders"; | ||
protected enable: boolean; | ||
protected require: boolean; | ||
protected name: string; | ||
protected description: string; | ||
protected constructor(parent: GdprGroupBuilder, storage: GdprStorage, enable: boolean); | ||
static create(gb: GdprGroupBuilder, storage?: GdprStorage, enabled?: boolean): GdprGuardBuilder; | ||
protected constructor(parent: GdprGroupBuilder, storage: GdprStorage, enable: boolean, require: boolean); | ||
static create(gb: GdprGroupBuilder, storage?: GdprStorage, enabled?: boolean, required?: boolean): GdprGuardBuilder; | ||
endGuard(): GdprGroupBuilder; | ||
@@ -19,3 +20,4 @@ protected edit(edit: (builder: GdprGuardBuilder) => any): GdprGuardBuilder; | ||
storedIn(storage: GdprStorage): GdprGuardBuilder; | ||
required(): GdprGuardBuilder; | ||
} | ||
export { GdprGuardBuilder, }; |
@@ -10,2 +10,3 @@ import { GdprGuardGroup } from "../GdprGuardGroup"; | ||
startGroup(storage?: GdprStorage | null, name?: string, description?: string, enabled?: boolean): GdprGroupBuilder; | ||
startRequiredGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; | ||
startEnabledGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; | ||
@@ -12,0 +13,0 @@ startDisabledGroup(storage?: GdprStorage | null, name?: string, description?: string): GdprGroupBuilder; |
@@ -6,3 +6,2 @@ import { makeGuard } from "./GdprGuard"; | ||
import { GdprManagerBuilder } from "./builders/builders"; | ||
declare const REQUIRED_GROUP: string, REQUIRED_GROUP_DESC: string; | ||
export { makeGuard, GdprGuardGroup, GdprManager, GdprStorage, GdprManagerBuilder, REQUIRED_GROUP, REQUIRED_GROUP_DESC, }; | ||
export { makeGuard, GdprGuardGroup, GdprManager, GdprStorage, GdprManagerBuilder, }; |
@@ -7,2 +7,3 @@ import { GdprStorage } from "./GdprStorage"; | ||
readonly storage: GdprStorage; | ||
required: boolean; | ||
isEnabled(name: string): boolean; | ||
@@ -12,2 +13,3 @@ enable(): GdprGuard; | ||
toggle(): GdprGuard; | ||
makeRequired(): GdprGuard; | ||
enableForStorage(type: GdprStorage): GdprGuard; | ||
@@ -21,6 +23,7 @@ disableForStorage(type: GdprStorage): GdprGuard; | ||
enabled: boolean; | ||
required: boolean; | ||
description: string; | ||
storage: GdprStorage; | ||
} | ||
declare function makeGuard(name: string, description: string, storage?: GdprStorage, enabled?: boolean): GdprGuard; | ||
declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard; | ||
export { GdprGuard, GdprGuardRaw, makeGuard, }; |
@@ -11,6 +11,7 @@ import { GdprGuard, GdprGuardRaw } from "./GdprGuard"; | ||
enabled: boolean; | ||
required: boolean; | ||
protected bindings: Map<string, GdprGuard>; | ||
readonly storage: GdprStorage; | ||
constructor(name: string, description?: string, enabled?: boolean); | ||
static for(name: string, description?: string): GdprGuardGroup; | ||
constructor(name: string, description?: string, enabled?: boolean, required?: boolean); | ||
static for(name: string, description?: string, enabled?: boolean, required?: boolean): GdprGuardGroup; | ||
addGuard(guard: GdprGuard): GdprGuardGroup; | ||
@@ -24,2 +25,3 @@ hasGuard(name: string): boolean; | ||
toggle(): GdprGuardGroup; | ||
makeRequired(): GdprGuardGroup; | ||
enableForStorage(type: GdprStorage): GdprGuardGroup; | ||
@@ -26,0 +28,0 @@ disableForStorage(type: GdprStorage): GdprGuardGroup; |
@@ -10,4 +10,2 @@ import { GdprGuard } from "./GdprGuard"; | ||
declare class GdprManager implements GdprGuardCollection { | ||
static readonly REQUIRED_GROUP: string; | ||
static readonly REQUIRED_GROUP_DESC: string; | ||
protected groups: Map<string, GdprGuardGroup>; | ||
@@ -18,2 +16,3 @@ readonly name: string; | ||
readonly storage: GdprStorage; | ||
required: boolean; | ||
protected constructor(); | ||
@@ -33,2 +32,3 @@ static create(groups?: GdprGuardGroup[]): GdprManager; | ||
toggle(): GdprManager; | ||
makeRequired(): GdprManager; | ||
enableForStorage(type: GdprStorage): GdprManager; | ||
@@ -35,0 +35,0 @@ disableForStorage(type: GdprStorage): GdprManager; |
{ | ||
"name": "gdpr-guard", | ||
"version": "0.1.1", | ||
"author": "Voltra <ludwig.guerin.98@gmx.fr>", | ||
"homepage": "https://github.com/Voltra/gdpr-guard#readme", | ||
"bugs": { | ||
"url": "https://github.com/Voltra/gdpr-guard/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Voltra/gdpr-guard.git" | ||
}, | ||
"description": "Simple GDPR manager", | ||
"main": "./dist/gdpr_guard.js", | ||
"types": "./dist/gdpr_guard.d.ts", | ||
"scripts": { | ||
"dev": "webpack --mode development", | ||
"build": "webpack --mode production", | ||
"clean": "rm -rf dist" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^13.1.2", | ||
"@types/webpack": "^4.41.1", | ||
"ts-loader": "^6.2.1", | ||
"ts-node": "^8.5.4", | ||
"typescript": "^3.7.4", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10" | ||
} | ||
"name": "gdpr-guard", | ||
"version": "1.0.0", | ||
"author": "Voltra <ludwig.guerin.98@gmx.fr>", | ||
"homepage": "https://github.com/Voltra/gdpr-guard#readme", | ||
"bugs": { | ||
"url": "https://github.com/Voltra/gdpr-guard/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Voltra/gdpr-guard.git" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://npm.pkg.github.com/" | ||
}, | ||
"description": "Simple GDPR manager", | ||
"main": "./dist/gdpr_guard.js", | ||
"types": "./dist/gdpr_guard.d.ts", | ||
"scripts": { | ||
"dev": "webpack --mode development", | ||
"build": "webpack --mode production", | ||
"watch": "webpack --mode development --watch", | ||
"clean": "rm -rf dist" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^13.1.2", | ||
"@types/webpack": "^4.41.1", | ||
"ts-loader": "^6.2.1", | ||
"ts-node": "^8.5.4", | ||
"typescript": "^3.7.4", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10" | ||
} | ||
} |
133
README.md
@@ -1,4 +0,131 @@ | ||
## gdpr-guard | ||
Simple GDPR manager | ||
# gdpr-guard | ||
> Simple GDPR manager | ||
This library helps you build a GPDR compliant system by providing you easy to manipulate interfaces. | ||
***Work In Progress*** | ||
## How to import | ||
Using ES6-style imports: | ||
```javascript | ||
import { | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
} from "gdpr-guard" | ||
``` | ||
Using node style require: | ||
```javascript | ||
const { | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
} = require("gdpr-guard"); | ||
``` | ||
Directly from your browser: | ||
```javascript | ||
const { | ||
makeGuard, | ||
GdprGuardGroup, | ||
GdprManager, | ||
GdprStorage, | ||
GdprManagerBuilder, | ||
} = gdprGuard; | ||
``` | ||
## 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. | ||
The wide concept of `guard` is that a `guard` is an entity that can be toggled to allow/deny some functionalities. | ||
## What is provided? | ||
The complete JSDoc will be coming soon | ||
### GdprStorage | ||
This is an enum-like type that lists the available storage options, these include: | ||
* None | ||
* Cookie | ||
* LocalStorage | ||
* SessionStorage | ||
* IndexedDb | ||
* FileSystem | ||
* ServerStorage | ||
* All | ||
### 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(); | ||
console.log(manager.raw()); // inspect useful information | ||
``` | ||
### GdprManager | ||
A `GdprManager` manages a list of `GdprGuardGroup`. You can : | ||
* get its most useful representation (`raw()`) | ||
* add or create groups (respectively `addGroup(guardGroup)` and `createGroup(name, description)`) | ||
* determine whether or not there is a specific guard (`hasGuard(name)`) | ||
* retrieve a specific guard (`getGuard(name)`) | ||
* determine whether or not there is a specific group (`hasGroup(name)`) | ||
* get a specific group (`getGroup(name)`) | ||
* determine if a guard/group is enabled (`isEnabled(name)`) | ||
* enable everything except required (`enable()`) | ||
* disable everything except required (`disable()`) | ||
* toggle state, i.e. either enable all or disable all (`toggle()`) | ||
* enable everything for a given storage (`enableForStorage(gdprStorage)`) | ||
* disable everything for a given storage (`disableForStorage(gdprStorage)`) | ||
* toggle state for a given storage (`toggleForStorage(gdprStorage)`) | ||
### 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). | ||
You can: | ||
* mark it as required, with every of its guards (`makeRequired()`) | ||
* get its most useful representation (`raw()`) | ||
* determine whether or not there is a specific guard (`hasGuard(name)`) | ||
* retrieve a specific guard (`getGuard(name)`) | ||
* determine if a guard/group is enabled (`isEnabled(name)`) | ||
* enable everything except required (`enable()`) | ||
* disable everything except required (`disable()`) | ||
* toggle state, i.e. either enable all or disable all (`toggle()`) | ||
* enable everything for a given storage (`enableForStorage(gdprStorage)`) | ||
* disable everything for a given storage (`disableForStorage(gdprStorage)`) | ||
* toggle state for a given storage (`toggleForStorage(gdprStorage)`) | ||
### makeGuard | ||
`makeGuard` is a function that creates the simplest guard possible, it has the following signature: | ||
```typescript | ||
declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard; | ||
``` |
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
131
28952
14
184
1