@vercel/node-bridge
Advanced tools
Comparing version 3.1.14 to 4.0.0
@@ -42,2 +42,3 @@ const { URL } = require('url'); | ||
responseCallbackUrl, | ||
features, | ||
} = payload; | ||
@@ -47,11 +48,11 @@ | ||
* | ||
* @param {string | Buffer} b | ||
* @param {string | Buffer} body | ||
* @returns Buffer | ||
*/ | ||
const normalizeBody = b => { | ||
if (b) { | ||
if (typeof b === 'string' && encoding === 'base64') { | ||
bodyBuffer = Buffer.from(b, encoding); | ||
const normalizeBody = body => { | ||
if (body) { | ||
if (typeof body === 'string' && encoding === 'base64') { | ||
bodyBuffer = Buffer.from(body, encoding); | ||
} else if (encoding === undefined) { | ||
bodyBuffer = Buffer.from(b); | ||
bodyBuffer = Buffer.from(body); | ||
} else { | ||
@@ -67,4 +68,5 @@ throw new Error(`Unsupported encoding: ${encoding}`); | ||
if (payloads) { | ||
for (const p of payloads) { | ||
p.body = normalizeBody(payload.body); | ||
for (const targetPayload of payloads) { | ||
targetPayload.features = features; | ||
targetPayload.body = normalizeBody(payload.body); | ||
} | ||
@@ -81,2 +83,3 @@ } | ||
payloads, | ||
features, | ||
responseCallbackCipher, | ||
@@ -91,46 +94,8 @@ responseCallbackCipherIV, | ||
/** | ||
* @param {import('aws-lambda').APIGatewayProxyEvent} event | ||
* @param {import('./types').VercelProxyEvent } event | ||
* @return {import('./types').VercelProxyRequest } | ||
*/ | ||
function normalizeAPIGatewayProxyEvent(event) { | ||
let bodyBuffer; | ||
const { httpMethod: method, path, headers, body } = event; | ||
if (body) { | ||
if (event.isBase64Encoded) { | ||
bodyBuffer = Buffer.from(body, 'base64'); | ||
} else { | ||
bodyBuffer = Buffer.from(body); | ||
} | ||
} else { | ||
bodyBuffer = Buffer.alloc(0); | ||
} | ||
return { | ||
body: bodyBuffer, | ||
headers, | ||
isApiGateway: true, | ||
method, | ||
path, | ||
responseCallbackCipher: undefined, | ||
responseCallbackCipherIV: undefined, | ||
responseCallbackCipherKey: undefined, | ||
responseCallbackStream: undefined, | ||
responseCallbackUrl: undefined, | ||
}; | ||
} | ||
/** | ||
* @param {import('./types').VercelProxyEvent | import('aws-lambda').APIGatewayProxyEvent} event | ||
* @return {import('./types').VercelProxyRequest} | ||
*/ | ||
function normalizeEvent(event) { | ||
if ('Action' in event) { | ||
if (event.Action === 'Invoke') { | ||
return normalizeProxyEvent(event); | ||
} else { | ||
throw new Error(`Unexpected event.Action: ${event.Action}`); | ||
} | ||
} else { | ||
return normalizeAPIGatewayProxyEvent(event); | ||
} | ||
if (event.Action === 'Invoke') return normalizeProxyEvent(event); | ||
throw new Error(`Unexpected event.Action: ${event.Action}`); | ||
} | ||
@@ -215,3 +180,3 @@ | ||
* | ||
* @param {import('./types').VercelProxyEvent | import('aws-lambda').APIGatewayProxyEvent} event | ||
* @param {import('./types').VercelProxyEvent} event | ||
* @param {import('aws-lambda').Context} context | ||
@@ -218,0 +183,0 @@ * @return {Promise<import('./types').VercelProxyResponse>} |
@@ -156,7 +156,7 @@ const { parse, pathToFileURL } = require('url'); | ||
/** | ||
* @param {import('aws-lambda').APIGatewayProxyEvent} e | ||
* @param {import('aws-lambda').APIGatewayProxyEvent} event | ||
* @param {import('aws-lambda').Context} context | ||
* @param {() => void} callback | ||
*/ | ||
function internal(e, context, callback) { | ||
function internal(event, context, callback) { | ||
const { | ||
@@ -167,3 +167,3 @@ path, | ||
headers, | ||
} = JSON.parse(e.body || '{}'); | ||
} = JSON.parse(event.body || '{}'); | ||
const { query } = parse(path, true); | ||
@@ -170,0 +170,0 @@ /** |
{ | ||
"name": "@vercel/node-bridge", | ||
"version": "3.1.14", | ||
"version": "4.0.0", | ||
"license": "MIT", | ||
@@ -35,3 +35,3 @@ "main": "./index.js", | ||
}, | ||
"gitHead": "803a9363f93c3f2be0f0ea2bce3ba64eefa78e04" | ||
"gitHead": "54514a44afef48726220bc8be8d20f4fda8e8b4f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180433
4860