pub struct CookieSessionView<'a> { /* private fields */ }Expand description
Cookie-only operations on a PubkySession.
Implementations§
Source§impl<'a> CookieSessionView<'a>
impl<'a> CookieSessionView<'a>
Sourcepub fn session_info(&self) -> CookieSessionRecord
pub fn session_info(&self) -> CookieSessionRecord
Returns the full cookie session record.
This gives access to cookie-specific fields like created_at and
the binary serialization format that are not available via the
shared
PubkySession::info
accessor.
Sourcepub fn export(&self) -> String
pub fn export(&self) -> String
Export session metadata for rehydrating after a tab refresh or process restart.
The returned string contains no secrets; it is a base64 encoding of the
public SessionInfo. The caller remains responsible for persisting the
HTTP-only session cookie; export() merely captures the metadata needed to
reconstruct a PubkySession handle.
Sourcepub fn export_secret(&self) -> Option<String>
pub fn export_secret(&self) -> Option<String>
Export the minimum data needed to restore this session later.
Returns a single compact secret token <pubkey>:<cookie_secret>.
Useful for scripts that need restarting. Helps avoid a new auth flow from a signer on a script restart.
Treat the returned String as a bearer secret. Do not log it; store it securely.
§Returns
Some(token)on native and Node.js WASM (the SDK captured the secret fromSet-Cookie).Noneon browser WASM, whereSet-Cookieis hidden from JavaScript by the WHATWG fetch spec — only the browser cookie jar holds the value.
Sourcepub fn write_secret_file<P: AsRef<Path>>(
&self,
secret_file_path: P,
) -> Result<()>
pub fn write_secret_file<P: AsRef<Path>>( &self, secret_file_path: P, ) -> Result<()>
Write the session secret token to disk. Ensures a .sess extension.
Native-only — depends on the standard filesystem APIs.
Behavior:
- If
secret_file_pathalready ends with.sess, it is used as-is. - If it has no extension,
.sessis added. - If it has a different extension, the filename gains
.sess(e.g.,foo.txt->foo.sess).
On Unix, permissions are set to 0o600.
§Errors
- Returns
std::io::Errorif the file cannot be written or permissions cannot be set. On native the secret is always present, so this never errors withNotFoundfor that reason.