Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/amazonq/src/lsp/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)}`)
}
Expand All @@ -96,7 +98,7 @@ export class AmazonQLspAuth {
return interval
}

private async createUpdateCredentialsRequest(data: any) {
private async createUpdateCredentialsRequest(data: any): Promise<UpdateCredentialsParams> {
const payload = new TextEncoder().encode(JSON.stringify({ data }))

const jwt = await new jose.CompactEncrypt(payload)
Expand All @@ -105,6 +107,11 @@ export class AmazonQLspAuth {

return {
data: jwt,
metadata: {
sso: {
startUrl: AuthUtil.instance.auth.startUrl,
},
},
encrypted: true,
}
}
Expand Down
9 changes: 0 additions & 9 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<ConnectionMetadata, Error>(notificationTypes.getConnectionMetadata.method, () => {
return {
sso: {
startUrl: AuthUtil.instance.auth.startUrl,
},
}
})
await auth.refreshConnection()

if (Experiments.instance.get('amazonqLSPInline', false)) {
Expand Down