62fe32759529 | atagen | 2026-09-26 08:50 UTC | 1 | #[cfg(feature = "sqlite")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 2 | use std::path::PathBuf; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 3 | use std::{collections::HashMap, sync::Arc}; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 4 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 5 | use matrix_sdk::{ |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 6 | Client, ClientBuilder, SendOutsideWasm, SyncOutsideWasm, ThreadingSupport, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 7 | authentication::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 8 | AuthSession, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 9 | matrix::MatrixSession, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 10 | oauth::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 11 | ClientId, ClientRegistrationData, CsrfToken, OAuthSession, UserSession, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 12 | registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 13 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 14 | }, |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 15 | cross_process_lock::CrossProcessLockConfig, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 16 | encryption::{BackupDownloadStrategy, EncryptionSettings}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 17 | ruma::{OwnedDeviceId, serde::Raw}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 18 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 19 | use serde::{Deserialize, Serialize}; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 20 | use thiserror::Error; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 21 | use url::Url; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 22 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 23 | use crate::{ |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 24 | ClientHandle, Engine, EngineConfig, EngineError, EventStream, SessionStore, error::SourceError, |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 25 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 26 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 27 | pub struct Session { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 28 | client: Client, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 29 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 30 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 31 | #[non_exhaustive] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 32 | pub struct PasswordLogin { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 33 | pub homeserver: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 34 | pub username: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 35 | pub password: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 36 | pub device_display_name: Option<String>, |
fa9114fcf75f | atagen | 2026-09-24 12:51 UTC | 37 | /// set after a soft logout so the store's keys still belong to us |
fa9114fcf75f | atagen | 2026-09-24 12:51 UTC | 38 | pub device_id: Option<OwnedDeviceId>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 39 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 40 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 41 | impl PasswordLogin { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 42 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 43 | pub fn new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 44 | homeserver: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 45 | username: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 46 | password: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 47 | ) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 48 | Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 49 | homeserver: homeserver.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 50 | username: username.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 51 | password: password.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 52 | device_display_name: None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 53 | device_id: None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 54 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 55 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 56 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 57 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 58 | pub fn with_device_display_name(mut self, name: impl Into<String>) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 59 | self.device_display_name = Some(name.into()); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 60 | self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 61 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 62 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 63 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 64 | pub fn with_device_id(mut self, device_id: OwnedDeviceId) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 65 | self.device_id = Some(device_id); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 66 | self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 67 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 68 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 69 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 70 | #[non_exhaustive] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 71 | pub struct OAuthLogin { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 72 | pub homeserver: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 73 | pub redirect_uri: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 74 | pub client_uri: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 75 | pub client_name: Option<String>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 76 | pub client_id: Option<String>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 77 | pub device_id: Option<OwnedDeviceId>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 78 | pub application_type: OAuthApplicationType, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 79 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 80 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 81 | impl OAuthLogin { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 82 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 83 | pub fn new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 84 | homeserver: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 85 | redirect_uri: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 86 | client_uri: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 87 | application_type: OAuthApplicationType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 88 | ) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 89 | Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 90 | homeserver: homeserver.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 91 | redirect_uri: redirect_uri.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 92 | client_uri: client_uri.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 93 | client_name: None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 94 | client_id: None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 95 | device_id: None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 96 | application_type, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 97 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 98 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 99 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 100 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 101 | pub fn with_client_name(mut self, name: impl Into<String>) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 102 | self.client_name = Some(name.into()); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 103 | self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 104 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 105 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 106 | /// a statically registered client id, skipping dynamic registration |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 107 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 108 | pub fn with_client_id(mut self, client_id: impl Into<String>) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 109 | self.client_id = Some(client_id.into()); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 110 | self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 111 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 112 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 113 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 114 | pub fn with_device_id(mut self, device_id: OwnedDeviceId) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 115 | self.device_id = Some(device_id); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 116 | self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 117 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 118 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 119 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 120 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 121 | #[non_exhaustive] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 122 | pub enum OAuthApplicationType { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 123 | Native, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 124 | Web, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 125 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 126 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 127 | pub struct PendingOAuthLogin { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 128 | client: Client, |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 129 | sessions: Arc<dyn SessionStore>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 130 | authorization_url: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 131 | state: Option<CsrfToken>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 132 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 133 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 134 | impl PendingOAuthLogin { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 135 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 136 | pub fn authorization_url(&self) -> &str { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 137 | &self.authorization_url |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 138 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 139 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 140 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 141 | pub fn registered_client_id(&self) -> String { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 142 | self.client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 143 | .oauth() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 144 | .client_id() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 145 | .expect("OAuth client was registered before authorization") |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 146 | .as_str() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 147 | .to_owned() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 148 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 149 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 150 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 151 | pub const fn is_pending(&self) -> bool { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 152 | self.state.is_some() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 153 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 154 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 155 | pub async fn finish(&mut self, callback_url: &str) -> Result<Session, AccountError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 156 | let callback_url = Url::parse(callback_url) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 157 | .map_err(|error| account_error("parsing the OAuth callback URL", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 158 | let state = self |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 159 | .state |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 160 | .take() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 161 | .ok_or(AccountError::OAuthCallbackAlreadySubmitted)?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 162 | let oauth = self.client.oauth(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 163 | if let Err(error) = oauth.finish_login(callback_url.into()).await { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 164 | oauth.abort_login(&state).await; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 165 | return Err(account_error("OAuth login", error)); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 166 | } |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 167 | Session::saved(self.client.clone(), &*self.sessions).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 168 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 169 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 170 | pub async fn abort(mut self) { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 171 | if let Some(state) = self.state.take() { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 172 | self.client.oauth().abort_login(&state).await; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 173 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 174 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 175 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 176 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 177 | pub struct StoreConfig { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 178 | location: StoreLocation, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 179 | passphrase: String, |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 180 | lock_holder: Option<String>, |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 181 | } |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 182 | |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 183 | enum StoreLocation { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 184 | #[cfg(feature = "sqlite")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 185 | Sqlite(PathBuf), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 186 | #[cfg(feature = "indexeddb")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 187 | IndexedDb(String), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 188 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 189 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 190 | impl StoreConfig { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 191 | #[cfg(feature = "sqlite")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 192 | #[must_use] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 193 | pub fn sqlite(path: impl Into<PathBuf>, passphrase: impl Into<String>) -> Self { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 194 | Self { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 195 | location: StoreLocation::Sqlite(path.into()), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 196 | passphrase: passphrase.into(), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 197 | lock_holder: None, |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 198 | } |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 199 | } |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 200 | |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 201 | #[cfg(feature = "indexeddb")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 202 | #[must_use] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 203 | pub fn indexeddb(name: impl Into<String>, passphrase: impl Into<String>) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 204 | Self { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 205 | location: StoreLocation::IndexedDb(name.into()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 206 | passphrase: passphrase.into(), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 207 | lock_holder: None, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 208 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 209 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 210 | |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 211 | /// the sdk names every client `main`, so two tabs on one store would both think they hold its lock |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 212 | #[must_use] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 213 | pub fn with_lock_holder(mut self, holder: impl Into<String>) -> Self { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 214 | self.lock_holder = Some(holder.into()); |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 215 | self |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 216 | } |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 217 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 218 | /// delete the store's databases, once nothing has them open |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 219 | pub async fn delete(&self) -> Result<(), AccountError> { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 220 | match &self.location { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 221 | #[cfg(feature = "sqlite")] |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 222 | StoreLocation::Sqlite(path) => crate::session_store::delete_sqlite_store(path) |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 223 | .map_err(|error| account_error("deleting the Matrix store", error)), |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 224 | #[cfg(feature = "indexeddb")] |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 225 | StoreLocation::IndexedDb(name) => crate::session_store::delete_indexeddb_store(name) |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 226 | .await |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 227 | .map_err(|error| account_error("deleting the Matrix store", error)), |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 228 | } |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 229 | } |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 230 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 231 | pub(crate) fn passphrase(&self) -> &str { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 232 | &self.passphrase |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 233 | } |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 234 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 235 | #[cfg(feature = "indexeddb")] |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 236 | pub(crate) fn indexeddb_name(&self) -> &str { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 237 | let StoreLocation::IndexedDb(name) = &self.location; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 238 | name |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 239 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 240 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 241 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 242 | /// Serializable authentication secrets. A `SessionStore` keeps it, and it must |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 243 | /// be replaced when `Event::SessionTokensChanged` arrives. |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 244 | #[derive(Clone, Deserialize, Serialize)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 245 | pub struct SessionRecord { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 246 | homeserver: String, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 247 | authentication: AuthenticationRecord, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 248 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 249 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 250 | #[derive(Clone, Deserialize, Serialize)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 251 | #[serde(tag = "type", content = "session", rename_all = "snake_case")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 252 | enum AuthenticationRecord { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 253 | Matrix(MatrixSession), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 254 | OAuth { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 255 | client_id: ClientId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 256 | user: UserSession, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 257 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 258 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 259 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 260 | impl SessionRecord { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 261 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 262 | pub fn homeserver(&self) -> &str { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 263 | &self.homeserver |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 264 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 265 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 266 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 267 | #[derive(Debug, Error)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 268 | pub enum AccountError { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 269 | #[error("{context} failed")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 270 | Operation { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 271 | context: &'static str, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 272 | #[source] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 273 | source: Box<SourceError>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 274 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 275 | #[error("the homeserver returned no authenticated session")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 276 | MissingSession, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 277 | #[error("the SDK returned an unsupported authentication session")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 278 | UnsupportedAuthentication, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 279 | #[error("the OAuth callback was already submitted")] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 280 | OAuthCallbackAlreadySubmitted, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 281 | #[error(transparent)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 282 | Engine(#[from] EngineError), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 283 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 284 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 285 | impl Session { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 286 | pub async fn login_password( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 287 | login: PasswordLogin, |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 288 | sessions: &dyn SessionStore, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 289 | ) -> Result<Self, AccountError> { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 290 | let client = matrix_client_builder(sessions.store()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 291 | .server_name_or_homeserver_url(login.homeserver.trim()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 292 | .build() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 293 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 294 | .map_err(|error| account_error("building the Matrix client", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 295 | let mut request = client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 296 | .matrix_auth() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 297 | .login_username(login.username.trim(), &login.password) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 298 | .request_refresh_token(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 299 | if let Some(name) = login.device_display_name.as_deref() { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 300 | request = request.initial_device_display_name(name); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 301 | } |
fa9114fcf75f | atagen | 2026-09-24 12:51 UTC | 302 | if let Some(device_id) = login.device_id.as_deref() { |
fa9114fcf75f | atagen | 2026-09-24 12:51 UTC | 303 | request = request.device_id(device_id.as_str()); |
fa9114fcf75f | atagen | 2026-09-24 12:51 UTC | 304 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 305 | request |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 306 | .send() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 307 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 308 | .map_err(|error| account_error("password login", error))?; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 309 | Self::saved(client, sessions).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 310 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 311 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 312 | pub async fn begin_oauth( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 313 | login: OAuthLogin, |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 314 | sessions: Arc<dyn SessionStore>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 315 | ) -> Result<PendingOAuthLogin, AccountError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 316 | let redirect_uri = Url::parse(login.redirect_uri.trim()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 317 | .map_err(|error| account_error("parsing the OAuth redirect URI", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 318 | let client_uri = Url::parse(login.client_uri.trim()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 319 | .map_err(|error| account_error("parsing the OAuth client URI", error))?; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 320 | let client = matrix_client_builder(sessions.store()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 321 | .server_name_or_homeserver_url(login.homeserver.trim()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 322 | .build() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 323 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 324 | .map_err(|error| account_error("building the Matrix client", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 325 | let application_type = match login.application_type { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 326 | OAuthApplicationType::Native => ApplicationType::Native, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 327 | OAuthApplicationType::Web => ApplicationType::Web, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 328 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 329 | let mut metadata = ClientMetadata::new( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 330 | application_type, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 331 | vec![OAuthGrantType::AuthorizationCode { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 332 | redirect_uris: vec![redirect_uri.clone()], |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 333 | }], |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 334 | Localized::new(client_uri, []), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 335 | ); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 336 | metadata.client_name = login.client_name.map(|name| Localized::new(name, [])); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 337 | let metadata = Raw::new(&metadata) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 338 | .map_err(|error| account_error("serializing OAuth client metadata", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 339 | let mut registration = ClientRegistrationData::new(metadata); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 340 | if let Some(client_id) = login.client_id { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 341 | registration.static_registrations = Some(HashMap::from([( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 342 | client.homeserver(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 343 | ClientId::new(client_id), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 344 | )])); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 345 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 346 | let authorization = client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 347 | .oauth() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 348 | .login(redirect_uri, login.device_id, Some(registration), None) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 349 | .build() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 350 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 351 | .map_err(|error| account_error("starting OAuth login", error))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 352 | Ok(PendingOAuthLogin { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 353 | client, |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 354 | sessions, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 355 | authorization_url: authorization.url.to_string(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 356 | state: Some(authorization.state), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 357 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 358 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 359 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 360 | /// Restore the record `sessions` holds, or `None` when it holds none. |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 361 | /// The caller must also handle refresh, rejection, and explicit logout. |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 362 | pub async fn restore(sessions: &dyn SessionStore) -> Result<Option<Self>, AccountError> { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 363 | let Some(record) = sessions.load().await? else { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 364 | return Ok(None); |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 365 | }; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 366 | let client = matrix_client_builder(sessions.store()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 367 | .homeserver_url(&record.homeserver) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 368 | .build() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 369 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 370 | .map_err(|error| account_error("reopening the Matrix store", error))?; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 371 | let authentication = match record.authentication { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 372 | AuthenticationRecord::Matrix(session) => AuthSession::Matrix(session), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 373 | AuthenticationRecord::OAuth { client_id, user } => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 374 | OAuthSession { client_id, user }.into() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 375 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 376 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 377 | client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 378 | .restore_session(authentication) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 379 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 380 | .map_err(|error| account_error("restoring the authenticated session", error))?; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 381 | Ok(Some(Self { client })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 382 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 383 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 384 | pub async fn build( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 385 | self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 386 | config: EngineConfig, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 387 | ) -> Result<(Engine, ClientHandle, EventStream), AccountError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 388 | Engine::from_client(self.client, config) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 389 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 390 | .map_err(AccountError::from) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 391 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 392 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 393 | async fn saved(client: Client, sessions: &dyn SessionStore) -> Result<Self, AccountError> { |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 394 | sessions.save(&session_record(&client)?).await?; |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 395 | Ok(Self { client }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 396 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 397 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 398 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 399 | pub(crate) fn session_record(client: &Client) -> Result<SessionRecord, AccountError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 400 | let authentication = match client.session().ok_or(AccountError::MissingSession)? { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 401 | AuthSession::Matrix(session) => AuthenticationRecord::Matrix(session), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 402 | AuthSession::OAuth(session) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 403 | let OAuthSession { client_id, user } = *session; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 404 | AuthenticationRecord::OAuth { client_id, user } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 405 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 406 | _ => return Err(AccountError::UnsupportedAuthentication), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 407 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 408 | Ok(SessionRecord { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 409 | homeserver: client.homeserver().to_string(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 410 | authentication, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 411 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 412 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 413 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 414 | fn encryption_settings() -> EncryptionSettings { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 415 | EncryptionSettings { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 416 | auto_enable_cross_signing: true, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 417 | backup_download_strategy: BackupDownloadStrategy::OneShot, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 418 | auto_enable_backups: true, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 419 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 420 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 421 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 422 | fn matrix_client_builder(store: &StoreConfig) -> ClientBuilder { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 423 | let mut builder = Client::builder() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 424 | .with_encryption_settings(encryption_settings()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 425 | .with_threading_support(ThreadingSupport::Enabled { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 426 | with_subscriptions: false, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 427 | }) |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 428 | .handle_refresh_tokens(); |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 429 | if let Some(holder) = &store.lock_holder { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 430 | builder = builder.cross_process_store_config(CrossProcessLockConfig::multi_process(holder)); |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 431 | } |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 432 | match &store.location { |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 433 | #[cfg(feature = "sqlite")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 434 | StoreLocation::Sqlite(path) => builder.sqlite_store(path, Some(&store.passphrase)), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 435 | #[cfg(feature = "indexeddb")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 436 | StoreLocation::IndexedDb(name) => builder.indexeddb_store(name, Some(&store.passphrase)), |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 437 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 438 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 439 | |
713205a95af2 | atagen | 2026-09-26 09:24 UTC | 440 | pub(crate) fn account_error( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 441 | context: &'static str, |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 442 | source: impl std::error::Error + SendOutsideWasm + SyncOutsideWasm + 'static, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 443 | ) -> AccountError { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 444 | AccountError::Operation { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 445 | context, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 446 | source: Box::new(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 447 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 448 | } |