permanent-storage
v1.0.3
Published
An implementation based on browser storage event to persist items in local storage and session storage
Maintainers
Readme
Permanent Storage
An implementation based on browser storage event to persist items in local storage and session storage against clear action.
|
|
|
|
|
|
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| 1 ✔ | 45 ✔ | ? | 15 ✔ | (min version support?) ✔ |
For more details, visit mdn.
Installation
npm i permanent-storageExample
import PermanentStorage from "permanent-storage";
// default is localStorage
const trackerStorage = new PermanentStorage();
/* can be overridden by passing storage object
const trackerStorage = new PermanentStorage(window.sessionStorage);
*/
trackerStorage.setItem("a", "7823634e-0b8d-4b5d-ac59-d1bd298d6116");
trackerStorage.setItem("tracking-id", "UA298d61");
trackerStorage.getItem("tracking-id");
trackerStorage.removeItem("tracking-id");
trackerStorage.clear();
Possible Usecase
For anonymous users, if you want to curbstone to prevent spam, this could be a neat and more reliable solution than using browser fingerprint. Fingerprinting is prune to data change that generate different hashes over time. Even if fingerprinting is using canvas images; chances of collision and gradual inconsistency are high.
License
Copyright (c) 2020 - present by Rehan Umar and individual contributors. Licensed under MIT license.
