guillaumepotier / Garlic.js

Automatically persist your forms' text and select field values locally, until the form is submitted.

Home Page:http://garlicjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get and set (persist) data override

soullivaneuh opened this issue · comments

Do we have any possibility to override the data that will be persisted and retrieved?

The goal is to combine crypto-js in order to crypt the registered data like this:

CryptoJS.HmacSHA1("Data from the form", "CryptKey")

Can this be possible? How to achieve it properly?

Thanks.

Hi there,

Currently, this is not possible. But definitely doable.

Garlic Storage is a dedicated decoupled class given with a dependency injection pattern to Garlic when instantiating the jQuery function here.

You could totally implement a SecureStorage class with the same public api (get, set, has, destroy..) using internally CryptoJS.HmacSHA1 to secure the stored data, and give it to Garlic. This SecureStorage class should be in a separate file, loaded only by users wanting to use it (and not to add unnecessary weight to the regular lib).

Here still, we could use some option conditional statement to pass this specific storage in config.

WDYT?

I'd be glad to review a PR on that and merge it then.

Best

Your solution may help.

Sorry, I currently don't have time for a PR, but let keep this issue opened for now. 😉