@aws-sdk/middleware-sdk-s3 3.485.0 → 3.495.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.
@@ -1,37 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCheckContentLengthHeaderPlugin = exports.checkContentLengthHeaderMiddlewareOptions = exports.checkContentLengthHeader = void 0;
4
- const protocol_http_1 = require("@smithy/protocol-http");
5
- const smithy_client_1 = require("@smithy/smithy-client");
6
- const CONTENT_LENGTH_HEADER = "content-length";
7
- function checkContentLengthHeader() {
8
- return (next, context) => async (args) => {
9
- var _a;
10
- const { request } = args;
11
- if (protocol_http_1.HttpRequest.isInstance(request)) {
12
- if (!request.headers[CONTENT_LENGTH_HEADER]) {
13
- 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.`;
14
- if (typeof ((_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.warn) === "function" && !(context.logger instanceof smithy_client_1.NoOpLogger)) {
15
- context.logger.warn(message);
16
- }
17
- else {
18
- console.warn(message);
19
- }
20
- }
21
- }
22
- return next({ ...args });
23
- };
24
- }
25
- exports.checkContentLengthHeader = checkContentLengthHeader;
26
- exports.checkContentLengthHeaderMiddlewareOptions = {
27
- step: "finalizeRequest",
28
- tags: ["CHECK_CONTENT_LENGTH_HEADER"],
29
- name: "getCheckContentLengthHeaderPlugin",
30
- override: true,
31
- };
32
- const getCheckContentLengthHeaderPlugin = (unused) => ({
33
- applyToStack: (clientStack) => {
34
- clientStack.add(checkContentLengthHeader(), exports.checkContentLengthHeaderMiddlewareOptions);
35
- },
36
- });
37
- exports.getCheckContentLengthHeaderPlugin = getCheckContentLengthHeaderPlugin;
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -1,10 +1,495 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./check-content-length-header"), exports);
5
- tslib_1.__exportStar(require("./region-redirect-endpoint-middleware"), exports);
6
- tslib_1.__exportStar(require("./region-redirect-middleware"), exports);
7
- tslib_1.__exportStar(require("./s3-express/index"), exports);
8
- tslib_1.__exportStar(require("./s3Configuration"), exports);
9
- tslib_1.__exportStar(require("./throw-200-exceptions"), exports);
10
- tslib_1.__exportStar(require("./validate-bucket-name"), exports);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS: () => NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS,
24
+ S3ExpressIdentityCache: () => S3ExpressIdentityCache,
25
+ S3ExpressIdentityCacheEntry: () => S3ExpressIdentityCacheEntry,
26
+ S3ExpressIdentityProviderImpl: () => S3ExpressIdentityProviderImpl,
27
+ SignatureV4S3Express: () => SignatureV4S3Express,
28
+ checkContentLengthHeader: () => checkContentLengthHeader,
29
+ checkContentLengthHeaderMiddlewareOptions: () => checkContentLengthHeaderMiddlewareOptions,
30
+ getCheckContentLengthHeaderPlugin: () => getCheckContentLengthHeaderPlugin,
31
+ getRegionRedirectMiddlewarePlugin: () => getRegionRedirectMiddlewarePlugin,
32
+ getS3ExpressPlugin: () => getS3ExpressPlugin,
33
+ getThrow200ExceptionsPlugin: () => getThrow200ExceptionsPlugin,
34
+ getValidateBucketNamePlugin: () => getValidateBucketNamePlugin,
35
+ regionRedirectEndpointMiddleware: () => regionRedirectEndpointMiddleware,
36
+ regionRedirectEndpointMiddlewareOptions: () => regionRedirectEndpointMiddlewareOptions,
37
+ regionRedirectMiddleware: () => regionRedirectMiddleware,
38
+ regionRedirectMiddlewareOptions: () => regionRedirectMiddlewareOptions,
39
+ resolveS3Config: () => resolveS3Config,
40
+ s3ExpressMiddleware: () => s3ExpressMiddleware,
41
+ s3ExpressMiddlewareOptions: () => s3ExpressMiddlewareOptions,
42
+ throw200ExceptionsMiddleware: () => throw200ExceptionsMiddleware,
43
+ throw200ExceptionsMiddlewareOptions: () => throw200ExceptionsMiddlewareOptions,
44
+ validateBucketNameMiddleware: () => validateBucketNameMiddleware,
45
+ validateBucketNameMiddlewareOptions: () => validateBucketNameMiddlewareOptions
46
+ });
47
+ module.exports = __toCommonJS(src_exports);
48
+
49
+ // src/check-content-length-header.ts
50
+ var import_protocol_http = require("@smithy/protocol-http");
51
+ var import_smithy_client = require("@smithy/smithy-client");
52
+ var CONTENT_LENGTH_HEADER = "content-length";
53
+ function checkContentLengthHeader() {
54
+ return (next, context) => async (args) => {
55
+ var _a;
56
+ const { request } = args;
57
+ if (import_protocol_http.HttpRequest.isInstance(request)) {
58
+ if (!request.headers[CONTENT_LENGTH_HEADER]) {
59
+ 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.`;
60
+ if (typeof ((_a = context == null ? void 0 : context.logger) == null ? void 0 : _a.warn) === "function" && !(context.logger instanceof import_smithy_client.NoOpLogger)) {
61
+ context.logger.warn(message);
62
+ } else {
63
+ console.warn(message);
64
+ }
65
+ }
66
+ }
67
+ return next({ ...args });
68
+ };
69
+ }
70
+ __name(checkContentLengthHeader, "checkContentLengthHeader");
71
+ var checkContentLengthHeaderMiddlewareOptions = {
72
+ step: "finalizeRequest",
73
+ tags: ["CHECK_CONTENT_LENGTH_HEADER"],
74
+ name: "getCheckContentLengthHeaderPlugin",
75
+ override: true
76
+ };
77
+ var getCheckContentLengthHeaderPlugin = /* @__PURE__ */ __name((unused) => ({
78
+ applyToStack: (clientStack) => {
79
+ clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
80
+ }
81
+ }), "getCheckContentLengthHeaderPlugin");
82
+
83
+ // src/region-redirect-endpoint-middleware.ts
84
+ var regionRedirectEndpointMiddleware = /* @__PURE__ */ __name((config) => {
85
+ return (next, context) => async (args) => {
86
+ const originalRegion = await config.region();
87
+ const regionProviderRef = config.region;
88
+ if (context.__s3RegionRedirect) {
89
+ config.region = async () => {
90
+ config.region = regionProviderRef;
91
+ return context.__s3RegionRedirect;
92
+ };
93
+ }
94
+ const result = await next(args);
95
+ if (context.__s3RegionRedirect) {
96
+ const region = await config.region();
97
+ if (originalRegion !== region) {
98
+ throw new Error("Region was not restored following S3 region redirect.");
99
+ }
100
+ }
101
+ return result;
102
+ };
103
+ }, "regionRedirectEndpointMiddleware");
104
+ var regionRedirectEndpointMiddlewareOptions = {
105
+ tags: ["REGION_REDIRECT", "S3"],
106
+ name: "regionRedirectEndpointMiddleware",
107
+ override: true,
108
+ relation: "before",
109
+ toMiddleware: "endpointV2Middleware"
110
+ };
111
+
112
+ // src/region-redirect-middleware.ts
113
+ function regionRedirectMiddleware(clientConfig) {
114
+ return (next, context) => async (args) => {
115
+ var _a, _b;
116
+ try {
117
+ return await next(args);
118
+ } catch (err) {
119
+ if (clientConfig.followRegionRedirects && // err.name === "PermanentRedirect" && --> removing the error name check, as that allows for HEAD operations (which have the 301 status code, but not the same error name) to be covered for region redirection as well
120
+ ((_a = err == null ? void 0 : err.$metadata) == null ? void 0 : _a.httpStatusCode) === 301) {
121
+ try {
122
+ const actualRegion = err.$response.headers["x-amz-bucket-region"];
123
+ (_b = context.logger) == null ? void 0 : _b.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`);
124
+ context.__s3RegionRedirect = actualRegion;
125
+ } catch (e) {
126
+ throw new Error("Region redirect failed: " + e);
127
+ }
128
+ return next(args);
129
+ } else {
130
+ throw err;
131
+ }
132
+ }
133
+ };
134
+ }
135
+ __name(regionRedirectMiddleware, "regionRedirectMiddleware");
136
+ var regionRedirectMiddlewareOptions = {
137
+ step: "initialize",
138
+ tags: ["REGION_REDIRECT", "S3"],
139
+ name: "regionRedirectMiddleware",
140
+ override: true
141
+ };
142
+ var getRegionRedirectMiddlewarePlugin = /* @__PURE__ */ __name((clientConfig) => ({
143
+ applyToStack: (clientStack) => {
144
+ clientStack.add(regionRedirectMiddleware(clientConfig), regionRedirectMiddlewareOptions);
145
+ clientStack.addRelativeTo(regionRedirectEndpointMiddleware(clientConfig), regionRedirectEndpointMiddlewareOptions);
146
+ }
147
+ }), "getRegionRedirectMiddlewarePlugin");
148
+
149
+ // src/s3-express/classes/S3ExpressIdentityCache.ts
150
+ var _S3ExpressIdentityCache = class _S3ExpressIdentityCache {
151
+ constructor(data = {}) {
152
+ this.data = data;
153
+ this.lastPurgeTime = Date.now();
154
+ }
155
+ get(key) {
156
+ const entry = this.data[key];
157
+ if (!entry) {
158
+ return;
159
+ }
160
+ return entry;
161
+ }
162
+ set(key, entry) {
163
+ this.data[key] = entry;
164
+ return entry;
165
+ }
166
+ delete(key) {
167
+ delete this.data[key];
168
+ }
169
+ async purgeExpired() {
170
+ const now = Date.now();
171
+ if (this.lastPurgeTime + _S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS > now) {
172
+ return;
173
+ }
174
+ for (const key in this.data) {
175
+ const entry = this.data[key];
176
+ if (!entry.isRefreshing) {
177
+ const credential = await entry.identity;
178
+ if (credential.expiration) {
179
+ if (credential.expiration.getTime() < now) {
180
+ delete this.data[key];
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ };
187
+ __name(_S3ExpressIdentityCache, "S3ExpressIdentityCache");
188
+ _S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS = 3e4;
189
+ var S3ExpressIdentityCache = _S3ExpressIdentityCache;
190
+
191
+ // src/s3-express/classes/S3ExpressIdentityCacheEntry.ts
192
+ var _S3ExpressIdentityCacheEntry = class _S3ExpressIdentityCacheEntry {
193
+ /**
194
+ * @param identity - stored identity.
195
+ * @param accessed - timestamp of last access in epoch ms.
196
+ * @param isRefreshing - this key is currently in the process of being refreshed (background).
197
+ */
198
+ constructor(_identity, isRefreshing = false, accessed = Date.now()) {
199
+ this._identity = _identity;
200
+ this.isRefreshing = isRefreshing;
201
+ this.accessed = accessed;
202
+ }
203
+ get identity() {
204
+ this.accessed = Date.now();
205
+ return this._identity;
206
+ }
207
+ };
208
+ __name(_S3ExpressIdentityCacheEntry, "S3ExpressIdentityCacheEntry");
209
+ var S3ExpressIdentityCacheEntry = _S3ExpressIdentityCacheEntry;
210
+
211
+ // src/s3-express/classes/S3ExpressIdentityProviderImpl.ts
212
+ var _S3ExpressIdentityProviderImpl = class _S3ExpressIdentityProviderImpl {
213
+ constructor(createSessionFn, cache = new S3ExpressIdentityCache()) {
214
+ this.createSessionFn = createSessionFn;
215
+ this.cache = cache;
216
+ }
217
+ async getS3ExpressIdentity(awsIdentity, identityProperties) {
218
+ const key = identityProperties.Bucket;
219
+ const { cache } = this;
220
+ const entry = cache.get(key);
221
+ if (entry) {
222
+ return entry.identity.then((identity) => {
223
+ var _a, _b;
224
+ const isExpired = (((_a = identity.expiration) == null ? void 0 : _a.getTime()) ?? 0) < Date.now();
225
+ if (isExpired) {
226
+ return cache.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
227
+ }
228
+ const isExpiringSoon = (((_b = identity.expiration) == null ? void 0 : _b.getTime()) ?? 0) < Date.now() + _S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS;
229
+ if (isExpiringSoon && !entry.isRefreshing) {
230
+ entry.isRefreshing = true;
231
+ this.getIdentity(key).then((id) => {
232
+ cache.set(key, new S3ExpressIdentityCacheEntry(Promise.resolve(id)));
233
+ });
234
+ }
235
+ return identity;
236
+ });
237
+ }
238
+ return cache.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
239
+ }
240
+ async getIdentity(key) {
241
+ var _a, _b;
242
+ await this.cache.purgeExpired().catch((error) => {
243
+ console.warn("Error while clearing expired entries in S3ExpressIdentityCache: \n" + error);
244
+ });
245
+ const session = await this.createSessionFn(key);
246
+ if (!((_a = session.Credentials) == null ? void 0 : _a.AccessKeyId) || !((_b = session.Credentials) == null ? void 0 : _b.SecretAccessKey)) {
247
+ throw new Error("s3#createSession response credential missing AccessKeyId or SecretAccessKey.");
248
+ }
249
+ const identity = {
250
+ accessKeyId: session.Credentials.AccessKeyId,
251
+ secretAccessKey: session.Credentials.SecretAccessKey,
252
+ sessionToken: session.Credentials.SessionToken,
253
+ expiration: session.Credentials.Expiration ? new Date(session.Credentials.Expiration) : void 0
254
+ };
255
+ return identity;
256
+ }
257
+ };
258
+ __name(_S3ExpressIdentityProviderImpl, "S3ExpressIdentityProviderImpl");
259
+ _S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS = 6e4;
260
+ var S3ExpressIdentityProviderImpl = _S3ExpressIdentityProviderImpl;
261
+
262
+ // src/s3-express/classes/SignatureV4S3Express.ts
263
+ var import_signature_v4 = require("@smithy/signature-v4");
264
+
265
+ // src/s3-express/constants.ts
266
+ var import_util_config_provider = require("@smithy/util-config-provider");
267
+ var S3_EXPRESS_BUCKET_TYPE = "Directory";
268
+ var S3_EXPRESS_BACKEND = "S3Express";
269
+ var S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
270
+ var SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
271
+ var SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
272
+ var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH";
273
+ var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth";
274
+ var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = {
275
+ environmentVariableSelector: (env) => (0, import_util_config_provider.booleanSelector)(env, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, import_util_config_provider.SelectorType.ENV),
276
+ configFileSelector: (profile) => (0, import_util_config_provider.booleanSelector)(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, import_util_config_provider.SelectorType.CONFIG),
277
+ default: false
278
+ };
279
+
280
+ // src/s3-express/classes/SignatureV4S3Express.ts
281
+ var _SignatureV4S3Express = class _SignatureV4S3Express extends import_signature_v4.SignatureV4 {
282
+ /**
283
+ * Signs with alternate provided credentials instead of those provided in the
284
+ * constructor.
285
+ *
286
+ * Additionally omits the credential sessionToken and assigns it to the
287
+ * alternate header field for S3 Express.
288
+ */
289
+ async signWithCredentials(requestToSign, credentials, options) {
290
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
291
+ requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
292
+ const privateAccess = this;
293
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
294
+ return privateAccess.signRequest(requestToSign, options ?? {});
295
+ }
296
+ /**
297
+ * Similar to {@link SignatureV4S3Express#signWithCredentials} but for presigning.
298
+ */
299
+ async presignWithCredentials(requestToSign, credentials, options) {
300
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
301
+ delete requestToSign.headers[SESSION_TOKEN_HEADER];
302
+ requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
303
+ requestToSign.query = requestToSign.query ?? {};
304
+ requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
305
+ const privateAccess = this;
306
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
307
+ return this.presign(requestToSign, options);
308
+ }
309
+ };
310
+ __name(_SignatureV4S3Express, "SignatureV4S3Express");
311
+ var SignatureV4S3Express = _SignatureV4S3Express;
312
+ function getCredentialsWithoutSessionToken(credentials) {
313
+ const credentialsWithoutSessionToken = {
314
+ accessKeyId: credentials.accessKeyId,
315
+ secretAccessKey: credentials.secretAccessKey,
316
+ expiration: credentials.expiration
317
+ };
318
+ return credentialsWithoutSessionToken;
319
+ }
320
+ __name(getCredentialsWithoutSessionToken, "getCredentialsWithoutSessionToken");
321
+ function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
322
+ const id = setTimeout(() => {
323
+ throw new Error("SignatureV4S3Express credential override was created but not called.");
324
+ }, 10);
325
+ const currentCredentialProvider = privateAccess.credentialProvider;
326
+ const overrideCredentialsProviderOnce = /* @__PURE__ */ __name(() => {
327
+ clearTimeout(id);
328
+ privateAccess.credentialProvider = currentCredentialProvider;
329
+ return Promise.resolve(credentialsWithoutSessionToken);
330
+ }, "overrideCredentialsProviderOnce");
331
+ privateAccess.credentialProvider = overrideCredentialsProviderOnce;
332
+ }
333
+ __name(setSingleOverride, "setSingleOverride");
334
+
335
+ // src/s3-express/functions/s3ExpressMiddleware.ts
336
+
337
+ var s3ExpressMiddleware = /* @__PURE__ */ __name((options) => {
338
+ return (next, context) => async (args) => {
339
+ var _a, _b, _c, _d, _e;
340
+ if (context.endpointV2) {
341
+ const endpoint = context.endpointV2;
342
+ const isS3ExpressAuth = ((_c = (_b = (_a = endpoint.properties) == null ? void 0 : _a.authSchemes) == null ? void 0 : _b[0]) == null ? void 0 : _c.name) === S3_EXPRESS_AUTH_SCHEME;
343
+ const isS3ExpressBucket = ((_d = endpoint.properties) == null ? void 0 : _d.backend) === S3_EXPRESS_BACKEND || ((_e = endpoint.properties) == null ? void 0 : _e.bucketType) === S3_EXPRESS_BUCKET_TYPE;
344
+ if (isS3ExpressBucket) {
345
+ context.isS3ExpressBucket = true;
346
+ }
347
+ if (isS3ExpressAuth) {
348
+ const requestBucket = args.input.Bucket;
349
+ if (requestBucket) {
350
+ const s3ExpressIdentity = await options.s3ExpressIdentityProvider.getS3ExpressIdentity(
351
+ await options.credentials(),
352
+ {
353
+ Bucket: requestBucket
354
+ }
355
+ );
356
+ context.s3ExpressIdentity = s3ExpressIdentity;
357
+ if (import_protocol_http.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
358
+ args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
359
+ }
360
+ }
361
+ }
362
+ }
363
+ return next(args);
364
+ };
365
+ }, "s3ExpressMiddleware");
366
+ var s3ExpressMiddlewareOptions = {
367
+ name: "s3ExpressMiddleware",
368
+ step: "build",
369
+ tags: ["S3", "S3_EXPRESS"],
370
+ override: true
371
+ };
372
+ var getS3ExpressPlugin = /* @__PURE__ */ __name((options) => ({
373
+ applyToStack: (clientStack) => {
374
+ clientStack.add(s3ExpressMiddleware(options), s3ExpressMiddlewareOptions);
375
+ }
376
+ }), "getS3ExpressPlugin");
377
+
378
+ // src/s3Configuration.ts
379
+ var resolveS3Config = /* @__PURE__ */ __name((input, {
380
+ session
381
+ }) => {
382
+ const [s3ClientProvider, CreateSessionCommandCtor] = session;
383
+ return {
384
+ ...input,
385
+ forcePathStyle: input.forcePathStyle ?? false,
386
+ useAccelerateEndpoint: input.useAccelerateEndpoint ?? false,
387
+ disableMultiregionAccessPoints: input.disableMultiregionAccessPoints ?? false,
388
+ followRegionRedirects: input.followRegionRedirects ?? false,
389
+ s3ExpressIdentityProvider: input.s3ExpressIdentityProvider ?? new S3ExpressIdentityProviderImpl(
390
+ async (key) => s3ClientProvider().send(
391
+ new CreateSessionCommandCtor({
392
+ Bucket: key,
393
+ SessionMode: "ReadWrite"
394
+ })
395
+ )
396
+ )
397
+ };
398
+ }, "resolveS3Config");
399
+
400
+ // src/throw-200-exceptions.ts
401
+
402
+ var throw200ExceptionsMiddleware = /* @__PURE__ */ __name((config) => (next) => async (args) => {
403
+ const result = await next(args);
404
+ const { response } = result;
405
+ if (!import_protocol_http.HttpResponse.isInstance(response))
406
+ return result;
407
+ const { statusCode, body } = response;
408
+ if (statusCode < 200 || statusCode >= 300)
409
+ return result;
410
+ const bodyBytes = await collectBody(body, config);
411
+ const bodyString = await collectBodyString(bodyBytes, config);
412
+ if (bodyBytes.length === 0) {
413
+ const err = new Error("S3 aborted request");
414
+ err.name = "InternalError";
415
+ throw err;
416
+ }
417
+ if (bodyString && bodyString.match("<Error>")) {
418
+ response.statusCode = 400;
419
+ }
420
+ response.body = bodyBytes;
421
+ return result;
422
+ }, "throw200ExceptionsMiddleware");
423
+ var collectBody = /* @__PURE__ */ __name((streamBody = new Uint8Array(), context) => {
424
+ if (streamBody instanceof Uint8Array) {
425
+ return Promise.resolve(streamBody);
426
+ }
427
+ return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
428
+ }, "collectBody");
429
+ var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body)), "collectBodyString");
430
+ var throw200ExceptionsMiddlewareOptions = {
431
+ relation: "after",
432
+ toMiddleware: "deserializerMiddleware",
433
+ tags: ["THROW_200_EXCEPTIONS", "S3"],
434
+ name: "throw200ExceptionsMiddleware",
435
+ override: true
436
+ };
437
+ var getThrow200ExceptionsPlugin = /* @__PURE__ */ __name((config) => ({
438
+ applyToStack: (clientStack) => {
439
+ clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);
440
+ }
441
+ }), "getThrow200ExceptionsPlugin");
442
+
443
+ // src/validate-bucket-name.ts
444
+ var import_util_arn_parser = require("@aws-sdk/util-arn-parser");
445
+ function validateBucketNameMiddleware() {
446
+ return (next) => async (args) => {
447
+ const {
448
+ input: { Bucket }
449
+ } = args;
450
+ if (typeof Bucket === "string" && !(0, import_util_arn_parser.validate)(Bucket) && Bucket.indexOf("/") >= 0) {
451
+ const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
452
+ err.name = "InvalidBucketName";
453
+ throw err;
454
+ }
455
+ return next({ ...args });
456
+ };
457
+ }
458
+ __name(validateBucketNameMiddleware, "validateBucketNameMiddleware");
459
+ var validateBucketNameMiddlewareOptions = {
460
+ step: "initialize",
461
+ tags: ["VALIDATE_BUCKET_NAME"],
462
+ name: "validateBucketNameMiddleware",
463
+ override: true
464
+ };
465
+ var getValidateBucketNamePlugin = /* @__PURE__ */ __name((unused) => ({
466
+ applyToStack: (clientStack) => {
467
+ clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
468
+ }
469
+ }), "getValidateBucketNamePlugin");
470
+ // Annotate the CommonJS export names for ESM import in node:
471
+ 0 && (module.exports = {
472
+ NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS,
473
+ S3ExpressIdentityCache,
474
+ S3ExpressIdentityCacheEntry,
475
+ S3ExpressIdentityProviderImpl,
476
+ SignatureV4S3Express,
477
+ checkContentLengthHeader,
478
+ checkContentLengthHeaderMiddlewareOptions,
479
+ getCheckContentLengthHeaderPlugin,
480
+ getRegionRedirectMiddlewarePlugin,
481
+ getS3ExpressPlugin,
482
+ getThrow200ExceptionsPlugin,
483
+ getValidateBucketNamePlugin,
484
+ regionRedirectEndpointMiddleware,
485
+ regionRedirectEndpointMiddlewareOptions,
486
+ regionRedirectMiddleware,
487
+ regionRedirectMiddlewareOptions,
488
+ resolveS3Config,
489
+ s3ExpressMiddleware,
490
+ s3ExpressMiddlewareOptions,
491
+ throw200ExceptionsMiddleware,
492
+ throw200ExceptionsMiddlewareOptions,
493
+ validateBucketNameMiddleware,
494
+ validateBucketNameMiddlewareOptions
495
+ });
@@ -1,31 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.regionRedirectEndpointMiddlewareOptions = exports.regionRedirectEndpointMiddleware = void 0;
4
- const regionRedirectEndpointMiddleware = (config) => {
5
- return (next, context) => async (args) => {
6
- const originalRegion = await config.region();
7
- const regionProviderRef = config.region;
8
- if (context.__s3RegionRedirect) {
9
- config.region = async () => {
10
- config.region = regionProviderRef;
11
- return context.__s3RegionRedirect;
12
- };
13
- }
14
- const result = await next(args);
15
- if (context.__s3RegionRedirect) {
16
- const region = await config.region();
17
- if (originalRegion !== region) {
18
- throw new Error("Region was not restored following S3 region redirect.");
19
- }
20
- }
21
- return result;
22
- };
23
- };
24
- exports.regionRedirectEndpointMiddleware = regionRedirectEndpointMiddleware;
25
- exports.regionRedirectEndpointMiddlewareOptions = {
26
- tags: ["REGION_REDIRECT", "S3"],
27
- name: "regionRedirectEndpointMiddleware",
28
- override: true,
29
- relation: "before",
30
- toMiddleware: "endpointV2Middleware",
31
- };
1
+ module.exports = require("./index.js");
@@ -1,43 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRegionRedirectMiddlewarePlugin = exports.regionRedirectMiddlewareOptions = exports.regionRedirectMiddleware = void 0;
4
- const region_redirect_endpoint_middleware_1 = require("./region-redirect-endpoint-middleware");
5
- function regionRedirectMiddleware(clientConfig) {
6
- return (next, context) => async (args) => {
7
- var _a, _b;
8
- try {
9
- return await next(args);
10
- }
11
- catch (err) {
12
- if (clientConfig.followRegionRedirects &&
13
- ((_a = err === null || err === void 0 ? void 0 : err.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) === 301) {
14
- try {
15
- const actualRegion = err.$response.headers["x-amz-bucket-region"];
16
- (_b = context.logger) === null || _b === void 0 ? void 0 : _b.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`);
17
- context.__s3RegionRedirect = actualRegion;
18
- }
19
- catch (e) {
20
- throw new Error("Region redirect failed: " + e);
21
- }
22
- return next(args);
23
- }
24
- else {
25
- throw err;
26
- }
27
- }
28
- };
29
- }
30
- exports.regionRedirectMiddleware = regionRedirectMiddleware;
31
- exports.regionRedirectMiddlewareOptions = {
32
- step: "initialize",
33
- tags: ["REGION_REDIRECT", "S3"],
34
- name: "regionRedirectMiddleware",
35
- override: true,
36
- };
37
- const getRegionRedirectMiddlewarePlugin = (clientConfig) => ({
38
- applyToStack: (clientStack) => {
39
- clientStack.add(regionRedirectMiddleware(clientConfig), exports.regionRedirectMiddlewareOptions);
40
- clientStack.addRelativeTo((0, region_redirect_endpoint_middleware_1.regionRedirectEndpointMiddleware)(clientConfig), region_redirect_endpoint_middleware_1.regionRedirectEndpointMiddlewareOptions);
41
- },
42
- });
43
- exports.getRegionRedirectMiddlewarePlugin = getRegionRedirectMiddlewarePlugin;
1
+ module.exports = require("./index.js");
@@ -1,42 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3ExpressIdentityCache = void 0;
4
- class S3ExpressIdentityCache {
5
- constructor(data = {}) {
6
- this.data = data;
7
- this.lastPurgeTime = Date.now();
8
- }
9
- get(key) {
10
- const entry = this.data[key];
11
- if (!entry) {
12
- return;
13
- }
14
- return entry;
15
- }
16
- set(key, entry) {
17
- this.data[key] = entry;
18
- return entry;
19
- }
20
- delete(key) {
21
- delete this.data[key];
22
- }
23
- async purgeExpired() {
24
- const now = Date.now();
25
- if (this.lastPurgeTime + S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS > now) {
26
- return;
27
- }
28
- for (const key in this.data) {
29
- const entry = this.data[key];
30
- if (!entry.isRefreshing) {
31
- const credential = await entry.identity;
32
- if (credential.expiration) {
33
- if (credential.expiration.getTime() < now) {
34
- delete this.data[key];
35
- }
36
- }
37
- }
38
- }
39
- }
40
- }
41
- exports.S3ExpressIdentityCache = S3ExpressIdentityCache;
42
- S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS = 30000;
1
+ module.exports = require("../../index.js");
@@ -1,15 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3ExpressIdentityCacheEntry = void 0;
4
- class S3ExpressIdentityCacheEntry {
5
- constructor(_identity, isRefreshing = false, accessed = Date.now()) {
6
- this._identity = _identity;
7
- this.isRefreshing = isRefreshing;
8
- this.accessed = accessed;
9
- }
10
- get identity() {
11
- this.accessed = Date.now();
12
- return this._identity;
13
- }
14
- }
15
- exports.S3ExpressIdentityCacheEntry = S3ExpressIdentityCacheEntry;
1
+ module.exports = require("../../index.js");
@@ -1,53 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3ExpressIdentityProviderImpl = void 0;
4
- const S3ExpressIdentityCache_1 = require("./S3ExpressIdentityCache");
5
- const S3ExpressIdentityCacheEntry_1 = require("./S3ExpressIdentityCacheEntry");
6
- class S3ExpressIdentityProviderImpl {
7
- constructor(createSessionFn, cache = new S3ExpressIdentityCache_1.S3ExpressIdentityCache()) {
8
- this.createSessionFn = createSessionFn;
9
- this.cache = cache;
10
- }
11
- async getS3ExpressIdentity(awsIdentity, identityProperties) {
12
- const key = identityProperties.Bucket;
13
- const { cache } = this;
14
- const entry = cache.get(key);
15
- if (entry) {
16
- return entry.identity.then((identity) => {
17
- var _a, _b, _c, _d;
18
- const isExpired = ((_b = (_a = identity.expiration) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0) < Date.now();
19
- if (isExpired) {
20
- return cache.set(key, new S3ExpressIdentityCacheEntry_1.S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
21
- }
22
- const isExpiringSoon = ((_d = (_c = identity.expiration) === null || _c === void 0 ? void 0 : _c.getTime()) !== null && _d !== void 0 ? _d : 0) < Date.now() + S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS;
23
- if (isExpiringSoon && !entry.isRefreshing) {
24
- entry.isRefreshing = true;
25
- this.getIdentity(key).then((id) => {
26
- cache.set(key, new S3ExpressIdentityCacheEntry_1.S3ExpressIdentityCacheEntry(Promise.resolve(id)));
27
- });
28
- }
29
- return identity;
30
- });
31
- }
32
- return cache.set(key, new S3ExpressIdentityCacheEntry_1.S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity;
33
- }
34
- async getIdentity(key) {
35
- var _a, _b;
36
- await this.cache.purgeExpired().catch((error) => {
37
- console.warn("Error while clearing expired entries in S3ExpressIdentityCache: \n" + error);
38
- });
39
- const session = await this.createSessionFn(key);
40
- if (!((_a = session.Credentials) === null || _a === void 0 ? void 0 : _a.AccessKeyId) || !((_b = session.Credentials) === null || _b === void 0 ? void 0 : _b.SecretAccessKey)) {
41
- throw new Error("s3#createSession response credential missing AccessKeyId or SecretAccessKey.");
42
- }
43
- const identity = {
44
- accessKeyId: session.Credentials.AccessKeyId,
45
- secretAccessKey: session.Credentials.SecretAccessKey,
46
- sessionToken: session.Credentials.SessionToken,
47
- expiration: session.Credentials.Expiration ? new Date(session.Credentials.Expiration) : undefined,
48
- };
49
- return identity;
50
- }
51
- }
52
- exports.S3ExpressIdentityProviderImpl = S3ExpressIdentityProviderImpl;
53
- S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS = 60000;
1
+ module.exports = require("../../index.js");
@@ -1,46 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignatureV4S3Express = void 0;
4
- const signature_v4_1 = require("@smithy/signature-v4");
5
- const constants_1 = require("../constants");
6
- class SignatureV4S3Express extends signature_v4_1.SignatureV4 {
7
- async signWithCredentials(requestToSign, credentials, options) {
8
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
9
- requestToSign.headers[constants_1.SESSION_TOKEN_HEADER] = credentials.sessionToken;
10
- const privateAccess = this;
11
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
12
- return privateAccess.signRequest(requestToSign, options !== null && options !== void 0 ? options : {});
13
- }
14
- async presignWithCredentials(requestToSign, credentials, options) {
15
- var _a;
16
- const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
17
- delete requestToSign.headers[constants_1.SESSION_TOKEN_HEADER];
18
- requestToSign.headers[constants_1.SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
19
- requestToSign.query = (_a = requestToSign.query) !== null && _a !== void 0 ? _a : {};
20
- requestToSign.query[constants_1.SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
21
- const privateAccess = this;
22
- setSingleOverride(privateAccess, credentialsWithoutSessionToken);
23
- return this.presign(requestToSign, options);
24
- }
25
- }
26
- exports.SignatureV4S3Express = SignatureV4S3Express;
27
- function getCredentialsWithoutSessionToken(credentials) {
28
- const credentialsWithoutSessionToken = {
29
- accessKeyId: credentials.accessKeyId,
30
- secretAccessKey: credentials.secretAccessKey,
31
- expiration: credentials.expiration,
32
- };
33
- return credentialsWithoutSessionToken;
34
- }
35
- function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
36
- const id = setTimeout(() => {
37
- throw new Error("SignatureV4S3Express credential override was created but not called.");
38
- }, 10);
39
- const currentCredentialProvider = privateAccess.credentialProvider;
40
- const overrideCredentialsProviderOnce = () => {
41
- clearTimeout(id);
42
- privateAccess.credentialProvider = currentCredentialProvider;
43
- return Promise.resolve(credentialsWithoutSessionToken);
44
- };
45
- privateAccess.credentialProvider = overrideCredentialsProviderOnce;
46
- }
1
+ module.exports = require("../../index.js");
@@ -1,16 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = exports.SESSION_TOKEN_HEADER = exports.SESSION_TOKEN_QUERY_PARAM = exports.S3_EXPRESS_AUTH_SCHEME = exports.S3_EXPRESS_BACKEND = exports.S3_EXPRESS_BUCKET_TYPE = void 0;
4
- const util_config_provider_1 = require("@smithy/util-config-provider");
5
- exports.S3_EXPRESS_BUCKET_TYPE = "Directory";
6
- exports.S3_EXPRESS_BACKEND = "S3Express";
7
- exports.S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express";
8
- exports.SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
9
- exports.SESSION_TOKEN_HEADER = exports.SESSION_TOKEN_QUERY_PARAM.toLowerCase();
10
- exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH";
11
- exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth";
12
- exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = {
13
- environmentVariableSelector: (env) => (0, util_config_provider_1.booleanSelector)(env, exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, util_config_provider_1.SelectorType.ENV),
14
- configFileSelector: (profile) => (0, util_config_provider_1.booleanSelector)(profile, exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, util_config_provider_1.SelectorType.CONFIG),
15
- default: false,
16
- };
1
+ module.exports = require("../index.js");
@@ -1,45 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getS3ExpressPlugin = exports.s3ExpressMiddlewareOptions = exports.s3ExpressMiddleware = void 0;
4
- const protocol_http_1 = require("@smithy/protocol-http");
5
- const constants_1 = require("../constants");
6
- const s3ExpressMiddleware = (options) => {
7
- return (next, context) => async (args) => {
8
- var _a, _b, _c, _d, _e;
9
- if (context.endpointV2) {
10
- const endpoint = context.endpointV2;
11
- const isS3ExpressAuth = ((_c = (_b = (_a = endpoint.properties) === null || _a === void 0 ? void 0 : _a.authSchemes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name) === constants_1.S3_EXPRESS_AUTH_SCHEME;
12
- const isS3ExpressBucket = ((_d = endpoint.properties) === null || _d === void 0 ? void 0 : _d.backend) === constants_1.S3_EXPRESS_BACKEND ||
13
- ((_e = endpoint.properties) === null || _e === void 0 ? void 0 : _e.bucketType) === constants_1.S3_EXPRESS_BUCKET_TYPE;
14
- if (isS3ExpressBucket) {
15
- context.isS3ExpressBucket = true;
16
- }
17
- if (isS3ExpressAuth) {
18
- const requestBucket = args.input.Bucket;
19
- if (requestBucket) {
20
- const s3ExpressIdentity = await options.s3ExpressIdentityProvider.getS3ExpressIdentity(await options.credentials(), {
21
- Bucket: requestBucket,
22
- });
23
- context.s3ExpressIdentity = s3ExpressIdentity;
24
- if (protocol_http_1.HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) {
25
- args.request.headers[constants_1.SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken;
26
- }
27
- }
28
- }
29
- }
30
- return next(args);
31
- };
32
- };
33
- exports.s3ExpressMiddleware = s3ExpressMiddleware;
34
- exports.s3ExpressMiddlewareOptions = {
35
- name: "s3ExpressMiddleware",
36
- step: "build",
37
- tags: ["S3", "S3_EXPRESS"],
38
- override: true,
39
- };
40
- const getS3ExpressPlugin = (options) => ({
41
- applyToStack: (clientStack) => {
42
- clientStack.add((0, exports.s3ExpressMiddleware)(options), exports.s3ExpressMiddlewareOptions);
43
- },
44
- });
45
- exports.getS3ExpressPlugin = getS3ExpressPlugin;
1
+ module.exports = require("../../index.js");
@@ -1,17 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.s3ExpressMiddlewareOptions = exports.s3ExpressMiddleware = exports.getS3ExpressPlugin = exports.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = exports.SignatureV4S3Express = exports.S3ExpressIdentityProviderImpl = exports.S3ExpressIdentityCacheEntry = exports.S3ExpressIdentityCache = void 0;
4
- var S3ExpressIdentityCache_1 = require("./classes/S3ExpressIdentityCache");
5
- Object.defineProperty(exports, "S3ExpressIdentityCache", { enumerable: true, get: function () { return S3ExpressIdentityCache_1.S3ExpressIdentityCache; } });
6
- var S3ExpressIdentityCacheEntry_1 = require("./classes/S3ExpressIdentityCacheEntry");
7
- Object.defineProperty(exports, "S3ExpressIdentityCacheEntry", { enumerable: true, get: function () { return S3ExpressIdentityCacheEntry_1.S3ExpressIdentityCacheEntry; } });
8
- var S3ExpressIdentityProviderImpl_1 = require("./classes/S3ExpressIdentityProviderImpl");
9
- Object.defineProperty(exports, "S3ExpressIdentityProviderImpl", { enumerable: true, get: function () { return S3ExpressIdentityProviderImpl_1.S3ExpressIdentityProviderImpl; } });
10
- var SignatureV4S3Express_1 = require("./classes/SignatureV4S3Express");
11
- Object.defineProperty(exports, "SignatureV4S3Express", { enumerable: true, get: function () { return SignatureV4S3Express_1.SignatureV4S3Express; } });
12
- var constants_1 = require("./constants");
13
- Object.defineProperty(exports, "NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS", { enumerable: true, get: function () { return constants_1.NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS; } });
14
- var s3ExpressMiddleware_1 = require("./functions/s3ExpressMiddleware");
15
- Object.defineProperty(exports, "getS3ExpressPlugin", { enumerable: true, get: function () { return s3ExpressMiddleware_1.getS3ExpressPlugin; } });
16
- Object.defineProperty(exports, "s3ExpressMiddleware", { enumerable: true, get: function () { return s3ExpressMiddleware_1.s3ExpressMiddleware; } });
17
- Object.defineProperty(exports, "s3ExpressMiddlewareOptions", { enumerable: true, get: function () { return s3ExpressMiddleware_1.s3ExpressMiddlewareOptions; } });
1
+ module.exports = require("../index.js");
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ module.exports = require("../../index.js");
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ module.exports = require("../../index.js");
@@ -1,20 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveS3Config = void 0;
4
- const s3_express_1 = require("./s3-express");
5
- const resolveS3Config = (input, { session, }) => {
6
- var _a, _b, _c, _d, _e;
7
- const [s3ClientProvider, CreateSessionCommandCtor] = session;
8
- return {
9
- ...input,
10
- forcePathStyle: (_a = input.forcePathStyle) !== null && _a !== void 0 ? _a : false,
11
- useAccelerateEndpoint: (_b = input.useAccelerateEndpoint) !== null && _b !== void 0 ? _b : false,
12
- disableMultiregionAccessPoints: (_c = input.disableMultiregionAccessPoints) !== null && _c !== void 0 ? _c : false,
13
- followRegionRedirects: (_d = input.followRegionRedirects) !== null && _d !== void 0 ? _d : false,
14
- s3ExpressIdentityProvider: (_e = input.s3ExpressIdentityProvider) !== null && _e !== void 0 ? _e : new s3_express_1.S3ExpressIdentityProviderImpl(async (key) => s3ClientProvider().send(new CreateSessionCommandCtor({
15
- Bucket: key,
16
- SessionMode: "ReadWrite",
17
- }))),
18
- };
19
- };
20
- exports.resolveS3Config = resolveS3Config;
1
+ module.exports = require("./index.js");
@@ -1,46 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getThrow200ExceptionsPlugin = exports.throw200ExceptionsMiddlewareOptions = exports.throw200ExceptionsMiddleware = void 0;
4
- const protocol_http_1 = require("@smithy/protocol-http");
5
- const throw200ExceptionsMiddleware = (config) => (next) => async (args) => {
6
- const result = await next(args);
7
- const { response } = result;
8
- if (!protocol_http_1.HttpResponse.isInstance(response))
9
- return result;
10
- const { statusCode, body } = response;
11
- if (statusCode < 200 || statusCode >= 300)
12
- return result;
13
- const bodyBytes = await collectBody(body, config);
14
- const bodyString = await collectBodyString(bodyBytes, config);
15
- if (bodyBytes.length === 0) {
16
- const err = new Error("S3 aborted request");
17
- err.name = "InternalError";
18
- throw err;
19
- }
20
- if (bodyString && bodyString.match("<Error>")) {
21
- response.statusCode = 400;
22
- }
23
- response.body = bodyBytes;
24
- return result;
25
- };
26
- exports.throw200ExceptionsMiddleware = throw200ExceptionsMiddleware;
27
- const collectBody = (streamBody = new Uint8Array(), context) => {
28
- if (streamBody instanceof Uint8Array) {
29
- return Promise.resolve(streamBody);
30
- }
31
- return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
32
- };
33
- const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
34
- exports.throw200ExceptionsMiddlewareOptions = {
35
- relation: "after",
36
- toMiddleware: "deserializerMiddleware",
37
- tags: ["THROW_200_EXCEPTIONS", "S3"],
38
- name: "throw200ExceptionsMiddleware",
39
- override: true,
40
- };
41
- const getThrow200ExceptionsPlugin = (config) => ({
42
- applyToStack: (clientStack) => {
43
- clientStack.addRelativeTo((0, exports.throw200ExceptionsMiddleware)(config), exports.throw200ExceptionsMiddlewareOptions);
44
- },
45
- });
46
- exports.getThrow200ExceptionsPlugin = getThrow200ExceptionsPlugin;
1
+ module.exports = require("./index.js");
@@ -1,28 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValidateBucketNamePlugin = exports.validateBucketNameMiddlewareOptions = exports.validateBucketNameMiddleware = void 0;
4
- const util_arn_parser_1 = require("@aws-sdk/util-arn-parser");
5
- function validateBucketNameMiddleware() {
6
- return (next) => async (args) => {
7
- const { input: { Bucket }, } = args;
8
- if (typeof Bucket === "string" && !(0, util_arn_parser_1.validate)(Bucket) && Bucket.indexOf("/") >= 0) {
9
- const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
10
- err.name = "InvalidBucketName";
11
- throw err;
12
- }
13
- return next({ ...args });
14
- };
15
- }
16
- exports.validateBucketNameMiddleware = validateBucketNameMiddleware;
17
- exports.validateBucketNameMiddlewareOptions = {
18
- step: "initialize",
19
- tags: ["VALIDATE_BUCKET_NAME"],
20
- name: "validateBucketNameMiddleware",
21
- override: true,
22
- };
23
- const getValidateBucketNamePlugin = (unused) => ({
24
- applyToStack: (clientStack) => {
25
- clientStack.add(validateBucketNameMiddleware(), exports.validateBucketNameMiddlewareOptions);
26
- },
27
- });
28
- exports.getValidateBucketNamePlugin = getValidateBucketNamePlugin;
1
+ module.exports = require("./index.js");
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.485.0",
3
+ "version": "3.495.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
- "build:cjs": "tsc -p tsconfig.cjs.json",
6
+ "build:cjs": "node ../../scripts/compilation/inline middleware-sdk-s3",
7
7
  "build:es": "tsc -p tsconfig.es.json",
8
8
  "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
9
9
  "build:types": "tsc -p tsconfig.types.json",
@@ -23,14 +23,14 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@aws-sdk/types": "3.485.0",
27
- "@aws-sdk/util-arn-parser": "3.465.0",
28
- "@smithy/node-config-provider": "^2.1.9",
29
- "@smithy/protocol-http": "^3.0.12",
30
- "@smithy/signature-v4": "^2.0.0",
31
- "@smithy/smithy-client": "^2.2.1",
32
- "@smithy/types": "^2.8.0",
33
- "@smithy/util-config-provider": "^2.1.0",
26
+ "@aws-sdk/types": "3.495.0",
27
+ "@aws-sdk/util-arn-parser": "3.495.0",
28
+ "@smithy/node-config-provider": "^2.2.0",
29
+ "@smithy/protocol-http": "^3.1.0",
30
+ "@smithy/signature-v4": "^2.1.0",
31
+ "@smithy/smithy-client": "^2.3.0",
32
+ "@smithy/types": "^2.9.0",
33
+ "@smithy/util-config-provider": "^2.2.0",
34
34
  "tslib": "^2.5.0"
35
35
  },
36
36
  "devDependencies": {