@@ -273,6 +273,16 @@ pub enum TokenType {
273273 IamIdentityCenter ,
274274}
275275
276+ impl From < Option < & str > > for TokenType {
277+ fn from ( start_url : Option < & str > ) -> Self {
278+ match start_url {
279+ Some ( url) if url == START_URL => TokenType :: BuilderId ,
280+ None => TokenType :: BuilderId ,
281+ Some ( _) => TokenType :: IamIdentityCenter ,
282+ }
283+ }
284+ }
285+
276286#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
277287pub struct BuilderIdToken {
278288 pub access_token : Secret ,
@@ -494,7 +504,7 @@ impl BuilderIdToken {
494504 }
495505
496506 pub fn token_type ( & self ) -> TokenType {
497- token_type_from_start_url ( self . start_url . as_deref ( ) )
507+ TokenType :: from ( self . start_url . as_deref ( ) )
498508 }
499509
500510 /// Check if the token is for the internal amzn start URL (`https://amzn.awsapps.com/start`),
@@ -505,14 +515,6 @@ impl BuilderIdToken {
505515 }
506516}
507517
508- pub fn token_type_from_start_url ( start_url : Option < & str > ) -> TokenType {
509- match start_url {
510- Some ( url) if url == START_URL => TokenType :: BuilderId ,
511- None => TokenType :: BuilderId ,
512- Some ( _) => TokenType :: IamIdentityCenter ,
513- }
514- }
515-
516518pub enum PollCreateToken {
517519 Pending ,
518520 Complete ,
@@ -568,7 +570,7 @@ pub async fn poll_create_token(
568570 error ! ( ?err, "Failed to poll for builder id token" ) ;
569571
570572 // Send telemetry for device code failure
571- let auth_method = match token_type_from_start_url ( start_url. as_deref ( ) ) {
573+ let auth_method = match TokenType :: from ( start_url. as_deref ( ) ) {
572574 TokenType :: BuilderId => "BuilderId" ,
573575 TokenType :: IamIdentityCenter => "IdentityCenter" ,
574576 } ;
0 commit comments