Skip to content

Commit e72f746

Browse files
committed
fix(amazonq): Update initializationOptions extension name
1 parent dfff38c commit e72f746

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/amazonq/src/lsp/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
1414
import { ResourcePaths, createServerOptions } from 'aws-core-vscode/shared'
15+
import { AuthUtils } from 'aws-core-vscode/auth'
1516

1617
const localize = nls.loadMessageBundle()
1718

@@ -45,7 +46,7 @@ export async function startLanguageServer(extensionContext: vscode.ExtensionCont
4546
name: env.appName,
4647
version: version,
4748
extension: {
48-
name: `AWS IDE Extensions for VSCode`, // TODO change this to C9/Amazon
49+
name: AuthUtils.clientName(),
4950
version: '0.0.1',
5051
},
5152
clientId: crypto.randomUUID(),

packages/core/src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { AwsLoginWithBrowser, AwsRefreshCredentials, telemetry } from '../../sha
2626
import { indent, toBase64URL } from '../../shared/utilities/textUtilities'
2727
import { AuthSSOServer } from './server'
2828
import { CancellationError, sleep } from '../../shared/utilities/timeoutUtils'
29-
import { getIdeProperties, isAmazonQ, isCloud9 } from '../../shared/extensionUtilities'
29+
import { isAmazonQ } from '../../shared/extensionUtilities'
3030
import { randomBytes, createHash } from 'crypto'
3131
import { localize } from '../../shared/utilities/vsCodeUtils'
3232
import { randomUUID } from '../../shared/crypto'
@@ -39,6 +39,7 @@ import { asStringifiedStack } from '../../shared/telemetry/spans'
3939
import { showViewLogsMessage } from '../../shared/utilities/messages'
4040
import _ from 'lodash'
4141
import { builderIdStartUrl } from './constants'
42+
import { clientName } from '../utils'
4243

4344
export const authenticationPath = 'sso/authenticated'
4445

@@ -451,10 +452,9 @@ function getSessionDuration(id: string) {
451452
*/
452453
export class DeviceFlowAuthorization extends SsoAccessTokenProvider {
453454
override async registerClient(): Promise<ClientRegistration> {
454-
const companyName = getIdeProperties().company
455455
return this.oidc.registerClient(
456456
{
457-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
457+
clientName: clientName(),
458458
clientType: clientRegistrationType,
459459
scopes: this.profile.scopes,
460460
},
@@ -556,11 +556,10 @@ export class DeviceFlowAuthorization extends SsoAccessTokenProvider {
556556
*/
557557
class AuthFlowAuthorization extends SsoAccessTokenProvider {
558558
override async registerClient(): Promise<ClientRegistration> {
559-
const companyName = getIdeProperties().company
560559
return this.oidc.registerClient(
561560
{
562561
// All AWS extensions (Q, Toolkit) for a given IDE use the same client name.
563-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
562+
clientName: clientName(),
564563
clientType: clientRegistrationType,
565564
scopes: this.profile.scopes,
566565
grantTypes: [authorizationGrantType, refreshGrantType],
@@ -666,11 +665,10 @@ class WebAuthorization extends SsoAccessTokenProvider {
666665
private redirectUri = 'http://127.0.0.1:54321/oauth/callback'
667666

668667
override async registerClient(): Promise<ClientRegistration> {
669-
const companyName = getIdeProperties().company
670668
return this.oidc.registerClient(
671669
{
672670
// All AWS extensions (Q, Toolkit) for a given IDE use the same client name.
673-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
671+
clientName: clientName(),
674672
clientType: clientRegistrationType,
675673
scopes: this.profile.scopes,
676674
grantTypes: [authorizationGrantType, refreshGrantType],

packages/core/src/auth/utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { TreeNode } from '../shared/treeview/resourceTreeDataProvider'
2020
import { createInputBox } from '../shared/ui/inputPrompter'
2121
import { CredentialSourceId, telemetry } from '../shared/telemetry/telemetry'
2222
import { createCommonButtons, createExitButton, createHelpButton, createRefreshButton } from '../shared/ui/buttons'
23-
import { getIdeProperties, isAmazonQ } from '../shared/extensionUtilities'
23+
import { getIdeProperties, isAmazonQ, isCloud9 } from '../shared/extensionUtilities'
2424
import { addScopes, getDependentAuths } from './secondaryAuth'
2525
import { DevSettings } from '../shared/settings'
2626
import { createRegionPrompter } from '../shared/ui/common/region'
@@ -60,6 +60,7 @@ import { EnvVarsCredentialsProvider } from './providers/envVarsCredentialsProvid
6060
import { showMessageWithUrl } from '../shared/utilities/messages'
6161
import { credentialHelpUrl } from '../shared/constants'
6262
import { ExtStartUpSource } from '../shared/telemetry/util'
63+
import { once } from '../shared/utilities/functionUtils'
6364

6465
// iam-only excludes Builder ID and IAM Identity Center from the list of valid connections
6566
// TODO: Understand if "iam" should include these from the list at all
@@ -800,3 +801,9 @@ export async function getAuthType() {
800801
}
801802
return authType
802803
}
804+
805+
export const clientName = once(_clientName)
806+
function _clientName() {
807+
const companyName = getIdeProperties().company
808+
return isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`
809+
}

0 commit comments

Comments
 (0)