Skip to content

Commit 033e7f4

Browse files
committed
Update
1 parent 85bd8b7 commit 033e7f4

File tree

9 files changed

+518
-486
lines changed

9 files changed

+518
-486
lines changed

Cargo.lock

Lines changed: 447 additions & 452 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-base/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ blake3 = { version = "1.4.5", package = "iroh-blake3", optional = true }
2020
data-encoding = { version = "2.3.3", optional = true }
2121
hex = "0.4.3"
2222
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"], optional = true }
23-
redb = { version = "2.0.0", optional = true }
23+
redb = { version = "2.1.2", optional = true }
2424
serde = { version = "1", features = ["derive"] }
2525
serde-error = "0.1.2"
2626
thiserror = "1"

iroh-blobs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ postcard = { version = "1", default-features = false, features = ["alloc", "use-
3939
quinn = { package = "iroh-quinn", version = "0.11", features = ["ring"] }
4040
rand = "0.8"
4141
range-collections = "0.4.0"
42-
redb = { version = "2.0.0", optional = true }
42+
redb = { version = "2.1.2", optional = true }
4343
redb_v1 = { package = "redb", version = "1.5.1", optional = true }
4444
reflink-copy = { version = "0.1.8", optional = true }
4545
self_cell = "1.0.1"

iroh-dns-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mainline = "2.0.1"
3030
parking_lot = "0.12.1"
3131
pkarr = { version = "2.2.0", features = [ "async", "relay", "dht"], default-features = false }
3232
rcgen = "0.12.1"
33-
redb = "2.0.0"
33+
redb = "2.1.2"
3434
regex = "1.10.3"
3535
rustls = { version = "0.23", default-features = false, features = ["ring"] }
3636
rustls-pemfile = { version = "2.1" }

iroh-docs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ num_enum = "0.7"
3535
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
3636
rand = "0.8.5"
3737
rand_core = "0.6.4"
38-
redb = { version = "2.0.0" }
38+
redb = { version = "2.1.2" }
3939
redb_v1 = { package = "redb", version = "1.5.1" }
4040
self_cell = "1.0.3"
4141
serde = { version = "1.0.164", features = ["derive"] }

iroh/src/client/docs.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub use iroh_docs::engine::{Origin, SyncEvent, SyncReason};
2222
use iroh_docs::{
2323
actor::OpenState,
2424
store::{DownloadPolicy, Query},
25-
AuthorId, Capability, CapabilityKind, ContentStatus, DocTicket, NamespaceId, PeerIdBytes,
26-
RecordIdentifier,
25+
AuthorId, Capability, CapabilityKind, ContentStatus, DocTicket, NamespaceId, NamespaceSecret,
26+
PeerIdBytes, RecordIdentifier,
2727
};
2828
use iroh_net::NodeAddr;
2929
use portable_atomic::{AtomicBool, Ordering};
@@ -35,10 +35,10 @@ use super::{blobs, flatten, RpcClient};
3535
use crate::rpc_protocol::{
3636
docs::{
3737
CloseRequest, CreateRequest, DelRequest, DelResponse, DocListRequest, DocSubscribeRequest,
38-
DropRequest, ExportFileRequest, GetDownloadPolicyRequest, GetExactRequest, GetManyRequest,
39-
GetSyncPeersRequest, ImportFileRequest, ImportRequest, LeaveRequest, OpenRequest,
40-
SetDownloadPolicyRequest, SetHashRequest, SetRequest, ShareRequest, StartSyncRequest,
41-
StatusRequest,
38+
DropRequest, ExportFileRequest, ExportSecretKeyRequest, GetDownloadPolicyRequest,
39+
GetExactRequest, GetManyRequest, GetSyncPeersRequest, ImportFileRequest, ImportRequest,
40+
LeaveRequest, OpenRequest, SetDownloadPolicyRequest, SetHashRequest, SetRequest,
41+
ShareRequest, StartSyncRequest, StatusRequest,
4242
},
4343
RpcService,
4444
};
@@ -68,6 +68,12 @@ impl Client {
6868
Ok(())
6969
}
7070

71+
/// Export secret key
72+
pub async fn export_secret_key(&self, doc_id: NamespaceId) -> Result<NamespaceSecret> {
73+
let response = self.rpc.rpc(ExportSecretKeyRequest { doc_id }).await??;
74+
Ok(response.secret)
75+
}
76+
7177
/// Imports a document from a namespace capability.
7278
///
7379
/// This does not start sync automatically. Use [`Doc::start_sync`] to start sync.

iroh/src/node/rpc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,12 @@ impl<D: BaoStore> Handler<D> {
455455
})
456456
.await
457457
}
458+
ExportSecretKey(msg) => {
459+
chan.rpc(msg, self, |handler, req| {
460+
handler.with_docs(|docs| async move { docs.export_secret_key(req).await })
461+
})
462+
.await
463+
}
458464
}
459465
}
460466

iroh/src/node/rpc/docs.rs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ use iroh_base::rpc::RpcResult;
66
use iroh_blobs::{store::Store as BaoStore, BlobFormat};
77
use iroh_docs::{Author, DocTicket, NamespaceSecret};
88

9-
use crate::{
10-
client::docs::ShareMode,
11-
node::DocsEngine,
12-
rpc_protocol::{
13-
authors::{
14-
CreateRequest, CreateResponse, DeleteRequest, DeleteResponse, ExportRequest,
15-
ExportResponse, GetDefaultRequest, GetDefaultResponse, ImportRequest, ImportResponse,
16-
ListRequest as AuthorListRequest, ListResponse as AuthorListResponse,
17-
SetDefaultRequest, SetDefaultResponse,
18-
},
19-
docs::{
20-
CloseRequest, CloseResponse, CreateRequest as DocCreateRequest,
21-
CreateResponse as DocCreateResponse, DelRequest, DelResponse, DocListRequest,
22-
DocSubscribeRequest, DocSubscribeResponse, DropRequest, DropResponse,
23-
GetDownloadPolicyRequest, GetDownloadPolicyResponse, GetExactRequest, GetExactResponse,
24-
GetManyRequest, GetManyResponse, GetSyncPeersRequest, GetSyncPeersResponse,
25-
ImportRequest as DocImportRequest, ImportResponse as DocImportResponse, LeaveRequest,
26-
LeaveResponse, ListResponse as DocListResponse, OpenRequest, OpenResponse,
27-
SetDownloadPolicyRequest, SetDownloadPolicyResponse, SetHashRequest, SetHashResponse,
28-
SetRequest, SetResponse, ShareRequest, ShareResponse, StartSyncRequest,
29-
StartSyncResponse, StatusRequest, StatusResponse,
30-
},
9+
use crate::client::docs::ShareMode;
10+
use crate::node::DocsEngine;
11+
12+
use crate::rpc_protocol::{
13+
authors::{
14+
CreateRequest, CreateResponse, DeleteRequest, DeleteResponse, ExportRequest,
15+
ExportResponse, GetDefaultRequest, GetDefaultResponse, ImportRequest, ImportResponse,
16+
ListRequest as AuthorListRequest, ListResponse as AuthorListResponse, SetDefaultRequest,
17+
SetDefaultResponse,
18+
},
19+
docs::{
20+
CloseRequest, CloseResponse, CreateRequest as DocCreateRequest,
21+
CreateResponse as DocCreateResponse, DelRequest, DelResponse, DocListRequest,
22+
DocSubscribeRequest, DocSubscribeResponse, DropRequest, DropResponse,
23+
ExportSecretKeyRequest, ExportSecretKeyResponse, GetDownloadPolicyRequest,
24+
GetDownloadPolicyResponse, GetExactRequest, GetExactResponse, GetManyRequest,
25+
GetManyResponse, GetSyncPeersRequest, GetSyncPeersResponse,
26+
ImportRequest as DocImportRequest, ImportResponse as DocImportResponse, LeaveRequest,
27+
LeaveResponse, ListResponse as DocListResponse, OpenRequest, OpenResponse,
28+
SetDownloadPolicyRequest, SetDownloadPolicyResponse, SetHashRequest, SetHashResponse,
29+
SetRequest, SetResponse, ShareRequest, ShareResponse, StartSyncRequest, StartSyncResponse,
30+
StatusRequest, StatusResponse,
3131
},
3232
};
3333

@@ -307,4 +307,12 @@ impl DocsEngine {
307307
let peers = self.sync.get_sync_peers(req.doc_id).await?;
308308
Ok(GetSyncPeersResponse { peers })
309309
}
310+
311+
pub async fn export_secret_key(
312+
&self,
313+
req: ExportSecretKeyRequest,
314+
) -> RpcResult<ExportSecretKeyResponse> {
315+
let secret = self.sync.export_secret_key(req.doc_id).await?;
316+
Ok(ExportSecretKeyResponse { secret })
317+
}
310318
}

iroh/src/rpc_protocol/docs.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use iroh_docs::{
1010
actor::OpenState,
1111
engine::LiveEvent,
1212
store::{DownloadPolicy, Query},
13-
AuthorId, Capability, CapabilityKind, DocTicket, Entry, NamespaceId, PeerIdBytes, SignedEntry,
13+
AuthorId, Capability, CapabilityKind, DocTicket, Entry, NamespaceId, NamespaceSecret,
14+
PeerIdBytes, SignedEntry,
1415
};
1516
use iroh_net::NodeAddr;
1617
use nested_enum_utils::enum_conversions;
@@ -38,6 +39,8 @@ pub enum Request {
3839
Create(CreateRequest),
3940
#[rpc(response = RpcResult<DropResponse>)]
4041
Drop(DropRequest),
42+
#[rpc(response = RpcResult<ExportSecretKeyResponse>)]
43+
ExportSecretKey(ExportSecretKeyRequest),
4144
#[rpc(response = RpcResult<ImportResponse>)]
4245
Import(ImportRequest),
4346
#[rpc(response = RpcResult<SetResponse>)]
@@ -96,6 +99,7 @@ pub enum Response {
9699
SetDownloadPolicy(RpcResult<SetDownloadPolicyResponse>),
97100
GetSyncPeers(RpcResult<GetSyncPeersResponse>),
98101
StreamCreated(RpcResult<StreamCreated>),
102+
ExportSecretKey(RpcResult<ExportSecretKeyResponse>),
99103
}
100104

101105
/// Subscribe to events for a document.
@@ -237,6 +241,19 @@ pub struct DropRequest {
237241
#[derive(Serialize, Deserialize, Debug)]
238242
pub struct DropResponse {}
239243

244+
/// Get secret key
245+
#[derive(Serialize, Deserialize, Debug)]
246+
pub struct ExportSecretKeyRequest {
247+
/// The document id
248+
pub doc_id: NamespaceId,
249+
}
250+
251+
/// Response to [`ExportSecretKeyRequest`]
252+
#[derive(Serialize, Deserialize, Debug)]
253+
pub struct ExportSecretKeyResponse {
254+
pub(crate) secret: NamespaceSecret,
255+
}
256+
240257
/// Set an entry in a document
241258
#[derive(Serialize, Deserialize, Debug)]
242259
pub struct SetRequest {
@@ -268,7 +285,7 @@ pub struct ImportFileRequest {
268285
pub doc_id: NamespaceId,
269286
/// Author of this entry.
270287
pub author_id: AuthorId,
271-
/// Key of this entry.
288+
/// Key of this entry.ExportSecretKeyResponse
272289
pub key: Bytes,
273290
/// The filepath to the data
274291
///

0 commit comments

Comments
 (0)