89 lines
3.1 KiB
C
89 lines
3.1 KiB
C
/*
|
|
* web_context.h — per-user WebKitWebContext construction/teardown
|
|
*
|
|
* Phase A of plans/webkit-data-isolation.md. Each Nostr identity gets
|
|
* its own WebKitWebContext backed by a per-user WebKitWebsiteDataManager
|
|
* rooted at ~/.sovereign_browser/profiles/<pubkey>/webkit/. This gives
|
|
* true isolation: cookies, cache, localStorage, IndexedDB, service
|
|
* workers, and favicons persist per-user and never cross-contaminate.
|
|
*
|
|
* WebKitGTK binds a WebKitWebsiteDataManager to a WebKitWebContext for
|
|
* the context's lifetime, so per-user isolation requires building a
|
|
* fresh context per login and tearing it down on logout/switch.
|
|
*
|
|
* The current context pointer is held in this module so the rest of the
|
|
* codebase can fetch it via web_context_get() instead of
|
|
* webkit_web_context_get_default().
|
|
*/
|
|
|
|
#ifndef WEB_CONTEXT_H
|
|
#define WEB_CONTEXT_H
|
|
|
|
#include <webkit2/webkit2.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* Build a fresh WebKitWebContext with a per-user WebKitWebsiteDataManager
|
|
* rooted at ~/.sovereign_browser/profiles/<pubkey_hex>/webkit/.
|
|
*
|
|
* pubkey_hex — 64-char hex pubkey. Must be non-NULL/non-empty.
|
|
*
|
|
* Configures:
|
|
* - per-user base-data-directory + base-cache-directory (WebKit derives
|
|
* local-storage, indexed-db, websql, service-worker, offline-app-cache,
|
|
* hsts, itp, device-id-hash-salt under these)
|
|
* - favicon database enabled (per-user)
|
|
* - TLS errors ignored (FIPS uses Noise IK, not TLS CAs)
|
|
* - security manager: sovereign://, tor://, file:// registered as
|
|
* secure; file:// also registered as local
|
|
*
|
|
* Stores the new context as the current context (returned by
|
|
* web_context_get()). The caller must call web_context_teardown() on the
|
|
* previous context first if one exists.
|
|
*
|
|
* Returns the new WebKitWebContext (owned by this module), or NULL on
|
|
* failure.
|
|
*/
|
|
WebKitWebContext *web_context_build_for_pubkey(const char *pubkey_hex);
|
|
|
|
/*
|
|
* Build a fresh WebKitWebContext with an EPHEMERAL data manager (no
|
|
* on-disk persistence). Used for --no-login / read-only mode where
|
|
* there is no pubkey to key a per-user data directory on, and for the
|
|
* logged-out state. Same security/TLS/favicon config as
|
|
* web_context_build_for_pubkey.
|
|
*
|
|
* Stores the new context as the current context.
|
|
*
|
|
* Returns the new WebKitWebContext, or NULL on failure.
|
|
*/
|
|
WebKitWebContext *web_context_build_ephemeral(void);
|
|
|
|
/*
|
|
* Tear down the current per-user WebKitWebContext: unref the context
|
|
* and its data manager. After this, web_context_get() returns NULL
|
|
* until the next build call.
|
|
*
|
|
* The caller MUST have already closed all webviews that reference the
|
|
* old context (tabs + sidebar webviews) before calling this, otherwise
|
|
* the webviews will hold dangling references. identity_teardown_web_state()
|
|
* in main.c does this.
|
|
*/
|
|
void web_context_teardown(void);
|
|
|
|
/*
|
|
* Return the current WebKitWebContext, or NULL if none has been built
|
|
* (or the last one was torn down). Replaces webkit_web_context_get_default()
|
|
* for code that wants the per-user context.
|
|
*/
|
|
WebKitWebContext *web_context_get(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* WEB_CONTEXT_H */
|