⚘ use your pds as a git remote if you want to ⚘
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

auth status

authored by

notplants and committed by
notplants
5d79349c ddc2c19d

+37 -3
+37 -3
src/main.rs
··· 143 143 } 144 144 } 145 145 146 - /// Handles `auth status` — prints stored credentials. 146 + /// Handles `auth status` — prints stored credentials with details. 147 147 fn handle_status() { 148 148 match pds_git_remote::auth::load_config() { 149 149 Ok(config) => { ··· 151 151 eprintln!("no stored credentials"); 152 152 return; 153 153 } 154 - for (handle, cred) in &config.credentials { 155 - eprintln!("{} ({}) @ {}", handle, cred.did, cred.pds_url); 154 + let now = std::time::SystemTime::now() 155 + .duration_since(std::time::UNIX_EPOCH) 156 + .map(|d| d.as_secs() as i64) 157 + .unwrap_or(0); 158 + 159 + for (i, (handle, cred)) in config.credentials.iter().enumerate() { 160 + if i > 0 { 161 + eprintln!(); 162 + } 163 + eprintln!("{}", handle); 164 + eprintln!(" did: {}", cred.did); 165 + eprintln!(" pds: {}", cred.pds_url); 166 + 167 + // auth method and token status 168 + if cred.dpop_key.is_some() { 169 + eprintln!(" auth: OAuth (DPoP)"); 170 + match cred.token_expiry { 171 + Some(expiry) => { 172 + let diff = expiry - now; 173 + if diff > 0 { 174 + let mins = diff / 60; 175 + let secs = diff % 60; 176 + eprintln!(" token: valid (expires in {}m {}s)", mins, secs); 177 + } else { 178 + let ago = -diff; 179 + let mins = ago / 60; 180 + eprintln!(" token: expired ({}m ago)", mins); 181 + } 182 + } 183 + None => { 184 + eprintln!(" token: unknown expiry"); 185 + } 186 + } 187 + } else { 188 + eprintln!(" auth: createSession (Bearer)"); 189 + } 156 190 } 157 191 } 158 192 Err(e) => {