···11use crate::api::error::ApiError;
22use crate::api::repo::record::utils::{CommitParams, RecordOp, commit_and_log};
33use crate::api::repo::record::write::{CommitInfo, prepare_repo_write};
44-use crate::auth::{Active, Auth};
44+use crate::auth::{Active, Auth, VerifyScope};
55+use crate::cid_types::CommitCid;
56use crate::delegation::DelegationActionType;
67use crate::repo::tracking::TrackingBlockStore;
78use crate::state::AppState;
···4344 auth: Auth<Active>,
4445 Json(input): Json<DeleteRecordInput>,
4546) -> Result<Response, crate::api::error::ApiError> {
4646- let repo_auth = match prepare_repo_write(&state, &auth, &input.repo).await {
4747+ let scope_proof = match auth.verify_repo_delete(&input.collection) {
4848+ Ok(proof) => proof,
4949+ Err(e) => return Ok(e.into_response()),
5050+ };
5151+5252+ let repo_auth = match prepare_repo_write(&state, &scope_proof, &input.repo).await {
4753 Ok(res) => res,
4854 Err(err_res) => return Ok(err_res),
4955 };
50565151- if let Err(e) = crate::auth::scope_check::check_repo_scope(
5252- repo_auth.is_oauth,
5353- repo_auth.scope.as_deref(),
5454- crate::oauth::RepoAction::Delete,
5555- &input.collection,
5656- ) {
5757- return Ok(e);
5858- }
5959-6057 let did = repo_auth.did;
6158 let user_id = repo_auth.user_id;
6259 let current_root_cid = repo_auth.current_root_cid;
6360 let controller_did = repo_auth.controller_did;
64616562 if let Some(swap_commit) = &input.swap_commit
6666- && Cid::from_str(swap_commit).ok() != Some(current_root_cid)
6363+ && CommitCid::from_str(swap_commit).ok().as_ref() != Some(¤t_root_cid)
6764 {
6865 return Ok(ApiError::InvalidSwap(Some("Repo has been modified".into())).into_response());
6966 }
7067 let tracking_store = TrackingBlockStore::new(state.block_store.clone());
7171- let commit_bytes = match tracking_store.get(¤t_root_cid).await {
6868+ let commit_bytes = match tracking_store.get(current_root_cid.as_cid()).await {
7269 Ok(Some(b)) => b,
7370 _ => {
7471 return Ok(
···159156 .into_iter()
160157 .collect();
161158 let written_cids_str: Vec<String> = written_cids.iter().map(|c| c.to_string()).collect();
162162- let obsolete_cids: Vec<Cid> = std::iter::once(current_root_cid)
159159+ let obsolete_cids: Vec<Cid> = std::iter::once(current_root_cid.into_cid())
163160 .chain(
164161 old_mst_blocks
165162 .keys()
···173170 CommitParams {
174171 did: &did,
175172 user_id,
176176- current_root_cid: Some(current_root_cid),
173173+ current_root_cid: Some(current_root_cid.into_cid()),
177174 prev_data_cid: Some(commit.data),
178175 new_mst_root,
179176 ops: vec![op],
+5
crates/tranquil-pds/src/api/repo/record/mod.rs
···11pub mod batch;
22pub mod delete;
33+pub mod pagination;
34pub mod read;
45pub mod utils;
56pub mod validation;
77+pub mod validation_mode;
68pub mod write;
99+1010+pub use pagination::PaginationDirection;
1111+pub use validation_mode::ValidationMode;
712813pub use batch::apply_writes;
914pub use delete::{DeleteRecordInput, delete_record, delete_record_internal};
···11+use crate::util::pds_hostname;
12use std::sync::OnceLock;
23use tranquil_db_traits::SsoProviderType;
34···5051 };
51525253 if config.is_any_enabled() {
5353- let hostname = std::env::var("PDS_HOSTNAME").unwrap_or_default();
5454+ let hostname = pds_hostname();
5455 if hostname.is_empty() || hostname == "localhost" {
5556 panic!(
5657 "PDS_HOSTNAME must be set to a valid hostname when SSO is enabled. \
···9999 use tranquil_pds::api::repo::record::utils::create_signed_commit;
100100101101 let signing_key = SigningKey::random(&mut rand::thread_rng());
102102- let did = Did::new_unchecked("did:plc:testuser123456789abcdef");
102102+ let did = unsafe { Did::new_unchecked("did:plc:testuser123456789abcdef") };
103103 let data_cid =
104104 Cid::from_str("bafyreib2rxk3ryblouj3fxza5jvx6psmwewwessc4m6g6e7pqhhkwqomfi").unwrap();
105105 let rev = Tid::now(LimitedU32::MIN).to_string();