pinia-plugin-persistedstate
                                
                                 pinia-plugin-persistedstate copied to clipboard
                                
                                    pinia-plugin-persistedstate copied to clipboard
                            
                            
                            
                        🔥 hydrate store using paths
Description
Currently the plugin will restore the entire contents of localStorage or sessionStorage back into the Vue store, regardless of which paths are whitelisted by the paths array. This can result in stale data from a user being put back into the store which should no longer be persisted (i.e in the past the field was included in the paths array but has since been removed) or potentially allows a bad actor to inject their own data into the Vue store (granted this is slightly contrived but could be an issue for some applications).
Linked Issues
#268
Additional context
This has been tested (via Jest) and also locally in my own app. Unsure if we want this to be turned on/off via a config option?
I would see this as a breaking change because it changes the rehydration behaviour, but i totally see it as a feature/something needed. Maybe keep it being a flag as opt-in to not break the current behaviour, it could eventually become thedefault behaviour on upcoming major version
I would see this as a breaking change because it changes the rehydration behaviour, but i totally see it as a feature/something needed. Maybe keep it being a flag as opt-in to not break the current behaviour, it could eventually become thedefault behaviour on upcoming major version
That's completely fair, appreciate the feedback @prazdevs - I'll update the PR to include an opt-in flag
Hey @prazdevs apologies for the delay in getting around to this - I've updated the PR with a new pathHydration opt-in flag