New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

light-my-request

Package Overview
Dependencies
Maintainers
9
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

light-my-request - npm Package Compare versions

Comparing version 4.10.1 to 4.11.0

build/build-validation.js

20

index.d.ts

@@ -1,2 +0,1 @@

import * as stream from 'stream'
import * as http from 'http'

@@ -23,3 +22,3 @@

type DispatchFunc = (req: Request, res: ServerResponse) => void
type DispatchFunc = http.RequestListener

@@ -30,3 +29,3 @@ type CallbackFunc = (err: Error, response: Response) => void

function isInjection (obj: Request | ServerResponse): boolean
function isInjection (obj: http.IncomingMessage | http.ServerResponse): boolean

@@ -65,19 +64,6 @@ interface InjectOptions {

interface Request extends stream.Readable {
url: string
httpVersion: string
method: HTTPMethods
headers: http.IncomingHttpHeaders
rawHeaders: string[]
prepare: (next: () => void) => void
// @deprecated
connection: object
}
interface ServerResponse extends http.ServerResponse {}
interface Response {
raw: {
res: http.ServerResponse,
req: Request
req: http.IncomingMessage
}

@@ -84,0 +70,0 @@ rawPayload: Buffer

'use strict'
const assert = require('assert')
const http = require('http')
const Ajv = require('ajv')
const Request = require('./lib/request')

@@ -10,70 +8,5 @@ const Response = require('./lib/response')

const errorMessage = 'The dispatch function has already been invoked'
const urlSchema = {
oneOf: [
{ type: 'string' },
{
type: 'object',
properties: {
protocol: { type: 'string' },
hostname: { type: 'string' },
pathname: { type: 'string' }
// port type => any
// query type => any
},
additionalProperties: true,
required: ['pathname']
}
]
}
const ajv = new Ajv()
const optsValidator = require('./lib/configValidator')
ajv.addKeyword({
keyword: 'prototypedType',
validate: (_, data) =>
data && data.prototype && typeof data.prototype === 'object'
})
const schema = {
type: 'object',
properties: {
url: urlSchema,
path: urlSchema,
cookies: {
type: 'object',
additionalProperties: true
},
headers: {
type: 'object',
additionalProperties: true
},
query: {
type: 'object',
additionalProperties: true
},
simulate: {
type: 'object',
properties: {
end: { type: 'boolean' },
split: { type: 'boolean' },
error: { type: 'boolean' },
close: { type: 'boolean' }
}
},
authority: { type: 'string' },
remoteAddress: { type: 'string' },
method: { type: 'string', enum: http.METHODS.concat(http.METHODS.map(toLowerCase)) },
validate: { type: 'boolean' },
Request: { prototypedType: true }
// payload type => any
},
additionalProperties: true,
oneOf: [
{ required: ['url'] },
{ required: ['path'] }
]
}
const optsValidator = ajv.compile(schema)
function inject (dispatchFunc, options, callback) {

@@ -226,6 +159,4 @@ if (typeof callback === 'undefined') {

function toLowerCase (m) { return m.toLowerCase() }
module.exports = inject
module.exports.inject = inject
module.exports.isInjection = isInjection
{
"name": "light-my-request",
"version": "4.10.1",
"version": "4.11.0",
"description": "Fake HTTP injection library",
"main": "index.js",
"dependencies": {
"ajv": "^8.1.0",
"cookie": "^0.5.0",
"process-warning": "^1.0.0",
"process-warning": "^2.0.0",
"set-cookie-parser": "^2.4.1"

@@ -14,3 +13,4 @@ },

"devDependencies": {
"@types/node": "^17.0.0",
"@fastify/ajv-compiler": "^3.1.0",
"@types/node": "^18.0.0",
"benchmark": "^2.1.4",

@@ -25,3 +25,3 @@ "end-of-stream": "^1.4.4",

"tap": "^16.0.0",
"tsd": "^0.20.0"
"tsd": "^0.22.0"
},

@@ -28,0 +28,0 @@ "scripts": {

@@ -5,3 +5,2 @@ # Light my Request

[![NPM version](https://img.shields.io/npm/v/light-my-request.svg?style=flat)](https://www.npmjs.com/package/light-my-request)
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/light-my-request/badge.svg)](https://snyk.io/test/github/fastify/light-my-request)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

@@ -8,0 +7,0 @@

import * as http from 'http'
import { inject, isInjection, Request, Response, DispatchFunc, InjectOptions, Chain, ServerResponse } from '../index'
import { inject, isInjection, Response, DispatchFunc, InjectOptions, Chain } from '../index'
import { expectType, expectAssignable, expectNotAssignable } from 'tsd'

@@ -7,3 +7,3 @@

const dispatch = function (req: Request, res: ServerResponse) {
const dispatch = function (req: http.IncomingMessage, res: http.ServerResponse) {
expectType<boolean>(isInjection(req))

@@ -21,4 +21,4 @@ expectType<boolean>(isInjection(res))

expectAssignable<Function>(res.json)
expectAssignable<ServerResponse>(res.raw.res)
expectAssignable<Request>(res.raw.req)
expectAssignable<http.ServerResponse>(res.raw.res)
expectAssignable<http.IncomingMessage>(res.raw.req)
console.log(res.cookies)

@@ -95,1 +95,15 @@ }

expectNotAssignable<http.ServerResponse>(response)
const httpDispatch = function (req: http.IncomingMessage, res: http.ServerResponse) {
expectType<boolean>(isInjection(req))
expectType<boolean>(isInjection(res))
const reply = 'Hello World'
res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length })
res.end(reply)
}
inject(httpDispatch, { method: 'get', url: '/' }, (err, res) => {
expectType<Error>(err)
expectResponse(res)
})

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