Skip to content

Commit 13cd37f

Browse files
Use proxy-lib package when working behind proxy (#3253)
The `proxy-lib` package provides required methods for setting and getting proxy. Its implementation is more secure when stroing credentials, so switch to it instead of current implementation. Remove the credentials-manager from CLI as it is no longer needed. Remove the CredentialsManager.exe as well and its source code. Fix the error `Cannot read property ExceptionMessage of null` when wokring behind proxy - add correct null checks. Fix tracking to google analytics behind proxy - pass the proxy URL to Universal Analytics module.
1 parent decd306 commit 13cd37f

File tree

5 files changed

+149
-10
lines changed

5 files changed

+149
-10
lines changed

lib/declarations.d.ts

-8
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,6 @@ interface IInfoService {
432432
printComponentsInfo(): Promise<void>;
433433
}
434434

435-
/**
436-
* Describes standard username/password type credentials.
437-
*/
438-
interface ICredentials {
439-
username: string;
440-
password: string;
441-
}
442-
443435
/**
444436
* Describes properties needed for uploading a package to iTunes Connect
445437
*/

lib/services/analytics/google-analytics-provider.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export class GoogleAnalyticsProvider implements IGoogleAnalyticsProvider {
1010
constructor(private clientId: string,
1111
private $staticConfig: IStaticConfig,
1212
private $analyticsSettingsService: IAnalyticsSettingsService,
13-
private $logger: ILogger) {
13+
private $logger: ILogger,
14+
private $proxyService: IProxyService) {
1415
}
1516

1617
public async trackHit(trackInfo: IGoogleAnalyticsData): Promise<void> {
@@ -27,11 +28,16 @@ export class GoogleAnalyticsProvider implements IGoogleAnalyticsProvider {
2728
}
2829

2930
private async track(gaTrackingId: string, trackInfo: IGoogleAnalyticsData, sessionId: string): Promise<void> {
31+
const proxySettings = await this.$proxyService.getCache();
32+
const proxy = proxySettings && proxySettings.proxy;
3033
const visitor = ua({
3134
tid: gaTrackingId,
3235
cid: this.clientId,
3336
headers: {
3437
["User-Agent"]: this.$analyticsSettingsService.getUserAgentString(`tnsCli/${this.$staticConfig.version}`)
38+
},
39+
requestOptions: {
40+
proxy
3541
}
3642
});
3743

npm-shrinkwrap.json

+140
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"plistlib": "0.2.1",
6565
"progress-stream": "1.1.1",
6666
"properties-parser": "0.2.3",
67+
"proxy-lib": "0.2.0",
6768
"qr-image": "3.2.0",
6869
"request": "2.81.0",
6970
"semver": "5.3.0",

0 commit comments

Comments
 (0)