Socket
Socket
Sign inDemoInstall

@aws-sdk/s3-request-presigner

Package Overview
Dependencies
Maintainers
5
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/s3-request-presigner - npm Package Compare versions

Comparing version 3.658.1 to 3.662.0

30

dist-cjs/index.js

@@ -54,6 +54,12 @@ "use strict";

}
presign(requestToSign, { unsignableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set(), ...options } = {}) {
presign(requestToSign, {
unsignableHeaders = /* @__PURE__ */ new Set(),
hoistableHeaders = /* @__PURE__ */ new Set(),
unhoistableHeaders = /* @__PURE__ */ new Set(),
...options
} = {}) {
this.prepareRequest(requestToSign, {
unsignableHeaders,
unhoistableHeaders
unhoistableHeaders,
hoistableHeaders
});

@@ -67,6 +73,12 @@ return this.signer.presign(requestToSign, {

}
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set(), ...options } = {}) {
presignWithCredentials(requestToSign, credentials, {
unsignableHeaders = /* @__PURE__ */ new Set(),
hoistableHeaders = /* @__PURE__ */ new Set(),
unhoistableHeaders = /* @__PURE__ */ new Set(),
...options
} = {}) {
this.prepareRequest(requestToSign, {
unsignableHeaders,
unhoistableHeaders
unhoistableHeaders,
hoistableHeaders
});

@@ -80,6 +92,12 @@ return this.signer.presignWithCredentials(requestToSign, credentials, {

}
prepareRequest(requestToSign, { unsignableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set() } = {}) {
prepareRequest(requestToSign, {
unsignableHeaders = /* @__PURE__ */ new Set(),
unhoistableHeaders = /* @__PURE__ */ new Set(),
hoistableHeaders = /* @__PURE__ */ new Set()
} = {}) {
unsignableHeaders.add("content-type");
Object.keys(requestToSign.headers).map((header) => header.toLowerCase()).filter((header) => header.startsWith("x-amz-server-side-encryption")).forEach((header) => {
unhoistableHeaders.add(header);
if (!hoistableHeaders.has(header)) {
unhoistableHeaders.add(header);
}
});

@@ -86,0 +104,0 @@ requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;

12

dist-es/presigner.js

@@ -13,6 +13,7 @@ import { SignatureV4MultiRegion } from "@aws-sdk/signature-v4-multi-region";

}
presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
presign(requestToSign, { unsignableHeaders = new Set(), hoistableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
this.prepareRequest(requestToSign, {
unsignableHeaders,
unhoistableHeaders,
hoistableHeaders,
});

@@ -26,6 +27,7 @@ return this.signer.presign(requestToSign, {

}
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), hoistableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
this.prepareRequest(requestToSign, {
unsignableHeaders,
unhoistableHeaders,
hoistableHeaders,
});

@@ -39,3 +41,3 @@ return this.signer.presignWithCredentials(requestToSign, credentials, {

}
prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set() } = {}) {
prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), hoistableHeaders = new Set(), } = {}) {
unsignableHeaders.add("content-type");

@@ -46,3 +48,5 @@ Object.keys(requestToSign.headers)

.forEach((header) => {
unhoistableHeaders.add(header);
if (!hoistableHeaders.has(header)) {
unhoistableHeaders.add(header);
}
});

@@ -49,0 +53,0 @@ requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;

@@ -11,6 +11,6 @@ import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";

constructor(options: S3RequestPresignerOptions);
presign(requestToSign: IHttpRequest, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
presign(requestToSign: IHttpRequest, { unsignableHeaders, hoistableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, { unsignableHeaders, hoistableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
private prepareRequest;
}
export {};

@@ -23,2 +23,3 @@ import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";

unsignableHeaders,
hoistableHeaders,
unhoistableHeaders,

@@ -33,2 +34,3 @@ ...options

unsignableHeaders,
hoistableHeaders,
unhoistableHeaders,

@@ -35,0 +37,0 @@ ...options

{
"name": "@aws-sdk/s3-request-presigner",
"version": "3.658.1",
"version": "3.662.0",
"scripts": {

@@ -24,14 +24,14 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

"dependencies": {
"@aws-sdk/signature-v4-multi-region": "3.658.1",
"@aws-sdk/types": "3.654.0",
"@aws-sdk/util-format-url": "3.654.0",
"@smithy/middleware-endpoint": "^3.1.3",
"@smithy/protocol-http": "^4.1.3",
"@smithy/smithy-client": "^3.3.5",
"@smithy/types": "^3.4.2",
"@aws-sdk/signature-v4-multi-region": "3.662.0",
"@aws-sdk/types": "3.662.0",
"@aws-sdk/util-format-url": "3.662.0",
"@smithy/middleware-endpoint": "^3.1.4",
"@smithy/protocol-http": "^4.1.4",
"@smithy/smithy-client": "^3.3.6",
"@smithy/types": "^3.5.0",
"tslib": "^2.6.2"
},
"devDependencies": {
"@aws-sdk/client-s3": "3.658.1",
"@smithy/hash-node": "^3.0.6",
"@aws-sdk/client-s3": "3.662.0",
"@smithy/hash-node": "^3.0.7",
"@tsconfig/recommended": "1.0.1",

@@ -38,0 +38,0 @@ "@types/node": "^16.18.96",

@@ -13,15 +13,3 @@ # @aws-sdk/s3-request-presigner

JavaScript Example:
```javascript
const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");
const { S3Client, GetObjectCommand } = require("@aws-sdk/client-s3");
const client = new S3Client(clientParams);
const command = new GetObjectCommand(getObjectParams);
const url = await getSignedUrl(client, command, { expiresIn: 3600 });
```
ES6 Example
```javascript
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";

@@ -38,6 +26,2 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";

If your request contains server-side encryption(`SSE*`) configurations, because
of S3 limitation, you need to send corresponding headers along with the
presigned url. For more information, please go to [S3 SSE reference](https://docs.aws.amazon.com/AmazonS3/latest/dev/KMSUsingRESTAPI.html)
If you already have a request, you can pre-sign the request following the

@@ -48,20 +32,3 @@ section bellow.

JavaScript Example:
```javascript
const { S3RequestPresigner } = require("@aws-sdk/s3-request-presigner");
const { Sha256 } = require("@aws-crypto/sha256-browser");
const { Hash } = require("@smithy/hash-node");
const signer = new S3RequestPresigner({
region: regionProvider,
credentials: credentialsProvider,
sha256: Hash.bind(null, "sha256"), // In Node.js
//sha256: Sha256 // In browsers
});
const presigned = await signer.presign(request);
```
ES6 Example:
```javascript
import { S3RequestPresigner } from "@aws-sdk/s3-request-presigner";

@@ -90,9 +57,2 @@ import { Sha256 } from "@aws-crypto/sha256-browser";

If your request contains server-side encryption(`x-amz-server-side-encryption*`)
headers, because of S3 limitation, you need to send these headers along
with the presigned url. That is to say, the url only from calling `formatUrl()`
to `presigned` is not sufficient to make a request. You need to send the
server-side encryption headers along with the url. These headers remain in the
`presigned.headers`
### Get Presigned URL with headers that cannot be signed

@@ -147,2 +107,24 @@

For more information, please go to [S3 SSE reference](https://docs.aws.amazon.com/AmazonS3/latest/dev/KMSUsingRESTAPI.html)
### PutObject with use of `hoistableHeaders`
`hoistableHeaders` overrides the default behavior of not hoisting
any headers that begin with `x-amz-*`.
```js
// example: Server Side Encryption headers
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
const params = {
Key: "...",
Bucket: "...",
ServerSideEncryption: "aws:kms",
SSEKMSKeyId: "arn:aws:kms:us-west-2:0000:key/abcd-1234-abcd",
};
const s3Client = new S3Client();
const command = new PutObjectCommand(params);
const preSignedUrl = await getSignedUrl(s3Client, command, {
hoistableHeaders: new Set(["x-amz-server-side-encryption", "x-amz-server-side-encryption-aws-kms-key-id"]),
});
```
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