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

@architect/asap

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/asap - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

src/lib/is-node-18.js

7

package.json
{
"name": "@architect/asap",
"version": "5.1.0",
"version": "5.1.1",
"description": "Architect Static Asset Proxy (ASAP) - a helpful library for Lambda-based static asset delivery",

@@ -30,6 +30,6 @@ "main": "src/asap.js",

"@architect/req-res-fixtures": "git+https://github.com/architect/req-res-fixtures.git",
"@aws-sdk/client-s3": "~3.216.0",
"@aws-sdk/client-s3": "3.188.0",
"aws-sdk": "2.1055.0",
"cross-env": "7.0.3",
"eslint": "~8.28.0",
"eslint": "~8.31.0",
"mime-types": "~2.1.35",

@@ -39,2 +39,3 @@ "mock-fs": "~5.2.0",

"proxyquire": "~2.1.3",
"tap-arc": "~0.3.5",
"tap-spec": "~5.0.0",

@@ -41,0 +42,0 @@ "tape": "~5.6.1"

@@ -7,17 +7,17 @@ let reader = require('./read')

*
* @param config - object, for configuration
* @param config.alias - object, map of root URLs to alias to other URLs (all should be root-rel)
* @param config.assets - object, map of unfingerprinted filenames to fingerprinted filenames
* @param config.env - string, arc environment; `testing` forces local reads
* @param config.bucket - object, { staging, production } override S3 bucket names
* @param config.bucket.staging - string, override the staging S3 bucket name
* @param config.bucket.production - string, override the production S3 bucket name
* @param config.bucket.folder - string, set an optional bucket folder to work within
* @param config.cacheControl - string, set a custom cache-control header value
* @param config.passthru - boolean, return null if no file is found
* @param config.headers - object, map of custom response headers
* @param config.sandboxPath - string, local filesystem path for Sandbox static assets
* @param config.spa - boolean, forces index.html no matter the folder depth
* @param {Object} config - for configuration
* @param {Object} config.alias - map of root URLs to alias to other URLs (all should be root-rel)
* @param {Object} config.assets - map of unfingerprinted filenames to fingerprinted filenames
* @param {string} config.env - arc environment; `testing` forces local reads
* @param {Object} config.bucket - { staging, production } override S3 bucket names
* @param {string} config.bucket.staging - override the staging S3 bucket name
* @param {string} config.bucket.production - override the production S3 bucket name
* @param {string} config.bucket.folder - set an optional bucket folder to work within
* @param {string} config.cacheControl - set a custom cache-control header value
* @param {boolean} config.passthru - return null if no file is found
* @param {Object} config.headers - map of custom response headers
* @param {string} config.sandboxPath - local filesystem path for Sandbox static assets
* @param {boolean} config.spa - forces index.html no matter the folder depth
*
* @returns HTTPLambda - an HTTP Lambda function that proxies calls to S3
* @returns {function} HTTPLambda - an HTTP Lambda function that proxies calls to S3
*/

@@ -24,0 +24,0 @@ function asap (config = {}) {

@@ -19,3 +19,3 @@ module.exports = function templatizeResponse (params) {

let startsWithSlash = Key.startsWith('/')
let lookup = startsWithSlash ? Key.substr(1) : Key
let lookup = startsWithSlash ? Key.substring(1) : Key
if (assets && assets[lookup] && !isLocal) {

@@ -22,0 +22,0 @@ Key = assets[lookup]

@@ -5,4 +5,4 @@ let { extname } = require('path')

if (!filename || !extname(filename)) return false
let ext = extname(filename).substr(1)
let ext = extname(filename).substring(1)
return HTMLorJSON.includes(ext)
}

@@ -22,3 +22,3 @@ let { existsSync, readFileSync } = require('fs')

* @param {Object} params.config
* @returns {Object} { statusCode, headers, body }
* @returns {Promise<Object>} { statusCode, headers, body }
*/

@@ -56,3 +56,3 @@ module.exports = async function readLocal (params) {

// If the static asset manifest has the key, use that, otherwise fall back to the original Key
let contentType = commonMimeTypes[extname(Key).substr(1)] || 'application/octet-stream'
let contentType = commonMimeTypes[extname(Key).substring(1)] || 'application/octet-stream'

@@ -81,3 +81,3 @@ if (!existsSync(filePath)) {

if (!matchedETag) {
let isBinary = binaryExts.includes(extname(Key).substr(1))
let isBinary = binaryExts.includes(extname(Key).substring(1))

@@ -84,0 +84,0 @@ // Handle templating

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

let isNode18 = require('./_is-node-18')
let _isNode18 = require('../lib/is-node-18')
let { existsSync, readFileSync } = require('fs')

@@ -50,3 +50,3 @@ let { join } = require('path')

async function getS3 (Key) {
if (isNode18) {
if (_isNode18) {
// eslint-disable-next-line

@@ -53,0 +53,0 @@ let { S3 } = require('@aws-sdk/client-s3')

let { existsSync, readFileSync } = require('fs')
let { extname, join } = require('path')
let isNode18 = require('./_is-node-18')
let _isNode18 = require('../lib/is-node-18')
let _isHTMLorJSON = require('../lib/is-html-json')

@@ -20,11 +20,11 @@ let binaryTypes = require('../lib/binary-types')

* @param {Object} params
* @param {String} params.Key
* @param {String} params.Bucket
* @param {String} params.IfNoneMatch
* @param {String} params.isFolder
* @param {string} params.Key
* @param {string} params.Bucket
* @param {string} params.IfNoneMatch
* @param {string} params.isFolder
* @param {string} params.rootPath
* @param {Object} params.config
* @returns {Object} { statusCode, headers, body }
* @returns {Promise<Object>} { statusCode, headers, body }
*/
module.exports = async function readS3 (params) {
let { Bucket, Key, IfNoneMatch, isFolder, config, rootPath } = params

@@ -79,16 +79,17 @@ let { ARC_STATIC_PREFIX } = process.env

let method
if (isNode18) {
if (_isNode18) {
// eslint-disable-next-line
let { S3 } = require('@aws-sdk/client-s3')
let s3 = new S3({ region: process.env.AWS_REGION || 'us-west-2' })
let { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3')
let client = new S3Client({ region: process.env.AWS_REGION || 'us-west-2' })
method = async params => {
let res = await s3.getObject(params)
const streamToString = (stream) => new Promise((resolve, reject) => {
const chunks = []
stream.on('data', (chunk) => chunks.push(chunk))
let command = new GetObjectCommand(params)
let res = await client.send(command)
let streamToString = stream => new Promise((resolve, reject) => {
let chunks = []
stream.on('data', chunk => chunks.push(chunk))
stream.on('error', reject)
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
stream.on('end', () => resolve(Buffer.concat(chunks)))
})
let bod = await streamToString(res.Body)
return { ...res, ...{ Body: bod } }
let Body = await streamToString(res.Body)
return { ...res, ...{ Body } }
}

@@ -132,3 +133,3 @@ }

let isBinary = binaryTypes.includes(result.ContentType) ||
binaryExts.includes(extname(Key).substr(1))
binaryExts.includes(extname(Key).substring(1))

@@ -183,3 +184,3 @@ // Handle templating

else if (existsSync(staticManifest) && !staticAssets) {
staticAssets = JSON.parse(readFileSync(staticManifest))
staticAssets = JSON.parse(readFileSync(staticManifest).toString())
}

@@ -186,0 +187,0 @@ else {

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