Skip to content

Repository files navigation

Permanent Storage

An implementation based on browser storage event to persist items in local storage and session storage against clear action.

Chrome Firefox IE Opera Safari
1 ✔ 45 ✔ ? 15 ✔ (min version support?) ✔

For more details, visit mdn.

Installation

npm i permanent-storage

Example

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();

image for localStorage

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.

About

An implementation based on browser storage event to persist items in local storage and session storage against clear event.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages