@apicity/b2 0.4.0 → 0.4.2
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/README.md +2 -3
- package/dist/src/b2.js +1 -1
- package/dist/src/b2.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/s3-types.d.ts +821 -0
- package/dist/src/s3-types.d.ts.map +1 -0
- package/dist/src/s3-types.js +17 -0
- package/dist/src/s3-types.js.map +1 -0
- package/dist/src/s3-zod.d.ts +1562 -0
- package/dist/src/s3-zod.d.ts.map +1 -0
- package/dist/src/s3-zod.js +463 -0
- package/dist/src/s3-zod.js.map +1 -0
- package/dist/src/s3.d.ts +3 -0
- package/dist/src/s3.d.ts.map +1 -0
- package/dist/src/s3.js +2880 -0
- package/dist/src/s3.js.map +1 -0
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/zod.d.ts +1 -1
- package/dist/src/zod.d.ts.map +1 -1
- package/dist/src/zod.js +2 -2
- package/dist/src/zod.js.map +1 -1
- package/package.json +2 -3
package/dist/src/s3.js
ADDED
|
@@ -0,0 +1,2880 @@
|
|
|
1
|
+
import { createHash, createHmac } from "node:crypto";
|
|
2
|
+
import { S3Error } from "./s3-types.js";
|
|
3
|
+
import { S3AbortMultipartUploadRequestSchema, S3BucketConfigRequestSchema, S3BucketConfigWithIdRequestSchema, S3BucketConfigWithPayerRequestSchema, S3BucketRequestSchema, S3CompleteMultipartUploadRequestSchema, S3CopyObjectRequestSchema, S3CreateMultipartUploadRequestSchema, S3CreateBucketRequestSchema, S3CreateSessionRequestSchema, S3DeleteObjectRequestSchema, S3DeleteObjectsRequestSchema, S3GetBucketVersioningRequestSchema, S3GetObjectRequestSchema, S3GetObjectAttributesRequestSchema, S3HeadObjectRequestSchema, S3ListBucketConfigsRequestSchema, S3ListBucketsRequestSchema, S3ListDirectoryBucketsRequestSchema, S3ListMultipartUploadsRequestSchema, S3ListObjectVersionsRequestSchema, S3ListObjectsRequestSchema, S3ListObjectsV2RequestSchema, S3ListPartsRequestSchema, S3ObjectGovernanceRequestSchema, S3ObjectTaggingRequestSchema, S3PutBucketAclRequestSchema, S3PutBucketPolicyRequestSchema, S3PutBucketMetadataConfigurationRequestSchema, S3PutBucketRequestPaymentRequestSchema, S3PutBucketTaggingRequestSchema, S3PutBucketVersioningRequestSchema, S3PutBucketXmlConfigRequestSchema, S3PutBucketXmlConfigWithIdRequestSchema, S3PutObjectAclRequestSchema, S3PutObjectLegalHoldRequestSchema, S3PutObjectLockConfigurationRequestSchema, S3PutObjectRetentionRequestSchema, S3PutObjectTaggingRequestSchema, S3PutObjectRequestSchema, S3PresignObjectRequestSchema, S3RenameObjectRequestSchema, S3RestoreObjectRequestSchema, S3SelectObjectContentRequestSchema, S3UpdateObjectEncryptionRequestSchema, S3UploadPartCopyRequestSchema, S3UploadPartRequestSchema, S3WriteGetObjectResponseRequestSchema, } from "./s3-zod.js";
|
|
4
|
+
const EMPTY_HASH = sha256Hex(new Uint8Array());
|
|
5
|
+
function endpointForRegion(region, usEastOneBaseURL) {
|
|
6
|
+
if (region === "us-east-1")
|
|
7
|
+
return usEastOneBaseURL;
|
|
8
|
+
return `https://s3.${region}.amazonaws.com`;
|
|
9
|
+
}
|
|
10
|
+
function attachAbortHandler(signal, controller) {
|
|
11
|
+
if (signal.aborted) {
|
|
12
|
+
controller.abort();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
16
|
+
}
|
|
17
|
+
function awsEncode(value) {
|
|
18
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
19
|
+
}
|
|
20
|
+
function encodeS3Key(key) {
|
|
21
|
+
return key.split("/").map(awsEncode).join("/");
|
|
22
|
+
}
|
|
23
|
+
function encodeCopySource(bucket, key, versionId) {
|
|
24
|
+
const source = `/${awsEncode(bucket)}/${encodeS3Key(key)}`;
|
|
25
|
+
const query = queryForVersion(versionId);
|
|
26
|
+
return query ? `${source}${query}` : source;
|
|
27
|
+
}
|
|
28
|
+
function buildQuery(params, joiner = "?") {
|
|
29
|
+
const entries = Object.entries(params).filter(([, value]) => value !== undefined);
|
|
30
|
+
if (entries.length === 0)
|
|
31
|
+
return "";
|
|
32
|
+
const query = entries
|
|
33
|
+
.map(([key, value]) => `${awsEncode(key)}=${awsEncode(String(value))}`)
|
|
34
|
+
.join("&");
|
|
35
|
+
return `${joiner}${query}`;
|
|
36
|
+
}
|
|
37
|
+
function queryForVersion(versionId) {
|
|
38
|
+
return buildQuery({ versionId });
|
|
39
|
+
}
|
|
40
|
+
async function bodyToBytes(body) {
|
|
41
|
+
if (body === undefined)
|
|
42
|
+
return undefined;
|
|
43
|
+
if (typeof body === "string")
|
|
44
|
+
return new TextEncoder().encode(body);
|
|
45
|
+
if (body instanceof Uint8Array)
|
|
46
|
+
return body;
|
|
47
|
+
if (body instanceof ArrayBuffer)
|
|
48
|
+
return new Uint8Array(body);
|
|
49
|
+
return new Uint8Array(await body.arrayBuffer());
|
|
50
|
+
}
|
|
51
|
+
function sha256Hex(data) {
|
|
52
|
+
return createHash("sha256").update(data).digest("hex");
|
|
53
|
+
}
|
|
54
|
+
function md5Base64(data) {
|
|
55
|
+
return createHash("md5").update(data).digest("base64");
|
|
56
|
+
}
|
|
57
|
+
function hmac(key, data) {
|
|
58
|
+
return createHmac("sha256", key).update(data, "utf8").digest();
|
|
59
|
+
}
|
|
60
|
+
function signingKey(secretAccessKey, date, region, service) {
|
|
61
|
+
const kDate = hmac(`AWS4${secretAccessKey}`, date);
|
|
62
|
+
const kRegion = hmac(kDate, region);
|
|
63
|
+
const kService = hmac(kRegion, service);
|
|
64
|
+
return hmac(kService, "aws4_request");
|
|
65
|
+
}
|
|
66
|
+
function formatAmzDate(date) {
|
|
67
|
+
const iso = date.toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
68
|
+
return { amzDate: iso, dateStamp: iso.slice(0, 8) };
|
|
69
|
+
}
|
|
70
|
+
function normalizeHeaderValue(value) {
|
|
71
|
+
return value.trim().replace(/\s+/g, " ");
|
|
72
|
+
}
|
|
73
|
+
function canonicalQuery(url) {
|
|
74
|
+
const pairs = [];
|
|
75
|
+
url.searchParams.forEach((value, key) => {
|
|
76
|
+
pairs.push([key, value]);
|
|
77
|
+
});
|
|
78
|
+
pairs.sort(([ak, av], [bk, bv]) => {
|
|
79
|
+
if (ak !== bk)
|
|
80
|
+
return ak < bk ? -1 : 1;
|
|
81
|
+
if (av !== bv)
|
|
82
|
+
return av < bv ? -1 : 1;
|
|
83
|
+
return 0;
|
|
84
|
+
});
|
|
85
|
+
return pairs
|
|
86
|
+
.map(([key, value]) => `${awsEncode(key)}=${awsEncode(value)}`)
|
|
87
|
+
.join("&");
|
|
88
|
+
}
|
|
89
|
+
function signHeaders(opts, method, url, headers, payloadHash, now, signingService = opts.signingService ?? "s3", signingRegion = opts.region) {
|
|
90
|
+
const { amzDate, dateStamp } = formatAmzDate(now);
|
|
91
|
+
const headersForSigning = {
|
|
92
|
+
...headers,
|
|
93
|
+
host: url.host,
|
|
94
|
+
"x-amz-content-sha256": payloadHash,
|
|
95
|
+
"x-amz-date": amzDate,
|
|
96
|
+
};
|
|
97
|
+
if (opts.sessionToken) {
|
|
98
|
+
headersForSigning["x-amz-security-token"] = opts.sessionToken;
|
|
99
|
+
}
|
|
100
|
+
const canonicalHeaderValues = {};
|
|
101
|
+
for (const [name, value] of Object.entries(headersForSigning)) {
|
|
102
|
+
canonicalHeaderValues[name.toLowerCase()] = value;
|
|
103
|
+
}
|
|
104
|
+
const sortedHeaderNames = Object.keys(canonicalHeaderValues).sort();
|
|
105
|
+
const canonicalHeaders = sortedHeaderNames
|
|
106
|
+
.map((name) => `${name}:${normalizeHeaderValue(canonicalHeaderValues[name])}\n`)
|
|
107
|
+
.join("");
|
|
108
|
+
const signedHeaders = sortedHeaderNames.join(";");
|
|
109
|
+
const canonicalRequest = [
|
|
110
|
+
method,
|
|
111
|
+
url.pathname || "/",
|
|
112
|
+
canonicalQuery(url),
|
|
113
|
+
canonicalHeaders,
|
|
114
|
+
signedHeaders,
|
|
115
|
+
payloadHash,
|
|
116
|
+
].join("\n");
|
|
117
|
+
const credentialScope = `${dateStamp}/${signingRegion}/${signingService}/aws4_request`;
|
|
118
|
+
const stringToSign = [
|
|
119
|
+
"AWS4-HMAC-SHA256",
|
|
120
|
+
amzDate,
|
|
121
|
+
credentialScope,
|
|
122
|
+
sha256Hex(new TextEncoder().encode(canonicalRequest)),
|
|
123
|
+
].join("\n");
|
|
124
|
+
const signature = createHmac("sha256", signingKey(opts.secretAccessKey, dateStamp, signingRegion, signingService))
|
|
125
|
+
.update(stringToSign, "utf8")
|
|
126
|
+
.digest("hex");
|
|
127
|
+
const authorization = [
|
|
128
|
+
`AWS4-HMAC-SHA256 Credential=${opts.accessKeyId}/${credentialScope}`,
|
|
129
|
+
`SignedHeaders=${signedHeaders}`,
|
|
130
|
+
`Signature=${signature}`,
|
|
131
|
+
].join(", ");
|
|
132
|
+
const finalHeaders = {
|
|
133
|
+
...headers,
|
|
134
|
+
Authorization: authorization,
|
|
135
|
+
"x-amz-content-sha256": payloadHash,
|
|
136
|
+
"x-amz-date": amzDate,
|
|
137
|
+
};
|
|
138
|
+
if (opts.sessionToken) {
|
|
139
|
+
finalHeaders["x-amz-security-token"] = opts.sessionToken;
|
|
140
|
+
}
|
|
141
|
+
return finalHeaders;
|
|
142
|
+
}
|
|
143
|
+
function isLocalOrIpHost(hostname) {
|
|
144
|
+
return (hostname === "localhost" ||
|
|
145
|
+
/^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname) ||
|
|
146
|
+
hostname.includes(":"));
|
|
147
|
+
}
|
|
148
|
+
function shouldUsePathStyle(endpoint, bucket, forcePathStyle) {
|
|
149
|
+
if (!bucket)
|
|
150
|
+
return true;
|
|
151
|
+
if (forcePathStyle !== undefined)
|
|
152
|
+
return forcePathStyle;
|
|
153
|
+
if (bucket.includes("."))
|
|
154
|
+
return true;
|
|
155
|
+
if (isLocalOrIpHost(endpoint.hostname))
|
|
156
|
+
return true;
|
|
157
|
+
return !endpoint.hostname.endsWith("amazonaws.com");
|
|
158
|
+
}
|
|
159
|
+
function buildRequestUrl(endpoint, pathStylePath, bucket, forcePathStyle) {
|
|
160
|
+
if (/^https?:\/\//i.test(pathStylePath)) {
|
|
161
|
+
return new URL(pathStylePath);
|
|
162
|
+
}
|
|
163
|
+
const url = new URL(endpoint);
|
|
164
|
+
const [rawPath = "/", rawQuery = ""] = pathStylePath.split("?");
|
|
165
|
+
const path = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
|
|
166
|
+
if (shouldUsePathStyle(url, bucket, forcePathStyle)) {
|
|
167
|
+
url.pathname = path;
|
|
168
|
+
}
|
|
169
|
+
else if (bucket) {
|
|
170
|
+
const bucketPrefix = `/${awsEncode(bucket)}`;
|
|
171
|
+
url.hostname = `${bucket}.${url.hostname}`;
|
|
172
|
+
if (path === bucketPrefix) {
|
|
173
|
+
url.pathname = "/";
|
|
174
|
+
}
|
|
175
|
+
else if (path.startsWith(`${bucketPrefix}/`)) {
|
|
176
|
+
url.pathname = path.slice(bucketPrefix.length);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
url.pathname = path;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
url.pathname = path;
|
|
184
|
+
}
|
|
185
|
+
url.search = rawQuery ? `?${rawQuery}` : "";
|
|
186
|
+
return url;
|
|
187
|
+
}
|
|
188
|
+
function collectHeaders(headers) {
|
|
189
|
+
const out = {};
|
|
190
|
+
headers.forEach((value, key) => {
|
|
191
|
+
out[key.toLowerCase()] = value;
|
|
192
|
+
});
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function getHeader(headers, name) {
|
|
196
|
+
return headers.get(name) ?? undefined;
|
|
197
|
+
}
|
|
198
|
+
function numberHeader(headers, name) {
|
|
199
|
+
const value = headers.get(name);
|
|
200
|
+
if (!value)
|
|
201
|
+
return undefined;
|
|
202
|
+
const parsed = Number(value);
|
|
203
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
204
|
+
}
|
|
205
|
+
function booleanHeader(headers, name) {
|
|
206
|
+
const value = headers.get(name);
|
|
207
|
+
if (value === null)
|
|
208
|
+
return undefined;
|
|
209
|
+
return value === "true";
|
|
210
|
+
}
|
|
211
|
+
function metadataHeaders(headers) {
|
|
212
|
+
const metadata = {};
|
|
213
|
+
headers.forEach((value, key) => {
|
|
214
|
+
if (key.toLowerCase().startsWith("x-amz-meta-")) {
|
|
215
|
+
metadata[key.slice("x-amz-meta-".length)] = value;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return metadata;
|
|
219
|
+
}
|
|
220
|
+
function objectHeaders(res) {
|
|
221
|
+
return {
|
|
222
|
+
acceptRanges: getHeader(res.headers, "accept-ranges"),
|
|
223
|
+
cacheControl: getHeader(res.headers, "cache-control"),
|
|
224
|
+
contentDisposition: getHeader(res.headers, "content-disposition"),
|
|
225
|
+
contentEncoding: getHeader(res.headers, "content-encoding"),
|
|
226
|
+
contentLanguage: getHeader(res.headers, "content-language"),
|
|
227
|
+
contentLength: numberHeader(res.headers, "content-length"),
|
|
228
|
+
contentRange: getHeader(res.headers, "content-range"),
|
|
229
|
+
contentType: getHeader(res.headers, "content-type"),
|
|
230
|
+
eTag: getHeader(res.headers, "etag"),
|
|
231
|
+
expires: getHeader(res.headers, "expires"),
|
|
232
|
+
lastModified: getHeader(res.headers, "last-modified"),
|
|
233
|
+
storageClass: getHeader(res.headers, "x-amz-storage-class"),
|
|
234
|
+
versionId: getHeader(res.headers, "x-amz-version-id"),
|
|
235
|
+
metadata: metadataHeaders(res.headers),
|
|
236
|
+
headers: collectHeaders(res.headers),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function decodeXml(text) {
|
|
240
|
+
if (text === undefined)
|
|
241
|
+
return undefined;
|
|
242
|
+
return text
|
|
243
|
+
.replace(/"/g, '"')
|
|
244
|
+
.replace(/'/g, "'")
|
|
245
|
+
.replace(/</g, "<")
|
|
246
|
+
.replace(/>/g, ">")
|
|
247
|
+
.replace(/&/g, "&");
|
|
248
|
+
}
|
|
249
|
+
function xmlEscape(value) {
|
|
250
|
+
return value
|
|
251
|
+
.replace(/&/g, "&")
|
|
252
|
+
.replace(/</g, "<")
|
|
253
|
+
.replace(/>/g, ">")
|
|
254
|
+
.replace(/"/g, """)
|
|
255
|
+
.replace(/'/g, "'");
|
|
256
|
+
}
|
|
257
|
+
function escapeRegExp(value) {
|
|
258
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
259
|
+
}
|
|
260
|
+
function xmlTagPattern(tag) {
|
|
261
|
+
return `(?:[A-Za-z_][\\w.-]*:)?${escapeRegExp(tag)}`;
|
|
262
|
+
}
|
|
263
|
+
function textOf(xml, tag) {
|
|
264
|
+
const tagPattern = xmlTagPattern(tag);
|
|
265
|
+
const match = xml.match(new RegExp(`<${tagPattern}(?:\\s[^>]*)?>([\\s\\S]*?)</${tagPattern}>`));
|
|
266
|
+
return decodeXml(match?.[1]);
|
|
267
|
+
}
|
|
268
|
+
function numberOf(xml, tag) {
|
|
269
|
+
const text = textOf(xml, tag);
|
|
270
|
+
if (text === undefined)
|
|
271
|
+
return undefined;
|
|
272
|
+
const parsed = Number(text);
|
|
273
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
274
|
+
}
|
|
275
|
+
function boolOf(xml, tag) {
|
|
276
|
+
const text = textOf(xml, tag);
|
|
277
|
+
if (text === undefined)
|
|
278
|
+
return undefined;
|
|
279
|
+
return text.toLowerCase() === "true";
|
|
280
|
+
}
|
|
281
|
+
function blocksOf(xml, tag) {
|
|
282
|
+
const blocks = [];
|
|
283
|
+
const tagPattern = xmlTagPattern(tag);
|
|
284
|
+
const regex = new RegExp(`<${tagPattern}(?:\\s[^>]*)?>([\\s\\S]*?)</${tagPattern}>`, "g");
|
|
285
|
+
let match;
|
|
286
|
+
while ((match = regex.exec(xml)) !== null) {
|
|
287
|
+
blocks.push(match[1]);
|
|
288
|
+
}
|
|
289
|
+
return blocks;
|
|
290
|
+
}
|
|
291
|
+
function textsOf(xml, tag) {
|
|
292
|
+
return blocksOf(xml, tag).flatMap((text) => {
|
|
293
|
+
const decoded = decodeXml(text);
|
|
294
|
+
return decoded === undefined ? [] : [decoded];
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function parseOwner(xml) {
|
|
298
|
+
return {
|
|
299
|
+
id: textOf(xml, "ID"),
|
|
300
|
+
displayName: textOf(xml, "DisplayName"),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function parseS3Error(xml) {
|
|
304
|
+
return {
|
|
305
|
+
code: textOf(xml, "Code"),
|
|
306
|
+
message: textOf(xml, "Message"),
|
|
307
|
+
requestId: textOf(xml, "RequestId") ?? textOf(xml, "RequestID"),
|
|
308
|
+
hostId: textOf(xml, "HostId"),
|
|
309
|
+
rawBody: xml,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function parseListBuckets(xml) {
|
|
313
|
+
const ownerBlock = blocksOf(xml, "Owner")[0];
|
|
314
|
+
const owner = ownerBlock ? parseOwner(ownerBlock) : undefined;
|
|
315
|
+
const buckets = blocksOf(xml, "Bucket").map((block) => ({
|
|
316
|
+
name: textOf(block, "Name") ?? "",
|
|
317
|
+
creationDate: textOf(block, "CreationDate"),
|
|
318
|
+
}));
|
|
319
|
+
return { buckets, owner, rawXml: xml };
|
|
320
|
+
}
|
|
321
|
+
function parseListDirectoryBuckets(xml) {
|
|
322
|
+
return {
|
|
323
|
+
buckets: blocksOf(xml, "Bucket").map((block) => ({
|
|
324
|
+
bucketArn: textOf(block, "BucketArn"),
|
|
325
|
+
bucketRegion: textOf(block, "BucketRegion"),
|
|
326
|
+
creationDate: textOf(block, "CreationDate"),
|
|
327
|
+
name: textOf(block, "Name") ?? "",
|
|
328
|
+
})),
|
|
329
|
+
continuationToken: textOf(xml, "ContinuationToken"),
|
|
330
|
+
rawXml: xml,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function parseCreateSession(xml, headers) {
|
|
334
|
+
const credentialsBlock = blocksOf(xml, "Credentials")[0] ?? "";
|
|
335
|
+
return {
|
|
336
|
+
credentials: credentialsBlock
|
|
337
|
+
? {
|
|
338
|
+
accessKeyId: textOf(credentialsBlock, "AccessKeyId"),
|
|
339
|
+
secretAccessKey: textOf(credentialsBlock, "SecretAccessKey"),
|
|
340
|
+
sessionToken: textOf(credentialsBlock, "SessionToken"),
|
|
341
|
+
expiration: textOf(credentialsBlock, "Expiration"),
|
|
342
|
+
}
|
|
343
|
+
: undefined,
|
|
344
|
+
rawXml: xml,
|
|
345
|
+
headers: collectHeaders(headers),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function parseListObjectsV2(xml) {
|
|
349
|
+
return {
|
|
350
|
+
name: textOf(xml, "Name"),
|
|
351
|
+
prefix: textOf(xml, "Prefix"),
|
|
352
|
+
delimiter: textOf(xml, "Delimiter"),
|
|
353
|
+
keyCount: numberOf(xml, "KeyCount"),
|
|
354
|
+
maxKeys: numberOf(xml, "MaxKeys"),
|
|
355
|
+
isTruncated: boolOf(xml, "IsTruncated") ?? false,
|
|
356
|
+
nextContinuationToken: textOf(xml, "NextContinuationToken"),
|
|
357
|
+
contents: blocksOf(xml, "Contents").map((block) => {
|
|
358
|
+
const ownerBlock = blocksOf(block, "Owner")[0];
|
|
359
|
+
return {
|
|
360
|
+
key: textOf(block, "Key") ?? "",
|
|
361
|
+
lastModified: textOf(block, "LastModified"),
|
|
362
|
+
eTag: textOf(block, "ETag"),
|
|
363
|
+
size: numberOf(block, "Size"),
|
|
364
|
+
storageClass: textOf(block, "StorageClass"),
|
|
365
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
366
|
+
};
|
|
367
|
+
}),
|
|
368
|
+
commonPrefixes: blocksOf(xml, "CommonPrefixes").map((block) => ({
|
|
369
|
+
prefix: textOf(block, "Prefix") ?? "",
|
|
370
|
+
})),
|
|
371
|
+
rawXml: xml,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function parseObjectSummary(block) {
|
|
375
|
+
const ownerBlock = blocksOf(block, "Owner")[0];
|
|
376
|
+
return {
|
|
377
|
+
key: textOf(block, "Key") ?? "",
|
|
378
|
+
lastModified: textOf(block, "LastModified"),
|
|
379
|
+
eTag: textOf(block, "ETag"),
|
|
380
|
+
size: numberOf(block, "Size"),
|
|
381
|
+
storageClass: textOf(block, "StorageClass"),
|
|
382
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function parseListObjects(xml, headers) {
|
|
386
|
+
return {
|
|
387
|
+
name: textOf(xml, "Name"),
|
|
388
|
+
prefix: textOf(xml, "Prefix"),
|
|
389
|
+
delimiter: textOf(xml, "Delimiter"),
|
|
390
|
+
marker: textOf(xml, "Marker"),
|
|
391
|
+
nextMarker: textOf(xml, "NextMarker"),
|
|
392
|
+
maxKeys: numberOf(xml, "MaxKeys"),
|
|
393
|
+
encodingType: textOf(xml, "EncodingType"),
|
|
394
|
+
isTruncated: boolOf(xml, "IsTruncated") ?? false,
|
|
395
|
+
contents: blocksOf(xml, "Contents").map(parseObjectSummary),
|
|
396
|
+
commonPrefixes: blocksOf(xml, "CommonPrefixes").map((block) => ({
|
|
397
|
+
prefix: textOf(block, "Prefix") ?? "",
|
|
398
|
+
})),
|
|
399
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
400
|
+
rawXml: xml,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function parseRestoreStatus(xml) {
|
|
404
|
+
return {
|
|
405
|
+
isRestoreInProgress: boolOf(xml, "IsRestoreInProgress"),
|
|
406
|
+
restoreExpiryDate: textOf(xml, "RestoreExpiryDate"),
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function parseListObjectVersions(xml, headers) {
|
|
410
|
+
return {
|
|
411
|
+
name: textOf(xml, "Name"),
|
|
412
|
+
prefix: textOf(xml, "Prefix"),
|
|
413
|
+
delimiter: textOf(xml, "Delimiter"),
|
|
414
|
+
keyMarker: textOf(xml, "KeyMarker"),
|
|
415
|
+
versionIdMarker: textOf(xml, "VersionIdMarker"),
|
|
416
|
+
nextKeyMarker: textOf(xml, "NextKeyMarker"),
|
|
417
|
+
nextVersionIdMarker: textOf(xml, "NextVersionIdMarker"),
|
|
418
|
+
maxKeys: numberOf(xml, "MaxKeys"),
|
|
419
|
+
encodingType: textOf(xml, "EncodingType"),
|
|
420
|
+
isTruncated: boolOf(xml, "IsTruncated") ?? false,
|
|
421
|
+
versions: blocksOf(xml, "Version").map((block) => {
|
|
422
|
+
const ownerBlock = blocksOf(block, "Owner")[0];
|
|
423
|
+
const restoreBlock = blocksOf(block, "RestoreStatus")[0];
|
|
424
|
+
return {
|
|
425
|
+
...checksumFieldsFromXml(block),
|
|
426
|
+
key: textOf(block, "Key") ?? "",
|
|
427
|
+
versionId: textOf(block, "VersionId"),
|
|
428
|
+
isLatest: boolOf(block, "IsLatest"),
|
|
429
|
+
lastModified: textOf(block, "LastModified"),
|
|
430
|
+
eTag: textOf(block, "ETag"),
|
|
431
|
+
size: numberOf(block, "Size"),
|
|
432
|
+
storageClass: textOf(block, "StorageClass"),
|
|
433
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
434
|
+
restoreStatus: restoreBlock
|
|
435
|
+
? parseRestoreStatus(restoreBlock)
|
|
436
|
+
: undefined,
|
|
437
|
+
};
|
|
438
|
+
}),
|
|
439
|
+
deleteMarkers: blocksOf(xml, "DeleteMarker").map((block) => {
|
|
440
|
+
const ownerBlock = blocksOf(block, "Owner")[0];
|
|
441
|
+
return {
|
|
442
|
+
key: textOf(block, "Key") ?? "",
|
|
443
|
+
versionId: textOf(block, "VersionId"),
|
|
444
|
+
isLatest: boolOf(block, "IsLatest"),
|
|
445
|
+
lastModified: textOf(block, "LastModified"),
|
|
446
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
447
|
+
};
|
|
448
|
+
}),
|
|
449
|
+
commonPrefixes: blocksOf(xml, "CommonPrefixes").map((block) => ({
|
|
450
|
+
prefix: textOf(block, "Prefix") ?? "",
|
|
451
|
+
})),
|
|
452
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
453
|
+
rawXml: xml,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function parseBucketLocation(xml) {
|
|
457
|
+
const locationConstraint = textOf(xml, "LocationConstraint");
|
|
458
|
+
return {
|
|
459
|
+
locationConstraint: locationConstraint && locationConstraint.length > 0
|
|
460
|
+
? locationConstraint
|
|
461
|
+
: undefined,
|
|
462
|
+
rawXml: xml,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
function parseBucketVersioning(xml) {
|
|
466
|
+
return {
|
|
467
|
+
status: textOf(xml, "Status"),
|
|
468
|
+
mfaDelete: textOf(xml, "MfaDelete"),
|
|
469
|
+
rawXml: xml,
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function bucketConfigResponse(res) {
|
|
473
|
+
return { headers: collectHeaders(res.headers) };
|
|
474
|
+
}
|
|
475
|
+
function bucketXmlConfigResponse(xml, headers) {
|
|
476
|
+
return {
|
|
477
|
+
rawXml: xml,
|
|
478
|
+
headers: collectHeaders(headers),
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function parseBucketTagging(xml, headers) {
|
|
482
|
+
return {
|
|
483
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
484
|
+
tagSet: blocksOf(xml, "Tag").map((block) => ({
|
|
485
|
+
key: textOf(block, "Key") ?? "",
|
|
486
|
+
value: textOf(block, "Value") ?? "",
|
|
487
|
+
})),
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function parseBucketRequestPayment(xml, headers) {
|
|
491
|
+
return {
|
|
492
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
493
|
+
payer: textOf(xml, "Payer"),
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function parseBucketAbac(xml, headers) {
|
|
497
|
+
return {
|
|
498
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
499
|
+
status: textOf(xml, "Status"),
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function parseBucketAccelerateConfiguration(xml, headers) {
|
|
503
|
+
return {
|
|
504
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
505
|
+
status: textOf(xml, "Status"),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function parseBucketPolicyStatus(xml, headers) {
|
|
509
|
+
return {
|
|
510
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
511
|
+
isPublic: boolOf(xml, "IsPublic"),
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function parseBucketPolicy(policy, headers) {
|
|
515
|
+
return {
|
|
516
|
+
policy,
|
|
517
|
+
headers: collectHeaders(headers),
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function parseCopyObject(xml, headers) {
|
|
521
|
+
return {
|
|
522
|
+
eTag: textOf(xml, "ETag"),
|
|
523
|
+
lastModified: textOf(xml, "LastModified"),
|
|
524
|
+
checksumCRC32: textOf(xml, "ChecksumCRC32"),
|
|
525
|
+
checksumCRC32C: textOf(xml, "ChecksumCRC32C"),
|
|
526
|
+
checksumCRC64NVME: textOf(xml, "ChecksumCRC64NVME"),
|
|
527
|
+
checksumSHA1: textOf(xml, "ChecksumSHA1"),
|
|
528
|
+
checksumSHA256: textOf(xml, "ChecksumSHA256"),
|
|
529
|
+
checksumSHA512: textOf(xml, "ChecksumSHA512"),
|
|
530
|
+
checksumMD5: textOf(xml, "ChecksumMD5"),
|
|
531
|
+
checksumType: textOf(xml, "ChecksumType"),
|
|
532
|
+
versionId: getHeader(headers, "x-amz-version-id"),
|
|
533
|
+
copySourceVersionId: getHeader(headers, "x-amz-copy-source-version-id"),
|
|
534
|
+
serverSideEncryption: getHeader(headers, "x-amz-server-side-encryption"),
|
|
535
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
536
|
+
rawXml: xml,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function parseObjectTagging(xml, headers) {
|
|
540
|
+
return {
|
|
541
|
+
tagSet: blocksOf(xml, "Tag").map((block) => ({
|
|
542
|
+
key: textOf(block, "Key") ?? "",
|
|
543
|
+
value: textOf(block, "Value") ?? "",
|
|
544
|
+
})),
|
|
545
|
+
versionId: getHeader(headers, "x-amz-version-id"),
|
|
546
|
+
rawXml: xml,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function objectConfigResponse(res) {
|
|
550
|
+
return {
|
|
551
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
552
|
+
headers: collectHeaders(res.headers),
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function objectXmlConfigResponse(xml, headers) {
|
|
556
|
+
return {
|
|
557
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
558
|
+
rawXml: xml,
|
|
559
|
+
versionId: getHeader(headers, "x-amz-version-id"),
|
|
560
|
+
headers: collectHeaders(headers),
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function granteeTypeOf(xml) {
|
|
564
|
+
return xml.match(/(?:xsi:)?type="([^"]+)"/)?.[1];
|
|
565
|
+
}
|
|
566
|
+
function parseAclGrants(xml) {
|
|
567
|
+
return blocksOf(xml, "Grant").map((block) => {
|
|
568
|
+
const granteeBlock = blocksOf(block, "Grantee")[0] ?? "";
|
|
569
|
+
return {
|
|
570
|
+
grantee: {
|
|
571
|
+
type: granteeTypeOf(block),
|
|
572
|
+
id: textOf(granteeBlock, "ID"),
|
|
573
|
+
displayName: textOf(granteeBlock, "DisplayName"),
|
|
574
|
+
uri: textOf(granteeBlock, "URI"),
|
|
575
|
+
emailAddress: textOf(granteeBlock, "EmailAddress"),
|
|
576
|
+
},
|
|
577
|
+
permission: textOf(block, "Permission"),
|
|
578
|
+
};
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function parseBucketAcl(xml, headers) {
|
|
582
|
+
const ownerBlock = blocksOf(xml, "Owner")[0];
|
|
583
|
+
return {
|
|
584
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
585
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
586
|
+
grants: parseAclGrants(xml),
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function parseObjectAcl(xml, headers) {
|
|
590
|
+
const ownerBlock = blocksOf(xml, "Owner")[0];
|
|
591
|
+
return {
|
|
592
|
+
...objectXmlConfigResponse(xml, headers),
|
|
593
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
594
|
+
grants: parseAclGrants(xml),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function parseObjectAttributes(xml, headers) {
|
|
598
|
+
return {
|
|
599
|
+
...checksumFieldsFromXml(xml),
|
|
600
|
+
deleteMarker: booleanHeader(headers, "x-amz-delete-marker"),
|
|
601
|
+
eTag: textOf(xml, "ETag"),
|
|
602
|
+
lastModified: getHeader(headers, "last-modified"),
|
|
603
|
+
objectParts: blocksOf(xml, "ObjectParts")[0],
|
|
604
|
+
objectSize: numberOf(xml, "ObjectSize"),
|
|
605
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
606
|
+
storageClass: textOf(xml, "StorageClass"),
|
|
607
|
+
versionId: getHeader(headers, "x-amz-version-id"),
|
|
608
|
+
rawXml: xml,
|
|
609
|
+
headers: collectHeaders(headers),
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function parseObjectLegalHold(xml, headers) {
|
|
613
|
+
return {
|
|
614
|
+
...objectXmlConfigResponse(xml, headers),
|
|
615
|
+
status: textOf(xml, "Status"),
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
function parseObjectRetention(xml, headers) {
|
|
619
|
+
return {
|
|
620
|
+
...objectXmlConfigResponse(xml, headers),
|
|
621
|
+
mode: textOf(xml, "Mode"),
|
|
622
|
+
retainUntilDate: textOf(xml, "RetainUntilDate"),
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function parseObjectLockConfiguration(xml, headers) {
|
|
626
|
+
return {
|
|
627
|
+
...bucketXmlConfigResponse(xml, headers),
|
|
628
|
+
objectLockEnabled: textOf(xml, "ObjectLockEnabled"),
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
function parseDeleteObjects(xml, headers) {
|
|
632
|
+
return {
|
|
633
|
+
deleted: blocksOf(xml, "Deleted").map((block) => ({
|
|
634
|
+
key: textOf(block, "Key") ?? "",
|
|
635
|
+
versionId: textOf(block, "VersionId"),
|
|
636
|
+
deleteMarker: boolOf(block, "DeleteMarker"),
|
|
637
|
+
deleteMarkerVersionId: textOf(block, "DeleteMarkerVersionId"),
|
|
638
|
+
})),
|
|
639
|
+
errors: blocksOf(xml, "Error").map((block) => ({
|
|
640
|
+
key: textOf(block, "Key") ?? "",
|
|
641
|
+
versionId: textOf(block, "VersionId"),
|
|
642
|
+
code: textOf(block, "Code"),
|
|
643
|
+
message: textOf(block, "Message"),
|
|
644
|
+
})),
|
|
645
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
646
|
+
rawXml: xml,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function checksumFieldsFromXml(xml) {
|
|
650
|
+
return {
|
|
651
|
+
checksumCRC32: textOf(xml, "ChecksumCRC32"),
|
|
652
|
+
checksumCRC32C: textOf(xml, "ChecksumCRC32C"),
|
|
653
|
+
checksumCRC64NVME: textOf(xml, "ChecksumCRC64NVME"),
|
|
654
|
+
checksumMD5: textOf(xml, "ChecksumMD5"),
|
|
655
|
+
checksumSHA1: textOf(xml, "ChecksumSHA1"),
|
|
656
|
+
checksumSHA256: textOf(xml, "ChecksumSHA256"),
|
|
657
|
+
checksumSHA512: textOf(xml, "ChecksumSHA512"),
|
|
658
|
+
checksumType: textOf(xml, "ChecksumType"),
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function checksumFieldsFromHeaders(headers) {
|
|
662
|
+
return {
|
|
663
|
+
checksumCRC32: getHeader(headers, "x-amz-checksum-crc32"),
|
|
664
|
+
checksumCRC32C: getHeader(headers, "x-amz-checksum-crc32c"),
|
|
665
|
+
checksumCRC64NVME: getHeader(headers, "x-amz-checksum-crc64nvme"),
|
|
666
|
+
checksumMD5: getHeader(headers, "x-amz-checksum-md5"),
|
|
667
|
+
checksumSHA1: getHeader(headers, "x-amz-checksum-sha1"),
|
|
668
|
+
checksumSHA256: getHeader(headers, "x-amz-checksum-sha256"),
|
|
669
|
+
checksumSHA512: getHeader(headers, "x-amz-checksum-sha512"),
|
|
670
|
+
checksumType: getHeader(headers, "x-amz-checksum-type"),
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function parseCreateMultipartUpload(xml, headers) {
|
|
674
|
+
return {
|
|
675
|
+
...checksumFieldsFromHeaders(headers),
|
|
676
|
+
bucket: textOf(xml, "Bucket"),
|
|
677
|
+
key: textOf(xml, "Key"),
|
|
678
|
+
uploadId: textOf(xml, "UploadId") ?? "",
|
|
679
|
+
abortDate: getHeader(headers, "x-amz-abort-date"),
|
|
680
|
+
abortRuleId: getHeader(headers, "x-amz-abort-rule-id"),
|
|
681
|
+
bucketKeyEnabled: booleanHeader(headers, "x-amz-server-side-encryption-bucket-key-enabled"),
|
|
682
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
683
|
+
serverSideEncryption: getHeader(headers, "x-amz-server-side-encryption"),
|
|
684
|
+
sseKmsKeyId: getHeader(headers, "x-amz-server-side-encryption-aws-kms-key-id"),
|
|
685
|
+
rawXml: xml,
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function parseUploadPartCopy(xml, headers) {
|
|
689
|
+
return {
|
|
690
|
+
...checksumFieldsFromXml(xml),
|
|
691
|
+
eTag: textOf(xml, "ETag"),
|
|
692
|
+
lastModified: textOf(xml, "LastModified"),
|
|
693
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
694
|
+
rawXml: xml,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function parseCompleteMultipartUpload(xml, headers) {
|
|
698
|
+
return {
|
|
699
|
+
...checksumFieldsFromXml(xml),
|
|
700
|
+
location: textOf(xml, "Location"),
|
|
701
|
+
bucket: textOf(xml, "Bucket"),
|
|
702
|
+
key: textOf(xml, "Key"),
|
|
703
|
+
eTag: textOf(xml, "ETag"),
|
|
704
|
+
bucketKeyEnabled: booleanHeader(headers, "x-amz-server-side-encryption-bucket-key-enabled"),
|
|
705
|
+
expiration: getHeader(headers, "x-amz-expiration"),
|
|
706
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
707
|
+
serverSideEncryption: getHeader(headers, "x-amz-server-side-encryption"),
|
|
708
|
+
sseKmsKeyId: getHeader(headers, "x-amz-server-side-encryption-aws-kms-key-id"),
|
|
709
|
+
versionId: getHeader(headers, "x-amz-version-id"),
|
|
710
|
+
rawXml: xml,
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
function parseListParts(xml, headers) {
|
|
714
|
+
const initiatorBlock = blocksOf(xml, "Initiator")[0];
|
|
715
|
+
const ownerBlock = blocksOf(xml, "Owner")[0];
|
|
716
|
+
return {
|
|
717
|
+
bucket: textOf(xml, "Bucket"),
|
|
718
|
+
key: textOf(xml, "Key"),
|
|
719
|
+
uploadId: textOf(xml, "UploadId"),
|
|
720
|
+
partNumberMarker: numberOf(xml, "PartNumberMarker"),
|
|
721
|
+
nextPartNumberMarker: numberOf(xml, "NextPartNumberMarker"),
|
|
722
|
+
maxParts: numberOf(xml, "MaxParts"),
|
|
723
|
+
isTruncated: boolOf(xml, "IsTruncated") ?? false,
|
|
724
|
+
initiator: initiatorBlock ? parseOwner(initiatorBlock) : undefined,
|
|
725
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
726
|
+
storageClass: textOf(xml, "StorageClass"),
|
|
727
|
+
abortDate: getHeader(headers, "x-amz-abort-date"),
|
|
728
|
+
abortRuleId: getHeader(headers, "x-amz-abort-rule-id"),
|
|
729
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
730
|
+
parts: blocksOf(xml, "Part").map((block) => ({
|
|
731
|
+
...checksumFieldsFromXml(block),
|
|
732
|
+
partNumber: numberOf(block, "PartNumber") ?? 0,
|
|
733
|
+
lastModified: textOf(block, "LastModified"),
|
|
734
|
+
eTag: textOf(block, "ETag"),
|
|
735
|
+
size: numberOf(block, "Size"),
|
|
736
|
+
})),
|
|
737
|
+
rawXml: xml,
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function parseListMultipartUploads(xml, headers) {
|
|
741
|
+
return {
|
|
742
|
+
bucket: textOf(xml, "Bucket"),
|
|
743
|
+
keyMarker: textOf(xml, "KeyMarker"),
|
|
744
|
+
uploadIdMarker: textOf(xml, "UploadIdMarker"),
|
|
745
|
+
nextKeyMarker: textOf(xml, "NextKeyMarker"),
|
|
746
|
+
nextUploadIdMarker: textOf(xml, "NextUploadIdMarker"),
|
|
747
|
+
delimiter: textOf(xml, "Delimiter"),
|
|
748
|
+
prefix: textOf(xml, "Prefix"),
|
|
749
|
+
encodingType: textOf(xml, "EncodingType"),
|
|
750
|
+
maxUploads: numberOf(xml, "MaxUploads"),
|
|
751
|
+
isTruncated: boolOf(xml, "IsTruncated") ?? false,
|
|
752
|
+
requestCharged: getHeader(headers, "x-amz-request-charged"),
|
|
753
|
+
uploads: blocksOf(xml, "Upload").map((block) => {
|
|
754
|
+
const initiatorBlock = blocksOf(block, "Initiator")[0];
|
|
755
|
+
const ownerBlock = blocksOf(block, "Owner")[0];
|
|
756
|
+
return {
|
|
757
|
+
key: textOf(block, "Key") ?? "",
|
|
758
|
+
uploadId: textOf(block, "UploadId") ?? "",
|
|
759
|
+
initiated: textOf(block, "Initiated"),
|
|
760
|
+
initiator: initiatorBlock ? parseOwner(initiatorBlock) : undefined,
|
|
761
|
+
owner: ownerBlock ? parseOwner(ownerBlock) : undefined,
|
|
762
|
+
storageClass: textOf(block, "StorageClass"),
|
|
763
|
+
checksumAlgorithms: textsOf(block, "ChecksumAlgorithm"),
|
|
764
|
+
checksumType: textOf(block, "ChecksumType"),
|
|
765
|
+
};
|
|
766
|
+
}),
|
|
767
|
+
commonPrefixes: blocksOf(xml, "CommonPrefixes").map((block) => ({
|
|
768
|
+
prefix: textOf(block, "Prefix") ?? "",
|
|
769
|
+
})),
|
|
770
|
+
rawXml: xml,
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
function bucketRequestHeaders(expectedBucketOwner) {
|
|
774
|
+
if (!expectedBucketOwner)
|
|
775
|
+
return {};
|
|
776
|
+
return { "x-amz-expected-bucket-owner": expectedBucketOwner };
|
|
777
|
+
}
|
|
778
|
+
function bucketConfigHeaders(req) {
|
|
779
|
+
return bucketRequestHeaders(req.expectedBucketOwner);
|
|
780
|
+
}
|
|
781
|
+
function bucketConfigWithPayerHeaders(req) {
|
|
782
|
+
const headers = {};
|
|
783
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
784
|
+
return headers;
|
|
785
|
+
}
|
|
786
|
+
function bucketPutConfigHeaders(req, body, contentType) {
|
|
787
|
+
const headers = {
|
|
788
|
+
"Content-MD5": req.contentMD5 ?? md5Base64(new TextEncoder().encode(body)),
|
|
789
|
+
"Content-Type": contentType,
|
|
790
|
+
};
|
|
791
|
+
if (req.expectedBucketOwner) {
|
|
792
|
+
headers["x-amz-expected-bucket-owner"] = req.expectedBucketOwner;
|
|
793
|
+
}
|
|
794
|
+
if (req.checksumAlgorithm) {
|
|
795
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
796
|
+
}
|
|
797
|
+
return headers;
|
|
798
|
+
}
|
|
799
|
+
function directoryBucketZoneId(bucket) {
|
|
800
|
+
return bucket.match(/--([a-z0-9-]+)--x-s3$/i)?.[1];
|
|
801
|
+
}
|
|
802
|
+
function s3ExpressZonalBase(bucket, region, endpointOverride) {
|
|
803
|
+
if (endpointOverride)
|
|
804
|
+
return endpointOverride;
|
|
805
|
+
const zoneId = directoryBucketZoneId(bucket);
|
|
806
|
+
if (!zoneId) {
|
|
807
|
+
throw new S3Error("S3 Express directory bucket names must end with --zone-id--x-s3 when no endpoint override is configured.", 400);
|
|
808
|
+
}
|
|
809
|
+
return `https://s3express-${zoneId}.${region}.amazonaws.com`;
|
|
810
|
+
}
|
|
811
|
+
function createSessionHeaders(req) {
|
|
812
|
+
const headers = {};
|
|
813
|
+
if (req.sessionMode) {
|
|
814
|
+
headers["x-amz-create-session-mode"] = req.sessionMode;
|
|
815
|
+
}
|
|
816
|
+
if (req.serverSideEncryption) {
|
|
817
|
+
headers["x-amz-server-side-encryption"] = req.serverSideEncryption;
|
|
818
|
+
}
|
|
819
|
+
if (req.sseKmsKeyId) {
|
|
820
|
+
headers["x-amz-server-side-encryption-aws-kms-key-id"] = req.sseKmsKeyId;
|
|
821
|
+
}
|
|
822
|
+
if (req.sseKmsEncryptionContext) {
|
|
823
|
+
headers["x-amz-server-side-encryption-context"] =
|
|
824
|
+
req.sseKmsEncryptionContext;
|
|
825
|
+
}
|
|
826
|
+
if (req.bucketKeyEnabled !== undefined) {
|
|
827
|
+
headers["x-amz-server-side-encryption-bucket-key-enabled"] = String(req.bucketKeyEnabled);
|
|
828
|
+
}
|
|
829
|
+
return headers;
|
|
830
|
+
}
|
|
831
|
+
function renameObjectHeaders(req) {
|
|
832
|
+
const headers = {
|
|
833
|
+
"x-amz-rename-source": `/${encodeS3Key(req.sourceKey)}`,
|
|
834
|
+
};
|
|
835
|
+
if (req.clientToken)
|
|
836
|
+
headers["x-amz-client-token"] = req.clientToken;
|
|
837
|
+
if (req.s3SessionToken) {
|
|
838
|
+
headers["x-amz-s3session-token"] = req.s3SessionToken;
|
|
839
|
+
}
|
|
840
|
+
if (req.destinationIfMatch) {
|
|
841
|
+
headers["If-Match"] = req.destinationIfMatch;
|
|
842
|
+
}
|
|
843
|
+
if (req.destinationIfModifiedSince) {
|
|
844
|
+
headers["If-Modified-Since"] = req.destinationIfModifiedSince;
|
|
845
|
+
}
|
|
846
|
+
if (req.destinationIfNoneMatch) {
|
|
847
|
+
headers["If-None-Match"] = req.destinationIfNoneMatch;
|
|
848
|
+
}
|
|
849
|
+
if (req.destinationIfUnmodifiedSince) {
|
|
850
|
+
headers["If-Unmodified-Since"] = req.destinationIfUnmodifiedSince;
|
|
851
|
+
}
|
|
852
|
+
if (req.sourceIfMatch) {
|
|
853
|
+
headers["x-amz-rename-source-if-match"] = req.sourceIfMatch;
|
|
854
|
+
}
|
|
855
|
+
if (req.sourceIfModifiedSince) {
|
|
856
|
+
headers["x-amz-rename-source-if-modified-since"] =
|
|
857
|
+
req.sourceIfModifiedSince;
|
|
858
|
+
}
|
|
859
|
+
if (req.sourceIfNoneMatch) {
|
|
860
|
+
headers["x-amz-rename-source-if-none-match"] = req.sourceIfNoneMatch;
|
|
861
|
+
}
|
|
862
|
+
if (req.sourceIfUnmodifiedSince) {
|
|
863
|
+
headers["x-amz-rename-source-if-unmodified-since"] =
|
|
864
|
+
req.sourceIfUnmodifiedSince;
|
|
865
|
+
}
|
|
866
|
+
return headers;
|
|
867
|
+
}
|
|
868
|
+
function addForwardedResponseHeaders(headers, req) {
|
|
869
|
+
headers["x-amz-request-route"] = req.requestRoute;
|
|
870
|
+
headers["x-amz-request-token"] = req.requestToken;
|
|
871
|
+
if (req.statusCode !== undefined) {
|
|
872
|
+
headers["x-amz-fwd-status"] = String(req.statusCode);
|
|
873
|
+
}
|
|
874
|
+
if (req.errorCode)
|
|
875
|
+
headers["x-amz-fwd-error-code"] = req.errorCode;
|
|
876
|
+
if (req.errorMessage) {
|
|
877
|
+
headers["x-amz-fwd-error-message"] = req.errorMessage;
|
|
878
|
+
}
|
|
879
|
+
for (const [name, value] of Object.entries(req.headers ?? {})) {
|
|
880
|
+
const headerName = name.toLowerCase().startsWith("x-amz-fwd-")
|
|
881
|
+
? name
|
|
882
|
+
: `x-amz-fwd-header-${name}`;
|
|
883
|
+
headers[headerName] = value;
|
|
884
|
+
}
|
|
885
|
+
for (const [name, value] of Object.entries(req.metadata ?? {})) {
|
|
886
|
+
headers[`x-amz-fwd-header-x-amz-meta-${name.toLowerCase()}`] = value;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function objectGovernanceHeaders(req) {
|
|
890
|
+
const headers = {};
|
|
891
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
892
|
+
return headers;
|
|
893
|
+
}
|
|
894
|
+
function objectPutConfigHeaders(req, body) {
|
|
895
|
+
const headers = {
|
|
896
|
+
"Content-MD5": req.contentMD5 ?? md5Base64(new TextEncoder().encode(body)),
|
|
897
|
+
"Content-Type": "application/xml",
|
|
898
|
+
};
|
|
899
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
900
|
+
if (req.checksumAlgorithm) {
|
|
901
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
902
|
+
}
|
|
903
|
+
return headers;
|
|
904
|
+
}
|
|
905
|
+
function addSseCustomerHeaders(headers, req) {
|
|
906
|
+
if (req.sseCustomerAlgorithm) {
|
|
907
|
+
headers["x-amz-server-side-encryption-customer-algorithm"] =
|
|
908
|
+
req.sseCustomerAlgorithm;
|
|
909
|
+
}
|
|
910
|
+
if (req.sseCustomerKey) {
|
|
911
|
+
headers["x-amz-server-side-encryption-customer-key"] = req.sseCustomerKey;
|
|
912
|
+
}
|
|
913
|
+
if (req.sseCustomerKeyMD5) {
|
|
914
|
+
headers["x-amz-server-side-encryption-customer-key-MD5"] =
|
|
915
|
+
req.sseCustomerKeyMD5;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function addOwnerAndPayerHeaders(headers, expectedBucketOwner, requestPayer) {
|
|
919
|
+
if (expectedBucketOwner) {
|
|
920
|
+
headers["x-amz-expected-bucket-owner"] = expectedBucketOwner;
|
|
921
|
+
}
|
|
922
|
+
if (requestPayer) {
|
|
923
|
+
headers["x-amz-request-payer"] = requestPayer;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function addObjectContentHeaders(headers, req) {
|
|
927
|
+
if (req.contentType)
|
|
928
|
+
headers["Content-Type"] = req.contentType;
|
|
929
|
+
if (req.cacheControl)
|
|
930
|
+
headers["Cache-Control"] = req.cacheControl;
|
|
931
|
+
if (req.contentDisposition) {
|
|
932
|
+
headers["Content-Disposition"] = req.contentDisposition;
|
|
933
|
+
}
|
|
934
|
+
if (req.contentEncoding)
|
|
935
|
+
headers["Content-Encoding"] = req.contentEncoding;
|
|
936
|
+
if (req.contentLanguage)
|
|
937
|
+
headers["Content-Language"] = req.contentLanguage;
|
|
938
|
+
}
|
|
939
|
+
function addMetadataHeaders(headers, metadata) {
|
|
940
|
+
for (const [name, value] of Object.entries(metadata ?? {})) {
|
|
941
|
+
headers[`x-amz-meta-${name.toLowerCase()}`] = value;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function addChecksumRequestHeaders(headers, req) {
|
|
945
|
+
if (req.contentMD5)
|
|
946
|
+
headers["Content-MD5"] = req.contentMD5;
|
|
947
|
+
if (req.checksumAlgorithm) {
|
|
948
|
+
headers["x-amz-checksum-algorithm"] = req.checksumAlgorithm;
|
|
949
|
+
}
|
|
950
|
+
if (req.checksumCRC32)
|
|
951
|
+
headers["x-amz-checksum-crc32"] = req.checksumCRC32;
|
|
952
|
+
if (req.checksumCRC32C) {
|
|
953
|
+
headers["x-amz-checksum-crc32c"] = req.checksumCRC32C;
|
|
954
|
+
}
|
|
955
|
+
if (req.checksumCRC64NVME) {
|
|
956
|
+
headers["x-amz-checksum-crc64nvme"] = req.checksumCRC64NVME;
|
|
957
|
+
}
|
|
958
|
+
if (req.checksumMD5)
|
|
959
|
+
headers["x-amz-checksum-md5"] = req.checksumMD5;
|
|
960
|
+
if (req.checksumSHA1)
|
|
961
|
+
headers["x-amz-checksum-sha1"] = req.checksumSHA1;
|
|
962
|
+
if (req.checksumSHA256) {
|
|
963
|
+
headers["x-amz-checksum-sha256"] = req.checksumSHA256;
|
|
964
|
+
}
|
|
965
|
+
if (req.checksumSHA512) {
|
|
966
|
+
headers["x-amz-checksum-sha512"] = req.checksumSHA512;
|
|
967
|
+
}
|
|
968
|
+
if (req.checksumType)
|
|
969
|
+
headers["x-amz-checksum-type"] = req.checksumType;
|
|
970
|
+
}
|
|
971
|
+
function presignQuery(req, method) {
|
|
972
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
973
|
+
return queryForVersion(req.versionId);
|
|
974
|
+
}
|
|
975
|
+
return buildQuery({
|
|
976
|
+
versionId: req.versionId,
|
|
977
|
+
"response-cache-control": req.responseCacheControl,
|
|
978
|
+
"response-content-disposition": req.responseContentDisposition,
|
|
979
|
+
"response-content-encoding": req.responseContentEncoding,
|
|
980
|
+
"response-content-language": req.responseContentLanguage,
|
|
981
|
+
"response-content-type": req.responseContentType,
|
|
982
|
+
"response-expires": req.responseExpires,
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function presignHeaders(req, method) {
|
|
986
|
+
const headers = {};
|
|
987
|
+
if (method === "GET" || method === "HEAD") {
|
|
988
|
+
if (req.range)
|
|
989
|
+
headers.Range = req.range;
|
|
990
|
+
return headers;
|
|
991
|
+
}
|
|
992
|
+
if (method === "PUT") {
|
|
993
|
+
addObjectContentHeaders(headers, req);
|
|
994
|
+
if (req.storageClass)
|
|
995
|
+
headers["x-amz-storage-class"] = req.storageClass;
|
|
996
|
+
addMetadataHeaders(headers, req.metadata);
|
|
997
|
+
addChecksumRequestHeaders(headers, req);
|
|
998
|
+
}
|
|
999
|
+
return headers;
|
|
1000
|
+
}
|
|
1001
|
+
function canonicalPresignHeaders(headers, url) {
|
|
1002
|
+
const values = { host: url.host };
|
|
1003
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
1004
|
+
values[name.toLowerCase()] = value;
|
|
1005
|
+
}
|
|
1006
|
+
const names = Object.keys(values).sort();
|
|
1007
|
+
return {
|
|
1008
|
+
canonicalHeaders: names
|
|
1009
|
+
.map((name) => `${name}:${normalizeHeaderValue(values[name])}\n`)
|
|
1010
|
+
.join(""),
|
|
1011
|
+
signedHeaders: names.join(";"),
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function createBucketBody(locationConstraint) {
|
|
1015
|
+
if (!locationConstraint)
|
|
1016
|
+
return "";
|
|
1017
|
+
return [
|
|
1018
|
+
'<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1019
|
+
`<LocationConstraint>${xmlEscape(locationConstraint)}</LocationConstraint>`,
|
|
1020
|
+
"</CreateBucketConfiguration>",
|
|
1021
|
+
].join("");
|
|
1022
|
+
}
|
|
1023
|
+
function createCompleteMultipartUploadBody(parts) {
|
|
1024
|
+
const body = parts
|
|
1025
|
+
.map((part) => {
|
|
1026
|
+
const fields = [
|
|
1027
|
+
["ChecksumCRC32", part.checksumCRC32],
|
|
1028
|
+
["ChecksumCRC32C", part.checksumCRC32C],
|
|
1029
|
+
["ChecksumCRC64NVME", part.checksumCRC64NVME],
|
|
1030
|
+
["ChecksumSHA1", part.checksumSHA1],
|
|
1031
|
+
["ChecksumSHA256", part.checksumSHA256],
|
|
1032
|
+
["ChecksumSHA512", part.checksumSHA512],
|
|
1033
|
+
["ETag", part.eTag],
|
|
1034
|
+
["PartNumber", String(part.partNumber)],
|
|
1035
|
+
]
|
|
1036
|
+
.filter(([, value]) => value !== undefined)
|
|
1037
|
+
.map(([tag, value]) => `<${tag}>${xmlEscape(value ?? "")}</${tag}>`)
|
|
1038
|
+
.join("");
|
|
1039
|
+
return `<Part>${fields}</Part>`;
|
|
1040
|
+
})
|
|
1041
|
+
.join("");
|
|
1042
|
+
return [
|
|
1043
|
+
'<CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1044
|
+
body,
|
|
1045
|
+
"</CompleteMultipartUpload>",
|
|
1046
|
+
].join("");
|
|
1047
|
+
}
|
|
1048
|
+
function createDeleteObjectsBody(req) {
|
|
1049
|
+
const objects = req.objects
|
|
1050
|
+
.map((object) => {
|
|
1051
|
+
const fields = [
|
|
1052
|
+
["ETag", object.eTag],
|
|
1053
|
+
["Key", object.key],
|
|
1054
|
+
["LastModifiedTime", object.lastModifiedTime],
|
|
1055
|
+
["Size", object.size === undefined ? undefined : String(object.size)],
|
|
1056
|
+
["VersionId", object.versionId],
|
|
1057
|
+
]
|
|
1058
|
+
.filter(([, value]) => value !== undefined)
|
|
1059
|
+
.map(([tag, value]) => `<${tag}>${xmlEscape(value ?? "")}</${tag}>`)
|
|
1060
|
+
.join("");
|
|
1061
|
+
return `<Object>${fields}</Object>`;
|
|
1062
|
+
})
|
|
1063
|
+
.join("");
|
|
1064
|
+
const quiet = req.quiet === undefined ? "" : `<Quiet>${String(req.quiet)}</Quiet>`;
|
|
1065
|
+
return [
|
|
1066
|
+
'<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1067
|
+
objects,
|
|
1068
|
+
quiet,
|
|
1069
|
+
"</Delete>",
|
|
1070
|
+
].join("");
|
|
1071
|
+
}
|
|
1072
|
+
function createBucketVersioningBody(req) {
|
|
1073
|
+
const status = req.status ? `<Status>${xmlEscape(req.status)}</Status>` : "";
|
|
1074
|
+
const mfaDelete = req.mfaDelete
|
|
1075
|
+
? `<MfaDelete>${xmlEscape(req.mfaDelete)}</MfaDelete>`
|
|
1076
|
+
: "";
|
|
1077
|
+
return [
|
|
1078
|
+
'<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1079
|
+
status,
|
|
1080
|
+
mfaDelete,
|
|
1081
|
+
"</VersioningConfiguration>",
|
|
1082
|
+
].join("");
|
|
1083
|
+
}
|
|
1084
|
+
function createTaggingBody(tagSet) {
|
|
1085
|
+
const tags = tagSet
|
|
1086
|
+
.map((tag) => [
|
|
1087
|
+
"<Tag>",
|
|
1088
|
+
`<Key>${xmlEscape(tag.key)}</Key>`,
|
|
1089
|
+
`<Value>${xmlEscape(tag.value)}</Value>`,
|
|
1090
|
+
"</Tag>",
|
|
1091
|
+
].join(""))
|
|
1092
|
+
.join("");
|
|
1093
|
+
return [
|
|
1094
|
+
'<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1095
|
+
"<TagSet>",
|
|
1096
|
+
tags,
|
|
1097
|
+
"</TagSet>",
|
|
1098
|
+
"</Tagging>",
|
|
1099
|
+
].join("");
|
|
1100
|
+
}
|
|
1101
|
+
function createRequestPaymentBody(req) {
|
|
1102
|
+
return [
|
|
1103
|
+
'<RequestPaymentConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1104
|
+
`<Payer>${xmlEscape(req.payer)}</Payer>`,
|
|
1105
|
+
"</RequestPaymentConfiguration>",
|
|
1106
|
+
].join("");
|
|
1107
|
+
}
|
|
1108
|
+
function createLegalHoldBody(req) {
|
|
1109
|
+
return [
|
|
1110
|
+
'<LegalHold xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1111
|
+
`<Status>${xmlEscape(req.status)}</Status>`,
|
|
1112
|
+
"</LegalHold>",
|
|
1113
|
+
].join("");
|
|
1114
|
+
}
|
|
1115
|
+
function createRetentionBody(req) {
|
|
1116
|
+
return [
|
|
1117
|
+
'<Retention xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
|
|
1118
|
+
`<Mode>${xmlEscape(req.mode)}</Mode>`,
|
|
1119
|
+
`<RetainUntilDate>${xmlEscape(req.retainUntilDate)}</RetainUntilDate>`,
|
|
1120
|
+
"</Retention>",
|
|
1121
|
+
].join("");
|
|
1122
|
+
}
|
|
1123
|
+
function formatErrorMessage(status, parsed) {
|
|
1124
|
+
if (parsed.message && parsed.code) {
|
|
1125
|
+
return `S3 API error ${status} ${parsed.code}: ${parsed.message}`;
|
|
1126
|
+
}
|
|
1127
|
+
if (parsed.message) {
|
|
1128
|
+
return `S3 API error ${status}: ${parsed.message}`;
|
|
1129
|
+
}
|
|
1130
|
+
return `S3 API error: ${status}`;
|
|
1131
|
+
}
|
|
1132
|
+
export function createS3(opts) {
|
|
1133
|
+
const baseURL = "https://s3.us-east-1.amazonaws.com";
|
|
1134
|
+
const endpoint = (opts.endpoint ?? endpointForRegion(opts.region, baseURL)).replace(/\/+$/, "");
|
|
1135
|
+
const doFetch = opts.fetch ?? fetch;
|
|
1136
|
+
const timeout = opts.timeout ?? 30000;
|
|
1137
|
+
function readErrorFromBody(res, body) {
|
|
1138
|
+
const parsed = parseS3Error(body);
|
|
1139
|
+
return new S3Error(formatErrorMessage(res.status, parsed), res.status, body, parsed.code, parsed.requestId, parsed.hostId);
|
|
1140
|
+
}
|
|
1141
|
+
async function readError(res) {
|
|
1142
|
+
let body = "";
|
|
1143
|
+
try {
|
|
1144
|
+
body = await res.text();
|
|
1145
|
+
}
|
|
1146
|
+
catch {
|
|
1147
|
+
// ignore parse errors
|
|
1148
|
+
}
|
|
1149
|
+
return readErrorFromBody(res, body);
|
|
1150
|
+
}
|
|
1151
|
+
function shouldRetryWithBucketRegion(res, config) {
|
|
1152
|
+
if (!config.bucket || config.baseOverride || opts.endpoint)
|
|
1153
|
+
return false;
|
|
1154
|
+
return res.status === 301 || res.status === 307 || res.status === 400;
|
|
1155
|
+
}
|
|
1156
|
+
async function makeSignedRequest(method, path, config = {}, signal) {
|
|
1157
|
+
const controller = new AbortController();
|
|
1158
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
1159
|
+
if (signal) {
|
|
1160
|
+
attachAbortHandler(signal, controller);
|
|
1161
|
+
}
|
|
1162
|
+
try {
|
|
1163
|
+
const bodyBytes = await bodyToBytes(config.body);
|
|
1164
|
+
const payloadHash = bodyBytes ? sha256Hex(bodyBytes) : EMPTY_HASH;
|
|
1165
|
+
const send = async (requestEndpoint, signingRegion) => {
|
|
1166
|
+
const url = buildRequestUrl(requestEndpoint, path, config.bucket, opts.forcePathStyle);
|
|
1167
|
+
const headers = signHeaders(opts, method, url, config.headers ?? {}, payloadHash, new Date(), config.signingService, signingRegion ?? config.signingRegion);
|
|
1168
|
+
const init = {
|
|
1169
|
+
method,
|
|
1170
|
+
headers,
|
|
1171
|
+
signal: controller.signal,
|
|
1172
|
+
};
|
|
1173
|
+
if (bodyBytes)
|
|
1174
|
+
init.body = bodyBytes;
|
|
1175
|
+
return doFetch(url, init);
|
|
1176
|
+
};
|
|
1177
|
+
let res = await send(config.baseOverride ?? endpoint);
|
|
1178
|
+
if (!res.ok && shouldRetryWithBucketRegion(res, config)) {
|
|
1179
|
+
const redirectRegion = getHeader(res.headers, "x-amz-bucket-region");
|
|
1180
|
+
if (redirectRegion && redirectRegion !== opts.region) {
|
|
1181
|
+
res = await send(endpointForRegion(redirectRegion, baseURL), redirectRegion);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
clearTimeout(timeoutId);
|
|
1185
|
+
if (!res.ok) {
|
|
1186
|
+
throw await readError(res);
|
|
1187
|
+
}
|
|
1188
|
+
return res;
|
|
1189
|
+
}
|
|
1190
|
+
catch (error) {
|
|
1191
|
+
clearTimeout(timeoutId);
|
|
1192
|
+
if (error instanceof S3Error)
|
|
1193
|
+
throw error;
|
|
1194
|
+
throw new S3Error(`S3 request failed: ${error}`, 500);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
function presignObjectUrl(method, req) {
|
|
1198
|
+
const expiresIn = req.expiresIn ?? 900;
|
|
1199
|
+
if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > 604800) {
|
|
1200
|
+
throw new S3Error("S3 presigned URLs require expiresIn from 1 to 604800 seconds.", 400);
|
|
1201
|
+
}
|
|
1202
|
+
const bucket = awsEncode(req.bucket);
|
|
1203
|
+
const key = encodeS3Key(req.key);
|
|
1204
|
+
const url = buildRequestUrl(endpoint, `/${bucket}/${key}${presignQuery(req, method)}`, req.bucket, opts.forcePathStyle);
|
|
1205
|
+
const now = new Date();
|
|
1206
|
+
const { amzDate, dateStamp } = formatAmzDate(now);
|
|
1207
|
+
const signingService = opts.signingService ?? "s3";
|
|
1208
|
+
const credentialScope = `${dateStamp}/${opts.region}/${signingService}/aws4_request`;
|
|
1209
|
+
const headers = presignHeaders(req, method);
|
|
1210
|
+
const { canonicalHeaders, signedHeaders } = canonicalPresignHeaders(headers, url);
|
|
1211
|
+
url.searchParams.set("X-Amz-Algorithm", "AWS4-HMAC-SHA256");
|
|
1212
|
+
url.searchParams.set("X-Amz-Credential", `${opts.accessKeyId}/${credentialScope}`);
|
|
1213
|
+
url.searchParams.set("X-Amz-Date", amzDate);
|
|
1214
|
+
url.searchParams.set("X-Amz-Expires", String(expiresIn));
|
|
1215
|
+
url.searchParams.set("X-Amz-SignedHeaders", signedHeaders);
|
|
1216
|
+
if (opts.sessionToken) {
|
|
1217
|
+
url.searchParams.set("X-Amz-Security-Token", opts.sessionToken);
|
|
1218
|
+
}
|
|
1219
|
+
const canonicalRequest = [
|
|
1220
|
+
method,
|
|
1221
|
+
url.pathname || "/",
|
|
1222
|
+
canonicalQuery(url),
|
|
1223
|
+
canonicalHeaders,
|
|
1224
|
+
signedHeaders,
|
|
1225
|
+
"UNSIGNED-PAYLOAD",
|
|
1226
|
+
].join("\n");
|
|
1227
|
+
const stringToSign = [
|
|
1228
|
+
"AWS4-HMAC-SHA256",
|
|
1229
|
+
amzDate,
|
|
1230
|
+
credentialScope,
|
|
1231
|
+
sha256Hex(new TextEncoder().encode(canonicalRequest)),
|
|
1232
|
+
].join("\n");
|
|
1233
|
+
const signature = createHmac("sha256", signingKey(opts.secretAccessKey, dateStamp, opts.region, signingService))
|
|
1234
|
+
.update(stringToSign, "utf8")
|
|
1235
|
+
.digest("hex");
|
|
1236
|
+
url.searchParams.set("X-Amz-Signature", signature);
|
|
1237
|
+
return {
|
|
1238
|
+
expiresAt: new Date(now.getTime() + expiresIn * 1000).toISOString(),
|
|
1239
|
+
headers,
|
|
1240
|
+
url: url.toString(),
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
// sig-ok: action namespace over S3 service root
|
|
1244
|
+
// GET https://s3.us-east-1.amazonaws.com/
|
|
1245
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
|
|
1246
|
+
const bucketsList = Object.assign(async (_req, signal) => {
|
|
1247
|
+
const res = await makeSignedRequest("GET", "/", undefined, signal);
|
|
1248
|
+
return parseListBuckets(await res.text());
|
|
1249
|
+
}, { schema: S3ListBucketsRequestSchema });
|
|
1250
|
+
// sig-ok: action namespace over S3 Express control root
|
|
1251
|
+
// GET https://s3express-control.{param}.amazonaws.com/{query}
|
|
1252
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListDirectoryBuckets.html
|
|
1253
|
+
const bucketsListDirectory = Object.assign(async (req, signal) => {
|
|
1254
|
+
const params = req ?? {};
|
|
1255
|
+
const query = buildQuery({
|
|
1256
|
+
"continuation-token": params.continuationToken,
|
|
1257
|
+
"max-directory-buckets": params.maxDirectoryBuckets,
|
|
1258
|
+
});
|
|
1259
|
+
const res = await makeSignedRequest("GET", `/${query}`, {
|
|
1260
|
+
baseOverride: `https://s3express-control.${opts.region}.amazonaws.com`,
|
|
1261
|
+
signingService: "s3express",
|
|
1262
|
+
}, signal);
|
|
1263
|
+
return parseListDirectoryBuckets(await res.text());
|
|
1264
|
+
}, { schema: S3ListDirectoryBucketsRequestSchema });
|
|
1265
|
+
// sig-ok: action namespace over dynamic S3 bucket path
|
|
1266
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}
|
|
1267
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html
|
|
1268
|
+
const bucketsCreate = Object.assign(async (req, signal) => {
|
|
1269
|
+
const bucket = awsEncode(req.bucket);
|
|
1270
|
+
const locationConstraint = req.locationConstraint ??
|
|
1271
|
+
(opts.region === "us-east-1" ? undefined : opts.region);
|
|
1272
|
+
const body = createBucketBody(locationConstraint);
|
|
1273
|
+
const headers = {};
|
|
1274
|
+
if (body)
|
|
1275
|
+
headers["Content-Type"] = "application/xml";
|
|
1276
|
+
if (req.acl)
|
|
1277
|
+
headers["x-amz-acl"] = req.acl;
|
|
1278
|
+
if (req.objectOwnership) {
|
|
1279
|
+
headers["x-amz-object-ownership"] = req.objectOwnership;
|
|
1280
|
+
}
|
|
1281
|
+
if (req.objectLockEnabledForBucket !== undefined) {
|
|
1282
|
+
headers["x-amz-bucket-object-lock-enabled"] = String(req.objectLockEnabledForBucket);
|
|
1283
|
+
}
|
|
1284
|
+
const res = await makeSignedRequest("PUT", `/${bucket}`, {
|
|
1285
|
+
bucket: req.bucket,
|
|
1286
|
+
body: body || undefined,
|
|
1287
|
+
headers,
|
|
1288
|
+
}, signal);
|
|
1289
|
+
return {
|
|
1290
|
+
location: getHeader(res.headers, "location"),
|
|
1291
|
+
headers: collectHeaders(res.headers),
|
|
1292
|
+
};
|
|
1293
|
+
}, { schema: S3CreateBucketRequestSchema });
|
|
1294
|
+
// sig-ok: action namespace over S3 Express zonal bucket session path
|
|
1295
|
+
// GET https://s3express-{param}.{param}.amazonaws.com/{bucket}?session
|
|
1296
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateSession.html
|
|
1297
|
+
const bucketsCreateSession = Object.assign(async (req, signal) => {
|
|
1298
|
+
if (!opts.endpoint) {
|
|
1299
|
+
s3ExpressZonalBase(req.bucket, opts.region, opts.endpoint);
|
|
1300
|
+
}
|
|
1301
|
+
const bucket = awsEncode(req.bucket);
|
|
1302
|
+
const res = await makeSignedRequest("GET", `/${bucket}?session`, {
|
|
1303
|
+
bucket: req.bucket,
|
|
1304
|
+
baseOverride: opts.endpoint ??
|
|
1305
|
+
`https://s3express-${directoryBucketZoneId(req.bucket)}.${opts.region}.amazonaws.com`,
|
|
1306
|
+
headers: createSessionHeaders(req),
|
|
1307
|
+
signingService: "s3express",
|
|
1308
|
+
}, signal);
|
|
1309
|
+
return parseCreateSession(await res.text(), res.headers);
|
|
1310
|
+
}, { schema: S3CreateSessionRequestSchema });
|
|
1311
|
+
// sig-ok: action namespace over dynamic S3 bucket path
|
|
1312
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}
|
|
1313
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html
|
|
1314
|
+
const bucketsDel = Object.assign(async (req, signal) => {
|
|
1315
|
+
const bucket = awsEncode(req.bucket);
|
|
1316
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}`, {
|
|
1317
|
+
bucket: req.bucket,
|
|
1318
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
1319
|
+
}, signal);
|
|
1320
|
+
return { headers: collectHeaders(res.headers) };
|
|
1321
|
+
}, { schema: S3BucketRequestSchema });
|
|
1322
|
+
// sig-ok: action namespace over dynamic S3 bucket path
|
|
1323
|
+
// HEAD https://s3.us-east-1.amazonaws.com/{bucket}
|
|
1324
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html
|
|
1325
|
+
const bucketsHead = Object.assign(async (req, signal) => {
|
|
1326
|
+
const bucket = awsEncode(req.bucket);
|
|
1327
|
+
const res = await makeSignedRequest("HEAD", `/${bucket}`, {
|
|
1328
|
+
bucket: req.bucket,
|
|
1329
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
1330
|
+
}, signal);
|
|
1331
|
+
return {
|
|
1332
|
+
bucketArn: getHeader(res.headers, "x-amz-bucket-arn"),
|
|
1333
|
+
bucketLocationType: getHeader(res.headers, "x-amz-bucket-location-type"),
|
|
1334
|
+
bucketLocationName: getHeader(res.headers, "x-amz-bucket-location-name"),
|
|
1335
|
+
bucketRegion: getHeader(res.headers, "x-amz-bucket-region"),
|
|
1336
|
+
accessPointAlias: booleanHeader(res.headers, "x-amz-access-point-alias"),
|
|
1337
|
+
headers: collectHeaders(res.headers),
|
|
1338
|
+
};
|
|
1339
|
+
}, { schema: S3BucketRequestSchema });
|
|
1340
|
+
// sig-ok: action namespace over dynamic S3 bucket location path
|
|
1341
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?location
|
|
1342
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html
|
|
1343
|
+
const bucketsLocation = Object.assign(async (req, signal) => {
|
|
1344
|
+
const bucket = awsEncode(req.bucket);
|
|
1345
|
+
const res = await makeSignedRequest("GET", `/${bucket}?location`, {
|
|
1346
|
+
bucket: req.bucket,
|
|
1347
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
1348
|
+
}, signal);
|
|
1349
|
+
return parseBucketLocation(await res.text());
|
|
1350
|
+
}, { schema: S3BucketRequestSchema });
|
|
1351
|
+
// sig-ok: action namespace over dynamic S3 bucket versioning path
|
|
1352
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?versioning
|
|
1353
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html
|
|
1354
|
+
const bucketsGetVersioning = Object.assign(async (req, signal) => {
|
|
1355
|
+
const bucket = awsEncode(req.bucket);
|
|
1356
|
+
const res = await makeSignedRequest("GET", `/${bucket}?versioning`, {
|
|
1357
|
+
bucket: req.bucket,
|
|
1358
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
1359
|
+
}, signal);
|
|
1360
|
+
return parseBucketVersioning(await res.text());
|
|
1361
|
+
}, { schema: S3GetBucketVersioningRequestSchema });
|
|
1362
|
+
// sig-ok: action namespace over dynamic S3 bucket versioning path
|
|
1363
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?versioning
|
|
1364
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html
|
|
1365
|
+
const bucketsPutVersioning = Object.assign(async (req, signal) => {
|
|
1366
|
+
const bucket = awsEncode(req.bucket);
|
|
1367
|
+
const body = createBucketVersioningBody(req);
|
|
1368
|
+
const headers = {
|
|
1369
|
+
"Content-MD5": req.contentMD5 ?? md5Base64(new TextEncoder().encode(body)),
|
|
1370
|
+
"Content-Type": "application/xml",
|
|
1371
|
+
};
|
|
1372
|
+
if (req.expectedBucketOwner) {
|
|
1373
|
+
headers["x-amz-expected-bucket-owner"] = req.expectedBucketOwner;
|
|
1374
|
+
}
|
|
1375
|
+
if (req.checksumAlgorithm) {
|
|
1376
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
1377
|
+
}
|
|
1378
|
+
if (req.mfa)
|
|
1379
|
+
headers["x-amz-mfa"] = req.mfa;
|
|
1380
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?versioning`, { bucket: req.bucket, body, headers }, signal);
|
|
1381
|
+
return {
|
|
1382
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
1383
|
+
headers: collectHeaders(res.headers),
|
|
1384
|
+
};
|
|
1385
|
+
}, { schema: S3PutBucketVersioningRequestSchema });
|
|
1386
|
+
// sig-ok: action namespace over dynamic S3 bucket object lock path
|
|
1387
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?object-lock
|
|
1388
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLockConfiguration.html
|
|
1389
|
+
const bucketsGetObjectLockConfiguration = Object.assign(async (req, signal) => {
|
|
1390
|
+
const bucket = awsEncode(req.bucket);
|
|
1391
|
+
const res = await makeSignedRequest("GET", `/${bucket}?object-lock`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1392
|
+
return parseObjectLockConfiguration(await res.text(), res.headers);
|
|
1393
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1394
|
+
// sig-ok: action namespace over dynamic S3 bucket object lock path
|
|
1395
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?object-lock
|
|
1396
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLockConfiguration.html
|
|
1397
|
+
const bucketsPutObjectLockConfiguration = Object.assign(async (req, signal) => {
|
|
1398
|
+
const bucket = awsEncode(req.bucket);
|
|
1399
|
+
const headers = objectPutConfigHeaders(req, req.body);
|
|
1400
|
+
if (req.objectLockToken) {
|
|
1401
|
+
headers["x-amz-bucket-object-lock-token"] = req.objectLockToken;
|
|
1402
|
+
}
|
|
1403
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?object-lock`, { bucket: req.bucket, body: req.body, headers }, signal);
|
|
1404
|
+
return bucketConfigResponse(res);
|
|
1405
|
+
}, { schema: S3PutObjectLockConfigurationRequestSchema });
|
|
1406
|
+
// sig-ok: action namespace over dynamic S3 bucket CORS path
|
|
1407
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?cors
|
|
1408
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html
|
|
1409
|
+
const bucketsGetCors = Object.assign(async (req, signal) => {
|
|
1410
|
+
const bucket = awsEncode(req.bucket);
|
|
1411
|
+
const res = await makeSignedRequest("GET", `/${bucket}?cors`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1412
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1413
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1414
|
+
// sig-ok: action namespace over dynamic S3 bucket CORS path
|
|
1415
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?cors
|
|
1416
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html
|
|
1417
|
+
const bucketsPutCors = Object.assign(async (req, signal) => {
|
|
1418
|
+
const bucket = awsEncode(req.bucket);
|
|
1419
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?cors`, {
|
|
1420
|
+
bucket: req.bucket,
|
|
1421
|
+
body: req.body,
|
|
1422
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1423
|
+
}, signal);
|
|
1424
|
+
return bucketConfigResponse(res);
|
|
1425
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1426
|
+
// sig-ok: action namespace over dynamic S3 bucket CORS path
|
|
1427
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?cors
|
|
1428
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html
|
|
1429
|
+
const bucketsDelCors = Object.assign(async (req, signal) => {
|
|
1430
|
+
const bucket = awsEncode(req.bucket);
|
|
1431
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?cors`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1432
|
+
return bucketConfigResponse(res);
|
|
1433
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1434
|
+
// sig-ok: action namespace over dynamic S3 bucket lifecycle path
|
|
1435
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?lifecycle
|
|
1436
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html
|
|
1437
|
+
const bucketsGetLifecycle = Object.assign(async (req, signal) => {
|
|
1438
|
+
const bucket = awsEncode(req.bucket);
|
|
1439
|
+
const res = await makeSignedRequest("GET", `/${bucket}?lifecycle`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1440
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1441
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1442
|
+
// sig-ok: action namespace over dynamic S3 bucket lifecycle path
|
|
1443
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?lifecycle
|
|
1444
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html
|
|
1445
|
+
const bucketsPutLifecycle = Object.assign(async (req, signal) => {
|
|
1446
|
+
const bucket = awsEncode(req.bucket);
|
|
1447
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?lifecycle`, {
|
|
1448
|
+
bucket: req.bucket,
|
|
1449
|
+
body: req.body,
|
|
1450
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1451
|
+
}, signal);
|
|
1452
|
+
return bucketConfigResponse(res);
|
|
1453
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1454
|
+
// sig-ok: action namespace over dynamic S3 bucket lifecycle path
|
|
1455
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?lifecycle
|
|
1456
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycle.html
|
|
1457
|
+
const bucketsGetLifecycleLegacy = Object.assign(async (req, signal) => {
|
|
1458
|
+
const bucket = awsEncode(req.bucket);
|
|
1459
|
+
const res = await makeSignedRequest("GET", `/${bucket}?lifecycle`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1460
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1461
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1462
|
+
// sig-ok: action namespace over dynamic S3 bucket lifecycle path
|
|
1463
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?lifecycle
|
|
1464
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html
|
|
1465
|
+
const bucketsPutLifecycleLegacy = Object.assign(async (req, signal) => {
|
|
1466
|
+
const bucket = awsEncode(req.bucket);
|
|
1467
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?lifecycle`, {
|
|
1468
|
+
bucket: req.bucket,
|
|
1469
|
+
body: req.body,
|
|
1470
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1471
|
+
}, signal);
|
|
1472
|
+
return bucketConfigResponse(res);
|
|
1473
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1474
|
+
// sig-ok: action namespace over dynamic S3 bucket lifecycle path
|
|
1475
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?lifecycle
|
|
1476
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html
|
|
1477
|
+
const bucketsDelLifecycle = Object.assign(async (req, signal) => {
|
|
1478
|
+
const bucket = awsEncode(req.bucket);
|
|
1479
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?lifecycle`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1480
|
+
return bucketConfigResponse(res);
|
|
1481
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1482
|
+
// sig-ok: action namespace over dynamic S3 bucket encryption path
|
|
1483
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?encryption
|
|
1484
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html
|
|
1485
|
+
const bucketsGetEncryption = Object.assign(async (req, signal) => {
|
|
1486
|
+
const bucket = awsEncode(req.bucket);
|
|
1487
|
+
const res = await makeSignedRequest("GET", `/${bucket}?encryption`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1488
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1489
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1490
|
+
// sig-ok: action namespace over dynamic S3 bucket encryption path
|
|
1491
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?encryption
|
|
1492
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html
|
|
1493
|
+
const bucketsPutEncryption = Object.assign(async (req, signal) => {
|
|
1494
|
+
const bucket = awsEncode(req.bucket);
|
|
1495
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?encryption`, {
|
|
1496
|
+
bucket: req.bucket,
|
|
1497
|
+
body: req.body,
|
|
1498
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1499
|
+
}, signal);
|
|
1500
|
+
return bucketConfigResponse(res);
|
|
1501
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1502
|
+
// sig-ok: action namespace over dynamic S3 bucket encryption path
|
|
1503
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?encryption
|
|
1504
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html
|
|
1505
|
+
const bucketsDelEncryption = Object.assign(async (req, signal) => {
|
|
1506
|
+
const bucket = awsEncode(req.bucket);
|
|
1507
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?encryption`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1508
|
+
return bucketConfigResponse(res);
|
|
1509
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1510
|
+
// sig-ok: action namespace over dynamic S3 bucket policy path
|
|
1511
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?policy
|
|
1512
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicy.html
|
|
1513
|
+
const bucketsGetPolicy = Object.assign(async (req, signal) => {
|
|
1514
|
+
const bucket = awsEncode(req.bucket);
|
|
1515
|
+
const res = await makeSignedRequest("GET", `/${bucket}?policy`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1516
|
+
return parseBucketPolicy(await res.text(), res.headers);
|
|
1517
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1518
|
+
// sig-ok: action namespace over dynamic S3 bucket policy path
|
|
1519
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?policy
|
|
1520
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketPolicy.html
|
|
1521
|
+
const bucketsPutPolicy = Object.assign(async (req, signal) => {
|
|
1522
|
+
const bucket = awsEncode(req.bucket);
|
|
1523
|
+
const headers = bucketPutConfigHeaders(req, req.policy, "application/json");
|
|
1524
|
+
if (req.confirmRemoveSelfBucketAccess !== undefined) {
|
|
1525
|
+
headers["x-amz-confirm-remove-self-bucket-access"] = String(req.confirmRemoveSelfBucketAccess);
|
|
1526
|
+
}
|
|
1527
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?policy`, { bucket: req.bucket, body: req.policy, headers }, signal);
|
|
1528
|
+
return bucketConfigResponse(res);
|
|
1529
|
+
}, { schema: S3PutBucketPolicyRequestSchema });
|
|
1530
|
+
// sig-ok: action namespace over dynamic S3 bucket policy path
|
|
1531
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?policy
|
|
1532
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketPolicy.html
|
|
1533
|
+
const bucketsDelPolicy = Object.assign(async (req, signal) => {
|
|
1534
|
+
const bucket = awsEncode(req.bucket);
|
|
1535
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?policy`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1536
|
+
return bucketConfigResponse(res);
|
|
1537
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1538
|
+
// sig-ok: action namespace over dynamic S3 bucket policy status path
|
|
1539
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?policyStatus
|
|
1540
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicyStatus.html
|
|
1541
|
+
const bucketsGetPolicyStatus = Object.assign(async (req, signal) => {
|
|
1542
|
+
const bucket = awsEncode(req.bucket);
|
|
1543
|
+
const res = await makeSignedRequest("GET", `/${bucket}?policyStatus`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1544
|
+
return parseBucketPolicyStatus(await res.text(), res.headers);
|
|
1545
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1546
|
+
// sig-ok: action namespace over dynamic S3 bucket tagging path
|
|
1547
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?tagging
|
|
1548
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html
|
|
1549
|
+
const bucketsGetTagging = Object.assign(async (req, signal) => {
|
|
1550
|
+
const bucket = awsEncode(req.bucket);
|
|
1551
|
+
const res = await makeSignedRequest("GET", `/${bucket}?tagging`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1552
|
+
return parseBucketTagging(await res.text(), res.headers);
|
|
1553
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1554
|
+
// sig-ok: action namespace over dynamic S3 bucket tagging path
|
|
1555
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?tagging
|
|
1556
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketTagging.html
|
|
1557
|
+
const bucketsPutTagging = Object.assign(async (req, signal) => {
|
|
1558
|
+
const bucket = awsEncode(req.bucket);
|
|
1559
|
+
const body = createTaggingBody(req.tagSet);
|
|
1560
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?tagging`, {
|
|
1561
|
+
bucket: req.bucket,
|
|
1562
|
+
body,
|
|
1563
|
+
headers: bucketPutConfigHeaders(req, body, "application/xml"),
|
|
1564
|
+
}, signal);
|
|
1565
|
+
return bucketConfigResponse(res);
|
|
1566
|
+
}, { schema: S3PutBucketTaggingRequestSchema });
|
|
1567
|
+
// sig-ok: action namespace over dynamic S3 bucket tagging path
|
|
1568
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?tagging
|
|
1569
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketTagging.html
|
|
1570
|
+
const bucketsDelTagging = Object.assign(async (req, signal) => {
|
|
1571
|
+
const bucket = awsEncode(req.bucket);
|
|
1572
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?tagging`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1573
|
+
return bucketConfigResponse(res);
|
|
1574
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1575
|
+
// sig-ok: action namespace over dynamic S3 bucket public access block path
|
|
1576
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?publicAccessBlock
|
|
1577
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html
|
|
1578
|
+
const bucketsGetPublicAccessBlock = Object.assign(async (req, signal) => {
|
|
1579
|
+
const bucket = awsEncode(req.bucket);
|
|
1580
|
+
const res = await makeSignedRequest("GET", `/${bucket}?publicAccessBlock`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1581
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1582
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1583
|
+
// sig-ok: action namespace over dynamic S3 bucket public access block path
|
|
1584
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?publicAccessBlock
|
|
1585
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html
|
|
1586
|
+
const bucketsPutPublicAccessBlock = Object.assign(async (req, signal) => {
|
|
1587
|
+
const bucket = awsEncode(req.bucket);
|
|
1588
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?publicAccessBlock`, {
|
|
1589
|
+
bucket: req.bucket,
|
|
1590
|
+
body: req.body,
|
|
1591
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1592
|
+
}, signal);
|
|
1593
|
+
return bucketConfigResponse(res);
|
|
1594
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1595
|
+
// sig-ok: action namespace over dynamic S3 bucket public access block path
|
|
1596
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?publicAccessBlock
|
|
1597
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeletePublicAccessBlock.html
|
|
1598
|
+
const bucketsDelPublicAccessBlock = Object.assign(async (req, signal) => {
|
|
1599
|
+
const bucket = awsEncode(req.bucket);
|
|
1600
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?publicAccessBlock`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1601
|
+
return bucketConfigResponse(res);
|
|
1602
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1603
|
+
// sig-ok: action namespace over dynamic S3 bucket ownership controls path
|
|
1604
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?ownershipControls
|
|
1605
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketOwnershipControls.html
|
|
1606
|
+
const bucketsGetOwnershipControls = Object.assign(async (req, signal) => {
|
|
1607
|
+
const bucket = awsEncode(req.bucket);
|
|
1608
|
+
const res = await makeSignedRequest("GET", `/${bucket}?ownershipControls`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1609
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1610
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1611
|
+
// sig-ok: action namespace over dynamic S3 bucket ownership controls path
|
|
1612
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?ownershipControls
|
|
1613
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketOwnershipControls.html
|
|
1614
|
+
const bucketsPutOwnershipControls = Object.assign(async (req, signal) => {
|
|
1615
|
+
const bucket = awsEncode(req.bucket);
|
|
1616
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?ownershipControls`, {
|
|
1617
|
+
bucket: req.bucket,
|
|
1618
|
+
body: req.body,
|
|
1619
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1620
|
+
}, signal);
|
|
1621
|
+
return bucketConfigResponse(res);
|
|
1622
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1623
|
+
// sig-ok: action namespace over dynamic S3 bucket ownership controls path
|
|
1624
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?ownershipControls
|
|
1625
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketOwnershipControls.html
|
|
1626
|
+
const bucketsDelOwnershipControls = Object.assign(async (req, signal) => {
|
|
1627
|
+
const bucket = awsEncode(req.bucket);
|
|
1628
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?ownershipControls`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1629
|
+
return bucketConfigResponse(res);
|
|
1630
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1631
|
+
// sig-ok: action namespace over dynamic S3 bucket website path
|
|
1632
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?website
|
|
1633
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketWebsite.html
|
|
1634
|
+
const bucketsGetWebsite = Object.assign(async (req, signal) => {
|
|
1635
|
+
const bucket = awsEncode(req.bucket);
|
|
1636
|
+
const res = await makeSignedRequest("GET", `/${bucket}?website`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1637
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1638
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1639
|
+
// sig-ok: action namespace over dynamic S3 bucket website path
|
|
1640
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?website
|
|
1641
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketWebsite.html
|
|
1642
|
+
const bucketsPutWebsite = Object.assign(async (req, signal) => {
|
|
1643
|
+
const bucket = awsEncode(req.bucket);
|
|
1644
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?website`, {
|
|
1645
|
+
bucket: req.bucket,
|
|
1646
|
+
body: req.body,
|
|
1647
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1648
|
+
}, signal);
|
|
1649
|
+
return bucketConfigResponse(res);
|
|
1650
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1651
|
+
// sig-ok: action namespace over dynamic S3 bucket website path
|
|
1652
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?website
|
|
1653
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketWebsite.html
|
|
1654
|
+
const bucketsDelWebsite = Object.assign(async (req, signal) => {
|
|
1655
|
+
const bucket = awsEncode(req.bucket);
|
|
1656
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?website`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1657
|
+
return bucketConfigResponse(res);
|
|
1658
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1659
|
+
// sig-ok: action namespace over dynamic S3 bucket logging path
|
|
1660
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?logging
|
|
1661
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLogging.html
|
|
1662
|
+
const bucketsGetLogging = Object.assign(async (req, signal) => {
|
|
1663
|
+
const bucket = awsEncode(req.bucket);
|
|
1664
|
+
const res = await makeSignedRequest("GET", `/${bucket}?logging`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1665
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1666
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1667
|
+
// sig-ok: action namespace over dynamic S3 bucket logging path
|
|
1668
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?logging
|
|
1669
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLogging.html
|
|
1670
|
+
const bucketsPutLogging = Object.assign(async (req, signal) => {
|
|
1671
|
+
const bucket = awsEncode(req.bucket);
|
|
1672
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?logging`, {
|
|
1673
|
+
bucket: req.bucket,
|
|
1674
|
+
body: req.body,
|
|
1675
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1676
|
+
}, signal);
|
|
1677
|
+
return bucketConfigResponse(res);
|
|
1678
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1679
|
+
// sig-ok: action namespace over dynamic S3 bucket notification path
|
|
1680
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?notification
|
|
1681
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketNotificationConfiguration.html
|
|
1682
|
+
const bucketsGetNotification = Object.assign(async (req, signal) => {
|
|
1683
|
+
const bucket = awsEncode(req.bucket);
|
|
1684
|
+
const res = await makeSignedRequest("GET", `/${bucket}?notification`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1685
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1686
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1687
|
+
// sig-ok: action namespace over dynamic S3 bucket notification path
|
|
1688
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?notification
|
|
1689
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html
|
|
1690
|
+
const bucketsPutNotification = Object.assign(async (req, signal) => {
|
|
1691
|
+
const bucket = awsEncode(req.bucket);
|
|
1692
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?notification`, {
|
|
1693
|
+
bucket: req.bucket,
|
|
1694
|
+
body: req.body,
|
|
1695
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1696
|
+
}, signal);
|
|
1697
|
+
return bucketConfigResponse(res);
|
|
1698
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1699
|
+
// sig-ok: action namespace over dynamic S3 bucket notification path
|
|
1700
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?notification
|
|
1701
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketNotification.html
|
|
1702
|
+
const bucketsGetNotificationLegacy = Object.assign(async (req, signal) => {
|
|
1703
|
+
const bucket = awsEncode(req.bucket);
|
|
1704
|
+
const res = await makeSignedRequest("GET", `/${bucket}?notification`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1705
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1706
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1707
|
+
// sig-ok: action namespace over dynamic S3 bucket notification path
|
|
1708
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?notification
|
|
1709
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotification.html
|
|
1710
|
+
const bucketsPutNotificationLegacy = Object.assign(async (req, signal) => {
|
|
1711
|
+
const bucket = awsEncode(req.bucket);
|
|
1712
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?notification`, {
|
|
1713
|
+
bucket: req.bucket,
|
|
1714
|
+
body: req.body,
|
|
1715
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1716
|
+
}, signal);
|
|
1717
|
+
return bucketConfigResponse(res);
|
|
1718
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1719
|
+
// sig-ok: action namespace over dynamic S3 bucket replication path
|
|
1720
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?replication
|
|
1721
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketReplication.html
|
|
1722
|
+
const bucketsGetReplication = Object.assign(async (req, signal) => {
|
|
1723
|
+
const bucket = awsEncode(req.bucket);
|
|
1724
|
+
const res = await makeSignedRequest("GET", `/${bucket}?replication`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1725
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1726
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1727
|
+
// sig-ok: action namespace over dynamic S3 bucket replication path
|
|
1728
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?replication
|
|
1729
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketReplication.html
|
|
1730
|
+
const bucketsPutReplication = Object.assign(async (req, signal) => {
|
|
1731
|
+
const bucket = awsEncode(req.bucket);
|
|
1732
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?replication`, {
|
|
1733
|
+
bucket: req.bucket,
|
|
1734
|
+
body: req.body,
|
|
1735
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1736
|
+
}, signal);
|
|
1737
|
+
return bucketConfigResponse(res);
|
|
1738
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1739
|
+
// sig-ok: action namespace over dynamic S3 bucket replication path
|
|
1740
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?replication
|
|
1741
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketReplication.html
|
|
1742
|
+
const bucketsDelReplication = Object.assign(async (req, signal) => {
|
|
1743
|
+
const bucket = awsEncode(req.bucket);
|
|
1744
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?replication`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1745
|
+
return bucketConfigResponse(res);
|
|
1746
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1747
|
+
// sig-ok: action namespace over dynamic S3 bucket request payment path
|
|
1748
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?requestPayment
|
|
1749
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketRequestPayment.html
|
|
1750
|
+
const bucketsGetRequestPayment = Object.assign(async (req, signal) => {
|
|
1751
|
+
const bucket = awsEncode(req.bucket);
|
|
1752
|
+
const res = await makeSignedRequest("GET", `/${bucket}?requestPayment`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1753
|
+
return parseBucketRequestPayment(await res.text(), res.headers);
|
|
1754
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1755
|
+
// sig-ok: action namespace over dynamic S3 bucket request payment path
|
|
1756
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?requestPayment
|
|
1757
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketRequestPayment.html
|
|
1758
|
+
const bucketsPutRequestPayment = Object.assign(async (req, signal) => {
|
|
1759
|
+
const bucket = awsEncode(req.bucket);
|
|
1760
|
+
const body = createRequestPaymentBody(req);
|
|
1761
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?requestPayment`, {
|
|
1762
|
+
bucket: req.bucket,
|
|
1763
|
+
body,
|
|
1764
|
+
headers: bucketPutConfigHeaders(req, body, "application/xml"),
|
|
1765
|
+
}, signal);
|
|
1766
|
+
return bucketConfigResponse(res);
|
|
1767
|
+
}, { schema: S3PutBucketRequestPaymentRequestSchema });
|
|
1768
|
+
// sig-ok: action namespace over dynamic S3 bucket ABAC path
|
|
1769
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?abac
|
|
1770
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAbac.html
|
|
1771
|
+
const bucketsGetAbac = Object.assign(async (req, signal) => {
|
|
1772
|
+
const bucket = awsEncode(req.bucket);
|
|
1773
|
+
const res = await makeSignedRequest("GET", `/${bucket}?abac`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1774
|
+
return parseBucketAbac(await res.text(), res.headers);
|
|
1775
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1776
|
+
// sig-ok: action namespace over dynamic S3 bucket ABAC path
|
|
1777
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?abac
|
|
1778
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAbac.html
|
|
1779
|
+
const bucketsPutAbac = Object.assign(async (req, signal) => {
|
|
1780
|
+
const bucket = awsEncode(req.bucket);
|
|
1781
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?abac`, {
|
|
1782
|
+
bucket: req.bucket,
|
|
1783
|
+
body: req.body,
|
|
1784
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1785
|
+
}, signal);
|
|
1786
|
+
return bucketConfigResponse(res);
|
|
1787
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1788
|
+
// sig-ok: action namespace over dynamic S3 bucket accelerate path
|
|
1789
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?accelerate
|
|
1790
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAccelerateConfiguration.html
|
|
1791
|
+
const bucketsGetAccelerateConfiguration = Object.assign(async (req, signal) => {
|
|
1792
|
+
const bucket = awsEncode(req.bucket);
|
|
1793
|
+
const res = await makeSignedRequest("GET", `/${bucket}?accelerate`, { bucket: req.bucket, headers: bucketConfigWithPayerHeaders(req) }, signal);
|
|
1794
|
+
return parseBucketAccelerateConfiguration(await res.text(), res.headers);
|
|
1795
|
+
}, { schema: S3BucketConfigWithPayerRequestSchema });
|
|
1796
|
+
// sig-ok: action namespace over dynamic S3 bucket accelerate path
|
|
1797
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?accelerate
|
|
1798
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAccelerateConfiguration.html
|
|
1799
|
+
const bucketsPutAccelerateConfiguration = Object.assign(async (req, signal) => {
|
|
1800
|
+
const bucket = awsEncode(req.bucket);
|
|
1801
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?accelerate`, {
|
|
1802
|
+
bucket: req.bucket,
|
|
1803
|
+
body: req.body,
|
|
1804
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1805
|
+
}, signal);
|
|
1806
|
+
return bucketConfigResponse(res);
|
|
1807
|
+
}, { schema: S3PutBucketXmlConfigRequestSchema });
|
|
1808
|
+
// sig-ok: action namespace over dynamic S3 bucket ACL path
|
|
1809
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?acl
|
|
1810
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAcl.html
|
|
1811
|
+
const bucketsGetAcl = Object.assign(async (req, signal) => {
|
|
1812
|
+
const bucket = awsEncode(req.bucket);
|
|
1813
|
+
const res = await makeSignedRequest("GET", `/${bucket}?acl`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1814
|
+
return parseBucketAcl(await res.text(), res.headers);
|
|
1815
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1816
|
+
// sig-ok: action namespace over dynamic S3 bucket ACL path
|
|
1817
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?acl
|
|
1818
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAcl.html
|
|
1819
|
+
const bucketsPutAcl = Object.assign(async (req, signal) => {
|
|
1820
|
+
const bucket = awsEncode(req.bucket);
|
|
1821
|
+
const headers = bucketConfigHeaders(req);
|
|
1822
|
+
if (req.acl)
|
|
1823
|
+
headers["x-amz-acl"] = req.acl;
|
|
1824
|
+
if (req.grantFullControl) {
|
|
1825
|
+
headers["x-amz-grant-full-control"] = req.grantFullControl;
|
|
1826
|
+
}
|
|
1827
|
+
if (req.grantRead)
|
|
1828
|
+
headers["x-amz-grant-read"] = req.grantRead;
|
|
1829
|
+
if (req.grantReadAcp) {
|
|
1830
|
+
headers["x-amz-grant-read-acp"] = req.grantReadAcp;
|
|
1831
|
+
}
|
|
1832
|
+
if (req.grantWrite)
|
|
1833
|
+
headers["x-amz-grant-write"] = req.grantWrite;
|
|
1834
|
+
if (req.grantWriteAcp) {
|
|
1835
|
+
headers["x-amz-grant-write-acp"] = req.grantWriteAcp;
|
|
1836
|
+
}
|
|
1837
|
+
if (req.accessControlPolicy !== undefined) {
|
|
1838
|
+
headers["Content-MD5"] =
|
|
1839
|
+
req.contentMD5 ??
|
|
1840
|
+
md5Base64(new TextEncoder().encode(req.accessControlPolicy));
|
|
1841
|
+
headers["Content-Type"] = "application/xml";
|
|
1842
|
+
}
|
|
1843
|
+
else if (req.contentMD5) {
|
|
1844
|
+
headers["Content-MD5"] = req.contentMD5;
|
|
1845
|
+
}
|
|
1846
|
+
if (req.checksumAlgorithm) {
|
|
1847
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
1848
|
+
}
|
|
1849
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?acl`, {
|
|
1850
|
+
bucket: req.bucket,
|
|
1851
|
+
body: req.accessControlPolicy,
|
|
1852
|
+
headers,
|
|
1853
|
+
}, signal);
|
|
1854
|
+
return bucketConfigResponse(res);
|
|
1855
|
+
}, { schema: S3PutBucketAclRequestSchema });
|
|
1856
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata path
|
|
1857
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}?metadataConfiguration
|
|
1858
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucketMetadataConfiguration.html
|
|
1859
|
+
const bucketsCreateMetadataConfiguration = Object.assign(async (req, signal) => {
|
|
1860
|
+
const bucket = awsEncode(req.bucket);
|
|
1861
|
+
const res = await makeSignedRequest("POST", `/${bucket}?metadataConfiguration`, {
|
|
1862
|
+
bucket: req.bucket,
|
|
1863
|
+
body: req.body,
|
|
1864
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1865
|
+
}, signal);
|
|
1866
|
+
return bucketConfigResponse(res);
|
|
1867
|
+
}, { schema: S3PutBucketMetadataConfigurationRequestSchema });
|
|
1868
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata path
|
|
1869
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?metadataConfiguration
|
|
1870
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetadataConfiguration.html
|
|
1871
|
+
const bucketsGetMetadataConfiguration = Object.assign(async (req, signal) => {
|
|
1872
|
+
const bucket = awsEncode(req.bucket);
|
|
1873
|
+
const res = await makeSignedRequest("GET", `/${bucket}?metadataConfiguration`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1874
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1875
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1876
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata path
|
|
1877
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?metadataConfiguration
|
|
1878
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetadataConfiguration.html
|
|
1879
|
+
const bucketsDelMetadataConfiguration = Object.assign(async (req, signal) => {
|
|
1880
|
+
const bucket = awsEncode(req.bucket);
|
|
1881
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?metadataConfiguration`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1882
|
+
return bucketConfigResponse(res);
|
|
1883
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1884
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata table path
|
|
1885
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}?metadataTable
|
|
1886
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucketMetadataTableConfiguration.html
|
|
1887
|
+
const bucketsCreateMetadataTableConfiguration = Object.assign(async (req, signal) => {
|
|
1888
|
+
const bucket = awsEncode(req.bucket);
|
|
1889
|
+
const res = await makeSignedRequest("POST", `/${bucket}?metadataTable`, {
|
|
1890
|
+
bucket: req.bucket,
|
|
1891
|
+
body: req.body,
|
|
1892
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1893
|
+
}, signal);
|
|
1894
|
+
return bucketConfigResponse(res);
|
|
1895
|
+
}, { schema: S3PutBucketMetadataConfigurationRequestSchema });
|
|
1896
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata table path
|
|
1897
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?metadataTable
|
|
1898
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetadataTableConfiguration.html
|
|
1899
|
+
const bucketsGetMetadataTableConfiguration = Object.assign(async (req, signal) => {
|
|
1900
|
+
const bucket = awsEncode(req.bucket);
|
|
1901
|
+
const res = await makeSignedRequest("GET", `/${bucket}?metadataTable`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1902
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1903
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1904
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata table path
|
|
1905
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?metadataTable
|
|
1906
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetadataTableConfiguration.html
|
|
1907
|
+
const bucketsDelMetadataTableConfiguration = Object.assign(async (req, signal) => {
|
|
1908
|
+
const bucket = awsEncode(req.bucket);
|
|
1909
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?metadataTable`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1910
|
+
return bucketConfigResponse(res);
|
|
1911
|
+
}, { schema: S3BucketConfigRequestSchema });
|
|
1912
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata inventory path
|
|
1913
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?metadataInventoryTable
|
|
1914
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UpdateBucketMetadataInventoryTableConfiguration.html
|
|
1915
|
+
const bucketsUpdateMetadataInventoryTable = Object.assign(async (req, signal) => {
|
|
1916
|
+
const bucket = awsEncode(req.bucket);
|
|
1917
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?metadataInventoryTable`, {
|
|
1918
|
+
bucket: req.bucket,
|
|
1919
|
+
body: req.body,
|
|
1920
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1921
|
+
}, signal);
|
|
1922
|
+
return bucketConfigResponse(res);
|
|
1923
|
+
}, { schema: S3PutBucketMetadataConfigurationRequestSchema });
|
|
1924
|
+
// sig-ok: action namespace over dynamic S3 bucket metadata journal path
|
|
1925
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?metadataJournalTable
|
|
1926
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UpdateBucketMetadataJournalTableConfiguration.html
|
|
1927
|
+
const bucketsUpdateMetadataJournalTable = Object.assign(async (req, signal) => {
|
|
1928
|
+
const bucket = awsEncode(req.bucket);
|
|
1929
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?metadataJournalTable`, {
|
|
1930
|
+
bucket: req.bucket,
|
|
1931
|
+
body: req.body,
|
|
1932
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1933
|
+
}, signal);
|
|
1934
|
+
return bucketConfigResponse(res);
|
|
1935
|
+
}, { schema: S3PutBucketMetadataConfigurationRequestSchema });
|
|
1936
|
+
// sig-ok: action namespace over dynamic S3 bucket intelligent-tiering path
|
|
1937
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?intelligent-tiering{query}
|
|
1938
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketIntelligentTieringConfigurations.html
|
|
1939
|
+
const bucketsListIntelligentTiering = Object.assign(async (req, signal) => {
|
|
1940
|
+
const bucket = awsEncode(req.bucket);
|
|
1941
|
+
const query = buildQuery({ "continuation-token": req.continuationToken }, "&");
|
|
1942
|
+
const res = await makeSignedRequest("GET", `/${bucket}?intelligent-tiering${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1943
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1944
|
+
}, { schema: S3ListBucketConfigsRequestSchema });
|
|
1945
|
+
// sig-ok: action namespace over dynamic S3 bucket intelligent-tiering path
|
|
1946
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?intelligent-tiering{query}
|
|
1947
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketIntelligentTieringConfiguration.html
|
|
1948
|
+
const bucketsGetIntelligentTiering = Object.assign(async (req, signal) => {
|
|
1949
|
+
const bucket = awsEncode(req.bucket);
|
|
1950
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
1951
|
+
const res = await makeSignedRequest("GET", `/${bucket}?intelligent-tiering${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1952
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1953
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
1954
|
+
// sig-ok: action namespace over dynamic S3 bucket intelligent-tiering path
|
|
1955
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?intelligent-tiering{query}
|
|
1956
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketIntelligentTieringConfiguration.html
|
|
1957
|
+
const bucketsPutIntelligentTiering = Object.assign(async (req, signal) => {
|
|
1958
|
+
const bucket = awsEncode(req.bucket);
|
|
1959
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
1960
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?intelligent-tiering${query}`, {
|
|
1961
|
+
bucket: req.bucket,
|
|
1962
|
+
body: req.body,
|
|
1963
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
1964
|
+
}, signal);
|
|
1965
|
+
return bucketConfigResponse(res);
|
|
1966
|
+
}, { schema: S3PutBucketXmlConfigWithIdRequestSchema });
|
|
1967
|
+
// sig-ok: action namespace over dynamic S3 bucket intelligent-tiering path
|
|
1968
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?intelligent-tiering{query}
|
|
1969
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketIntelligentTieringConfiguration.html
|
|
1970
|
+
const bucketsDelIntelligentTiering = Object.assign(async (req, signal) => {
|
|
1971
|
+
const bucket = awsEncode(req.bucket);
|
|
1972
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
1973
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?intelligent-tiering${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1974
|
+
return bucketConfigResponse(res);
|
|
1975
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
1976
|
+
// sig-ok: action namespace over dynamic S3 bucket metrics path
|
|
1977
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?metrics{query}
|
|
1978
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html
|
|
1979
|
+
const bucketsListMetrics = Object.assign(async (req, signal) => {
|
|
1980
|
+
const bucket = awsEncode(req.bucket);
|
|
1981
|
+
const query = buildQuery({ "continuation-token": req.continuationToken }, "&");
|
|
1982
|
+
const res = await makeSignedRequest("GET", `/${bucket}?metrics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1983
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1984
|
+
}, { schema: S3ListBucketConfigsRequestSchema });
|
|
1985
|
+
// sig-ok: action namespace over dynamic S3 bucket metrics path
|
|
1986
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?metrics{query}
|
|
1987
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html
|
|
1988
|
+
const bucketsGetMetrics = Object.assign(async (req, signal) => {
|
|
1989
|
+
const bucket = awsEncode(req.bucket);
|
|
1990
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
1991
|
+
const res = await makeSignedRequest("GET", `/${bucket}?metrics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
1992
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
1993
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
1994
|
+
// sig-ok: action namespace over dynamic S3 bucket metrics path
|
|
1995
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?metrics{query}
|
|
1996
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html
|
|
1997
|
+
const bucketsPutMetrics = Object.assign(async (req, signal) => {
|
|
1998
|
+
const bucket = awsEncode(req.bucket);
|
|
1999
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2000
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?metrics${query}`, {
|
|
2001
|
+
bucket: req.bucket,
|
|
2002
|
+
body: req.body,
|
|
2003
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
2004
|
+
}, signal);
|
|
2005
|
+
return bucketConfigResponse(res);
|
|
2006
|
+
}, { schema: S3PutBucketXmlConfigWithIdRequestSchema });
|
|
2007
|
+
// sig-ok: action namespace over dynamic S3 bucket metrics path
|
|
2008
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?metrics{query}
|
|
2009
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetricsConfiguration.html
|
|
2010
|
+
const bucketsDelMetrics = Object.assign(async (req, signal) => {
|
|
2011
|
+
const bucket = awsEncode(req.bucket);
|
|
2012
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2013
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?metrics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2014
|
+
return bucketConfigResponse(res);
|
|
2015
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
2016
|
+
// sig-ok: action namespace over dynamic S3 bucket inventory path
|
|
2017
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?inventory{query}
|
|
2018
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html
|
|
2019
|
+
const bucketsListInventory = Object.assign(async (req, signal) => {
|
|
2020
|
+
const bucket = awsEncode(req.bucket);
|
|
2021
|
+
const query = buildQuery({ "continuation-token": req.continuationToken }, "&");
|
|
2022
|
+
const res = await makeSignedRequest("GET", `/${bucket}?inventory${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2023
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
2024
|
+
}, { schema: S3ListBucketConfigsRequestSchema });
|
|
2025
|
+
// sig-ok: action namespace over dynamic S3 bucket inventory path
|
|
2026
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?inventory{query}
|
|
2027
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html
|
|
2028
|
+
const bucketsGetInventory = Object.assign(async (req, signal) => {
|
|
2029
|
+
const bucket = awsEncode(req.bucket);
|
|
2030
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2031
|
+
const res = await makeSignedRequest("GET", `/${bucket}?inventory${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2032
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
2033
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
2034
|
+
// sig-ok: action namespace over dynamic S3 bucket inventory path
|
|
2035
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?inventory{query}
|
|
2036
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html
|
|
2037
|
+
const bucketsPutInventory = Object.assign(async (req, signal) => {
|
|
2038
|
+
const bucket = awsEncode(req.bucket);
|
|
2039
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2040
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?inventory${query}`, {
|
|
2041
|
+
bucket: req.bucket,
|
|
2042
|
+
body: req.body,
|
|
2043
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
2044
|
+
}, signal);
|
|
2045
|
+
return bucketConfigResponse(res);
|
|
2046
|
+
}, { schema: S3PutBucketXmlConfigWithIdRequestSchema });
|
|
2047
|
+
// sig-ok: action namespace over dynamic S3 bucket inventory path
|
|
2048
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?inventory{query}
|
|
2049
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html
|
|
2050
|
+
const bucketsDelInventory = Object.assign(async (req, signal) => {
|
|
2051
|
+
const bucket = awsEncode(req.bucket);
|
|
2052
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2053
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?inventory${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2054
|
+
return bucketConfigResponse(res);
|
|
2055
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
2056
|
+
// sig-ok: action namespace over dynamic S3 bucket analytics path
|
|
2057
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?analytics{query}
|
|
2058
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketAnalyticsConfigurations.html
|
|
2059
|
+
const bucketsListAnalytics = Object.assign(async (req, signal) => {
|
|
2060
|
+
const bucket = awsEncode(req.bucket);
|
|
2061
|
+
const query = buildQuery({ "continuation-token": req.continuationToken }, "&");
|
|
2062
|
+
const res = await makeSignedRequest("GET", `/${bucket}?analytics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2063
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
2064
|
+
}, { schema: S3ListBucketConfigsRequestSchema });
|
|
2065
|
+
// sig-ok: action namespace over dynamic S3 bucket analytics path
|
|
2066
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?analytics{query}
|
|
2067
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAnalyticsConfiguration.html
|
|
2068
|
+
const bucketsGetAnalytics = Object.assign(async (req, signal) => {
|
|
2069
|
+
const bucket = awsEncode(req.bucket);
|
|
2070
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2071
|
+
const res = await makeSignedRequest("GET", `/${bucket}?analytics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2072
|
+
return bucketXmlConfigResponse(await res.text(), res.headers);
|
|
2073
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
2074
|
+
// sig-ok: action namespace over dynamic S3 bucket analytics path
|
|
2075
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}?analytics{query}
|
|
2076
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAnalyticsConfiguration.html
|
|
2077
|
+
const bucketsPutAnalytics = Object.assign(async (req, signal) => {
|
|
2078
|
+
const bucket = awsEncode(req.bucket);
|
|
2079
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2080
|
+
const res = await makeSignedRequest("PUT", `/${bucket}?analytics${query}`, {
|
|
2081
|
+
bucket: req.bucket,
|
|
2082
|
+
body: req.body,
|
|
2083
|
+
headers: bucketPutConfigHeaders(req, req.body, "application/xml"),
|
|
2084
|
+
}, signal);
|
|
2085
|
+
return bucketConfigResponse(res);
|
|
2086
|
+
}, { schema: S3PutBucketXmlConfigWithIdRequestSchema });
|
|
2087
|
+
// sig-ok: action namespace over dynamic S3 bucket analytics path
|
|
2088
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}?analytics{query}
|
|
2089
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketAnalyticsConfiguration.html
|
|
2090
|
+
const bucketsDelAnalytics = Object.assign(async (req, signal) => {
|
|
2091
|
+
const bucket = awsEncode(req.bucket);
|
|
2092
|
+
const query = buildQuery({ id: req.id }, "&");
|
|
2093
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}?analytics${query}`, { bucket: req.bucket, headers: bucketConfigHeaders(req) }, signal);
|
|
2094
|
+
return bucketConfigResponse(res);
|
|
2095
|
+
}, { schema: S3BucketConfigWithIdRequestSchema });
|
|
2096
|
+
// sig-ok: action namespace over dynamic S3 bucket path
|
|
2097
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}{query}
|
|
2098
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html
|
|
2099
|
+
const objectsListLegacy = Object.assign(async (req, signal) => {
|
|
2100
|
+
const bucket = awsEncode(req.bucket);
|
|
2101
|
+
const query = buildQuery({
|
|
2102
|
+
delimiter: req.delimiter,
|
|
2103
|
+
"encoding-type": req.encodingType,
|
|
2104
|
+
marker: req.marker,
|
|
2105
|
+
"max-keys": req.maxKeys,
|
|
2106
|
+
prefix: req.prefix,
|
|
2107
|
+
});
|
|
2108
|
+
const headers = {};
|
|
2109
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2110
|
+
if (req.optionalObjectAttributes?.length) {
|
|
2111
|
+
headers["x-amz-optional-object-attributes"] =
|
|
2112
|
+
req.optionalObjectAttributes.join(",");
|
|
2113
|
+
}
|
|
2114
|
+
const res = await makeSignedRequest("GET", `/${bucket}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2115
|
+
return parseListObjects(await res.text(), res.headers);
|
|
2116
|
+
}, { schema: S3ListObjectsRequestSchema });
|
|
2117
|
+
// sig-ok: action namespace over dynamic S3 bucket path
|
|
2118
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?list-type=2{query}
|
|
2119
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
|
2120
|
+
const objectsList = Object.assign(async (req, signal) => {
|
|
2121
|
+
const bucket = awsEncode(req.bucket);
|
|
2122
|
+
const query = buildQuery({
|
|
2123
|
+
prefix: req.prefix,
|
|
2124
|
+
delimiter: req.delimiter,
|
|
2125
|
+
"continuation-token": req.continuationToken,
|
|
2126
|
+
"max-keys": req.maxKeys,
|
|
2127
|
+
"start-after": req.startAfter,
|
|
2128
|
+
"encoding-type": req.encodingType,
|
|
2129
|
+
"fetch-owner": req.fetchOwner,
|
|
2130
|
+
}, "&");
|
|
2131
|
+
const res = await makeSignedRequest("GET", `/${bucket}?list-type=2${query}`, { bucket: req.bucket }, signal);
|
|
2132
|
+
return parseListObjectsV2(await res.text());
|
|
2133
|
+
}, { schema: S3ListObjectsV2RequestSchema });
|
|
2134
|
+
// sig-ok: action namespace over dynamic S3 bucket versions path
|
|
2135
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?versions{query}
|
|
2136
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html
|
|
2137
|
+
const objectsListVersions = Object.assign(async (req, signal) => {
|
|
2138
|
+
const bucket = awsEncode(req.bucket);
|
|
2139
|
+
const query = buildQuery({
|
|
2140
|
+
delimiter: req.delimiter,
|
|
2141
|
+
"encoding-type": req.encodingType,
|
|
2142
|
+
"key-marker": req.keyMarker,
|
|
2143
|
+
"max-keys": req.maxKeys,
|
|
2144
|
+
prefix: req.prefix,
|
|
2145
|
+
"version-id-marker": req.versionIdMarker,
|
|
2146
|
+
}, "&");
|
|
2147
|
+
const headers = {};
|
|
2148
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2149
|
+
const res = await makeSignedRequest("GET", `/${bucket}?versions${query}`, { bucket: req.bucket, headers }, signal);
|
|
2150
|
+
return parseListObjectVersions(await res.text(), res.headers);
|
|
2151
|
+
}, { schema: S3ListObjectVersionsRequestSchema });
|
|
2152
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2153
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}
|
|
2154
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
|
2155
|
+
const objectsPut = Object.assign(async (req, signal) => {
|
|
2156
|
+
const bucket = awsEncode(req.bucket);
|
|
2157
|
+
const key = encodeS3Key(req.key);
|
|
2158
|
+
const headers = {};
|
|
2159
|
+
const bodyType = req.body instanceof Blob ? req.body.type : undefined;
|
|
2160
|
+
const contentType = req.contentType ?? bodyType;
|
|
2161
|
+
addObjectContentHeaders(headers, { ...req, contentType });
|
|
2162
|
+
if (req.storageClass)
|
|
2163
|
+
headers["x-amz-storage-class"] = req.storageClass;
|
|
2164
|
+
addMetadataHeaders(headers, req.metadata);
|
|
2165
|
+
addChecksumRequestHeaders(headers, req);
|
|
2166
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}`, { bucket: req.bucket, body: req.body, headers }, signal);
|
|
2167
|
+
return {
|
|
2168
|
+
eTag: getHeader(res.headers, "etag"),
|
|
2169
|
+
versionId: getHeader(res.headers, "x-amz-version-id"),
|
|
2170
|
+
serverSideEncryption: getHeader(res.headers, "x-amz-server-side-encryption"),
|
|
2171
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
2172
|
+
};
|
|
2173
|
+
}, { schema: S3PutObjectRequestSchema });
|
|
2174
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2175
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}
|
|
2176
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html
|
|
2177
|
+
const objectsCopy = Object.assign(async (req, signal) => {
|
|
2178
|
+
const bucket = awsEncode(req.bucket);
|
|
2179
|
+
const key = encodeS3Key(req.key);
|
|
2180
|
+
const headers = {
|
|
2181
|
+
"x-amz-copy-source": encodeCopySource(req.sourceBucket, req.sourceKey, req.sourceVersionId),
|
|
2182
|
+
};
|
|
2183
|
+
addObjectContentHeaders(headers, req);
|
|
2184
|
+
const hasReplacementMetadata = req.contentType !== undefined ||
|
|
2185
|
+
req.cacheControl !== undefined ||
|
|
2186
|
+
req.contentDisposition !== undefined ||
|
|
2187
|
+
req.contentEncoding !== undefined ||
|
|
2188
|
+
req.contentLanguage !== undefined ||
|
|
2189
|
+
Object.keys(req.metadata ?? {}).length > 0;
|
|
2190
|
+
const metadataDirective = req.metadataDirective ??
|
|
2191
|
+
(hasReplacementMetadata ? "REPLACE" : undefined);
|
|
2192
|
+
if (metadataDirective) {
|
|
2193
|
+
headers["x-amz-metadata-directive"] = metadataDirective;
|
|
2194
|
+
}
|
|
2195
|
+
if (req.taggingDirective) {
|
|
2196
|
+
headers["x-amz-tagging-directive"] = req.taggingDirective;
|
|
2197
|
+
}
|
|
2198
|
+
if (req.storageClass)
|
|
2199
|
+
headers["x-amz-storage-class"] = req.storageClass;
|
|
2200
|
+
if (req.expectedBucketOwner) {
|
|
2201
|
+
headers["x-amz-expected-bucket-owner"] = req.expectedBucketOwner;
|
|
2202
|
+
}
|
|
2203
|
+
if (req.sourceExpectedBucketOwner) {
|
|
2204
|
+
headers["x-amz-source-expected-bucket-owner"] =
|
|
2205
|
+
req.sourceExpectedBucketOwner;
|
|
2206
|
+
}
|
|
2207
|
+
addMetadataHeaders(headers, req.metadata);
|
|
2208
|
+
if (req.checksumAlgorithm) {
|
|
2209
|
+
headers["x-amz-checksum-algorithm"] = req.checksumAlgorithm;
|
|
2210
|
+
}
|
|
2211
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}`, { bucket: req.bucket, headers }, signal);
|
|
2212
|
+
return parseCopyObject(await res.text(), res.headers);
|
|
2213
|
+
}, { schema: S3CopyObjectRequestSchema });
|
|
2214
|
+
// sig-ok: action namespace over dynamic S3 Express object rename path
|
|
2215
|
+
// PUT https://s3express-{param}.{param}.amazonaws.com/{bucket}/{key}?renameObject
|
|
2216
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_RenameObject.html
|
|
2217
|
+
const objectsRename = Object.assign(async (req, signal) => {
|
|
2218
|
+
if (!opts.endpoint) {
|
|
2219
|
+
s3ExpressZonalBase(req.bucket, opts.region, opts.endpoint);
|
|
2220
|
+
}
|
|
2221
|
+
const bucket = awsEncode(req.bucket);
|
|
2222
|
+
const key = encodeS3Key(req.key);
|
|
2223
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?renameObject`, {
|
|
2224
|
+
bucket: req.bucket,
|
|
2225
|
+
baseOverride: opts.endpoint ??
|
|
2226
|
+
`https://s3express-${directoryBucketZoneId(req.bucket)}.${opts.region}.amazonaws.com`,
|
|
2227
|
+
headers: renameObjectHeaders(req),
|
|
2228
|
+
signingService: "s3express",
|
|
2229
|
+
}, signal);
|
|
2230
|
+
return objectConfigResponse(res);
|
|
2231
|
+
}, { schema: S3RenameObjectRequestSchema });
|
|
2232
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2233
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2234
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
|
2235
|
+
const objectsGet = Object.assign(async (req, signal) => {
|
|
2236
|
+
const bucket = awsEncode(req.bucket);
|
|
2237
|
+
const key = encodeS3Key(req.key);
|
|
2238
|
+
const headers = {};
|
|
2239
|
+
if (req.range)
|
|
2240
|
+
headers.Range = req.range;
|
|
2241
|
+
const query = queryForVersion(req.versionId);
|
|
2242
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2243
|
+
return {
|
|
2244
|
+
...objectHeaders(res),
|
|
2245
|
+
body: await res.arrayBuffer(),
|
|
2246
|
+
};
|
|
2247
|
+
}, { schema: S3GetObjectRequestSchema });
|
|
2248
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2249
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2250
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
|
2251
|
+
const objectsGetStream = Object.assign(async (req, signal) => {
|
|
2252
|
+
const bucket = awsEncode(req.bucket);
|
|
2253
|
+
const key = encodeS3Key(req.key);
|
|
2254
|
+
const headers = {};
|
|
2255
|
+
if (req.range)
|
|
2256
|
+
headers.Range = req.range;
|
|
2257
|
+
const query = queryForVersion(req.versionId);
|
|
2258
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2259
|
+
return {
|
|
2260
|
+
...objectHeaders(res),
|
|
2261
|
+
body: res.body,
|
|
2262
|
+
};
|
|
2263
|
+
}, { schema: S3GetObjectRequestSchema });
|
|
2264
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2265
|
+
// HEAD https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2266
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html
|
|
2267
|
+
const objectsHead = Object.assign(async (req, signal) => {
|
|
2268
|
+
const bucket = awsEncode(req.bucket);
|
|
2269
|
+
const key = encodeS3Key(req.key);
|
|
2270
|
+
const headers = {};
|
|
2271
|
+
if (req.range)
|
|
2272
|
+
headers.Range = req.range;
|
|
2273
|
+
const query = queryForVersion(req.versionId);
|
|
2274
|
+
const res = await makeSignedRequest("HEAD", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2275
|
+
return objectHeaders(res);
|
|
2276
|
+
}, { schema: S3HeadObjectRequestSchema });
|
|
2277
|
+
// sig-ok: action namespace over dynamic S3 object path
|
|
2278
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2279
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
|
2280
|
+
const objectsDel = Object.assign(async (req, signal) => {
|
|
2281
|
+
const bucket = awsEncode(req.bucket);
|
|
2282
|
+
const key = encodeS3Key(req.key);
|
|
2283
|
+
const query = queryForVersion(req.versionId);
|
|
2284
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}/${key}${query}`, { bucket: req.bucket }, signal);
|
|
2285
|
+
return {
|
|
2286
|
+
deleteMarker: booleanHeader(res.headers, "x-amz-delete-marker"),
|
|
2287
|
+
versionId: getHeader(res.headers, "x-amz-version-id"),
|
|
2288
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
2289
|
+
};
|
|
2290
|
+
}, { schema: S3DeleteObjectRequestSchema });
|
|
2291
|
+
// sig-ok: action namespace over dynamic S3 bucket delete path
|
|
2292
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}?delete
|
|
2293
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
|
2294
|
+
const objectsDelMany = Object.assign(async (req, signal) => {
|
|
2295
|
+
const bucket = awsEncode(req.bucket);
|
|
2296
|
+
const body = createDeleteObjectsBody(req);
|
|
2297
|
+
const bodyBytes = new TextEncoder().encode(body);
|
|
2298
|
+
const headers = {
|
|
2299
|
+
"Content-MD5": req.contentMD5 ?? md5Base64(bodyBytes),
|
|
2300
|
+
"Content-Type": "application/xml",
|
|
2301
|
+
};
|
|
2302
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2303
|
+
if (req.bypassGovernanceRetention !== undefined) {
|
|
2304
|
+
headers["x-amz-bypass-governance-retention"] = String(req.bypassGovernanceRetention);
|
|
2305
|
+
}
|
|
2306
|
+
if (req.checksumAlgorithm) {
|
|
2307
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
2308
|
+
}
|
|
2309
|
+
if (req.mfa)
|
|
2310
|
+
headers["x-amz-mfa"] = req.mfa;
|
|
2311
|
+
const res = await makeSignedRequest("POST", `/${bucket}?delete`, { bucket: req.bucket, body: bodyBytes, headers }, signal);
|
|
2312
|
+
return parseDeleteObjects(await res.text(), res.headers);
|
|
2313
|
+
}, { schema: S3DeleteObjectsRequestSchema });
|
|
2314
|
+
// sig-ok: action namespace over dynamic S3 object tagging path
|
|
2315
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?tagging{query}
|
|
2316
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html
|
|
2317
|
+
const objectsGetTagging = Object.assign(async (req, signal) => {
|
|
2318
|
+
const bucket = awsEncode(req.bucket);
|
|
2319
|
+
const key = encodeS3Key(req.key);
|
|
2320
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2321
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?tagging${query}`, {
|
|
2322
|
+
bucket: req.bucket,
|
|
2323
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
2324
|
+
}, signal);
|
|
2325
|
+
return parseObjectTagging(await res.text(), res.headers);
|
|
2326
|
+
}, { schema: S3ObjectTaggingRequestSchema });
|
|
2327
|
+
// sig-ok: action namespace over dynamic S3 object tagging path
|
|
2328
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}?tagging{query}
|
|
2329
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html
|
|
2330
|
+
const objectsPutTagging = Object.assign(async (req, signal) => {
|
|
2331
|
+
const bucket = awsEncode(req.bucket);
|
|
2332
|
+
const key = encodeS3Key(req.key);
|
|
2333
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2334
|
+
const body = createTaggingBody(req.tagSet);
|
|
2335
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?tagging${query}`, {
|
|
2336
|
+
bucket: req.bucket,
|
|
2337
|
+
body,
|
|
2338
|
+
headers: {
|
|
2339
|
+
"Content-Type": "application/xml",
|
|
2340
|
+
...bucketRequestHeaders(req.expectedBucketOwner),
|
|
2341
|
+
},
|
|
2342
|
+
}, signal);
|
|
2343
|
+
return {
|
|
2344
|
+
versionId: getHeader(res.headers, "x-amz-version-id"),
|
|
2345
|
+
};
|
|
2346
|
+
}, { schema: S3PutObjectTaggingRequestSchema });
|
|
2347
|
+
// sig-ok: action namespace over dynamic S3 object tagging path
|
|
2348
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}/{key}?tagging{query}
|
|
2349
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjectTagging.html
|
|
2350
|
+
const objectsDelTagging = Object.assign(async (req, signal) => {
|
|
2351
|
+
const bucket = awsEncode(req.bucket);
|
|
2352
|
+
const key = encodeS3Key(req.key);
|
|
2353
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2354
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}/${key}?tagging${query}`, {
|
|
2355
|
+
bucket: req.bucket,
|
|
2356
|
+
headers: bucketRequestHeaders(req.expectedBucketOwner),
|
|
2357
|
+
}, signal);
|
|
2358
|
+
return {
|
|
2359
|
+
versionId: getHeader(res.headers, "x-amz-version-id"),
|
|
2360
|
+
};
|
|
2361
|
+
}, { schema: S3ObjectTaggingRequestSchema });
|
|
2362
|
+
// sig-ok: action namespace over dynamic S3 object ACL path
|
|
2363
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?acl{query}
|
|
2364
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAcl.html
|
|
2365
|
+
const objectsGetAcl = Object.assign(async (req, signal) => {
|
|
2366
|
+
const bucket = awsEncode(req.bucket);
|
|
2367
|
+
const key = encodeS3Key(req.key);
|
|
2368
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2369
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?acl${query}`, { bucket: req.bucket, headers: objectGovernanceHeaders(req) }, signal);
|
|
2370
|
+
return parseObjectAcl(await res.text(), res.headers);
|
|
2371
|
+
}, { schema: S3ObjectGovernanceRequestSchema });
|
|
2372
|
+
// sig-ok: action namespace over dynamic S3 object ACL path
|
|
2373
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}?acl{query}
|
|
2374
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectAcl.html
|
|
2375
|
+
const objectsPutAcl = Object.assign(async (req, signal) => {
|
|
2376
|
+
const bucket = awsEncode(req.bucket);
|
|
2377
|
+
const key = encodeS3Key(req.key);
|
|
2378
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2379
|
+
const headers = objectGovernanceHeaders(req);
|
|
2380
|
+
if (req.acl)
|
|
2381
|
+
headers["x-amz-acl"] = req.acl;
|
|
2382
|
+
if (req.grantFullControl) {
|
|
2383
|
+
headers["x-amz-grant-full-control"] = req.grantFullControl;
|
|
2384
|
+
}
|
|
2385
|
+
if (req.grantRead)
|
|
2386
|
+
headers["x-amz-grant-read"] = req.grantRead;
|
|
2387
|
+
if (req.grantReadAcp) {
|
|
2388
|
+
headers["x-amz-grant-read-acp"] = req.grantReadAcp;
|
|
2389
|
+
}
|
|
2390
|
+
if (req.grantWriteAcp) {
|
|
2391
|
+
headers["x-amz-grant-write-acp"] = req.grantWriteAcp;
|
|
2392
|
+
}
|
|
2393
|
+
if (req.accessControlPolicy !== undefined) {
|
|
2394
|
+
headers["Content-MD5"] =
|
|
2395
|
+
req.contentMD5 ??
|
|
2396
|
+
md5Base64(new TextEncoder().encode(req.accessControlPolicy));
|
|
2397
|
+
headers["Content-Type"] = "application/xml";
|
|
2398
|
+
}
|
|
2399
|
+
else if (req.contentMD5) {
|
|
2400
|
+
headers["Content-MD5"] = req.contentMD5;
|
|
2401
|
+
}
|
|
2402
|
+
if (req.checksumAlgorithm) {
|
|
2403
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
2404
|
+
}
|
|
2405
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?acl${query}`, {
|
|
2406
|
+
bucket: req.bucket,
|
|
2407
|
+
body: req.accessControlPolicy,
|
|
2408
|
+
headers,
|
|
2409
|
+
}, signal);
|
|
2410
|
+
return objectConfigResponse(res);
|
|
2411
|
+
}, { schema: S3PutObjectAclRequestSchema });
|
|
2412
|
+
// sig-ok: action namespace over dynamic S3 object attributes path
|
|
2413
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?attributes{query}
|
|
2414
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html
|
|
2415
|
+
const objectsGetAttributes = Object.assign(async (req, signal) => {
|
|
2416
|
+
const bucket = awsEncode(req.bucket);
|
|
2417
|
+
const key = encodeS3Key(req.key);
|
|
2418
|
+
const query = buildQuery({
|
|
2419
|
+
versionId: req.versionId,
|
|
2420
|
+
"max-parts": req.maxParts,
|
|
2421
|
+
"part-number-marker": req.partNumberMarker,
|
|
2422
|
+
}, "&");
|
|
2423
|
+
const headers = objectGovernanceHeaders(req);
|
|
2424
|
+
headers["x-amz-object-attributes"] = req.objectAttributes.join(",");
|
|
2425
|
+
addSseCustomerHeaders(headers, req);
|
|
2426
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?attributes${query}`, { bucket: req.bucket, headers }, signal);
|
|
2427
|
+
return parseObjectAttributes(await res.text(), res.headers);
|
|
2428
|
+
}, { schema: S3GetObjectAttributesRequestSchema });
|
|
2429
|
+
// sig-ok: action namespace over dynamic S3 object restore path
|
|
2430
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}/{key}?restore{query}
|
|
2431
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html
|
|
2432
|
+
const objectsRestore = Object.assign(async (req, signal) => {
|
|
2433
|
+
const bucket = awsEncode(req.bucket);
|
|
2434
|
+
const key = encodeS3Key(req.key);
|
|
2435
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2436
|
+
const headers = objectGovernanceHeaders(req);
|
|
2437
|
+
if (req.body !== undefined) {
|
|
2438
|
+
headers["Content-MD5"] =
|
|
2439
|
+
req.contentMD5 ?? md5Base64(new TextEncoder().encode(req.body));
|
|
2440
|
+
headers["Content-Type"] = "application/xml";
|
|
2441
|
+
}
|
|
2442
|
+
else if (req.contentMD5) {
|
|
2443
|
+
headers["Content-MD5"] = req.contentMD5;
|
|
2444
|
+
}
|
|
2445
|
+
if (req.checksumAlgorithm) {
|
|
2446
|
+
headers["x-amz-sdk-checksum-algorithm"] = req.checksumAlgorithm;
|
|
2447
|
+
}
|
|
2448
|
+
const res = await makeSignedRequest("POST", `/${bucket}/${key}?restore${query}`, { bucket: req.bucket, body: req.body, headers }, signal);
|
|
2449
|
+
return objectConfigResponse(res);
|
|
2450
|
+
}, { schema: S3RestoreObjectRequestSchema });
|
|
2451
|
+
// sig-ok: action namespace over dynamic S3 object legal hold path
|
|
2452
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?legal-hold{query}
|
|
2453
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLegalHold.html
|
|
2454
|
+
const objectsGetLegalHold = Object.assign(async (req, signal) => {
|
|
2455
|
+
const bucket = awsEncode(req.bucket);
|
|
2456
|
+
const key = encodeS3Key(req.key);
|
|
2457
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2458
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?legal-hold${query}`, { bucket: req.bucket, headers: objectGovernanceHeaders(req) }, signal);
|
|
2459
|
+
return parseObjectLegalHold(await res.text(), res.headers);
|
|
2460
|
+
}, { schema: S3ObjectGovernanceRequestSchema });
|
|
2461
|
+
// sig-ok: action namespace over dynamic S3 object legal hold path
|
|
2462
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}?legal-hold{query}
|
|
2463
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLegalHold.html
|
|
2464
|
+
const objectsPutLegalHold = Object.assign(async (req, signal) => {
|
|
2465
|
+
const bucket = awsEncode(req.bucket);
|
|
2466
|
+
const key = encodeS3Key(req.key);
|
|
2467
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2468
|
+
const body = createLegalHoldBody(req);
|
|
2469
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?legal-hold${query}`, {
|
|
2470
|
+
bucket: req.bucket,
|
|
2471
|
+
body,
|
|
2472
|
+
headers: objectPutConfigHeaders(req, body),
|
|
2473
|
+
}, signal);
|
|
2474
|
+
return objectConfigResponse(res);
|
|
2475
|
+
}, { schema: S3PutObjectLegalHoldRequestSchema });
|
|
2476
|
+
// sig-ok: action namespace over dynamic S3 object retention path
|
|
2477
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?retention{query}
|
|
2478
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectRetention.html
|
|
2479
|
+
const objectsGetRetention = Object.assign(async (req, signal) => {
|
|
2480
|
+
const bucket = awsEncode(req.bucket);
|
|
2481
|
+
const key = encodeS3Key(req.key);
|
|
2482
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2483
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?retention${query}`, { bucket: req.bucket, headers: objectGovernanceHeaders(req) }, signal);
|
|
2484
|
+
return parseObjectRetention(await res.text(), res.headers);
|
|
2485
|
+
}, { schema: S3ObjectGovernanceRequestSchema });
|
|
2486
|
+
// sig-ok: action namespace over dynamic S3 object retention path
|
|
2487
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}?retention{query}
|
|
2488
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectRetention.html
|
|
2489
|
+
const objectsPutRetention = Object.assign(async (req, signal) => {
|
|
2490
|
+
const bucket = awsEncode(req.bucket);
|
|
2491
|
+
const key = encodeS3Key(req.key);
|
|
2492
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2493
|
+
const body = createRetentionBody(req);
|
|
2494
|
+
const headers = objectPutConfigHeaders(req, body);
|
|
2495
|
+
if (req.bypassGovernanceRetention !== undefined) {
|
|
2496
|
+
headers["x-amz-bypass-governance-retention"] = String(req.bypassGovernanceRetention);
|
|
2497
|
+
}
|
|
2498
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?retention${query}`, { bucket: req.bucket, body, headers }, signal);
|
|
2499
|
+
return objectConfigResponse(res);
|
|
2500
|
+
}, { schema: S3PutObjectRetentionRequestSchema });
|
|
2501
|
+
// sig-ok: action namespace over dynamic S3 object torrent path
|
|
2502
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}?torrent{query}
|
|
2503
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTorrent.html
|
|
2504
|
+
const objectsGetTorrent = Object.assign(async (req, signal) => {
|
|
2505
|
+
const bucket = awsEncode(req.bucket);
|
|
2506
|
+
const key = encodeS3Key(req.key);
|
|
2507
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2508
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}?torrent${query}`, { bucket: req.bucket, headers: objectGovernanceHeaders(req) }, signal);
|
|
2509
|
+
return {
|
|
2510
|
+
...objectConfigResponse(res),
|
|
2511
|
+
body: await res.arrayBuffer(),
|
|
2512
|
+
};
|
|
2513
|
+
}, { schema: S3ObjectGovernanceRequestSchema });
|
|
2514
|
+
// sig-ok: action namespace over dynamic S3 object select path
|
|
2515
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}/{key}?select&select-type=2
|
|
2516
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_SelectObjectContent.html
|
|
2517
|
+
const objectsSelectContent = Object.assign(async (req, signal) => {
|
|
2518
|
+
const bucket = awsEncode(req.bucket);
|
|
2519
|
+
const key = encodeS3Key(req.key);
|
|
2520
|
+
const headers = {
|
|
2521
|
+
"Content-Type": "application/xml",
|
|
2522
|
+
};
|
|
2523
|
+
if (req.expectedBucketOwner) {
|
|
2524
|
+
headers["x-amz-expected-bucket-owner"] = req.expectedBucketOwner;
|
|
2525
|
+
}
|
|
2526
|
+
addSseCustomerHeaders(headers, req);
|
|
2527
|
+
const res = await makeSignedRequest("POST", `/${bucket}/${key}?select&select-type=2`, { bucket: req.bucket, body: req.body, headers }, signal);
|
|
2528
|
+
return {
|
|
2529
|
+
...objectConfigResponse(res),
|
|
2530
|
+
body: await res.arrayBuffer(),
|
|
2531
|
+
};
|
|
2532
|
+
}, { schema: S3SelectObjectContentRequestSchema });
|
|
2533
|
+
// sig-ok: action namespace over dynamic S3 object encryption path
|
|
2534
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}?encryption{query}
|
|
2535
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UpdateObjectEncryption.html
|
|
2536
|
+
const objectsUpdateEncryption = Object.assign(async (req, signal) => {
|
|
2537
|
+
const bucket = awsEncode(req.bucket);
|
|
2538
|
+
const key = encodeS3Key(req.key);
|
|
2539
|
+
const query = buildQuery({ versionId: req.versionId }, "&");
|
|
2540
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}?encryption${query}`, {
|
|
2541
|
+
bucket: req.bucket,
|
|
2542
|
+
body: req.body,
|
|
2543
|
+
headers: objectPutConfigHeaders(req, req.body),
|
|
2544
|
+
}, signal);
|
|
2545
|
+
return objectConfigResponse(res);
|
|
2546
|
+
}, { schema: S3UpdateObjectEncryptionRequestSchema });
|
|
2547
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2548
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}/{key}?uploads
|
|
2549
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html
|
|
2550
|
+
const objectsCreateMultipartUpload = Object.assign(async (req, signal) => {
|
|
2551
|
+
const bucket = awsEncode(req.bucket);
|
|
2552
|
+
const key = encodeS3Key(req.key);
|
|
2553
|
+
const headers = {};
|
|
2554
|
+
addObjectContentHeaders(headers, req);
|
|
2555
|
+
addMetadataHeaders(headers, req.metadata);
|
|
2556
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2557
|
+
addChecksumRequestHeaders(headers, req);
|
|
2558
|
+
if (req.acl)
|
|
2559
|
+
headers["x-amz-acl"] = req.acl;
|
|
2560
|
+
if (req.bucketKeyEnabled !== undefined) {
|
|
2561
|
+
headers["x-amz-server-side-encryption-bucket-key-enabled"] = String(req.bucketKeyEnabled);
|
|
2562
|
+
}
|
|
2563
|
+
if (req.objectLockLegalHold) {
|
|
2564
|
+
headers["x-amz-object-lock-legal-hold"] = req.objectLockLegalHold;
|
|
2565
|
+
}
|
|
2566
|
+
if (req.objectLockMode) {
|
|
2567
|
+
headers["x-amz-object-lock-mode"] = req.objectLockMode;
|
|
2568
|
+
}
|
|
2569
|
+
if (req.objectLockRetainUntilDate) {
|
|
2570
|
+
headers["x-amz-object-lock-retain-until-date"] =
|
|
2571
|
+
req.objectLockRetainUntilDate;
|
|
2572
|
+
}
|
|
2573
|
+
if (req.serverSideEncryption) {
|
|
2574
|
+
headers["x-amz-server-side-encryption"] = req.serverSideEncryption;
|
|
2575
|
+
}
|
|
2576
|
+
if (req.sseKmsEncryptionContext) {
|
|
2577
|
+
headers["x-amz-server-side-encryption-context"] =
|
|
2578
|
+
req.sseKmsEncryptionContext;
|
|
2579
|
+
}
|
|
2580
|
+
if (req.sseKmsKeyId) {
|
|
2581
|
+
headers["x-amz-server-side-encryption-aws-kms-key-id"] =
|
|
2582
|
+
req.sseKmsKeyId;
|
|
2583
|
+
}
|
|
2584
|
+
if (req.storageClass)
|
|
2585
|
+
headers["x-amz-storage-class"] = req.storageClass;
|
|
2586
|
+
if (req.tagging)
|
|
2587
|
+
headers["x-amz-tagging"] = req.tagging;
|
|
2588
|
+
if (req.websiteRedirectLocation) {
|
|
2589
|
+
headers["x-amz-website-redirect-location"] =
|
|
2590
|
+
req.websiteRedirectLocation;
|
|
2591
|
+
}
|
|
2592
|
+
const res = await makeSignedRequest("POST", `/${bucket}/${key}?uploads`, { bucket: req.bucket, headers }, signal);
|
|
2593
|
+
return parseCreateMultipartUpload(await res.text(), res.headers);
|
|
2594
|
+
}, { schema: S3CreateMultipartUploadRequestSchema });
|
|
2595
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2596
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2597
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html
|
|
2598
|
+
const objectsUploadPart = Object.assign(async (req, signal) => {
|
|
2599
|
+
const bucket = awsEncode(req.bucket);
|
|
2600
|
+
const key = encodeS3Key(req.key);
|
|
2601
|
+
const query = buildQuery({
|
|
2602
|
+
partNumber: req.partNumber,
|
|
2603
|
+
uploadId: req.uploadId,
|
|
2604
|
+
});
|
|
2605
|
+
const headers = {};
|
|
2606
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2607
|
+
addChecksumRequestHeaders(headers, req);
|
|
2608
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}${query}`, {
|
|
2609
|
+
bucket: req.bucket,
|
|
2610
|
+
body: req.body,
|
|
2611
|
+
headers,
|
|
2612
|
+
}, signal);
|
|
2613
|
+
return {
|
|
2614
|
+
...checksumFieldsFromHeaders(res.headers),
|
|
2615
|
+
eTag: getHeader(res.headers, "etag"),
|
|
2616
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
2617
|
+
serverSideEncryption: getHeader(res.headers, "x-amz-server-side-encryption"),
|
|
2618
|
+
sseKmsKeyId: getHeader(res.headers, "x-amz-server-side-encryption-aws-kms-key-id"),
|
|
2619
|
+
};
|
|
2620
|
+
}, { schema: S3UploadPartRequestSchema });
|
|
2621
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2622
|
+
// PUT https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2623
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html
|
|
2624
|
+
const objectsUploadPartCopy = Object.assign(async (req, signal) => {
|
|
2625
|
+
const bucket = awsEncode(req.bucket);
|
|
2626
|
+
const key = encodeS3Key(req.key);
|
|
2627
|
+
const query = buildQuery({
|
|
2628
|
+
partNumber: req.partNumber,
|
|
2629
|
+
uploadId: req.uploadId,
|
|
2630
|
+
});
|
|
2631
|
+
const headers = {
|
|
2632
|
+
"x-amz-copy-source": encodeCopySource(req.sourceBucket, req.sourceKey, req.sourceVersionId),
|
|
2633
|
+
};
|
|
2634
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2635
|
+
if (req.copySourceIfMatch) {
|
|
2636
|
+
headers["x-amz-copy-source-if-match"] = req.copySourceIfMatch;
|
|
2637
|
+
}
|
|
2638
|
+
if (req.copySourceIfModifiedSince) {
|
|
2639
|
+
headers["x-amz-copy-source-if-modified-since"] =
|
|
2640
|
+
req.copySourceIfModifiedSince;
|
|
2641
|
+
}
|
|
2642
|
+
if (req.copySourceIfNoneMatch) {
|
|
2643
|
+
headers["x-amz-copy-source-if-none-match"] = req.copySourceIfNoneMatch;
|
|
2644
|
+
}
|
|
2645
|
+
if (req.copySourceIfUnmodifiedSince) {
|
|
2646
|
+
headers["x-amz-copy-source-if-unmodified-since"] =
|
|
2647
|
+
req.copySourceIfUnmodifiedSince;
|
|
2648
|
+
}
|
|
2649
|
+
if (req.copySourceRange) {
|
|
2650
|
+
headers["x-amz-copy-source-range"] = req.copySourceRange;
|
|
2651
|
+
}
|
|
2652
|
+
if (req.sourceExpectedBucketOwner) {
|
|
2653
|
+
headers["x-amz-source-expected-bucket-owner"] =
|
|
2654
|
+
req.sourceExpectedBucketOwner;
|
|
2655
|
+
}
|
|
2656
|
+
const res = await makeSignedRequest("PUT", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2657
|
+
return parseUploadPartCopy(await res.text(), res.headers);
|
|
2658
|
+
}, { schema: S3UploadPartCopyRequestSchema });
|
|
2659
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2660
|
+
// POST https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2661
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html
|
|
2662
|
+
const objectsCompleteMultipartUpload = Object.assign(async (req, signal) => {
|
|
2663
|
+
const bucket = awsEncode(req.bucket);
|
|
2664
|
+
const key = encodeS3Key(req.key);
|
|
2665
|
+
const query = buildQuery({ uploadId: req.uploadId });
|
|
2666
|
+
const headers = {
|
|
2667
|
+
"Content-Type": "application/xml",
|
|
2668
|
+
};
|
|
2669
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2670
|
+
addChecksumRequestHeaders(headers, req);
|
|
2671
|
+
if (req.ifMatch)
|
|
2672
|
+
headers["If-Match"] = req.ifMatch;
|
|
2673
|
+
if (req.ifNoneMatch)
|
|
2674
|
+
headers["If-None-Match"] = req.ifNoneMatch;
|
|
2675
|
+
if (req.mpuObjectSize !== undefined) {
|
|
2676
|
+
headers["x-amz-mp-object-size"] = String(req.mpuObjectSize);
|
|
2677
|
+
}
|
|
2678
|
+
const res = await makeSignedRequest("POST", `/${bucket}/${key}${query}`, {
|
|
2679
|
+
bucket: req.bucket,
|
|
2680
|
+
body: createCompleteMultipartUploadBody(req.parts),
|
|
2681
|
+
headers,
|
|
2682
|
+
}, signal);
|
|
2683
|
+
return parseCompleteMultipartUpload(await res.text(), res.headers);
|
|
2684
|
+
}, { schema: S3CompleteMultipartUploadRequestSchema });
|
|
2685
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2686
|
+
// DELETE https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2687
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html
|
|
2688
|
+
const objectsAbortMultipartUpload = Object.assign(async (req, signal) => {
|
|
2689
|
+
const bucket = awsEncode(req.bucket);
|
|
2690
|
+
const key = encodeS3Key(req.key);
|
|
2691
|
+
const query = buildQuery({ uploadId: req.uploadId });
|
|
2692
|
+
const headers = {};
|
|
2693
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2694
|
+
const res = await makeSignedRequest("DELETE", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2695
|
+
return {
|
|
2696
|
+
requestCharged: getHeader(res.headers, "x-amz-request-charged"),
|
|
2697
|
+
headers: collectHeaders(res.headers),
|
|
2698
|
+
};
|
|
2699
|
+
}, { schema: S3AbortMultipartUploadRequestSchema });
|
|
2700
|
+
// sig-ok: action namespace over dynamic S3 multipart object path
|
|
2701
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}/{key}{query}
|
|
2702
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html
|
|
2703
|
+
const objectsListParts = Object.assign(async (req, signal) => {
|
|
2704
|
+
const bucket = awsEncode(req.bucket);
|
|
2705
|
+
const key = encodeS3Key(req.key);
|
|
2706
|
+
const query = buildQuery({
|
|
2707
|
+
uploadId: req.uploadId,
|
|
2708
|
+
"max-parts": req.maxParts,
|
|
2709
|
+
"part-number-marker": req.partNumberMarker,
|
|
2710
|
+
}, "?");
|
|
2711
|
+
const headers = {};
|
|
2712
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2713
|
+
const res = await makeSignedRequest("GET", `/${bucket}/${key}${query}`, { bucket: req.bucket, headers }, signal);
|
|
2714
|
+
return parseListParts(await res.text(), res.headers);
|
|
2715
|
+
}, { schema: S3ListPartsRequestSchema });
|
|
2716
|
+
// sig-ok: action namespace over dynamic S3 bucket multipart path
|
|
2717
|
+
// GET https://s3.us-east-1.amazonaws.com/{bucket}?uploads{query}
|
|
2718
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
|
|
2719
|
+
const objectsListMultipartUploads = Object.assign(async (req, signal) => {
|
|
2720
|
+
const bucket = awsEncode(req.bucket);
|
|
2721
|
+
const query = buildQuery({
|
|
2722
|
+
delimiter: req.delimiter,
|
|
2723
|
+
"encoding-type": req.encodingType,
|
|
2724
|
+
"key-marker": req.keyMarker,
|
|
2725
|
+
"max-uploads": req.maxUploads,
|
|
2726
|
+
prefix: req.prefix,
|
|
2727
|
+
"upload-id-marker": req.uploadIdMarker,
|
|
2728
|
+
}, "&");
|
|
2729
|
+
const headers = {};
|
|
2730
|
+
addOwnerAndPayerHeaders(headers, req.expectedBucketOwner, req.requestPayer);
|
|
2731
|
+
const res = await makeSignedRequest("GET", `/${bucket}?uploads${query}`, { bucket: req.bucket, headers }, signal);
|
|
2732
|
+
return parseListMultipartUploads(await res.text(), res.headers);
|
|
2733
|
+
}, { schema: S3ListMultipartUploadsRequestSchema });
|
|
2734
|
+
// sig-ok: action namespace over S3 Object Lambda response path
|
|
2735
|
+
// POST https://{param}.s3-object-lambda.{param}.amazonaws.com/WriteGetObjectResponse
|
|
2736
|
+
// Docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_WriteGetObjectResponse.html
|
|
2737
|
+
const objectLambdaWriteGetObjectResponse = Object.assign(async (req, signal) => {
|
|
2738
|
+
const headers = {};
|
|
2739
|
+
addForwardedResponseHeaders(headers, req);
|
|
2740
|
+
const res = await makeSignedRequest("POST", "/WriteGetObjectResponse", {
|
|
2741
|
+
baseOverride: opts.endpoint ??
|
|
2742
|
+
`https://${req.requestRoute}.s3-object-lambda.${opts.region}.amazonaws.com`,
|
|
2743
|
+
body: req.body,
|
|
2744
|
+
headers,
|
|
2745
|
+
signingService: "s3-object-lambda",
|
|
2746
|
+
}, signal);
|
|
2747
|
+
return objectConfigResponse(res);
|
|
2748
|
+
}, { schema: S3WriteGetObjectResponseRequestSchema });
|
|
2749
|
+
const presignGetObject = Object.assign((req) => presignObjectUrl("GET", req), { schema: S3PresignObjectRequestSchema });
|
|
2750
|
+
const presignPutObject = Object.assign((req) => presignObjectUrl("PUT", req), { schema: S3PresignObjectRequestSchema });
|
|
2751
|
+
const presignHeadObject = Object.assign((req) => presignObjectUrl("HEAD", req), { schema: S3PresignObjectRequestSchema });
|
|
2752
|
+
const presignDeleteObject = Object.assign((req) => presignObjectUrl("DELETE", req), { schema: S3PresignObjectRequestSchema });
|
|
2753
|
+
return {
|
|
2754
|
+
buckets: {
|
|
2755
|
+
create: bucketsCreate,
|
|
2756
|
+
createMetadataConfiguration: bucketsCreateMetadataConfiguration,
|
|
2757
|
+
createMetadataTableConfiguration: bucketsCreateMetadataTableConfiguration,
|
|
2758
|
+
createSession: bucketsCreateSession,
|
|
2759
|
+
del: bucketsDel,
|
|
2760
|
+
delAnalytics: bucketsDelAnalytics,
|
|
2761
|
+
delCors: bucketsDelCors,
|
|
2762
|
+
delEncryption: bucketsDelEncryption,
|
|
2763
|
+
delIntelligentTiering: bucketsDelIntelligentTiering,
|
|
2764
|
+
delInventory: bucketsDelInventory,
|
|
2765
|
+
delLifecycle: bucketsDelLifecycle,
|
|
2766
|
+
delMetadataConfiguration: bucketsDelMetadataConfiguration,
|
|
2767
|
+
delMetadataTableConfiguration: bucketsDelMetadataTableConfiguration,
|
|
2768
|
+
delMetrics: bucketsDelMetrics,
|
|
2769
|
+
delOwnershipControls: bucketsDelOwnershipControls,
|
|
2770
|
+
delPolicy: bucketsDelPolicy,
|
|
2771
|
+
delPublicAccessBlock: bucketsDelPublicAccessBlock,
|
|
2772
|
+
delReplication: bucketsDelReplication,
|
|
2773
|
+
delTagging: bucketsDelTagging,
|
|
2774
|
+
delWebsite: bucketsDelWebsite,
|
|
2775
|
+
getAbac: bucketsGetAbac,
|
|
2776
|
+
getAccelerateConfiguration: bucketsGetAccelerateConfiguration,
|
|
2777
|
+
getAcl: bucketsGetAcl,
|
|
2778
|
+
getAnalytics: bucketsGetAnalytics,
|
|
2779
|
+
getCors: bucketsGetCors,
|
|
2780
|
+
getEncryption: bucketsGetEncryption,
|
|
2781
|
+
getIntelligentTiering: bucketsGetIntelligentTiering,
|
|
2782
|
+
getInventory: bucketsGetInventory,
|
|
2783
|
+
getLifecycle: bucketsGetLifecycle,
|
|
2784
|
+
getLifecycleLegacy: bucketsGetLifecycleLegacy,
|
|
2785
|
+
getLogging: bucketsGetLogging,
|
|
2786
|
+
getMetadataConfiguration: bucketsGetMetadataConfiguration,
|
|
2787
|
+
getMetadataTableConfiguration: bucketsGetMetadataTableConfiguration,
|
|
2788
|
+
getMetrics: bucketsGetMetrics,
|
|
2789
|
+
getNotification: bucketsGetNotification,
|
|
2790
|
+
getNotificationLegacy: bucketsGetNotificationLegacy,
|
|
2791
|
+
getObjectLockConfiguration: bucketsGetObjectLockConfiguration,
|
|
2792
|
+
getOwnershipControls: bucketsGetOwnershipControls,
|
|
2793
|
+
getPolicy: bucketsGetPolicy,
|
|
2794
|
+
getPolicyStatus: bucketsGetPolicyStatus,
|
|
2795
|
+
getPublicAccessBlock: bucketsGetPublicAccessBlock,
|
|
2796
|
+
getReplication: bucketsGetReplication,
|
|
2797
|
+
getRequestPayment: bucketsGetRequestPayment,
|
|
2798
|
+
getTagging: bucketsGetTagging,
|
|
2799
|
+
getVersioning: bucketsGetVersioning,
|
|
2800
|
+
getWebsite: bucketsGetWebsite,
|
|
2801
|
+
head: bucketsHead,
|
|
2802
|
+
listAnalytics: bucketsListAnalytics,
|
|
2803
|
+
listDirectory: bucketsListDirectory,
|
|
2804
|
+
listIntelligentTiering: bucketsListIntelligentTiering,
|
|
2805
|
+
listInventory: bucketsListInventory,
|
|
2806
|
+
list: bucketsList,
|
|
2807
|
+
listMetrics: bucketsListMetrics,
|
|
2808
|
+
location: bucketsLocation,
|
|
2809
|
+
putAbac: bucketsPutAbac,
|
|
2810
|
+
putAccelerateConfiguration: bucketsPutAccelerateConfiguration,
|
|
2811
|
+
putAcl: bucketsPutAcl,
|
|
2812
|
+
putAnalytics: bucketsPutAnalytics,
|
|
2813
|
+
putCors: bucketsPutCors,
|
|
2814
|
+
putEncryption: bucketsPutEncryption,
|
|
2815
|
+
putIntelligentTiering: bucketsPutIntelligentTiering,
|
|
2816
|
+
putInventory: bucketsPutInventory,
|
|
2817
|
+
putLifecycle: bucketsPutLifecycle,
|
|
2818
|
+
putLifecycleLegacy: bucketsPutLifecycleLegacy,
|
|
2819
|
+
putLogging: bucketsPutLogging,
|
|
2820
|
+
putMetrics: bucketsPutMetrics,
|
|
2821
|
+
putNotification: bucketsPutNotification,
|
|
2822
|
+
putNotificationLegacy: bucketsPutNotificationLegacy,
|
|
2823
|
+
putObjectLockConfiguration: bucketsPutObjectLockConfiguration,
|
|
2824
|
+
putOwnershipControls: bucketsPutOwnershipControls,
|
|
2825
|
+
putPolicy: bucketsPutPolicy,
|
|
2826
|
+
putPublicAccessBlock: bucketsPutPublicAccessBlock,
|
|
2827
|
+
putReplication: bucketsPutReplication,
|
|
2828
|
+
putRequestPayment: bucketsPutRequestPayment,
|
|
2829
|
+
putTagging: bucketsPutTagging,
|
|
2830
|
+
putVersioning: bucketsPutVersioning,
|
|
2831
|
+
putWebsite: bucketsPutWebsite,
|
|
2832
|
+
updateMetadataInventoryTable: bucketsUpdateMetadataInventoryTable,
|
|
2833
|
+
updateMetadataJournalTable: bucketsUpdateMetadataJournalTable,
|
|
2834
|
+
},
|
|
2835
|
+
objectLambda: {
|
|
2836
|
+
writeGetObjectResponse: objectLambdaWriteGetObjectResponse,
|
|
2837
|
+
},
|
|
2838
|
+
objects: {
|
|
2839
|
+
abortMultipartUpload: objectsAbortMultipartUpload,
|
|
2840
|
+
completeMultipartUpload: objectsCompleteMultipartUpload,
|
|
2841
|
+
copy: objectsCopy,
|
|
2842
|
+
createMultipartUpload: objectsCreateMultipartUpload,
|
|
2843
|
+
del: objectsDel,
|
|
2844
|
+
delMany: objectsDelMany,
|
|
2845
|
+
delTagging: objectsDelTagging,
|
|
2846
|
+
get: objectsGet,
|
|
2847
|
+
getAcl: objectsGetAcl,
|
|
2848
|
+
getAttributes: objectsGetAttributes,
|
|
2849
|
+
getLegalHold: objectsGetLegalHold,
|
|
2850
|
+
getRetention: objectsGetRetention,
|
|
2851
|
+
getStream: objectsGetStream,
|
|
2852
|
+
getTagging: objectsGetTagging,
|
|
2853
|
+
getTorrent: objectsGetTorrent,
|
|
2854
|
+
head: objectsHead,
|
|
2855
|
+
listMultipartUploads: objectsListMultipartUploads,
|
|
2856
|
+
listVersions: objectsListVersions,
|
|
2857
|
+
list: objectsList,
|
|
2858
|
+
listLegacy: objectsListLegacy,
|
|
2859
|
+
listParts: objectsListParts,
|
|
2860
|
+
put: objectsPut,
|
|
2861
|
+
putAcl: objectsPutAcl,
|
|
2862
|
+
putLegalHold: objectsPutLegalHold,
|
|
2863
|
+
putRetention: objectsPutRetention,
|
|
2864
|
+
putTagging: objectsPutTagging,
|
|
2865
|
+
rename: objectsRename,
|
|
2866
|
+
restore: objectsRestore,
|
|
2867
|
+
selectContent: objectsSelectContent,
|
|
2868
|
+
updateEncryption: objectsUpdateEncryption,
|
|
2869
|
+
uploadPart: objectsUploadPart,
|
|
2870
|
+
uploadPartCopy: objectsUploadPartCopy,
|
|
2871
|
+
},
|
|
2872
|
+
presign: {
|
|
2873
|
+
deleteObject: presignDeleteObject,
|
|
2874
|
+
getObject: presignGetObject,
|
|
2875
|
+
headObject: presignHeadObject,
|
|
2876
|
+
putObject: presignPutObject,
|
|
2877
|
+
},
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
//# sourceMappingURL=s3.js.map
|