pub struct Session {
pub cookies: Vec<Cookie>,
pub hydra_jwt: Option<String>,
pub hydra_exp: Option<i64>,
pub web_app_version: Option<String>,
pub payment_type_id: Option<String>,
pub user_agent: Option<String>,
pub exported_at: Option<f64>,
}Expand description
The on-disk session document. Field names match the browser export helper
and the Python reference client so an existing session.json imports as-is.
Fields§
§hydra_jwt: Option<String>The hydra device JWT (attached as the x-hydra-jwt header).
hydra_exp: Option<i64>exp of the hydra JWT, Unix seconds.
web_app_version: Option<String>The Next.js build id, sent as x-grab-web-app-version.
payment_type_id: Option<String>Default payment method id captured from the browser, if any.
user_agent: Option<String>The browser’s User-Agent at import time.
exported_at: Option<f64>When the cookies were exported, Unix seconds.
Implementations§
Source§impl Session
impl Session
pub fn load(path: &Path) -> Result<Self>
Sourcepub fn load_default() -> Result<Self>
pub fn load_default() -> Result<Self>
Load from the default/env path.
pub fn save(&self, path: &Path) -> Result<()>
pub fn save_default(&self) -> Result<()>
Insert or replace a cookie, matched by name, path and domain (a
leading dot is ignored for the match, so .grab.com and a legacy
grab.com entry are the same cookie). Used to merge Set-Cookies.
Remove a cookie (same matching rules as upsert_cookie).
Apply one parsed Set-Cookie (insert, replace, or delete).
Sourcepub fn carry_over_preferences(&mut self, prev: &Session) -> Vec<String>
pub fn carry_over_preferences(&mut self, prev: &Session) -> Vec<String>
Copy the PREFERENCE_COOKIES that this session lacks (by name)
from prev. Never touches auth cookies and never overwrites a
preference the new session already has. Returns the names copied.
Replace every cookie called name with the ones called name in
source (e.g. a browser’s cookies), leaving all other cookies alone.
Returns whether source had any; if not, nothing changes.
Set the location cookie’s value, keeping the existing cookie’s
domain, path and expiry (or food.grab.com, /, one year if none).
Value of the first stored cookie called name (any domain).
The Cookie: header a browser would send to url: only cookies whose
domain and path match, and that haven’t expired. Domain cookies are
stored with a leading dot (.grab.com); others are host-only.
Sourcepub fn gfc_logged_in(&self) -> bool
pub fn gfc_logged_in(&self) -> bool
Whether gfc_session is a logged-in food session (its JWT carries
an access token). Before login, food.grab.com/auth/login sets an
anonymous gfc_session that only holds the PKCE verifier and state.
Sourcepub fn gfc_session_key(&self) -> Result<String>
pub fn gfc_session_key(&self) -> Result<String>
The x-gfc-session header value: the sessionKey claim inside the
gfc_session cookie (a JWT).
Sourcepub fn gfc_session_exp(&self) -> Option<i64>
pub fn gfc_session_exp(&self) -> Option<i64>
Expiry of the gfc_session cookie’s embedded access token (Unix seconds).
Sourcepub fn gfc_expires_at(&self) -> Option<i64>
pub fn gfc_expires_at(&self) -> Option<i64>
When the food session stops working: the earlier of the
gfc_session cookie’s own expiry (Max-Age=7200) and its JWT exp.