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
0
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.3.0 to 14.3.1

6

CHANGELOG.md

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

## [14.3.1] - 2025-01-09
### Changed
- Fixing issues with previous versions
## [14.3.0] - 2025-01-09

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

10

dist/config.js

@@ -10,7 +10,7 @@ "use strict";

awsAccessKeyId: "AKIAIPWT257FWZ5I4ZGQ",
signerURL: "https://production-upload-signer.culturehq.com/production/signature",
signerAuthToken: "SIGNER-AUTH-TOKEN",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com",
AWSAccessKey: "AWS-KEY",
AWSSecretAccessKey: "AWS-SECRET"
signerURL: "https://fyzqa1okfe.execute-api.us-west-2.amazonaws.com/production/signature",
// TODO
// signerURL: "https://production-upload-signer.culturehq.com/production/signature",
// signerAuthToken: "SIGNER-AUTH-TOKEN",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com"
};

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

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

var _clientS = require("@aws-sdk/client-s3");
var _config = _interopRequireDefault(require("./config"));

@@ -36,70 +34,39 @@

var signUpload = function signUpload(file, onProgress) {
var folderPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
return new Promise(function (resolve, reject) {
return fetch(_config["default"].signerURL).then(function (response) {
return response.json();
}).then(function (_ref) {
var policy = _ref.policy,
signature = _ref.signature,
key = _ref.key;
var xhr = new XMLHttpRequest();
xhr.open("POST", "".concat(_config["default"].uploadBucket, "/"));
xhr.upload.addEventListener("load", function (event) {
if (event.type === "error") {
reject(event);
} else {
resolve("".concat(_config["default"].uploadBucket, "/").concat(key));
}
});
xhr.upload.addEventListener("error", reject);
if (_config["default"].uploadBucket !== "https://culturehq-direct-uploads-eu.s3-eu-west-2.amazonaws.com") {
return new Promise(function (resolve, reject) {
return fetch(_config["default"].signerURL).then(function (response) {
return response.json();
}).then(function (_ref) {
var policy = _ref.policy,
signature = _ref.signature,
key = _ref.key;
var xhr = new XMLHttpRequest();
xhr.open("POST", "".concat(_config["default"].uploadBucket, "/"));
xhr.upload.addEventListener("load", function (event) {
if (event.type === "error") {
reject(event);
} else {
resolve("".concat(_config["default"].uploadBucket, "/").concat(key));
}
if (onProgress) {
xhr.upload.addEventListener("progress", function (_ref2) {
var loaded = _ref2.loaded,
total = _ref2.total;
onProgress(total === 0 ? 100 : Math.ceil(loaded / total * 100));
});
xhr.upload.addEventListener("error", reject);
}
if (onProgress) {
xhr.upload.addEventListener("progress", function (_ref2) {
var loaded = _ref2.loaded,
total = _ref2.total;
onProgress(total === 0 ? 100 : Math.ceil(loaded / total * 100));
});
}
xhr.send((0, _formData["default"])({
key: key,
AWSAccessKeyId: _config["default"].awsAccessKeyId,
acl: "public-read",
policy: policy,
signature: signature,
success_action_status: "201",
"Content-Type": file.type,
file: file
}));
})["catch"](reject);
});
}
var s3Client = new _clientS.S3Client({
region: "eu-west-2",
credentials: {
accessKeyId: _config["default"].AWSAccessKey,
secretAccessKey: _config["default"].AWSSecretAccessKey
}
}); // Construct the S3 object key
var objectKey = folderPath ? "".concat(folderPath, "/").concat(file.name) : file.name; // Create a PutObjectCommand to upload the file to S3
var uploadParams = {
Bucket: _config["default"].bucketName,
Key: objectKey,
Body: file
};
return new Promise(function (resolve, reject) {
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);
});
xhr.send((0, _formData["default"])({
key: key,
AWSAccessKeyId: _config["default"].awsAccessKeyId,
acl: "public-read",
policy: policy,
signature: signature,
success_action_status: "201",
"Content-Type": file.type,
file: file
}));
})["catch"](reject);
});

@@ -106,0 +73,0 @@ };

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

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

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

@@ -26,0 +25,0 @@ },

const config = {
apiHost: "https://api.culturehq.com",
awsAccessKeyId: "AKIAIPWT257FWZ5I4ZGQ",
signerURL: "https://production-upload-signer.culturehq.com/production/signature",
signerAuthToken: "SIGNER-AUTH-TOKEN",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com",
AWSAccessKey: "AWS-KEY",
AWSSecretAccessKey: "AWS-SECRET"
signerURL: "https://fyzqa1okfe.execute-api.us-west-2.amazonaws.com/production/signature",
// TODO
// signerURL: "https://production-upload-signer.culturehq.com/production/signature",
// signerAuthToken: "SIGNER-AUTH-TOKEN",
uploadBucket: "https://culturehq-direct-uploads.s3-us-west-2.amazonaws.com"
};

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

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

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

@@ -23,76 +21,43 @@ import formData from "./formData";

/* eslint-disable no-promise-executor-return */
const signUpload = (file, onProgress, folderPath = undefined) => {
if (config.uploadBucket !== "https://culturehq-direct-uploads-eu.s3-eu-west-2.amazonaws.com") {
return new Promise((resolve, reject) => (
fetch(config.signerURL)
.then(response => response.json())
.then(({ policy, signature, key }) => {
const xhr = new XMLHttpRequest();
xhr.open("POST", `${config.uploadBucket}/`);
const signUpload = (file, onProgress) => (
new Promise((resolve, reject) => (
fetch(config.signerURL)
.then(response => response.json())
.then(({ policy, signature, key }) => {
const xhr = new XMLHttpRequest();
xhr.open("POST", `${config.uploadBucket}/`);
xhr.upload.addEventListener("load", event => {
if (event.type === "error") {
reject(event);
} else {
resolve(`${config.uploadBucket}/${key}`);
}
});
xhr.upload.addEventListener("error", reject);
if (onProgress) {
xhr.upload.addEventListener("progress", ({ loaded, total }) => {
onProgress(total === 0 ? 100 : Math.ceil((loaded / total) * 100));
});
xhr.upload.addEventListener("load", event => {
if (event.type === "error") {
reject(event);
} else {
resolve(`${config.uploadBucket}/${key}`);
}
});
xhr.send(
formData({
key,
AWSAccessKeyId: config.awsAccessKeyId,
acl: "public-read",
policy,
signature,
success_action_status: "201",
"Content-Type": file.type,
file
})
);
})
.catch(reject)
));
}
xhr.upload.addEventListener("error", reject);
const s3Client = new S3Client({
region: "eu-west-2",
credentials: {
accessKeyId: config.AWSAccessKey,
secretAccessKey: config.AWSSecretAccessKey
}
});
if (onProgress) {
xhr.upload.addEventListener("progress", ({ loaded, total }) => {
onProgress(total === 0 ? 100 : Math.ceil((loaded / total) * 100));
});
}
// Construct the S3 object key
const objectKey = folderPath ? `${folderPath}/${file.name}` : file.name;
xhr.send(
formData({
key,
AWSAccessKeyId: config.awsAccessKeyId,
acl: "public-read",
policy,
signature,
success_action_status: "201",
"Content-Type": file.type,
file
})
);
})
.catch(reject)
))
);
// 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.error("File uploaded", response);
resolve(response);
}).catch(error => {
// eslint-disable-next-line no-console
console.error("File upload error:", error);
reject(error);
});
});
};
export default signUpload;
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