@@ -4,6 +4,7 @@ export const smExtensionId = "intersystems-community.servermanager";
44
55import vscode = require( "vscode" ) ;
66import * as semver from "semver" ;
7+ import * as serverManager from "@intersystems-community/intersystems-servermanager" ;
78
89import { AtelierJob , Content , Response , ServerInfo } from "./api/atelier" ;
910export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript" ;
@@ -198,7 +199,7 @@ let reporter: TelemetryReporter = null;
198199
199200export let checkingConnection = false ;
200201
201- let serverManagerApi : any ;
202+ let serverManagerApi : serverManager . ServerManagerAPI ;
202203
203204// Map of the intersystems.server connection specs we have resolved via the API to that extension
204205const resolvedConnSpecs = new Map < string , any > ( ) ;
@@ -222,18 +223,26 @@ export async function resolveConnectionSpec(serverName: string): Promise<void> {
222223
223224// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
224225export async function resolvePassword ( serverSpec , ignoreUnauthenticated = false ) : Promise < void > {
225- const AUTHENTICATION_PROVIDER = "intersystems-server-credentials" ;
226- // This arises if setting says to use authentication provider
227226 if (
228227 // Connection isn't unauthenticated
229228 ( ! isUnauthenticated ( serverSpec . username ) || ignoreUnauthenticated ) &&
230229 // A password is missing
231230 typeof serverSpec . password == "undefined"
232231 ) {
233232 const scopes = [ serverSpec . name , serverSpec . username || "" ] ;
234- let session = await vscode . authentication . getSession ( AUTHENTICATION_PROVIDER , scopes , { silent : true } ) ;
233+
234+ // Handle Server Manager extension version < 3.8.0
235+ const account = serverManagerApi . getAccount ? serverManagerApi . getAccount ( serverSpec ) : undefined ;
236+
237+ let session = await vscode . authentication . getSession ( serverManager . AUTHENTICATION_PROVIDER , scopes , {
238+ silent : true ,
239+ account,
240+ } ) ;
235241 if ( ! session ) {
236- session = await vscode . authentication . getSession ( AUTHENTICATION_PROVIDER , scopes , { createIfNone : true } ) ;
242+ session = await vscode . authentication . getSession ( serverManager . AUTHENTICATION_PROVIDER , scopes , {
243+ createIfNone : true ,
244+ account,
245+ } ) ;
237246 }
238247 if ( session ) {
239248 // If original spec lacked username use the one obtained by the authprovider
@@ -1164,7 +1173,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11641173 }
11651174 const fileName = filePathNoWorkspaceArr . join ( "." ) ;
11661175 // Generate the new content
1167- const newContent = generateFileContent ( uri , fileName , Buffer . from ( await vscode . workspace . fs . readFile ( uri ) ) ) ;
1176+ const newContent = generateFileContent ( uri , fileName , await vscode . workspace . fs . readFile ( uri ) ) ;
11681177 // Write the new content to the file
11691178 return vscode . workspace . fs . writeFile ( uri , new TextEncoder ( ) . encode ( newContent . content . join ( "\n" ) ) ) ;
11701179 } )
0 commit comments