gdpr-guard-local
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,7 +0,22 @@ | ||
import { VersionComparator, LocalStoreFactory, LocalStorageConfig } from "./types"; | ||
import { DateFactory, LocalStorageConfig, LocalStoreFactory, VersionComparator } from "./types"; | ||
export declare const versionComparator: VersionComparator; | ||
export declare const defaultStoreFactory: LocalStoreFactory; | ||
export declare const expiration: () => Date; | ||
/** | ||
* Default value for the expiration. GDPR says max duration is 13 months | ||
*/ | ||
export declare const expiration: DateFactory; | ||
/** | ||
* Parts of the default config that are most used. | ||
* Default string equality test for versions, 13 months expiration | ||
*/ | ||
export declare const defaultConfigParts: Partial<LocalStorageConfig>; | ||
/** | ||
* Full default config. | ||
* Keys are "gdpr" for the manager's state and "gdpr__version" for the version number. | ||
*/ | ||
export declare const defaultConfig: LocalStorageConfig; | ||
/** | ||
* Make a config object by overriding the {@link defaultConfig} | ||
* @param config The user-provided config | ||
*/ | ||
export declare const makeConfig: (config?: Partial<LocalStorageConfig>) => LocalStorageConfig; |
@@ -1,3 +0,3 @@ | ||
import { GdprSaviorAdapter, GdprManager, GdprManagerRaw } from "gdpr-guard"; | ||
import { LocalStore, LocalStoreFactory, LocalStorageConfig } from "./types"; | ||
import { GdprManager, GdprManagerRaw, GdprSaviorAdapter } from "gdpr-guard"; | ||
import { LocalStorageConfig, LocalStore, LocalStoreFactory } from "./types"; | ||
export declare class LocalStorageSavior extends GdprSaviorAdapter { | ||
@@ -7,5 +7,17 @@ protected config: LocalStorageConfig; | ||
constructor(config?: LocalStorageConfig, storeFactory?: LocalStoreFactory); | ||
/** | ||
* @inheritDoc | ||
* @override | ||
*/ | ||
updateSharedManager(_manager: GdprManager): Promise<void>; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
*/ | ||
restore(shouldUpdate?: boolean): Promise<GdprManager | null>; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
*/ | ||
store(manager: GdprManagerRaw): Promise<boolean>; | ||
} |
export interface LocalStore { | ||
/** | ||
* Whether the given key is present in the store | ||
* @param key | ||
*/ | ||
has(key: string): Promise<boolean>; | ||
/** | ||
* Set a value into the store (must be JSON stringifiable) | ||
* @param key | ||
* @param value | ||
* @param expiration - The date upon which the value will be expired (and needs to be remove from the store) | ||
*/ | ||
set(key: string, value: any, expiration: Date): Promise<void>; | ||
/** | ||
* Remove the given value from the store | ||
* @param key The key to the value to remove | ||
*/ | ||
remove(key: string): Promise<void>; | ||
/** | ||
* Get the given value from the store | ||
* @param key The key to the value to retrieve | ||
*/ | ||
get(key: string): Promise<any>; | ||
@@ -9,11 +27,31 @@ removeExpiredKeys(): Promise<void>; | ||
export declare type Version = string | number; | ||
/** | ||
* A function that compares two versions. It returns TRUE if the {@link newVersion} is greater | ||
* than the {@link oldVersion} | ||
*/ | ||
export declare type VersionComparator = (oldVersion: Version, newVersion: Version) => boolean; | ||
export declare type DateFactory = () => Date; | ||
export interface LocalStorageConfig { | ||
/** | ||
* The key used to store the manager's state | ||
*/ | ||
storeKey: string; | ||
/** | ||
* The key used to store the version number | ||
*/ | ||
versionKey: string; | ||
/** | ||
* The current version number | ||
*/ | ||
version: Version; | ||
/** | ||
* The function used to compare two version numbers. | ||
* Returns true if the new version is greater than the old version | ||
*/ | ||
comparator: VersionComparator; | ||
/** | ||
* A factory for the expiration date to remove the store's state | ||
*/ | ||
expiration: DateFactory; | ||
} | ||
export declare type LocalStoreFactory = () => LocalStore; |
{ | ||
"name": "gdpr-guard-local", | ||
"version": "1.0.0", | ||
"description": "A simple local storage adapter for gdpr-guard", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"dev": "webpack --mode development", | ||
"build": "webpack --mode production", | ||
"watch": "webpack --mode development --watch", | ||
"clean": "rm -rf dist", | ||
"docs": "([[ -d ./docs ]] && rm -rf ./docs); typedoc --options typedoc.config.js --out docs src" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Voltra/gdpr-guard-local.git" | ||
}, | ||
"author": "Voltra <ludwig.guerin.98@gmx.fr>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Voltra/gdpr-guard-local/issues" | ||
}, | ||
"homepage": "https://github.com/Voltra/gdpr-guard-local#readme", | ||
"dependencies": { | ||
"gdpr-guard": "^2.1.0", | ||
"moment": "^2.27.0", | ||
"store": "^2.0.12" | ||
}, | ||
"devDependencies": { | ||
"eledoc": "^0.2.1", | ||
"ts-loader": "^7.0.5", | ||
"typedoc": "^0.17.7", | ||
"typedoc-plugin-as-member-of": "^1.0.2", | ||
"typescript": "^3.9.5", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12" | ||
} | ||
"name": "gdpr-guard-local", | ||
"version": "1.1.0", | ||
"description": "A simple local storage adapter for gdpr-guard", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"dev": "webpack --mode development", | ||
"build": "webpack --mode production", | ||
"watch": "webpack --mode development --watch", | ||
"clean": "rm -rf dist", | ||
"predocs": "([[ -d ./docs ]] && rm -rf ./docs) || true", | ||
"docs": "typedoc --options typedoc.config.js --out docs src", | ||
"predeploy:docs": "npm run docs", | ||
"deploy:docs": "gh-pages -d docs" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Voltra/gdpr-guard-local.git" | ||
}, | ||
"author": "Voltra <ludwig.guerin.98@gmx.fr>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Voltra/gdpr-guard-local/issues" | ||
}, | ||
"homepage": "https://github.com/Voltra/gdpr-guard-local#readme", | ||
"dependencies": { | ||
"date-fns": "^2.28.0", | ||
"gdpr-guard": "^2.2.1", | ||
"store": "^2.0.12" | ||
}, | ||
"devDependencies": { | ||
"eledoc": "^0.2.1", | ||
"gh-pages": "^3.2.3", | ||
"ts-loader": "^7.0.5", | ||
"typedoc": "^0.17.7", | ||
"typedoc-plugin-as-member-of": "^1.0.2", | ||
"typescript": "4.6", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12" | ||
} | ||
} |
@@ -25,2 +25,10 @@ # gdpr-guard-local | ||
} from "gdpr-guard-local" | ||
// In your browser | ||
const { | ||
// everything from gdpr-guard | ||
defaults, | ||
LocalStorageSavior, | ||
} = gdprGuardLocal; | ||
``` | ||
@@ -27,0 +35,0 @@ |
@@ -0,0 +0,0 @@ module.exports = { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14
97
175713
8
268
+ Addeddate-fns@^2.28.0
+ Added@babel/runtime@7.26.9(transitive)
+ Addeddate-fns@2.30.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedmoment@^2.27.0
- Removedmoment@2.30.1(transitive)
Updatedgdpr-guard@^2.2.1