@@ -50,9 +50,6 @@ export const codeWhispererCoreScopes = [...scopesCodeWhispererCore]
5050export const codeWhispererChatScopes = [ ...codeWhispererCoreScopes , ...scopesCodeWhispererChat ]
5151export const amazonQScopes = [ ...codeWhispererChatScopes , ...scopesGumby , ...scopesFeatureDev ]
5252
53- function isValidSageMakerConnection ( conn ?: Connection ) {
54- return isIamConnection ( conn ) || isSsoConnection ( conn )
55- }
5653/**
5754 * "Core" are the CW scopes that existed before the addition of new scopes
5855 * for Amazon Q.
@@ -63,15 +60,15 @@ export const isValidCodeWhispererCoreConnection = (conn?: Connection): conn is C
6360 }
6461
6562 return (
66- isValidSageMakerConnection ( conn ) ||
63+ ( isSageMaker ( ) && isIamConnection ( conn ) ) ||
6764 ( isCloud9 ( 'codecatalyst' ) && isIamConnection ( conn ) ) ||
6865 ( isSsoConnection ( conn ) && hasScopes ( conn , codeWhispererCoreScopes ) )
6966 )
7067}
7168/** Superset that includes all of CodeWhisperer + Amazon Q */
7269export const isValidAmazonQConnection = ( conn ?: Connection ) : conn is Connection => {
7370 return (
74- isValidSageMakerConnection ( conn ) ||
71+ ( isSageMaker ( ) && isIamConnection ( conn ) ) ||
7572 ( ( isSsoConnection ( conn ) || isBuilderIdConnection ( conn ) ) &&
7673 isValidCodeWhispererCoreConnection ( conn ) &&
7774 hasScopes ( conn , amazonQScopes ) )
@@ -444,6 +441,10 @@ export class AuthUtil {
444441 return buildFeatureAuthState ( AuthStates . disconnected )
445442 }
446443
444+ if ( ! isSsoConnection ( conn ) && ! isSageMaker ( ) ) {
445+ throw new ToolkitError ( `Connection "${ conn . id } " is not a valid type: ${ conn . type } ` )
446+ }
447+
447448 // default to expired to indicate reauth is needed if unmodified
448449 const state : FeatureAuthState = buildFeatureAuthState ( AuthStates . expired )
449450
0 commit comments