3
votes

Correct me if I'm wrong but I feel like every single article about service workers I have read, covers only one use-case: very simple, "static" website. Like "Here, you can cache your images using SW and now your app can work offline. The end.".

Well... I have an existing app, let's say it's a "TODO-list": user logs in and can view/modify the list. Server communication is based on POST requests (JSON).

Now, I want to make it work offline: user should be able to still view the list (this time from cache). Its pretty easy to cache POST requests using IndexedDB but how do it securely? Lists can contain sensitive data and if not encrypted, everyone could just open DevTools and browse them.

Any tips, ideas? I need at least some level of security. My first -not a bright- idea was to encrypt the cached data using user's credentials but that wouldn't work: credentials are known only when loggin in and are lost after page refresh.

1

1 Answers

0
votes

How about encrypting cached data with session id (from cookie)? If user logs out or if session (cookie) expire - cookie is deleted and the decryption key is lost.

However, according to this comment:

Yeah, some firefox versions seem to conserve expired cookies forever. I just deleted some cookies from my Firefox which expired in April 2012. (There were newer cookies with same domain and name, though.)

I know, the comment is old (2013) but still a bit worrying