Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] API to clear webview-managed data #6567

Closed
prestomation opened this issue Mar 26, 2023 · 10 comments · Fixed by #11066
Closed

[feat] API to clear webview-managed data #6567

prestomation opened this issue Mar 26, 2023 · 10 comments · Fixed by #11066
Labels
status: backlog Issue is ready and we can work on it type: feature request

Comments

@prestomation
Copy link

Describe the problem

My application uses cookies/localStorage on the javascript side for various purposes.

I don't see a clear way to clear all the stuff stored by the Webview engine. I could have the javascript side clear these, but there are things that this side can't clear like disk cache, etc

Describe the solution you'd like

I want to put a native button like 'Logout' that clears all this data.

An API on app/app_handle that clears this data might make sense. Maybe it needs to be part of exit or relaunch?

Alternatives considered

I considered manually deleting some of the path_resolver() directories, but directories like /Users/pttamkin/Library/HTTPStorage/{pkg} and /Users/pttamkin/Library/WebKit/{pkg} aren't captured here. Also not sure I can delete these while my app is running?

Additional context

No response

@fortitudepub
Copy link

I have this requirement too, for example user may want to switch to user another user to login to my app, and the authentication is done by using webview and authenticated data is stored in the cookie.

It seems we can do this by remove some data in app dir?

@FabianLars
Copy link
Member

It seems we can do this by remove some data in app dir?

Yeah you could, but at least on Windows this should only reliable work when there is no webview open, as far as i know at least.

Anyway, in contrast to last time we talked about this API all webviews should now have built-in ways to clear the data so it should be possible now for us to implement this :)

@fortitudepub
Copy link

It seems we can do this by remove some data in app dir?

Yeah you could, but at least on Windows this should only reliable work when there is no webview open, as far as i know at least.

Anyway, in contrast to last time we talked about this API all webviews should now have built-in ways to clear the data so it should be possible now for us to implement this :)

Glad to hear that, it seems the javascript context can't be accessed directly from the tauri WebviewWindow object, if the API is not implemented now, do you know there is some way we can inject a tiny javascript to the webview to do that ? can initialization_script achieve that?

I do not know much above web programming, if there is an API to be released, I can delay a feature depend on this and implement when the API is released, thanks a lot.

@FabianLars
Copy link
Member

Glad to hear that, it seems the javascript context can't be accessed directly from the tauri WebviewWindow object, if the API is not implemented now, do you know there is some way we can inject a tiny javascript to the webview to do that ? can initialization_script achieve that?

The API we're talking about here would need to be implemented in Rust (via the webview bindings) so we could add an api for it on the WebviewWindow object too (unless there are security concerns i don't have in mind right now)

@amrbashir
Copy link
Member

/upstream tauri-apps/wry

@tauri-apps tauri-apps bot added the status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes label Mar 28, 2023
@j67Sv89n
Copy link

j67Sv89n commented Apr 1, 2023

Most likely you need to find the paths or folders where the files are stored, check different options for deleting them,
manually or by code, delete them in parts, etc.

Option 1: Deleting cache path, C:\Users\<username>\AppData\Roaming\<appname>\Cache, directly:
Option 2: which also clears the same C:\Users\<username>\AppData\Roaming\<appname>\Cache directory

You can also use native Rust code, which has access to the file system and deletes files and folders.
Based on the general description, mostly problems arise because You reference or use the cache while the program is running.

@tauri-apps
Copy link

tauri-apps bot commented Apr 18, 2023

Upstream issue at tauri-apps/wry#914 has been closed.

@tauri-apps tauri-apps bot added status: backlog Issue is ready and we can work on it and removed status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes labels Apr 18, 2023
@datner
Copy link

datner commented Aug 28, 2024

any updates on this?

@imfunniee
Copy link

hello??

@FabianLars
Copy link
Member

Hi 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backlog Issue is ready and we can work on it type: feature request
Projects
Status: 📬Proposal
Development

Successfully merging a pull request may close this issue.

7 participants