@aws-sdk/s3-request-presigner 3.460.0 → 3.461.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,11 +29,18 @@ const getSignedUrl = async (client, command, options = {}) => {
29
29
  delete request.headers["amz-sdk-invocation-id"];
30
30
  delete request.headers["amz-sdk-request"];
31
31
  delete request.headers["x-amz-user-agent"];
32
- const presigned = await s3Presigner.presign(request, {
32
+ let presigned;
33
+ const presignerOptions = {
33
34
  ...options,
34
35
  signingRegion: (_a = options.signingRegion) !== null && _a !== void 0 ? _a : context["signing_region"],
35
36
  signingService: (_b = options.signingService) !== null && _b !== void 0 ? _b : context["signing_service"],
36
- });
37
+ };
38
+ if (context.s3ExpressIdentity) {
39
+ presigned = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions);
40
+ }
41
+ else {
42
+ presigned = await s3Presigner.presign(request, presignerOptions);
43
+ }
37
44
  return {
38
45
  response: {},
39
46
  output: {
@@ -14,6 +14,30 @@ class S3RequestPresigner {
14
14
  this.signer = new signature_v4_multi_region_1.SignatureV4MultiRegion(resolvedOptions);
15
15
  }
16
16
  presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
17
+ this.prepareRequest(requestToSign, {
18
+ unsignableHeaders,
19
+ unhoistableHeaders,
20
+ });
21
+ return this.signer.presign(requestToSign, {
22
+ expiresIn: 900,
23
+ unsignableHeaders,
24
+ unhoistableHeaders,
25
+ ...options,
26
+ });
27
+ }
28
+ presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
29
+ this.prepareRequest(requestToSign, {
30
+ unsignableHeaders,
31
+ unhoistableHeaders,
32
+ });
33
+ return this.signer.presignWithCredentials(requestToSign, credentials, {
34
+ expiresIn: 900,
35
+ unsignableHeaders,
36
+ unhoistableHeaders,
37
+ ...options,
38
+ });
39
+ }
40
+ prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set() } = {}) {
17
41
  unsignableHeaders.add("content-type");
18
42
  Object.keys(requestToSign.headers)
19
43
  .map((header) => header.toLowerCase())
@@ -28,12 +52,6 @@ class S3RequestPresigner {
28
52
  if (!currentHostHeader || (currentHostHeader === requestToSign.hostname && requestToSign.port != null)) {
29
53
  requestToSign.headers.host = expectedHostHeader;
30
54
  }
31
- return this.signer.presign(requestToSign, {
32
- expiresIn: 900,
33
- unsignableHeaders,
34
- unhoistableHeaders,
35
- ...options,
36
- });
37
55
  }
38
56
  }
39
57
  exports.S3RequestPresigner = S3RequestPresigner;
@@ -24,11 +24,18 @@ export const getSignedUrl = async (client, command, options = {}) => {
24
24
  delete request.headers["amz-sdk-invocation-id"];
25
25
  delete request.headers["amz-sdk-request"];
26
26
  delete request.headers["x-amz-user-agent"];
27
- const presigned = await s3Presigner.presign(request, {
27
+ let presigned;
28
+ const presignerOptions = {
28
29
  ...options,
29
30
  signingRegion: options.signingRegion ?? context["signing_region"],
30
31
  signingService: options.signingService ?? context["signing_service"],
31
- });
32
+ };
33
+ if (context.s3ExpressIdentity) {
34
+ presigned = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions);
35
+ }
36
+ else {
37
+ presigned = await s3Presigner.presign(request, presignerOptions);
38
+ }
32
39
  return {
33
40
  response: {},
34
41
  output: {
@@ -11,6 +11,30 @@ export class S3RequestPresigner {
11
11
  this.signer = new SignatureV4MultiRegion(resolvedOptions);
12
12
  }
13
13
  presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
14
+ this.prepareRequest(requestToSign, {
15
+ unsignableHeaders,
16
+ unhoistableHeaders,
17
+ });
18
+ return this.signer.presign(requestToSign, {
19
+ expiresIn: 900,
20
+ unsignableHeaders,
21
+ unhoistableHeaders,
22
+ ...options,
23
+ });
24
+ }
25
+ presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
26
+ this.prepareRequest(requestToSign, {
27
+ unsignableHeaders,
28
+ unhoistableHeaders,
29
+ });
30
+ return this.signer.presignWithCredentials(requestToSign, credentials, {
31
+ expiresIn: 900,
32
+ unsignableHeaders,
33
+ unhoistableHeaders,
34
+ ...options,
35
+ });
36
+ }
37
+ prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set() } = {}) {
14
38
  unsignableHeaders.add("content-type");
15
39
  Object.keys(requestToSign.headers)
16
40
  .map((header) => header.toLowerCase())
@@ -25,11 +49,5 @@ export class S3RequestPresigner {
25
49
  if (!currentHostHeader || (currentHostHeader === requestToSign.hostname && requestToSign.port != null)) {
26
50
  requestToSign.headers.host = expectedHostHeader;
27
51
  }
28
- return this.signer.presign(requestToSign, {
29
- expiresIn: 900,
30
- unsignableHeaders,
31
- unhoistableHeaders,
32
- ...options,
33
- });
34
52
  }
35
53
  }
@@ -1,3 +1,6 @@
1
1
  import { Client, Command } from "@smithy/smithy-client";
2
2
  import { MetadataBearer, RequestPresigningArguments } from "@smithy/types";
3
+ /**
4
+ * @public
5
+ */
3
6
  export declare const getSignedUrl: <InputTypesUnion extends object, InputType extends InputTypesUnion, OutputType extends MetadataBearer = MetadataBearer>(client: Client<any, InputTypesUnion, MetadataBearer, any>, command: Command<InputType, OutputType, any, InputTypesUnion, MetadataBearer>, options?: RequestPresigningArguments) => Promise<string>;
@@ -1,5 +1,5 @@
1
1
  import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";
2
- import { RequestPresigner, RequestPresigningArguments } from "@smithy/types";
2
+ import { AwsCredentialIdentity, RequestPresigner, RequestPresigningArguments } from "@smithy/types";
3
3
  import { HttpRequest as IHttpRequest } from "@smithy/types";
4
4
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
5
  export type S3RequestPresignerOptions = PartialBy<SignatureV4MultiRegionInit, "service" | "uriEscapePath"> & {
@@ -9,5 +9,7 @@ export declare class S3RequestPresigner implements RequestPresigner {
9
9
  private readonly signer;
10
10
  constructor(options: S3RequestPresignerOptions);
11
11
  presign(requestToSign: IHttpRequest, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
12
+ presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
13
+ private prepareRequest;
12
14
  }
13
15
  export {};
@@ -1,5 +1,9 @@
1
1
  import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";
2
- import { RequestPresigner, RequestPresigningArguments } from "@smithy/types";
2
+ import {
3
+ AwsCredentialIdentity,
4
+ RequestPresigner,
5
+ RequestPresigningArguments,
6
+ } from "@smithy/types";
3
7
  import { HttpRequest as IHttpRequest } from "@smithy/types";
4
8
  type PartialBy<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> &
5
9
  Partial<Pick<T, K>>;
@@ -20,5 +24,15 @@ export declare class S3RequestPresigner implements RequestPresigner {
20
24
  ...options
21
25
  }?: RequestPresigningArguments
22
26
  ): Promise<IHttpRequest>;
27
+ presignWithCredentials(
28
+ requestToSign: IHttpRequest,
29
+ credentials: AwsCredentialIdentity,
30
+ {
31
+ unsignableHeaders,
32
+ unhoistableHeaders,
33
+ ...options
34
+ }?: RequestPresigningArguments
35
+ ): Promise<IHttpRequest>;
36
+ private prepareRequest;
23
37
  }
24
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/s3-request-presigner",
3
- "version": "3.460.0",
3
+ "version": "3.461.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@aws-sdk/signature-v4-multi-region": "3.460.0",
24
+ "@aws-sdk/signature-v4-multi-region": "3.461.0",
25
25
  "@aws-sdk/types": "3.460.0",
26
26
  "@aws-sdk/util-format-url": "3.460.0",
27
27
  "@smithy/middleware-endpoint": "^2.2.0",
@@ -31,7 +31,7 @@
31
31
  "tslib": "^2.5.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@aws-sdk/client-s3": "3.460.0",
34
+ "@aws-sdk/client-s3": "3.461.0",
35
35
  "@smithy/hash-node": "^2.0.15",
36
36
  "@tsconfig/recommended": "1.0.1",
37
37
  "@types/node": "^14.14.31",