Aktueller Stand
This commit is contained in:
6
backend/node_modules/light-my-request/lib/config-validator.js
generated
vendored
6
backend/node_modules/light-my-request/lib/config-validator.js
generated
vendored
@@ -1,10 +1,10 @@
|
||||
// This file is autogenerated by build/build-validation.js, do not edit
|
||||
/* istanbul ignore file */
|
||||
/* c8 ignore start */
|
||||
/* eslint-disable */
|
||||
"use strict";
|
||||
module.exports = validate10;
|
||||
module.exports.default = validate10;
|
||||
const schema11 = {"type":"object","properties":{"url":{"oneOf":[{"type":"string"},{"type":"object","properties":{"protocol":{"type":"string"},"hostname":{"type":"string"},"pathname":{"type":"string"}},"additionalProperties":true,"required":["pathname"]}]},"path":{"oneOf":[{"type":"string"},{"type":"object","properties":{"protocol":{"type":"string"},"hostname":{"type":"string"},"pathname":{"type":"string"}},"additionalProperties":true,"required":["pathname"]}]},"cookies":{"type":"object","additionalProperties":true},"headers":{"type":"object","additionalProperties":true},"query":{"anyOf":[{"type":"object","additionalProperties":true},{"type":"string"}]},"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":["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE","acl","bind","checkout","connect","copy","delete","get","head","link","lock","m-search","merge","mkactivity","mkcalendar","mkcol","move","notify","options","patch","post","propfind","proppatch","purge","put","rebind","report","search","source","subscribe","trace","unbind","unlink","unlock","unsubscribe"]},"validate":{"type":"boolean"}},"additionalProperties":true,"oneOf":[{"required":["url"]},{"required":["path"]}]};
|
||||
const schema11 = {"type":"object","properties":{"url":{"oneOf":[{"type":"string"},{"type":"object","properties":{"protocol":{"type":"string"},"hostname":{"type":"string"},"pathname":{"type":"string"}},"additionalProperties":true,"required":["pathname"]}]},"path":{"oneOf":[{"type":"string"},{"type":"object","properties":{"protocol":{"type":"string"},"hostname":{"type":"string"},"pathname":{"type":"string"}},"additionalProperties":true,"required":["pathname"]}]},"cookies":{"type":"object","additionalProperties":true},"headers":{"type":"object","additionalProperties":true},"query":{"anyOf":[{"type":"object","additionalProperties":true},{"type":"string"}]},"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":["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","QUERY","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE","acl","bind","checkout","connect","copy","delete","get","head","link","lock","m-search","merge","mkactivity","mkcalendar","mkcol","move","notify","options","patch","post","propfind","proppatch","purge","put","query","rebind","report","search","source","subscribe","trace","unbind","unlink","unlock","unsubscribe"]},"validate":{"type":"boolean"}},"additionalProperties":true,"oneOf":[{"required":["url"]},{"required":["path"]}]};
|
||||
|
||||
function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){
|
||||
let vErrors = null;
|
||||
@@ -859,7 +859,7 @@ data["method"] = coerced15;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((data18 === "ACL") || (data18 === "BIND")) || (data18 === "CHECKOUT")) || (data18 === "CONNECT")) || (data18 === "COPY")) || (data18 === "DELETE")) || (data18 === "GET")) || (data18 === "HEAD")) || (data18 === "LINK")) || (data18 === "LOCK")) || (data18 === "M-SEARCH")) || (data18 === "MERGE")) || (data18 === "MKACTIVITY")) || (data18 === "MKCALENDAR")) || (data18 === "MKCOL")) || (data18 === "MOVE")) || (data18 === "NOTIFY")) || (data18 === "OPTIONS")) || (data18 === "PATCH")) || (data18 === "POST")) || (data18 === "PROPFIND")) || (data18 === "PROPPATCH")) || (data18 === "PURGE")) || (data18 === "PUT")) || (data18 === "REBIND")) || (data18 === "REPORT")) || (data18 === "SEARCH")) || (data18 === "SOURCE")) || (data18 === "SUBSCRIBE")) || (data18 === "TRACE")) || (data18 === "UNBIND")) || (data18 === "UNLINK")) || (data18 === "UNLOCK")) || (data18 === "UNSUBSCRIBE")) || (data18 === "acl")) || (data18 === "bind")) || (data18 === "checkout")) || (data18 === "connect")) || (data18 === "copy")) || (data18 === "delete")) || (data18 === "get")) || (data18 === "head")) || (data18 === "link")) || (data18 === "lock")) || (data18 === "m-search")) || (data18 === "merge")) || (data18 === "mkactivity")) || (data18 === "mkcalendar")) || (data18 === "mkcol")) || (data18 === "move")) || (data18 === "notify")) || (data18 === "options")) || (data18 === "patch")) || (data18 === "post")) || (data18 === "propfind")) || (data18 === "proppatch")) || (data18 === "purge")) || (data18 === "put")) || (data18 === "rebind")) || (data18 === "report")) || (data18 === "search")) || (data18 === "source")) || (data18 === "subscribe")) || (data18 === "trace")) || (data18 === "unbind")) || (data18 === "unlink")) || (data18 === "unlock")) || (data18 === "unsubscribe"))){
|
||||
if(!((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((data18 === "ACL") || (data18 === "BIND")) || (data18 === "CHECKOUT")) || (data18 === "CONNECT")) || (data18 === "COPY")) || (data18 === "DELETE")) || (data18 === "GET")) || (data18 === "HEAD")) || (data18 === "LINK")) || (data18 === "LOCK")) || (data18 === "M-SEARCH")) || (data18 === "MERGE")) || (data18 === "MKACTIVITY")) || (data18 === "MKCALENDAR")) || (data18 === "MKCOL")) || (data18 === "MOVE")) || (data18 === "NOTIFY")) || (data18 === "OPTIONS")) || (data18 === "PATCH")) || (data18 === "POST")) || (data18 === "PROPFIND")) || (data18 === "PROPPATCH")) || (data18 === "PURGE")) || (data18 === "PUT")) || (data18 === "QUERY")) || (data18 === "REBIND")) || (data18 === "REPORT")) || (data18 === "SEARCH")) || (data18 === "SOURCE")) || (data18 === "SUBSCRIBE")) || (data18 === "TRACE")) || (data18 === "UNBIND")) || (data18 === "UNLINK")) || (data18 === "UNLOCK")) || (data18 === "UNSUBSCRIBE")) || (data18 === "acl")) || (data18 === "bind")) || (data18 === "checkout")) || (data18 === "connect")) || (data18 === "copy")) || (data18 === "delete")) || (data18 === "get")) || (data18 === "head")) || (data18 === "link")) || (data18 === "lock")) || (data18 === "m-search")) || (data18 === "merge")) || (data18 === "mkactivity")) || (data18 === "mkcalendar")) || (data18 === "mkcol")) || (data18 === "move")) || (data18 === "notify")) || (data18 === "options")) || (data18 === "patch")) || (data18 === "post")) || (data18 === "propfind")) || (data18 === "proppatch")) || (data18 === "purge")) || (data18 === "put")) || (data18 === "query")) || (data18 === "rebind")) || (data18 === "report")) || (data18 === "search")) || (data18 === "source")) || (data18 === "subscribe")) || (data18 === "trace")) || (data18 === "unbind")) || (data18 === "unlink")) || (data18 === "unlock")) || (data18 === "unsubscribe"))){
|
||||
validate10.errors = [{instancePath:instancePath+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues: schema11.properties.method.enum},message:"must be equal to one of the allowed values"}];
|
||||
return false;
|
||||
}
|
||||
|
||||
6
backend/node_modules/light-my-request/lib/form-data.js
generated
vendored
6
backend/node_modules/light-my-request/lib/form-data.js
generated
vendored
@@ -53,15 +53,13 @@ function formDataToStream (formdata) {
|
||||
// header
|
||||
yield textEncoder.encode(header)
|
||||
// body
|
||||
/* istanbul ignore else */
|
||||
if (value.stream) {
|
||||
yield * value.stream()
|
||||
} else {
|
||||
} /* c8 ignore start */ else {
|
||||
// shouldn't be here since Blob / File should provide .stream
|
||||
// and FormData always convert to USVString
|
||||
/* istanbul ignore next */
|
||||
yield value
|
||||
}
|
||||
} /* c8 ignore stop */
|
||||
yield linebreak
|
||||
}
|
||||
}
|
||||
|
||||
72
backend/node_modules/light-my-request/lib/request.js
generated
vendored
72
backend/node_modules/light-my-request/lib/request.js
generated
vendored
@@ -13,7 +13,11 @@ const { isFormDataLike, formDataToStream } = require('./form-data')
|
||||
const { EventEmitter } = require('node:events')
|
||||
|
||||
// request.connectin deprecation https://nodejs.org/api/http.html#http_request_connection
|
||||
const FST_LIGHTMYREQUEST_DEP01 = createDeprecation({ name: 'FastifyDeprecationLightMyRequest', code: 'FST_LIGHTMYREQUEST_DEP01', message: 'You are accessing "request.connection", use "request.socket" instead.' })
|
||||
const FST_LIGHTMYREQUEST_DEP01 = createDeprecation({
|
||||
name: 'FastifyDeprecationLightMyRequest',
|
||||
code: 'FST_LIGHTMYREQUEST_DEP01',
|
||||
message: 'You are accessing "request.connection", use "request.socket" instead.'
|
||||
})
|
||||
|
||||
/**
|
||||
* Get hostname:port
|
||||
@@ -103,6 +107,7 @@ function Request (options) {
|
||||
|
||||
this.headers = {}
|
||||
this.rawHeaders = []
|
||||
|
||||
const headers = options.headers || {}
|
||||
|
||||
for (const field in headers) {
|
||||
@@ -155,6 +160,7 @@ function Request (options) {
|
||||
payloadResume = true
|
||||
// we override the content-type
|
||||
this.headers['content-type'] = stream.contentType
|
||||
this.headers['transfer-encoding'] = 'chunked'
|
||||
}
|
||||
|
||||
if (payload && typeof payload !== 'string' && !payloadResume && !Buffer.isBuffer(payload)) {
|
||||
@@ -166,7 +172,7 @@ function Request (options) {
|
||||
}
|
||||
|
||||
// Set the content-length for the corresponding payload if none set
|
||||
if (payload && !payloadResume && !Object.prototype.hasOwnProperty.call(this.headers, 'content-length')) {
|
||||
if (payload && !payloadResume && !Object.hasOwn(this.headers, 'content-length')) {
|
||||
this.headers['content-length'] = (Buffer.isBuffer(payload) ? payload.length : Buffer.byteLength(payload)).toString()
|
||||
}
|
||||
|
||||
@@ -178,50 +184,63 @@ function Request (options) {
|
||||
this._lightMyRequest = {
|
||||
payload,
|
||||
isDone: false,
|
||||
simulate: options.simulate || {}
|
||||
simulate: options.simulate || {},
|
||||
payloadAsStream: options.payloadAsStream,
|
||||
signal: options.signal
|
||||
}
|
||||
|
||||
const signal = options.signal
|
||||
/* istanbul ignore if */
|
||||
/* c8 ignore next 3 */
|
||||
if (signal) {
|
||||
addAbortSignal(signal, this)
|
||||
}
|
||||
|
||||
{
|
||||
const payload = this._lightMyRequest.payload
|
||||
if (payload?._readableState) { // does quack like a modern stream
|
||||
this._read = readStream
|
||||
|
||||
payload.on('error', (err) => {
|
||||
this.destroy(err)
|
||||
})
|
||||
|
||||
payload.on('end', () => {
|
||||
this.push(null)
|
||||
})
|
||||
} else {
|
||||
// Stream v1 are handled in index.js synchronously
|
||||
this._read = readEverythingElse
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
util.inherits(Request, Readable)
|
||||
util.inherits(CustomRequest, Request)
|
||||
|
||||
Request.prototype.prepare = function (next) {
|
||||
function readStream () {
|
||||
const payload = this._lightMyRequest.payload
|
||||
if (!payload || typeof payload.resume !== 'function') { // does not quack like a stream
|
||||
return next()
|
||||
|
||||
let more = true
|
||||
let pushed = false
|
||||
let chunk
|
||||
while (more && (chunk = payload.read())) {
|
||||
pushed = true
|
||||
more = this.push(chunk)
|
||||
}
|
||||
|
||||
const chunks = []
|
||||
|
||||
payload.on('data', (chunk) => chunks.push(Buffer.from(chunk)))
|
||||
|
||||
payload.on('end', () => {
|
||||
const payload = Buffer.concat(chunks)
|
||||
this.headers['content-length'] = this.headers['content-length'] || ('' + payload.length)
|
||||
this._lightMyRequest.payload = payload
|
||||
return next()
|
||||
})
|
||||
|
||||
// Force to resume the stream. Needed for Stream 1
|
||||
payload.resume()
|
||||
// We set up a recursive 'readable' event only if we didn't read anything.
|
||||
// Otheriwse, the stream machinery will call _read() for us.
|
||||
if (more && !pushed) {
|
||||
this._lightMyRequest.payload.once('readable', this._read.bind(this))
|
||||
}
|
||||
}
|
||||
|
||||
Request.prototype._read = function (size) {
|
||||
function readEverythingElse () {
|
||||
setImmediate(() => {
|
||||
if (this._lightMyRequest.isDone) {
|
||||
// 'end' defaults to true
|
||||
if (this._lightMyRequest.simulate.end !== false) {
|
||||
this.push(null)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -251,6 +270,9 @@ Request.prototype._read = function (size) {
|
||||
})
|
||||
}
|
||||
|
||||
util.inherits(Request, Readable)
|
||||
util.inherits(CustomRequest, Request)
|
||||
|
||||
Request.prototype.destroy = function (error) {
|
||||
if (this.destroyed || this._lightMyRequest.isDone) return
|
||||
this.destroyed = true
|
||||
|
||||
99
backend/node_modules/light-my-request/lib/response.js
generated
vendored
99
backend/node_modules/light-my-request/lib/response.js
generated
vendored
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const http = require('node:http')
|
||||
const { Writable, Readable } = require('node:stream')
|
||||
const { Writable, Readable, addAbortSignal } = require('node:stream')
|
||||
const util = require('node:util')
|
||||
|
||||
const setCookie = require('set-cookie-parser')
|
||||
@@ -9,7 +9,17 @@ const setCookie = require('set-cookie-parser')
|
||||
function Response (req, onEnd, reject) {
|
||||
http.ServerResponse.call(this, req)
|
||||
|
||||
this._lightMyRequest = { headers: null, trailers: {}, payloadChunks: [] }
|
||||
if (req._lightMyRequest?.payloadAsStream) {
|
||||
const read = this.emit.bind(this, 'drain')
|
||||
this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read }) }
|
||||
const signal = req._lightMyRequest.signal
|
||||
|
||||
if (signal) {
|
||||
addAbortSignal(signal, this._lightMyRequest.stream)
|
||||
}
|
||||
} else {
|
||||
this._lightMyRequest = { headers: null, trailers: {}, payloadChunks: [] }
|
||||
}
|
||||
// This forces node@8 to always render the headers
|
||||
this.setHeader('foo', 'bar'); this.removeHeader('foo')
|
||||
|
||||
@@ -19,28 +29,51 @@ function Response (req, onEnd, reject) {
|
||||
|
||||
let called = false
|
||||
const onEndSuccess = (payload) => {
|
||||
// no need to early-return if already called because this handler is bound `once`
|
||||
if (called) return
|
||||
called = true
|
||||
if (this._promiseCallback) {
|
||||
return process.nextTick(() => onEnd(payload))
|
||||
}
|
||||
process.nextTick(() => onEnd(null, payload))
|
||||
}
|
||||
this._lightMyRequest.onEndSuccess = onEndSuccess
|
||||
|
||||
let finished = false
|
||||
const onEndFailure = (err) => {
|
||||
if (called) return
|
||||
if (called) {
|
||||
if (this._lightMyRequest.stream && !finished) {
|
||||
if (!err) {
|
||||
err = new Error('response destroyed before completion')
|
||||
err.code = 'LIGHT_ECONNRESET'
|
||||
}
|
||||
this._lightMyRequest.stream.destroy(err)
|
||||
this._lightMyRequest.stream.on('error', () => {})
|
||||
}
|
||||
return
|
||||
}
|
||||
called = true
|
||||
if (!err) {
|
||||
err = new Error('response destroyed before completion')
|
||||
err.code = 'LIGHT_ECONNRESET'
|
||||
}
|
||||
if (this._promiseCallback) {
|
||||
return process.nextTick(() => reject(err))
|
||||
}
|
||||
process.nextTick(() => onEnd(err, null))
|
||||
}
|
||||
|
||||
this.once('finish', () => {
|
||||
const res = generatePayload(this)
|
||||
res.raw.req = req
|
||||
onEndSuccess(res)
|
||||
})
|
||||
if (this._lightMyRequest.stream) {
|
||||
this.once('finish', () => {
|
||||
finished = true
|
||||
this._lightMyRequest.stream.push(null)
|
||||
})
|
||||
} else {
|
||||
this.once('finish', () => {
|
||||
const res = generatePayload(this)
|
||||
res.raw.req = req
|
||||
onEndSuccess(res)
|
||||
})
|
||||
}
|
||||
|
||||
this.connection.once('error', onEndFailure)
|
||||
|
||||
@@ -64,6 +97,10 @@ Response.prototype.writeHead = function () {
|
||||
|
||||
copyHeaders(this)
|
||||
|
||||
if (this._lightMyRequest.stream) {
|
||||
this._lightMyRequest.onEndSuccess(generatePayload(this))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -72,8 +109,12 @@ Response.prototype.write = function (data, encoding, callback) {
|
||||
clearTimeout(this.timeoutHandle)
|
||||
}
|
||||
http.ServerResponse.prototype.write.call(this, data, encoding, callback)
|
||||
this._lightMyRequest.payloadChunks.push(Buffer.from(data, encoding))
|
||||
return true
|
||||
if (this._lightMyRequest.stream) {
|
||||
return this._lightMyRequest.stream.push(Buffer.from(data, encoding))
|
||||
} else {
|
||||
this._lightMyRequest.payloadChunks.push(Buffer.from(data, encoding))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Response.prototype.end = function (data, encoding, callback) {
|
||||
@@ -110,7 +151,7 @@ Response.prototype.addTrailers = function (trailers) {
|
||||
|
||||
function generatePayload (response) {
|
||||
// This seems only to happen when using `fastify-express` - see https://github.com/fastify/fastify-express/issues/47
|
||||
/* istanbul ignore if */
|
||||
/* c8 ignore next 3 */
|
||||
if (response._lightMyRequest.headers === null) {
|
||||
copyHeaders(response)
|
||||
}
|
||||
@@ -129,22 +170,32 @@ function generatePayload (response) {
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare payload and trailers
|
||||
const rawBuffer = Buffer.concat(response._lightMyRequest.payloadChunks)
|
||||
res.rawPayload = rawBuffer
|
||||
|
||||
// we keep both of them for compatibility reasons
|
||||
res.payload = rawBuffer.toString()
|
||||
res.body = res.payload
|
||||
res.trailers = response._lightMyRequest.trailers
|
||||
|
||||
// Prepare payload parsers
|
||||
res.json = function parseJsonPayload () {
|
||||
return JSON.parse(res.payload)
|
||||
if (response._lightMyRequest.payloadChunks) {
|
||||
// Prepare payload and trailers
|
||||
const rawBuffer = Buffer.concat(response._lightMyRequest.payloadChunks)
|
||||
res.rawPayload = rawBuffer
|
||||
|
||||
// we keep both of them for compatibility reasons
|
||||
res.payload = rawBuffer.toString()
|
||||
res.body = res.payload
|
||||
|
||||
// Prepare payload parsers
|
||||
res.json = function parseJsonPayload () {
|
||||
return JSON.parse(res.payload)
|
||||
}
|
||||
} else {
|
||||
res.json = function () {
|
||||
throw new Error('Response payload is not available with payloadAsStream: true')
|
||||
}
|
||||
}
|
||||
|
||||
// Provide stream Readable for advanced user
|
||||
res.stream = function streamPayload () {
|
||||
if (response._lightMyRequest.stream) {
|
||||
return response._lightMyRequest.stream
|
||||
}
|
||||
return Readable.from(response._lightMyRequest.payloadChunks)
|
||||
}
|
||||
|
||||
@@ -154,7 +205,7 @@ function generatePayload (response) {
|
||||
// Throws away all written data to prevent response from buffering payload
|
||||
function getNullSocket () {
|
||||
return new Writable({
|
||||
write (chunk, encoding, callback) {
|
||||
write (_chunk, _encoding, callback) {
|
||||
setImmediate(callback)
|
||||
}
|
||||
})
|
||||
@@ -179,7 +230,7 @@ function copyHeaders (response) {
|
||||
// Add raw headers
|
||||
;['Date', 'Connection', 'Transfer-Encoding'].forEach((name) => {
|
||||
const regex = new RegExp('\\r\\n' + name + ': ([^\\r]*)\\r\\n')
|
||||
const field = response._header.match(regex)
|
||||
const field = response._header?.match(regex)
|
||||
if (field) {
|
||||
response._lightMyRequest.headers[name.toLowerCase()] = field[1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user