From de41e5f475fc71a99934682dbbafa290c1cccc3f Mon Sep 17 00:00:00 2001 From: Josh Pinkney Date: Wed, 23 Apr 2025 16:05:16 -0400 Subject: [PATCH 1/2] fix(amazonq): send sso startUrl on token update --- packages/amazonq/src/lsp/auth.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/amazonq/src/lsp/auth.ts b/packages/amazonq/src/lsp/auth.ts index 4eb92e40788..ed5753e9d82 100644 --- a/packages/amazonq/src/lsp/auth.ts +++ b/packages/amazonq/src/lsp/auth.ts @@ -4,10 +4,12 @@ */ import { + bearerCredentialsUpdateRequestType, ConnectionMetadata, NotificationType, RequestType, ResponseMessage, + UpdateCredentialsParams, } from '@aws/language-server-runtimes/protocol' import * as jose from 'jose' import * as crypto from 'crypto' @@ -81,7 +83,7 @@ export class AmazonQLspAuth { token, }) - await this.client.sendRequest(notificationTypes.updateBearerToken.method, request) + await this.client.sendRequest(bearerCredentialsUpdateRequestType.method, request) this.client.info(`UpdateBearerToken: ${JSON.stringify(request)}`) } @@ -96,7 +98,7 @@ export class AmazonQLspAuth { return interval } - private async createUpdateCredentialsRequest(data: any) { + private async createUpdateCredentialsRequest(data: any): Promise { const payload = new TextEncoder().encode(JSON.stringify({ data })) const jwt = await new jose.CompactEncrypt(payload) @@ -105,6 +107,11 @@ export class AmazonQLspAuth { return { data: jwt, + metadata: { + sso: { + startUrl: AuthUtil.instance.auth.startUrl, + }, + }, encrypted: true, } } From 0c9dc99b9cd0868d465d84d988dce3528bab6098 Mon Sep 17 00:00:00 2001 From: Josh Pinkney Date: Wed, 23 Apr 2025 16:26:22 -0400 Subject: [PATCH 2/2] remove connection metadata --- packages/amazonq/src/lsp/client.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index 7e612102c23..fa45e269114 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -10,7 +10,6 @@ import { LanguageClient, LanguageClientOptions, RequestType } from 'vscode-langu import { InlineCompletionManager } from '../app/inline/completion' import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth' import { - ConnectionMetadata, CreateFilesParams, DeleteFilesParams, DidChangeWorkspaceFoldersParams, @@ -164,14 +163,6 @@ export async function startLanguageServer( const auth = new AmazonQLspAuth(client) return client.onReady().then(async () => { - // Request handler for when the server wants to know about the clients auth connnection. Must be registered before the initial auth init call - client.onRequest(notificationTypes.getConnectionMetadata.method, () => { - return { - sso: { - startUrl: AuthUtil.instance.auth.startUrl, - }, - } - }) await auth.refreshConnection() if (Experiments.instance.get('amazonqLSPInline', false)) {