feat: 通过加密会话和冲突设置连接桌面 Sync

This commit is contained in:
2026-09-08 16:03:49 +08:00
parent 3a4d6e5586
commit 91ef49442d
27 changed files with 1005 additions and 9 deletions
+14 -1
View File
@@ -21,7 +21,7 @@ pub struct SyncError {
pub retry_after: Option<u64>,
}
impl SyncError {
fn new(code: &str) -> Self {
pub(crate) fn new(code: &str) -> Self {
Self {
code: code.into(),
status: 0,
@@ -197,6 +197,19 @@ impl SyncClient {
let value = self.json(Method::POST, "sync/v1/auth/sessions", Some(json!({"username":username,"password":password.as_str(),"device_name":device_name}))).await?;
serde_json::from_value(value).map_err(|_| SyncError::new("SYNC_RESPONSE_INVALID"))
}
pub fn endpoint(&self) -> &str {
self.endpoint.as_str()
}
pub async fn refresh(&self, refresh_token: &str) -> Result<Session> {
let value = self
.json(
Method::POST,
"sync/v1/auth/refresh",
Some(json!({"refresh_token":refresh_token})),
)
.await?;
serde_json::from_value(value).map_err(|_| SyncError::new("SYNC_RESPONSE_INVALID"))
}
pub async fn handshake(&self) -> Result<()> {
let result = self
.json(Method::GET, "sync/v1/handshake?protocol=1", None)