@aws-sdk/middleware-sdk-s3 3.972.51 → 3.972.52

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,521 +1,4 @@
1
- 'use strict';
2
-
3
- var client = require('@smithy/core/client');
4
- var protocols = require('@smithy/core/protocols');
5
- var serde = require('@smithy/core/serde');
6
- var signatureV4MultiRegion = require('@aws-sdk/signature-v4-multi-region');
7
- var config = require('@smithy/core/config');
8
- var client$1 = require('@aws-sdk/core/client');
9
- var core = require('@smithy/core');
10
- var node_stream = require('node:stream');
11
- var util = require('@aws-sdk/core/util');
12
- var protocols$1 = require('@aws-sdk/core/protocols');
13
- var schema = require('@smithy/core/schema');
14
-
15
- const CONTENT_LENGTH_HEADER = "content-length";
16
- const DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length";
17
- function checkContentLengthHeader() {
18
- return (next, context) => async (args) => {
19
- const { request } = args;
20
- if (protocols.HttpRequest.isInstance(request)) {
21
- if (!(CONTENT_LENGTH_HEADER in request.headers) && !(DECODED_CONTENT_LENGTH_HEADER in request.headers)) {
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 client.NoOpLogger)) {
24
- context.logger.warn(message);
25
- }
26
- else {
27
- console.warn(message);
28
- }
29
- }
30
- }
31
- return next({ ...args });
32
- };
33
- }
34
- const checkContentLengthHeaderMiddlewareOptions = {
35
- step: "finalizeRequest",
36
- tags: ["CHECK_CONTENT_LENGTH_HEADER"],
37
- name: "getCheckContentLengthHeaderPlugin",
38
- override: true,
39
- };
40
- const getCheckContentLengthHeaderPlugin = (unused) => ({
41
- applyToStack: (clientStack) => {
42
- clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
43
- },
44
- });
45
-
46
- const regionRedirectEndpointMiddleware = (config) => {
47
- return (next, context) => async (args) => {
48
- const originalRegion = await config.region();
49
- const regionProviderRef = config.region;
50
- let unlock = () => { };
51
- if (context.__s3RegionRedirect) {
52
- Object.defineProperty(config, "region", {
53
- writable: false,
54
- value: async () => {
55
- return context.__s3RegionRedirect;
56
- },
57
- });
58
- unlock = () => Object.defineProperty(config, "region", {
59
- writable: true,
60
- value: regionProviderRef,
61
- });
62
- }
63
- try {
64
- const result = await next(args);
65
- if (context.__s3RegionRedirect) {
66
- unlock();
67
- const region = await config.region();
68
- if (originalRegion !== region) {
69
- throw new Error("Region was not restored following S3 region redirect.");
70
- }
71
- }
72
- return result;
73
- }
74
- catch (e) {
75
- unlock();
76
- throw e;
77
- }
78
- };
79
- };
80
- const regionRedirectEndpointMiddlewareOptions = {
81
- tags: ["REGION_REDIRECT", "S3"],
82
- name: "regionRedirectEndpointMiddleware",
83
- override: true,
84
- relation: "before",
85
- toMiddleware: "endpointV2Middleware",
86
- };
87
-
88
- function regionRedirectMiddleware(clientConfig) {
89
- return (next, context) => async (args) => {
90
- try {
91
- return await next(args);
92
- }
93
- catch (err) {
94
- if (clientConfig.followRegionRedirects) {
95
- const statusCode = err?.$metadata?.httpStatusCode;
96
- const isHeadBucket = context.commandName === "HeadBucketCommand";
97
- const bucketRegionHeader = err?.$response?.headers?.["x-amz-bucket-region"];
98
- if (bucketRegionHeader) {
99
- if (statusCode === 301 ||
100
- (statusCode === 400 && (err?.name === "IllegalLocationConstraintException" || isHeadBucket))) {
101
- try {
102
- const actualRegion = bucketRegionHeader;
103
- context.logger?.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`);
104
- context.__s3RegionRedirect = actualRegion;
105
- }
106
- catch (e) {
107
- throw new Error("Region redirect failed: " + e);
108
- }
109
- return next(args);
110
- }
111
- }
112
- }
113
- throw err;
114
- }
115
- };
116
- }
117
- const regionRedirectMiddlewareOptions = {
118
- step: "initialize",
119
- tags: ["REGION_REDIRECT", "S3"],
120
- name: "regionRedirectMiddleware",
121
- override: true,
122
- };
123
- const getRegionRedirectMiddlewarePlugin = (clientConfig) => ({
124
- applyToStack: (clientStack) => {
125
- clientStack.add(regionRedirectMiddleware(clientConfig), regionRedirectMiddlewareOptions);
126
- clientStack.addRelativeTo(regionRedirectEndpointMiddleware(clientConfig), regionRedirectEndpointMiddlewareOptions);
127
- },
128
- });
129
-
130
- class S3ExpressIdentityCache {
131
- data;
132
- lastPurgeTime = Date.now();
133
- static EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS = 30_000;
134
- constructor(data = {}) {
135
- this.data = data;
136
- }
137
- get(key) {
138
- const entry = this.data[key];
139
- if (!entry) {
140
- return;
141
- }
142
- return entry;
143
- }
144
- set(key, entry) {
145
- this.data[key] = entry;
146
- return entry;
147
- }
148
- delete(key) {
149
- delete this.data[key];
150
- }
151
- async purgeExpired() {
152
- const now = Date.now();
153
- if (this.lastPurgeTime + S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS > now) {
154
- return;
155
- }
156
- for (const key in this.data) {
157
- const entry = this.data[key];
158
- if (!entry.isRefreshing) {
159
- const credential = await entry.identity;
160
- if (credential.expiration) {
161
- if (credential.expiration.getTime() < now) {
162
- delete this.data[key];
163
- }
164
- }
165
- }
166
- }
167
- }
168
- }
169
-
170
- class S3ExpressIdentityCacheEntry {
171
- _identity;
172
- isRefreshing;
173
- accessed;
174
- constructor(_identity, isRefreshing = false, accessed = Date.now()) {
175
- this._identity = _identity;
176
- this.isRefreshing = isRefreshing;
177
- this.accessed = accessed;
178
- }
179
- get identity() {
180
- this.accessed = Date.now();
181
- return this._identity;
182
- }
183
- }
184
-
185
- class S3ExpressIdentityProviderImpl {
186
- createSessionFn;
187
- cache;
188
- static REFRESH_WINDOW_MS = 60_000;
189
- constructor(createSessionFn, cache = new S3ExpressIdentityCache()) {
190
- this.createSessionFn = createSessionFn;
191
- this.cache = cache;
192
- }
193
- async getS3ExpressIdentity(awsIdentity, identityProperties) {
194
- const key = identityProperties.Bucket;
195
- const { cache } = this;
196
- const entry = cache.get(key);
197
- if (entry) {
198
- return entry.identity.then((identity) => {
199
- const isExpired = (identity.expiration?.getTime() ?? 0) < Date.now();
200
- if (isExpired) {
201
- return cache.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
202
- }
203
- const isExpiringSoon = (identity.expiration?.getTime() ?? 0) < Date.now() + S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS;
204
- if (isExpiringSoon && !entry.isRefreshing) {
205
- entry.isRefreshing = true;
206
- this.getIdentity(key).then((id) => {
207
- cache.set(key, new S3ExpressIdentityCacheEntry(Promise.resolve(id)));
208
- });
209
- }
210
- return identity;
211
- });
212
- }
213
- return cache.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
214
- }
215
- async getIdentity(key) {
216
- await this.cache.purgeExpired().catch((error) => {
217
- console.warn("Error while clearing expired entries in S3ExpressIdentityCache: \n" + error);
218
- });
219
- const session = await this.createSessionFn(key);
220
- if (!session.Credentials?.AccessKeyId || !session.Credentials?.SecretAccessKey) {
221
- throw new Error("s3#createSession response credential missing AccessKeyId or SecretAccessKey.");
222
- }
223
- const identity = {
224
- accessKeyId: session.Credentials.AccessKeyId,
225
- secretAccessKey: session.Credentials.SecretAccessKey,
226
- sessionToken: session.Credentials.SessionToken,
227
- expiration: session.Credentials.Expiration ? new Date(session.Credentials.Expiration) : undefined,
228
- };
229
- return identity;
230
- }
231
- }
232
-
233
- const resolveS3Config = (input, { session, }) => {
234
- const [s3ClientProvider, CreateSessionCommandCtor] = session;
235
- const { forcePathStyle, useAccelerateEndpoint, disableMultiregionAccessPoints, followRegionRedirects, s3ExpressIdentityProvider, bucketEndpoint, expectContinueHeader, } = input;
236
- return Object.assign(input, {
237
- forcePathStyle: forcePathStyle ?? false,
238
- useAccelerateEndpoint: useAccelerateEndpoint ?? false,
239
- disableMultiregionAccessPoints: disableMultiregionAccessPoints ?? false,
240
- followRegionRedirects: followRegionRedirects ?? false,
241
- s3ExpressIdentityProvider: s3ExpressIdentityProvider ??
242
- new S3ExpressIdentityProviderImpl(async (key) => s3ClientProvider().send(new CreateSessionCommandCtor({
243
- Bucket: key,
244
- }))),
245
- bucketEndpoint: bucketEndpoint ?? false,
246
- expectContinueHeader: expectContinueHeader ?? 2_097_152,
247
- });
248
- };
249
-
250
- const s3ExpiresMiddleware = (config) => {
251
- return (next, context) => async (args) => {
252
- const result = await next(args);
253
- const { response } = result;
254
- if (protocols.HttpResponse.isInstance(response)) {
255
- if (response.headers.expires) {
256
- response.headers.expiresstring = response.headers.expires;
257
- try {
258
- serde.parseRfc7231DateTime(response.headers.expires);
259
- }
260
- catch (e) {
261
- context.logger?.warn(`AWS SDK Warning for ${context.clientName}::${context.commandName} response parsing (${response.headers.expires}): ${e}`);
262
- delete response.headers.expires;
263
- }
264
- }
265
- }
266
- return result;
267
- };
268
- };
269
- const s3ExpiresMiddlewareOptions = {
270
- tags: ["S3"],
271
- name: "s3ExpiresMiddleware",
272
- override: true,
273
- relation: "after",
274
- toMiddleware: "deserializerMiddleware",
275
- };
276
- const getS3ExpiresMiddlewarePlugin = (clientConfig) => ({
277
- applyToStack: (clientStack) => {
278
- clientStack.addRelativeTo(s3ExpiresMiddleware(), s3ExpiresMiddlewareOptions);
279
- },
280
- });
281
-
282
- class SignatureV4S3Express extends signatureV4MultiRegion.SignatureV4SignWithCredentials {
283
- }
284
-
285
- const S3_EXPRESS_BUCKET_TYPE = "Directory";
286
- const S3_EXPRESS_BACKEND = "S3Express";
287
- const S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
288
- const SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
289
- const SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
290
- const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH";
291
- const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth";
292
- const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = {
293
- environmentVariableSelector: (env) => config.booleanSelector(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, config.SelectorType.ENV),
294
- configFileSelector: (profile) => config.booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, config.SelectorType.CONFIG),
295
- default: false,
296
- };
297
-
298
- const s3ExpressMiddleware = (options) => {
299
- return (next, context) => async (args) => {
300
- if (context.endpointV2) {
301
- const endpoint = context.endpointV2;
302
- const isS3ExpressAuth = endpoint.properties?.authSchemes?.[0]?.name === S3_EXPRESS_AUTH_SCHEME;
303
- const isS3ExpressBucket = endpoint.properties?.backend === S3_EXPRESS_BACKEND ||
304
- endpoint.properties?.bucketType === S3_EXPRESS_BUCKET_TYPE;
305
- if (isS3ExpressBucket) {
306
- client$1.setFeature(context, "S3_EXPRESS_BUCKET", "J");
307
- context.isS3ExpressBucket = true;
308
- }
309
- if (isS3ExpressAuth) {
310
- const requestBucket = args.input.Bucket;
311
- if (requestBucket) {
312
- const s3ExpressIdentity = await options.s3ExpressIdentityProvider.getS3ExpressIdentity(await options.credentials(), {
313
- Bucket: requestBucket,
314
- });
315
- context.s3ExpressIdentity = s3ExpressIdentity;
316
- if (protocols.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
317
- args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
318
- }
319
- }
320
- }
321
- }
322
- return next(args);
323
- };
324
- };
325
- const s3ExpressMiddlewareOptions = {
326
- name: "s3ExpressMiddleware",
327
- step: "build",
328
- tags: ["S3", "S3_EXPRESS"],
329
- override: true,
330
- };
331
- const getS3ExpressPlugin = (options) => ({
332
- applyToStack: (clientStack) => {
333
- clientStack.add(s3ExpressMiddleware(options), s3ExpressMiddlewareOptions);
334
- },
335
- });
336
-
337
- const signS3Express = async (s3ExpressIdentity, signingOptions, request, sigV4MultiRegionSigner) => {
338
- const signedRequest = await sigV4MultiRegionSigner.signWithCredentials(request, s3ExpressIdentity, {});
339
- if (signedRequest.headers["X-Amz-Security-Token"] || signedRequest.headers["x-amz-security-token"]) {
340
- throw new Error("X-Amz-Security-Token must not be set for s3-express requests.");
341
- }
342
- return signedRequest;
343
- };
344
-
345
- const defaultErrorHandler = (signingProperties) => (error) => {
346
- throw error;
347
- };
348
- const defaultSuccessHandler = (httpResponse, signingProperties) => { };
349
- const s3ExpressHttpSigningMiddlewareOptions = core.httpSigningMiddlewareOptions;
350
- const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (args) => {
351
- if (!protocols.HttpRequest.isInstance(args.request)) {
352
- return next(args);
353
- }
354
- const smithyContext = client.getSmithyContext(context);
355
- const scheme = smithyContext.selectedHttpAuthScheme;
356
- if (!scheme) {
357
- throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
358
- }
359
- const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme;
360
- let request;
361
- if (context.s3ExpressIdentity) {
362
- request = await signS3Express(context.s3ExpressIdentity, signingProperties, args.request, await config.signer());
363
- }
364
- else {
365
- request = await signer.sign(args.request, identity, signingProperties);
366
- }
367
- const output = await next({
368
- ...args,
369
- request,
370
- }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
371
- (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
372
- return output;
373
- };
374
- const getS3ExpressHttpSigningPlugin = (config) => ({
375
- applyToStack: (clientStack) => {
376
- clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), core.httpSigningMiddlewareOptions);
377
- },
378
- });
379
-
380
- function toStream(bytes) {
381
- return node_stream.Readable.from(Buffer.from(bytes));
382
- }
383
-
384
- const THROW_IF_EMPTY_BODY = {
385
- CopyObjectCommand: true,
386
- UploadPartCopyCommand: true,
387
- CompleteMultipartUploadCommand: true,
388
- };
389
- const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
390
- const result = await next(args);
391
- const { response } = result;
392
- if (!protocols.HttpResponse.isInstance(response)) {
393
- return result;
394
- }
395
- const { statusCode, body } = response;
396
- if (statusCode < 200 || statusCode >= 300) {
397
- return result;
398
- }
399
- const bodyBytes = await collectBody(body, config);
400
- response.body = toStream(bodyBytes);
401
- if (bodyBytes.length === 0 && THROW_IF_EMPTY_BODY[context.commandName]) {
402
- const err = new Error("S3 aborted request");
403
- err.$metadata = {
404
- httpStatusCode: 503,
405
- };
406
- err.name = "InternalError";
407
- throw err;
408
- }
409
- const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
410
- if (bodyStringTail && bodyStringTail.endsWith("</Error>")) {
411
- response.statusCode = 503;
412
- }
413
- return result;
414
- };
415
- const collectBody = (streamBody = new Uint8Array(), context) => {
416
- if (streamBody instanceof Uint8Array) {
417
- return Promise.resolve(streamBody);
418
- }
419
- return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
420
- };
421
- const throw200ExceptionsMiddlewareOptions = {
422
- relation: "after",
423
- toMiddleware: "deserializerMiddleware",
424
- tags: ["THROW_200_EXCEPTIONS", "S3"],
425
- name: "throw200ExceptionsMiddleware",
426
- override: true,
427
- };
428
- const getThrow200ExceptionsPlugin = (config) => ({
429
- applyToStack: (clientStack) => {
430
- clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);
431
- },
432
- });
433
-
434
- function bucketEndpointMiddleware(options) {
435
- return (next, context) => async (args) => {
436
- if (options.bucketEndpoint) {
437
- const endpoint = context.endpointV2;
438
- if (endpoint) {
439
- const bucket = args.input.Bucket;
440
- if (typeof bucket === "string") {
441
- try {
442
- const bucketEndpointUrl = new URL(bucket);
443
- context.endpointV2 = {
444
- ...endpoint,
445
- url: bucketEndpointUrl,
446
- };
447
- }
448
- catch (e) {
449
- const warning = `@aws-sdk/middleware-sdk-s3: bucketEndpoint=true was set but Bucket=${bucket} could not be parsed as URL.`;
450
- if (context.logger?.constructor?.name === "NoOpLogger") {
451
- console.warn(warning);
452
- }
453
- else {
454
- context.logger?.warn?.(warning);
455
- }
456
- throw e;
457
- }
458
- }
459
- }
460
- }
461
- return next(args);
462
- };
463
- }
464
- const bucketEndpointMiddlewareOptions = {
465
- name: "bucketEndpointMiddleware",
466
- override: true,
467
- relation: "after",
468
- toMiddleware: "endpointV2Middleware",
469
- };
470
-
471
- function validateBucketNameMiddleware({ bucketEndpoint }) {
472
- return (next) => async (args) => {
473
- const { input: { Bucket }, } = args;
474
- if (!bucketEndpoint && typeof Bucket === "string" && !util.validate(Bucket) && Bucket.indexOf("/") >= 0) {
475
- const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
476
- err.name = "InvalidBucketName";
477
- throw err;
478
- }
479
- return next({ ...args });
480
- };
481
- }
482
- const validateBucketNameMiddlewareOptions = {
483
- step: "initialize",
484
- tags: ["VALIDATE_BUCKET_NAME"],
485
- name: "validateBucketNameMiddleware",
486
- override: true,
487
- };
488
- const getValidateBucketNamePlugin = (options) => ({
489
- applyToStack: (clientStack) => {
490
- clientStack.add(validateBucketNameMiddleware(options), validateBucketNameMiddlewareOptions);
491
- clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions);
492
- },
493
- });
494
-
495
- class S3RestXmlProtocol extends protocols$1.AwsRestXmlProtocol {
496
- async serializeRequest(operationSchema, input, context) {
497
- const request = await super.serializeRequest(operationSchema, input, context);
498
- const ns = schema.NormalizedSchema.of(operationSchema.input);
499
- const staticStructureSchema = ns.getSchema();
500
- let bucketMemberIndex = 0;
501
- const requiredMemberCount = staticStructureSchema[6] ?? 0;
502
- if (input && typeof input === "object") {
503
- for (const [memberName, memberNs] of ns.structIterator()) {
504
- if (++bucketMemberIndex > requiredMemberCount) {
505
- break;
506
- }
507
- if (memberName === "Bucket") {
508
- if (!input.Bucket && memberNs.getMergedTraits().httpLabel) {
509
- throw new Error(`No value provided for input HTTP label: Bucket.`);
510
- }
511
- break;
512
- }
513
- }
514
- }
515
- return request;
516
- }
517
- }
518
-
1
+ const { NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, S3RestXmlProtocol, SignatureV4S3Express, checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, getRegionRedirectMiddlewarePlugin, getS3ExpiresMiddlewarePlugin, getS3ExpressHttpSigningPlugin, getS3ExpressPlugin, getThrow200ExceptionsPlugin, getValidateBucketNamePlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, s3ExpressMiddleware, s3ExpressMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions } = require("@aws-sdk/middleware-sdk-s3/s3");
519
2
  exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS;
520
3
  exports.S3ExpressIdentityCache = S3ExpressIdentityCache;
521
4
  exports.S3ExpressIdentityCacheEntry = S3ExpressIdentityCacheEntry;
@@ -1,26 +1,24 @@
1
- 'use strict';
2
-
3
- var client = require('@smithy/core/client');
4
- var protocols = require('@smithy/core/protocols');
5
- var serde = require('@smithy/core/serde');
6
- var signatureV4MultiRegion = require('@aws-sdk/signature-v4-multi-region');
7
- var client$1 = require('@aws-sdk/core/client');
8
- require('@smithy/core/config');
9
- var core = require('@smithy/core');
10
- var node_stream = require('node:stream');
11
- var util = require('@aws-sdk/core/util');
12
- var protocols$1 = require('@aws-sdk/core/protocols');
13
- var schema = require('@smithy/core/schema');
1
+ const { NoOpLogger, getSmithyContext } = require("@smithy/core/client");
2
+ const { HttpRequest, HttpResponse } = require("@smithy/core/protocols");
3
+ const { parseRfc7231DateTime } = require("@smithy/core/serde");
4
+ const { SignatureV4SignWithCredentials } = require("@aws-sdk/signature-v4-multi-region");
5
+ const { setFeature } = require("@aws-sdk/core/client");
6
+ require("@smithy/core/config");
7
+ const { httpSigningMiddlewareOptions } = require("@smithy/core");
8
+ const { Readable } = require("node:stream");
9
+ const { validate, parse } = require("@aws-sdk/core/util");
10
+ const { AwsRestXmlProtocol } = require("@aws-sdk/core/protocols");
11
+ const { NormalizedSchema } = require("@smithy/core/schema");
14
12
 
15
13
  const CONTENT_LENGTH_HEADER = "content-length";
16
14
  const DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length";
17
15
  function checkContentLengthHeader() {
18
16
  return (next, context) => async (args) => {
19
17
  const { request } = args;
20
- if (protocols.HttpRequest.isInstance(request)) {
18
+ if (HttpRequest.isInstance(request)) {
21
19
  if (!(CONTENT_LENGTH_HEADER in request.headers) && !(DECODED_CONTENT_LENGTH_HEADER in request.headers)) {
22
20
  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 client.NoOpLogger)) {
21
+ if (typeof context?.logger?.warn === "function" && !(context.logger instanceof NoOpLogger)) {
24
22
  context.logger.warn(message);
25
23
  }
26
24
  else {
@@ -251,11 +249,11 @@ const s3ExpiresMiddleware = (config) => {
251
249
  return (next, context) => async (args) => {
252
250
  const result = await next(args);
253
251
  const { response } = result;
254
- if (protocols.HttpResponse.isInstance(response)) {
252
+ if (HttpResponse.isInstance(response)) {
255
253
  if (response.headers.expires) {
256
254
  response.headers.expiresstring = response.headers.expires;
257
255
  try {
258
- serde.parseRfc7231DateTime(response.headers.expires);
256
+ parseRfc7231DateTime(response.headers.expires);
259
257
  }
260
258
  catch (e) {
261
259
  context.logger?.warn(`AWS SDK Warning for ${context.clientName}::${context.commandName} response parsing (${response.headers.expires}): ${e}`);
@@ -279,7 +277,7 @@ const getS3ExpiresMiddlewarePlugin = (clientConfig) => ({
279
277
  },
280
278
  });
281
279
 
282
- class SignatureV4S3Express extends signatureV4MultiRegion.SignatureV4SignWithCredentials {
280
+ class SignatureV4S3Express extends SignatureV4SignWithCredentials {
283
281
  }
284
282
 
285
283
  const S3_EXPRESS_BUCKET_TYPE = "Directory";
@@ -296,7 +294,7 @@ const s3ExpressMiddleware = (options) => {
296
294
  const isS3ExpressBucket = endpoint.properties?.backend === S3_EXPRESS_BACKEND ||
297
295
  endpoint.properties?.bucketType === S3_EXPRESS_BUCKET_TYPE;
298
296
  if (isS3ExpressBucket) {
299
- client$1.setFeature(context, "S3_EXPRESS_BUCKET", "J");
297
+ setFeature(context, "S3_EXPRESS_BUCKET", "J");
300
298
  context.isS3ExpressBucket = true;
301
299
  }
302
300
  if (isS3ExpressAuth) {
@@ -306,7 +304,7 @@ const s3ExpressMiddleware = (options) => {
306
304
  Bucket: requestBucket,
307
305
  });
308
306
  context.s3ExpressIdentity = s3ExpressIdentity;
309
- if (protocols.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
307
+ if (HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
310
308
  args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
311
309
  }
312
310
  }
@@ -339,12 +337,12 @@ const defaultErrorHandler = (signingProperties) => (error) => {
339
337
  throw error;
340
338
  };
341
339
  const defaultSuccessHandler = (httpResponse, signingProperties) => { };
342
- const s3ExpressHttpSigningMiddlewareOptions = core.httpSigningMiddlewareOptions;
340
+ const s3ExpressHttpSigningMiddlewareOptions = httpSigningMiddlewareOptions;
343
341
  const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (args) => {
344
- if (!protocols.HttpRequest.isInstance(args.request)) {
342
+ if (!HttpRequest.isInstance(args.request)) {
345
343
  return next(args);
346
344
  }
347
- const smithyContext = client.getSmithyContext(context);
345
+ const smithyContext = getSmithyContext(context);
348
346
  const scheme = smithyContext.selectedHttpAuthScheme;
349
347
  if (!scheme) {
350
348
  throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
@@ -366,12 +364,12 @@ const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (arg
366
364
  };
367
365
  const getS3ExpressHttpSigningPlugin = (config) => ({
368
366
  applyToStack: (clientStack) => {
369
- clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), core.httpSigningMiddlewareOptions);
367
+ clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), httpSigningMiddlewareOptions);
370
368
  },
371
369
  });
372
370
 
373
371
  function toStream(bytes) {
374
- return node_stream.Readable.from(Buffer.from(bytes));
372
+ return Readable.from(Buffer.from(bytes));
375
373
  }
376
374
 
377
375
  const THROW_IF_EMPTY_BODY = {
@@ -382,7 +380,7 @@ const THROW_IF_EMPTY_BODY = {
382
380
  const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
383
381
  const result = await next(args);
384
382
  const { response } = result;
385
- if (!protocols.HttpResponse.isInstance(response)) {
383
+ if (!HttpResponse.isInstance(response)) {
386
384
  return result;
387
385
  }
388
386
  const { statusCode, body } = response;
@@ -464,7 +462,7 @@ const bucketEndpointMiddlewareOptions$1 = {
464
462
  function validateBucketNameMiddleware({ bucketEndpoint }) {
465
463
  return (next) => async (args) => {
466
464
  const { input: { Bucket }, } = args;
467
- if (!bucketEndpoint && typeof Bucket === "string" && !util.validate(Bucket) && Bucket.indexOf("/") >= 0) {
465
+ if (!bucketEndpoint && typeof Bucket === "string" && !validate(Bucket) && Bucket.indexOf("/") >= 0) {
468
466
  const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
469
467
  err.name = "InvalidBucketName";
470
468
  throw err;
@@ -485,10 +483,10 @@ const getValidateBucketNamePlugin = (options) => ({
485
483
  },
486
484
  });
487
485
 
488
- class S3RestXmlProtocol extends protocols$1.AwsRestXmlProtocol {
486
+ class S3RestXmlProtocol extends AwsRestXmlProtocol {
489
487
  async serializeRequest(operationSchema, input, context) {
490
488
  const request = await super.serializeRequest(operationSchema, input, context);
491
- const ns = schema.NormalizedSchema.of(operationSchema.input);
489
+ const ns = NormalizedSchema.of(operationSchema.input);
492
490
  const staticStructureSchema = ns.getSchema();
493
491
  let bucketMemberIndex = 0;
494
492
  const requiredMemberCount = staticStructureSchema[6] ?? 0;
@@ -731,12 +729,12 @@ const bucketEndpointMiddleware = (options) => (next, context) => async (args) =>
731
729
  const { Bucket: bucketName } = args.input;
732
730
  let replaceBucketInPath = options.bucketEndpoint;
733
731
  const request = args.request;
734
- if (protocols.HttpRequest.isInstance(request)) {
732
+ if (HttpRequest.isInstance(request)) {
735
733
  if (options.bucketEndpoint) {
736
734
  request.hostname = bucketName;
737
735
  }
738
- else if (util.validate(bucketName)) {
739
- const bucketArn = util.parse(bucketName);
736
+ else if (validate(bucketName)) {
737
+ const bucketArn = parse(bucketName);
740
738
  const clientRegion = await options.region();
741
739
  const useDualstackEndpoint = await options.useDualstackEndpoint();
742
740
  const useFipsEndpoint = await options.useFipsEndpoint();
@@ -823,7 +821,7 @@ function addExpectContinueMiddleware(options) {
823
821
  return (next) => async (args) => {
824
822
  const { request } = args;
825
823
  if (options.expectContinueHeader !== false &&
826
- protocols.HttpRequest.isInstance(request) &&
824
+ HttpRequest.isInstance(request) &&
827
825
  request.body &&
828
826
  options.runtime === "node" &&
829
827
  options.requestHandler?.constructor?.name !== "FetchHttpHandler") {
@@ -1,26 +1,24 @@
1
- 'use strict';
2
-
3
- var client = require('@smithy/core/client');
4
- var protocols = require('@smithy/core/protocols');
5
- var serde = require('@smithy/core/serde');
6
- var signatureV4MultiRegion = require('@aws-sdk/signature-v4-multi-region');
7
- var config = require('@smithy/core/config');
8
- var client$1 = require('@aws-sdk/core/client');
9
- var core = require('@smithy/core');
10
- var node_stream = require('node:stream');
11
- var util = require('@aws-sdk/core/util');
12
- var protocols$1 = require('@aws-sdk/core/protocols');
13
- var schema = require('@smithy/core/schema');
1
+ const { NoOpLogger, getSmithyContext } = require("@smithy/core/client");
2
+ const { HttpRequest, HttpResponse } = require("@smithy/core/protocols");
3
+ const { parseRfc7231DateTime } = require("@smithy/core/serde");
4
+ const { SignatureV4SignWithCredentials } = require("@aws-sdk/signature-v4-multi-region");
5
+ const { booleanSelector, SelectorType } = require("@smithy/core/config");
6
+ const { setFeature } = require("@aws-sdk/core/client");
7
+ const { httpSigningMiddlewareOptions } = require("@smithy/core");
8
+ const { Readable } = require("node:stream");
9
+ const { validate, parse } = require("@aws-sdk/core/util");
10
+ const { AwsRestXmlProtocol } = require("@aws-sdk/core/protocols");
11
+ const { NormalizedSchema } = require("@smithy/core/schema");
14
12
 
15
13
  const CONTENT_LENGTH_HEADER = "content-length";
16
14
  const DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length";
17
15
  function checkContentLengthHeader() {
18
16
  return (next, context) => async (args) => {
19
17
  const { request } = args;
20
- if (protocols.HttpRequest.isInstance(request)) {
18
+ if (HttpRequest.isInstance(request)) {
21
19
  if (!(CONTENT_LENGTH_HEADER in request.headers) && !(DECODED_CONTENT_LENGTH_HEADER in request.headers)) {
22
20
  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 client.NoOpLogger)) {
21
+ if (typeof context?.logger?.warn === "function" && !(context.logger instanceof NoOpLogger)) {
24
22
  context.logger.warn(message);
25
23
  }
26
24
  else {
@@ -251,11 +249,11 @@ const s3ExpiresMiddleware = (config) => {
251
249
  return (next, context) => async (args) => {
252
250
  const result = await next(args);
253
251
  const { response } = result;
254
- if (protocols.HttpResponse.isInstance(response)) {
252
+ if (HttpResponse.isInstance(response)) {
255
253
  if (response.headers.expires) {
256
254
  response.headers.expiresstring = response.headers.expires;
257
255
  try {
258
- serde.parseRfc7231DateTime(response.headers.expires);
256
+ parseRfc7231DateTime(response.headers.expires);
259
257
  }
260
258
  catch (e) {
261
259
  context.logger?.warn(`AWS SDK Warning for ${context.clientName}::${context.commandName} response parsing (${response.headers.expires}): ${e}`);
@@ -279,7 +277,7 @@ const getS3ExpiresMiddlewarePlugin = (clientConfig) => ({
279
277
  },
280
278
  });
281
279
 
282
- class SignatureV4S3Express extends signatureV4MultiRegion.SignatureV4SignWithCredentials {
280
+ class SignatureV4S3Express extends SignatureV4SignWithCredentials {
283
281
  }
284
282
 
285
283
  const S3_EXPRESS_BUCKET_TYPE = "Directory";
@@ -290,8 +288,8 @@ const SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
290
288
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH";
291
289
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth";
292
290
  const NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = {
293
- environmentVariableSelector: (env) => config.booleanSelector(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, config.SelectorType.ENV),
294
- configFileSelector: (profile) => config.booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, config.SelectorType.CONFIG),
291
+ environmentVariableSelector: (env) => booleanSelector(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, SelectorType.ENV),
292
+ configFileSelector: (profile) => booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, SelectorType.CONFIG),
295
293
  default: false,
296
294
  };
297
295
 
@@ -303,7 +301,7 @@ const s3ExpressMiddleware = (options) => {
303
301
  const isS3ExpressBucket = endpoint.properties?.backend === S3_EXPRESS_BACKEND ||
304
302
  endpoint.properties?.bucketType === S3_EXPRESS_BUCKET_TYPE;
305
303
  if (isS3ExpressBucket) {
306
- client$1.setFeature(context, "S3_EXPRESS_BUCKET", "J");
304
+ setFeature(context, "S3_EXPRESS_BUCKET", "J");
307
305
  context.isS3ExpressBucket = true;
308
306
  }
309
307
  if (isS3ExpressAuth) {
@@ -313,7 +311,7 @@ const s3ExpressMiddleware = (options) => {
313
311
  Bucket: requestBucket,
314
312
  });
315
313
  context.s3ExpressIdentity = s3ExpressIdentity;
316
- if (protocols.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
314
+ if (HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
317
315
  args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
318
316
  }
319
317
  }
@@ -346,12 +344,12 @@ const defaultErrorHandler = (signingProperties) => (error) => {
346
344
  throw error;
347
345
  };
348
346
  const defaultSuccessHandler = (httpResponse, signingProperties) => { };
349
- const s3ExpressHttpSigningMiddlewareOptions = core.httpSigningMiddlewareOptions;
347
+ const s3ExpressHttpSigningMiddlewareOptions = httpSigningMiddlewareOptions;
350
348
  const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (args) => {
351
- if (!protocols.HttpRequest.isInstance(args.request)) {
349
+ if (!HttpRequest.isInstance(args.request)) {
352
350
  return next(args);
353
351
  }
354
- const smithyContext = client.getSmithyContext(context);
352
+ const smithyContext = getSmithyContext(context);
355
353
  const scheme = smithyContext.selectedHttpAuthScheme;
356
354
  if (!scheme) {
357
355
  throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
@@ -373,12 +371,12 @@ const s3ExpressHttpSigningMiddleware = (config) => (next, context) => async (arg
373
371
  };
374
372
  const getS3ExpressHttpSigningPlugin = (config) => ({
375
373
  applyToStack: (clientStack) => {
376
- clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), core.httpSigningMiddlewareOptions);
374
+ clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), httpSigningMiddlewareOptions);
377
375
  },
378
376
  });
379
377
 
380
378
  function toStream(bytes) {
381
- return node_stream.Readable.from(Buffer.from(bytes));
379
+ return Readable.from(Buffer.from(bytes));
382
380
  }
383
381
 
384
382
  const THROW_IF_EMPTY_BODY = {
@@ -389,7 +387,7 @@ const THROW_IF_EMPTY_BODY = {
389
387
  const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
390
388
  const result = await next(args);
391
389
  const { response } = result;
392
- if (!protocols.HttpResponse.isInstance(response)) {
390
+ if (!HttpResponse.isInstance(response)) {
393
391
  return result;
394
392
  }
395
393
  const { statusCode, body } = response;
@@ -471,7 +469,7 @@ const bucketEndpointMiddlewareOptions$1 = {
471
469
  function validateBucketNameMiddleware({ bucketEndpoint }) {
472
470
  return (next) => async (args) => {
473
471
  const { input: { Bucket }, } = args;
474
- if (!bucketEndpoint && typeof Bucket === "string" && !util.validate(Bucket) && Bucket.indexOf("/") >= 0) {
472
+ if (!bucketEndpoint && typeof Bucket === "string" && !validate(Bucket) && Bucket.indexOf("/") >= 0) {
475
473
  const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
476
474
  err.name = "InvalidBucketName";
477
475
  throw err;
@@ -492,10 +490,10 @@ const getValidateBucketNamePlugin = (options) => ({
492
490
  },
493
491
  });
494
492
 
495
- class S3RestXmlProtocol extends protocols$1.AwsRestXmlProtocol {
493
+ class S3RestXmlProtocol extends AwsRestXmlProtocol {
496
494
  async serializeRequest(operationSchema, input, context) {
497
495
  const request = await super.serializeRequest(operationSchema, input, context);
498
- const ns = schema.NormalizedSchema.of(operationSchema.input);
496
+ const ns = NormalizedSchema.of(operationSchema.input);
499
497
  const staticStructureSchema = ns.getSchema();
500
498
  let bucketMemberIndex = 0;
501
499
  const requiredMemberCount = staticStructureSchema[6] ?? 0;
@@ -519,16 +517,16 @@ class S3RestXmlProtocol extends protocols$1.AwsRestXmlProtocol {
519
517
  const NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
520
518
  const NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME = "s3_disable_multiregion_access_points";
521
519
  const NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS = {
522
- environmentVariableSelector: (env) => config.booleanSelector(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, config.SelectorType.ENV),
523
- configFileSelector: (profile) => config.booleanSelector(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, config.SelectorType.CONFIG),
520
+ environmentVariableSelector: (env) => booleanSelector(env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, SelectorType.ENV),
521
+ configFileSelector: (profile) => booleanSelector(profile, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, SelectorType.CONFIG),
524
522
  default: false,
525
523
  };
526
524
 
527
525
  const NODE_USE_ARN_REGION_ENV_NAME = "AWS_S3_USE_ARN_REGION";
528
526
  const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
529
527
  const NODE_USE_ARN_REGION_CONFIG_OPTIONS = {
530
- environmentVariableSelector: (env) => config.booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, config.SelectorType.ENV),
531
- configFileSelector: (profile) => config.booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, config.SelectorType.CONFIG),
528
+ environmentVariableSelector: (env) => booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, SelectorType.ENV),
529
+ configFileSelector: (profile) => booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, SelectorType.CONFIG),
532
530
  default: undefined,
533
531
  };
534
532
 
@@ -754,12 +752,12 @@ const bucketEndpointMiddleware = (options) => (next, context) => async (args) =>
754
752
  const { Bucket: bucketName } = args.input;
755
753
  let replaceBucketInPath = options.bucketEndpoint;
756
754
  const request = args.request;
757
- if (protocols.HttpRequest.isInstance(request)) {
755
+ if (HttpRequest.isInstance(request)) {
758
756
  if (options.bucketEndpoint) {
759
757
  request.hostname = bucketName;
760
758
  }
761
- else if (util.validate(bucketName)) {
762
- const bucketArn = util.parse(bucketName);
759
+ else if (validate(bucketName)) {
760
+ const bucketArn = parse(bucketName);
763
761
  const clientRegion = await options.region();
764
762
  const useDualstackEndpoint = await options.useDualstackEndpoint();
765
763
  const useFipsEndpoint = await options.useFipsEndpoint();
@@ -846,7 +844,7 @@ function addExpectContinueMiddleware(options) {
846
844
  return (next) => async (args) => {
847
845
  const { request } = args;
848
846
  if (options.expectContinueHeader !== false &&
849
- protocols.HttpRequest.isInstance(request) &&
847
+ HttpRequest.isInstance(request) &&
850
848
  request.body &&
851
849
  options.runtime === "node" &&
852
850
  options.requestHandler?.constructor?.name !== "FetchHttpHandler") {
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
- var s3 = require('@aws-sdk/middleware-sdk-s3/s3');
4
- var client = require('@aws-sdk/core/client');
5
- var util = require('@aws-sdk/core/util');
6
- var protocols = require('@smithy/core/protocols');
1
+ const { validateOutpostService, validatePartition, validateAccountId, getArnResources } = require("@aws-sdk/middleware-sdk-s3/s3");
2
+ const { partition } = require("@aws-sdk/core/client");
3
+ const { validate, parse } = require("@aws-sdk/core/util");
4
+ const { HttpRequest } = require("@smithy/core/protocols");
7
5
 
8
6
  function resolveS3ControlConfig(input) {
9
7
  const { useArnRegion } = input;
@@ -20,7 +18,7 @@ const CONTEXT_SIGNING_REGION = "signing_region";
20
18
 
21
19
  const parseOutpostArnablesMiddleaware = (options) => (next, context) => async (args) => {
22
20
  const { input } = args;
23
- const parameter = input.Name && util.validate(input.Name) ? "Name" : input.Bucket && util.validate(input.Bucket) ? "Bucket" : undefined;
21
+ const parameter = input.Name && validate(input.Name) ? "Name" : input.Bucket && validate(input.Bucket) ? "Bucket" : undefined;
24
22
  if (!parameter)
25
23
  return next(args);
26
24
  const clientRegion = await options.region();
@@ -38,20 +36,20 @@ const parseOutpostArnablesMiddleaware = (options) => (next, context) => async (a
38
36
  }
39
37
  else {
40
38
  signingRegion = context.endpointV2?.properties?.authSchemes?.[0]?.signingRegion || baseRegion;
41
- clientPartition = client.partition(signingRegion).name;
39
+ clientPartition = partition(signingRegion).name;
42
40
  }
43
41
  const validatorOptions = {
44
42
  clientPartition};
45
43
  let arn;
46
44
  if (parameter === "Name") {
47
- arn = util.parse(input.Name);
45
+ arn = parse(input.Name);
48
46
  validateOutpostsArn(arn, validatorOptions);
49
47
  const { outpostId, accesspointName } = parseOutpostsAccessPointArnResource(arn.resource);
50
48
  input.Name = accesspointName;
51
49
  context[CONTEXT_OUTPOST_ID] = outpostId;
52
50
  }
53
51
  else {
54
- arn = util.parse(input.Bucket);
52
+ arn = parse(input.Bucket);
55
53
  validateOutpostsArn(arn, validatorOptions);
56
54
  const { outpostId, bucketName } = parseOutpostBucketArnResource(arn.resource);
57
55
  input.Bucket = bucketName;
@@ -74,12 +72,12 @@ const parseOutpostArnablesMiddleawareOptions = {
74
72
  };
75
73
  const validateOutpostsArn = (arn, { clientPartition }) => {
76
74
  const { service, partition, accountId, region } = arn;
77
- s3.validateOutpostService(service);
78
- s3.validatePartition(partition, { clientPartition });
79
- s3.validateAccountId(accountId);
75
+ validateOutpostService(service);
76
+ validatePartition(partition, { clientPartition });
77
+ validateAccountId(accountId);
80
78
  };
81
79
  const parseOutpostsAccessPointArnResource = (resource) => {
82
- const { outpostId, accesspointName } = s3.getArnResources(resource);
80
+ const { outpostId, accesspointName } = getArnResources(resource);
83
81
  if (!outpostId) {
84
82
  throw new Error("ARN resource should begin with 'outpost'");
85
83
  }
@@ -126,7 +124,7 @@ const ACCOUNT_ID_HEADER = "x-amz-account-id";
126
124
  const OUTPOST_ID_HEADER = "x-amz-outpost-id";
127
125
  const updateArnablesRequestMiddleware = (config) => (next, context) => async (args) => {
128
126
  const { request } = args;
129
- if (!protocols.HttpRequest.isInstance(request)) {
127
+ if (!HttpRequest.isInstance(request)) {
130
128
  return next(args);
131
129
  }
132
130
  if (context[CONTEXT_ACCOUNT_ID]) {
@@ -178,7 +176,7 @@ const getHostPrefixDeduplicationPlugin = (config) => ({
178
176
 
179
177
  const redirectFromPostIdMiddleware = (config) => (next, context) => async (args) => {
180
178
  const { input, request } = args;
181
- if (!protocols.HttpRequest.isInstance(request))
179
+ if (!HttpRequest.isInstance(request))
182
180
  return next(args);
183
181
  if (input.OutpostId) {
184
182
  const { isCustomEndpoint } = config;
package/dist-es/index.js CHANGED
@@ -1 +1 @@
1
- export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "./submodules/s3/index";
1
+ export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "@aws-sdk/middleware-sdk-s3/s3";
@@ -1,2 +1,2 @@
1
- export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "./submodules/s3/index";
2
- export type { PreviouslyResolved, S3InputConfig, S3ResolvedConfig, S3ExpressIdentity, S3ExpressIdentityProvider, } from "./submodules/s3/index";
1
+ export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "@aws-sdk/middleware-sdk-s3/s3";
2
+ export type { PreviouslyResolved, S3InputConfig, S3ResolvedConfig, S3ExpressIdentity, S3ExpressIdentityProvider, } from "@aws-sdk/middleware-sdk-s3/s3";
@@ -29,11 +29,11 @@ export {
29
29
  validateBucketNameMiddlewareOptions,
30
30
  getValidateBucketNamePlugin,
31
31
  S3RestXmlProtocol,
32
- } from "./submodules/s3/index";
32
+ } from "@aws-sdk/middleware-sdk-s3/s3";
33
33
  export {
34
34
  PreviouslyResolved,
35
35
  S3InputConfig,
36
36
  S3ResolvedConfig,
37
37
  S3ExpressIdentity,
38
38
  S3ExpressIdentityProvider,
39
- } from "./submodules/s3/index";
39
+ } from "@aws-sdk/middleware-sdk-s3/s3";
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.972.51",
3
+ "version": "3.972.52",
4
4
  "scripts": {
5
- "build": "yarn lint && concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
5
+ "build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
6
6
  "build:cjs": "node ../../scripts/compilation/inline",
7
- "build:es": "tsc -p tsconfig.es.json",
7
+ "build:es": "premove dist-es && tsc -p tsconfig.es.json",
8
8
  "build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
9
- "build:types": "tsc -p tsconfig.types.json",
9
+ "build:types": "premove dist-types && tsc -p tsconfig.types.json",
10
10
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
11
- "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
11
+ "clean": "premove dist-cjs dist-es dist-types",
12
12
  "extract:docs": "api-extractor run --local",
13
13
  "lint": "node ../../scripts/validation/submodules-linter.js",
14
+ "prebuild": "yarn lint",
14
15
  "test": "yarn g:vitest run",
15
16
  "test:watch": "yarn g:vitest watch",
16
17
  "test:integration": "yarn g:vitest run -c vitest.config.integ.mts && yarn test:types",
@@ -66,9 +67,9 @@
66
67
  },
67
68
  "license": "Apache-2.0",
68
69
  "dependencies": {
69
- "@aws-sdk/core": "^3.974.20",
70
- "@aws-sdk/signature-v4-multi-region": "^3.996.34",
71
- "@aws-sdk/types": "^3.973.12",
70
+ "@aws-sdk/core": "^3.974.21",
71
+ "@aws-sdk/signature-v4-multi-region": "^3.996.35",
72
+ "@aws-sdk/types": "^3.973.13",
72
73
  "@smithy/core": "^3.24.6",
73
74
  "@smithy/types": "^4.14.3",
74
75
  "tslib": "^2.6.2"
@@ -98,14 +99,11 @@
98
99
  "dist-*/**"
99
100
  ],
100
101
  "browser": {
101
- "./dist-es/index": "./dist-es/index.browser",
102
102
  "./dist-es/submodules/s3/index": "./dist-es/submodules/s3/index.browser",
103
103
  "./dist-es/submodules/s3/index.js": "./dist-es/submodules/s3/index.browser.js",
104
104
  "./dist-es/submodules/s3/to-stream/toStream": "./dist-es/submodules/s3/to-stream/toStream.browser"
105
105
  },
106
106
  "react-native": {
107
- "./dist-es/index": "./dist-es/index.browser",
108
- "./dist-cjs/index": "./dist-cjs/index.browser",
109
107
  "./dist-es/submodules/s3/index": "./dist-es/submodules/s3/index.browser",
110
108
  "./dist-cjs/submodules/s3/index": "./dist-cjs/submodules/s3/index.browser",
111
109
  "./dist-es/submodules/s3/to-stream/toStream": "./dist-es/submodules/s3/to-stream/toStream.browser",
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3RestXmlProtocol = exports.getValidateBucketNamePlugin = exports.validateBucketNameMiddlewareOptions = exports.validateBucketNameMiddleware = exports.getThrow200ExceptionsPlugin = exports.throw200ExceptionsMiddlewareOptions = exports.throw200ExceptionsMiddleware = exports.s3ExpressHttpSigningMiddlewareOptions = exports.s3ExpressHttpSigningMiddleware = exports.getS3ExpressHttpSigningPlugin = exports.s3ExpressMiddlewareOptions = exports.s3ExpressMiddleware = exports.getS3ExpressPlugin = exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = exports.SignatureV4S3Express = exports.S3ExpressIdentityProviderImpl = exports.S3ExpressIdentityCacheEntry = exports.S3ExpressIdentityCache = exports.getS3ExpiresMiddlewarePlugin = exports.s3ExpiresMiddlewareOptions = exports.s3ExpiresMiddleware = exports.resolveS3Config = exports.getRegionRedirectMiddlewarePlugin = exports.regionRedirectMiddlewareOptions = exports.regionRedirectMiddleware = exports.regionRedirectEndpointMiddlewareOptions = exports.regionRedirectEndpointMiddleware = exports.getCheckContentLengthHeaderPlugin = exports.checkContentLengthHeaderMiddlewareOptions = exports.checkContentLengthHeader = void 0;
4
- var index_browser_1 = require("./submodules/s3/index.browser");
5
- Object.defineProperty(exports, "checkContentLengthHeader", { enumerable: true, get: function () { return index_browser_1.checkContentLengthHeader; } });
6
- Object.defineProperty(exports, "checkContentLengthHeaderMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.checkContentLengthHeaderMiddlewareOptions; } });
7
- Object.defineProperty(exports, "getCheckContentLengthHeaderPlugin", { enumerable: true, get: function () { return index_browser_1.getCheckContentLengthHeaderPlugin; } });
8
- Object.defineProperty(exports, "regionRedirectEndpointMiddleware", { enumerable: true, get: function () { return index_browser_1.regionRedirectEndpointMiddleware; } });
9
- Object.defineProperty(exports, "regionRedirectEndpointMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.regionRedirectEndpointMiddlewareOptions; } });
10
- Object.defineProperty(exports, "regionRedirectMiddleware", { enumerable: true, get: function () { return index_browser_1.regionRedirectMiddleware; } });
11
- Object.defineProperty(exports, "regionRedirectMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.regionRedirectMiddlewareOptions; } });
12
- Object.defineProperty(exports, "getRegionRedirectMiddlewarePlugin", { enumerable: true, get: function () { return index_browser_1.getRegionRedirectMiddlewarePlugin; } });
13
- Object.defineProperty(exports, "resolveS3Config", { enumerable: true, get: function () { return index_browser_1.resolveS3Config; } });
14
- Object.defineProperty(exports, "s3ExpiresMiddleware", { enumerable: true, get: function () { return index_browser_1.s3ExpiresMiddleware; } });
15
- Object.defineProperty(exports, "s3ExpiresMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.s3ExpiresMiddlewareOptions; } });
16
- Object.defineProperty(exports, "getS3ExpiresMiddlewarePlugin", { enumerable: true, get: function () { return index_browser_1.getS3ExpiresMiddlewarePlugin; } });
17
- Object.defineProperty(exports, "S3ExpressIdentityCache", { enumerable: true, get: function () { return index_browser_1.S3ExpressIdentityCache; } });
18
- Object.defineProperty(exports, "S3ExpressIdentityCacheEntry", { enumerable: true, get: function () { return index_browser_1.S3ExpressIdentityCacheEntry; } });
19
- Object.defineProperty(exports, "S3ExpressIdentityProviderImpl", { enumerable: true, get: function () { return index_browser_1.S3ExpressIdentityProviderImpl; } });
20
- Object.defineProperty(exports, "SignatureV4S3Express", { enumerable: true, get: function () { return index_browser_1.SignatureV4S3Express; } });
21
- Object.defineProperty(exports, "NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS", { enumerable: true, get: function () { return index_browser_1.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS; } });
22
- Object.defineProperty(exports, "getS3ExpressPlugin", { enumerable: true, get: function () { return index_browser_1.getS3ExpressPlugin; } });
23
- Object.defineProperty(exports, "s3ExpressMiddleware", { enumerable: true, get: function () { return index_browser_1.s3ExpressMiddleware; } });
24
- Object.defineProperty(exports, "s3ExpressMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.s3ExpressMiddlewareOptions; } });
25
- Object.defineProperty(exports, "getS3ExpressHttpSigningPlugin", { enumerable: true, get: function () { return index_browser_1.getS3ExpressHttpSigningPlugin; } });
26
- Object.defineProperty(exports, "s3ExpressHttpSigningMiddleware", { enumerable: true, get: function () { return index_browser_1.s3ExpressHttpSigningMiddleware; } });
27
- Object.defineProperty(exports, "s3ExpressHttpSigningMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.s3ExpressHttpSigningMiddlewareOptions; } });
28
- Object.defineProperty(exports, "throw200ExceptionsMiddleware", { enumerable: true, get: function () { return index_browser_1.throw200ExceptionsMiddleware; } });
29
- Object.defineProperty(exports, "throw200ExceptionsMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.throw200ExceptionsMiddlewareOptions; } });
30
- Object.defineProperty(exports, "getThrow200ExceptionsPlugin", { enumerable: true, get: function () { return index_browser_1.getThrow200ExceptionsPlugin; } });
31
- Object.defineProperty(exports, "validateBucketNameMiddleware", { enumerable: true, get: function () { return index_browser_1.validateBucketNameMiddleware; } });
32
- Object.defineProperty(exports, "validateBucketNameMiddlewareOptions", { enumerable: true, get: function () { return index_browser_1.validateBucketNameMiddlewareOptions; } });
33
- Object.defineProperty(exports, "getValidateBucketNamePlugin", { enumerable: true, get: function () { return index_browser_1.getValidateBucketNamePlugin; } });
34
- Object.defineProperty(exports, "S3RestXmlProtocol", { enumerable: true, get: function () { return index_browser_1.S3RestXmlProtocol; } });
@@ -1 +0,0 @@
1
- export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "./submodules/s3/index.browser";
@@ -1,2 +0,0 @@
1
- export { checkContentLengthHeader, checkContentLengthHeaderMiddlewareOptions, getCheckContentLengthHeaderPlugin, regionRedirectEndpointMiddleware, regionRedirectEndpointMiddlewareOptions, regionRedirectMiddleware, regionRedirectMiddlewareOptions, getRegionRedirectMiddlewarePlugin, resolveS3Config, s3ExpiresMiddleware, s3ExpiresMiddlewareOptions, getS3ExpiresMiddlewarePlugin, S3ExpressIdentityCache, S3ExpressIdentityCacheEntry, S3ExpressIdentityProviderImpl, SignatureV4S3Express, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, getS3ExpressPlugin, s3ExpressMiddleware, s3ExpressMiddlewareOptions, getS3ExpressHttpSigningPlugin, s3ExpressHttpSigningMiddleware, s3ExpressHttpSigningMiddlewareOptions, throw200ExceptionsMiddleware, throw200ExceptionsMiddlewareOptions, getThrow200ExceptionsPlugin, validateBucketNameMiddleware, validateBucketNameMiddlewareOptions, getValidateBucketNamePlugin, S3RestXmlProtocol, } from "./submodules/s3/index.browser";
2
- export type { PreviouslyResolved, S3InputConfig, S3ResolvedConfig, S3ExpressIdentity, S3ExpressIdentityProvider, } from "./submodules/s3/index.browser";
@@ -1,39 +0,0 @@
1
- export {
2
- checkContentLengthHeader,
3
- checkContentLengthHeaderMiddlewareOptions,
4
- getCheckContentLengthHeaderPlugin,
5
- regionRedirectEndpointMiddleware,
6
- regionRedirectEndpointMiddlewareOptions,
7
- regionRedirectMiddleware,
8
- regionRedirectMiddlewareOptions,
9
- getRegionRedirectMiddlewarePlugin,
10
- resolveS3Config,
11
- s3ExpiresMiddleware,
12
- s3ExpiresMiddlewareOptions,
13
- getS3ExpiresMiddlewarePlugin,
14
- S3ExpressIdentityCache,
15
- S3ExpressIdentityCacheEntry,
16
- S3ExpressIdentityProviderImpl,
17
- SignatureV4S3Express,
18
- NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS,
19
- getS3ExpressPlugin,
20
- s3ExpressMiddleware,
21
- s3ExpressMiddlewareOptions,
22
- getS3ExpressHttpSigningPlugin,
23
- s3ExpressHttpSigningMiddleware,
24
- s3ExpressHttpSigningMiddlewareOptions,
25
- throw200ExceptionsMiddleware,
26
- throw200ExceptionsMiddlewareOptions,
27
- getThrow200ExceptionsPlugin,
28
- validateBucketNameMiddleware,
29
- validateBucketNameMiddlewareOptions,
30
- getValidateBucketNamePlugin,
31
- S3RestXmlProtocol,
32
- } from "./submodules/s3/index.browser";
33
- export {
34
- PreviouslyResolved,
35
- S3InputConfig,
36
- S3ResolvedConfig,
37
- S3ExpressIdentity,
38
- S3ExpressIdentityProvider,
39
- } from "./submodules/s3/index.browser";