
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Proxy library used in NativeScript tooling. This library gives you methods to get, set and clear proxy settings respected by NativeScript tooling.
Proxy library used in NativeScript tooling. This library gives you methods to get, set and clear proxy settings respected by NativeScript tooling.
This method returns the proxy information. In case there's no proxy settings file, the returned promise is resolved with null.
/**
* Get information about current proxy settings.
* @param {string | { credentialsKey: string, userSpecifiedSettingsFilePath: string }} params @optional CredentialsKey and path to file from which to get the information.
* @returns {Promise<{ proxy: string, rejectUnauthorized: boolean, username: string, password: string, protocol: string, port: string, hostname: string }>} Information about proxy settings
*/
getProxySettings(params: string | { credentialsKey: string, userSpecifiedSettingsFilePath: string }): Promise<{proxy: string, rejectUnauthorized: boolean, username: string, password: string, protocol: string, port: string, hostname: string}>;
credentials key only - in this case the settings will be read from default location:const proxyLib = require("proxy-lib");
proxyLib.getProxySettings({ credentialsKey: "myCredKey" })
.then(proxySettings => console.log(proxySettings))
.catch(err => console.error("Error while getting proxy settings.", err));
credentialsKey and userSpecifiedSettingsFilePath - proxy settings will be read from this file:const proxyLib = require("proxy-lib");
proxyLib.getProxySettings({ credentialsKey: "myCredKey", userSpecifiedSettingsFilePath: "~/.local/share/myProxyFile.json" })
.then(proxySettings => console.log(proxySettings))
.catch(err => console.error("Error while getting proxy settings.", err));
const proxyLib = require("proxy-lib");
proxyLib.getProxySettings("myCredKey")
.then(proxySettings => console.log(proxySettings))
.catch(err => console.error("Error while getting proxy settings.", err));
This method sets the proxy information to a specified file (or default location). In case proxy requires authentication, you can pass credentials and they'll be stored securely in Windows Credentials Manager.
/**
* Sets new proxy settings.
* @param {string | { proxyUrl: string, credentialsKey: string, rejectUnauthorized: boolean, username: string, password: string, userSpecifiedSettingsFilePath: string }} params Proxy settings
* @returns {Promise<void>}
*/
setProxySettings(params: string | { proxyUrl: string, credentialsKey: string, rejectUnauthorized: boolean, username: string, password: string, userSpecifiedSettingsFilePath: string }): Promise<void>;
const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888", credentialsKey: "myCredKey", rejectUnauthorized: true, username: "myUsername", password: "myPassword", userSpecifiedSettingsFilePath: "~/.local/share/myProxyFile.json" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
proxyUrl - this parameter is mandatory and it shows the url of the proxy. You can pass it as a single string argument of the method or as part of an object:const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
or
const proxyLib = require("proxy-lib");
proxyLib.setProxySettings("http://192.168.1.102:8888")
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
The proxyUrl may also contain the authentication information, in this case the call will be:
const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://myUsername:myPassword@192.168.1.102:8888" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
or
const proxyLib = require("proxy-lib");
proxyLib.setProxySettings("http://myUsername:myPassword@192.168.1.102:8888")
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
rejectUnauthorized - this parameter defines if Node.js errors for invalid certificates should be respected. In case you do not pass this value, it will be set to true, so based on the configuration, errors like self signed certificate in certificate chain may be thrown. Setting this value to false will disregard such errors.const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888", rejectUnauthorized: false })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
username and password - these parameters should be used in case the proxy requires basic authentication. Currently you can use them only on Windows. Passing only one of the values will throw error. You can either pass the two arguments or include the authentication in the proxyUrl as shown above. The passed values will be saved in Windows Credential Manager.const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888", username: "myUsername", password: "myPassword" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
credentialsKey - this parameter defines the name of the entry in Windows Credential Manager, where the username and password will be persisted. If it is not passed, it has default value. This parameter has no effect in case there's no authentication arguments passed.const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888", username: "myUsername", password: "myPassword", credentialsKey: "myKey" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
userSpecifiedSettingsFilePath - this parameter defines the path to the file where proxy settings (without authentication) will be persisted. In case it is not passed, it has default value.const proxyLib = require("proxy-lib");
proxyLib.setProxySettings({ proxyUrl: "http://192.168.1.102:8888", userSpecifiedSettingsFilePath: "~/.local/share/myProxyFile.json" })
.then(() => console.log("Successfully set proxy settings."))
.catch(err => console.error("Unable to set proxy settings", err));
This method clears the proxy settings by removing the proxy file and removing the specified entry from Credentials Manager.
/**
* Clears proxy settings.
* @param {string | { credentialsKey: string, userSpecifiedSettingsFilePath: string }} params @optional Options for credentials key and path to be cleaned.
* @returns {Promise<void>}
*/
clearProxySettings(params: string | { credentialsKey: string, userSpecifiedSettingsFilePath: string }): Promise<void>;
const proxyLib = require("proxy-lib");
proxyLib.clearProxySettings()
.then(() => console.log("Successfully cleared proxy settings file."))
.catch(err => console.error("Unable to clear proxy settings", err));
const proxyLib = require("proxy-lib");
proxyLib.clearProxySettings({ userSpecifiedSettingsFilePath: "~/.local/share/myProxyFile.json" })
.then(() => console.log("Successfully cleared custom proxy settings file."))
.catch(err => console.error("Unable to clear proxy settings", err));
const proxyLib = require("proxy-lib");
proxyLib.clearProxySettings({ credentialsKey: "myKey" })
.then(() => console.log("Successfully cleared custom proxy settings file and custom entry."))
.catch(err => console.error("Unable to clear proxy settings", err));
FAQs
Proxy library used in NativeScript tooling. This library gives you methods to get, set and clear proxy settings respected by NativeScript tooling.
We found that proxy-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.