Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hmpo-model

Package Overview
Dependencies
Maintainers
0
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-model - npm Package Compare versions

Comparing version 5.0.1 to 6.0.0

.husky/pre-push

30

lib/remote-model.js

@@ -9,3 +9,2 @@ 'use strict';

const ModelError = require('./model-error');
const DEFAULT_TIMEOUT = 60000;

@@ -26,3 +25,3 @@

this.logger = require('hmpo-logger');
} catch (e) {
} catch {
/* istanbul ignore next */

@@ -136,17 +135,8 @@ console.warn('Warning: ' + this.options.label + ': Unable to find hmpo-logger for logging, using console instead!');

const getAuth = u =>
u.username && u.password ? decodeURIComponent(`${u.username}:${u.password}`) :
u.username ? decodeURIComponent(u.username) : null;
const getPath = u => u.pathname + u.search + u.hash;
const options = Object.assign({
host: proxyUrl.hostname,
port: proxyUrl.port,
protocol: proxyUrl.protocol,
path: getPath(proxyUrl),
auth: getAuth(proxyUrl),
const options = {
headers: this.options.headers || {},
keepAlive: false,
maxSockets: 1,
keepAlive: false
}, proxy);
...proxy
};

@@ -156,8 +146,8 @@ const isHttps = (new URL(url).protocol === 'https:');

if (isHttps) {
const HttpsProxyAgent = require('https-proxy-agent');
const agent = new HttpsProxyAgent(options);
const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent(proxyUrl, options);
return { https: agent };
} else {
const HttpProxyAgent = require('http-proxy-agent');
const agent = new HttpProxyAgent(options);
const { HttpProxyAgent } = require('http-proxy-agent');
const agent = new HttpProxyAgent(proxyUrl, options);
return { http: agent };

@@ -164,0 +154,0 @@ }

{
"name": "hmpo-model",
"version": "5.0.1",
"version": "6.0.0",
"description": "Simple model for interacting with http/rest apis.",

@@ -12,3 +12,4 @@ "main": "index.js",

"unit": "nyc --reporter=lcov --reporter=text-summary _mocha test/ --recursive --require test/helper",
"check-coverage": "nyc check-coverage"
"check-coverage": "nyc check-coverage",
"prepare": "husky"
},

@@ -22,3 +23,3 @@ "repository": {

"engines": {
"node": ">=14"
"node": "20.x || 22.x"
},

@@ -30,6 +31,6 @@ "bugs": {

"dependencies": {
"debug": "^4.3.6",
"debug": "^4.3.7",
"got": "<12",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
"lodash.kebabcase": "^4.1.1"

@@ -39,9 +40,11 @@ },

"chai": "^4.5.0",
"eslint": "^8.57.0",
"hmpo-logger": "^7.0.2",
"mocha": "^10.7.0",
"nyc": "^17.0.0",
"proxyquire": "^2.0.0",
"sinon": "^18.0.0",
"sinon-chai": "^3.7.0"
"eslint": "^9.12.0",
"hmpo-logger": "git+https://github.com/HMPO/hmpo-logger.git#DD-272-update-dependencies",
"mocha": "^10.7.3",
"nyc": "^17.1.0",
"proxyquire": "^2.1.3",
"sinon": "^19.0.2",
"sinon-chai": "^3.7.0",
"husky": "^9.1.6",
"globals": "^15.9.0"
},

@@ -52,3 +55,4 @@ "nyc": {

"coverage/**",
"test/**"
"test/**",
"eslint.config.js"
],

@@ -55,0 +59,0 @@ "lines": 100,

'use strict';
const Model = require('../../lib/local-model');
const { expect } = require('chai');

@@ -5,0 +6,0 @@ describe('Local Model', () => {

@@ -7,5 +7,6 @@ 'use strict';

const logger = require('hmpo-logger');
const { expect } = require('chai');
const HttpsProxyAgent = require('https-proxy-agent');
const HttpProxyAgent = require('http-proxy-agent');
const { HttpProxyAgent } = require('http-proxy-agent');
const { HttpsProxyAgent } = require('https-proxy-agent');

@@ -404,12 +405,8 @@ describe('Remote Model', () => {

const returnedConfig = model.requestConfig({
'method': 'VERB',
'url': 'http://example.net',
'proxy': 'http://proxy.example.com:8000'
method: 'VERB',
url: 'http://example.net',
proxy: 'http://proxy.example.com:8000'
});
sinon.assert.match(returnedConfig, {
agent: {
http: sinon.match.instanceOf(HttpProxyAgent)
}
});
expect(returnedConfig.agent.http).to.be.an.instanceOf(HttpProxyAgent);
});

@@ -433,5 +430,5 @@

const returnedConfig = model.requestConfig({
'method': 'VERB',
'url': 'http://example.net',
'proxy': {
method: 'VERB',
url: 'http://example.net',
proxy: {
uri: 'http://proxy.example.com:8000',

@@ -443,14 +440,9 @@ keepAlive: true,

sinon.assert.match(returnedConfig, {
agent: {
http: {
proxy: {
keepAlive: true,
maxSockets: 200
}
}
}
});
const agent = returnedConfig.agent.http;
expect(agent).to.be.instanceOf(require('http').Agent);
expect(agent.keepAlive).to.equal(true);
expect(agent.maxSockets).to.equal(200);
});
it('should process auth for the proxy', () => {

@@ -461,6 +453,13 @@ let agent;

sinon.assert.match(agent.https.proxy, {
auth: 'username:password',
host: 'host',
port: 123,
protocol: 'http:'
href: 'http://username:password@host:123/path',
origin: 'http://host:123',
protocol: 'http:',
username: 'username',
password: 'password',
host: 'host:123',
hostname: 'host',
port: '123',
pathname: '/path',
search: '',
hash: ''
});

@@ -470,8 +469,16 @@

sinon.assert.match(agent.https.proxy, {
auth: 'username',
host: 'host',
port: 123,
protocol: 'http:'
href: 'http://username@host:123/path',
origin: 'http://host:123',
protocol: 'http:',
username: 'username',
password: '',
host: 'host:123',
hostname: 'host',
port: '123',
pathname: '/path',
search: '',
hash: ''
});
});
});

@@ -478,0 +485,0 @@

'use strict';
const { expect } = require('chai');

@@ -3,0 +4,0 @@ describe('hmpo-model', () => {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc