Skip to content

Commit 8a297b8

Browse files
authored
fix(amazonq): Update initializationOptions extension name (#6468)
## Problem Initialization name is just dummy text for now. We should consider updating it to the c9/toolkit one ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c363389 commit 8a297b8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/amazonq/src/lsp/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { registerInlineCompletion } from '../app/inline/completion'
1111
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
14-
import { ResourcePaths, Settings, createServerOptions, globals } from 'aws-core-vscode/shared'
14+
import { ResourcePaths, Settings, oidcClientName, createServerOptions, globals } from 'aws-core-vscode/shared'
1515

1616
const localize = nls.loadMessageBundle()
1717

@@ -48,7 +48,7 @@ export async function startLanguageServer(extensionContext: vscode.ExtensionCont
4848
name: env.appName,
4949
version: version,
5050
extension: {
51-
name: `AWS IDE Extensions for VSCode`, // TODO change this to C9/Amazon
51+
name: oidcClientName(),
5252
version: '0.0.1',
5353
},
5454
clientId: crypto.randomUUID(),

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

Lines changed: 4 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 { oidcClientName, isAmazonQ } from '../../shared/extensionUtilities'
3030
import { randomBytes, createHash } from 'crypto'
3131
import { localize } from '../../shared/utilities/vsCodeUtils'
3232
import { randomUUID } from '../../shared/crypto'
@@ -438,10 +438,9 @@ function getSessionDuration(id: string) {
438438
*/
439439
export class DeviceFlowAuthorization extends SsoAccessTokenProvider {
440440
override async registerClient(): Promise<ClientRegistration> {
441-
const companyName = getIdeProperties().company
442441
return this.oidc.registerClient(
443442
{
444-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
443+
clientName: oidcClientName(),
445444
clientType: clientRegistrationType,
446445
scopes: this.profile.scopes,
447446
},
@@ -543,11 +542,10 @@ export class DeviceFlowAuthorization extends SsoAccessTokenProvider {
543542
*/
544543
class AuthFlowAuthorization extends SsoAccessTokenProvider {
545544
override async registerClient(): Promise<ClientRegistration> {
546-
const companyName = getIdeProperties().company
547545
return this.oidc.registerClient(
548546
{
549547
// All AWS extensions (Q, Toolkit) for a given IDE use the same client name.
550-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
548+
clientName: oidcClientName(),
551549
clientType: clientRegistrationType,
552550
scopes: this.profile.scopes,
553551
grantTypes: [authorizationGrantType, refreshGrantType],
@@ -653,11 +651,10 @@ class WebAuthorization extends SsoAccessTokenProvider {
653651
private redirectUri = 'http://127.0.0.1:54321/oauth/callback'
654652

655653
override async registerClient(): Promise<ClientRegistration> {
656-
const companyName = getIdeProperties().company
657654
return this.oidc.registerClient(
658655
{
659656
// All AWS extensions (Q, Toolkit) for a given IDE use the same client name.
660-
clientName: isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`,
657+
clientName: oidcClientName(),
661658
clientType: clientRegistrationType,
662659
scopes: this.profile.scopes,
663660
grantTypes: [authorizationGrantType, refreshGrantType],

packages/core/src/shared/extensionUtilities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export function productName() {
4848
return isAmazonQ() ? 'Amazon Q' : `${getIdeProperties().company} Toolkit`
4949
}
5050

51+
/** Gets the client name stored in oidc */
52+
export const oidcClientName = once(_oidcClientName)
53+
function _oidcClientName() {
54+
const companyName = getIdeProperties().company
55+
return isCloud9() ? `${companyName} Cloud9` : `${companyName} IDE Extensions for VSCode`
56+
}
57+
5158
export const getExtensionId = () => {
5259
return isAmazonQ() ? VSCODE_EXTENSION_ID.amazonq : VSCODE_EXTENSION_ID.awstoolkit
5360
}

0 commit comments

Comments
 (0)