@aws-sdk/middleware-sdk-s3 3.972.36 → 3.972.38

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.
package/dist-cjs/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  'use strict';
2
2
 
3
- var protocolHttp = require('@smithy/protocol-http');
4
- var smithyClient = require('@smithy/smithy-client');
3
+ var client = require('@smithy/core/client');
4
+ var protocols = require('@smithy/core/protocols');
5
+ var serde = require('@smithy/core/serde');
5
6
  var toStream = require('./toStream');
6
- var utilArnParser = require('@aws-sdk/util-arn-parser');
7
- var protocols = require('@aws-sdk/core/protocols');
7
+ var util = require('@aws-sdk/core/util');
8
+ var protocols$1 = require('@aws-sdk/core/protocols');
8
9
  var schema = require('@smithy/core/schema');
9
- var signatureV4 = require('@smithy/signature-v4');
10
- var utilConfigProvider = require('@smithy/util-config-provider');
11
- var client = require('@aws-sdk/core/client');
10
+ var signatureV4MultiRegion = require('@aws-sdk/signature-v4-multi-region');
11
+ var config = require('@smithy/core/config');
12
+ var client$1 = require('@aws-sdk/core/client');
12
13
  var core = require('@smithy/core');
13
- var utilMiddleware = require('@smithy/util-middleware');
14
14
 
15
15
  const CONTENT_LENGTH_HEADER = "content-length";
16
16
  const DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length";
17
17
  function checkContentLengthHeader() {
18
18
  return (next, context) => async (args) => {
19
19
  const { request } = args;
20
- if (protocolHttp.HttpRequest.isInstance(request)) {
20
+ if (protocols.HttpRequest.isInstance(request)) {
21
21
  if (!(CONTENT_LENGTH_HEADER in request.headers) && !(DECODED_CONTENT_LENGTH_HEADER in request.headers)) {
22
22
  const message = `Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.`;
23
- if (typeof context?.logger?.warn === "function" && !(context.logger instanceof smithyClient.NoOpLogger)) {
23
+ if (typeof context?.logger?.warn === "function" && !(context.logger instanceof client.NoOpLogger)) {
24
24
  context.logger.warn(message);
25
25
  }
26
26
  else {
@@ -131,11 +131,11 @@ const s3ExpiresMiddleware = (config) => {
131
131
  return (next, context) => async (args) => {
132
132
  const result = await next(args);
133
133
  const { response } = result;
134
- if (protocolHttp.HttpResponse.isInstance(response)) {
134
+ if (protocols.HttpResponse.isInstance(response)) {
135
135
  if (response.headers.expires) {
136
136
  response.headers.expiresstring = response.headers.expires;
137
137
  try {
138
- smithyClient.parseRfc7231DateTime(response.headers.expires);
138
+ serde.parseRfc7231DateTime(response.headers.expires);
139
139
  }
140
140
  catch (e) {
141
141
  context.logger?.warn(`AWS SDK Warning for ${context.clientName}::${context.commandName} response parsing (${response.headers.expires}): ${e}`);
@@ -262,6 +262,9 @@ class S3ExpressIdentityProviderImpl {
262
262
  }
263
263
  }
264
264
 
265
+ class SignatureV4S3Express extends signatureV4MultiRegion.SignatureV4SignWithCredentials {
266
+ }
267
+
265
268
  const S3_EXPRESS_BUCKET_TYPE = "Directory";
266
269
  const S3_EXPRESS_BACKEND = "S3Express";
267
270
  const S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
@@ -270,51 +273,11 @@ const SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
270
273
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH";
271
274
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth";
272
275
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = {
273
- environmentVariableSelector: (env) => utilConfigProvider.booleanSelector(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, utilConfigProvider.SelectorType.ENV),
274
- configFileSelector: (profile) => utilConfigProvider.booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, utilConfigProvider.SelectorType.CONFIG),
276
+ environmentVariableSelector: (env) => config.booleanSelector(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, config.SelectorType.ENV),
277
+ configFileSelector: (profile) => config.booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, config.SelectorType.CONFIG),
275
278
  default: false,
276
279
  };
277
280
 
278
- class SignatureV4S3Express extends signatureV4.SignatureV4 {
279
- async signWithCredentials(requestToSign, credentials, options) {
280
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
281
- requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
282
- const privateAccess = this;
283
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
284
- return privateAccess.signRequest(requestToSign, options ?? {});
285
- }
286
- async presignWithCredentials(requestToSign, credentials, options) {
287
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
288
- delete requestToSign.headers[SESSION_TOKEN_HEADER];
289
- requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
290
- requestToSign.query = requestToSign.query ?? {};
291
- requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
292
- const privateAccess = this;
293
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
294
- return this.presign(requestToSign, options);
295
- }
296
- }
297
- function getCredentialsWithoutSessionToken(credentials) {
298
- const credentialsWithoutSessionToken = {
299
- accessKeyId: credentials.accessKeyId,
300
- secretAccessKey: credentials.secretAccessKey,
301
- expiration: credentials.expiration,
302
- };
303
- return credentialsWithoutSessionToken;
304
- }
305
- function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
306
- const id = setTimeout(() => {
307
- throw new Error("SignatureV4S3Express credential override was created but not called.");
308
- }, 10);
309
- const currentCredentialProvider = privateAccess.credentialProvider;
310
- const overrideCredentialsProviderOnce = () => {
311
- clearTimeout(id);
312
- privateAccess.credentialProvider = currentCredentialProvider;
313
- return Promise.resolve(credentialsWithoutSessionToken);
314
- };
315
- privateAccess.credentialProvider = overrideCredentialsProviderOnce;
316
- }
317
-
318
281
  const s3ExpressMiddleware = (options) => {
319
282
  return (next, context) => async (args) => {
320
283
  if (context.endpointV2) {
@@ -323,7 +286,7 @@ const s3ExpressMiddleware = (options) => {
323
286
  const isS3ExpressBucket = endpoint.properties?.backend === S3_EXPRESS_BACKEND ||
324
287
  endpoint.properties?.bucketType === S3_EXPRESS_BUCKET_TYPE;
325
288
  if (isS3ExpressBucket) {
326
- client.setFeature(context, "S3_EXPRESS_BUCKET", "J");
289
+ client$1.setFeature(context, "S3_EXPRESS_BUCKET", "J");
327
290
  context.isS3ExpressBucket = true;
328
291
  }
329
292
  if (isS3ExpressAuth) {
@@ -333,7 +296,7 @@ const s3ExpressMiddleware = (options) => {
333
296
  Bucket: requestBucket,
334
297
  });
335
298
  context.s3ExpressIdentity = s3ExpressIdentity;
336
- if (protocolHttp.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
299
+ if (protocols.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
337
300
  args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
338
301
  }
339
302
  }
@@ -368,10 +331,10 @@ const defaultErrorHandler = (signingProperties) => (error) => {
368
331
  const defaultSuccessHandler = (httpResponse, signingProperties) => { };
369
332
  const s3ExpressHttpSigningMiddlewareOptions = core.httpSigningMiddlewareOptions;
370
333
  const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (args) => {
371
- if (!protocolHttp.HttpRequest.isInstance(args.request)) {
334
+ if (!protocols.HttpRequest.isInstance(args.request)) {
372
335
  return next(args);
373
336
  }
374
- const smithyContext = utilMiddleware.getSmithyContext(context);
337
+ const smithyContext = client.getSmithyContext(context);
375
338
  const scheme = smithyContext.selectedHttpAuthScheme;
376
339
  if (!scheme) {
377
340
  throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
@@ -422,7 +385,7 @@ const THROW_IF_EMPTY_BODY = {
422
385
  const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
423
386
  const result = await next(args);
424
387
  const { response } = result;
425
- if (!protocolHttp.HttpResponse.isInstance(response)) {
388
+ if (!protocols.HttpResponse.isInstance(response)) {
426
389
  return result;
427
390
  }
428
391
  const { statusCode, body } = response;
@@ -504,7 +467,7 @@ const bucketEndpointMiddlewareOptions = {
504
467
  function validateBucketNameMiddleware({ bucketEndpoint }) {
505
468
  return (next) => async (args) => {
506
469
  const { input: { Bucket }, } = args;
507
- if (!bucketEndpoint && typeof Bucket === "string" && !utilArnParser.validate(Bucket) && Bucket.indexOf("/") >= 0) {
470
+ if (!bucketEndpoint && typeof Bucket === "string" && !util.validate(Bucket) && Bucket.indexOf("/") >= 0) {
508
471
  const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
509
472
  err.name = "InvalidBucketName";
510
473
  throw err;
@@ -525,7 +488,7 @@ const getValidateBucketNamePlugin = (options) => ({
525
488
  },
526
489
  });
527
490
 
528
- class S3RestXmlProtocol extends protocols.AwsRestXmlProtocol {
491
+ class S3RestXmlProtocol extends protocols$1.AwsRestXmlProtocol {
529
492
  async serializeRequest(operationSchema, input, context) {
530
493
  const request = await super.serializeRequest(operationSchema, input, context);
531
494
  const ns = schema.NormalizedSchema.of(operationSchema.input);
@@ -1,5 +1,5 @@
1
- import { HttpRequest } from "@smithy/protocol-http";
2
- import { NoOpLogger } from "@smithy/smithy-client";
1
+ import { NoOpLogger } from "@smithy/core/client";
2
+ import { HttpRequest } from "@smithy/core/protocols";
3
3
  const CONTENT_LENGTH_HEADER = "content-length";
4
4
  const DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length";
5
5
  export function checkContentLengthHeader() {
@@ -1,5 +1,5 @@
1
- import { HttpResponse } from "@smithy/protocol-http";
2
- import { parseRfc7231DateTime } from "@smithy/smithy-client";
1
+ import { HttpResponse } from "@smithy/core/protocols";
2
+ import { parseRfc7231DateTime } from "@smithy/core/serde";
3
3
  export const s3ExpiresMiddleware = (config) => {
4
4
  return (next, context) => async (args) => {
5
5
  const result = await next(args);
@@ -1,41 +1,3 @@
1
- import { SignatureV4 } from "@smithy/signature-v4";
2
- import { SESSION_TOKEN_HEADER, SESSION_TOKEN_QUERY_PARAM } from "../constants";
3
- export class SignatureV4S3Express extends SignatureV4 {
4
- async signWithCredentials(requestToSign, credentials, options) {
5
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
6
- requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
7
- const privateAccess = this;
8
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
9
- return privateAccess.signRequest(requestToSign, options ?? {});
10
- }
11
- async presignWithCredentials(requestToSign, credentials, options) {
12
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
13
- delete requestToSign.headers[SESSION_TOKEN_HEADER];
14
- requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
15
- requestToSign.query = requestToSign.query ?? {};
16
- requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
17
- const privateAccess = this;
18
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
19
- return this.presign(requestToSign, options);
20
- }
21
- }
22
- function getCredentialsWithoutSessionToken(credentials) {
23
- const credentialsWithoutSessionToken = {
24
- accessKeyId: credentials.accessKeyId,
25
- secretAccessKey: credentials.secretAccessKey,
26
- expiration: credentials.expiration,
27
- };
28
- return credentialsWithoutSessionToken;
29
- }
30
- function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
31
- const id = setTimeout(() => {
32
- throw new Error("SignatureV4S3Express credential override was created but not called.");
33
- }, 10);
34
- const currentCredentialProvider = privateAccess.credentialProvider;
35
- const overrideCredentialsProviderOnce = () => {
36
- clearTimeout(id);
37
- privateAccess.credentialProvider = currentCredentialProvider;
38
- return Promise.resolve(credentialsWithoutSessionToken);
39
- };
40
- privateAccess.credentialProvider = overrideCredentialsProviderOnce;
1
+ import { SignatureV4SignWithCredentials } from "@aws-sdk/signature-v4-multi-region";
2
+ export class SignatureV4S3Express extends SignatureV4SignWithCredentials {
41
3
  }
@@ -1,4 +1,4 @@
1
- import { booleanSelector, SelectorType } from "@smithy/util-config-provider";
1
+ import { booleanSelector, SelectorType } from "@smithy/core/config";
2
2
  export const S3_EXPRESS_BUCKET_TYPE = "Directory";
3
3
  export const S3_EXPRESS_BACKEND = "S3Express";
4
4
  export const S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
@@ -1,6 +1,6 @@
1
1
  import { httpSigningMiddlewareOptions } from "@smithy/core";
2
- import { HttpRequest } from "@smithy/protocol-http";
3
- import { getSmithyContext } from "@smithy/util-middleware";
2
+ import { getSmithyContext } from "@smithy/core/client";
3
+ import { HttpRequest } from "@smithy/core/protocols";
4
4
  import { signS3Express } from "./signS3Express";
5
5
  const defaultErrorHandler = (signingProperties) => (error) => {
6
6
  throw error;
@@ -1,5 +1,5 @@
1
1
  import { setFeature } from "@aws-sdk/core/client";
2
- import { HttpRequest } from "@smithy/protocol-http";
2
+ import { HttpRequest } from "@smithy/core/protocols";
3
3
  import { S3_EXPRESS_AUTH_SCHEME, S3_EXPRESS_BACKEND, S3_EXPRESS_BUCKET_TYPE, SESSION_TOKEN_HEADER } from "../constants";
4
4
  export const s3ExpressMiddleware = (options) => {
5
5
  return (next, context) => async (args) => {
@@ -1,4 +1,4 @@
1
- import { HttpResponse } from "@smithy/protocol-http";
1
+ import { HttpResponse } from "@smithy/core/protocols";
2
2
  import { toStream } from "./toStream";
3
3
  const THROW_IF_EMPTY_BODY = {
4
4
  CopyObjectCommand: true,
@@ -1,4 +1,4 @@
1
- import { validate as validateArn } from "@aws-sdk/util-arn-parser";
1
+ import { validate as validateArn } from "@aws-sdk/core/util";
2
2
  import { bucketEndpointMiddleware, bucketEndpointMiddlewareOptions } from "./bucket-endpoint-middleware";
3
3
  export function validateBucketNameMiddleware({ bucketEndpoint }) {
4
4
  return (next) => async (args) => {
@@ -1,17 +1,6 @@
1
- import type { AwsCredentialIdentity } from "@aws-sdk/types";
2
- import { SignatureV4 } from "@smithy/signature-v4";
3
- import type { HttpRequest as IHttpRequest, RequestPresigningArguments, RequestSigningArguments } from "@smithy/types";
4
- export declare class SignatureV4S3Express extends SignatureV4 {
5
- /**
6
- * Signs with alternate provided credentials instead of those provided in the
7
- * constructor.
8
- *
9
- * Additionally omits the credential sessionToken and assigns it to the
10
- * alternate header field for S3 Express.
11
- */
12
- signWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, options?: RequestSigningArguments): Promise<IHttpRequest>;
13
- /**
14
- * Similar to {@link SignatureV4S3Express#signWithCredentials} but for presigning.
15
- */
16
- presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, options?: RequestPresigningArguments): Promise<IHttpRequest>;
1
+ import { SignatureV4SignWithCredentials } from "@aws-sdk/signature-v4-multi-region";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare class SignatureV4S3Express extends SignatureV4SignWithCredentials {
17
6
  }
@@ -1,4 +1,4 @@
1
- import type { LoadedConfigSelectors } from "@smithy/node-config-provider";
1
+ import type { LoadedConfigSelectors } from "@smithy/core/config";
2
2
  /**
3
3
  * @internal
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { IHttpRequest } from "@smithy/protocol-http";
1
+ import type { IHttpRequest } from "@smithy/core/protocols";
2
2
  import type { AuthScheme, AwsCredentialIdentity, FinalizeRequestMiddleware, Pluggable, RequestSigner } from "@smithy/types";
3
3
  interface SigningProperties {
4
4
  signingRegion: string;
@@ -1,19 +1,2 @@
1
- import { AwsCredentialIdentity } from "@aws-sdk/types";
2
- import { SignatureV4 } from "@smithy/signature-v4";
3
- import {
4
- HttpRequest as IHttpRequest,
5
- RequestPresigningArguments,
6
- RequestSigningArguments,
7
- } from "@smithy/types";
8
- export declare class SignatureV4S3Express extends SignatureV4 {
9
- signWithCredentials(
10
- requestToSign: IHttpRequest,
11
- credentials: AwsCredentialIdentity,
12
- options?: RequestSigningArguments
13
- ): Promise<IHttpRequest>;
14
- presignWithCredentials(
15
- requestToSign: IHttpRequest,
16
- credentials: AwsCredentialIdentity,
17
- options?: RequestPresigningArguments
18
- ): Promise<IHttpRequest>;
19
- }
1
+ import { SignatureV4SignWithCredentials } from "@aws-sdk/signature-v4-multi-region";
2
+ export declare class SignatureV4S3Express extends SignatureV4SignWithCredentials {}
@@ -1,4 +1,4 @@
1
- import { LoadedConfigSelectors } from "@smithy/node-config-provider";
1
+ import { LoadedConfigSelectors } from "@smithy/core/config";
2
2
  export declare const S3_EXPRESS_BUCKET_TYPE = "Directory";
3
3
  export declare const S3_EXPRESS_BACKEND = "S3Express";
4
4
  export declare const S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
@@ -1,4 +1,4 @@
1
- import { IHttpRequest } from "@smithy/protocol-http";
1
+ import { IHttpRequest } from "@smithy/core/protocols";
2
2
  import {
3
3
  AuthScheme,
4
4
  AwsCredentialIdentity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.972.36",
3
+ "version": "3.972.38",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
6
6
  "build:cjs": "node ../../scripts/compilation/inline middleware-sdk-s3",
@@ -28,19 +28,12 @@
28
28
  },
29
29
  "license": "Apache-2.0",
30
30
  "dependencies": {
31
- "@aws-sdk/core": "^3.974.7",
31
+ "@aws-sdk/core": "^3.974.9",
32
+ "@aws-sdk/signature-v4-multi-region": "^3.996.26",
32
33
  "@aws-sdk/types": "^3.973.8",
33
- "@aws-sdk/util-arn-parser": "^3.972.3",
34
- "@smithy/core": "^3.23.17",
35
- "@smithy/node-config-provider": "^4.3.14",
36
- "@smithy/protocol-http": "^5.3.14",
37
- "@smithy/signature-v4": "^5.3.14",
38
- "@smithy/smithy-client": "^4.12.13",
34
+ "@smithy/core": "^3.24.1",
35
+ "@smithy/signature-v4": "^5.4.1",
39
36
  "@smithy/types": "^4.14.1",
40
- "@smithy/util-config-provider": "^4.2.2",
41
- "@smithy/util-middleware": "^4.2.14",
42
- "@smithy/util-stream": "^4.5.25",
43
- "@smithy/util-utf8": "^4.2.2",
44
37
  "tslib": "^2.6.2"
45
38
  },
46
39
  "devDependencies": {