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

@culturehq/client

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@culturehq/client - npm Package Compare versions

Comparing version 14.0.0 to 14.1.0

6

CHANGELOG.md

@@ -9,2 +9,8 @@ # Changelog

## [14.1.0] - 2023-09-05
### Added
- Upload files to s3 bucket using the SDK because of the signature that AWS is asking
## [14.0.0] - 2023-09-05

@@ -11,0 +17,0 @@

4

dist/config.js

@@ -11,3 +11,5 @@ "use strict";

signerURL: "https://fyzqa1okfe.execute-api.us-west-2.amazonaws.com/production/signature",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com"
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com",
AWSAccessKey: undefined,
AWSSecretAccessKey: undefined
};

@@ -14,0 +16,0 @@

@@ -8,8 +8,4 @@ "use strict";

var _awsSdk = _interopRequireDefault(require("aws-sdk"));
var _clientS = require("@aws-sdk/client-s3");
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _config = _interopRequireDefault(require("./config"));

@@ -40,2 +36,4 @@

var signUpload = function signUpload(file, onProgress) {
var folderPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
if (_config["default"].uploadBucket !== "https://culturehq-direct-uploads-eu.s3-eu-west-2.amazonaws.com") {

@@ -82,36 +80,26 @@ return new Promise(function (resolve, reject) {

_awsSdk["default"].config.loadFromPath("./aws-config.json");
var s3Client = new _clientS.S3Client({
region: "eu-west-2",
credentials: {
accessKeyId: _config["default"].AWSAccessKey,
secretAccessKey: _config["default"].AWSSecretAccessKey
}
}); // Construct the S3 object key
var s3 = new _awsSdk["default"].S3({
apiVersion: "2006-03-01"
}); // call S3 to retrieve upload file to specified bucket
var objectKey = folderPath ? "".concat(folderPath, "/").concat(file.name) : file.name; // Create a PutObjectCommand to upload the file to S3
var uploadParams = {
Bucket: _config["default"].uploadBucket,
Key: "",
Body: ""
}; // Configure the file stream and obtain the upload parameters
var fileStream = _fs["default"].createReadStream(file);
fileStream.on("error", function (err) {
// eslint-disable-next-line no-console
console.log("File Error", err);
});
uploadParams.Body = fileStream;
uploadParams.Key = _path["default"].basename(file); // call S3 to retrieve upload file to specified bucket
Bucket: _config["default"].bucketName,
Key: objectKey,
Body: file
};
return new Promise(function (resolve, reject) {
return s3.upload(uploadParams, function (err, data) {
if (err) {
// eslint-disable-next-line no-console
console.log("Error", err);
reject(err);
}
if (data) {
// eslint-disable-next-line no-console
console.log("Upload Success", data.Location);
resolve("".concat(_config["default"].uploadBucket, "/").concat(data.Location));
}
s3Client.send(new _clientS.PutObjectCommand(uploadParams)).then(function (response) {
// eslint-disable-next-line no-console
console.error("File uploaded", response);
resolve(response);
})["catch"](function (error) {
// eslint-disable-next-line no-console
console.error("File upload error:", error);
reject(error);
});

@@ -118,0 +106,0 @@ });

{
"name": "@culturehq/client",
"version": "14.0.0",
"version": "14.1.0",
"description": "A JavaScript client that wraps the CultureHQ API",

@@ -23,4 +23,4 @@ "main": "dist/client.js",

"dependencies": {
"@rails/actioncable": "^7.0.0",
"aws-sdk": "^2.1451.0"
"@aws-sdk/client-s3": "^3.405.0",
"@rails/actioncable": "^7.0.0"
},

@@ -27,0 +27,0 @@ "devDependencies": {

@@ -5,3 +5,5 @@ const config = {

signerURL: "https://fyzqa1okfe.execute-api.us-west-2.amazonaws.com/production/signature",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com"
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com",
AWSAccessKey: undefined,
AWSSecretAccessKey: undefined
};

@@ -8,0 +10,0 @@

@@ -1,4 +0,3 @@

import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import config from "./config";

@@ -24,3 +23,3 @@ import formData from "./formData";

/* eslint-disable no-promise-executor-return */
const signUpload = (file, onProgress) => {
const signUpload = (file, onProgress, folderPath = undefined) => {
if (config.uploadBucket !== "https://culturehq-direct-uploads-eu.s3-eu-west-2.amazonaws.com") {

@@ -67,32 +66,34 @@ return new Promise((resolve, reject) => (

AWS.config.loadFromPath("./aws-config.json");
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
// call S3 to retrieve upload file to specified bucket
const uploadParams = { Bucket: config.uploadBucket, Key: "", Body: "" };
// Configure the file stream and obtain the upload parameters
const fileStream = fs.createReadStream(file);
fileStream.on("error", err => {
// eslint-disable-next-line no-console
console.log("File Error", err);
const s3Client = new S3Client({
region: "eu-west-2",
credentials: {
accessKeyId: config.AWSAccessKey,
secretAccessKey: config.AWSSecretAccessKey
}
});
uploadParams.Body = fileStream;
uploadParams.Key = path.basename(file);
// call S3 to retrieve upload file to specified bucket
return new Promise((resolve, reject) => (
s3.upload(uploadParams, (err, data) => {
if (err) {
// Construct the S3 object key
const objectKey = folderPath ? `${folderPath}/${file.name}` : file.name;
// Create a PutObjectCommand to upload the file to S3
const uploadParams = {
Bucket: config.bucketName,
Key: objectKey,
Body: file
};
return new Promise((resolve, reject) => {
s3Client.send(new PutObjectCommand(uploadParams))
.then(response => {
// eslint-disable-next-line no-console
console.log("Error", err);
reject(err);
} if (data) {
console.error("File uploaded", response);
resolve(response);
}).catch(error => {
// eslint-disable-next-line no-console
console.log("Upload Success", data.Location);
resolve(`${config.uploadBucket}/${data.Location}`);
}
})
));
console.error("File upload error:", error);
reject(error);
});
});
};
export default signUpload;
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