+3
-3
src/auth.rs
+3
-3
src/auth.rs
···
1
1
//! Authentication primitives.
2
2
3
-
use anyhow::{anyhow, Context};
3
+
use anyhow::{Context, anyhow};
4
4
use atrium_crypto::{
5
5
keypair::{Did, Secp256k1Keypair},
6
6
verify::Verifier,
···
8
8
use axum::{extract::FromRequestParts, http::StatusCode};
9
9
use base64::Engine;
10
10
11
-
use crate::{auth, error::ErrorMessage, AppState, Error};
11
+
use crate::{AppState, Error, auth, error::ErrorMessage};
12
12
13
13
/// This is an axum request extractor that represents an authenticated user.
14
14
///
···
46
46
return Err(Error::with_status(
47
47
StatusCode::UNAUTHORIZED,
48
48
anyhow!("no bearer token"),
49
-
))
49
+
));
50
50
}
51
51
};
52
52
+1
-1
src/did.rs
+1
-1
src/did.rs
+7
-4
src/endpoints/identity.rs
+7
-4
src/endpoints/identity.rs
···
1
1
use std::collections::HashMap;
2
2
3
-
use anyhow::{anyhow, Context};
3
+
use anyhow::{Context, anyhow};
4
4
use atrium_api::{
5
5
com::atproto::identity,
6
6
types::string::{Datetime, Handle},
···
8
8
use atrium_crypto::keypair::Did;
9
9
use atrium_repo::blockstore::{AsyncBlockStoreWrite, CarStore, DAG_CBOR, SHA2_256};
10
10
use axum::{
11
+
Json, Router,
11
12
extract::{Query, State},
12
13
http::StatusCode,
13
14
routing::{get, post},
14
-
Json, Router,
15
15
};
16
16
use constcat::concat;
17
17
18
18
use crate::{
19
+
AppState, Client, Db, Error, Result, RotationKey, SigningKey,
19
20
auth::AuthenticatedUser,
20
21
config::AppConfig,
21
22
did,
22
23
firehose::FirehoseProducer,
23
24
plc::{self, PlcOperation, PlcService},
24
-
AppState, Client, Db, Error, Result, RotationKey, SigningKey,
25
25
};
26
26
27
27
async fn resolve_handle(
···
69
69
todo!()
70
70
}
71
71
72
-
#[expect(clippy::too_many_arguments, reason = "Many parameters are required for this endpoint")]
72
+
#[expect(
73
+
clippy::too_many_arguments,
74
+
reason = "Many parameters are required for this endpoint"
75
+
)]
73
76
async fn update_handle(
74
77
user: AuthenticatedUser,
75
78
State(skey): State<SigningKey>,
+1
-1
src/endpoints/mod.rs
+1
-1
src/endpoints/mod.rs
+6
-5
src/endpoints/repo.rs
+6
-5
src/endpoints/repo.rs
···
1
1
use std::{collections::HashSet, str::FromStr};
2
2
3
-
use anyhow::{anyhow, Context};
3
+
use anyhow::{Context, anyhow};
4
4
use atrium_api::{
5
5
com::atproto::repo::{self, defs::CommitMetaData},
6
6
types::{
7
-
string::{AtIdentifier, Nsid, Tid},
8
7
LimitedU32, Object, TryFromUnknown, TryIntoUnknown, Unknown,
8
+
string::{AtIdentifier, Nsid, Tid},
9
9
},
10
10
};
11
-
use atrium_repo::{blockstore::CarStore, Cid};
11
+
use atrium_repo::{Cid, blockstore::CarStore};
12
12
use axum::{
13
+
Json, Router,
13
14
body::Body,
14
15
extract::{Query, Request, State},
15
16
http::{self, StatusCode},
16
17
routing::{get, post},
17
-
Json, Router,
18
18
};
19
19
use constcat::concat;
20
20
use futures::TryStreamExt;
···
24
24
use tokio::io::AsyncWriteExt;
25
25
26
26
use crate::{
27
+
AppState, Db, Error, Result, SigningKey,
27
28
auth::AuthenticatedUser,
28
29
config::AppConfig,
29
30
firehose::{self, FirehoseProducer, RepoOp},
30
31
metrics::{REPO_COMMITS, REPO_OP_CREATE, REPO_OP_DELETE, REPO_OP_UPDATE},
31
-
storage, AppState, Db, Error, Result, SigningKey,
32
+
storage,
32
33
};
33
34
34
35
/// IPLD CID raw binary
+5
-5
src/endpoints/server.rs
+5
-5
src/endpoints/server.rs
···
1
1
use std::{collections::HashMap, str::FromStr};
2
2
3
-
use anyhow::{anyhow, Context};
4
-
use argon2::{password_hash::SaltString, Argon2, PasswordHash, PasswordHasher, PasswordVerifier};
3
+
use anyhow::{Context, anyhow};
4
+
use argon2::{Argon2, PasswordHash, PasswordHasher, PasswordVerifier, password_hash::SaltString};
5
5
use atrium_api::{
6
6
com::atproto::server,
7
7
types::string::{Datetime, Did, Handle, Tid},
8
8
};
9
9
use atrium_crypto::keypair::Did as _;
10
10
use atrium_repo::{
11
-
blockstore::{AsyncBlockStoreWrite, CarStore, DAG_CBOR, SHA2_256},
12
11
Cid, Repository,
12
+
blockstore::{AsyncBlockStoreWrite, CarStore, DAG_CBOR, SHA2_256},
13
13
};
14
14
use axum::{
15
+
Json, Router,
15
16
extract::{Query, Request, State},
16
17
http::StatusCode,
17
18
routing::{get, post},
18
-
Json, Router,
19
19
};
20
20
use constcat::concat;
21
21
use metrics::counter;
···
24
24
use uuid::Uuid;
25
25
26
26
use crate::{
27
+
AppState, Client, Db, Error, Result, RotationKey, SigningKey,
27
28
auth::{self, AuthenticatedUser},
28
29
config::AppConfig,
29
30
firehose::{Commit, FirehoseProducer},
30
31
metrics::AUTH_FAILED,
31
32
plc::{self, PlcOperation, PlcService},
32
-
AppState, Client, Db, Error, Result, RotationKey, SigningKey,
33
33
};
34
34
35
35
/// This is a dummy password that can be used in absence of a real password.
+4
-4
src/endpoints/sync.rs
+4
-4
src/endpoints/sync.rs
···
1
1
use std::str::FromStr;
2
2
3
-
use anyhow::{anyhow, Context};
3
+
use anyhow::{Context, anyhow};
4
4
use atrium_api::{com::atproto::sync, types::string::Did};
5
5
use atrium_repo::{
6
-
blockstore::{AsyncBlockStoreRead, AsyncBlockStoreWrite, CarStore, DAG_CBOR, SHA2_256},
7
6
Cid,
7
+
blockstore::{AsyncBlockStoreRead, AsyncBlockStoreWrite, CarStore, DAG_CBOR, SHA2_256},
8
8
};
9
9
use axum::{
10
+
Json, Router,
10
11
body::Body,
11
12
extract::{Query, State, WebSocketUpgrade},
12
13
http::{self, Response, StatusCode},
13
14
response::IntoResponse,
14
15
routing::get,
15
-
Json, Router,
16
16
};
17
17
use constcat::concat;
18
18
use futures::stream::TryStreamExt;
19
19
use tokio_util::io::ReaderStream;
20
20
21
21
use crate::{
22
+
AppState, Db, Error, Result,
22
23
config::AppConfig,
23
24
firehose::FirehoseProducer,
24
25
storage::{open_repo_db, open_store},
25
-
AppState, Db, Error, Result,
26
26
};
27
27
28
28
async fn get_blob(
+10
-2
src/error.rs
+10
-2
src/error.rs
···
21
21
}
22
22
impl std::fmt::Display for ErrorMessage {
23
23
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24
-
write!(f, r#"{{"error":"{}","message":"{}"}}"#, self.error, self.message)
24
+
write!(
25
+
f,
26
+
r#"{{"error":"{}","message":"{}"}}"#,
27
+
self.error, self.message
28
+
)
25
29
}
26
30
}
27
31
impl ErrorMessage {
···
46
50
}
47
51
}
48
52
49
-
pub fn with_message(status: StatusCode, err: impl Into<anyhow::Error>, message: impl Into<ErrorMessage>) -> Self {
53
+
pub fn with_message(
54
+
status: StatusCode,
55
+
err: impl Into<anyhow::Error>,
56
+
message: impl Into<ErrorMessage>,
57
+
) -> Self {
50
58
Self {
51
59
status,
52
60
err: err.into(),
+10
-5
src/firehose.rs
+10
-5
src/firehose.rs
···
1
1
use std::{collections::VecDeque, time::Duration};
2
2
3
-
use anyhow::{bail, Result};
3
+
use anyhow::{Result, bail};
4
4
use atrium_api::{
5
5
com::atproto::sync::{self},
6
6
types::string::{Datetime, Did},
···
9
9
use axum::extract::ws::{Message, WebSocket};
10
10
use metrics::{counter, gauge};
11
11
use rand::Rng;
12
-
use serde::{ser::SerializeMap, Serialize};
12
+
use serde::{Serialize, ser::SerializeMap};
13
13
use tracing::{debug, error, info, warn};
14
14
15
15
use crate::{
16
+
Client,
16
17
config::AppConfig,
17
18
metrics::{FIREHOSE_HISTORY, FIREHOSE_LISTENERS, FIREHOSE_MESSAGES, FIREHOSE_SEQUENCE},
18
-
Client,
19
19
};
20
20
21
21
enum FirehoseMessage {
···
156
156
}
157
157
158
158
pub async fn client_connection(&self, ws: WebSocket, cursor: Option<i64>) {
159
-
let _ = self.tx.send(FirehoseMessage::Connect(Box::new((ws, cursor)))).await;
159
+
let _ = self
160
+
.tx
161
+
.send(FirehoseMessage::Connect(Box::new((ws, cursor))))
162
+
.await;
160
163
}
161
164
}
162
165
···
227
230
228
231
// Drop the connection.
229
232
let _ = ws.send(Message::binary(frame)).await;
230
-
bail!("connection dropped: cursor {cursor} is greater than the current sequence number {seq}");
233
+
bail!(
234
+
"connection dropped: cursor {cursor} is greater than the current sequence number {seq}"
235
+
);
231
236
}
232
237
233
238
for (seq, ty, msg) in history.iter() {
+10
-8
src/main.rs
+10
-8
src/main.rs
···
9
9
use atrium_crypto::keypair::{Export, Secp256k1Keypair};
10
10
use auth::AuthenticatedUser;
11
11
use axum::{
12
+
Router,
12
13
body::Body,
13
14
extract::{FromRef, Request, State},
14
15
http::{self, HeaderMap, Response, StatusCode, Uri},
15
16
response::IntoResponse,
16
17
routing::get,
17
-
Router,
18
18
};
19
19
use azure_core::credentials::TokenCredential;
20
20
use clap::Parser;
21
-
use clap_verbosity_flag::{log::LevelFilter, InfoLevel, Verbosity};
21
+
use clap_verbosity_flag::{InfoLevel, Verbosity, log::LevelFilter};
22
22
use config::AppConfig;
23
-
use figment::{providers::Format, Figment};
23
+
use figment::{Figment, providers::Format};
24
24
use firehose::FirehoseProducer;
25
25
use http_cache_reqwest::{CacheMode, HttpCacheOptions, MokaManager};
26
26
use rand::Rng;
27
27
use serde::{Deserialize, Serialize};
28
-
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
28
+
use sqlx::{SqlitePool, sqlite::SqliteConnectOptions};
29
29
use tokio::net::TcpListener;
30
30
use tower_http::{cors::CorsLayer, trace::TraceLayer};
31
31
32
-
use anyhow::{anyhow, Context};
32
+
use anyhow::{Context, anyhow};
33
33
use tracing::{info, warn};
34
34
35
35
mod auth;
···
137
137
/// This will _very likely_ be changed in the future.
138
138
mod actor_endpoints {
139
139
use atrium_api::app::bsky::actor;
140
-
use axum::{routing::post, Json};
140
+
use axum::{Json, routing::post};
141
141
use constcat::concat;
142
142
143
143
use super::*;
···
247
247
return Err(Error::with_status(
248
248
StatusCode::BAD_REQUEST,
249
249
anyhow!("could not find resolve service #{id}"),
250
-
))
250
+
));
251
251
}
252
252
};
253
253
···
347
347
if config.test {
348
348
warn!("BluePDS starting up in TEST mode.");
349
349
warn!("This means the application will not federate with the rest of the network.");
350
-
warn!("If you want to turn this off, either set `test` to false in the config or define `BLUEPDS_TEST = false`");
350
+
warn!(
351
+
"If you want to turn this off, either set `test` to false in the config or define `BLUEPDS_TEST = false`"
352
+
);
351
353
}
352
354
353
355
// Initialize metrics reporting.
+1
-1
src/plc.rs
+1
-1
src/plc.rs
+3
-5
src/storage.rs
+3
-5
src/storage.rs
···
4
4
5
5
use anyhow::{Context, Result};
6
6
use atrium_repo::{
7
-
blockstore::{AsyncBlockStoreRead, AsyncBlockStoreWrite, CarStore},
8
7
Cid, Repository,
8
+
blockstore::{AsyncBlockStoreRead, AsyncBlockStoreWrite, CarStore},
9
9
};
10
10
11
-
use crate::{config::RepoConfig, Db};
11
+
use crate::{Db, config::RepoConfig};
12
12
13
13
pub async fn open_store(
14
14
config: &RepoConfig,
···
28
28
.await
29
29
.context("failed to open repository file")?;
30
30
31
-
CarStore::open(f)
32
-
.await
33
-
.context("failed to open car store")
31
+
CarStore::open(f).await.context("failed to open car store")
34
32
}
35
33
36
34
pub async fn open_repo_db(