@microsoft/vscode-azext-azureappservice
Advanced tools
Comparing version 2.1.1 to 2.1.2
import type { SiteConfigResource } from '@azure/arm-appservice'; | ||
import { IActionContext } from '@microsoft/vscode-azext-utils'; | ||
import { ParsedSite } from '../SiteClient'; | ||
import { AzExtGenericCredentials } from '@microsoft/vscode-azext-azureutils'; | ||
export declare enum RemoteDebugLanguage { | ||
@@ -8,2 +9,9 @@ Node = 0, | ||
} | ||
export declare function startRemoteDebug(context: IActionContext, site: ParsedSite, siteConfig: SiteConfigResource, language: RemoteDebugLanguage): Promise<void>; | ||
interface StartRemoteDebuggingOptions { | ||
credentials: AzExtGenericCredentials; | ||
site: ParsedSite; | ||
siteConfig: SiteConfigResource; | ||
language: RemoteDebugLanguage; | ||
} | ||
export declare function startRemoteDebug(context: IActionContext, options: StartRemoteDebuggingOptions): Promise<void>; | ||
export {}; |
@@ -28,3 +28,3 @@ "use strict"; | ||
})(RemoteDebugLanguage = exports.RemoteDebugLanguage || (exports.RemoteDebugLanguage = {})); | ||
function startRemoteDebug(context, site, siteConfig, language) { | ||
function startRemoteDebug(context, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -36,3 +36,3 @@ if (isRemoteDebugging) { | ||
try { | ||
yield startRemoteDebugInternal(context, site, siteConfig, language); | ||
yield startRemoteDebugInternal(context, options); | ||
} | ||
@@ -46,13 +46,11 @@ catch (error) { | ||
exports.startRemoteDebug = startRemoteDebug; | ||
function startRemoteDebugInternal(context, site, siteConfig, language) { | ||
function startRemoteDebugInternal(context, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: true }, (progress, token) => __awaiter(this, void 0, void 0, function* () { | ||
const localHostPortNumber = yield (0, vscode_azext_utils_1.findFreePort)(); | ||
const debugConfig = yield getDebugConfiguration(language, localHostPortNumber); | ||
const debugConfig = yield getDebugConfiguration(options.language, localHostPortNumber); | ||
const confirmEnableMessage = vscode.l10n.t('The configuration will be updated to enable remote debugging. Would you like to continue? This will restart the app.'); | ||
yield (0, remoteDebugCommon_1.setRemoteDebug)(context, true, confirmEnableMessage, undefined, site, siteConfig, progress, token, remoteDebugLink); | ||
yield (0, remoteDebugCommon_1.setRemoteDebug)(context, true, confirmEnableMessage, undefined, options.site, options.siteConfig, progress, token, remoteDebugLink); | ||
(0, remoteDebugCommon_1.reportMessage)(vscode.l10n.t('Starting tunnel proxy...'), progress, token); | ||
const client = yield site.createClient(context); | ||
const publishCredential = yield client.getWebAppPublishCredential(); | ||
const tunnelProxy = new TunnelProxy_1.TunnelProxy(localHostPortNumber, site, publishCredential); | ||
const tunnelProxy = new TunnelProxy_1.TunnelProxy(localHostPortNumber, options.site, options.credentials); | ||
yield (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('appService.remoteDebugStartProxy', (startContext) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -79,3 +77,3 @@ startContext.errorHandling.suppressDisplay = true; | ||
yield vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: true }, (innerProgress, innerToken) => __awaiter(this, void 0, void 0, function* () { | ||
yield (0, remoteDebugCommon_1.setRemoteDebug)(context, false, confirmDisableMessage, undefined, site, siteConfig, innerProgress, innerToken, remoteDebugLink); | ||
yield (0, remoteDebugCommon_1.setRemoteDebug)(context, false, confirmDisableMessage, undefined, options.site, options.siteConfig, innerProgress, innerToken, remoteDebugLink); | ||
})); | ||
@@ -82,0 +80,0 @@ } |
@@ -1,3 +0,2 @@ | ||
import type { User } from '@azure/arm-appservice'; | ||
import { IActionContext } from '@microsoft/vscode-azext-utils'; | ||
import { AzExtServiceClientCredentials, IActionContext } from '@microsoft/vscode-azext-utils'; | ||
import { CancellationToken } from 'vscode'; | ||
@@ -11,7 +10,7 @@ import { ParsedSite } from './SiteClient'; | ||
private _site; | ||
private _publishCredential; | ||
private _server; | ||
private _openSockets; | ||
private _isSsh; | ||
constructor(port: number, site: ParsedSite, publishCredential: User, isSsh?: boolean); | ||
private _credentials; | ||
constructor(port: number, site: ParsedSite, credentials: AzExtServiceClientCredentials, isSsh?: boolean); | ||
startProxy(context: IActionContext, token: CancellationToken): Promise<void>; | ||
@@ -18,0 +17,0 @@ dispose(): void; |
@@ -43,9 +43,9 @@ "use strict"; | ||
class TunnelProxy { | ||
constructor(port, site, publishCredential, isSsh = false) { | ||
constructor(port, site, credentials, isSsh = false) { | ||
this._port = port; | ||
this._site = site; | ||
this._publishCredential = publishCredential; | ||
this._server = (0, net_1.createServer)(); | ||
this._openSockets = []; | ||
this._isSsh = isSsh; | ||
this._credentials = credentials; | ||
} | ||
@@ -56,3 +56,4 @@ startProxy(context, token) { | ||
yield this.checkTunnelStatusWithRetry(context, token); | ||
yield this.setupTunnelServer(token); | ||
const bearerToken = (yield this._credentials.getToken()).token; | ||
yield this.setupTunnelServer(bearerToken, token); | ||
} | ||
@@ -97,6 +98,7 @@ catch (error) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const publishingUserName = (0, vscode_azext_utils_1.nonNullProp)(this._publishCredential, 'publishingUserName'); | ||
const password = (0, vscode_azext_utils_1.nonNullProp)(this._publishCredential, 'publishingPassword'); | ||
const client = yield (0, vscode_azext_azureutils_1.createGenericClient)(context, undefined); | ||
(0, vscode_azext_azureutils_1.addBasicAuthenticationCredentialsToClient)(client, publishingUserName, password); | ||
client.pipeline.addPolicy((0, core_rest_pipeline_1.bearerTokenAuthenticationPolicy)({ | ||
scopes: [], | ||
credential: this._credentials | ||
})); | ||
let tunnelStatus; | ||
@@ -106,3 +108,3 @@ try { | ||
method: 'GET', | ||
url: `https://${this._site.kuduHostName}/AppServiceTunnel/Tunnel.ashx?GetStatus&GetStatusAPIVer=2` | ||
url: `https://${this._site.kuduHostName}/AppServiceTunnel/Tunnel.ashx?GetStatus&GetStatusAPIVer=2`, | ||
})); | ||
@@ -166,3 +168,3 @@ extensionVariables_1.ext.outputChannel.appendLog(`[Tunnel] Checking status, body: ${response.bodyAsText}`); | ||
} | ||
setupTunnelServer(token) { | ||
setupTunnelServer(bearerToken, token) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -180,5 +182,5 @@ return new Promise((resolve, reject) => { | ||
'Cache-Control': 'no-cache', | ||
Pragma: 'no-cache' | ||
Pragma: 'no-cache', | ||
Authorization: `Bearer ${bearerToken}`, | ||
}, | ||
auth: `${this._publishCredential.publishingUserName}:${this._publishCredential.publishingPassword}`, | ||
}); | ||
@@ -185,0 +187,0 @@ this._openSockets.push(tunnelSocket); |
{ | ||
"name": "@microsoft/vscode-azext-azureappservice", | ||
"author": "Microsoft Corporation", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Common tools for developing Azure App Service extensions for VS Code", | ||
@@ -6,0 +6,0 @@ "tags": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6714
370501