MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / client_for_remote

Function client_for_remote

libatomic/src/signer_refresh.rs:10–21  ·  view source on GitHub ↗

Reuse the authenticated remote's origin and credentials, never an unrelated globally selected server. Anonymous remotes do not trigger discovery.

(remote: &str, config: &HttpRemoteConfig)

Source from the content-addressed store, hash-verified

8/// Reuse the authenticated remote's origin and credentials, never an unrelated
9/// globally selected server. Anonymous remotes do not trigger discovery.
10pub fn client_for_remote(remote: &str, config: &HttpRemoteConfig) -> Option<StorageClient> {
11 let header = |name: &str| {
12 config
13 .extra_headers
14 .iter()
15 .find(|(key, _)| key.eq_ignore_ascii_case(name))
16 .map(|(_, value)| value.as_str())
17 };
18 let token = header("authorization")?.strip_prefix("Bearer ")?;
19 let origin = url::Url::parse(remote).ok()?.origin().ascii_serialization();
20 StorageClient::with_delegation(&origin, "", token, header("atomic-delegation")).ok()
21}
22
23/// Discover only unresolved DIDs, with no pristine transaction held over I/O.
24/// Older storage versions cannot resolve fingerprint DIDs: that is a cache

Callers 2

pull_changes_implFunction · 0.85

Calls 6

originMethod · 0.80
headerFunction · 0.50
parseFunction · 0.50
iterMethod · 0.45
as_strMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected