Skip to content

Commit

Permalink
Fix last branch (#75)
Browse files Browse the repository at this point in the history
* Fix regression with Databricks Extension Auth

* update dependencies

* Fixes
  • Loading branch information
fjakobs committed Dec 11, 2023
1 parent 4af9a33 commit a022e9b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.3",
"@types/uuid": "^9.0.7",
"@types/vscode": "^1.85.0",
"@types/vscode": "^1.83.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@vscode/vsce": "^2.22.0",
Expand Down
8 changes: 4 additions & 4 deletions src/DatabricksCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/

import {ILanguageServer} from "@sqltools/types";
import {Headers as HeaderFields} from "./types";
import {HeadersInit} from "./types";
import {IExtension} from "@sqltools/types";

export class DatabricksCommandsClient {
constructor(private server: ILanguageServer) {}

async authenticate(headers: HeaderFields) {
async authenticate(headers: HeadersInit): Promise<HeadersInit> {
return await this.server.sendRequest("db/authenticate", headers);
}

Expand Down Expand Up @@ -55,15 +55,15 @@ export async function initDatabricksCommands(

await client.onRequest(
"db/authenticate",
async (headerFields: HeaderFields) => {
async (headerFields: HeadersInit) => {
const apiClient = await getApiClient();
const headers = new Headers(headerFields);
await apiClient.config.authenticate(headers);

return [...headers.entries()].reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
}, {} as HeaderFields);
}, {} as HeadersInit);
}
);

Expand Down
11 changes: 4 additions & 7 deletions src/ls/ExtensionAuthProvider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import IAuthentication from "@databricks/sql/dist/connection/contracts/IAuthentication";
import ITransport from "@databricks/sql/dist/connection/contracts/ITransport";
import {buildUserAgentString} from "@databricks/sql/dist/utils";
import {DatabricksCommandsClient} from "../DatabricksCommands";
import {Headers} from "../types";
import {HeadersInit} from "../types";

export class ExtensionAuthProvider implements IAuthentication {
private headers: Headers;
private headers: HeadersInit;

constructor(
private dbCommands: DatabricksCommandsClient,
Expand All @@ -15,10 +14,8 @@ export class ExtensionAuthProvider implements IAuthentication {
this.headers["User-Agent"] = buildUserAgentString(clientId);
}

async authenticate(transport: ITransport): Promise<ITransport> {
async authenticate(): Promise<HeadersInit> {
const headers = await this.dbCommands.authenticate(this.headers);
transport.setOptions("headers", headers);

return transport;
return headers;
}
}
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Headers = Record<string, string>;
export type HeadersInit = Record<string, string>;
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ __metadata:
languageName: node
linkType: hard

"@types/vscode@npm:^1.85.0":
"@types/vscode@npm:^1.83.0":
version: 1.85.0
resolution: "@types/vscode@npm:1.85.0"
checksum: d7934e55b8606d0df0ac60e6ce0877d3edd513b5bc150e06fababd888f328a6ba87e3eef71930fc8eae1bcce60ec6106dae89d149905cdad613e84f48a6d003e
Expand Down Expand Up @@ -4442,7 +4442,7 @@ __metadata:
"@types/mocha": ^10.0.6
"@types/node": ^18.19.3
"@types/uuid": ^9.0.7
"@types/vscode": ^1.85.0
"@types/vscode": ^1.83.0
"@typescript-eslint/eslint-plugin": ^6.13.2
"@typescript-eslint/parser": ^6.13.2
"@vscode/vsce": ^2.22.0
Expand Down

0 comments on commit a022e9b

Please sign in to comment.