(opts: {
json?: boolean
text?: boolean
})
| 325 | } |
| 326 | |
| 327 | export async function authStatus(opts: { |
| 328 | json?: boolean |
| 329 | text?: boolean |
| 330 | }): Promise<void> { |
| 331 | const statusView = await getAuthRuntime().getStatusView() |
| 332 | const continuityView = await getLeaseManager().getStatusView() |
| 333 | |
| 334 | if (opts.text) { |
| 335 | const properties = [ |
| 336 | ...statusView.accountProperties, |
| 337 | ...buildAPIProviderProperties(), |
| 338 | ] |
| 339 | let hasAuthProperty = false |
| 340 | for (const prop of properties) { |
| 341 | const value = |
| 342 | typeof prop.value === 'string' |
| 343 | ? prop.value |
| 344 | : Array.isArray(prop.value) |
| 345 | ? prop.value.join(', ') |
| 346 | : null |
| 347 | if (value === null || value === 'none') { |
| 348 | continue |
| 349 | } |
| 350 | hasAuthProperty = true |
| 351 | if (prop.label) { |
| 352 | process.stdout.write(`${prop.label}: ${value}\n`) |
| 353 | } else { |
| 354 | process.stdout.write(`${value}\n`) |
| 355 | } |
| 356 | } |
| 357 | process.stdout.write( |
| 358 | `Continuity: ${formatContinuityStateLabel(continuityView.continuityState)}\n`, |
| 359 | ) |
| 360 | process.stdout.write( |
| 361 | `Lease renewal: ${formatLeaseRenewalStateLabel(continuityView.leaseRenewalState)}\n`, |
| 362 | ) |
| 363 | if (continuityView.executionTarget) { |
| 364 | process.stdout.write( |
| 365 | `Execution: ${formatExecutionTargetLabel(continuityView.executionTarget)}\n`, |
| 366 | ) |
| 367 | } |
| 368 | if (statusView.recoveryMessage) { |
| 369 | process.stdout.write(`${statusView.recoveryMessage}\n`) |
| 370 | } else if (!statusView.loggedIn) { |
| 371 | process.stdout.write('Not logged in. Run auth login to authenticate.\n') |
| 372 | } |
| 373 | } else { |
| 374 | const output: Record<string, string | boolean | null> = { |
| 375 | loggedIn: statusView.loggedIn, |
| 376 | authMethod: statusView.authMethod, |
| 377 | apiProvider: statusView.apiProvider, |
| 378 | } |
| 379 | if (statusView.authExpired) { |
| 380 | output.authExpired = true |
| 381 | } |
| 382 | if (statusView.apiKeySource) { |
| 383 | output.apiKeySource = statusView.apiKeySource |
| 384 | } |
no test coverage detected