let (session, auth) = MemoryCredentialSession::authenticated(
handle.clone().into(),
password.clone().into(),
None,
)
.await
.map_err(|e| e.to_string())?;
What to store in file auth data/ AtpSession and session data?
pub struct AtpSession {
pub access_jwt: CowStr<'static>,
pub refresh_jwt: CowStr<'static>,
pub did: Did<'static>,
pub handle: Handle<'static>,
}
How to store and retrieve session?
First of all, I strongly recommend OAuth for production, that is the protocol developers' expressed strong preference and will have much more granular permissions than an app password over time, unless you have clear need for an indefinite duration session with broad permissions and it's unreasonable to expect a user to occasionally have to click something to refresh it.
atproto OAuth has a reputation, but I promise Jacquard makes it pretty easy. You need a route to call start_auth on an
OAuthClientinstance backed by your auth store implementation, a route to receive the callback and call the callback function on thatOAuthClient, which returns anOAuthSessionbacked by that auth store, and a place to publish your client metadata, that's it. I've been meaning to write an example of a more production-like OAuth setup, to demonstrate that it really is pretty simple.Here are the docs for
CredentialSession. If you are committed to using an app password session, you want something that implements theSessionStoretrait with the key type being(Did<'static>, CowStr<'static>)(the DID and a session identifier, which can be unique or a constant), andAtpSessionfor the value type.MemorySessionStore(whatMemoryCredentialSessionuses) is one.FileAuthStoreis another. It supports OAuth and app password sessions, implementing both theSessionStoretrait app password sessions use and theClientAuthStoretrait fromjacquard-oauth. However,FileAuthStoreis not at all suited for production, it is primarily intended to be a rough-and-ready but functional persistent session store for development.For a production use case, you should implement the required storage trait for your session type (either
SessionStoreorClientAuthStore) yourself, backed by your app's database or other storage medium. The traits are quite simple to implement. Jacquard does not currently provide any such implementations, as they are likely to be quite specific to each app's own needs.