@@ -243,6 +243,98 @@ export function register(program: Command): void {
243243 } ) ,
244244 ) ;
245245
246+ computers !
247+ . command ( "viewer-password <computer-id>" )
248+ . alias ( "password" )
249+ . description ( "Show external desktop viewer-password status" )
250+ . option ( "--json" , "Output as JSON" )
251+ . action ( ( id : string , opts : JsonOptions ) =>
252+ runAction ( async ( ) => {
253+ const raw = unwrap < Record < string , unknown > > (
254+ await client ( ) . apiGet < unknown > (
255+ apiPath ( `/computers/${ enc ( id ) } /viewer-password` ) ,
256+ ) ,
257+ ) ;
258+
259+ if ( isJsonMode ( opts ) ) {
260+ console . log ( JSON . stringify ( raw , null , 2 ) ) ;
261+ return ;
262+ }
263+
264+ printBanner ( { subtitle : "External desktop viewer password" } ) ;
265+ console . log (
266+ kvPanel ( [
267+ { icon : icon . info , label : "computer" , value : chalk . dim ( id ) } ,
268+ {
269+ label : "password_set" ,
270+ value : raw [ "password_set" ] ? chalk . green ( "yes" ) : chalk . yellow ( "no" ) ,
271+ } ,
272+ ...( raw [ "viewer_password_set_at" ] || raw [ "password_set_at" ]
273+ ? [
274+ {
275+ label : "set_at" ,
276+ value : chalk . dim (
277+ String ( raw [ "viewer_password_set_at" ] ?? raw [ "password_set_at" ] ) ,
278+ ) ,
279+ } ,
280+ ]
281+ : [ ] ) ,
282+ ] ) ,
283+ ) ;
284+ console . log ( ) ;
285+ console . log (
286+ hintBlock ( "Use" , [
287+ `miosa computers rotate-viewer-password ${ id } ` ,
288+ "Authenticated platform desktop links do not need this password." ,
289+ ] ) ,
290+ ) ;
291+ console . log ( ) ;
292+ } ) ,
293+ ) ;
294+
295+ computers !
296+ . command ( "rotate-viewer-password <computer-id>" )
297+ . alias ( "rotate-password" )
298+ . description ( "Rotate and print the external desktop viewer password once" )
299+ . option ( "--json" , "Output as JSON" )
300+ . action ( ( id : string , opts : JsonOptions ) =>
301+ runAction ( async ( ) => {
302+ const raw = unwrap < Record < string , unknown > > (
303+ await client ( ) . apiPost < unknown > (
304+ apiPath ( `/computers/${ enc ( id ) } /viewer-password/rotate` ) ,
305+ { } ,
306+ ) ,
307+ ) ;
308+
309+ if ( isJsonMode ( opts ) ) {
310+ console . log ( JSON . stringify ( raw , null , 2 ) ) ;
311+ return ;
312+ }
313+
314+ const password = String ( raw [ "viewer_password" ] ?? raw [ "password" ] ?? "" ) ;
315+ printBanner ( { subtitle : "Rotated external viewer password" } ) ;
316+ console . log (
317+ kvPanel ( [
318+ { icon : icon . ok , label : "computer" , value : chalk . dim ( id ) } ,
319+ {
320+ label : "viewer_password" ,
321+ value : password ? chalk . bold ( password ) : chalk . dim ( "not returned" ) ,
322+ } ,
323+ ...( raw [ "rotated_at" ]
324+ ? [ { label : "rotated_at" , value : chalk . dim ( String ( raw [ "rotated_at" ] ) ) } ]
325+ : [ ] ) ,
326+ ] ) ,
327+ ) ;
328+ console . log ( ) ;
329+ console . log (
330+ chalk . yellow (
331+ "This password is for raw external desktop viewer links. Store it now; it may not be returned again." ,
332+ ) ,
333+ ) ;
334+ console . log ( ) ;
335+ } ) ,
336+ ) ;
337+
246338 // Workspace-aware create (skipped in resourceCommands via skipCommands).
247339 addDataOption (
248340 computers !
0 commit comments