in server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/AmazonQTokenServiceManager.ts [191:258]
private handleSsoConnectionChange() {
const newConnectionType = this.features.credentialsProvider.getConnectionType()
this.logServiceState('Validate State of SSO Connection')
const noCreds = !this.features.credentialsProvider.hasCredentials('bearer')
const noConnectionType = newConnectionType === 'none'
if (noCreds || noConnectionType) {
// Connection was reset, wait for SSO connection token from client
this.log(
`No active SSO connection is detected: no ${noCreds ? 'credentials' : 'connection type'} provided. Resetting the client`
)
this.resetCodewhispererService()
this.connectionType = 'none'
this.state = 'PENDING_CONNECTION'
return
}
// Connection type hasn't change.
if (newConnectionType === this.connectionType) {
this.logging.debug(`Connection type did not change: ${this.connectionType}`)
return
}
// Connection type changed to 'builderId'
if (newConnectionType === 'builderId') {
this.log('Detected New connection type: builderId')
this.resetCodewhispererService()
// For the builderId connection type regional endpoint discovery chain is:
// region set by client -> runtime region -> default region
const clientParams = this.features.lsp.getClientInitializeParams()
this.createCodewhispererServiceInstances('builderId', clientParams?.initializationOptions?.aws?.region)
this.state = 'INITIALIZED'
this.log('Initialized Amazon Q service with builderId connection')
return
}
// Connection type changed to 'identityCenter'
if (newConnectionType === 'identityCenter') {
this.log('Detected New connection type: identityCenter')
this.resetCodewhispererService()
if (this.enableDeveloperProfileSupport) {
this.connectionType = 'identityCenter'
this.state = 'PENDING_Q_PROFILE'
this.logServiceState('Pending profile selection for IDC connection')
return
}
this.createCodewhispererServiceInstances('identityCenter')
this.state = 'INITIALIZED'
this.log('Initialized Amazon Q service with identityCenter connection')
return
}
this.logServiceState('Unknown Connection state')
}