Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Feature: Proxy validation and authentication (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Feb 6, 2018
1 parent 9332d2d commit 4d7e1a2
Show file tree
Hide file tree
Showing 17 changed files with 826 additions and 91 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ install:
- npm install
script:
- npm run build
- npm test
- npm run tslint

deploy:
Expand Down
7 changes: 5 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"outputCapture": "std",
"sourceMaps": true,
"preLaunchTask": "npm: build",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"env": {
"DEBUGGING": "1",
}
}
]
}
}
28 changes: 20 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
[![Build Status](https://travis-ci.org/Azure/get-proxy-settings.svg?branch=master)](https://travis-ci.org/Azure/get-proxy-settings)
[![npm version](https://badge.fury.io/js/get-proxy-settings.svg)](https://badge.fury.io/js/get-proxy-settings)

This library will read the system proxy setttings and return.
It will first try to read from the environment variable `HTTP_PROXY` and `HTTPS_PROXY`
On windows it will then look at the internet settings in the registry.
This library support
- Reading proxy settings from the `HTTP_PROXY` or `HTTPS_PROXY` environment variables
- Reading proxy settings from the `HTTP_PROXY` or `HTTPS_PROXY` node configuration
- Retrieveing the settings from the the ioternet settings on windows in the registry
- Validating the connection and asking for credentials if needed

## Install

Expand All @@ -16,22 +18,32 @@ npm install --save get-proxy-settings

**Import**
```js
// Default import
import getProxySettings from "get-proxy-settings";
// With named import
import { getProxySettings } from "get-proxy-settings";
import { getProxySettings, getAndTestProxySettings } from "get-proxy-settings";

// Or with commonjs
const getProxySettings = require("get-proxy-settings");
const { getProxySettings, getAndTestProxySettings } = require("get-proxy-settings");
```

**Use**
```js

async function my() {
async function basic() {
const proxy = await getProxySettings();
console.log("proxy", proxy.http, proxy.https);
}

// Get and validate the proxy settings

async function withValidation() {
async function login() {
// Do any async operation to retrieve the username and password of the user(prompt?)
return {username: "abc", password: "123"}
}

const proxy = await getAndTestProxySettings(login);
console.log("proxy", proxy.http, proxy.https);
}
```


Expand Down
Loading

0 comments on commit 4d7e1a2

Please sign in to comment.