@@ -4,6 +4,7 @@ export const smExtensionId = "intersystems-community.servermanager";
4
4
5
5
import vscode = require( "vscode" ) ;
6
6
import * as semver from "semver" ;
7
+ import * as serverManager from "@intersystems-community/intersystems-servermanager" ;
7
8
8
9
import { AtelierJob , Content , Response , ServerInfo } from "./api/atelier" ;
9
10
export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript" ;
@@ -198,7 +199,7 @@ let reporter: TelemetryReporter = null;
198
199
199
200
export let checkingConnection = false ;
200
201
201
- let serverManagerApi : any ;
202
+ let serverManagerApi : serverManager . ServerManagerAPI ;
202
203
203
204
// Map of the intersystems.server connection specs we have resolved via the API to that extension
204
205
const resolvedConnSpecs = new Map < string , any > ( ) ;
@@ -222,18 +223,26 @@ export async function resolveConnectionSpec(serverName: string): Promise<void> {
222
223
223
224
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
224
225
export 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
227
226
if (
228
227
// Connection isn't unauthenticated
229
228
( ! isUnauthenticated ( serverSpec . username ) || ignoreUnauthenticated ) &&
230
229
// A password is missing
231
230
typeof serverSpec . password == "undefined"
232
231
) {
233
232
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
+ } ) ;
235
241
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
+ } ) ;
237
246
}
238
247
if ( session ) {
239
248
// 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> {
1164
1173
}
1165
1174
const fileName = filePathNoWorkspaceArr . join ( "." ) ;
1166
1175
// 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 ) ) ;
1168
1177
// Write the new content to the file
1169
1178
return vscode . workspace . fs . writeFile ( uri , new TextEncoder ( ) . encode ( newContent . content . join ( "\n" ) ) ) ;
1170
1179
} )
0 commit comments