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

postman-request

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-request - npm Package Compare versions

Comparing version 2.88.1-postman.18 to 2.88.1-postman.19

3

lib/oauth.js
'use strict'
var url = require('url')
var qs = require('qs')

@@ -135,3 +134,3 @@ var caseless = require('caseless')

var href = self.request.uri.href += (query ? '&' : '?') + self.concatParams(oa, '&')
self.request.uri = url.parse(href)
self.request.uri = self.request.urlParser.parse(href)
self.request.path = self.request.uri.path

@@ -138,0 +137,0 @@ break

'use strict'
var url = require('url')
var fs = require('fs')

@@ -90,2 +89,3 @@ var isUrl = /^https?:/

var request = self.request
var urlParser = request.urlParser
var options = {}

@@ -114,7 +114,7 @@

if (!isUrl.test(redirectTo)) {
redirectTo = url.resolve(request.uri.href, redirectTo)
redirectTo = urlParser.resolve(request.uri.href, redirectTo)
}
var uriPrev = request.uri
request.uri = url.parse(redirectTo)
request.uri = urlParser.parse(redirectTo)

@@ -121,0 +121,0 @@ // handle the case where we change protocol from https to http or vice versa

'use strict'
var url = require('url')
var tunnel = require('@postman/tunnel-agent')

@@ -140,3 +139,3 @@

if (typeof request.proxy === 'string') {
request.proxy = url.parse(request.proxy)
request.proxy = request.urlParser.parse(request.proxy)
}

@@ -143,0 +142,0 @@

var url = require('url')
var urlEncoder = require('postman-url-encoder')
var EMPTY = ''
var ZERO = '0'
var PERCENT = '%'
var STRING = 'string'

@@ -12,2 +13,85 @@ var AMPERSAND = '&'

/**
* Percent encode a character with given code.
*
* @param {Number} c - character code of the character to encode
* @returns {String} - percent encoding of given character
*/
var percentEncode = function (c) {
var hex = c.toString(16).toUpperCase()
hex.length === 1 && (hex = ZERO + hex)
return PERCENT + hex
}
/**
* Checks if character with given code is valid hexadecimal digit or not.
*
* @param {Number} byte
* @returns {Boolean}
*/
var isPreEncodedCharacter = function (byte) {
return (byte >= 0x30 && byte <= 0x39) || // 0-9
(byte >= 0x41 && byte <= 0x46) || // A-F
(byte >= 0x61 && byte <= 0x66) // a-f
}
/**
* Checks if character at given index in the buffer is already percent encoded or not.
*
* @param {Buffer} buffer
* @param {Number} i
* @returns {Boolean}
*/
var isPreEncoded = function (buffer, i) {
// If it is % check next two bytes for percent encode characters
// looking for pattern %00 - %FF
return (buffer[i] === 0x25 &&
(isPreEncodedCharacter(buffer[i + 1]) &&
isPreEncodedCharacter(buffer[i + 2]))
)
}
/**
* Checks whether given character should be percent encoded or not for fixture.
*
* @param {Number} byte
* @returns {Boolean}
*/
var charactersToPercentEncode = function (byte) {
return (byte < 0x23 || byte > 0x7E || // Below # and after ~
byte === 0x3C || byte === 0x3E || // > and <
byte === 0x28 || byte === 0x29 || // ( and )
byte === 0x25 || // %
byte === 0x27 || // '
byte === 0x2A // *
)
}
/**
* Percent encode a query string according to RFC 3986.
* Note: This function is supposed to be used on top of node's inbuilt url encoding
* to solve issue https://github.com/nodejs/node/issues/8321
*
* @param {String} value
* @returns {String}
*/
var encode = function (value) {
if (!value) { return EMPTY }
var buffer = Buffer.from(value)
var ret = EMPTY
var i
var ii
for (i = 0, ii = buffer.length; i < ii; ++i) {
if (charactersToPercentEncode(buffer[i]) && !isPreEncoded(buffer, i)) {
ret += percentEncode(buffer[i])
} else {
ret += String.fromCodePoint(buffer[i]) // Only works in ES6 (available in Node v4+)
}
}
return ret
}
/**
* Parses a query string into an array, preserving parameter values

@@ -58,15 +142,15 @@ *

if (value === undefined) {
return ''
return EMPTY
}
if (key === null) {
key = ''
key = EMPTY
}
if (value === null) {
return urlEncoder.encode(key)
return encode(key)
}
return urlEncoder.encode(key) + EQUALS + urlEncoder.encode(value)
}).join(AMPERSAND) : ''
return encode(key) + EQUALS + encode(value)
}).join(AMPERSAND) : EMPTY
}

@@ -73,0 +157,0 @@

@@ -10,3 +10,3 @@ {

],
"version": "2.88.1-postman.18",
"version": "2.88.1-postman.19",
"repository": {

@@ -27,2 +27,3 @@ "type": "git",

"dependencies": {
"@postman/form-data": "~3.1.0",
"@postman/tunnel-agent": "^0.6.3",

@@ -36,3 +37,2 @@ "aws-sign2": "~0.7.0",

"forever-agent": "~0.6.1",
"@postman/form-data": "~3.1.0",
"har-validator": "~5.1.3",

@@ -46,3 +46,2 @@ "http-signature": "~1.2.0",

"performance-now": "^2.1.0",
"postman-url-encoder": "1.0.1",
"qs": "~6.5.2",

@@ -70,9 +69,10 @@ "safe-buffer": "^5.1.2",

"istanbul": "^0.4.0",
"karma": "^3.0.0",
"karma": "^3.1.4",
"karma-browserify": "^5.0.1",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^1.0.0",
"karma-coverage": "^1.0.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-tap": "^3.0.1",
"phantomjs-prebuilt": "^2.1.3",
"postman-url-encoder": "^2.1.0-beta.3",
"puppeteer": "^1.20.0",
"rimraf": "^2.2.8",

@@ -79,0 +79,0 @@ "server-destroy": "^1.0.1",

@@ -975,2 +975,3 @@

- `disableUrlEncoding` - if `true`, it will not use postman-url-encoder to encode URL. It means that if URL is given as object, it will be used as it is without doing any encoding. But if URL is given as string, it will be encoded by Node while converting it to object.
- `urlParser` - it takes an object with two functions `parse` and `resolve` in it. The `parse` function is used to parse the URL string into URL object and the `resolve` function is used to resolve relative URLs with respect to base URL. If this option is not provided or it is provided but does not contain both (`parse` and `resolve`) methods, it will default to Node's `url.parse()` and `url.resolve()` methods.
- `time` - if `true`, the request-response cycle (including all redirects) is timed at millisecond resolution. When set, the following properties are added to the response object:

@@ -977,0 +978,0 @@ - `elapsedTime` Duration of the entire request/response in milliseconds (*deprecated*).

@@ -152,2 +152,14 @@ 'use strict'

// use custom URL parser if provided, fallback to url.parse and url.resolve
if (!(
options.urlParser &&
typeof options.urlParser.parse === 'function' &&
typeof options.urlParser.resolve === 'function'
)) {
options.urlParser = {
parse: url.parse,
resolve: url.resolve
}
}
stream.Stream.call(self)

@@ -308,3 +320,3 @@ var reserved = Object.keys(Request.prototype)

if (typeof self.uri === 'string') {
self.uri = url.parse(self.uri)
self.uri = self.urlParser.parse(self.uri)
}

@@ -730,3 +742,3 @@

if (typeof proxy === 'string') {
proxy = url.parse(proxy)
proxy = self.urlParser.parse(proxy)
}

@@ -1372,4 +1384,4 @@ var isHttps = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'

var addCookie = function (cookie, cb) {
// set the cookie if it's domain in the href's domain.
targetCookieJar.setCookie(cookie, self.uri.href, {ignoreError: true}, function () {
// set the cookie if it's domain in the URI's domain.
targetCookieJar.setCookie(cookie, self.uri, {ignoreError: true}, function () {
// swallow the error, don't fail the request because of cookie jar failure

@@ -1531,3 +1543,3 @@ cb()

self.uri = url.parse(self.uri.href.split('?')[0] + '?' + qs)
self.uri = self.urlParser.parse(self.uri.href.split('?')[0] + '?' + qs)
self.url = self.uri

@@ -1760,5 +1772,4 @@ self.path = self.uri.path

var targetCookieJar = jar.getCookieString ? jar : globalCookieJar
var urihref = self.uri.href
// fetch cookie in the Specified host
targetCookieJar.getCookieString(urihref, function (err, cookies) {
targetCookieJar.getCookieString(self.uri, function (err, cookies) {
if (err) { return cb() }

@@ -1765,0 +1776,0 @@

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