11use anyhow:: { Context , Result } ;
2- use runbeam_sdk:: { RunbeamClient , UserInfo , validate_jwt_token as sdk_validate_jwt, JwtValidationOptions } ;
2+ use runbeam_sdk:: {
3+ JwtValidationOptions , RunbeamClient , UserInfo , validate_jwt_token as sdk_validate_jwt,
4+ } ;
35use serde:: { Deserialize , Serialize } ;
46use std:: thread;
57use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
@@ -49,7 +51,10 @@ pub fn login() -> Result<()> {
4951 // Verify the token is still valid
5052 let validation_result = tokio:: runtime:: Runtime :: new ( )
5153 . expect ( "Failed to create Tokio runtime" )
52- . block_on ( sdk_validate_jwt ( & existing_auth. token , & JwtValidationOptions :: default ( ) ) ) ;
54+ . block_on ( sdk_validate_jwt (
55+ & existing_auth. token ,
56+ & JwtValidationOptions :: default ( ) ,
57+ ) ) ;
5358
5459 if validation_result. is_ok ( ) {
5560 println ! ( "✓ Already logged in with a valid token." ) ;
@@ -207,7 +212,10 @@ pub fn login() -> Result<()> {
207212 // Verify the token using SDK (RS256 with JWKS)
208213 let validation_result = tokio:: runtime:: Runtime :: new ( )
209214 . expect ( "Failed to create Tokio runtime" )
210- . block_on ( sdk_validate_jwt ( & token_clone, & JwtValidationOptions :: default ( ) ) ) ;
215+ . block_on ( sdk_validate_jwt (
216+ & token_clone,
217+ & JwtValidationOptions :: default ( ) ,
218+ ) ) ;
211219
212220 match validation_result {
213221 Ok ( jwt_claims) => {
@@ -291,7 +299,10 @@ pub fn authorize_harmony(
291299 debug ! ( "Validating JWT token before authorization..." ) ;
292300 let validation_result = tokio:: runtime:: Runtime :: new ( )
293301 . expect ( "Failed to create Tokio runtime" )
294- . block_on ( sdk_validate_jwt ( & auth. token , & JwtValidationOptions :: default ( ) ) ) ;
302+ . block_on ( sdk_validate_jwt (
303+ & auth. token ,
304+ & JwtValidationOptions :: default ( ) ,
305+ ) ) ;
295306
296307 match validation_result {
297308 Ok ( claims) => {
@@ -303,7 +314,10 @@ pub fn authorize_harmony(
303314 . as_secs ( ) as i64 ;
304315 let time_remaining = claims. exp - now;
305316 if time_remaining < 3600 {
306- println ! ( "⚠️ Warning: Your token expires in {} minutes." , time_remaining / 60 ) ;
317+ println ! (
318+ "⚠️ Warning: Your token expires in {} minutes." ,
319+ time_remaining / 60
320+ ) ;
307321 println ! ( " Consider running `runbeam login` to refresh your token." ) ;
308322 println ! ( ) ;
309323 }
@@ -399,7 +413,10 @@ pub fn authorize_harmony(
399413 if let Some ( stored_instance) = instances. iter_mut ( ) . find ( |i| i. id == instance_id) {
400414 stored_instance. gateway_id = Some ( auth_response. gateway . id . clone ( ) ) ;
401415 storage:: save_harmony_instances ( & instances) ?;
402- debug ! ( "Stored gateway_id {} for instance {}" , auth_response. gateway. id, instance_id) ;
416+ debug ! (
417+ "Stored gateway_id {} for instance {}" ,
418+ auth_response. gateway. id, instance_id
419+ ) ;
403420 }
404421
405422 // Send machine token to Harmony proxy instance
@@ -461,7 +478,9 @@ pub fn authorize_harmony(
461478 } else {
462479 // Interactive prompt
463480 println ! ( "📡 Upload local configuration to Runbeam Cloud?" ) ;
464- println ! ( " This will overwrite any configuration changes made on Runbeam Cloud." ) ;
481+ println ! (
482+ " This will overwrite any configuration changes made on Runbeam Cloud."
483+ ) ;
465484 print ! ( " Upload configuration? [y/N]: " ) ;
466485 std:: io:: Write :: flush ( & mut std:: io:: stdout ( ) ) . ok ( ) ;
467486
@@ -481,7 +500,9 @@ pub fn authorize_harmony(
481500 Err ( e) => {
482501 warn ! ( "Configuration upload failed: {}" , e) ;
483502 println ! ( "⚠️ Configuration upload failed: {}" , e) ;
484- println ! ( " Authorization is still valid. You can manually upload config with:" ) ;
503+ println ! (
504+ " Authorization is still valid. You can manually upload config with:"
505+ ) ;
485506 println ! ( " runbeam harmony:update --id {}" , instance_id) ;
486507 }
487508 }
@@ -583,7 +604,10 @@ pub fn verify_token() -> Result<()> {
583604 // Validate the token using SDK (async)
584605 let validation_result = tokio:: runtime:: Runtime :: new ( )
585606 . expect ( "Failed to create Tokio runtime" )
586- . block_on ( sdk_validate_jwt ( & auth. token , & JwtValidationOptions :: default ( ) ) ) ;
607+ . block_on ( sdk_validate_jwt (
608+ & auth. token ,
609+ & JwtValidationOptions :: default ( ) ,
610+ ) ) ;
587611
588612 match validation_result {
589613 Ok ( claims) => {
@@ -702,7 +726,10 @@ pub fn get_token(gateway_code: &str, raw: bool) -> Result<()> {
702726 // Output with context
703727 println ! ( "✅ Machine token retrieved successfully!" ) ;
704728 println ! ( ) ;
705- println ! ( "Gateway: {} ({})" , auth_response. gateway. name, auth_response. gateway. code) ;
729+ println ! (
730+ "Gateway: {} ({})" ,
731+ auth_response. gateway. name, auth_response. gateway. code
732+ ) ;
706733 println ! ( "Gateway ID: {}" , auth_response. gateway. id) ;
707734 println ! ( "Expires at: {}" , auth_response. expires_at) ;
708735 let expires_in_days = ( auth_response. expires_in / 86400.0 ) . round ( ) as i64 ;
@@ -715,7 +742,10 @@ pub fn get_token(gateway_code: &str, raw: bool) -> Result<()> {
715742 println ! ( "{}" , auth_response. machine_token) ;
716743 println ! ( ) ;
717744 println ! ( "Usage:" ) ;
718- println ! ( " export RUNBEAM_MACHINE_TOKEN=$(runbeam token:get -g {} --raw)" , gateway_code) ;
745+ println ! (
746+ " export RUNBEAM_MACHINE_TOKEN=$(runbeam token:get -g {} --raw)" ,
747+ gateway_code
748+ ) ;
719749 }
720750
721751 info ! ( "Token retrieved for gateway: {}" , auth_response. gateway. id) ;
0 commit comments