Skip to content

Instantly share code, notes, and snippets.

@josephrocca
Created October 29, 2022 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephrocca/332e516102e039c2190a48da43519c5f to your computer and use it in GitHub Desktop.
Save josephrocca/332e516102e039c2190a48da43519c5f to your computer and use it in GitHub Desktop.
AWS S3 (v3) working in Deno
import * as AWS from "./aws_sdk_client_s3_v3.198.0-es.js";
let s3 = new AWS.S3({
region: "YOUR_REGION",
endpoint: "YOUR_ENDPOINT_URL_IF_NECCESSARY",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET",
},
});
let result = await s3.putObject({
Bucket: "YOUR_BUCKET_NAME",
Key: "hello_world.txt",
Body: "Hello World!
});
console.log("Success.");
// HOW TO CREATE aws_sdk_client_s3_v3.198.0-es.js YOURSELF:
// (because you shouldn't trust random scripts like this on the web)
// (and also because you may want to update to a newer version)
// STEP 1: Run this command: deno bundle https://cdn.skypack.dev/@aws-sdk/client-s3@3.198.0/dist-es/index.js
// STEP 2: Manually replace all instances of `thing.__proto__ = otherThing` with `Object.setPrototypeOf(thing, otherThing)` until this is fixed: https://github.com/skypackjs/skypack-cdn/issues/327
// That's it.
This file has been truncated, but you can view the full file.
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
function parseQueryString(querystring) {
const query = {};
querystring = querystring.replace(/^\?/, "");
if (querystring) {
for (const pair of querystring.split("&")){
let [key, value = null] = pair.split("=");
key = decodeURIComponent(key);
if (value) {
value = decodeURIComponent(value);
}
if (!(key in query)) {
query[key] = value;
} else if (Array.isArray(query[key])) {
query[key].push(value);
} else {
query[key] = [
query[key],
value
];
}
}
}
return query;
}
const parseUrl = (url)=>{
if (typeof url === "string") {
return parseUrl(new URL(url));
}
const { hostname , pathname , port , protocol , search } = url;
let query;
if (search) {
query = parseQueryString(search);
}
return {
hostname,
port: port ? parseInt(port) : void 0,
protocol,
path: pathname,
query
};
};
const deserializerMiddleware = (options, deserializer)=>(next, context)=>async (args)=>{
const { response } = await next(args);
try {
const parsed = await deserializer(response, options);
return {
response,
output: parsed
};
} catch (error) {
Object.defineProperty(error, "$response", {
value: response
});
throw error;
}
};
const serializerMiddleware = (options, serializer)=>(next, context)=>async (args)=>{
var _a;
const endpoint = ((_a = context.endpointV2) == null ? void 0 : _a.url) && options.urlParser ? async ()=>options.urlParser(context.endpointV2.url) : options.endpoint;
if (!endpoint) {
throw new Error("No valid endpoint provider available.");
}
const request = await serializer(args.input, {
...options,
endpoint
});
return next({
...args,
request
});
};
const deserializerMiddlewareOption = {
name: "deserializerMiddleware",
step: "deserialize",
tags: [
"DESERIALIZER"
],
override: true
};
const serializerMiddlewareOption = {
name: "serializerMiddleware",
step: "serialize",
tags: [
"SERIALIZER"
],
override: true
};
function getSerdePlugin(config, serializer, deserializer) {
return {
applyToStack: (commandStack)=>{
commandStack.add(deserializerMiddleware(config, deserializer), deserializerMiddlewareOption);
commandStack.add(serializerMiddleware(config, serializer), serializerMiddlewareOption);
}
};
}
const normalizeProvider = (input)=>{
if (typeof input === "function") return input;
const promisified = Promise.resolve(input);
return ()=>promisified;
};
const resolveParamsForS3 = async (endpointParams)=>{
const bucket = (endpointParams == null ? void 0 : endpointParams.Bucket) || "";
if (typeof endpointParams.Bucket === "string") {
endpointParams.Bucket = bucket.replace(/#/g, encodeURIComponent("#")).replace(/\?/g, encodeURIComponent("?"));
}
if (isArnBucketName(bucket)) {
if (endpointParams.ForcePathStyle === true) {
throw new Error("Path-style addressing cannot be used with ARN buckets");
}
} else if (!isDnsCompatibleBucketName(bucket) || bucket.indexOf(".") !== -1 && !String(endpointParams.Endpoint).startsWith("http:") || bucket.toLowerCase() !== bucket || bucket.length < 3) {
endpointParams.ForcePathStyle = true;
}
if (endpointParams.DisableMultiRegionAccessPoints) {
endpointParams.disableMultiRegionAccessPoints = true;
endpointParams.DisableMRAP = true;
}
return endpointParams;
};
const DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
const IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
const DOTS_PATTERN = /\.\./;
const isDnsCompatibleBucketName = (bucketName)=>DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
const isArnBucketName = (bucketName)=>{
const [arn, partition, service, region, account, typeOrId] = bucketName.split(":");
const isArn = arn === "arn" && bucketName.split(":").length >= 6;
const isValidArn = [
arn,
partition,
service,
account,
typeOrId
].filter(Boolean).length === 5;
if (isArn && !isValidArn) {
throw new Error(`Invalid ARN: ${bucketName} was an invalid ARN.`);
}
return arn === "arn" && !!partition && !!service && !!account && !!typeOrId;
};
const createConfigValueProvider = (configKey, canonicalEndpointParamKey, config)=>{
const configProvider = async ()=>{
var _a;
const configValue = (_a = config[configKey]) != null ? _a : config[canonicalEndpointParamKey];
if (typeof configValue === "function") {
return configValue();
}
return configValue;
};
if (configKey === "endpoint" || canonicalEndpointParamKey === "endpoint") {
return async ()=>{
const endpoint = await configProvider();
if (endpoint && typeof endpoint === "object") {
if ("url" in endpoint) {
return endpoint.url.href;
}
if ("hostname" in endpoint) {
const { protocol , hostname , port , path } = endpoint;
return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
}
}
return endpoint;
};
}
return configProvider;
};
const getEndpointFromInstructions = async (commandInput, instructionsSupplier, clientConfig, context)=>{
const endpointParams = await resolveParams(commandInput, instructionsSupplier, clientConfig);
if (typeof clientConfig.endpointProvider !== "function") {
throw new Error("config.endpointProvider is not set.");
}
const endpoint = clientConfig.endpointProvider(endpointParams, context);
return endpoint;
};
const resolveParams = async (commandInput, instructionsSupplier, clientConfig)=>{
var _a;
const endpointParams = {};
const instructions = ((_a = instructionsSupplier == null ? void 0 : instructionsSupplier.getEndpointParameterInstructions) == null ? void 0 : _a.call(instructionsSupplier)) || {};
for (const [name, instruction] of Object.entries(instructions)){
switch(instruction.type){
case "staticContextParams":
endpointParams[name] = instruction.value;
break;
case "contextParams":
endpointParams[name] = commandInput[instruction.name];
break;
case "clientContextParams":
case "builtInParams":
endpointParams[name] = await createConfigValueProvider(instruction.name, name, clientConfig)();
break;
default:
throw new Error("Unrecognized endpoint parameter instruction: " + JSON.stringify(instruction));
}
}
if (Object.keys(instructions).length === 0) {
Object.assign(endpointParams, clientConfig);
}
if (String(clientConfig.serviceId).toLowerCase() === "s3") {
await resolveParamsForS3(endpointParams);
}
return endpointParams;
};
const toEndpointV1 = (endpoint)=>{
if (typeof endpoint === "object") {
if ("url" in endpoint) {
return parseUrl(endpoint.url);
}
return endpoint;
}
return parseUrl(endpoint);
};
const endpointMiddleware = ({ config , instructions })=>{
return (next, context)=>async (args)=>{
var _a, _b;
const endpoint = await getEndpointFromInstructions(args.input, {
getEndpointParameterInstructions () {
return instructions;
}
}, {
...config
}, context);
context.endpointV2 = endpoint;
context.authSchemes = (_a = endpoint.properties) == null ? void 0 : _a.authSchemes;
const authScheme = (_b = context.authSchemes) == null ? void 0 : _b[0];
if (authScheme) {
context["signing_region"] = authScheme.signingRegion;
context["signing_service"] = authScheme.signingName;
}
return next({
...args
});
};
};
const endpointMiddlewareOptions = {
step: "serialize",
tags: [
"ENDPOINT_PARAMETERS",
"ENDPOINT_V2",
"ENDPOINT"
],
name: "endpointV2Middleware",
override: true,
relation: "before",
toMiddleware: serializerMiddlewareOption.name
};
const getEndpointPlugin = (config, instructions)=>({
applyToStack: (clientStack)=>{
clientStack.addRelativeTo(endpointMiddleware({
config,
instructions
}), endpointMiddlewareOptions);
}
});
const resolveEndpointConfig = (input)=>{
var _a, _b, _c;
const tls = (_a = input.tls) != null ? _a : true;
const { endpoint } = input;
const customEndpointProvider = endpoint != null ? async ()=>toEndpointV1(await normalizeProvider(endpoint)()) : void 0;
const isCustomEndpoint = !!endpoint;
return {
...input,
endpoint: customEndpointProvider,
tls,
isCustomEndpoint,
useDualstackEndpoint: normalizeProvider((_b = input.useDualstackEndpoint) != null ? _b : false),
useFipsEndpoint: normalizeProvider((_c = input.useFipsEndpoint) != null ? _c : false)
};
};
const constructStack = ()=>{
let absoluteEntries = [];
let relativeEntries = [];
const entriesNameSet = new Set();
const sort = (entries)=>entries.sort((a, b)=>stepWeights[b.step] - stepWeights[a.step] || priorityWeights[b.priority || "normal"] - priorityWeights[a.priority || "normal"]);
const removeByName = (toRemove)=>{
let isRemoved = false;
const filterCb = (entry)=>{
if (entry.name && entry.name === toRemove) {
isRemoved = true;
entriesNameSet.delete(toRemove);
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
};
const removeByReference = (toRemove)=>{
let isRemoved = false;
const filterCb = (entry)=>{
if (entry.middleware === toRemove) {
isRemoved = true;
if (entry.name) entriesNameSet.delete(entry.name);
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
};
const cloneTo = (toStack)=>{
absoluteEntries.forEach((entry)=>{
toStack.add(entry.middleware, {
...entry
});
});
relativeEntries.forEach((entry)=>{
toStack.addRelativeTo(entry.middleware, {
...entry
});
});
return toStack;
};
const expandRelativeMiddlewareList = (from)=>{
const expandedMiddlewareList = [];
from.before.forEach((entry)=>{
if (entry.before.length === 0 && entry.after.length === 0) {
expandedMiddlewareList.push(entry);
} else {
expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry));
}
});
expandedMiddlewareList.push(from);
from.after.reverse().forEach((entry)=>{
if (entry.before.length === 0 && entry.after.length === 0) {
expandedMiddlewareList.push(entry);
} else {
expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry));
}
});
return expandedMiddlewareList;
};
const getMiddlewareList = (debug = false)=>{
const normalizedAbsoluteEntries = [];
const normalizedRelativeEntries = [];
const normalizedEntriesNameMap = {};
absoluteEntries.forEach((entry)=>{
const normalizedEntry = {
...entry,
before: [],
after: []
};
if (normalizedEntry.name) normalizedEntriesNameMap[normalizedEntry.name] = normalizedEntry;
normalizedAbsoluteEntries.push(normalizedEntry);
});
relativeEntries.forEach((entry)=>{
const normalizedEntry = {
...entry,
before: [],
after: []
};
if (normalizedEntry.name) normalizedEntriesNameMap[normalizedEntry.name] = normalizedEntry;
normalizedRelativeEntries.push(normalizedEntry);
});
normalizedRelativeEntries.forEach((entry)=>{
if (entry.toMiddleware) {
const toMiddleware = normalizedEntriesNameMap[entry.toMiddleware];
if (toMiddleware === void 0) {
if (debug) {
return;
}
throw new Error(`${entry.toMiddleware} is not found when adding ${entry.name || "anonymous"} middleware ${entry.relation} ${entry.toMiddleware}`);
}
if (entry.relation === "after") {
toMiddleware.after.push(entry);
}
if (entry.relation === "before") {
toMiddleware.before.push(entry);
}
}
});
const mainChain = sort(normalizedAbsoluteEntries).map(expandRelativeMiddlewareList).reduce((wholeList, expendedMiddlewareList)=>{
wholeList.push(...expendedMiddlewareList);
return wholeList;
}, []);
return mainChain;
};
const stack = {
add: (middleware, options = {})=>{
const { name , override } = options;
const entry = {
step: "initialize",
priority: "normal",
middleware,
...options
};
if (name) {
if (entriesNameSet.has(name)) {
if (!override) throw new Error(`Duplicate middleware name '${name}'`);
const toOverrideIndex = absoluteEntries.findIndex((entry2)=>entry2.name === name);
const toOverride = absoluteEntries[toOverrideIndex];
if (toOverride.step !== entry.step || toOverride.priority !== entry.priority) {
throw new Error(`"${name}" middleware with ${toOverride.priority} priority in ${toOverride.step} step cannot be overridden by same-name middleware with ${entry.priority} priority in ${entry.step} step.`);
}
absoluteEntries.splice(toOverrideIndex, 1);
}
entriesNameSet.add(name);
}
absoluteEntries.push(entry);
},
addRelativeTo: (middleware, options)=>{
const { name , override } = options;
const entry = {
middleware,
...options
};
if (name) {
if (entriesNameSet.has(name)) {
if (!override) throw new Error(`Duplicate middleware name '${name}'`);
const toOverrideIndex = relativeEntries.findIndex((entry2)=>entry2.name === name);
const toOverride = relativeEntries[toOverrideIndex];
if (toOverride.toMiddleware !== entry.toMiddleware || toOverride.relation !== entry.relation) {
throw new Error(`"${name}" middleware ${toOverride.relation} "${toOverride.toMiddleware}" middleware cannot be overridden by same-name middleware ${entry.relation} "${entry.toMiddleware}" middleware.`);
}
relativeEntries.splice(toOverrideIndex, 1);
}
entriesNameSet.add(name);
}
relativeEntries.push(entry);
},
clone: ()=>cloneTo(constructStack()),
use: (plugin)=>{
plugin.applyToStack(stack);
},
remove: (toRemove)=>{
if (typeof toRemove === "string") return removeByName(toRemove);
else return removeByReference(toRemove);
},
removeByTag: (toRemove)=>{
let isRemoved = false;
const filterCb = (entry)=>{
const { tags , name } = entry;
if (tags && tags.includes(toRemove)) {
if (name) entriesNameSet.delete(name);
isRemoved = true;
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
},
concat: (from)=>{
const cloned = cloneTo(constructStack());
cloned.use(from);
return cloned;
},
applyToStack: cloneTo,
identify: ()=>{
return getMiddlewareList(true).map((mw)=>{
return mw.name + ": " + (mw.tags || []).join(",");
});
},
resolve: (handler, context)=>{
for (const middleware of getMiddlewareList().map((entry)=>entry.middleware).reverse()){
handler = middleware(handler, context);
}
return handler;
}
};
return stack;
};
const stepWeights = {
initialize: 5,
serialize: 4,
build: 3,
finalizeRequest: 2,
deserialize: 1
};
const priorityWeights = {
high: 3,
normal: 2,
low: 1
};
class Client {
constructor(config2){
this.middlewareStack = constructStack();
this.config = config2;
}
send(command, optionsOrCb, cb) {
const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0;
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
const handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
if (callback) {
handler(command).then((result)=>callback(null, result.output), (err)=>callback(err)).catch(()=>{});
} else {
return handler(command).then((result)=>result.output);
}
}
destroy() {
if (this.config.requestHandler.destroy) this.config.requestHandler.destroy();
}
}
class Command {
constructor(){
this.middlewareStack = constructStack();
}
}
const SENSITIVE_STRING = "***SensitiveInformation***";
const parseBoolean = (value)=>{
switch(value){
case "true":
return true;
case "false":
return false;
default:
throw new Error(`Unable to parse boolean value "${value}"`);
}
};
const expectNumber = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (typeof value === "string") {
const parsed = parseFloat(value);
if (!Number.isNaN(parsed)) {
if (String(parsed) !== String(value)) {
logger.warn(stackTraceWarning(`Expected number but observed string: ${value}`));
}
return parsed;
}
}
if (typeof value === "number") {
return value;
}
throw new TypeError(`Expected number, got ${typeof value}: ${value}`);
};
const MAX_FLOAT = Math.ceil(2 ** 127 * (2 - 2 ** -23));
const expectFloat32 = (value)=>{
const expected = expectNumber(value);
if (expected !== void 0 && !Number.isNaN(expected) && expected !== Infinity && expected !== -Infinity) {
if (Math.abs(expected) > MAX_FLOAT) {
throw new TypeError(`Expected 32-bit float, got ${value}`);
}
}
return expected;
};
const expectLong = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (Number.isInteger(value) && !Number.isNaN(value)) {
return value;
}
throw new TypeError(`Expected integer, got ${typeof value}: ${value}`);
};
const expectInt32 = (value)=>expectSizedInt(value, 32);
const expectShort = (value)=>expectSizedInt(value, 16);
const expectByte = (value)=>expectSizedInt(value, 8);
const expectSizedInt = (value, size)=>{
const expected = expectLong(value);
if (expected !== void 0 && castInt(expected, size) !== expected) {
throw new TypeError(`Expected ${size}-bit integer, got ${value}`);
}
return expected;
};
const castInt = (value, size)=>{
switch(size){
case 32:
return Int32Array.of(value)[0];
case 16:
return Int16Array.of(value)[0];
case 8:
return Int8Array.of(value)[0];
}
};
const expectNonNull = (value, location)=>{
if (value === null || value === void 0) {
if (location) {
throw new TypeError(`Expected a non-null value for ${location}`);
}
throw new TypeError("Expected a non-null value");
}
return value;
};
const expectObject = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (typeof value === "object" && !Array.isArray(value)) {
return value;
}
const receivedType = Array.isArray(value) ? "array" : typeof value;
throw new TypeError(`Expected object, got ${receivedType}: ${value}`);
};
const expectString = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (typeof value === "string") {
return value;
}
if ([
"boolean",
"number",
"bigint"
].includes(typeof value)) {
logger.warn(stackTraceWarning(`Expected string, got ${typeof value}: ${value}`));
return String(value);
}
throw new TypeError(`Expected string, got ${typeof value}: ${value}`);
};
const expectUnion = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
const asObject = expectObject(value);
const setKeys = Object.entries(asObject).filter(([, v])=>v != null).map(([k])=>k);
if (setKeys.length === 0) {
throw new TypeError(`Unions must have exactly one non-null member. None were found.`);
}
if (setKeys.length > 1) {
throw new TypeError(`Unions must have exactly one non-null member. Keys ${setKeys} were not null.`);
}
return asObject;
};
const strictParseFloat32 = (value)=>{
if (typeof value == "string") {
return expectFloat32(parseNumber(value));
}
return expectFloat32(value);
};
const NUMBER_REGEX = /(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g;
const parseNumber = (value)=>{
const matches = value.match(NUMBER_REGEX);
if (matches === null || matches[0].length !== value.length) {
throw new TypeError(`Expected real number, got implicit NaN`);
}
return parseFloat(value);
};
const strictParseLong = (value)=>{
if (typeof value === "string") {
return expectLong(parseNumber(value));
}
return expectLong(value);
};
const strictParseInt32 = (value)=>{
if (typeof value === "string") {
return expectInt32(parseNumber(value));
}
return expectInt32(value);
};
const strictParseShort = (value)=>{
if (typeof value === "string") {
return expectShort(parseNumber(value));
}
return expectShort(value);
};
const strictParseByte = (value)=>{
if (typeof value === "string") {
return expectByte(parseNumber(value));
}
return expectByte(value);
};
const stackTraceWarning = (message)=>{
return String(new TypeError(message).stack || message).split("\n").slice(0, 5).filter((s)=>!s.includes("stackTraceWarning")).join("\n");
};
const logger = {
warn: console.warn
};
const DAYS = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
];
const MONTHS = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
];
function dateToUtcString(date) {
const year = date.getUTCFullYear();
const month = date.getUTCMonth();
const dayOfWeek = date.getUTCDay();
const dayOfMonthInt = date.getUTCDate();
const hoursInt = date.getUTCHours();
const minutesInt = date.getUTCMinutes();
const secondsInt = date.getUTCSeconds();
const dayOfMonthString = dayOfMonthInt < 10 ? `0${dayOfMonthInt}` : `${dayOfMonthInt}`;
const hoursString = hoursInt < 10 ? `0${hoursInt}` : `${hoursInt}`;
const minutesString = minutesInt < 10 ? `0${minutesInt}` : `${minutesInt}`;
const secondsString = secondsInt < 10 ? `0${secondsInt}` : `${secondsInt}`;
return `${DAYS[dayOfWeek]}, ${dayOfMonthString} ${MONTHS[month]} ${year} ${hoursString}:${minutesString}:${secondsString} GMT`;
}
const RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);
const parseRfc3339DateTime = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (typeof value !== "string") {
throw new TypeError("RFC-3339 date-times must be expressed as strings");
}
const match = RFC3339.exec(value);
if (!match) {
throw new TypeError("Invalid RFC-3339 date-time value");
}
const [_, yearStr, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds] = match;
const year = strictParseShort(stripLeadingZeroes(yearStr));
const month = parseDateValue(monthStr, "month", 1, 12);
const day = parseDateValue(dayStr, "day", 1, 31);
return buildDate(year, month, day, {
hours,
minutes,
seconds,
fractionalMilliseconds
});
};
const IMF_FIXDATE = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
const RFC_850_DATE = new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
const ASC_TIME = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/);
const parseRfc7231DateTime = (value)=>{
if (value === null || value === void 0) {
return void 0;
}
if (typeof value !== "string") {
throw new TypeError("RFC-7231 date-times must be expressed as strings");
}
let match = IMF_FIXDATE.exec(value);
if (match) {
const [_, dayStr, monthStr, yearStr, hours, minutes, seconds, fractionalMilliseconds] = match;
return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), {
hours,
minutes,
seconds,
fractionalMilliseconds
});
}
match = RFC_850_DATE.exec(value);
if (match) {
const [_1, dayStr1, monthStr1, yearStr1, hours1, minutes1, seconds1, fractionalMilliseconds1] = match;
return adjustRfc850Year(buildDate(parseTwoDigitYear(yearStr1), parseMonthByShortName(monthStr1), parseDateValue(dayStr1, "day", 1, 31), {
hours: hours1,
minutes: minutes1,
seconds: seconds1,
fractionalMilliseconds: fractionalMilliseconds1
}));
}
match = ASC_TIME.exec(value);
if (match) {
const [_2, monthStr2, dayStr2, hours2, minutes2, seconds2, fractionalMilliseconds2, yearStr2] = match;
return buildDate(strictParseShort(stripLeadingZeroes(yearStr2)), parseMonthByShortName(monthStr2), parseDateValue(dayStr2.trimLeft(), "day", 1, 31), {
hours: hours2,
minutes: minutes2,
seconds: seconds2,
fractionalMilliseconds: fractionalMilliseconds2
});
}
throw new TypeError("Invalid RFC-7231 date-time value");
};
const buildDate = (year, month, day, time)=>{
const adjustedMonth = month - 1;
validateDayOfMonth(year, adjustedMonth, day);
return new Date(Date.UTC(year, adjustedMonth, day, parseDateValue(time.hours, "hour", 0, 23), parseDateValue(time.minutes, "minute", 0, 59), parseDateValue(time.seconds, "seconds", 0, 60), parseMilliseconds(time.fractionalMilliseconds)));
};
const parseTwoDigitYear = (value)=>{
const thisYear = new Date().getUTCFullYear();
const valueInThisCentury = Math.floor(thisYear / 100) * 100 + strictParseShort(stripLeadingZeroes(value));
if (valueInThisCentury < thisYear) {
return valueInThisCentury + 100;
}
return valueInThisCentury;
};
const FIFTY_YEARS_IN_MILLIS = 50 * 365 * 24 * 60 * 60 * 1e3;
const adjustRfc850Year = (input)=>{
if (input.getTime() - new Date().getTime() > FIFTY_YEARS_IN_MILLIS) {
return new Date(Date.UTC(input.getUTCFullYear() - 100, input.getUTCMonth(), input.getUTCDate(), input.getUTCHours(), input.getUTCMinutes(), input.getUTCSeconds(), input.getUTCMilliseconds()));
}
return input;
};
const parseMonthByShortName = (value)=>{
const monthIdx = MONTHS.indexOf(value);
if (monthIdx < 0) {
throw new TypeError(`Invalid month: ${value}`);
}
return monthIdx + 1;
};
const DAYS_IN_MONTH = [
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
];
const validateDayOfMonth = (year, month, day)=>{
let maxDays = DAYS_IN_MONTH[month];
if (month === 1 && isLeapYear(year)) {
maxDays = 29;
}
if (day > maxDays) {
throw new TypeError(`Invalid day for ${MONTHS[month]} in ${year}: ${day}`);
}
};
const isLeapYear = (year)=>{
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
};
const parseDateValue = (value, type, lower, upper)=>{
const dateVal = strictParseByte(stripLeadingZeroes(value));
if (dateVal < lower || dateVal > upper) {
throw new TypeError(`${type} must be between ${lower} and ${upper}, inclusive`);
}
return dateVal;
};
const parseMilliseconds = (value)=>{
if (value === null || value === void 0) {
return 0;
}
return strictParseFloat32("0." + value) * 1e3;
};
const stripLeadingZeroes = (value)=>{
let idx = 0;
while(idx < value.length - 1 && value.charAt(idx) === "0"){
idx++;
}
if (idx === 0) {
return value;
}
return value.slice(idx);
};
class ServiceException extends Error {
constructor(options){
super(options.message);
Object.setPrototypeOf(this, ServiceException.prototype);
this.name = options.name;
this.$fault = options.$fault;
this.$metadata = options.$metadata;
}
}
const decorateServiceException = (exception, additions = {})=>{
Object.entries(additions).filter(([, v])=>v !== void 0).forEach(([k, v])=>{
if (exception[k] == void 0 || exception[k] === "") {
exception[k] = v;
}
});
const message = exception.message || exception.Message || "UnknownError";
exception.message = message;
delete exception.Message;
return exception;
};
const throwDefaultError = ({ output , parsedBody , exceptionCtor , errorCode })=>{
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : void 0;
const response = new exceptionCtor({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknownError",
$fault: "client",
$metadata
});
throw decorateServiceException(response, parsedBody);
};
const deserializeMetadata = (output)=>{
var _a;
return {
httpStatusCode: output.statusCode,
requestId: (_a = output.headers["x-amzn-requestid"]) != null ? _a : output.headers["x-amzn-request-id"],
extendedRequestId: output.headers["x-amz-id-2"],
cfId: output.headers["x-amz-cf-id"]
};
};
const loadConfigsForDefaultMode = (mode)=>{
switch(mode){
case "standard":
return {
retryMode: "standard",
connectionTimeout: 3100
};
case "in-region":
return {
retryMode: "standard",
connectionTimeout: 1100
};
case "cross-region":
return {
retryMode: "standard",
connectionTimeout: 3100
};
case "mobile":
return {
retryMode: "standard",
connectionTimeout: 3e4
};
default:
return {};
}
};
function defaultSetTimout() {
throw new Error("setTimeout has not been defined");
}
function defaultClearTimeout() {
throw new Error("clearTimeout has not been defined");
}
var cachedSetTimeout = defaultSetTimout;
var cachedClearTimeout = defaultClearTimeout;
var globalContext;
if (typeof window !== "undefined") {
globalContext = window;
} else if (typeof self !== "undefined") {
globalContext = self;
} else {
globalContext = {};
}
if (typeof globalContext.setTimeout === "function") {
cachedSetTimeout = setTimeout;
}
if (typeof globalContext.clearTimeout === "function") {
cachedClearTimeout = clearTimeout;
}
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function() {
this.fun.apply(null, this.array);
};
var performance = globalContext.performance || {};
performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
return new Date().getTime();
};
new Date();
function extendedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
const getArrayIfSingleItem = (mayBeArray)=>Array.isArray(mayBeArray) ? mayBeArray : [
mayBeArray
];
const getValueFromTextNode = (obj)=>{
const textNodeName = "#text";
for(const key in obj){
if (obj.hasOwnProperty(key) && obj[key][textNodeName] !== void 0) {
obj[key] = obj[key][textNodeName];
} else if (typeof obj[key] === "object" && obj[key] !== null) {
obj[key] = getValueFromTextNode(obj[key]);
}
}
return obj;
};
const StringWrapper = function() {
const Class = Object.getPrototypeOf(this).constructor;
const Constructor = Function.bind.apply(String, [
null,
...arguments
]);
const instance = new Constructor();
Object.setPrototypeOf(instance, Class.prototype);
return instance;
};
StringWrapper.prototype = Object.create(String.prototype, {
constructor: {
value: StringWrapper,
enumerable: false,
writable: true,
configurable: true
}
});
Object.setPrototypeOf(StringWrapper, String);
function map(arg0, arg1, arg2) {
let target;
let filter;
let instructions;
if (typeof arg1 === "undefined" && typeof arg2 === "undefined") {
target = {};
instructions = arg0;
} else {
target = arg0;
if (typeof arg1 === "function") {
filter = arg1;
instructions = arg2;
return mapWithFilter(target, filter, instructions);
} else {
instructions = arg1;
}
}
for (const key of Object.keys(instructions)){
if (!Array.isArray(instructions[key])) {
target[key] = instructions[key];
continue;
}
let [filter2, value] = instructions[key];
if (typeof value === "function") {
let _value;
const defaultFilterPassed = filter2 === void 0 && (_value = value()) != null;
const customFilterPassed = typeof filter2 === "function" && !!filter2(void 0) || typeof filter2 !== "function" && !!filter2;
if (defaultFilterPassed) {
target[key] = _value;
} else if (customFilterPassed) {
target[key] = value();
}
} else {
const defaultFilterPassed1 = filter2 === void 0 && value != null;
const customFilterPassed1 = typeof filter2 === "function" && !!filter2(value) || typeof filter2 !== "function" && !!filter2;
if (defaultFilterPassed1 || customFilterPassed1) {
target[key] = value;
}
}
}
return target;
}
const mapWithFilter = (target, filter, instructions)=>{
return map(target, Object.entries(instructions).reduce((_instructions, [key, value])=>{
if (Array.isArray(value)) {
_instructions[key] = value;
} else {
if (typeof value === "function") {
_instructions[key] = [
filter,
value()
];
} else {
_instructions[key] = [
filter,
value
];
}
}
return _instructions;
}, {}));
};
const resolvedPath = (resolvedPath2, input, memberName, labelValueProvider, uriLabel, isGreedyLabel)=>{
if (input != null && input[memberName] !== void 0) {
const labelValue = labelValueProvider();
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: " + memberName + ".");
}
resolvedPath2 = resolvedPath2.replace(uriLabel, isGreedyLabel ? labelValue.split("/").map((segment)=>extendedEncodeURIComponent(segment)).join("/") : extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: " + memberName + ".");
}
return resolvedPath2;
};
class HttpRequest {
constructor(options){
this.method = options.method || "GET";
this.hostname = options.hostname || "localhost";
this.port = options.port;
this.query = options.query || {};
this.headers = options.headers || {};
this.body = options.body;
this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
}
static isInstance(request) {
if (!request) return false;
const req = request;
return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
}
clone() {
const cloned = new HttpRequest({
...this,
headers: {
...this.headers
}
});
if (cloned.query) cloned.query = cloneQuery(cloned.query);
return cloned;
}
}
function cloneQuery(query) {
return Object.keys(query).reduce((carry, paramName)=>{
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [
...param
] : param
};
}, {});
}
class HttpResponse {
constructor(options){
this.statusCode = options.statusCode;
this.headers = options.headers || {};
this.body = options.body;
}
static isInstance(response) {
if (!response) return false;
const resp = response;
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
}
}
function isValidHostname(hostname) {
const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/;
return hostPattern.test(hostname);
}
function escapeAttribute(value) {
return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
}
function escapeElement(value) {
return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\r/g, "&#x0D;").replace(/\n/g, "&#x0A;").replace(/\u0085/g, "&#x85;").replace(/\u2028/, "&#x2028;");
}
class XmlText {
constructor(value){
this.value = value;
}
toString() {
return escapeElement("" + this.value);
}
}
class XmlNode {
constructor(name, children = []){
this.name = name;
this.children = children;
this.attributes = {};
}
static of(name, childText, withName) {
const node = new XmlNode(name);
if (childText !== void 0) {
node.addChildNode(new XmlText(childText));
}
if (withName !== void 0) {
node.withName(withName);
}
return node;
}
withName(name) {
this.name = name;
return this;
}
addAttribute(name, value) {
this.attributes[name] = value;
return this;
}
addChildNode(child) {
this.children.push(child);
return this;
}
removeAttribute(name) {
delete this.attributes[name];
return this;
}
toString() {
const hasChildren = Boolean(this.children.length);
let xmlText = `<${this.name}`;
const attributes = this.attributes;
for (const attributeName of Object.keys(attributes)){
const attribute = attributes[attributeName];
if (typeof attribute !== "undefined" && attribute !== null) {
xmlText += ` ${attributeName}="${escapeAttribute("" + attribute)}"`;
}
}
return xmlText += !hasChildren ? "/>" : `>${this.children.map((c)=>c.toString()).join("")}</${this.name}>`;
}
}
const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
if (!Number.parseInt && window.parseInt) {
Number.parseInt = window.parseInt;
}
if (!Number.parseFloat && window.parseFloat) {
Number.parseFloat = window.parseFloat;
}
const consider = {
hex: true,
leadingZeros: true,
decimalPoint: ".",
eNotation: true
};
function toNumber(str, options = {}) {
options = Object.assign({}, consider, options);
if (!str || typeof str !== "string") return str;
let trimmedStr = str.trim();
if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
else if (options.hex && hexRegex.test(trimmedStr)) {
return Number.parseInt(trimmedStr, 16);
} else {
const match = numRegex.exec(trimmedStr);
if (match) {
const sign = match[1];
const leadingZeros = match[2];
let numTrimmedByZeros = trimZeros(match[3]);
const eNotation = match[4] || match[6];
if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
else {
const num = Number(trimmedStr);
const numStr = "" + num;
if (numStr.search(/[eE]/) !== -1) {
if (options.eNotation) return num;
else return str;
} else if (eNotation) {
if (options.eNotation) return num;
else return str;
} else if (trimmedStr.indexOf(".") !== -1) {
if (numStr === "0" && numTrimmedByZeros === "") return num;
else if (numStr === numTrimmedByZeros) return num;
else if (sign && numStr === "-" + numTrimmedByZeros) return num;
else return str;
}
if (leadingZeros) {
if (numTrimmedByZeros === numStr) return num;
else if (sign + numTrimmedByZeros === numStr) return num;
else return str;
}
if (trimmedStr === numStr) return num;
else if (trimmedStr === sign + numStr) return num;
return str;
}
} else {
return str;
}
}
}
function trimZeros(numStr) {
if (numStr && numStr.indexOf(".") !== -1) {
numStr = numStr.replace(/0+$/, "");
if (numStr === ".") numStr = "0";
else if (numStr[0] === ".") numStr = "0" + numStr;
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
return numStr;
}
return numStr;
}
var strnum = toNumber;
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function commonjsRequire() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var util = createCommonjsModule(function(module, exports) {
const nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
const nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
const nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
const regexName = new RegExp("^" + nameRegexp + "$");
const getAllMatches = function(string, regex) {
const matches = [];
let match = regex.exec(string);
while(match){
const allmatches = [];
allmatches.startIndex = regex.lastIndex - match[0].length;
const len = match.length;
for(let index = 0; index < len; index++){
allmatches.push(match[index]);
}
matches.push(allmatches);
match = regex.exec(string);
}
return matches;
};
const isName = function(string) {
const match = regexName.exec(string);
return !(match === null || typeof match === "undefined");
};
exports.isExist = function(v) {
return typeof v !== "undefined";
};
exports.isEmptyObject = function(obj) {
return Object.keys(obj).length === 0;
};
exports.merge = function(target, a, arrayMode) {
if (a) {
const keys = Object.keys(a);
const len = keys.length;
for(let i = 0; i < len; i++){
if (arrayMode === "strict") {
target[keys[i]] = [
a[keys[i]]
];
} else {
target[keys[i]] = a[keys[i]];
}
}
}
};
exports.getValue = function(v) {
if (exports.isExist(v)) {
return v;
} else {
return "";
}
};
exports.isName = isName;
exports.getAllMatches = getAllMatches;
exports.nameRegexp = nameRegexp;
});
const defaultOptions = {
allowBooleanAttributes: false,
unpairedTags: []
};
var validate = function(xmlData, options) {
options = Object.assign({}, defaultOptions, options);
const tags = [];
let tagFound = false;
let reachedRoot = false;
if (xmlData[0] === "\uFEFF") {
xmlData = xmlData.substr(1);
}
for(let i = 0; i < xmlData.length; i++){
if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
i += 2;
i = readPI(xmlData, i);
if (i.err) return i;
} else if (xmlData[i] === "<") {
let tagStartPos = i;
i++;
if (xmlData[i] === "!") {
i = readCommentAndCDATA(xmlData, i);
continue;
} else {
let closingTag = false;
if (xmlData[i] === "/") {
closingTag = true;
i++;
}
let tagName = "";
for(; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++){
tagName += xmlData[i];
}
tagName = tagName.trim();
if (tagName[tagName.length - 1] === "/") {
tagName = tagName.substring(0, tagName.length - 1);
i--;
}
if (!validateTagName(tagName)) {
let msg;
if (tagName.trim().length === 0) {
msg = "Invalid space after '<'.";
} else {
msg = "Tag '" + tagName + "' is an invalid name.";
}
return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
}
const result = readAttributeStr(xmlData, i);
if (result === false) {
return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
}
let attrStr = result.value;
i = result.index;
if (attrStr[attrStr.length - 1] === "/") {
const attrStrStart = i - attrStr.length;
attrStr = attrStr.substring(0, attrStr.length - 1);
const isValid = validateAttributeString(attrStr, options);
if (isValid === true) {
tagFound = true;
} else {
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
}
} else if (closingTag) {
if (!result.tagClosed) {
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
} else if (attrStr.trim().length > 0) {
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
} else {
const otg = tags.pop();
if (tagName !== otg.tagName) {
let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
return getErrorObject("InvalidTag", "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.", getLineNumberForPosition(xmlData, tagStartPos));
}
if (tags.length == 0) {
reachedRoot = true;
}
}
} else {
const isValid1 = validateAttributeString(attrStr, options);
if (isValid1 !== true) {
return getErrorObject(isValid1.err.code, isValid1.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid1.err.line));
}
if (reachedRoot === true) {
return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
} else if (options.unpairedTags.indexOf(tagName) !== -1) ;
else {
tags.push({
tagName,
tagStartPos
});
}
tagFound = true;
}
for(i++; i < xmlData.length; i++){
if (xmlData[i] === "<") {
if (xmlData[i + 1] === "!") {
i++;
i = readCommentAndCDATA(xmlData, i);
continue;
} else if (xmlData[i + 1] === "?") {
i = readPI(xmlData, ++i);
if (i.err) return i;
} else {
break;
}
} else if (xmlData[i] === "&") {
const afterAmp = validateAmpersand(xmlData, i);
if (afterAmp == -1) return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
i = afterAmp;
} else {
if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
}
}
}
if (xmlData[i] === "<") {
i--;
}
}
} else {
if (isWhiteSpace(xmlData[i])) {
continue;
}
return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
}
}
if (!tagFound) {
return getErrorObject("InvalidXml", "Start tag expected.", 1);
} else if (tags.length == 1) {
return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
} else if (tags.length > 0) {
return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t)=>t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
line: 1,
col: 1
});
}
return true;
};
function isWhiteSpace(__char) {
return __char === " " || __char === " " || __char === "\n" || __char === "\r";
}
function readPI(xmlData, i) {
const start = i;
for(; i < xmlData.length; i++){
if (xmlData[i] == "?" || xmlData[i] == " ") {
const tagname = xmlData.substr(start, i - start);
if (i > 5 && tagname === "xml") {
return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
} else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
i++;
break;
} else {
continue;
}
}
}
return i;
}
function readCommentAndCDATA(xmlData, i) {
if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
for(i += 3; i < xmlData.length; i++){
if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
i += 2;
break;
}
}
} else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
let angleBracketsCount = 1;
for(i += 8; i < xmlData.length; i++){
if (xmlData[i] === "<") {
angleBracketsCount++;
} else if (xmlData[i] === ">") {
angleBracketsCount--;
if (angleBracketsCount === 0) {
break;
}
}
}
} else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
for(i += 8; i < xmlData.length; i++){
if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
i += 2;
break;
}
}
}
return i;
}
const doubleQuote = '"';
const singleQuote = "'";
function readAttributeStr(xmlData, i) {
let attrStr = "";
let startChar = "";
let tagClosed = false;
for(; i < xmlData.length; i++){
if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
if (startChar === "") {
startChar = xmlData[i];
} else if (startChar !== xmlData[i]) ;
else {
startChar = "";
}
} else if (xmlData[i] === ">") {
if (startChar === "") {
tagClosed = true;
break;
}
}
attrStr += xmlData[i];
}
if (startChar !== "") {
return false;
}
return {
value: attrStr,
index: i,
tagClosed
};
}
const validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
function validateAttributeString(attrStr, options) {
const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
const attrNames = {};
for(let i = 0; i < matches.length; i++){
if (matches[i][1].length === 0) {
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
} else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
} else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
}
const attrName = matches[i][2];
if (!validateAttrName(attrName)) {
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
}
if (!attrNames.hasOwnProperty(attrName)) {
attrNames[attrName] = 1;
} else {
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
}
}
return true;
}
function validateNumberAmpersand(xmlData, i) {
let re = /\d/;
if (xmlData[i] === "x") {
i++;
re = /[\da-fA-F]/;
}
for(; i < xmlData.length; i++){
if (xmlData[i] === ";") return i;
if (!xmlData[i].match(re)) break;
}
return -1;
}
function validateAmpersand(xmlData, i) {
i++;
if (xmlData[i] === ";") return -1;
if (xmlData[i] === "#") {
i++;
return validateNumberAmpersand(xmlData, i);
}
let count = 0;
for(; i < xmlData.length; i++, count++){
if (xmlData[i].match(/\w/) && count < 20) continue;
if (xmlData[i] === ";") break;
return -1;
}
return i;
}
function getErrorObject(code, message, lineNumber) {
return {
err: {
code,
msg: message,
line: lineNumber.line || lineNumber,
col: lineNumber.col
}
};
}
function validateAttrName(attrName) {
return util.isName(attrName);
}
function validateTagName(tagname) {
return util.isName(tagname);
}
function getLineNumberForPosition(xmlData, index) {
const lines = xmlData.substring(0, index).split(/\r?\n/);
return {
line: lines.length,
col: lines[lines.length - 1].length + 1
};
}
function getPositionFromMatch(match) {
return match.startIndex + match[1].length;
}
var validator = {
validate
};
const defaultOptions$1 = {
preserveOrder: false,
attributeNamePrefix: "@_",
attributesGroupName: false,
textNodeName: "#text",
ignoreAttributes: true,
removeNSPrefix: false,
allowBooleanAttributes: false,
parseTagValue: true,
parseAttributeValue: false,
trimValues: true,
cdataPropName: false,
numberParseOptions: {
hex: true,
leadingZeros: true
},
tagValueProcessor: function(tagName, val) {
return val;
},
attributeValueProcessor: function(attrName, val) {
return val;
},
stopNodes: [],
alwaysCreateTextNode: false,
isArray: ()=>false,
commentPropName: false,
unpairedTags: [],
processEntities: true,
htmlEntities: false,
ignoreDeclaration: false,
ignorePiTags: false,
transformTagName: false
};
const buildOptions = function(options) {
return Object.assign({}, defaultOptions$1, options);
};
var buildOptions_1 = buildOptions;
var defaultOptions_1 = defaultOptions$1;
var OptionsBuilder = {
buildOptions: buildOptions_1,
defaultOptions: defaultOptions_1
};
class XmlNode1 {
constructor(tagname){
this.tagname = tagname;
this.child = [];
this[":@"] = {};
}
add(key, val) {
this.child.push({
[key]: val
});
}
addChild(node) {
if (node[":@"] && Object.keys(node[":@"]).length > 0) {
this.child.push({
[node.tagname]: node.child,
[":@"]: node[":@"]
});
} else {
this.child.push({
[node.tagname]: node.child
});
}
}
}
var xmlNode = XmlNode1;
function readDocType(xmlData, i) {
const entities = {};
if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
i = i + 9;
let angleBracketsCount = 1;
let hasBody = false, entity = false, comment = false;
let exp = "";
for(; i < xmlData.length; i++){
if (xmlData[i] === "<") {
if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") {
i += 7;
entity = true;
} else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") {
i += 8;
} else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") {
i += 8;
} else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") {
i += 9;
} else if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") {
comment = true;
} else {
throw new Error("Invalid DOCTYPE");
}
angleBracketsCount++;
exp = "";
} else if (xmlData[i] === ">") {
if (comment) {
if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
comment = false;
} else {
throw new Error(`Invalid XML comment in DOCTYPE`);
}
} else if (entity) {
parseEntityExp(exp, entities);
entity = false;
}
angleBracketsCount--;
if (angleBracketsCount === 0) {
break;
}
} else if (xmlData[i] === "[") {
hasBody = true;
} else {
exp += xmlData[i];
}
}
if (angleBracketsCount !== 0) {
throw new Error(`Unclosed DOCTYPE`);
}
} else {
throw new Error(`Invalid Tag instead of DOCTYPE`);
}
return {
entities,
i
};
}
const entityRegex = RegExp(`^\\s([a-zA-z0-0]+)[ ](['"])([^&]+)\\2`);
function parseEntityExp(exp, entities) {
const match = entityRegex.exec(exp);
if (match) {
entities[match[1]] = {
regx: RegExp(`&${match[1]};`, "g"),
val: match[3]
};
}
}
var DocTypeReader = readDocType;
"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, util.nameRegexp);
class OrderedObjParser {
constructor(options){
this.options = options;
this.currentNode = null;
this.tagsNodeStack = [];
this.docTypeEntities = {};
this.lastEntities = {
apos: {
regex: /&(apos|#39|#x27);/g,
val: "'"
},
gt: {
regex: /&(gt|#62|#x3E);/g,
val: ">"
},
lt: {
regex: /&(lt|#60|#x3C);/g,
val: "<"
},
quot: {
regex: /&(quot|#34|#x22);/g,
val: '"'
}
};
this.ampEntity = {
regex: /&(amp|#38|#x26);/g,
val: "&"
};
this.htmlEntities = {
space: {
regex: /&(nbsp|#160);/g,
val: " "
},
cent: {
regex: /&(cent|#162);/g,
val: "\xA2"
},
pound: {
regex: /&(pound|#163);/g,
val: "\xA3"
},
yen: {
regex: /&(yen|#165);/g,
val: "\xA5"
},
euro: {
regex: /&(euro|#8364);/g,
val: "\u20AC"
},
copyright: {
regex: /&(copy|#169);/g,
val: "\xA9"
},
reg: {
regex: /&(reg|#174);/g,
val: "\xAE"
},
inr: {
regex: /&(inr|#8377);/g,
val: "\u20B9"
}
};
this.addExternalEntities = addExternalEntities;
this.parseXml = parseXml;
this.parseTextData = parseTextData;
this.resolveNameSpace = resolveNameSpace;
this.buildAttributesMap = buildAttributesMap;
this.isItStopNode = isItStopNode;
this.replaceEntitiesValue = replaceEntitiesValue;
this.readStopNodeData = readStopNodeData;
this.saveTextToParentTag = saveTextToParentTag;
}
}
function addExternalEntities(externalEntities) {
const entKeys = Object.keys(externalEntities);
for(let i = 0; i < entKeys.length; i++){
const ent = entKeys[i];
this.lastEntities[ent] = {
regex: new RegExp("&" + ent + ";", "g"),
val: externalEntities[ent]
};
}
}
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
if (val !== void 0) {
if (this.options.trimValues && !dontTrim) {
val = val.trim();
}
if (val.length > 0) {
if (!escapeEntities) val = this.replaceEntitiesValue(val);
const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
if (newval === null || newval === void 0) {
return val;
} else if (typeof newval !== typeof val || newval !== val) {
return newval;
} else if (this.options.trimValues) {
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
} else {
const trimmedVal = val.trim();
if (trimmedVal === val) {
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
} else {
return val;
}
}
}
}
}
function resolveNameSpace(tagname) {
if (this.options.removeNSPrefix) {
const tags = tagname.split(":");
const prefix = tagname.charAt(0) === "/" ? "/" : "";
if (tags[0] === "xmlns") {
return "";
}
if (tags.length === 2) {
tagname = prefix + tags[1];
}
}
return tagname;
}
const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
function buildAttributesMap(attrStr, jPath) {
if (!this.options.ignoreAttributes && typeof attrStr === "string") {
const matches = util.getAllMatches(attrStr, attrsRegx);
const len = matches.length;
const attrs = {};
for(let i = 0; i < len; i++){
const attrName = this.resolveNameSpace(matches[i][1]);
let oldVal = matches[i][4];
const aName = this.options.attributeNamePrefix + attrName;
if (attrName.length) {
if (oldVal !== void 0) {
if (this.options.trimValues) {
oldVal = oldVal.trim();
}
oldVal = this.replaceEntitiesValue(oldVal);
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
if (newVal === null || newVal === void 0) {
attrs[aName] = oldVal;
} else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
attrs[aName] = newVal;
} else {
attrs[aName] = parseValue(oldVal, this.options.parseAttributeValue, this.options.numberParseOptions);
}
} else if (this.options.allowBooleanAttributes) {
attrs[aName] = true;
}
}
}
if (!Object.keys(attrs).length) {
return;
}
if (this.options.attributesGroupName) {
const attrCollection = {};
attrCollection[this.options.attributesGroupName] = attrs;
return attrCollection;
}
return attrs;
}
}
const parseXml = function(xmlData) {
xmlData = xmlData.replace(/\r\n?/g, "\n");
const xmlObj = new xmlNode("!xml");
let currentNode = xmlObj;
let textData = "";
let jPath = "";
for(let i = 0; i < xmlData.length; i++){
const ch = xmlData[i];
if (ch === "<") {
if (xmlData[i + 1] === "/") {
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
let tagName = xmlData.substring(i + 2, closeIndex).trim();
if (this.options.removeNSPrefix) {
const colonIndex = tagName.indexOf(":");
if (colonIndex !== -1) {
tagName = tagName.substr(colonIndex + 1);
}
}
if (this.options.transformTagName) {
tagName = this.options.transformTagName(tagName);
}
if (currentNode) {
textData = this.saveTextToParentTag(textData, currentNode, jPath);
}
jPath = jPath.substr(0, jPath.lastIndexOf("."));
currentNode = this.tagsNodeStack.pop();
textData = "";
i = closeIndex;
} else if (xmlData[i + 1] === "?") {
let tagData = readTagExp(xmlData, i, false, "?>");
if (!tagData) throw new Error("Pi Tag is not closed.");
textData = this.saveTextToParentTag(textData, currentNode, jPath);
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
else {
const childNode = new xmlNode(tagData.tagName);
childNode.add(this.options.textNodeName, "");
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
}
currentNode.addChild(childNode);
}
i = tagData.closeIndex + 1;
} else if (xmlData.substr(i + 1, 3) === "!--") {
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
if (this.options.commentPropName) {
const comment = xmlData.substring(i + 4, endIndex - 2);
textData = this.saveTextToParentTag(textData, currentNode, jPath);
currentNode.add(this.options.commentPropName, [
{
[this.options.textNodeName]: comment
}
]);
}
i = endIndex;
} else if (xmlData.substr(i + 1, 2) === "!D") {
const result = DocTypeReader(xmlData, i);
this.docTypeEntities = result.entities;
i = result.i;
} else if (xmlData.substr(i + 1, 2) === "![") {
const closeIndex1 = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
const tagExp = xmlData.substring(i + 9, closeIndex1);
textData = this.saveTextToParentTag(textData, currentNode, jPath);
if (this.options.cdataPropName) {
currentNode.add(this.options.cdataPropName, [
{
[this.options.textNodeName]: tagExp
}
]);
} else {
let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
if (val == void 0) val = "";
currentNode.add(this.options.textNodeName, val);
}
i = closeIndex1 + 2;
} else {
let result1 = readTagExp(xmlData, i, this.options.removeNSPrefix);
let tagName1 = result1.tagName;
let tagExp1 = result1.tagExp;
let attrExpPresent = result1.attrExpPresent;
let closeIndex2 = result1.closeIndex;
if (this.options.transformTagName) {
tagName1 = this.options.transformTagName(tagName1);
}
if (currentNode && textData) {
if (currentNode.tagname !== "!xml") {
textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
}
}
if (tagName1 !== xmlObj.tagname) {
jPath += jPath ? "." + tagName1 : tagName1;
}
const lastTag = currentNode;
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
currentNode = this.tagsNodeStack.pop();
}
if (this.isItStopNode(this.options.stopNodes, jPath, tagName1)) {
let tagContent = "";
if (tagExp1.length > 0 && tagExp1.lastIndexOf("/") === tagExp1.length - 1) {
i = result1.closeIndex;
} else if (this.options.unpairedTags.indexOf(tagName1) !== -1) {
i = result1.closeIndex;
} else {
const result2 = this.readStopNodeData(xmlData, tagName1, closeIndex2 + 1);
if (!result2) throw new Error(`Unexpected end of ${tagName1}`);
i = result2.i;
tagContent = result2.tagContent;
}
const childNode1 = new xmlNode(tagName1);
if (tagName1 !== tagExp1 && attrExpPresent) {
childNode1[":@"] = this.buildAttributesMap(tagExp1, jPath);
}
if (tagContent) {
tagContent = this.parseTextData(tagContent, tagName1, jPath, true, attrExpPresent, true, true);
}
jPath = jPath.substr(0, jPath.lastIndexOf("."));
childNode1.add(this.options.textNodeName, tagContent);
currentNode.addChild(childNode1);
} else {
if (tagExp1.length > 0 && tagExp1.lastIndexOf("/") === tagExp1.length - 1) {
if (tagName1[tagName1.length - 1] === "/") {
tagName1 = tagName1.substr(0, tagName1.length - 1);
tagExp1 = tagName1;
} else {
tagExp1 = tagExp1.substr(0, tagExp1.length - 1);
}
if (this.options.transformTagName) {
tagName1 = this.options.transformTagName(tagName1);
}
const childNode2 = new xmlNode(tagName1);
if (tagName1 !== tagExp1 && attrExpPresent) {
childNode2[":@"] = this.buildAttributesMap(tagExp1, jPath);
}
jPath = jPath.substr(0, jPath.lastIndexOf("."));
currentNode.addChild(childNode2);
} else {
const childNode3 = new xmlNode(tagName1);
this.tagsNodeStack.push(currentNode);
if (tagName1 !== tagExp1 && attrExpPresent) {
childNode3[":@"] = this.buildAttributesMap(tagExp1, jPath);
}
currentNode.addChild(childNode3);
currentNode = childNode3;
}
textData = "";
i = closeIndex2;
}
}
} else {
textData += xmlData[i];
}
}
return xmlObj.child;
};
const replaceEntitiesValue = function(val) {
if (this.options.processEntities) {
for(let entityName in this.docTypeEntities){
const entity = this.docTypeEntities[entityName];
val = val.replace(entity.regx, entity.val);
}
for(let entityName1 in this.lastEntities){
const entity1 = this.lastEntities[entityName1];
val = val.replace(entity1.regex, entity1.val);
}
if (this.options.htmlEntities) {
for(let entityName2 in this.htmlEntities){
const entity2 = this.htmlEntities[entityName2];
val = val.replace(entity2.regex, entity2.val);
}
}
val = val.replace(this.ampEntity.regex, this.ampEntity.val);
}
return val;
};
function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
if (textData) {
if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
textData = this.parseTextData(textData, currentNode.tagname, jPath, false, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false, isLeafNode);
if (textData !== void 0 && textData !== "") currentNode.add(this.options.textNodeName, textData);
textData = "";
}
return textData;
}
function isItStopNode(stopNodes, jPath, currentTagName) {
const allNodesExp = "*." + currentTagName;
for(const stopNodePath in stopNodes){
const stopNodeExp = stopNodes[stopNodePath];
if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
}
return false;
}
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
let attrBoundary;
let tagExp = "";
for(let index = i; index < xmlData.length; index++){
let ch = xmlData[index];
if (attrBoundary) {
if (ch === attrBoundary) attrBoundary = "";
} else if (ch === '"' || ch === "'") {
attrBoundary = ch;
} else if (ch === closingChar[0]) {
if (closingChar[1]) {
if (xmlData[index + 1] === closingChar[1]) {
return {
data: tagExp,
index
};
}
} else {
return {
data: tagExp,
index
};
}
} else if (ch === " ") {
ch = " ";
}
tagExp += ch;
}
}
function findClosingIndex(xmlData, str, i, errMsg) {
const closingIndex = xmlData.indexOf(str, i);
if (closingIndex === -1) {
throw new Error(errMsg);
} else {
return closingIndex + str.length - 1;
}
}
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
if (!result) return;
let tagExp = result.data;
const closeIndex = result.index;
const separatorIndex = tagExp.search(/\s/);
let tagName = tagExp;
let attrExpPresent = true;
if (separatorIndex !== -1) {
tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, "");
tagExp = tagExp.substr(separatorIndex + 1);
}
if (removeNSPrefix) {
const colonIndex = tagName.indexOf(":");
if (colonIndex !== -1) {
tagName = tagName.substr(colonIndex + 1);
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
}
}
return {
tagName,
tagExp,
closeIndex,
attrExpPresent
};
}
function readStopNodeData(xmlData, tagName, i) {
const startIndex = i;
let openTagCount = 1;
for(; i < xmlData.length; i++){
if (xmlData[i] === "<") {
if (xmlData[i + 1] === "/") {
const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
if (closeTagName === tagName) {
openTagCount--;
if (openTagCount === 0) {
return {
tagContent: xmlData.substring(startIndex, i),
i: closeIndex
};
}
}
i = closeIndex;
} else if (xmlData[i + 1] === "?") {
const closeIndex1 = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
i = closeIndex1;
} else if (xmlData.substr(i + 1, 3) === "!--") {
const closeIndex2 = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
i = closeIndex2;
} else if (xmlData.substr(i + 1, 2) === "![") {
const closeIndex3 = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
i = closeIndex3;
} else {
const tagData = readTagExp(xmlData, i, ">");
if (tagData) {
const openTagName = tagData && tagData.tagName;
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
openTagCount++;
}
i = tagData.closeIndex;
}
}
}
}
}
function parseValue(val, shouldParse, options) {
if (shouldParse && typeof val === "string") {
const newval = val.trim();
if (newval === "true") return true;
else if (newval === "false") return false;
else return strnum(val, options);
} else {
if (util.isExist(val)) {
return val;
} else {
return "";
}
}
}
var OrderedObjParser_1 = OrderedObjParser;
function prettify(node, options) {
return compress(node, options);
}
function compress(arr, options, jPath) {
let text;
const compressedObj = {};
for(let i = 0; i < arr.length; i++){
const tagObj = arr[i];
const property = propName(tagObj);
let newJpath = "";
if (jPath === void 0) newJpath = property;
else newJpath = jPath + "." + property;
if (property === options.textNodeName) {
if (text === void 0) text = tagObj[property];
else text += "" + tagObj[property];
} else if (property === void 0) {
continue;
} else if (tagObj[property]) {
let val = compress(tagObj[property], options, newJpath);
const isLeaf = isLeafTag(val, options);
if (tagObj[":@"]) {
assignAttributes(val, tagObj[":@"], newJpath, options);
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
val = val[options.textNodeName];
} else if (Object.keys(val).length === 0) {
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
else val = "";
}
if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
if (!Array.isArray(compressedObj[property])) {
compressedObj[property] = [
compressedObj[property]
];
}
compressedObj[property].push(val);
} else {
if (options.isArray(property, newJpath, isLeaf)) {
compressedObj[property] = [
val
];
} else {
compressedObj[property] = val;
}
}
}
}
if (typeof text === "string") {
if (text.length > 0) compressedObj[options.textNodeName] = text;
} else if (text !== void 0) compressedObj[options.textNodeName] = text;
return compressedObj;
}
function propName(obj) {
const keys = Object.keys(obj);
for(let i = 0; i < keys.length; i++){
const key = keys[i];
if (key !== ":@") return key;
}
}
function assignAttributes(obj, attrMap, jpath, options) {
if (attrMap) {
const keys = Object.keys(attrMap);
const len = keys.length;
for(let i = 0; i < len; i++){
const atrrName = keys[i];
if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
obj[atrrName] = [
attrMap[atrrName]
];
} else {
obj[atrrName] = attrMap[atrrName];
}
}
}
}
function isLeafTag(obj, options) {
const propCount = Object.keys(obj).length;
if (propCount === 0 || propCount === 1 && obj[options.textNodeName]) return true;
return false;
}
var prettify_1 = prettify;
var node2json = {
prettify: prettify_1
};
const { buildOptions: buildOptions$1 } = OptionsBuilder;
const { prettify: prettify$1 } = node2json;
class XMLParser {
constructor(options){
this.externalEntities = {};
this.options = buildOptions$1(options);
}
parse(xmlData, validationOption) {
if (typeof xmlData === "string") ;
else if (xmlData.toString) {
xmlData = xmlData.toString();
} else {
throw new Error("XML data is accepted in String or Bytes[] form.");
}
if (validationOption) {
if (validationOption === true) validationOption = {};
const result = validator.validate(xmlData, validationOption);
if (result !== true) {
throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
}
}
const orderedObjParser = new OrderedObjParser_1(this.options);
orderedObjParser.addExternalEntities(this.externalEntities);
const orderedResult = orderedObjParser.parseXml(xmlData);
if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
else return prettify$1(orderedResult, this.options);
}
addEntity(key, value) {
if (value.indexOf("&") !== -1) {
throw new Error("Entity value can't have '&'");
} else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
} else if (value === "&") {
throw new Error("An entity with value '&' is not permitted");
} else {
this.externalEntities[key] = value;
}
}
}
var XMLParser_1 = XMLParser;
const EOL = "\n";
function toXml(jArray, options) {
return arrToStr(jArray, options, "", 0);
}
function arrToStr(arr, options, jPath, level) {
let xmlStr = "";
let indentation = "";
if (options.format && options.indentBy.length > 0) {
indentation = EOL + "" + options.indentBy.repeat(level);
}
for(let i = 0; i < arr.length; i++){
const tagObj = arr[i];
const tagName = propName$1(tagObj);
let newJPath = "";
if (jPath.length === 0) newJPath = tagName;
else newJPath = `${jPath}.${tagName}`;
if (tagName === options.textNodeName) {
let tagText = tagObj[tagName];
if (!isStopNode(newJPath, options)) {
tagText = options.tagValueProcessor(tagName, tagText);
tagText = replaceEntitiesValue$1(tagText, options);
}
xmlStr += indentation + tagText;
continue;
} else if (tagName === options.cdataPropName) {
xmlStr += indentation + `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
continue;
} else if (tagName === options.commentPropName) {
xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
continue;
} else if (tagName[0] === "?") {
const attStr2 = attr_to_str(tagObj[":@"], options);
const tempInd = tagName === "?xml" ? "" : indentation;
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
continue;
}
const attStr = attr_to_str(tagObj[":@"], options);
let tagStart = indentation + `<${tagName}${attStr}`;
let tagValue = arrToStr(tagObj[tagName], options, newJPath, level + 1);
if (options.unpairedTags.indexOf(tagName) !== -1) {
if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
else xmlStr += tagStart + "/>";
} else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
xmlStr += tagStart + "/>";
} else {
xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
}
}
return xmlStr;
}
function propName$1(obj) {
const keys = Object.keys(obj);
for(let i = 0; i < keys.length; i++){
const key = keys[i];
if (key !== ":@") return key;
}
}
function attr_to_str(attrMap, options) {
let attrStr = "";
if (attrMap && !options.ignoreAttributes) {
for(let attr in attrMap){
let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
attrVal = replaceEntitiesValue$1(attrVal, options);
if (attrVal === true && options.suppressBooleanAttributes) {
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
} else {
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
}
}
}
return attrStr;
}
function isStopNode(jPath, options) {
jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
for(let index in options.stopNodes){
if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
}
return false;
}
function replaceEntitiesValue$1(textValue, options) {
if (textValue && textValue.length > 0 && options.processEntities) {
for(let i = 0; i < options.entities.length; i++){
const entity = options.entities[i];
textValue = textValue.replace(entity.regex, entity.val);
}
}
return textValue;
}
var orderedJs2Xml = toXml;
const defaultOptions$2 = {
attributeNamePrefix: "@_",
attributesGroupName: false,
textNodeName: "#text",
ignoreAttributes: true,
cdataPropName: false,
format: false,
indentBy: " ",
suppressEmptyNode: false,
suppressUnpairedNode: true,
suppressBooleanAttributes: true,
tagValueProcessor: function(key, a) {
return a;
},
attributeValueProcessor: function(attrName, a) {
return a;
},
preserveOrder: false,
commentPropName: false,
unpairedTags: [],
entities: [
{
regex: new RegExp("&", "g"),
val: "&amp;"
},
{
regex: new RegExp(">", "g"),
val: "&gt;"
},
{
regex: new RegExp("<", "g"),
val: "&lt;"
},
{
regex: new RegExp("'", "g"),
val: "&apos;"
},
{
regex: new RegExp('"', "g"),
val: "&quot;"
}
],
processEntities: true,
stopNodes: [],
transformTagName: false
};
function Builder(options) {
this.options = Object.assign({}, defaultOptions$2, options);
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
this.isAttribute = function() {
return false;
};
} else {
this.attrPrefixLen = this.options.attributeNamePrefix.length;
this.isAttribute = isAttribute;
}
this.processTextOrObjNode = processTextOrObjNode;
if (this.options.format) {
this.indentate = indentate;
this.tagEndChar = ">\n";
this.newLine = "\n";
} else {
this.indentate = function() {
return "";
};
this.tagEndChar = ">";
this.newLine = "";
}
if (this.options.suppressEmptyNode) {
this.buildTextNode = buildEmptyTextNode;
this.buildObjNode = buildEmptyObjNode;
} else {
this.buildTextNode = buildTextValNode;
this.buildObjNode = buildObjectNode;
}
this.buildTextValNode = buildTextValNode;
this.buildObjectNode = buildObjectNode;
this.replaceEntitiesValue = replaceEntitiesValue$2;
this.buildAttrPairStr = buildAttrPairStr;
}
Builder.prototype.build = function(jObj) {
if (this.options.preserveOrder) {
return orderedJs2Xml(jObj, this.options);
} else {
if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
jObj = {
[this.options.arrayNodeName]: jObj
};
}
return this.j2x(jObj, 0).val;
}
};
Builder.prototype.j2x = function(jObj, level) {
let attrStr = "";
let val = "";
for(let key in jObj){
if (typeof jObj[key] === "undefined") ;
else if (jObj[key] === null) {
if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
} else if (jObj[key] instanceof Date) {
val += this.buildTextNode(jObj[key], key, "", level);
} else if (typeof jObj[key] !== "object") {
const attr = this.isAttribute(key);
if (attr) {
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
} else {
if (key === this.options.textNodeName) {
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
val += this.replaceEntitiesValue(newval);
} else {
val += this.buildTextNode(jObj[key], key, "", level);
}
}
} else if (Array.isArray(jObj[key])) {
const arrLen = jObj[key].length;
for(let j = 0; j < arrLen; j++){
const item = jObj[key][j];
if (typeof item === "undefined") ;
else if (item === null) {
if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
} else if (typeof item === "object") {
val += this.processTextOrObjNode(item, key, level);
} else {
val += this.buildTextNode(item, key, "", level);
}
}
} else {
if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
const Ks = Object.keys(jObj[key]);
const L = Ks.length;
for(let j1 = 0; j1 < L; j1++){
attrStr += this.buildAttrPairStr(Ks[j1], "" + jObj[key][Ks[j1]]);
}
} else {
val += this.processTextOrObjNode(jObj[key], key, level);
}
}
}
return {
attrStr,
val
};
};
function buildAttrPairStr(attrName, val) {
val = this.options.attributeValueProcessor(attrName, "" + val);
val = this.replaceEntitiesValue(val);
if (this.options.suppressBooleanAttributes && val === "true") {
return " " + attrName;
} else return " " + attrName + '="' + val + '"';
}
function processTextOrObjNode(object, key, level) {
const result = this.j2x(object, level + 1);
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level);
} else {
return this.buildObjNode(result.val, key, result.attrStr, level);
}
}
function buildObjectNode(val, key, attrStr, level) {
let tagEndExp = "</" + key + this.tagEndChar;
let piClosingChar = "";
if (key[0] === "?") {
piClosingChar = "?";
tagEndExp = "";
}
if (attrStr && val.indexOf("<") === -1) {
return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
return this.indentate(level) + `<!--${val}-->` + this.newLine;
} else {
return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
}
}
function buildEmptyObjNode(val, key, attrStr, level) {
if (val !== "") {
return this.buildObjectNode(val, key, attrStr, level);
} else {
if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
else return this.indentate(level) + "<" + key + attrStr + "/" + this.tagEndChar;
}
}
function buildTextValNode(val, key, attrStr, level) {
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
} else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
return this.indentate(level) + `<!--${val}-->` + this.newLine;
} else {
let textValue = this.options.tagValueProcessor(key, val);
textValue = this.replaceEntitiesValue(textValue);
if (textValue === "" && this.options.unpairedTags.indexOf(key) !== -1) {
if (this.options.suppressUnpairedNode) {
return this.indentate(level) + "<" + key + this.tagEndChar;
} else {
return this.indentate(level) + "<" + key + "/" + this.tagEndChar;
}
} else {
return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
}
}
}
function replaceEntitiesValue$2(textValue) {
if (textValue && textValue.length > 0 && this.options.processEntities) {
for(let i = 0; i < this.options.entities.length; i++){
const entity = this.options.entities[i];
textValue = textValue.replace(entity.regex, entity.val);
}
}
return textValue;
}
function buildEmptyTextNode(val, key, attrStr, level) {
if (val === "" && this.options.unpairedTags.indexOf(key) !== -1) {
if (this.options.suppressUnpairedNode) {
return this.indentate(level) + "<" + key + this.tagEndChar;
} else {
return this.indentate(level) + "<" + key + "/" + this.tagEndChar;
}
} else if (val !== "") {
return this.buildTextValNode(val, key, attrStr, level);
} else {
if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
else return this.indentate(level) + "<" + key + attrStr + "/" + this.tagEndChar;
}
}
function indentate(level) {
return this.options.indentBy.repeat(level);
}
function isAttribute(name) {
if (name.startsWith(this.options.attributeNamePrefix)) {
return name.substr(this.attrPrefixLen);
} else {
return false;
}
}
var json2xml = Builder;
var fxp = {
XMLParser: XMLParser_1,
XMLValidator: validator,
XMLBuilder: json2xml
};
fxp.XMLBuilder;
fxp.XMLParser;
fxp.XMLValidator;
const validate1 = (str)=>typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
var SelectorType;
(function(SelectorType2) {
SelectorType2["ENV"] = "env";
SelectorType2["CONFIG"] = "shared config entry";
})(SelectorType || (SelectorType = {}));
const S3_HOSTNAME_PATTERN = /^(.+\.)?s3(-fips)?(\.dualstack)?[.-]([a-z0-9-]+)\./;
const S3_US_EAST_1_ALTNAME_PATTERN = /^s3(-external-1)?\.amazonaws\.com$/;
const AWS_PARTITION_SUFFIX = "amazonaws.com";
const getRegionalSuffix = (hostname)=>{
const parts = hostname.match(S3_HOSTNAME_PATTERN);
return [
parts[4],
hostname.replace(new RegExp(`^${parts[0]}`), "")
];
};
const getSuffixForArnEndpoint = (hostname)=>S3_US_EAST_1_ALTNAME_PATTERN.test(hostname) ? [
hostname.replace(`.${AWS_PARTITION_SUFFIX}`, ""),
AWS_PARTITION_SUFFIX
] : getRegionalSuffix(hostname);
const CONTENT_LENGTH_HEADER = "content-length";
function checkContentLengthHeader() {
return (next, context)=>async (args)=>{
var _a;
const { request } = args;
if (HttpRequest.isInstance(request)) {
if (!request.headers[CONTENT_LENGTH_HEADER]) {
const message = `Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.`;
if (typeof ((_a = context == null ? void 0 : context.logger) == null ? void 0 : _a.warn) === "function") {
context.logger.warn(message);
} else {
console.warn(message);
}
}
}
return next({
...args
});
};
}
const checkContentLengthHeaderMiddlewareOptions = {
step: "finalizeRequest",
tags: [
"CHECK_CONTENT_LENGTH_HEADER"
],
name: "getCheckContentLengthHeaderPlugin",
override: true
};
const getCheckContentLengthHeaderPlugin = (unused)=>({
applyToStack: (clientStack)=>{
clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
}
});
const resolveS3Config = (input)=>{
var _a, _b, _c;
return {
...input,
forcePathStyle: (_a = input.forcePathStyle) != null ? _a : false,
useAccelerateEndpoint: (_b = input.useAccelerateEndpoint) != null ? _b : false,
disableMultiregionAccessPoints: (_c = input.disableMultiregionAccessPoints) != null ? _c : false
};
};
const throw200ExceptionsMiddleware = (config)=>(next)=>async (args)=>{
const result = await next(args);
const { response } = result;
if (!HttpResponse.isInstance(response)) return result;
const { statusCode , body } = response;
if (statusCode < 200 || statusCode >= 300) return result;
const bodyBytes = await collectBody(body, config);
const bodyString = await collectBodyString(bodyBytes, config);
if (bodyBytes.length === 0) {
const err = new Error("S3 aborted request");
err.name = "InternalError";
throw err;
}
if (bodyString && bodyString.match("<Error>")) {
response.statusCode = 400;
}
response.body = bodyBytes;
return result;
};
const collectBody = (streamBody = new Uint8Array(), context)=>{
if (streamBody instanceof Uint8Array) {
return Promise.resolve(streamBody);
}
return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
};
const collectBodyString = (streamBody, context)=>collectBody(streamBody, context).then((body)=>context.utf8Encoder(body));
const throw200ExceptionsMiddlewareOptions = {
relation: "after",
toMiddleware: "deserializerMiddleware",
tags: [
"THROW_200_EXCEPTIONS",
"S3"
],
name: "throw200ExceptionsMiddleware",
override: true
};
const getThrow200ExceptionsPlugin = (config)=>({
applyToStack: (clientStack)=>{
clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);
}
});
function validateBucketNameMiddleware() {
return (next)=>async (args)=>{
const { input: { Bucket } } = args;
if (typeof Bucket === "string" && !validate1(Bucket) && Bucket.indexOf("/") >= 0) {
const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`);
err.name = "InvalidBucketName";
throw err;
}
return next({
...args
});
};
}
const validateBucketNameMiddlewareOptions = {
step: "initialize",
tags: [
"VALIDATE_BUCKET_NAME"
],
name: "validateBucketNameMiddleware",
override: true
};
const getValidateBucketNamePlugin = (unused)=>({
applyToStack: (clientStack)=>{
clientStack.add(validateBucketNameMiddleware(), validateBucketNameMiddlewareOptions);
}
});
const writeGetObjectResponseEndpointMiddleware = (config)=>(next, context)=>async (args)=>{
const { region: regionProvider , isCustomEndpoint , disableHostPrefix } = config;
const region = await regionProvider();
const { request , input } = args;
if (!HttpRequest.isInstance(request)) return next({
...args
});
let hostname = request.hostname;
if (hostname.endsWith("s3.amazonaws.com") || hostname.endsWith("s3-external-1.amazonaws.com")) {
return next({
...args
});
}
if (!isCustomEndpoint) {
const [, suffix] = getSuffixForArnEndpoint(request.hostname);
hostname = `s3-object-lambda.${region}.${suffix}`;
}
if (!disableHostPrefix && input.RequestRoute) {
hostname = `${input.RequestRoute}.${hostname}`;
}
request.hostname = hostname;
context["signing_service"] = "s3-object-lambda";
if (config.runtime === "node" && !request.headers["content-length"]) {
request.headers["transfer-encoding"] = "chunked";
}
return next({
...args
});
};
const writeGetObjectResponseEndpointMiddlewareOptions = {
relation: "after",
toMiddleware: "contentLengthMiddleware",
tags: [
"WRITE_GET_OBJECT_RESPONSE",
"S3",
"ENDPOINT"
],
name: "writeGetObjectResponseEndpointMiddleware",
override: true
};
const getWriteGetObjectResponseEndpointPlugin = (config)=>({
applyToStack: (clientStack)=>{
clientStack.addRelativeTo(writeGetObjectResponseEndpointMiddleware(config), writeGetObjectResponseEndpointMiddlewareOptions);
}
});
function ssecMiddleware(options) {
return (next)=>async (args)=>{
let input = {
...args.input
};
const properties = [
{
target: "SSECustomerKey",
hash: "SSECustomerKeyMD5"
},
{
target: "CopySourceSSECustomerKey",
hash: "CopySourceSSECustomerKeyMD5"
}
];
for (const prop of properties){
const value = input[prop.target];
if (value) {
const valueView = ArrayBuffer.isView(value) ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : typeof value === "string" ? options.utf8Decoder(value) : new Uint8Array(value);
const encoded = options.base64Encoder(valueView);
const hash = new options.md5();
hash.update(valueView);
input = {
...input,
[prop.target]: encoded,
[prop.hash]: options.base64Encoder(await hash.digest())
};
}
}
return next({
...args,
input
});
};
}
const ssecMiddlewareOptions = {
name: "ssecMiddleware",
step: "initialize",
tags: [
"SSE"
],
override: true
};
const getSsecPlugin = (config)=>({
applyToStack: (clientStack)=>{
clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
}
});
function locationConstraintMiddleware(options) {
return (next)=>async (args)=>{
const { CreateBucketConfiguration } = args.input;
const region = await options.region();
if (!CreateBucketConfiguration || !CreateBucketConfiguration.LocationConstraint) {
args = {
...args,
input: {
...args.input,
CreateBucketConfiguration: region === "us-east-1" ? void 0 : {
LocationConstraint: region
}
}
};
}
return next(args);
};
}
const locationConstraintMiddlewareOptions = {
step: "initialize",
tags: [
"LOCATION_CONSTRAINT",
"CREATE_BUCKET_CONFIGURATION"
],
name: "locationConstraintMiddleware",
override: true
};
const getLocationConstraintPlugin = (config)=>({
applyToStack: (clientStack)=>{
clientStack.add(locationConstraintMiddleware(config), locationConstraintMiddlewareOptions);
}
});
const isArrayBuffer = (arg)=>typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf || ({
__proto__: []
}) instanceof Array && function(d2, b2) {
// d2.__proto__ = b2;
Object.setPrototypeOf(d2, b2);
} || function(d2, b2) {
for(var p in b2)if (b2.hasOwnProperty(p)) d2[p] = b2[p];
};
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign2(t) {
for(var s, i = 1, n = arguments.length; i < n; i++){
s = arguments[i];
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++){
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = {
label: 0,
sent: function() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
}, f, y, t, g;
return g = {
next: verb(0),
throw: verb(1),
return: verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
return function(v) {
return step([
n,
v
]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while(_)try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [
op[0] & 2,
t.value
];
switch(op[0]){
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return {
value: op[1],
done: false
};
case 5:
_.label++;
y = op[1];
op = [
0
];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [
6,
e
];
y = 0;
} finally{
f = t = 0;
}
if (op[0] & 5) throw op[1];
return {
value: op[0] ? op[1] : void 0,
done: true
};
}
}
function __createBinding(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
}
function __exportStar(m, exports) {
for(var p in m)if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function() {
if (o && i >= o.length) o = void 0;
return {
value: o && o[i++],
done: !o
};
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value);
} catch (error) {
e = {
error
};
} finally{
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally{
if (e) throw e.error;
}
}
return ar;
}
function __spread() {
for(var ar = [], i = 0; i < arguments.length; i++)ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for(var s = 0, i = 0, il = arguments.length; i < il; i++)s += arguments[i].length;
for(var r = Array(s), k = 0, i = 0; i < il; i++)for(var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)r[k] = a[j];
return r;
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function verb(n) {
if (g[n]) i[n] = function(v) {
return new Promise(function(a, b) {
q.push([
n,
v,
a,
b
]) > 1 || resume(n, v);
});
};
}
function resume(n, v) {
try {
step(g[n](v));
} catch (e) {
settle(q[0][3], e);
}
}
function step(r) {
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
}
function fulfill(value) {
resume("next", value);
}
function reject(value) {
resume("throw", value);
}
function settle(f, v) {
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
}
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function(e) {
throw e;
}), verb("return"), i[Symbol.iterator] = function() {
return this;
}, i;
function verb(n, f) {
i[n] = o[n] ? function(v) {
return (p = !p) ? {
value: __await(o[n](v)),
done: n === "return"
} : f ? f(v) : v;
} : f;
}
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i);
function verb(n) {
i[n] = o[n] && function(v) {
return new Promise(function(resolve, reject) {
v = o[n](v), settle(resolve, reject, v.done, v.value);
});
};
}
function settle(resolve, reject, d, v) {
Promise.resolve(v).then(function(v2) {
resolve({
value: v2,
done: d
});
}, reject);
}
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", {
value: raw
});
} else {
cooked.raw = raw;
}
return cooked;
}
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for(var k in mod)if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
}
result.default = mod;
return result;
}
function __importDefault(mod) {
return mod && mod.__esModule ? mod : {
default: mod
};
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
const mod = function() {
return {
__assign: __assign,
__asyncDelegator: __asyncDelegator,
__asyncGenerator: __asyncGenerator,
__asyncValues: __asyncValues,
__await: __await,
__awaiter: __awaiter,
__classPrivateFieldGet: __classPrivateFieldGet,
__classPrivateFieldSet: __classPrivateFieldSet,
__createBinding: __createBinding,
__decorate: __decorate,
__exportStar: __exportStar,
__extends: __extends,
__generator: __generator,
__importDefault: __importDefault,
__importStar: __importStar,
__makeTemplateObject: __makeTemplateObject,
__metadata: __metadata,
__param: __param,
__read: __read,
__rest: __rest,
__spread: __spread,
__spreadArrays: __spreadArrays,
__values: __values,
default: null
};
}();
var fromUtf8 = function(input) {
var bytes = [];
for(var i = 0, len = input.length; i < len; i++){
var value = input.charCodeAt(i);
if (value < 128) {
bytes.push(value);
} else if (value < 2048) {
bytes.push(value >> 6 | 192, value & 63 | 128);
} else if (i + 1 < input.length && (value & 64512) === 55296 && (input.charCodeAt(i + 1) & 64512) === 56320) {
var surrogatePair = 65536 + ((value & 1023) << 10) + (input.charCodeAt(++i) & 1023);
bytes.push(surrogatePair >> 18 | 240, surrogatePair >> 12 & 63 | 128, surrogatePair >> 6 & 63 | 128, surrogatePair & 63 | 128);
} else {
bytes.push(value >> 12 | 224, value >> 6 & 63 | 128, value & 63 | 128);
}
}
return Uint8Array.from(bytes);
};
var toUtf8 = function(input) {
var decoded = "";
for(var i = 0, len = input.length; i < len; i++){
var __byte = input[i];
if (__byte < 128) {
decoded += String.fromCharCode(__byte);
} else if (192 <= __byte && __byte < 224) {
var nextByte = input[++i];
decoded += String.fromCharCode((__byte & 31) << 6 | nextByte & 63);
} else if (240 <= __byte && __byte < 365) {
var surrogatePair = [
__byte,
input[++i],
input[++i],
input[++i]
];
var encoded = "%" + surrogatePair.map(function(byteValue) {
return byteValue.toString(16);
}).join("%");
decoded += decodeURIComponent(encoded);
} else {
decoded += String.fromCharCode((__byte & 15) << 12 | (input[++i] & 63) << 6 | input[++i] & 63);
}
}
return decoded;
};
function fromUtf8$1(input) {
return new TextEncoder().encode(input);
}
function toUtf8$1(input) {
return new TextDecoder("utf-8").decode(input);
}
var fromUtf8$2 = function(input) {
return typeof TextEncoder === "function" ? fromUtf8$1(input) : fromUtf8(input);
};
var toUtf8$2 = function(input) {
return typeof TextDecoder === "function" ? toUtf8$1(input) : toUtf8(input);
};
const mod1 = function() {
return {
fromUtf8: fromUtf8$2,
toUtf8: toUtf8$2,
default: null
};
}();
function getDefaultExportFromCjs(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule1(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire1(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire1() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
var lookup = [];
var revLookup = [];
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
var inited = false;
function init() {
inited = true;
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for(var i = 0, len = code.length; i < len; ++i){
lookup[i] = code[i];
revLookup[code.charCodeAt(i)] = i;
}
revLookup["-".charCodeAt(0)] = 62;
revLookup["_".charCodeAt(0)] = 63;
}
function toByteArray(b64) {
if (!inited) {
init();
}
var i, j, l, tmp, placeHolders, arr;
var len = b64.length;
if (len % 4 > 0) {
throw new Error("Invalid string. Length must be a multiple of 4");
}
placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
arr = new Arr(len * 3 / 4 - placeHolders);
l = placeHolders > 0 ? len - 4 : len;
var L = 0;
for(i = 0, j = 0; i < l; i += 4, j += 3){
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
arr[L++] = tmp >> 16 & 255;
arr[L++] = tmp >> 8 & 255;
arr[L++] = tmp & 255;
}
if (placeHolders === 2) {
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
arr[L++] = tmp & 255;
} else if (placeHolders === 1) {
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
arr[L++] = tmp >> 8 & 255;
arr[L++] = tmp & 255;
}
return arr;
}
function tripletToBase64(num) {
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
}
function encodeChunk(uint8, start, end) {
var tmp;
var output = [];
for(var i = start; i < end; i += 3){
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
output.push(tripletToBase64(tmp));
}
return output.join("");
}
function fromByteArray(uint8) {
if (!inited) {
init();
}
var tmp;
var len = uint8.length;
var extraBytes = len % 3;
var output = "";
var parts = [];
var maxChunkLength = 16383;
for(var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength){
parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
}
if (extraBytes === 1) {
tmp = uint8[len - 1];
output += lookup[tmp >> 2];
output += lookup[tmp << 4 & 63];
output += "==";
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
output += lookup[tmp >> 10];
output += lookup[tmp >> 4 & 63];
output += lookup[tmp << 2 & 63];
output += "=";
}
parts.push(output);
return parts.join("");
}
function read(buffer, offset, isLE, mLen, nBytes) {
var e, m;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i = isLE ? nBytes - 1 : 0;
var d = isLE ? -1 : 1;
var s = buffer[offset + i];
i += d;
e = s & (1 << -nBits) - 1;
s >>= -nBits;
nBits += eLen;
for(; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){}
m = e & (1 << -nBits) - 1;
e >>= -nBits;
nBits += mLen;
for(; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){}
if (e === 0) {
e = 1 - eBias;
} else if (e === eMax) {
return m ? NaN : (s ? -1 : 1) * Infinity;
} else {
m = m + Math.pow(2, mLen);
e = e - eBias;
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
}
function write(buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
var i = isLE ? 0 : nBytes - 1;
var d = isLE ? 1 : -1;
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e = eMax;
} else {
e = Math.floor(Math.log(value) / Math.LN2);
if (value * (c = Math.pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) {
value += rt / c;
} else {
value += rt * Math.pow(2, 1 - eBias);
}
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen);
e = e + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e = 0;
}
}
for(; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8){}
e = e << mLen | m;
eLen += mLen;
for(; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8){}
buffer[offset + i - d] |= s * 128;
}
var toString = {}.toString;
var isArray = Array.isArray || function(arr) {
return toString.call(arr) == "[object Array]";
};
var INSPECT_MAX_BYTES = 50;
Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== void 0 ? global$1.TYPED_ARRAY_SUPPORT : true;
function kMaxLength() {
return Buffer.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
}
function createBuffer(that, length) {
if (kMaxLength() < length) {
throw new RangeError("Invalid typed array length");
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
that = new Uint8Array(length);
// that.__proto__ = Buffer.prototype; // MANUALLY CHANGED BY JOE
Object.setPrototypeOf(that, Buffer.prototype)
} else {
if (that === null) {
that = new Buffer(length);
}
that.length = length;
}
return that;
}
function Buffer(arg, encodingOrOffset, length) {
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
return new Buffer(arg, encodingOrOffset, length);
}
if (typeof arg === "number") {
if (typeof encodingOrOffset === "string") {
throw new Error("If encoding is specified then the first argument must be a string");
}
return allocUnsafe(this, arg);
}
return from(this, arg, encodingOrOffset, length);
}
Buffer.poolSize = 8192;
Buffer._augment = function(arr) {
// arr.__proto__ = Buffer.prototype;
Object.setPrototypeOf(arr, Buffer.prototype);
return arr;
};
function from(that, value, encodingOrOffset, length) {
if (typeof value === "number") {
throw new TypeError('"value" argument must not be a number');
}
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
return fromArrayBuffer(that, value, encodingOrOffset, length);
}
if (typeof value === "string") {
return fromString(that, value, encodingOrOffset);
}
return fromObject(that, value);
}
Buffer.from = function(value, encodingOrOffset, length) {
return from(null, value, encodingOrOffset, length);
};
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Buffer.prototype.__proto__ = Uint8Array.prototype;
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
// Buffer.__proto__ = Uint8Array;
Object.setPrototypeOf(Buffer, Uint8Array);
}
function assertSize(size) {
if (typeof size !== "number") {
throw new TypeError('"size" argument must be a number');
} else if (size < 0) {
throw new RangeError('"size" argument must not be negative');
}
}
function alloc(that, size, fill2, encoding) {
assertSize(size);
if (size <= 0) {
return createBuffer(that, size);
}
if (fill2 !== void 0) {
return typeof encoding === "string" ? createBuffer(that, size).fill(fill2, encoding) : createBuffer(that, size).fill(fill2);
}
return createBuffer(that, size);
}
Buffer.alloc = function(size, fill2, encoding) {
return alloc(null, size, fill2, encoding);
};
function allocUnsafe(that, size) {
assertSize(size);
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
if (!Buffer.TYPED_ARRAY_SUPPORT) {
for(var i = 0; i < size; ++i){
that[i] = 0;
}
}
return that;
}
Buffer.allocUnsafe = function(size) {
return allocUnsafe(null, size);
};
Buffer.allocUnsafeSlow = function(size) {
return allocUnsafe(null, size);
};
function fromString(that, string, encoding) {
if (typeof encoding !== "string" || encoding === "") {
encoding = "utf8";
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('"encoding" must be a valid string encoding');
}
var length = byteLength(string, encoding) | 0;
that = createBuffer(that, length);
var actual = that.write(string, encoding);
if (actual !== length) {
that = that.slice(0, actual);
}
return that;
}
function fromArrayLike(that, array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0;
that = createBuffer(that, length);
for(var i = 0; i < length; i += 1){
that[i] = array[i] & 255;
}
return that;
}
function fromArrayBuffer(that, array, byteOffset, length) {
array.byteLength;
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError("'offset' is out of bounds");
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError("'length' is out of bounds");
}
if (byteOffset === void 0 && length === void 0) {
array = new Uint8Array(array);
} else if (length === void 0) {
array = new Uint8Array(array, byteOffset);
} else {
array = new Uint8Array(array, byteOffset, length);
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
that = array;
// that.__proto__ = Buffer.prototype;
Object.setPrototypeOf(that, Buffer.prototype);
} else {
that = fromArrayLike(that, array);
}
return that;
}
function fromObject(that, obj) {
if (internalIsBuffer(obj)) {
var len = checked(obj.length) | 0;
that = createBuffer(that, len);
if (that.length === 0) {
return that;
}
obj.copy(that, 0, 0, len);
return that;
}
if (obj) {
if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
if (typeof obj.length !== "number" || isnan(obj.length)) {
return createBuffer(that, 0);
}
return fromArrayLike(that, obj);
}
if (obj.type === "Buffer" && isArray(obj.data)) {
return fromArrayLike(that, obj.data);
}
}
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
}
function checked(length) {
if (length >= kMaxLength()) {
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
}
return length | 0;
}
Buffer.isBuffer = isBuffer;
function internalIsBuffer(b) {
return !!(b != null && b._isBuffer);
}
Buffer.compare = function compare(a, b) {
if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
throw new TypeError("Arguments must be Buffers");
}
if (a === b) return 0;
var x = a.length;
var y = b.length;
for(var i = 0, len = Math.min(x, y); i < len; ++i){
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y) return -1;
if (y < x) return 1;
return 0;
};
Buffer.isEncoding = function isEncoding(encoding) {
switch(String(encoding).toLowerCase()){
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return true;
default:
return false;
}
};
Buffer.concat = function concat(list, length) {
if (!isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
if (list.length === 0) {
return Buffer.alloc(0);
}
var i;
if (length === void 0) {
length = 0;
for(i = 0; i < list.length; ++i){
length += list[i].length;
}
}
var buffer = Buffer.allocUnsafe(length);
var pos = 0;
for(i = 0; i < list.length; ++i){
var buf = list[i];
if (!internalIsBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
buf.copy(buffer, pos);
pos += buf.length;
}
return buffer;
};
function byteLength(string, encoding) {
if (internalIsBuffer(string)) {
return string.length;
}
if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength;
}
if (typeof string !== "string") {
string = "" + string;
}
var len = string.length;
if (len === 0) return 0;
var loweredCase = false;
for(;;){
switch(encoding){
case "ascii":
case "latin1":
case "binary":
return len;
case "utf8":
case "utf-8":
case void 0:
return utf8ToBytes(string).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return len * 2;
case "hex":
return len >>> 1;
case "base64":
return base64ToBytes(string).length;
default:
if (loweredCase) return utf8ToBytes(string).length;
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
}
Buffer.byteLength = byteLength;
function slowToString(encoding, start, end) {
var loweredCase = false;
if (start === void 0 || start < 0) {
start = 0;
}
if (start > this.length) {
return "";
}
if (end === void 0 || end > this.length) {
end = this.length;
}
if (end <= 0) {
return "";
}
end >>>= 0;
start >>>= 0;
if (end <= start) {
return "";
}
if (!encoding) encoding = "utf8";
while(true){
switch(encoding){
case "hex":
return hexSlice(this, start, end);
case "utf8":
case "utf-8":
return utf8Slice(this, start, end);
case "ascii":
return asciiSlice(this, start, end);
case "latin1":
case "binary":
return latin1Slice(this, start, end);
case "base64":
return base64Slice(this, start, end);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return utf16leSlice(this, start, end);
default:
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
encoding = (encoding + "").toLowerCase();
loweredCase = true;
}
}
}
Buffer.prototype._isBuffer = true;
function swap(b, n, m) {
var i = b[n];
b[n] = b[m];
b[m] = i;
}
Buffer.prototype.swap16 = function swap16() {
var len = this.length;
if (len % 2 !== 0) {
throw new RangeError("Buffer size must be a multiple of 16-bits");
}
for(var i = 0; i < len; i += 2){
swap(this, i, i + 1);
}
return this;
};
Buffer.prototype.swap32 = function swap32() {
var len = this.length;
if (len % 4 !== 0) {
throw new RangeError("Buffer size must be a multiple of 32-bits");
}
for(var i = 0; i < len; i += 4){
swap(this, i, i + 3);
swap(this, i + 1, i + 2);
}
return this;
};
Buffer.prototype.swap64 = function swap64() {
var len = this.length;
if (len % 8 !== 0) {
throw new RangeError("Buffer size must be a multiple of 64-bits");
}
for(var i = 0; i < len; i += 8){
swap(this, i, i + 7);
swap(this, i + 1, i + 6);
swap(this, i + 2, i + 5);
swap(this, i + 3, i + 4);
}
return this;
};
Buffer.prototype.toString = function toString2() {
var length = this.length | 0;
if (length === 0) return "";
if (arguments.length === 0) return utf8Slice(this, 0, length);
return slowToString.apply(this, arguments);
};
Buffer.prototype.equals = function equals(b) {
if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
if (this === b) return true;
return Buffer.compare(this, b) === 0;
};
Buffer.prototype.inspect = function inspect() {
var str = "";
var max = INSPECT_MAX_BYTES;
if (this.length > 0) {
str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
if (this.length > max) str += " ... ";
}
return "<Buffer " + str + ">";
};
Buffer.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
if (!internalIsBuffer(target)) {
throw new TypeError("Argument must be a Buffer");
}
if (start === void 0) {
start = 0;
}
if (end === void 0) {
end = target ? target.length : 0;
}
if (thisStart === void 0) {
thisStart = 0;
}
if (thisEnd === void 0) {
thisEnd = this.length;
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new RangeError("out of range index");
}
if (thisStart >= thisEnd && start >= end) {
return 0;
}
if (thisStart >= thisEnd) {
return -1;
}
if (start >= end) {
return 1;
}
start >>>= 0;
end >>>= 0;
thisStart >>>= 0;
thisEnd >>>= 0;
if (this === target) return 0;
var x = thisEnd - thisStart;
var y = end - start;
var len = Math.min(x, y);
var thisCopy = this.slice(thisStart, thisEnd);
var targetCopy = target.slice(start, end);
for(var i = 0; i < len; ++i){
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i];
y = targetCopy[i];
break;
}
}
if (x < y) return -1;
if (y < x) return 1;
return 0;
};
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
if (buffer.length === 0) return -1;
if (typeof byteOffset === "string") {
encoding = byteOffset;
byteOffset = 0;
} else if (byteOffset > 2147483647) {
byteOffset = 2147483647;
} else if (byteOffset < -2147483648) {
byteOffset = -2147483648;
}
byteOffset = +byteOffset;
if (isNaN(byteOffset)) {
byteOffset = dir ? 0 : buffer.length - 1;
}
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
if (byteOffset >= buffer.length) {
if (dir) return -1;
else byteOffset = buffer.length - 1;
} else if (byteOffset < 0) {
if (dir) byteOffset = 0;
else return -1;
}
if (typeof val === "string") {
val = Buffer.from(val, encoding);
}
if (internalIsBuffer(val)) {
if (val.length === 0) {
return -1;
}
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
} else if (typeof val === "number") {
val = val & 255;
if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
}
}
return arrayIndexOf(buffer, [
val
], byteOffset, encoding, dir);
}
throw new TypeError("val must be string, number or Buffer");
}
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
var indexSize = 1;
var arrLength = arr.length;
var valLength = val.length;
if (encoding !== void 0) {
encoding = String(encoding).toLowerCase();
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
if (arr.length < 2 || val.length < 2) {
return -1;
}
indexSize = 2;
arrLength /= 2;
valLength /= 2;
byteOffset /= 2;
}
}
function read2(buf, i2) {
if (indexSize === 1) {
return buf[i2];
} else {
return buf.readUInt16BE(i2 * indexSize);
}
}
var i;
if (dir) {
var foundIndex = -1;
for(i = byteOffset; i < arrLength; i++){
if (read2(arr, i) === read2(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i;
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
} else {
if (foundIndex !== -1) i -= i - foundIndex;
foundIndex = -1;
}
}
} else {
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
for(i = byteOffset; i >= 0; i--){
var found = true;
for(var j = 0; j < valLength; j++){
if (read2(arr, i + j) !== read2(val, j)) {
found = false;
break;
}
}
if (found) return i;
}
}
return -1;
}
Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1;
};
Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
};
Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
};
function hexWrite(buf, string, offset, length) {
offset = Number(offset) || 0;
var remaining = buf.length - offset;
if (!length) {
length = remaining;
} else {
length = Number(length);
if (length > remaining) {
length = remaining;
}
}
var strLen = string.length;
if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
if (length > strLen / 2) {
length = strLen / 2;
}
for(var i = 0; i < length; ++i){
var parsed = parseInt(string.substr(i * 2, 2), 16);
if (isNaN(parsed)) return i;
buf[offset + i] = parsed;
}
return i;
}
function utf8Write(buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
}
function asciiWrite(buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length);
}
function latin1Write(buf, string, offset, length) {
return asciiWrite(buf, string, offset, length);
}
function base64Write(buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length);
}
function ucs2Write(buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
}
Buffer.prototype.write = function write2(string, offset, length, encoding) {
if (offset === void 0) {
encoding = "utf8";
length = this.length;
offset = 0;
} else if (length === void 0 && typeof offset === "string") {
encoding = offset;
length = this.length;
offset = 0;
} else if (isFinite(offset)) {
offset = offset | 0;
if (isFinite(length)) {
length = length | 0;
if (encoding === void 0) encoding = "utf8";
} else {
encoding = length;
length = void 0;
}
} else {
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
}
var remaining = this.length - offset;
if (length === void 0 || length > remaining) length = remaining;
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
throw new RangeError("Attempt to write outside buffer bounds");
}
if (!encoding) encoding = "utf8";
var loweredCase = false;
for(;;){
switch(encoding){
case "hex":
return hexWrite(this, string, offset, length);
case "utf8":
case "utf-8":
return utf8Write(this, string, offset, length);
case "ascii":
return asciiWrite(this, string, offset, length);
case "latin1":
case "binary":
return latin1Write(this, string, offset, length);
case "base64":
return base64Write(this, string, offset, length);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return ucs2Write(this, string, offset, length);
default:
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
};
Buffer.prototype.toJSON = function toJSON() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function base64Slice(buf, start, end) {
if (start === 0 && end === buf.length) {
return fromByteArray(buf);
} else {
return fromByteArray(buf.slice(start, end));
}
}
function utf8Slice(buf, start, end) {
end = Math.min(buf.length, end);
var res = [];
var i = start;
while(i < end){
var firstByte = buf[i];
var codePoint = null;
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint;
switch(bytesPerSequence){
case 1:
if (firstByte < 128) {
codePoint = firstByte;
}
break;
case 2:
secondByte = buf[i + 1];
if ((secondByte & 192) === 128) {
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
if (tempCodePoint > 127) {
codePoint = tempCodePoint;
}
}
break;
case 3:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
codePoint = tempCodePoint;
}
}
break;
case 4:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
fourthByte = buf[i + 3];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
codePoint = tempCodePoint;
}
}
}
}
if (codePoint === null) {
codePoint = 65533;
bytesPerSequence = 1;
} else if (codePoint > 65535) {
codePoint -= 65536;
res.push(codePoint >>> 10 & 1023 | 55296);
codePoint = 56320 | codePoint & 1023;
}
res.push(codePoint);
i += bytesPerSequence;
}
return decodeCodePointsArray(res);
}
var MAX_ARGUMENTS_LENGTH = 4096;
function decodeCodePointsArray(codePoints) {
var len = codePoints.length;
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints);
}
var res = "";
var i = 0;
while(i < len){
res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
}
return res;
}
function asciiSlice(buf, start, end) {
var ret = "";
end = Math.min(buf.length, end);
for(var i = start; i < end; ++i){
ret += String.fromCharCode(buf[i] & 127);
}
return ret;
}
function latin1Slice(buf, start, end) {
var ret = "";
end = Math.min(buf.length, end);
for(var i = start; i < end; ++i){
ret += String.fromCharCode(buf[i]);
}
return ret;
}
function hexSlice(buf, start, end) {
var len = buf.length;
if (!start || start < 0) start = 0;
if (!end || end < 0 || end > len) end = len;
var out = "";
for(var i = start; i < end; ++i){
out += toHex(buf[i]);
}
return out;
}
function utf16leSlice(buf, start, end) {
var bytes = buf.slice(start, end);
var res = "";
for(var i = 0; i < bytes.length; i += 2){
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
}
return res;
}
Buffer.prototype.slice = function slice(start, end) {
var len = this.length;
start = ~~start;
end = end === void 0 ? len : ~~end;
if (start < 0) {
start += len;
if (start < 0) start = 0;
} else if (start > len) {
start = len;
}
if (end < 0) {
end += len;
if (end < 0) end = 0;
} else if (end > len) {
end = len;
}
if (end < start) end = start;
var newBuf;
if (Buffer.TYPED_ARRAY_SUPPORT) {
newBuf = this.subarray(start, end);
// newBuf.__proto__ = Buffer.prototype; // MANUALLY CHANGED BY JOE
Object.setPrototypeOf(newBuf, Buffer.prototype)
} else {
var sliceLen = end - start;
newBuf = new Buffer(sliceLen, void 0);
for(var i = 0; i < sliceLen; ++i){
newBuf[i] = this[i + start];
}
}
return newBuf;
};
function checkOffset(offset, ext, length) {
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
}
Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset(offset, byteLength2, this.length);
var val = this[offset];
var mul = 1;
var i = 0;
while(++i < byteLength2 && (mul *= 256)){
val += this[offset + i] * mul;
}
return val;
};
Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
checkOffset(offset, byteLength2, this.length);
}
var val = this[offset + --byteLength2];
var mul = 1;
while(byteLength2 > 0 && (mul *= 256)){
val += this[offset + --byteLength2] * mul;
}
return val;
};
Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length);
return this[offset];
};
Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length);
return this[offset] | this[offset + 1] << 8;
};
Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length);
return this[offset] << 8 | this[offset + 1];
};
Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
};
Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
};
Buffer.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset(offset, byteLength2, this.length);
var val = this[offset];
var mul = 1;
var i = 0;
while(++i < byteLength2 && (mul *= 256)){
val += this[offset + i] * mul;
}
mul *= 128;
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset(offset, byteLength2, this.length);
var i = byteLength2;
var mul = 1;
var val = this[offset + --i];
while(i > 0 && (mul *= 256)){
val += this[offset + --i] * mul;
}
mul *= 128;
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length);
if (!(this[offset] & 128)) return this[offset];
return (255 - this[offset] + 1) * -1;
};
Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length);
var val = this[offset] | this[offset + 1] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length);
var val = this[offset + 1] | this[offset] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
};
Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
};
Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return read(this, offset, true, 23, 4);
};
Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length);
return read(this, offset, false, 23, 4);
};
Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length);
return read(this, offset, true, 52, 8);
};
Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length);
return read(this, offset, false, 52, 8);
};
function checkInt(buf, value, offset, ext, max, min) {
if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
if (offset + ext > buf.length) throw new RangeError("Index out of range");
}
Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt(this, value, offset, byteLength2, maxBytes, 0);
}
var mul = 1;
var i = 0;
this[offset] = value & 255;
while(++i < byteLength2 && (mul *= 256)){
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt(this, value, offset, byteLength2, maxBytes, 0);
}
var i = byteLength2 - 1;
var mul = 1;
this[offset + i] = value & 255;
while(--i >= 0 && (mul *= 256)){
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
this[offset] = value & 255;
return offset + 1;
};
function objectWriteUInt16(buf, value, offset, littleEndian) {
if (value < 0) value = 65535 + value + 1;
for(var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i){
buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
}
}
Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
} else {
objectWriteUInt16(this, value, offset, true);
}
return offset + 2;
};
Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
} else {
objectWriteUInt16(this, value, offset, false);
}
return offset + 2;
};
function objectWriteUInt32(buf, value, offset, littleEndian) {
if (value < 0) value = 4294967295 + value + 1;
for(var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i){
buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
}
}
Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset + 3] = value >>> 24;
this[offset + 2] = value >>> 16;
this[offset + 1] = value >>> 8;
this[offset] = value & 255;
} else {
objectWriteUInt32(this, value, offset, true);
}
return offset + 4;
};
Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
} else {
objectWriteUInt32(this, value, offset, false);
}
return offset + 4;
};
Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
}
var i = 0;
var mul = 1;
var sub = 0;
this[offset] = value & 255;
while(++i < byteLength2 && (mul *= 256)){
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
}
var i = byteLength2 - 1;
var mul = 1;
var sub = 0;
this[offset + i] = value & 255;
while(--i >= 0 && (mul *= 256)){
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
if (value < 0) value = 255 + value + 1;
this[offset] = value & 255;
return offset + 1;
};
Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
} else {
objectWriteUInt16(this, value, offset, true);
}
return offset + 2;
};
Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
} else {
objectWriteUInt16(this, value, offset, false);
}
return offset + 2;
};
Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
this[offset + 2] = value >>> 16;
this[offset + 3] = value >>> 24;
} else {
objectWriteUInt32(this, value, offset, true);
}
return offset + 4;
};
Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
if (value < 0) value = 4294967295 + value + 1;
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
} else {
objectWriteUInt32(this, value, offset, false);
}
return offset + 4;
};
function checkIEEE754(buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError("Index out of range");
if (offset < 0) throw new RangeError("Index out of range");
}
function writeFloat(buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 4);
}
write(buf, value, offset, littleEndian, 23, 4);
return offset + 4;
}
Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
return writeFloat(this, value, offset, true, noAssert);
};
Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
return writeFloat(this, value, offset, false, noAssert);
};
function writeDouble(buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 8);
}
write(buf, value, offset, littleEndian, 52, 8);
return offset + 8;
}
Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
return writeDouble(this, value, offset, true, noAssert);
};
Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert);
};
Buffer.prototype.copy = function copy(target, targetStart, start, end) {
if (!start) start = 0;
if (!end && end !== 0) end = this.length;
if (targetStart >= target.length) targetStart = target.length;
if (!targetStart) targetStart = 0;
if (end > 0 && end < start) end = start;
if (end === start) return 0;
if (target.length === 0 || this.length === 0) return 0;
if (targetStart < 0) {
throw new RangeError("targetStart out of bounds");
}
if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
if (end < 0) throw new RangeError("sourceEnd out of bounds");
if (end > this.length) end = this.length;
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start;
}
var len = end - start;
var i;
if (this === target && start < targetStart && targetStart < end) {
for(i = len - 1; i >= 0; --i){
target[i + targetStart] = this[i + start];
}
} else if (len < 1e3 || !Buffer.TYPED_ARRAY_SUPPORT) {
for(i = 0; i < len; ++i){
target[i + targetStart] = this[i + start];
}
} else {
Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
}
return len;
};
Buffer.prototype.fill = function fill(val, start, end, encoding) {
if (typeof val === "string") {
if (typeof start === "string") {
encoding = start;
start = 0;
end = this.length;
} else if (typeof end === "string") {
encoding = end;
end = this.length;
}
if (val.length === 1) {
var code = val.charCodeAt(0);
if (code < 256) {
val = code;
}
}
if (encoding !== void 0 && typeof encoding !== "string") {
throw new TypeError("encoding must be a string");
}
if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) {
throw new TypeError("Unknown encoding: " + encoding);
}
} else if (typeof val === "number") {
val = val & 255;
}
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError("Out of range index");
}
if (end <= start) {
return this;
}
start = start >>> 0;
end = end === void 0 ? this.length : end >>> 0;
if (!val) val = 0;
var i;
if (typeof val === "number") {
for(i = start; i < end; ++i){
this[i] = val;
}
} else {
var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
var len = bytes.length;
for(i = 0; i < end - start; ++i){
this[i + start] = bytes[i % len];
}
}
return this;
};
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
function base64clean(str) {
str = stringtrim(str).replace(INVALID_BASE64_RE, "");
if (str.length < 2) return "";
while(str.length % 4 !== 0){
str = str + "=";
}
return str;
}
function stringtrim(str) {
if (str.trim) return str.trim();
return str.replace(/^\s+|\s+$/g, "");
}
function toHex(n) {
if (n < 16) return "0" + n.toString(16);
return n.toString(16);
}
function utf8ToBytes(string, units) {
units = units || Infinity;
var codePoint;
var length = string.length;
var leadSurrogate = null;
var bytes = [];
for(var i = 0; i < length; ++i){
codePoint = string.charCodeAt(i);
if (codePoint > 55295 && codePoint < 57344) {
if (!leadSurrogate) {
if (codePoint > 56319) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
continue;
} else if (i + 1 === length) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
continue;
}
leadSurrogate = codePoint;
continue;
}
if (codePoint < 56320) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
leadSurrogate = codePoint;
continue;
}
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
} else if (leadSurrogate) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
}
leadSurrogate = null;
if (codePoint < 128) {
if ((units -= 1) < 0) break;
bytes.push(codePoint);
} else if (codePoint < 2048) {
if ((units -= 2) < 0) break;
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
} else if (codePoint < 65536) {
if ((units -= 3) < 0) break;
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else if (codePoint < 1114112) {
if ((units -= 4) < 0) break;
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else {
throw new Error("Invalid code point");
}
}
return bytes;
}
function asciiToBytes(str) {
var byteArray = [];
for(var i = 0; i < str.length; ++i){
byteArray.push(str.charCodeAt(i) & 255);
}
return byteArray;
}
function utf16leToBytes(str, units) {
var c, hi, lo;
var byteArray = [];
for(var i = 0; i < str.length; ++i){
if ((units -= 2) < 0) break;
c = str.charCodeAt(i);
hi = c >> 8;
lo = c % 256;
byteArray.push(lo);
byteArray.push(hi);
}
return byteArray;
}
function base64ToBytes(str) {
return toByteArray(base64clean(str));
}
function blitBuffer(src, dst, offset, length) {
for(var i = 0; i < length; ++i){
if (i + offset >= dst.length || i >= src.length) break;
dst[i + offset] = src[i];
}
return i;
}
function isnan(val) {
return val !== val;
}
function isBuffer(obj) {
return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
}
function isFastBuffer(obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
}
function isSlowBuffer(obj) {
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
}
var util_utf8_browser_1 = getDefaultExportFromNamespaceIfNotNamed(mod1);
var convertToBuffer_1 = createCommonjsModule1(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertToBuffer = void 0;
var fromUtf8 = typeof Buffer !== "undefined" && Buffer.from ? function(input) {
return Buffer.from(input, "utf8");
} : util_utf8_browser_1.fromUtf8;
function convertToBuffer2(data) {
if (data instanceof Uint8Array) return data;
if (typeof data === "string") {
return fromUtf8(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}
exports.convertToBuffer = convertToBuffer2;
});
var isEmptyData_1 = createCommonjsModule1(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmptyData = void 0;
function isEmptyData2(data) {
if (typeof data === "string") {
return data.length === 0;
}
return data.byteLength === 0;
}
exports.isEmptyData = isEmptyData2;
});
var numToUint8_1 = createCommonjsModule1(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.numToUint8 = void 0;
function numToUint82(num) {
return new Uint8Array([
(num & 4278190080) >> 24,
(num & 16711680) >> 16,
(num & 65280) >> 8,
num & 255
]);
}
exports.numToUint8 = numToUint82;
});
var uint32ArrayFrom_1 = createCommonjsModule1(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.uint32ArrayFrom = void 0;
function uint32ArrayFrom2(a_lookUpTable) {
if (!Uint32Array.from) {
var return_array = new Uint32Array(a_lookUpTable.length);
var a_index = 0;
while(a_index < a_lookUpTable.length){
return_array[a_index] = a_lookUpTable[a_index];
a_index += 1;
}
return return_array;
}
return Uint32Array.from(a_lookUpTable);
}
exports.uint32ArrayFrom = uint32ArrayFrom2;
});
var build = createCommonjsModule1(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.uint32ArrayFrom = exports.numToUint8 = exports.isEmptyData = exports.convertToBuffer = void 0;
Object.defineProperty(exports, "convertToBuffer", {
enumerable: true,
get: function() {
return convertToBuffer_1.convertToBuffer;
}
});
Object.defineProperty(exports, "isEmptyData", {
enumerable: true,
get: function() {
return isEmptyData_1.isEmptyData;
}
});
Object.defineProperty(exports, "numToUint8", {
enumerable: true,
get: function() {
return numToUint8_1.numToUint8;
}
});
Object.defineProperty(exports, "uint32ArrayFrom", {
enumerable: true,
get: function() {
return uint32ArrayFrom_1.uint32ArrayFrom;
}
});
});
var __pika_web_default_export_for_treeshaking__ = getDefaultExportFromCjs(build);
build.convertToBuffer;
build.isEmptyData;
build.numToUint8;
build.uint32ArrayFrom;
function getDefaultExportFromCjs1(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule2(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire2(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed1(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire2() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var tslib_1 = getDefaultExportFromNamespaceIfNotNamed1(mod);
var aws_crc32 = createCommonjsModule2(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AwsCrc32 = void 0;
var AwsCrc322 = function() {
function AwsCrc323() {
this.crc32 = new build1.Crc32();
}
AwsCrc323.prototype.update = function(toHash) {
if ((0, __pika_web_default_export_for_treeshaking__.isEmptyData)(toHash)) return;
this.crc32.update((0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(toHash));
};
AwsCrc323.prototype.digest = function() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function() {
return (0, tslib_1.__generator)(this, function(_a) {
return [
2,
(0, __pika_web_default_export_for_treeshaking__.numToUint8)(this.crc32.digest())
];
});
});
};
return AwsCrc323;
}();
exports.AwsCrc32 = AwsCrc322;
});
var build1 = createCommonjsModule2(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AwsCrc32 = exports.Crc32 = exports.crc32 = void 0;
function crc322(data) {
return new Crc322().update(data).digest();
}
exports.crc32 = crc322;
var Crc322 = function() {
function Crc323() {
this.checksum = 4294967295;
}
Crc323.prototype.update = function(data) {
var e_1, _a;
try {
for(var data_1 = (0, tslib_1.__values)(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()){
var __byte = data_1_1.value;
this.checksum = this.checksum >>> 8 ^ lookupTable[(this.checksum ^ __byte) & 255];
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
} finally{
try {
if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
} finally{
if (e_1) throw e_1.error;
}
}
return this;
};
Crc323.prototype.digest = function() {
return (this.checksum ^ 4294967295) >>> 0;
};
return Crc323;
}();
exports.Crc32 = Crc322;
var a_lookUpTable = [
0,
1996959894,
3993919788,
2567524794,
124634137,
1886057615,
3915621685,
2657392035,
249268274,
2044508324,
3772115230,
2547177864,
162941995,
2125561021,
3887607047,
2428444049,
498536548,
1789927666,
4089016648,
2227061214,
450548861,
1843258603,
4107580753,
2211677639,
325883990,
1684777152,
4251122042,
2321926636,
335633487,
1661365465,
4195302755,
2366115317,
997073096,
1281953886,
3579855332,
2724688242,
1006888145,
1258607687,
3524101629,
2768942443,
901097722,
1119000684,
3686517206,
2898065728,
853044451,
1172266101,
3705015759,
2882616665,
651767980,
1373503546,
3369554304,
3218104598,
565507253,
1454621731,
3485111705,
3099436303,
671266974,
1594198024,
3322730930,
2970347812,
795835527,
1483230225,
3244367275,
3060149565,
1994146192,
31158534,
2563907772,
4023717930,
1907459465,
112637215,
2680153253,
3904427059,
2013776290,
251722036,
2517215374,
3775830040,
2137656763,
141376813,
2439277719,
3865271297,
1802195444,
476864866,
2238001368,
4066508878,
1812370925,
453092731,
2181625025,
4111451223,
1706088902,
314042704,
2344532202,
4240017532,
1658658271,
366619977,
2362670323,
4224994405,
1303535960,
984961486,
2747007092,
3569037538,
1256170817,
1037604311,
2765210733,
3554079995,
1131014506,
879679996,
2909243462,
3663771856,
1141124467,
855842277,
2852801631,
3708648649,
1342533948,
654459306,
3188396048,
3373015174,
1466479909,
544179635,
3110523913,
3462522015,
1591671054,
702138776,
2966460450,
3352799412,
1504918807,
783551873,
3082640443,
3233442989,
3988292384,
2596254646,
62317068,
1957810842,
3939845945,
2647816111,
81470997,
1943803523,
3814918930,
2489596804,
225274430,
2053790376,
3826175755,
2466906013,
167816743,
2097651377,
4027552580,
2265490386,
503444072,
1762050814,
4150417245,
2154129355,
426522225,
1852507879,
4275313526,
2312317920,
282753626,
1742555852,
4189708143,
2394877945,
397917763,
1622183637,
3604390888,
2714866558,
953729732,
1340076626,
3518719985,
2797360999,
1068828381,
1219638859,
3624741850,
2936675148,
906185462,
1090812512,
3747672003,
2825379669,
829329135,
1181335161,
3412177804,
3160834842,
628085408,
1382605366,
3423369109,
3138078467,
570562233,
1426400815,
3317316542,
2998733608,
733239954,
1555261956,
3268935591,
3050360625,
752459403,
1541320221,
2607071920,
3965973030,
1969922972,
40735498,
2617837225,
3943577151,
1913087877,
83908371,
2512341634,
3803740692,
2075208622,
213261112,
2463272603,
3855990285,
2094854071,
198958881,
2262029012,
4057260610,
1759359992,
534414190,
2176718541,
4139329115,
1873836001,
414664567,
2282248934,
4279200368,
1711684554,
285281116,
2405801727,
4167216745,
1634467795,
376229701,
2685067896,
3608007406,
1308918612,
956543938,
2808555105,
3495958263,
1231636301,
1047427035,
2932959818,
3654703836,
1088359270,
936918e3,
2847714899,
3736837829,
1202900863,
817233897,
3183342108,
3401237130,
1404277552,
615818150,
3134207493,
3453421203,
1423857449,
601450431,
3009837614,
3294710456,
1567103746,
711928724,
3020668471,
3272380065,
1510334235,
755167117
];
var lookupTable = (0, __pika_web_default_export_for_treeshaking__.uint32ArrayFrom)(a_lookUpTable);
Object.defineProperty(exports, "AwsCrc32", {
enumerable: true,
get: function() {
return aws_crc32.AwsCrc32;
}
});
});
var __pika_web_default_export_for_treeshaking__1 = getDefaultExportFromCjs1(build1);
build1.AwsCrc32;
build1.Crc32;
build1.crc32;
function getDefaultExportFromCjs2(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule3(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire3(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed2(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire3() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var tslib_11 = getDefaultExportFromNamespaceIfNotNamed2(mod);
var aws_crc32c = createCommonjsModule3(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AwsCrc32c = void 0;
var AwsCrc32c2 = function() {
function AwsCrc32c3() {
this.crc32c = new build2.Crc32c();
}
AwsCrc32c3.prototype.update = function(toHash) {
if ((0, __pika_web_default_export_for_treeshaking__.isEmptyData)(toHash)) return;
this.crc32c.update((0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(toHash));
};
AwsCrc32c3.prototype.digest = function() {
return (0, tslib_11.__awaiter)(this, void 0, void 0, function() {
return (0, tslib_11.__generator)(this, function(_a) {
return [
2,
(0, __pika_web_default_export_for_treeshaking__.numToUint8)(this.crc32c.digest())
];
});
});
};
return AwsCrc32c3;
}();
exports.AwsCrc32c = AwsCrc32c2;
});
var build2 = createCommonjsModule3(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AwsCrc32c = exports.Crc32c = exports.crc32c = void 0;
function crc32c2(data) {
return new Crc32c2().update(data).digest();
}
exports.crc32c = crc32c2;
var Crc32c2 = function() {
function Crc32c3() {
this.checksum = 4294967295;
}
Crc32c3.prototype.update = function(data) {
var e_1, _a;
try {
for(var data_1 = (0, tslib_11.__values)(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()){
var __byte = data_1_1.value;
this.checksum = this.checksum >>> 8 ^ lookupTable[(this.checksum ^ __byte) & 255];
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
} finally{
try {
if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
} finally{
if (e_1) throw e_1.error;
}
}
return this;
};
Crc32c3.prototype.digest = function() {
return (this.checksum ^ 4294967295) >>> 0;
};
return Crc32c3;
}();
exports.Crc32c = Crc32c2;
var a_lookupTable = [
0,
4067132163,
3778769143,
324072436,
3348797215,
904991772,
648144872,
3570033899,
2329499855,
2024987596,
1809983544,
2575936315,
1296289744,
3207089363,
2893594407,
1578318884,
274646895,
3795141740,
4049975192,
51262619,
3619967088,
632279923,
922689671,
3298075524,
2592579488,
1760304291,
2075979607,
2312596564,
1562183871,
2943781820,
3156637768,
1313733451,
549293790,
3537243613,
3246849577,
871202090,
3878099393,
357341890,
102525238,
4101499445,
2858735121,
1477399826,
1264559846,
3107202533,
1845379342,
2677391885,
2361733625,
2125378298,
820201905,
3263744690,
3520608582,
598981189,
4151959214,
85089709,
373468761,
3827903834,
3124367742,
1213305469,
1526817161,
2842354314,
2107672161,
2412447074,
2627466902,
1861252501,
1098587580,
3004210879,
2688576843,
1378610760,
2262928035,
1955203488,
1742404180,
2511436119,
3416409459,
969524848,
714683780,
3639785095,
205050476,
4266873199,
3976438427,
526918040,
1361435347,
2739821008,
2954799652,
1114974503,
2529119692,
1691668175,
2005155131,
2247081528,
3690758684,
697762079,
986182379,
3366744552,
476452099,
3993867776,
4250756596,
255256311,
1640403810,
2477592673,
2164122517,
1922457750,
2791048317,
1412925310,
1197962378,
3037525897,
3944729517,
427051182,
170179418,
4165941337,
746937522,
3740196785,
3451792453,
1070968646,
1905808397,
2213795598,
2426610938,
1657317369,
3053634322,
1147748369,
1463399397,
2773627110,
4215344322,
153784257,
444234805,
3893493558,
1021025245,
3467647198,
3722505002,
797665321,
2197175160,
1889384571,
1674398607,
2443626636,
1164749927,
3070701412,
2757221520,
1446797203,
137323447,
4198817972,
3910406976,
461344835,
3484808360,
1037989803,
781091935,
3705997148,
2460548119,
1623424788,
1939049696,
2180517859,
1429367560,
2807687179,
3020495871,
1180866812,
410100952,
3927582683,
4182430767,
186734380,
3756733383,
763408580,
1053836080,
3434856499,
2722870694,
1344288421,
1131464017,
2971354706,
1708204729,
2545590714,
2229949006,
1988219213,
680717673,
3673779818,
3383336350,
1002577565,
4010310262,
493091189,
238226049,
4233660802,
2987750089,
1082061258,
1395524158,
2705686845,
1972364758,
2279892693,
2494862625,
1725896226,
952904198,
3399985413,
3656866545,
731699698,
4283874585,
222117402,
510512622,
3959836397,
3280807620,
837199303,
582374963,
3504198960,
68661723,
4135334616,
3844915500,
390545967,
1230274059,
3141532936,
2825850620,
1510247935,
2395924756,
2091215383,
1878366691,
2644384480,
3553878443,
565732008,
854102364,
3229815391,
340358836,
3861050807,
4117890627,
119113024,
1493875044,
2875275879,
3090270611,
1247431312,
2660249211,
1828433272,
2141937292,
2378227087,
3811616794,
291187481,
34330861,
4032846830,
615137029,
3603020806,
3314634738,
939183345,
1776939221,
2609017814,
2295496738,
2058945313,
2926798794,
1545135305,
1330124605,
3173225534,
4084100981,
17165430,
307568514,
3762199681,
888469610,
3332340585,
3587147933,
665062302,
2042050490,
2346497209,
2559330125,
1793573966,
3190661285,
1279665062,
1595330642,
2910671697
];
var lookupTable = (0, __pika_web_default_export_for_treeshaking__.uint32ArrayFrom)(a_lookupTable);
Object.defineProperty(exports, "AwsCrc32c", {
enumerable: true,
get: function() {
return aws_crc32c.AwsCrc32c;
}
});
});
var __pika_web_default_export_for_treeshaking__2 = getDefaultExportFromCjs2(build2);
build2.AwsCrc32c;
build2.Crc32c;
build2.crc32c;
const { AwsCrc32 } = __pika_web_default_export_for_treeshaking__1;
const { AwsCrc32c } = __pika_web_default_export_for_treeshaking__2;
var ChecksumAlgorithm;
(function(ChecksumAlgorithm2) {
ChecksumAlgorithm2["MD5"] = "MD5";
ChecksumAlgorithm2["CRC32"] = "CRC32";
ChecksumAlgorithm2["CRC32C"] = "CRC32C";
ChecksumAlgorithm2["SHA1"] = "SHA1";
ChecksumAlgorithm2["SHA256"] = "SHA256";
})(ChecksumAlgorithm || (ChecksumAlgorithm = {}));
var ChecksumLocation;
(function(ChecksumLocation2) {
ChecksumLocation2["HEADER"] = "header";
ChecksumLocation2["TRAILER"] = "trailer";
})(ChecksumLocation || (ChecksumLocation = {}));
const CLIENT_SUPPORTED_ALGORITHMS = [
ChecksumAlgorithm.CRC32,
ChecksumAlgorithm.CRC32C,
ChecksumAlgorithm.SHA1,
ChecksumAlgorithm.SHA256
];
const PRIORITY_ORDER_ALGORITHMS = [
ChecksumAlgorithm.CRC32,
ChecksumAlgorithm.CRC32C,
ChecksumAlgorithm.SHA1,
ChecksumAlgorithm.SHA256
];
const getChecksumAlgorithmForRequest = (input, { requestChecksumRequired , requestAlgorithmMember })=>{
if (!requestAlgorithmMember || !input[requestAlgorithmMember]) {
return requestChecksumRequired ? ChecksumAlgorithm.MD5 : void 0;
}
const checksumAlgorithm = input[requestAlgorithmMember];
if (!CLIENT_SUPPORTED_ALGORITHMS.includes(checksumAlgorithm)) {
throw new Error(`The checksum algorithm "${checksumAlgorithm}" is not supported by the client. Select one of ${CLIENT_SUPPORTED_ALGORITHMS}.`);
}
return checksumAlgorithm;
};
const getChecksumLocationName = (algorithm)=>algorithm === ChecksumAlgorithm.MD5 ? "content-md5" : `x-amz-checksum-${algorithm.toLowerCase()}`;
const hasHeader = (header, headers)=>{
const soughtHeader = header.toLowerCase();
for (const headerName of Object.keys(headers)){
if (soughtHeader === headerName.toLowerCase()) {
return true;
}
}
return false;
};
const isStreaming = (body)=>body !== void 0 && typeof body !== "string" && !ArrayBuffer.isView(body) && !isArrayBuffer(body);
const selectChecksumAlgorithmFunction = (checksumAlgorithm, config)=>({
[ChecksumAlgorithm.MD5]: config.md5,
[ChecksumAlgorithm.CRC32]: AwsCrc32,
[ChecksumAlgorithm.CRC32C]: AwsCrc32c,
[ChecksumAlgorithm.SHA1]: config.sha1,
[ChecksumAlgorithm.SHA256]: config.sha256
})[checksumAlgorithm];
const stringHasher = (checksumAlgorithmFn, body)=>{
const hash = new checksumAlgorithmFn();
hash.update(body || "");
return hash.digest();
};
const getChecksum = async (body, { streamHasher , checksumAlgorithmFn , base64Encoder })=>{
const digest = isStreaming(body) ? streamHasher(checksumAlgorithmFn, body) : stringHasher(checksumAlgorithmFn, body);
return base64Encoder(await digest);
};
const getChecksumAlgorithmListForResponse = (responseAlgorithms = [])=>{
const validChecksumAlgorithms = [];
for (const algorithm of PRIORITY_ORDER_ALGORITHMS){
if (!responseAlgorithms.includes(algorithm) || !CLIENT_SUPPORTED_ALGORITHMS.includes(algorithm)) {
continue;
}
validChecksumAlgorithms.push(algorithm);
}
return validChecksumAlgorithms;
};
const validateChecksumFromResponse = async (response, { config , responseAlgorithms })=>{
const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms);
const { body: responseBody , headers: responseHeaders } = response;
for (const algorithm of checksumAlgorithms){
const responseHeader = getChecksumLocationName(algorithm);
const checksumFromResponse = responseHeaders[responseHeader];
if (checksumFromResponse) {
const checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config);
const { streamHasher , base64Encoder } = config;
const checksum = await getChecksum(responseBody, {
streamHasher,
checksumAlgorithmFn,
base64Encoder
});
if (checksum === checksumFromResponse) {
break;
}
throw new Error(`Checksum mismatch: expected "${checksum}" but received "${checksumFromResponse}" in response header "${responseHeader}".`);
}
}
};
const flexibleChecksumsMiddleware = (config, middlewareConfig)=>(next)=>async (args)=>{
if (!HttpRequest.isInstance(args.request)) {
return next(args);
}
const { request } = args;
const { body: requestBody , headers } = request;
const { base64Encoder , streamHasher } = config;
const { input , requestChecksumRequired , requestAlgorithmMember } = middlewareConfig;
const checksumAlgorithm = getChecksumAlgorithmForRequest(input, {
requestChecksumRequired,
requestAlgorithmMember
});
let updatedBody = requestBody;
let updatedHeaders = headers;
if (checksumAlgorithm) {
const checksumLocationName = getChecksumLocationName(checksumAlgorithm);
const checksumAlgorithmFn = selectChecksumAlgorithmFunction(checksumAlgorithm, config);
if (isStreaming(requestBody)) {
const { getAwsChunkedEncodingStream , bodyLengthChecker } = config;
updatedBody = getAwsChunkedEncodingStream(requestBody, {
base64Encoder,
bodyLengthChecker,
checksumLocationName,
checksumAlgorithmFn,
streamHasher
});
updatedHeaders = {
...headers,
"content-encoding": "aws-chunked",
"transfer-encoding": "chunked",
"x-amz-decoded-content-length": headers["content-length"],
"x-amz-content-sha256": "STREAMING-UNSIGNED-PAYLOAD-TRAILER",
"x-amz-trailer": checksumLocationName
};
delete updatedHeaders["content-length"];
} else if (!hasHeader(checksumLocationName, headers)) {
const rawChecksum = await stringHasher(checksumAlgorithmFn, requestBody);
updatedHeaders = {
...headers,
[checksumLocationName]: base64Encoder(rawChecksum)
};
}
}
const result = await next({
...args,
request: {
...request,
headers: updatedHeaders,
body: updatedBody
}
});
const { requestValidationModeMember , responseAlgorithms } = middlewareConfig;
if (requestValidationModeMember && input[requestValidationModeMember] === "ENABLED") {
validateChecksumFromResponse(result.response, {
config,
responseAlgorithms
});
}
return result;
};
const flexibleChecksumsMiddlewareOptions = {
name: "flexibleChecksumsMiddleware",
step: "build",
tags: [
"BODY_CHECKSUM"
],
override: true
};
const getFlexibleChecksumsPlugin = (config, middlewareConfig)=>({
applyToStack: (clientStack)=>{
clientStack.add(flexibleChecksumsMiddleware(config, middlewareConfig), flexibleChecksumsMiddlewareOptions);
}
});
const isFipsRegion = (region)=>typeof region === "string" && (region.startsWith("fips-") || region.endsWith("-fips"));
const getRealRegion = (region)=>isFipsRegion(region) ? [
"fips-aws-global",
"aws-fips"
].includes(region) ? "us-east-1" : region.replace(/fips-(dkr-|prod-)?|-fips/, "") : region;
const resolveRegionConfig = (input)=>{
const { region , useFipsEndpoint } = input;
if (!region) {
throw new Error("Region is missing");
}
return {
...input,
region: async ()=>{
if (typeof region === "string") {
return getRealRegion(region);
}
const providedRegion = await region();
return getRealRegion(providedRegion);
},
useFipsEndpoint: async ()=>{
const providedRegion = typeof region === "string" ? region : await region();
if (isFipsRegion(providedRegion)) {
return true;
}
return typeof useFipsEndpoint === "boolean" ? Promise.resolve(useFipsEndpoint) : useFipsEndpoint();
}
};
};
const resolveEventStreamSerdeConfig = (input)=>({
...input,
eventStreamMarshaller: input.eventStreamSerdeProvider(input)
});
const CONTENT_LENGTH_HEADER1 = "content-length";
function contentLengthMiddleware(bodyLengthChecker) {
return (next)=>async (args)=>{
const request = args.request;
if (HttpRequest.isInstance(request)) {
const { body , headers } = request;
if (body && Object.keys(headers).map((str)=>str.toLowerCase()).indexOf(CONTENT_LENGTH_HEADER1) === -1) {
try {
const length = bodyLengthChecker(body);
request.headers = {
...request.headers,
[CONTENT_LENGTH_HEADER1]: String(length)
};
} catch (error) {}
}
}
return next({
...args,
request
});
};
}
const contentLengthMiddlewareOptions = {
step: "build",
tags: [
"SET_CONTENT_LENGTH",
"CONTENT_LENGTH"
],
name: "contentLengthMiddleware",
override: true
};
const getContentLengthPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
}
});
function addExpectContinueMiddleware(options) {
return (next)=>async (args)=>{
const { request } = args;
if (HttpRequest.isInstance(request) && request.body && options.runtime === "node") {
request.headers = {
...request.headers,
Expect: "100-continue"
};
}
return next({
...args,
request
});
};
}
const addExpectContinueMiddlewareOptions = {
step: "build",
tags: [
"SET_EXPECT_HEADER",
"EXPECT_HEADER"
],
name: "addExpectContinueMiddleware",
override: true
};
const getAddExpectContinuePlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(addExpectContinueMiddleware(options), addExpectContinueMiddlewareOptions);
}
});
function resolveHostHeaderConfig(input) {
return input;
}
const hostHeaderMiddleware = (options)=>(next)=>async (args)=>{
if (!HttpRequest.isInstance(args.request)) return next(args);
const { request } = args;
const { handlerProtocol ="" } = options.requestHandler.metadata || {};
if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
delete request.headers["host"];
request.headers[":authority"] = "";
} else if (!request.headers["host"]) {
request.headers["host"] = request.hostname;
}
return next(args);
};
const hostHeaderMiddlewareOptions = {
name: "hostHeaderMiddleware",
step: "build",
priority: "low",
tags: [
"HOST"
],
override: true
};
const getHostHeaderPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
}
});
const loggerMiddleware = ()=>(next, context)=>async (args)=>{
const { clientName , commandName , inputFilterSensitiveLog , logger , outputFilterSensitiveLog } = context;
const response = await next(args);
if (!logger) {
return response;
}
if (typeof logger.info === "function") {
const { $metadata , ...outputWithoutMetadata } = response.output;
logger.info({
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
output: outputFilterSensitiveLog(outputWithoutMetadata),
metadata: $metadata
});
}
return response;
};
const loggerMiddlewareOptions = {
name: "loggerMiddleware",
tags: [
"LOGGER"
],
step: "initialize",
override: true
};
const getLoggerPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
}
});
function defaultSetTimout1() {
throw new Error("setTimeout has not been defined");
}
function defaultClearTimeout1() {
throw new Error("clearTimeout has not been defined");
}
var cachedSetTimeout1 = defaultSetTimout1;
var cachedClearTimeout1 = defaultClearTimeout1;
var globalContext1;
if (typeof window !== "undefined") {
globalContext1 = window;
} else if (typeof self !== "undefined") {
globalContext1 = self;
} else {
globalContext1 = {};
}
if (typeof globalContext1.setTimeout === "function") {
cachedSetTimeout1 = setTimeout;
}
if (typeof globalContext1.clearTimeout === "function") {
cachedClearTimeout1 = clearTimeout;
}
function runTimeout(fun) {
if (cachedSetTimeout1 === setTimeout) {
return setTimeout(fun, 0);
}
if ((cachedSetTimeout1 === defaultSetTimout1 || !cachedSetTimeout1) && setTimeout) {
cachedSetTimeout1 = setTimeout;
return setTimeout(fun, 0);
}
try {
return cachedSetTimeout1(fun, 0);
} catch (e) {
try {
return cachedSetTimeout1.call(null, fun, 0);
} catch (e2) {
return cachedSetTimeout1.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout1 === clearTimeout) {
return clearTimeout(marker);
}
if ((cachedClearTimeout1 === defaultClearTimeout1 || !cachedClearTimeout1) && clearTimeout) {
cachedClearTimeout1 = clearTimeout;
return clearTimeout(marker);
}
try {
return cachedClearTimeout1(marker);
} catch (e) {
try {
return cachedClearTimeout1.call(null, marker);
} catch (e2) {
return cachedClearTimeout1.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len){
currentQueue = queue;
queue = [];
while(++queueIndex < len){
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
function nextTick(fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for(var i = 1; i < arguments.length; i++){
args[i - 1] = arguments[i];
}
}
queue.push(new Item1(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
}
function Item1(fun, array) {
this.fun = fun;
this.array = array;
}
Item1.prototype.run = function() {
this.fun.apply(null, this.array);
};
var title = "browser";
var platform = "browser";
var browser = true;
var argv = [];
var version = "";
var versions = {};
var release = {};
var config = {};
function noop() {}
var on = noop;
var addListener = noop;
var once = noop;
var off = noop;
var removeListener = noop;
var removeAllListeners = noop;
var emit = noop;
function binding(name) {
throw new Error("process.binding is not supported");
}
function cwd() {
return "/";
}
function chdir(dir) {
throw new Error("process.chdir is not supported");
}
function umask() {
return 0;
}
var performance1 = globalContext1.performance || {};
var performanceNow = performance1.now || performance1.mozNow || performance1.msNow || performance1.oNow || performance1.webkitNow || function() {
return new Date().getTime();
};
function hrtime(previousTimestamp) {
var clocktime = performanceNow.call(performance1) * 1e-3;
var seconds = Math.floor(clocktime);
var nanoseconds = Math.floor(clocktime % 1 * 1e9);
if (previousTimestamp) {
seconds = seconds - previousTimestamp[0];
nanoseconds = nanoseconds - previousTimestamp[1];
if (nanoseconds < 0) {
seconds--;
nanoseconds += 1e9;
}
}
return [
seconds,
nanoseconds
];
}
var startTime = new Date();
function uptime() {
var currentTime = new Date();
var dif = currentTime - startTime;
return dif / 1e3;
}
var process = {
nextTick,
title,
browser,
env: {
NODE_ENV: "production"
},
argv,
version,
versions,
on,
addListener,
once,
off,
removeListener,
removeAllListeners,
emit,
binding,
cwd,
chdir,
umask,
hrtime,
platform,
release,
config,
uptime
};
const TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
const ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
const recursionDetectionMiddleware = (options)=>(next)=>async (args)=>{
const { request } = args;
if (!HttpRequest.isInstance(request) || options.runtime !== "node" || request.headers.hasOwnProperty(TRACE_ID_HEADER_NAME)) {
return next(args);
}
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
const traceId = process.env[ENV_TRACE_ID];
const nonEmptyString = (str)=>typeof str === "string" && str.length > 0;
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
request.headers[TRACE_ID_HEADER_NAME] = traceId;
}
return next({
...args,
request
});
};
const addRecursionDetectionMiddlewareOptions = {
step: "build",
tags: [
"RECURSION_DETECTION"
],
name: "recursionDetectionMiddleware",
override: true,
priority: "low"
};
const getRecursionDetectionPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(recursionDetectionMiddleware(options), addRecursionDetectionMiddlewareOptions);
}
});
const CLOCK_SKEW_ERROR_CODES = [
"AuthFailure",
"InvalidSignatureException",
"RequestExpired",
"RequestInTheFuture",
"RequestTimeTooSkewed",
"SignatureDoesNotMatch"
];
const THROTTLING_ERROR_CODES = [
"BandwidthLimitExceeded",
"EC2ThrottledException",
"LimitExceededException",
"PriorRequestNotComplete",
"ProvisionedThroughputExceededException",
"RequestLimitExceeded",
"RequestThrottled",
"RequestThrottledException",
"SlowDown",
"ThrottledException",
"Throttling",
"ThrottlingException",
"TooManyRequestsException",
"TransactionInProgressException"
];
const TRANSIENT_ERROR_CODES = [
"AbortError",
"TimeoutError",
"RequestTimeout",
"RequestTimeoutException"
];
const TRANSIENT_ERROR_STATUS_CODES = [
500,
502,
503,
504
];
const NODEJS_TIMEOUT_ERROR_CODES = [
"ECONNRESET",
"EPIPE",
"ETIMEDOUT"
];
const isRetryableByTrait = (error)=>error.$retryable !== void 0;
const isClockSkewError = (error)=>CLOCK_SKEW_ERROR_CODES.includes(error.name);
const isThrottlingError = (error)=>{
var _a, _b;
return ((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) === 429 || THROTTLING_ERROR_CODES.includes(error.name) || ((_b = error.$retryable) == null ? void 0 : _b.throttling) == true;
};
const isTransientError = (error)=>{
var _a;
return TRANSIENT_ERROR_CODES.includes(error.name) || NODEJS_TIMEOUT_ERROR_CODES.includes((error == null ? void 0 : error.code) || "") || TRANSIENT_ERROR_STATUS_CODES.includes(((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) || 0);
};
var getRandomValues;
var rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues) {
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
if (!getRandomValues) {
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
}
}
return getRandomValues(rnds8);
}
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function validate2(uuid) {
return typeof uuid === "string" && REGEX.test(uuid);
}
var byteToHex = [];
for(var i = 0; i < 256; ++i){
byteToHex.push((i + 256).toString(16).substr(1));
}
function stringify(arr) {
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
if (!validate2(uuid)) {
throw TypeError("Stringified UUID is invalid");
}
return uuid;
}
function parse(uuid) {
if (!validate2(uuid)) {
throw TypeError("Invalid UUID");
}
var v;
var arr = new Uint8Array(16);
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
arr[1] = v >>> 16 & 255;
arr[2] = v >>> 8 & 255;
arr[3] = v & 255;
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
arr[5] = v & 255;
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
arr[7] = v & 255;
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
arr[9] = v & 255;
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
arr[11] = v / 4294967296 & 255;
arr[12] = v >>> 24 & 255;
arr[13] = v >>> 16 & 255;
arr[14] = v >>> 8 & 255;
arr[15] = v & 255;
return arr;
}
function stringToBytes(str) {
str = unescape(encodeURIComponent(str));
var bytes = [];
for(var i = 0; i < str.length; ++i){
bytes.push(str.charCodeAt(i));
}
return bytes;
}
var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
var URL1 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
function v35(name, version2, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
if (typeof value === "string") {
value = stringToBytes(value);
}
if (typeof namespace === "string") {
namespace = parse(namespace);
}
if (namespace.length !== 16) {
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
}
var bytes = new Uint8Array(16 + value.length);
bytes.set(namespace);
bytes.set(value, namespace.length);
bytes = hashfunc(bytes);
bytes[6] = bytes[6] & 15 | version2;
bytes[8] = bytes[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for(var i = 0; i < 16; ++i){
buf[offset + i] = bytes[i];
}
return buf;
}
return stringify(bytes);
}
try {
generateUUID.name = name;
} catch (err) {}
generateUUID.DNS = DNS;
generateUUID.URL = URL1;
return generateUUID;
}
function md5(bytes) {
if (typeof bytes === "string") {
var msg = unescape(encodeURIComponent(bytes));
bytes = new Uint8Array(msg.length);
for(var i = 0; i < msg.length; ++i){
bytes[i] = msg.charCodeAt(i);
}
}
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
}
function md5ToHexEncodedArray(input) {
var output = [];
var length32 = input.length * 32;
var hexTab = "0123456789abcdef";
for(var i = 0; i < length32; i += 8){
var x = input[i >> 5] >>> i % 32 & 255;
var hex = parseInt(hexTab.charAt(x >>> 4 & 15) + hexTab.charAt(x & 15), 16);
output.push(hex);
}
return output;
}
function getOutputLength(inputLength8) {
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
}
function wordsToMd5(x, len) {
x[len >> 5] |= 128 << len % 32;
x[getOutputLength(len) - 1] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16){
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5ff(a, b, c, d, x[i], 7, -680876936);
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5gg(b, c, d, a, x[i], 20, -373897302);
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5hh(d, a, b, c, x[i], 11, -358537222);
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5ii(a, b, c, d, x[i], 6, -198630844);
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safeAdd(a, olda);
b = safeAdd(b, oldb);
c = safeAdd(c, oldc);
d = safeAdd(d, oldd);
}
return [
a,
b,
c,
d
];
}
function bytesToWords(input) {
if (input.length === 0) {
return [];
}
var length8 = input.length * 8;
var output = new Uint32Array(getOutputLength(length8));
for(var i = 0; i < length8; i += 8){
output[i >> 5] |= (input[i / 8] & 255) << i % 32;
}
return output;
}
function safeAdd(x, y) {
var lsw = (x & 65535) + (y & 65535);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return msw << 16 | lsw & 65535;
}
function bitRotateLeft(num, cnt) {
return num << cnt | num >>> 32 - cnt;
}
function md5cmn(q, a, b, x, s, t) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
}
function md5ff(a, b, c, d, x, s, t) {
return md5cmn(b & c | ~b & d, a, b, x, s, t);
}
function md5gg(a, b, c, d, x, s, t) {
return md5cmn(b & d | c & ~d, a, b, x, s, t);
}
function md5hh(a, b, c, d, x, s, t) {
return md5cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5ii(a, b, c, d, x, s, t) {
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
}
v35("v3", 48, md5);
function v4(options, buf, offset) {
options = options || {};
var rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for(var i = 0; i < 16; ++i){
buf[offset + i] = rnds[i];
}
return buf;
}
return stringify(rnds);
}
function f(s, x, y, z) {
switch(s){
case 0:
return x & y ^ ~x & z;
case 1:
return x ^ y ^ z;
case 2:
return x & y ^ x & z ^ y & z;
case 3:
return x ^ y ^ z;
}
}
function ROTL(x, n) {
return x << n | x >>> 32 - n;
}
function sha1(bytes) {
var K = [
1518500249,
1859775393,
2400959708,
3395469782
];
var H = [
1732584193,
4023233417,
2562383102,
271733878,
3285377520
];
if (typeof bytes === "string") {
var msg = unescape(encodeURIComponent(bytes));
bytes = [];
for(var i = 0; i < msg.length; ++i){
bytes.push(msg.charCodeAt(i));
}
} else if (!Array.isArray(bytes)) {
bytes = Array.prototype.slice.call(bytes);
}
bytes.push(128);
var l = bytes.length / 4 + 2;
var N = Math.ceil(l / 16);
var M = new Array(N);
for(var _i = 0; _i < N; ++_i){
var arr = new Uint32Array(16);
for(var j = 0; j < 16; ++j){
arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
}
M[_i] = arr;
}
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
M[N - 1][14] = Math.floor(M[N - 1][14]);
M[N - 1][15] = (bytes.length - 1) * 8 & 4294967295;
for(var _i2 = 0; _i2 < N; ++_i2){
var W = new Uint32Array(80);
for(var t = 0; t < 16; ++t){
W[t] = M[_i2][t];
}
for(var _t = 16; _t < 80; ++_t){
W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
}
var a = H[0];
var b = H[1];
var c = H[2];
var d = H[3];
var e = H[4];
for(var _t2 = 0; _t2 < 80; ++_t2){
var s = Math.floor(_t2 / 20);
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
e = d;
d = c;
c = ROTL(b, 30) >>> 0;
b = a;
a = T;
}
H[0] = H[0] + a >>> 0;
H[1] = H[1] + b >>> 0;
H[2] = H[2] + c >>> 0;
H[3] = H[3] + d >>> 0;
H[4] = H[4] + e >>> 0;
}
return [
H[0] >> 24 & 255,
H[0] >> 16 & 255,
H[0] >> 8 & 255,
H[0] & 255,
H[1] >> 24 & 255,
H[1] >> 16 & 255,
H[1] >> 8 & 255,
H[1] & 255,
H[2] >> 24 & 255,
H[2] >> 16 & 255,
H[2] >> 8 & 255,
H[2] & 255,
H[3] >> 24 & 255,
H[3] >> 16 & 255,
H[3] >> 8 & 255,
H[3] & 255,
H[4] >> 24 & 255,
H[4] >> 16 & 255,
H[4] >> 8 & 255,
H[4] & 255
];
}
v35("v5", 80, sha1);
var RETRY_MODES;
(function(RETRY_MODES2) {
RETRY_MODES2["STANDARD"] = "standard";
RETRY_MODES2["ADAPTIVE"] = "adaptive";
})(RETRY_MODES || (RETRY_MODES = {}));
const DEFAULT_MAX_ATTEMPTS = 3;
const DEFAULT_RETRY_MODE = RETRY_MODES.STANDARD;
class DefaultRateLimiter {
constructor(options){
var _a, _b, _c, _d, _e;
this.currentCapacity = 0;
this.enabled = false;
this.lastMaxRate = 0;
this.measuredTxRate = 0;
this.requestCount = 0;
this.lastTimestamp = 0;
this.timeWindow = 0;
this.beta = (_a = options == null ? void 0 : options.beta) != null ? _a : 0.7;
this.minCapacity = (_b = options == null ? void 0 : options.minCapacity) != null ? _b : 1;
this.minFillRate = (_c = options == null ? void 0 : options.minFillRate) != null ? _c : 0.5;
this.scaleConstant = (_d = options == null ? void 0 : options.scaleConstant) != null ? _d : 0.4;
this.smooth = (_e = options == null ? void 0 : options.smooth) != null ? _e : 0.8;
const currentTimeInSeconds = this.getCurrentTimeInSeconds();
this.lastThrottleTime = currentTimeInSeconds;
this.lastTxRateBucket = Math.floor(this.getCurrentTimeInSeconds());
this.fillRate = this.minFillRate;
this.maxCapacity = this.minCapacity;
}
getCurrentTimeInSeconds() {
return Date.now() / 1e3;
}
async getSendToken() {
return this.acquireTokenBucket(1);
}
async acquireTokenBucket(amount) {
if (!this.enabled) {
return;
}
this.refillTokenBucket();
if (amount > this.currentCapacity) {
const delay = (amount - this.currentCapacity) / this.fillRate * 1e3;
await new Promise((resolve)=>setTimeout(resolve, delay));
}
this.currentCapacity = this.currentCapacity - amount;
}
refillTokenBucket() {
const timestamp = this.getCurrentTimeInSeconds();
if (!this.lastTimestamp) {
this.lastTimestamp = timestamp;
return;
}
const fillAmount = (timestamp - this.lastTimestamp) * this.fillRate;
this.currentCapacity = Math.min(this.maxCapacity, this.currentCapacity + fillAmount);
this.lastTimestamp = timestamp;
}
updateClientSendingRate(response) {
let calculatedRate;
this.updateMeasuredRate();
if (isThrottlingError(response)) {
const rateToUse = !this.enabled ? this.measuredTxRate : Math.min(this.measuredTxRate, this.fillRate);
this.lastMaxRate = rateToUse;
this.calculateTimeWindow();
this.lastThrottleTime = this.getCurrentTimeInSeconds();
calculatedRate = this.cubicThrottle(rateToUse);
this.enableTokenBucket();
} else {
this.calculateTimeWindow();
calculatedRate = this.cubicSuccess(this.getCurrentTimeInSeconds());
}
const newRate = Math.min(calculatedRate, 2 * this.measuredTxRate);
this.updateTokenBucketRate(newRate);
}
calculateTimeWindow() {
this.timeWindow = this.getPrecise(Math.pow(this.lastMaxRate * (1 - this.beta) / this.scaleConstant, 1 / 3));
}
cubicThrottle(rateToUse) {
return this.getPrecise(rateToUse * this.beta);
}
cubicSuccess(timestamp) {
return this.getPrecise(this.scaleConstant * Math.pow(timestamp - this.lastThrottleTime - this.timeWindow, 3) + this.lastMaxRate);
}
enableTokenBucket() {
this.enabled = true;
}
updateTokenBucketRate(newRate) {
this.refillTokenBucket();
this.fillRate = Math.max(newRate, this.minFillRate);
this.maxCapacity = Math.max(newRate, this.minCapacity);
this.currentCapacity = Math.min(this.currentCapacity, this.maxCapacity);
}
updateMeasuredRate() {
const t = this.getCurrentTimeInSeconds();
const timeBucket = Math.floor(t * 2) / 2;
this.requestCount++;
if (timeBucket > this.lastTxRateBucket) {
const currentRate = this.requestCount / (timeBucket - this.lastTxRateBucket);
this.measuredTxRate = this.getPrecise(currentRate * this.smooth + this.measuredTxRate * (1 - this.smooth));
this.requestCount = 0;
this.lastTxRateBucket = timeBucket;
}
}
getPrecise(num) {
return parseFloat(num.toFixed(8));
}
}
const MAXIMUM_RETRY_DELAY = 20 * 1e3;
const INITIAL_RETRY_TOKENS = 500;
const INVOCATION_ID_HEADER = "amz-sdk-invocation-id";
const REQUEST_HEADER = "amz-sdk-request";
const getDefaultRetryQuota = (initialRetryTokens, options)=>{
var _a, _b, _c;
const MAX_CAPACITY = initialRetryTokens;
const noRetryIncrement = (_a = options == null ? void 0 : options.noRetryIncrement) != null ? _a : 1;
const retryCost = (_b = options == null ? void 0 : options.retryCost) != null ? _b : 5;
const timeoutRetryCost = (_c = options == null ? void 0 : options.timeoutRetryCost) != null ? _c : 10;
let availableCapacity = initialRetryTokens;
const getCapacityAmount = (error)=>error.name === "TimeoutError" ? timeoutRetryCost : retryCost;
const hasRetryTokens = (error)=>getCapacityAmount(error) <= availableCapacity;
const retrieveRetryTokens = (error)=>{
if (!hasRetryTokens(error)) {
throw new Error("No retry token available");
}
const capacityAmount = getCapacityAmount(error);
availableCapacity -= capacityAmount;
return capacityAmount;
};
const releaseRetryTokens = (capacityReleaseAmount)=>{
availableCapacity += capacityReleaseAmount != null ? capacityReleaseAmount : noRetryIncrement;
availableCapacity = Math.min(availableCapacity, MAX_CAPACITY);
};
return Object.freeze({
hasRetryTokens,
retrieveRetryTokens,
releaseRetryTokens
});
};
const defaultDelayDecider = (delayBase, attempts)=>Math.floor(Math.min(MAXIMUM_RETRY_DELAY, Math.random() * 2 ** attempts * delayBase));
const defaultRetryDecider = (error)=>{
if (!error) {
return false;
}
return isRetryableByTrait(error) || isClockSkewError(error) || isThrottlingError(error) || isTransientError(error);
};
class StandardRetryStrategy {
constructor(maxAttemptsProvider, options){
var _a, _b, _c;
this.maxAttemptsProvider = maxAttemptsProvider;
this.mode = RETRY_MODES.STANDARD;
this.retryDecider = (_a = options == null ? void 0 : options.retryDecider) != null ? _a : defaultRetryDecider;
this.delayDecider = (_b = options == null ? void 0 : options.delayDecider) != null ? _b : defaultDelayDecider;
this.retryQuota = (_c = options == null ? void 0 : options.retryQuota) != null ? _c : getDefaultRetryQuota(INITIAL_RETRY_TOKENS);
}
shouldRetry(error, attempts, maxAttempts) {
return attempts < maxAttempts && this.retryDecider(error) && this.retryQuota.hasRetryTokens(error);
}
async getMaxAttempts() {
let maxAttempts;
try {
maxAttempts = await this.maxAttemptsProvider();
} catch (error) {
maxAttempts = DEFAULT_MAX_ATTEMPTS;
}
return maxAttempts;
}
async retry(next, args, options) {
let retryTokenAmount;
let attempts = 0;
let totalDelay = 0;
const maxAttempts = await this.getMaxAttempts();
const { request } = args;
if (HttpRequest.isInstance(request)) {
request.headers[INVOCATION_ID_HEADER] = v4();
}
while(true){
try {
if (HttpRequest.isInstance(request)) {
request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`;
}
if (options == null ? void 0 : options.beforeRequest) {
await options.beforeRequest();
}
const { response , output } = await next(args);
if (options == null ? void 0 : options.afterRequest) {
options.afterRequest(response);
}
this.retryQuota.releaseRetryTokens(retryTokenAmount);
output.$metadata.attempts = attempts + 1;
output.$metadata.totalRetryDelay = totalDelay;
return {
response,
output
};
} catch (e) {
const err = asSdkError(e);
attempts++;
if (this.shouldRetry(err, attempts, maxAttempts)) {
retryTokenAmount = this.retryQuota.retrieveRetryTokens(err);
const delayFromDecider = this.delayDecider(isThrottlingError(err) ? 500 : 100, attempts);
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
totalDelay += delay;
await new Promise((resolve)=>setTimeout(resolve, delay));
continue;
}
if (!err.$metadata) {
err.$metadata = {};
}
err.$metadata.attempts = attempts;
err.$metadata.totalRetryDelay = totalDelay;
throw err;
}
}
}
}
const getDelayFromRetryAfterHeader = (response)=>{
if (!HttpResponse.isInstance(response)) return;
const retryAfterHeaderName = Object.keys(response.headers).find((key)=>key.toLowerCase() === "retry-after");
if (!retryAfterHeaderName) return;
const retryAfter = response.headers[retryAfterHeaderName];
const retryAfterSeconds = Number(retryAfter);
if (!Number.isNaN(retryAfterSeconds)) return retryAfterSeconds * 1e3;
const retryAfterDate = new Date(retryAfter);
return retryAfterDate.getTime() - Date.now();
};
const asSdkError = (error)=>{
if (error instanceof Error) return error;
if (error instanceof Object) return Object.assign(new Error(), error);
if (typeof error === "string") return new Error(error);
return new Error(`AWS SDK error wrapper for ${error}`);
};
class AdaptiveRetryStrategy extends StandardRetryStrategy {
constructor(maxAttemptsProvider, options){
const { rateLimiter , ...superOptions } = options != null ? options : {};
super(maxAttemptsProvider, superOptions);
this.rateLimiter = rateLimiter != null ? rateLimiter : new DefaultRateLimiter();
this.mode = RETRY_MODES.ADAPTIVE;
}
async retry(next, args) {
return super.retry(next, args, {
beforeRequest: async ()=>{
return this.rateLimiter.getSendToken();
},
afterRequest: (response)=>{
this.rateLimiter.updateClientSendingRate(response);
}
});
}
}
const resolveRetryConfig = (input)=>{
var _a;
const maxAttempts = normalizeProvider((_a = input.maxAttempts) != null ? _a : 3);
return {
...input,
maxAttempts,
retryStrategy: async ()=>{
if (input.retryStrategy) {
return input.retryStrategy;
}
const retryMode = await normalizeProvider(input.retryMode)();
if (retryMode === RETRY_MODES.ADAPTIVE) {
return new AdaptiveRetryStrategy(maxAttempts);
}
return new StandardRetryStrategy(maxAttempts);
}
};
};
const retryMiddleware = (options)=>(next, context)=>async (args)=>{
const retryStrategy = await options.retryStrategy();
if (retryStrategy == null ? void 0 : retryStrategy.mode) context.userAgent = [
...context.userAgent || [],
[
"cfg/retry-mode",
retryStrategy.mode
]
];
return retryStrategy.retry(next, args);
};
const retryMiddlewareOptions = {
name: "retryMiddleware",
tags: [
"RETRY"
],
step: "finalizeRequest",
priority: "high",
override: true
};
const getRetryPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.add(retryMiddleware(options), retryMiddlewareOptions);
}
});
const memoize = (provider, isExpired, requiresRefresh)=>{
let resolved;
let pending;
let hasResult;
let isConstant = false;
const coalesceProvider = async ()=>{
if (!pending) {
pending = provider();
}
try {
resolved = await pending;
hasResult = true;
isConstant = false;
} finally{
pending = void 0;
}
return resolved;
};
if (isExpired === void 0) {
return async (options)=>{
if (!hasResult || (options == null ? void 0 : options.forceRefresh)) {
resolved = await coalesceProvider();
}
return resolved;
};
}
return async (options)=>{
if (!hasResult || (options == null ? void 0 : options.forceRefresh)) {
resolved = await coalesceProvider();
}
if (isConstant) {
return resolved;
}
if (requiresRefresh && !requiresRefresh(resolved)) {
isConstant = true;
return resolved;
}
if (isExpired(resolved)) {
await coalesceProvider();
return resolved;
}
return resolved;
};
};
const SHORT_TO_HEX = {};
const HEX_TO_SHORT = {};
for(let i1 = 0; i1 < 256; i1++){
let encodedByte = i1.toString(16).toLowerCase();
if (encodedByte.length === 1) {
encodedByte = `0${encodedByte}`;
}
SHORT_TO_HEX[i1] = encodedByte;
HEX_TO_SHORT[encodedByte] = i1;
}
function fromHex(encoded) {
if (encoded.length % 2 !== 0) {
throw new Error("Hex encoded strings must have an even number length");
}
const out = new Uint8Array(encoded.length / 2);
for(let i = 0; i < encoded.length; i += 2){
const encodedByte = encoded.slice(i, i + 2).toLowerCase();
if (encodedByte in HEX_TO_SHORT) {
out[i / 2] = HEX_TO_SHORT[encodedByte];
} else {
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
}
}
return out;
}
function toHex1(bytes) {
let out = "";
for(let i = 0; i < bytes.byteLength; i++){
out += SHORT_TO_HEX[bytes[i]];
}
return out;
}
const escapeUri = (uri)=>encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
const hexEncode = (c)=>`%${c.charCodeAt(0).toString(16).toUpperCase()}`;
const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
const SIGNATURE_QUERY_PARAM = "X-Amz-Signature";
const TOKEN_QUERY_PARAM = "X-Amz-Security-Token";
const AUTH_HEADER = "authorization";
const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase();
const DATE_HEADER = "date";
const GENERATED_HEADERS = [
AUTH_HEADER,
AMZ_DATE_HEADER,
DATE_HEADER
];
const SIGNATURE_HEADER = SIGNATURE_QUERY_PARAM.toLowerCase();
const SHA256_HEADER = "x-amz-content-sha256";
const TOKEN_HEADER = TOKEN_QUERY_PARAM.toLowerCase();
const ALWAYS_UNSIGNABLE_HEADERS = {
authorization: true,
"cache-control": true,
connection: true,
expect: true,
from: true,
"keep-alive": true,
"max-forwards": true,
pragma: true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
"user-agent": true,
"x-amzn-trace-id": true
};
const PROXY_HEADER_PATTERN = /^proxy-/;
const SEC_HEADER_PATTERN = /^sec-/;
const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
const EVENT_ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256-PAYLOAD";
const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
const KEY_TYPE_IDENTIFIER = "aws4_request";
const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
const signingKeyCache = {};
const cacheQueue = [];
const createScope = (shortDate, region, service)=>`${shortDate}/${region}/${service}/${KEY_TYPE_IDENTIFIER}`;
const getSigningKey = async (sha256Constructor, credentials, shortDate, region, service)=>{
const credsHash = await hmac(sha256Constructor, credentials.secretAccessKey, credentials.accessKeyId);
const cacheKey = `${shortDate}:${region}:${service}:${toHex1(credsHash)}:${credentials.sessionToken}`;
if (cacheKey in signingKeyCache) {
return signingKeyCache[cacheKey];
}
cacheQueue.push(cacheKey);
while(cacheQueue.length > 50){
delete signingKeyCache[cacheQueue.shift()];
}
let key = `AWS4${credentials.secretAccessKey}`;
for (const signable of [
shortDate,
region,
service,
KEY_TYPE_IDENTIFIER
]){
key = await hmac(sha256Constructor, key, signable);
}
return signingKeyCache[cacheKey] = key;
};
const hmac = (ctor, secret, data)=>{
const hash = new ctor(secret);
hash.update(data);
return hash.digest();
};
const getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders)=>{
const canonical = {};
for (const headerName of Object.keys(headers).sort()){
if (headers[headerName] == void 0) {
continue;
}
const canonicalHeaderName = headerName.toLowerCase();
if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS || (unsignableHeaders == null ? void 0 : unsignableHeaders.has(canonicalHeaderName)) || PROXY_HEADER_PATTERN.test(canonicalHeaderName) || SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
if (!signableHeaders || signableHeaders && !signableHeaders.has(canonicalHeaderName)) {
continue;
}
}
canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
}
return canonical;
};
const getCanonicalQuery = ({ query ={} })=>{
const keys = [];
const serialized = {};
for (const key of Object.keys(query).sort()){
if (key.toLowerCase() === SIGNATURE_HEADER) {
continue;
}
keys.push(key);
const value = query[key];
if (typeof value === "string") {
serialized[key] = `${escapeUri(key)}=${escapeUri(value)}`;
} else if (Array.isArray(value)) {
serialized[key] = value.slice(0).sort().reduce((encoded, value2)=>encoded.concat([
`${escapeUri(key)}=${escapeUri(value2)}`
]), []).join("&");
}
}
return keys.map((key)=>serialized[key]).filter((serialized2)=>serialized2).join("&");
};
const getPayloadHash = async ({ headers , body }, hashConstructor)=>{
for (const headerName of Object.keys(headers)){
if (headerName.toLowerCase() === SHA256_HEADER) {
return headers[headerName];
}
}
if (body == void 0) {
return "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
} else if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
const hashCtor = new hashConstructor();
hashCtor.update(body);
return toHex1(await hashCtor.digest());
}
return UNSIGNED_PAYLOAD;
};
const hasHeader1 = (soughtHeader, headers)=>{
soughtHeader = soughtHeader.toLowerCase();
for (const headerName of Object.keys(headers)){
if (soughtHeader === headerName.toLowerCase()) {
return true;
}
}
return false;
};
const cloneRequest = ({ headers , query , ...rest })=>({
...rest,
headers: {
...headers
},
query: query ? cloneQuery1(query) : void 0
});
const cloneQuery1 = (query)=>Object.keys(query).reduce((carry, paramName)=>{
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [
...param
] : param
};
}, {});
const moveHeadersToQuery = (request, options = {})=>{
var _a;
const { headers , query ={} } = typeof request.clone === "function" ? request.clone() : cloneRequest(request);
for (const name of Object.keys(headers)){
const lname = name.toLowerCase();
if (lname.slice(0, 6) === "x-amz-" && !((_a = options.unhoistableHeaders) == null ? void 0 : _a.has(lname))) {
query[name] = headers[name];
delete headers[name];
}
}
return {
...request,
headers,
query
};
};
const prepareRequest = (request)=>{
request = typeof request.clone === "function" ? request.clone() : cloneRequest(request);
for (const headerName of Object.keys(request.headers)){
if (GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
delete request.headers[headerName];
}
}
return request;
};
const iso8601 = (time)=>toDate(time).toISOString().replace(/\.\d{3}Z$/, "Z");
const toDate = (time)=>{
if (typeof time === "number") {
return new Date(time * 1e3);
}
if (typeof time === "string") {
if (Number(time)) {
return new Date(Number(time) * 1e3);
}
return new Date(time);
}
return time;
};
class SignatureV4 {
constructor({ applyChecksum , credentials , region , service , sha256 , uriEscapePath =true }){
this.service = service;
this.sha256 = sha256;
this.uriEscapePath = uriEscapePath;
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
this.regionProvider = normalizeProvider(region);
this.credentialProvider = normalizeProvider(credentials);
}
async presign(originalRequest, options = {}) {
const { signingDate =new Date() , expiresIn =3600 , unsignableHeaders , unhoistableHeaders , signableHeaders , signingRegion , signingService } = options;
const credentials = await this.credentialProvider();
this.validateResolvedCredentials(credentials);
const region = signingRegion != null ? signingRegion : await this.regionProvider();
const { longDate , shortDate } = formatDate(signingDate);
if (expiresIn > MAX_PRESIGNED_TTL) {
return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");
}
const scope = createScope(shortDate, region, signingService != null ? signingService : this.service);
const request = moveHeadersToQuery(prepareRequest(originalRequest), {
unhoistableHeaders
});
if (credentials.sessionToken) {
request.query[TOKEN_QUERY_PARAM] = credentials.sessionToken;
}
request.query[ALGORITHM_QUERY_PARAM] = ALGORITHM_IDENTIFIER;
request.query[CREDENTIAL_QUERY_PARAM] = `${credentials.accessKeyId}/${scope}`;
request.query[AMZ_DATE_QUERY_PARAM] = longDate;
request.query[EXPIRES_QUERY_PARAM] = expiresIn.toString(10);
const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
request.query[SIGNED_HEADERS_QUERY_PARAM] = getCanonicalHeaderList(canonicalHeaders);
request.query[SIGNATURE_QUERY_PARAM] = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, await getPayloadHash(originalRequest, this.sha256)));
return request;
}
async sign(toSign, options) {
if (typeof toSign === "string") {
return this.signString(toSign, options);
} else if (toSign.headers && toSign.payload) {
return this.signEvent(toSign, options);
} else {
return this.signRequest(toSign, options);
}
}
async signEvent({ headers , payload }, { signingDate =new Date() , priorSignature , signingRegion , signingService }) {
const region = signingRegion != null ? signingRegion : await this.regionProvider();
const { shortDate , longDate } = formatDate(signingDate);
const scope = createScope(shortDate, region, signingService != null ? signingService : this.service);
const hashedPayload = await getPayloadHash({
headers: {},
body: payload
}, this.sha256);
const hash = new this.sha256();
hash.update(headers);
const hashedHeaders = toHex1(await hash.digest());
const stringToSign = [
EVENT_ALGORITHM_IDENTIFIER,
longDate,
scope,
priorSignature,
hashedHeaders,
hashedPayload
].join("\n");
return this.signString(stringToSign, {
signingDate,
signingRegion: region,
signingService
});
}
async signString(stringToSign, { signingDate =new Date() , signingRegion , signingService } = {}) {
const credentials = await this.credentialProvider();
this.validateResolvedCredentials(credentials);
const region = signingRegion != null ? signingRegion : await this.regionProvider();
const { shortDate } = formatDate(signingDate);
const hash = new this.sha256(await this.getSigningKey(credentials, region, shortDate, signingService));
hash.update(stringToSign);
return toHex1(await hash.digest());
}
async signRequest(requestToSign, { signingDate =new Date() , signableHeaders , unsignableHeaders , signingRegion , signingService } = {}) {
const credentials = await this.credentialProvider();
this.validateResolvedCredentials(credentials);
const region = signingRegion != null ? signingRegion : await this.regionProvider();
const request = prepareRequest(requestToSign);
const { longDate , shortDate } = formatDate(signingDate);
const scope = createScope(shortDate, region, signingService != null ? signingService : this.service);
request.headers[AMZ_DATE_HEADER] = longDate;
if (credentials.sessionToken) {
request.headers[TOKEN_HEADER] = credentials.sessionToken;
}
const payloadHash = await getPayloadHash(request, this.sha256);
if (!hasHeader1(SHA256_HEADER, request.headers) && this.applyChecksum) {
request.headers[SHA256_HEADER] = payloadHash;
}
const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
const signature = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, payloadHash));
request.headers[AUTH_HEADER] = `${ALGORITHM_IDENTIFIER} Credential=${credentials.accessKeyId}/${scope}, SignedHeaders=${getCanonicalHeaderList(canonicalHeaders)}, Signature=${signature}`;
return request;
}
createCanonicalRequest(request, canonicalHeaders, payloadHash) {
const sortedHeaders = Object.keys(canonicalHeaders).sort();
return `${request.method}
${this.getCanonicalPath(request)}
${getCanonicalQuery(request)}
${sortedHeaders.map((name)=>`${name}:${canonicalHeaders[name]}`).join("\n")}
${sortedHeaders.join(";")}
${payloadHash}`;
}
async createStringToSign(longDate, credentialScope, canonicalRequest) {
const hash = new this.sha256();
hash.update(canonicalRequest);
const hashedRequest = await hash.digest();
return `${ALGORITHM_IDENTIFIER}
${longDate}
${credentialScope}
${toHex1(hashedRequest)}`;
}
getCanonicalPath({ path }) {
if (this.uriEscapePath) {
const normalizedPathSegments = [];
for (const pathSegment of path.split("/")){
if ((pathSegment == null ? void 0 : pathSegment.length) === 0) continue;
if (pathSegment === ".") continue;
if (pathSegment === "..") {
normalizedPathSegments.pop();
} else {
normalizedPathSegments.push(pathSegment);
}
}
const normalizedPath = `${(path == null ? void 0 : path.startsWith("/")) ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && (path == null ? void 0 : path.endsWith("/")) ? "/" : ""}`;
const doubleEncoded = encodeURIComponent(normalizedPath);
return doubleEncoded.replace(/%2F/g, "/");
}
return path;
}
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
const hash = new this.sha256(await keyPromise);
hash.update(stringToSign);
return toHex1(await hash.digest());
}
getSigningKey(credentials, region, shortDate, service) {
return getSigningKey(this.sha256, credentials, shortDate, region, service || this.service);
}
validateResolvedCredentials(credentials) {
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
throw new Error("Resolved credential object is not valid");
}
}
}
const formatDate = (now)=>{
const longDate = iso8601(now).replace(/[\-:]/g, "");
return {
longDate,
shortDate: longDate.slice(0, 8)
};
};
const getCanonicalHeaderList = (headers)=>Object.keys(headers).sort().join(";");
const resolveAwsAuthConfig = (input)=>{
const normalizedCreds = input.credentials ? normalizeCredentialProvider(input.credentials) : input.credentialDefaultProvider(input);
const { signingEscapePath =true , systemClockOffset =input.systemClockOffset || 0 , sha256 } = input;
let signer;
if (input.signer) {
signer = normalizeProvider(input.signer);
} else if (input.regionInfoProvider) {
signer = ()=>normalizeProvider(input.region)().then(async (region)=>[
await input.regionInfoProvider(region, {
useFipsEndpoint: await input.useFipsEndpoint(),
useDualstackEndpoint: await input.useDualstackEndpoint()
}) || {},
region
]).then(([regionInfo, region])=>{
const { signingRegion , signingService } = regionInfo;
input.signingRegion = input.signingRegion || signingRegion || region;
input.signingName = input.signingName || signingService || input.serviceId;
const params = {
...input,
credentials: normalizedCreds,
region: input.signingRegion,
service: input.signingName,
sha256,
uriEscapePath: signingEscapePath
};
const SignerCtor = input.signerConstructor || SignatureV4;
return new SignerCtor(params);
});
} else {
signer = async (authScheme)=>{
authScheme = Object.assign({}, {
name: "sigv4",
signingName: input.signingName || input.defaultSigningName,
signingRegion: await normalizeProvider(input.region)(),
properties: {}
}, authScheme);
const signingRegion = authScheme.signingRegion;
const signingService = authScheme.signingName;
input.signingRegion = input.signingRegion || signingRegion;
input.signingName = input.signingName || signingService || input.serviceId;
const params = {
...input,
credentials: normalizedCreds,
region: input.signingRegion,
service: input.signingName,
sha256,
uriEscapePath: signingEscapePath
};
const SignerCtor = input.signerConstructor || SignatureV4;
return new SignerCtor(params);
};
}
return {
...input,
systemClockOffset,
signingEscapePath,
credentials: normalizedCreds,
signer
};
};
const normalizeCredentialProvider = (credentials)=>{
if (typeof credentials === "function") {
return memoize(credentials, (credentials2)=>credentials2.expiration !== void 0 && credentials2.expiration.getTime() - Date.now() < 3e5, (credentials2)=>credentials2.expiration !== void 0);
}
return normalizeProvider(credentials);
};
const getSkewCorrectedDate = (systemClockOffset)=>new Date(Date.now() + systemClockOffset);
const isClockSkewed = (clockTime, systemClockOffset)=>Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 3e5;
const getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset)=>{
const clockTimeInMs = Date.parse(clockTime);
if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
return clockTimeInMs - Date.now();
}
return currentSystemClockOffset;
};
const awsAuthMiddleware = (options)=>(next, context)=>async function(args) {
var _a, _b, _c, _d;
if (!HttpRequest.isInstance(args.request)) return next(args);
const authScheme = (_c = (_b = (_a = context.endpointV2) == null ? void 0 : _a.properties) == null ? void 0 : _b.authSchemes) == null ? void 0 : _c[0];
const multiRegionOverride = (authScheme == null ? void 0 : authScheme.name) === "sigv4a" ? (_d = authScheme == null ? void 0 : authScheme.signingRegionSet) == null ? void 0 : _d.join(",") : void 0;
const signer = await options.signer(authScheme);
const output = await next({
...args,
request: await signer.sign(args.request, {
signingDate: getSkewCorrectedDate(options.systemClockOffset),
signingRegion: multiRegionOverride || context["signing_region"],
signingService: context["signing_service"]
})
}).catch((error)=>{
var _a2;
const serverTime = (_a2 = error.ServerTime) != null ? _a2 : getDateHeader(error.$response);
if (serverTime) {
options.systemClockOffset = getUpdatedSystemClockOffset(serverTime, options.systemClockOffset);
}
throw error;
});
const dateHeader = getDateHeader(output.response);
if (dateHeader) {
options.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, options.systemClockOffset);
}
return output;
};
const getDateHeader = (response)=>{
var _a, _b, _c;
return HttpResponse.isInstance(response) ? (_c = (_a = response.headers) == null ? void 0 : _a.date) != null ? _c : (_b = response.headers) == null ? void 0 : _b.Date : void 0;
};
const awsAuthMiddlewareOptions = {
name: "awsAuthMiddleware",
tags: [
"SIGNATURE",
"AWSAUTH"
],
relation: "after",
toMiddleware: "retryMiddleware",
override: true
};
const getAwsAuthPlugin = (options)=>({
applyToStack: (clientStack)=>{
clientStack.addRelativeTo(awsAuthMiddleware(options), awsAuthMiddlewareOptions);
}
});
function resolveUserAgentConfig(input) {
return {
...input,
customUserAgent: typeof input.customUserAgent === "string" ? [
[
input.customUserAgent
]
] : input.customUserAgent
};
}
const USER_AGENT = "user-agent";
const X_AMZ_USER_AGENT = "x-amz-user-agent";
const SPACE = " ";
const UA_ESCAPE_REGEX = /[^\!\#\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
const userAgentMiddleware = (options)=>(next, context)=>async (args)=>{
var _a, _b;
const { request } = args;
if (!HttpRequest.isInstance(request)) return next(args);
const { headers } = request;
const userAgent = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
const customUserAgent = ((_b = options == null ? void 0 : options.customUserAgent) == null ? void 0 : _b.map(escapeUserAgent)) || [];
const sdkUserAgentValue = [
...defaultUserAgent,
...userAgent,
...customUserAgent
].join(SPACE);
const normalUAValue = [
...defaultUserAgent.filter((section)=>section.startsWith("aws-sdk-")),
...customUserAgent
].join(SPACE);
if (options.runtime !== "browser") {
if (normalUAValue) {
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT]} ${normalUAValue}` : normalUAValue;
}
headers[USER_AGENT] = sdkUserAgentValue;
} else {
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
}
return next({
...args,
request
});
};
const escapeUserAgent = ([name, version])=>{
const prefixSeparatorIndex = name.indexOf("/");
const prefix = name.substring(0, prefixSeparatorIndex);
let uaName = name.substring(prefixSeparatorIndex + 1);
if (prefix === "api") {
uaName = uaName.toLowerCase();
}
return [
prefix,
uaName,
version
].filter((item)=>item && item.length > 0).map((item)=>item == null ? void 0 : item.replace(UA_ESCAPE_REGEX, "_")).join("/");
};
const getUserAgentMiddlewareOptions = {
name: "getUserAgentMiddleware",
step: "build",
priority: "low",
tags: [
"SET_USER_AGENT",
"USER_AGENT"
],
override: true
};
const getUserAgentPlugin = (config)=>({
applyToStack: (clientStack)=>{
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
}
});
var fromUtf81 = function(input) {
var bytes = [];
for(var i = 0, len = input.length; i < len; i++){
var value = input.charCodeAt(i);
if (value < 128) {
bytes.push(value);
} else if (value < 2048) {
bytes.push(value >> 6 | 192, value & 63 | 128);
} else if (i + 1 < input.length && (value & 64512) === 55296 && (input.charCodeAt(i + 1) & 64512) === 56320) {
var surrogatePair = 65536 + ((value & 1023) << 10) + (input.charCodeAt(++i) & 1023);
bytes.push(surrogatePair >> 18 | 240, surrogatePair >> 12 & 63 | 128, surrogatePair >> 6 & 63 | 128, surrogatePair & 63 | 128);
} else {
bytes.push(value >> 12 | 224, value >> 6 & 63 | 128, value & 63 | 128);
}
}
return Uint8Array.from(bytes);
};
var toUtf81 = function(input) {
var decoded = "";
for(var i = 0, len = input.length; i < len; i++){
var __byte = input[i];
if (__byte < 128) {
decoded += String.fromCharCode(__byte);
} else if (192 <= __byte && __byte < 224) {
var nextByte = input[++i];
decoded += String.fromCharCode((__byte & 31) << 6 | nextByte & 63);
} else if (240 <= __byte && __byte < 365) {
var surrogatePair = [
__byte,
input[++i],
input[++i],
input[++i]
];
var encoded = "%" + surrogatePair.map(function(byteValue) {
return byteValue.toString(16);
}).join("%");
decoded += decodeURIComponent(encoded);
} else {
decoded += String.fromCharCode((__byte & 15) << 12 | (input[++i] & 63) << 6 | input[++i] & 63);
}
}
return decoded;
};
function fromUtf8$11(input) {
return new TextEncoder().encode(input);
}
function toUtf8$11(input) {
return new TextDecoder("utf-8").decode(input);
}
var fromUtf8$21 = function(input) {
return typeof TextEncoder === "function" ? fromUtf8$11(input) : fromUtf81(input);
};
var toUtf8$21 = function(input) {
return typeof TextDecoder === "function" ? toUtf8$11(input) : toUtf81(input);
};
const mod2 = function() {
return {
fromUtf8: fromUtf8$21,
toUtf8: toUtf8$21,
default: null
};
}();
var fallbackWindow = {};
function locateWindow() {
if (typeof window !== "undefined") {
return window;
} else if (typeof self !== "undefined") {
return self;
}
return fallbackWindow;
}
const mod3 = function() {
return {
locateWindow: locateWindow,
default: null
};
}();
function getDefaultExportFromCjs3(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule4(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire4(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed3(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire4() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var tslib_12 = getDefaultExportFromNamespaceIfNotNamed3(mod);
var supportsWebCrypto_1 = createCommonjsModule4(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.supportsZeroByteGCM = exports.supportsSubtleCrypto = exports.supportsSecureRandom = exports.supportsWebCrypto = void 0;
var subtleCryptoMethods = [
"decrypt",
"digest",
"encrypt",
"exportKey",
"generateKey",
"importKey",
"sign",
"verify"
];
function supportsWebCrypto(window1) {
if (supportsSecureRandom(window1) && typeof window1.crypto.subtle === "object") {
var subtle = window1.crypto.subtle;
return supportsSubtleCrypto(subtle);
}
return false;
}
exports.supportsWebCrypto = supportsWebCrypto;
function supportsSecureRandom(window1) {
if (typeof window1 === "object" && typeof window1.crypto === "object") {
var getRandomValues = window1.crypto.getRandomValues;
return typeof getRandomValues === "function";
}
return false;
}
exports.supportsSecureRandom = supportsSecureRandom;
function supportsSubtleCrypto(subtle) {
return subtle && subtleCryptoMethods.every(function(methodName) {
return typeof subtle[methodName] === "function";
});
}
exports.supportsSubtleCrypto = supportsSubtleCrypto;
function supportsZeroByteGCM(subtle) {
return (0, tslib_12.__awaiter)(this, void 0, void 0, function() {
var key, zeroByteAuthTag;
return (0, tslib_12.__generator)(this, function(_b) {
switch(_b.label){
case 0:
if (!supportsSubtleCrypto(subtle)) return [
2,
false
];
_b.label = 1;
case 1:
_b.trys.push([
1,
4,
,
5
]);
return [
4,
subtle.generateKey({
name: "AES-GCM",
length: 128
}, false, [
"encrypt"
])
];
case 2:
key = _b.sent();
return [
4,
subtle.encrypt({
name: "AES-GCM",
iv: new Uint8Array(Array(12)),
additionalData: new Uint8Array(Array(16)),
tagLength: 128
}, key, new Uint8Array(0))
];
case 3:
zeroByteAuthTag = _b.sent();
return [
2,
zeroByteAuthTag.byteLength === 16
];
case 4:
_b.sent();
return [
2,
false
];
case 5:
return [
2
];
}
});
});
}
exports.supportsZeroByteGCM = supportsZeroByteGCM;
});
var build3 = createCommonjsModule4(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
(0, tslib_12.__exportStar)(supportsWebCrypto_1, exports);
});
var index = getDefaultExportFromCjs3(build3);
function getDefaultExportFromCjs4(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule5(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire5(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed4(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire5() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var CryptoOperation = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
});
var Key = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
});
var KeyOperation = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
});
var MsSubtleCrypto = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
});
var MsWindow = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isMsWindow = void 0;
var msSubtleCryptoMethods = [
"decrypt",
"digest",
"encrypt",
"exportKey",
"generateKey",
"importKey",
"sign",
"verify"
];
function quacksLikeAnMsWindow(window1) {
return "MSInputMethodContext" in window1 && "msCrypto" in window1;
}
function isMsWindow(window1) {
if (quacksLikeAnMsWindow(window1) && window1.msCrypto.subtle !== void 0) {
var _a = window1.msCrypto, getRandomValues = _a.getRandomValues, subtle_1 = _a.subtle;
return msSubtleCryptoMethods.map(function(methodName) {
return subtle_1[methodName];
}).concat(getRandomValues).every(function(method) {
return typeof method === "function";
});
}
return false;
}
exports.isMsWindow = isMsWindow;
});
var tslib_13 = getDefaultExportFromNamespaceIfNotNamed4(mod);
var build4 = createCommonjsModule5(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
(0, tslib_13.__exportStar)(CryptoOperation, exports);
(0, tslib_13.__exportStar)(Key, exports);
(0, tslib_13.__exportStar)(KeyOperation, exports);
(0, tslib_13.__exportStar)(MsSubtleCrypto, exports);
(0, tslib_13.__exportStar)(MsWindow, exports);
});
var index1 = getDefaultExportFromCjs4(build4);
function getDefaultExportFromCjs5(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule6(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire6(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed5(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire6() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var isEmptyData_11 = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmptyData = void 0;
function isEmptyData(data) {
if (typeof data === "string") {
return data.length === 0;
}
return data.byteLength === 0;
}
exports.isEmptyData = isEmptyData;
});
var constants = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EMPTY_DATA_SHA_1 = exports.SHA_1_HMAC_ALGO = exports.SHA_1_HASH = void 0;
exports.SHA_1_HASH = {
name: "SHA-1"
};
exports.SHA_1_HMAC_ALGO = {
name: "HMAC",
hash: exports.SHA_1_HASH
};
exports.EMPTY_DATA_SHA_1 = new Uint8Array([
218,
57,
163,
238,
94,
107,
75,
13,
50,
85,
191,
239,
149,
96,
24,
144,
175,
216,
7,
9
]);
});
var util_utf8_browser_11 = getDefaultExportFromNamespaceIfNotNamed5(mod2);
var util_locate_window_1 = getDefaultExportFromNamespaceIfNotNamed5(mod3);
var ie11Sha1 = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha1 = void 0;
var Sha1 = function() {
function Sha12(secret) {
if (secret) {
this.operation = getKeyPromise(secret).then(function(keyData) {
return (0, util_locate_window_1.locateWindow)().msCrypto.subtle.sign(constants.SHA_1_HMAC_ALGO, keyData);
});
this.operation.catch(function() {});
} else {
this.operation = Promise.resolve((0, util_locate_window_1.locateWindow)().msCrypto.subtle.digest("SHA-1"));
}
}
Sha12.prototype.update = function(toHash) {
var _this = this;
if ((0, isEmptyData_11.isEmptyData)(toHash)) {
return;
}
this.operation = this.operation.then(function(operation) {
operation.onerror = function() {
_this.operation = Promise.reject(new Error("Error encountered updating hash"));
};
operation.process(toArrayBufferView(toHash));
return operation;
});
this.operation.catch(function() {});
};
Sha12.prototype.digest = function() {
return this.operation.then(function(operation) {
return new Promise(function(resolve, reject) {
operation.onerror = function() {
reject(new Error("Error encountered finalizing hash"));
};
operation.oncomplete = function() {
if (operation.result) {
resolve(new Uint8Array(operation.result));
}
reject(new Error("Error encountered finalizing hash"));
};
operation.finish();
});
});
};
return Sha12;
}();
exports.Sha1 = Sha1;
function getKeyPromise(secret) {
return new Promise(function(resolve, reject) {
var keyOperation = (0, util_locate_window_1.locateWindow)().msCrypto.subtle.importKey("raw", toArrayBufferView(secret), constants.SHA_1_HMAC_ALGO, false, [
"sign"
]);
keyOperation.oncomplete = function() {
if (keyOperation.result) {
resolve(keyOperation.result);
}
reject(new Error("ImportKey completed without importing key."));
};
keyOperation.onerror = function() {
reject(new Error("ImportKey failed to import key."));
};
});
}
function toArrayBufferView(data) {
if (typeof data === "string") {
return (0, util_utf8_browser_11.fromUtf8)(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}
});
var webCryptoSha1 = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha1 = void 0;
var Sha1 = function() {
function Sha12(secret) {
this.toHash = new Uint8Array(0);
if (secret !== void 0) {
this.key = new Promise(function(resolve, reject) {
(0, util_locate_window_1.locateWindow)().crypto.subtle.importKey("raw", convertToBuffer(secret), constants.SHA_1_HMAC_ALGO, false, [
"sign"
]).then(resolve, reject);
});
this.key.catch(function() {});
}
}
Sha12.prototype.update = function(data) {
if ((0, isEmptyData_11.isEmptyData)(data)) {
return;
}
var update = convertToBuffer(data);
var typedArray = new Uint8Array(this.toHash.byteLength + update.byteLength);
typedArray.set(this.toHash, 0);
typedArray.set(update, this.toHash.byteLength);
this.toHash = typedArray;
};
Sha12.prototype.digest = function() {
var _this = this;
if (this.key) {
return this.key.then(function(key) {
return (0, util_locate_window_1.locateWindow)().crypto.subtle.sign(constants.SHA_1_HMAC_ALGO, key, _this.toHash).then(function(data) {
return new Uint8Array(data);
});
});
}
if ((0, isEmptyData_11.isEmptyData)(this.toHash)) {
return Promise.resolve(constants.EMPTY_DATA_SHA_1);
}
return Promise.resolve().then(function() {
return (0, util_locate_window_1.locateWindow)().crypto.subtle.digest(constants.SHA_1_HASH, _this.toHash);
}).then(function(data) {
return Promise.resolve(new Uint8Array(data));
});
};
return Sha12;
}();
exports.Sha1 = Sha1;
function convertToBuffer(data) {
if (typeof data === "string") {
return (0, util_utf8_browser_11.fromUtf8)(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}
});
var crossPlatformSha1 = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha1 = void 0;
var Sha1 = function() {
function Sha12(secret) {
if ((0, index.supportsWebCrypto)((0, util_locate_window_1.locateWindow)())) {
this.hash = new webCryptoSha1.Sha1(secret);
} else if ((0, index1.isMsWindow)((0, util_locate_window_1.locateWindow)())) {
this.hash = new ie11Sha1.Sha1(secret);
} else {
throw new Error("SHA1 not supported");
}
}
Sha12.prototype.update = function(data, encoding) {
this.hash.update(data, encoding);
};
Sha12.prototype.digest = function() {
return this.hash.digest();
};
return Sha12;
}();
exports.Sha1 = Sha1;
});
var tslib_14 = getDefaultExportFromNamespaceIfNotNamed5(mod);
var build5 = createCommonjsModule6(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WebCryptoSha1 = exports.Ie11Sha1 = void 0;
(0, tslib_14.__exportStar)(crossPlatformSha1, exports);
Object.defineProperty(exports, "Ie11Sha1", {
enumerable: true,
get: function() {
return ie11Sha1.Sha1;
}
});
Object.defineProperty(exports, "WebCryptoSha1", {
enumerable: true,
get: function() {
return webCryptoSha1.Sha1;
}
});
});
var __pika_web_default_export_for_treeshaking__3 = getDefaultExportFromCjs5(build5);
build5.Ie11Sha1;
build5.WebCryptoSha1;
var fallbackWindow1 = {};
function locateWindow1() {
if (typeof window !== "undefined") {
return window;
} else if (typeof self !== "undefined") {
return self;
}
return fallbackWindow1;
}
const mod4 = function() {
return {
locateWindow: locateWindow1,
default: null
};
}();
function getDefaultExportFromCjs6(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule7(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire7(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed6(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire7() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var constants1 = createCommonjsModule7(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MAX_HASHABLE_LENGTH = exports.INIT = exports.KEY = exports.DIGEST_LENGTH = exports.BLOCK_SIZE = void 0;
exports.BLOCK_SIZE = 64;
exports.DIGEST_LENGTH = 32;
exports.KEY = new Uint32Array([
1116352408,
1899447441,
3049323471,
3921009573,
961987163,
1508970993,
2453635748,
2870763221,
3624381080,
310598401,
607225278,
1426881987,
1925078388,
2162078206,
2614888103,
3248222580,
3835390401,
4022224774,
264347078,
604807628,
770255983,
1249150122,
1555081692,
1996064986,
2554220882,
2821834349,
2952996808,
3210313671,
3336571891,
3584528711,
113926993,
338241895,
666307205,
773529912,
1294757372,
1396182291,
1695183700,
1986661051,
2177026350,
2456956037,
2730485921,
2820302411,
3259730800,
3345764771,
3516065817,
3600352804,
4094571909,
275423344,
430227734,
506948616,
659060556,
883997877,
958139571,
1322822218,
1537002063,
1747873779,
1955562222,
2024104815,
2227730452,
2361852424,
2428436474,
2756734187,
3204031479,
3329325298
]);
exports.INIT = [
1779033703,
3144134277,
1013904242,
2773480762,
1359893119,
2600822924,
528734635,
1541459225
];
exports.MAX_HASHABLE_LENGTH = Math.pow(2, 53) - 1;
});
var RawSha256_1 = createCommonjsModule7(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RawSha256 = void 0;
var RawSha256 = function() {
function RawSha2562() {
this.state = Int32Array.from(constants1.INIT);
this.temp = new Int32Array(64);
this.buffer = new Uint8Array(64);
this.bufferLength = 0;
this.bytesHashed = 0;
this.finished = false;
}
RawSha2562.prototype.update = function(data) {
if (this.finished) {
throw new Error("Attempted to update an already finished hash.");
}
var position = 0;
var byteLength = data.byteLength;
this.bytesHashed += byteLength;
if (this.bytesHashed * 8 > constants1.MAX_HASHABLE_LENGTH) {
throw new Error("Cannot hash more than 2^53 - 1 bits");
}
while(byteLength > 0){
this.buffer[this.bufferLength++] = data[position++];
byteLength--;
if (this.bufferLength === constants1.BLOCK_SIZE) {
this.hashBuffer();
this.bufferLength = 0;
}
}
};
RawSha2562.prototype.digest = function() {
if (!this.finished) {
var bitsHashed = this.bytesHashed * 8;
var bufferView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
var undecoratedLength = this.bufferLength;
bufferView.setUint8(this.bufferLength++, 128);
if (undecoratedLength % constants1.BLOCK_SIZE >= constants1.BLOCK_SIZE - 8) {
for(var i = this.bufferLength; i < constants1.BLOCK_SIZE; i++){
bufferView.setUint8(i, 0);
}
this.hashBuffer();
this.bufferLength = 0;
}
for(var i = this.bufferLength; i < constants1.BLOCK_SIZE - 8; i++){
bufferView.setUint8(i, 0);
}
bufferView.setUint32(constants1.BLOCK_SIZE - 8, Math.floor(bitsHashed / 4294967296), true);
bufferView.setUint32(constants1.BLOCK_SIZE - 4, bitsHashed);
this.hashBuffer();
this.finished = true;
}
var out = new Uint8Array(constants1.DIGEST_LENGTH);
for(var i = 0; i < 8; i++){
out[i * 4] = this.state[i] >>> 24 & 255;
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
}
return out;
};
RawSha2562.prototype.hashBuffer = function() {
var _a = this, buffer = _a.buffer, state = _a.state;
var state0 = state[0], state1 = state[1], state2 = state[2], state3 = state[3], state4 = state[4], state5 = state[5], state6 = state[6], state7 = state[7];
for(var i = 0; i < constants1.BLOCK_SIZE; i++){
if (i < 16) {
this.temp[i] = (buffer[i * 4] & 255) << 24 | (buffer[i * 4 + 1] & 255) << 16 | (buffer[i * 4 + 2] & 255) << 8 | buffer[i * 4 + 3] & 255;
} else {
var u = this.temp[i - 2];
var t1_1 = (u >>> 17 | u << 15) ^ (u >>> 19 | u << 13) ^ u >>> 10;
u = this.temp[i - 15];
var t2_1 = (u >>> 7 | u << 25) ^ (u >>> 18 | u << 14) ^ u >>> 3;
this.temp[i] = (t1_1 + this.temp[i - 7] | 0) + (t2_1 + this.temp[i - 16] | 0);
}
var t1 = (((state4 >>> 6 | state4 << 26) ^ (state4 >>> 11 | state4 << 21) ^ (state4 >>> 25 | state4 << 7)) + (state4 & state5 ^ ~state4 & state6) | 0) + (state7 + (constants1.KEY[i] + this.temp[i] | 0) | 0) | 0;
var t2 = ((state0 >>> 2 | state0 << 30) ^ (state0 >>> 13 | state0 << 19) ^ (state0 >>> 22 | state0 << 10)) + (state0 & state1 ^ state0 & state2 ^ state1 & state2) | 0;
state7 = state6;
state6 = state5;
state5 = state4;
state4 = state3 + t1 | 0;
state3 = state2;
state2 = state1;
state1 = state0;
state0 = t1 + t2 | 0;
}
state[0] += state0;
state[1] += state1;
state[2] += state2;
state[3] += state3;
state[4] += state4;
state[5] += state5;
state[6] += state6;
state[7] += state7;
};
return RawSha2562;
}();
exports.RawSha256 = RawSha256;
});
var tslib_15 = getDefaultExportFromNamespaceIfNotNamed6(mod);
var jsSha256 = createCommonjsModule7(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha256 = void 0;
var Sha256 = function() {
function Sha2562(secret) {
this.hash = new RawSha256_1.RawSha256();
if (secret) {
this.outer = new RawSha256_1.RawSha256();
var inner = bufferFromSecret(secret);
var outer = new Uint8Array(constants1.BLOCK_SIZE);
outer.set(inner);
for(var i = 0; i < constants1.BLOCK_SIZE; i++){
inner[i] ^= 54;
outer[i] ^= 92;
}
this.hash.update(inner);
this.outer.update(outer);
for(var i = 0; i < inner.byteLength; i++){
inner[i] = 0;
}
}
}
Sha2562.prototype.update = function(toHash) {
if ((0, __pika_web_default_export_for_treeshaking__.isEmptyData)(toHash) || this.error) {
return;
}
try {
this.hash.update((0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(toHash));
} catch (e) {
this.error = e;
}
};
Sha2562.prototype.digestSync = function() {
if (this.error) {
throw this.error;
}
if (this.outer) {
if (!this.outer.finished) {
this.outer.update(this.hash.digest());
}
return this.outer.digest();
}
return this.hash.digest();
};
Sha2562.prototype.digest = function() {
return (0, tslib_15.__awaiter)(this, void 0, void 0, function() {
return (0, tslib_15.__generator)(this, function(_a) {
return [
2,
this.digestSync()
];
});
});
};
return Sha2562;
}();
exports.Sha256 = Sha256;
function bufferFromSecret(secret) {
var input = (0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(secret);
if (input.byteLength > constants1.BLOCK_SIZE) {
var bufferHash = new RawSha256_1.RawSha256();
bufferHash.update(input);
input = bufferHash.digest();
}
var buffer = new Uint8Array(constants1.BLOCK_SIZE);
buffer.set(input);
return buffer;
}
});
var build6 = createCommonjsModule7(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
(0, tslib_15.__exportStar)(jsSha256, exports);
});
var index2 = getDefaultExportFromCjs6(build6);
function getDefaultExportFromCjs7(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function createCommonjsModule8(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function(path, base) {
return commonjsRequire8(path, base === void 0 || base === null ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getDefaultExportFromNamespaceIfNotNamed7(n) {
return n && Object.prototype.hasOwnProperty.call(n, "default") && Object.keys(n).length === 1 ? n["default"] : n;
}
function commonjsRequire8() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
var isEmptyData_12 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmptyData = void 0;
function isEmptyData(data) {
if (typeof data === "string") {
return data.length === 0;
}
return data.byteLength === 0;
}
exports.isEmptyData = isEmptyData;
});
var constants2 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EMPTY_DATA_SHA_256 = exports.SHA_256_HMAC_ALGO = exports.SHA_256_HASH = void 0;
exports.SHA_256_HASH = {
name: "SHA-256"
};
exports.SHA_256_HMAC_ALGO = {
name: "HMAC",
hash: exports.SHA_256_HASH
};
exports.EMPTY_DATA_SHA_256 = new Uint8Array([
227,
176,
196,
66,
152,
252,
28,
20,
154,
251,
244,
200,
153,
111,
185,
36,
39,
174,
65,
228,
100,
155,
147,
76,
164,
149,
153,
27,
120,
82,
184,
85
]);
});
var util_utf8_browser_12 = getDefaultExportFromNamespaceIfNotNamed7(mod1);
var util_locate_window_11 = getDefaultExportFromNamespaceIfNotNamed7(mod4);
var ie11Sha256 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha256 = void 0;
var Sha256 = function() {
function Sha2562(secret) {
if (secret) {
this.operation = getKeyPromise(secret).then(function(keyData) {
return (0, util_locate_window_11.locateWindow)().msCrypto.subtle.sign(constants2.SHA_256_HMAC_ALGO, keyData);
});
this.operation.catch(function() {});
} else {
this.operation = Promise.resolve((0, util_locate_window_11.locateWindow)().msCrypto.subtle.digest("SHA-256"));
}
}
Sha2562.prototype.update = function(toHash) {
var _this = this;
if ((0, isEmptyData_12.isEmptyData)(toHash)) {
return;
}
this.operation = this.operation.then(function(operation) {
operation.onerror = function() {
_this.operation = Promise.reject(new Error("Error encountered updating hash"));
};
operation.process(toArrayBufferView(toHash));
return operation;
});
this.operation.catch(function() {});
};
Sha2562.prototype.digest = function() {
return this.operation.then(function(operation) {
return new Promise(function(resolve, reject) {
operation.onerror = function() {
reject(new Error("Error encountered finalizing hash"));
};
operation.oncomplete = function() {
if (operation.result) {
resolve(new Uint8Array(operation.result));
}
reject(new Error("Error encountered finalizing hash"));
};
operation.finish();
});
});
};
return Sha2562;
}();
exports.Sha256 = Sha256;
function getKeyPromise(secret) {
return new Promise(function(resolve, reject) {
var keyOperation = (0, util_locate_window_11.locateWindow)().msCrypto.subtle.importKey("raw", toArrayBufferView(secret), constants2.SHA_256_HMAC_ALGO, false, [
"sign"
]);
keyOperation.oncomplete = function() {
if (keyOperation.result) {
resolve(keyOperation.result);
}
reject(new Error("ImportKey completed without importing key."));
};
keyOperation.onerror = function() {
reject(new Error("ImportKey failed to import key."));
};
});
}
function toArrayBufferView(data) {
if (typeof data === "string") {
return (0, util_utf8_browser_12.fromUtf8)(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}
});
var webCryptoSha256 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha256 = void 0;
var Sha256 = function() {
function Sha2562(secret) {
this.toHash = new Uint8Array(0);
if (secret !== void 0) {
this.key = new Promise(function(resolve, reject) {
(0, util_locate_window_11.locateWindow)().crypto.subtle.importKey("raw", (0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(secret), constants2.SHA_256_HMAC_ALGO, false, [
"sign"
]).then(resolve, reject);
});
this.key.catch(function() {});
}
}
Sha2562.prototype.update = function(data) {
if ((0, __pika_web_default_export_for_treeshaking__.isEmptyData)(data)) {
return;
}
var update = (0, __pika_web_default_export_for_treeshaking__.convertToBuffer)(data);
var typedArray = new Uint8Array(this.toHash.byteLength + update.byteLength);
typedArray.set(this.toHash, 0);
typedArray.set(update, this.toHash.byteLength);
this.toHash = typedArray;
};
Sha2562.prototype.digest = function() {
var _this = this;
if (this.key) {
return this.key.then(function(key) {
return (0, util_locate_window_11.locateWindow)().crypto.subtle.sign(constants2.SHA_256_HMAC_ALGO, key, _this.toHash).then(function(data) {
return new Uint8Array(data);
});
});
}
if ((0, __pika_web_default_export_for_treeshaking__.isEmptyData)(this.toHash)) {
return Promise.resolve(constants2.EMPTY_DATA_SHA_256);
}
return Promise.resolve().then(function() {
return (0, util_locate_window_11.locateWindow)().crypto.subtle.digest(constants2.SHA_256_HASH, _this.toHash);
}).then(function(data) {
return Promise.resolve(new Uint8Array(data));
});
};
return Sha2562;
}();
exports.Sha256 = Sha256;
});
var crossPlatformSha256 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Sha256 = void 0;
var Sha256 = function() {
function Sha2562(secret) {
if ((0, index.supportsWebCrypto)((0, util_locate_window_11.locateWindow)())) {
this.hash = new webCryptoSha256.Sha256(secret);
} else if ((0, index1.isMsWindow)((0, util_locate_window_11.locateWindow)())) {
this.hash = new ie11Sha256.Sha256(secret);
} else {
this.hash = new index2.Sha256(secret);
}
}
Sha2562.prototype.update = function(data, encoding) {
this.hash.update(data, encoding);
};
Sha2562.prototype.digest = function() {
return this.hash.digest();
};
return Sha2562;
}();
exports.Sha256 = Sha256;
});
var tslib_16 = getDefaultExportFromNamespaceIfNotNamed7(mod);
var build7 = createCommonjsModule8(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WebCryptoSha256 = exports.Ie11Sha256 = void 0;
(0, tslib_16.__exportStar)(crossPlatformSha256, exports);
Object.defineProperty(exports, "Ie11Sha256", {
enumerable: true,
get: function() {
return ie11Sha256.Sha256;
}
});
Object.defineProperty(exports, "WebCryptoSha256", {
enumerable: true,
get: function() {
return webCryptoSha256.Sha256;
}
});
});
var __pika_web_default_export_for_treeshaking__4 = getDefaultExportFromCjs7(build7);
build7.Ie11Sha256;
build7.WebCryptoSha256;
const { Crc32 } = __pika_web_default_export_for_treeshaking__1;
class Int64 {
constructor(bytes){
this.bytes = bytes;
if (bytes.byteLength !== 8) {
throw new Error("Int64 buffers must be exactly 8 bytes");
}
}
static fromNumber(number) {
if (number > 9223372036854776e3 || number < -9223372036854776e3) {
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
}
const bytes = new Uint8Array(8);
for(let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256){
bytes[i] = remaining;
}
if (number < 0) {
negate(bytes);
}
return new Int64(bytes);
}
valueOf() {
const bytes = this.bytes.slice(0);
const negative = bytes[0] & 128;
if (negative) {
negate(bytes);
}
return parseInt(toHex1(bytes), 16) * (negative ? -1 : 1);
}
toString() {
return String(this.valueOf());
}
}
function negate(bytes) {
for(let i = 0; i < 8; i++){
bytes[i] ^= 255;
}
for(let i1 = 7; i1 > -1; i1--){
bytes[i1]++;
if (bytes[i1] !== 0) break;
}
}
class HeaderMarshaller {
constructor(toUtf8, fromUtf8){
this.toUtf8 = toUtf8;
this.fromUtf8 = fromUtf8;
}
format(headers) {
const chunks = [];
for (const headerName of Object.keys(headers)){
const bytes = this.fromUtf8(headerName);
chunks.push(Uint8Array.from([
bytes.byteLength
]), bytes, this.formatHeaderValue(headers[headerName]));
}
const out = new Uint8Array(chunks.reduce((carry, bytes)=>carry + bytes.byteLength, 0));
let position = 0;
for (const chunk of chunks){
out.set(chunk, position);
position += chunk.byteLength;
}
return out;
}
formatHeaderValue(header) {
switch(header.type){
case "boolean":
return Uint8Array.from([
header.value ? 0 : 1
]);
case "byte":
return Uint8Array.from([
2,
header.value
]);
case "short":
const shortView = new DataView(new ArrayBuffer(3));
shortView.setUint8(0, 3);
shortView.setInt16(1, header.value, false);
return new Uint8Array(shortView.buffer);
case "integer":
const intView = new DataView(new ArrayBuffer(5));
intView.setUint8(0, 4);
intView.setInt32(1, header.value, false);
return new Uint8Array(intView.buffer);
case "long":
const longBytes = new Uint8Array(9);
longBytes[0] = 5;
longBytes.set(header.value.bytes, 1);
return longBytes;
case "binary":
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
binView.setUint8(0, 6);
binView.setUint16(1, header.value.byteLength, false);
const binBytes = new Uint8Array(binView.buffer);
binBytes.set(header.value, 3);
return binBytes;
case "string":
const utf8Bytes = this.fromUtf8(header.value);
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
strView.setUint8(0, 7);
strView.setUint16(1, utf8Bytes.byteLength, false);
const strBytes = new Uint8Array(strView.buffer);
strBytes.set(utf8Bytes, 3);
return strBytes;
case "timestamp":
const tsBytes = new Uint8Array(9);
tsBytes[0] = 8;
tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
return tsBytes;
case "uuid":
if (!UUID_PATTERN.test(header.value)) {
throw new Error(`Invalid UUID received: ${header.value}`);
}
const uuidBytes = new Uint8Array(17);
uuidBytes[0] = 9;
uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
return uuidBytes;
}
}
parse(headers) {
const out = {};
let position = 0;
while(position < headers.byteLength){
const nameLength = headers.getUint8(position++);
const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
position += nameLength;
switch(headers.getUint8(position++)){
case 0:
out[name] = {
type: BOOLEAN_TAG,
value: true
};
break;
case 1:
out[name] = {
type: BOOLEAN_TAG,
value: false
};
break;
case 2:
out[name] = {
type: BYTE_TAG,
value: headers.getInt8(position++)
};
break;
case 3:
out[name] = {
type: SHORT_TAG,
value: headers.getInt16(position, false)
};
position += 2;
break;
case 4:
out[name] = {
type: INT_TAG,
value: headers.getInt32(position, false)
};
position += 4;
break;
case 5:
out[name] = {
type: LONG_TAG,
value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
};
position += 8;
break;
case 6:
const binaryLength = headers.getUint16(position, false);
position += 2;
out[name] = {
type: BINARY_TAG,
value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
};
position += binaryLength;
break;
case 7:
const stringLength = headers.getUint16(position, false);
position += 2;
out[name] = {
type: STRING_TAG,
value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
};
position += stringLength;
break;
case 8:
out[name] = {
type: TIMESTAMP_TAG,
value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
};
position += 8;
break;
case 9:
const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
position += 16;
out[name] = {
type: UUID_TAG,
value: `${toHex1(uuidBytes.subarray(0, 4))}-${toHex1(uuidBytes.subarray(4, 6))}-${toHex1(uuidBytes.subarray(6, 8))}-${toHex1(uuidBytes.subarray(8, 10))}-${toHex1(uuidBytes.subarray(10))}`
};
break;
default:
throw new Error(`Unrecognized header type tag`);
}
}
return out;
}
}
var HEADER_VALUE_TYPE;
(function(HEADER_VALUE_TYPE2) {
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
const BOOLEAN_TAG = "boolean";
const BYTE_TAG = "byte";
const SHORT_TAG = "short";
const INT_TAG = "integer";
const LONG_TAG = "long";
const BINARY_TAG = "binary";
const STRING_TAG = "string";
const TIMESTAMP_TAG = "timestamp";
const UUID_TAG = "uuid";
const UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
const PRELUDE_LENGTH = 4 * 2;
const MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + 4 * 2;
function splitMessage({ byteLength , byteOffset , buffer }) {
if (byteLength < MINIMUM_MESSAGE_LENGTH) {
throw new Error("Provided message too short to accommodate event stream message overhead");
}
const view = new DataView(buffer, byteOffset, byteLength);
const messageLength = view.getUint32(0, false);
if (byteLength !== messageLength) {
throw new Error("Reported message length does not match received message length");
}
const headerLength = view.getUint32(4, false);
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
const expectedMessageChecksum = view.getUint32(byteLength - 4, false);
const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
if (expectedPreludeChecksum !== checksummer.digest()) {
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`);
}
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + 4)));
if (expectedMessageChecksum !== checksummer.digest()) {
throw new Error(`The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`);
}
return {
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + 4, headerLength),
body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + 4 + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + 4 + 4))
};
}
class EventStreamCodec {
constructor(toUtf8, fromUtf8){
this.headerMarshaller = new HeaderMarshaller(toUtf8, fromUtf8);
}
encode({ headers: rawHeaders , body }) {
const headers = this.headerMarshaller.format(rawHeaders);
const length = headers.byteLength + body.byteLength + 16;
const out = new Uint8Array(length);
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
const checksum = new Crc32();
view.setUint32(0, length, false);
view.setUint32(4, headers.byteLength, false);
view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
out.set(headers, 12);
out.set(body, headers.byteLength + 12);
view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
return out;
}
decode(message) {
const { headers , body } = splitMessage(message);
return {
headers: this.headerMarshaller.parse(headers),
body
};
}
formatHeaders(rawHeaders) {
return this.headerMarshaller.format(rawHeaders);
}
}
function getChunkedStream(source) {
let currentMessageTotalLength = 0;
let currentMessagePendingLength = 0;
let currentMessage = null;
let messageLengthBuffer = null;
const allocateMessage = (size)=>{
if (typeof size !== "number") {
throw new Error("Attempted to allocate an event message where size was not a number: " + size);
}
currentMessageTotalLength = size;
currentMessagePendingLength = 4;
currentMessage = new Uint8Array(size);
const currentMessageView = new DataView(currentMessage.buffer);
currentMessageView.setUint32(0, size, false);
};
const iterator = async function*() {
const sourceIterator = source[Symbol.asyncIterator]();
while(true){
const { value , done } = await sourceIterator.next();
if (done) {
if (!currentMessageTotalLength) {
return;
} else if (currentMessageTotalLength === currentMessagePendingLength) {
yield currentMessage;
} else {
throw new Error("Truncated event message received.");
}
return;
}
const chunkLength = value.length;
let currentOffset = 0;
while(currentOffset < chunkLength){
if (!currentMessage) {
const bytesRemaining = chunkLength - currentOffset;
if (!messageLengthBuffer) {
messageLengthBuffer = new Uint8Array(4);
}
const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
currentMessagePendingLength += numBytesForTotal;
currentOffset += numBytesForTotal;
if (currentMessagePendingLength < 4) {
break;
}
allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
messageLengthBuffer = null;
}
const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
currentMessagePendingLength += numBytesToWrite;
currentOffset += numBytesToWrite;
if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
yield currentMessage;
currentMessage = null;
currentMessageTotalLength = 0;
currentMessagePendingLength = 0;
}
}
}
};
return {
[Symbol.asyncIterator]: iterator
};
}
function getUnmarshalledStream(source, options) {
return {
[Symbol.asyncIterator]: async function*() {
for await (const chunk of source){
const message = options.eventStreamCodec.decode(chunk);
const { value: messageType } = message.headers[":message-type"];
if (messageType === "error") {
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
unmodeledError.name = message.headers[":error-code"].value;
throw unmodeledError;
} else if (messageType === "exception") {
const code = message.headers[":exception-type"].value;
const exception = {
[code]: message
};
const deserializedException = await options.deserializer(exception);
if (deserializedException.$unknown) {
const error = new Error(options.toUtf8(message.body));
error.name = code;
throw error;
}
throw deserializedException[code];
} else if (messageType === "event") {
const event = {
[message.headers[":event-type"].value]: message
};
const deserialized = await options.deserializer(event);
if (deserialized.$unknown) continue;
yield deserialized;
} else {
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
}
}
}
};
}
class EventStreamMarshaller {
constructor({ utf8Encoder , utf8Decoder }){
this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
this.utfEncoder = utf8Encoder;
}
deserialize(body, deserializer) {
const chunkedStream = getChunkedStream(body);
const unmarshalledStream = getUnmarshalledStream(chunkedStream, {
eventStreamCodec: this.eventStreamCodec,
deserializer,
toUtf8: this.utfEncoder
});
return unmarshalledStream;
}
serialize(input, serializer) {
const self1 = this;
const serializedIterator = async function*() {
for await (const chunk of input){
const payloadBuf = self1.eventStreamCodec.encode(serializer(chunk));
yield payloadBuf;
}
yield new Uint8Array(0);
};
return {
[Symbol.asyncIterator]: serializedIterator
};
}
}
const readableStreamtoIterable = (readableStream)=>({
[Symbol.asyncIterator]: async function*() {
const reader = readableStream.getReader();
try {
while(true){
const { done , value } = await reader.read();
if (done) return;
yield value;
}
} finally{
reader.releaseLock();
}
}
});
const iterableToReadableStream = (asyncIterable)=>{
const iterator = asyncIterable[Symbol.asyncIterator]();
return new ReadableStream({
async pull (controller) {
const { done , value } = await iterator.next();
if (done) {
return controller.close();
}
controller.enqueue(value);
}
});
};
class EventStreamMarshaller1 {
constructor({ utf8Encoder , utf8Decoder }){
this.universalMarshaller = new EventStreamMarshaller({
utf8Decoder,
utf8Encoder
});
}
deserialize(body, deserializer) {
const bodyIterable = isReadableStream(body) ? readableStreamtoIterable(body) : body;
return this.universalMarshaller.deserialize(bodyIterable, deserializer);
}
serialize(input, serializer) {
const serialziedIterable = this.universalMarshaller.serialize(input, serializer);
return typeof ReadableStream === "function" ? iterableToReadableStream(serialziedIterable) : serialziedIterable;
}
}
const isReadableStream = (body)=>typeof ReadableStream === "function" && body instanceof ReadableStream;
const eventStreamSerdeProvider = (options)=>new EventStreamMarshaller1(options);
function buildQueryString(query) {
const parts = [];
for (let key of Object.keys(query).sort()){
const value = query[key];
key = escapeUri(key);
if (Array.isArray(value)) {
for(let i = 0, iLen = value.length; i < iLen; i++){
parts.push(`${key}=${escapeUri(value[i])}`);
}
} else {
let qsEntry = key;
if (value || typeof value === "string") {
qsEntry += `=${escapeUri(value)}`;
}
parts.push(qsEntry);
}
}
return parts.join("&");
}
const alphabetByEncoding = {};
const alphabetByValue = new Array(64);
for(let i2 = 0, start = "A".charCodeAt(0), limit = "Z".charCodeAt(0); i2 + start <= limit; i2++){
const __char = String.fromCharCode(i2 + start);
alphabetByEncoding[__char] = i2;
alphabetByValue[i2] = __char;
}
for(let i11 = 0, start1 = "a".charCodeAt(0), limit1 = "z".charCodeAt(0); i11 + start1 <= limit1; i11++){
const char1 = String.fromCharCode(i11 + start1);
const index3 = i11 + 26;
alphabetByEncoding[char1] = index3;
alphabetByValue[index3] = char1;
}
for(let i21 = 0; i21 < 10; i21++){
alphabetByEncoding[i21.toString(10)] = i21 + 52;
const char2 = i21.toString(10);
const index11 = i21 + 52;
alphabetByEncoding[char2] = index11;
alphabetByValue[index11] = char2;
}
alphabetByEncoding["+"] = 62;
alphabetByValue[62] = "+";
alphabetByEncoding["/"] = 63;
alphabetByValue[63] = "/";
const bitsPerLetter = 6;
const bitsPerByte = 8;
const maxLetterValue = 63;
function fromBase64(input) {
let totalByteLength = input.length / 4 * 3;
if (input.slice(-2) === "==") {
totalByteLength -= 2;
} else if (input.slice(-1) === "=") {
totalByteLength--;
}
const out = new ArrayBuffer(totalByteLength);
const dataView = new DataView(out);
for(let i = 0; i < input.length; i += 4){
let bits = 0;
let bitLength = 0;
for(let j = i, limit = i + 3; j <= limit; j++){
if (input[j] !== "=") {
if (!(input[j] in alphabetByEncoding)) {
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
}
bits |= alphabetByEncoding[input[j]] << (limit - j) * bitsPerLetter;
bitLength += bitsPerLetter;
} else {
bits >>= bitsPerLetter;
}
}
const chunkOffset = i / 4 * 3;
bits >>= bitLength % bitsPerByte;
const byteLength = Math.floor(bitLength / 8);
for(let k = 0; k < byteLength; k++){
const offset = (byteLength - k - 1) * 8;
dataView.setUint8(chunkOffset + k, (bits & 255 << offset) >> offset);
}
}
return new Uint8Array(out);
}
function toBase64(input) {
let str = "";
for(let i = 0; i < input.length; i += 3){
let bits = 0;
let bitLength = 0;
for(let j = i, limit = Math.min(i + 3, input.length); j < limit; j++){
bits |= input[j] << (limit - j - 1) * bitsPerByte;
bitLength += bitsPerByte;
}
const bitClusterCount = Math.ceil(bitLength / 6);
bits <<= bitClusterCount * bitsPerLetter - bitLength;
for(let k = 1; k <= bitClusterCount; k++){
const offset = (bitClusterCount - k) * 6;
str += alphabetByValue[(bits & maxLetterValue << offset) >> offset];
}
str += "==".slice(0, 4 - bitClusterCount);
}
return str;
}
function requestTimeout(timeoutInMs = 0) {
return new Promise((resolve, reject)=>{
if (timeoutInMs) {
setTimeout(()=>{
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
timeoutError.name = "TimeoutError";
reject(timeoutError);
}, timeoutInMs);
}
});
}
class FetchHttpHandler {
constructor(options){
if (typeof options === "function") {
this.configProvider = options().then((opts)=>opts || {});
} else {
this.config = options != null ? options : {};
this.configProvider = Promise.resolve(this.config);
}
}
destroy() {}
async handle(request, { abortSignal } = {}) {
if (!this.config) {
this.config = await this.configProvider;
}
const requestTimeoutInMs = this.config.requestTimeout;
if (abortSignal == null ? void 0 : abortSignal.aborted) {
const abortError = new Error("Request aborted");
abortError.name = "AbortError";
return Promise.reject(abortError);
}
let path = request.path;
if (request.query) {
const queryString = buildQueryString(request.query);
if (queryString) {
path += `?${queryString}`;
}
}
const { port , method } = request;
const url = `${request.protocol}//${request.hostname}${port ? `:${port}` : ""}${path}`;
const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
const requestOptions = {
body,
headers: new Headers(request.headers),
method
};
if (typeof AbortController !== "undefined") {
requestOptions["signal"] = abortSignal;
}
const fetchRequest = new Request(url, requestOptions);
const raceOfPromises = [
fetch(fetchRequest).then((response)=>{
const fetchHeaders = response.headers;
const transformedHeaders = {};
for (const pair of fetchHeaders.entries()){
transformedHeaders[pair[0]] = pair[1];
}
const hasReadableStream = response.body !== void 0;
if (!hasReadableStream) {
return response.blob().then((body2)=>({
response: new HttpResponse({
headers: transformedHeaders,
statusCode: response.status,
body: body2
})
}));
}
return {
response: new HttpResponse({
headers: transformedHeaders,
statusCode: response.status,
body: response.body
})
};
}),
requestTimeout(requestTimeoutInMs)
];
if (abortSignal) {
raceOfPromises.push(new Promise((resolve, reject)=>{
abortSignal.onabort = ()=>{
const abortError = new Error("Request aborted");
abortError.name = "AbortError";
reject(abortError);
};
}));
}
return Promise.race(raceOfPromises);
}
}
const streamCollector = (stream)=>{
if (typeof Blob === "function" && stream instanceof Blob) {
return collectBlob(stream);
}
return collectStream(stream);
};
async function collectBlob(blob) {
const base64 = await readToBase64(blob);
const arrayBuffer = fromBase64(base64);
return new Uint8Array(arrayBuffer);
}
async function collectStream(stream) {
let res = new Uint8Array(0);
const reader = stream.getReader();
let isDone = false;
while(!isDone){
const { done , value } = await reader.read();
if (value) {
const prior = res;
res = new Uint8Array(prior.length + value.length);
res.set(prior);
res.set(value, prior.length);
}
isDone = done;
}
return res;
}
function readToBase64(blob) {
return new Promise((resolve, reject)=>{
const reader = new FileReader();
reader.onloadend = ()=>{
var _a;
if (reader.readyState !== 2) {
return reject(new Error("Reader aborted too early"));
}
const result = (_a = reader.result) != null ? _a : "";
const commaIndex = result.indexOf(",");
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
resolve(result.substring(dataOffset));
};
reader.onabort = ()=>reject(new Error("Read aborted"));
reader.onerror = ()=>reject(reader.error);
reader.readAsDataURL(blob);
});
}
function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
return new Promise((resolve, reject)=>{
const fileReader = new FileReader();
fileReader.addEventListener("error", reject);
fileReader.addEventListener("abort", reject);
const size = blob.size;
let totalBytesRead = 0;
function read() {
if (totalBytesRead >= size) {
resolve();
return;
}
fileReader.readAsArrayBuffer(blob.slice(totalBytesRead, Math.min(size, totalBytesRead + chunkSize)));
}
fileReader.addEventListener("load", (event)=>{
const result = event.target.result;
onChunk(new Uint8Array(result));
totalBytesRead += result.byteLength;
read();
});
read();
});
}
const blobHasher = async function blobHasher2(hashCtor, blob) {
const hash = new hashCtor();
await blobReader(blob, (chunk)=>{
hash.update(chunk);
});
return hash.digest();
};
const invalidProvider = (message)=>()=>Promise.reject(message);
var global$11 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
var lookup1 = [];
var revLookup1 = [];
var Arr1 = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
var inited1 = false;
function init1() {
inited1 = true;
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for(var i = 0, len = code.length; i < len; ++i){
lookup1[i] = code[i];
revLookup1[code.charCodeAt(i)] = i;
}
revLookup1["-".charCodeAt(0)] = 62;
revLookup1["_".charCodeAt(0)] = 63;
}
function toByteArray1(b64) {
if (!inited1) {
init1();
}
var i, j, l, tmp, placeHolders, arr;
var len = b64.length;
if (len % 4 > 0) {
throw new Error("Invalid string. Length must be a multiple of 4");
}
placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
arr = new Arr1(len * 3 / 4 - placeHolders);
l = placeHolders > 0 ? len - 4 : len;
var L = 0;
for(i = 0, j = 0; i < l; i += 4, j += 3){
tmp = revLookup1[b64.charCodeAt(i)] << 18 | revLookup1[b64.charCodeAt(i + 1)] << 12 | revLookup1[b64.charCodeAt(i + 2)] << 6 | revLookup1[b64.charCodeAt(i + 3)];
arr[L++] = tmp >> 16 & 255;
arr[L++] = tmp >> 8 & 255;
arr[L++] = tmp & 255;
}
if (placeHolders === 2) {
tmp = revLookup1[b64.charCodeAt(i)] << 2 | revLookup1[b64.charCodeAt(i + 1)] >> 4;
arr[L++] = tmp & 255;
} else if (placeHolders === 1) {
tmp = revLookup1[b64.charCodeAt(i)] << 10 | revLookup1[b64.charCodeAt(i + 1)] << 4 | revLookup1[b64.charCodeAt(i + 2)] >> 2;
arr[L++] = tmp >> 8 & 255;
arr[L++] = tmp & 255;
}
return arr;
}
function tripletToBase641(num) {
return lookup1[num >> 18 & 63] + lookup1[num >> 12 & 63] + lookup1[num >> 6 & 63] + lookup1[num & 63];
}
function encodeChunk1(uint8, start, end) {
var tmp;
var output = [];
for(var i = start; i < end; i += 3){
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
output.push(tripletToBase641(tmp));
}
return output.join("");
}
function fromByteArray1(uint8) {
if (!inited1) {
init1();
}
var tmp;
var len = uint8.length;
var extraBytes = len % 3;
var output = "";
var parts = [];
var maxChunkLength = 16383;
for(var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength){
parts.push(encodeChunk1(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
}
if (extraBytes === 1) {
tmp = uint8[len - 1];
output += lookup1[tmp >> 2];
output += lookup1[tmp << 4 & 63];
output += "==";
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
output += lookup1[tmp >> 10];
output += lookup1[tmp >> 4 & 63];
output += lookup1[tmp << 2 & 63];
output += "=";
}
parts.push(output);
return parts.join("");
}
function read1(buffer, offset, isLE, mLen, nBytes) {
var e, m;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i = isLE ? nBytes - 1 : 0;
var d = isLE ? -1 : 1;
var s = buffer[offset + i];
i += d;
e = s & (1 << -nBits) - 1;
s >>= -nBits;
nBits += eLen;
for(; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){}
m = e & (1 << -nBits) - 1;
e >>= -nBits;
nBits += mLen;
for(; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){}
if (e === 0) {
e = 1 - eBias;
} else if (e === eMax) {
return m ? NaN : (s ? -1 : 1) * Infinity;
} else {
m = m + Math.pow(2, mLen);
e = e - eBias;
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
}
function write1(buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
var i = isLE ? 0 : nBytes - 1;
var d = isLE ? 1 : -1;
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e = eMax;
} else {
e = Math.floor(Math.log(value) / Math.LN2);
if (value * (c = Math.pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) {
value += rt / c;
} else {
value += rt * Math.pow(2, 1 - eBias);
}
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen);
e = e + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e = 0;
}
}
for(; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8){}
e = e << mLen | m;
eLen += mLen;
for(; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8){}
buffer[offset + i - d] |= s * 128;
}
var toString1 = {}.toString;
var isArray1 = Array.isArray || function(arr) {
return toString1.call(arr) == "[object Array]";
};
var INSPECT_MAX_BYTES1 = 50;
Buffer1.TYPED_ARRAY_SUPPORT = global$11.TYPED_ARRAY_SUPPORT !== void 0 ? global$11.TYPED_ARRAY_SUPPORT : true;
function kMaxLength1() {
return Buffer1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
}
function createBuffer1(that, length) {
if (kMaxLength1() < length) {
throw new RangeError("Invalid typed array length");
}
if (Buffer1.TYPED_ARRAY_SUPPORT) {
that = new Uint8Array(length);
// that.__proto__ = Buffer1.prototype; // MANUALLY CHANGED BY JOE
Object.setPrototypeOf(that, Buffer1.prototype);
} else {
if (that === null) {
that = new Buffer1(length);
}
that.length = length;
}
return that;
}
function Buffer1(arg, encodingOrOffset, length) {
if (!Buffer1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer1)) {
return new Buffer1(arg, encodingOrOffset, length);
}
if (typeof arg === "number") {
if (typeof encodingOrOffset === "string") {
throw new Error("If encoding is specified then the first argument must be a string");
}
return allocUnsafe1(this, arg);
}
return from1(this, arg, encodingOrOffset, length);
}
Buffer1.poolSize = 8192;
Buffer1._augment = function(arr) {
// arr.__proto__ = Buffer1.prototype; // MANUALLY CHANGED BY JOE
Object.setPrototypeOf(arr, Buffer1.prototype);
return arr;
};
function from1(that, value, encodingOrOffset, length) {
if (typeof value === "number") {
throw new TypeError('"value" argument must not be a number');
}
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
return fromArrayBuffer1(that, value, encodingOrOffset, length);
}
if (typeof value === "string") {
return fromString1(that, value, encodingOrOffset);
}
return fromObject1(that, value);
}
Buffer1.from = function(value, encodingOrOffset, length) {
return from1(null, value, encodingOrOffset, length);
};
if (Buffer1.TYPED_ARRAY_SUPPORT) {
// Buffer1.prototype.__proto__ = Uint8Array.prototype;
Object.setPrototypeOf(Buffer1, Uint8Array.prototype);
// Buffer1.__proto__ = Uint8Array;
Object.setPrototypeOf(Buffer1, Uint8Array);
}
function assertSize1(size) {
if (typeof size !== "number") {
throw new TypeError('"size" argument must be a number');
} else if (size < 0) {
throw new RangeError('"size" argument must not be negative');
}
}
function alloc1(that, size, fill2, encoding) {
assertSize1(size);
if (size <= 0) {
return createBuffer1(that, size);
}
if (fill2 !== void 0) {
return typeof encoding === "string" ? createBuffer1(that, size).fill(fill2, encoding) : createBuffer1(that, size).fill(fill2);
}
return createBuffer1(that, size);
}
Buffer1.alloc = function(size, fill2, encoding) {
return alloc1(null, size, fill2, encoding);
};
function allocUnsafe1(that, size) {
assertSize1(size);
that = createBuffer1(that, size < 0 ? 0 : checked1(size) | 0);
if (!Buffer1.TYPED_ARRAY_SUPPORT) {
for(var i = 0; i < size; ++i){
that[i] = 0;
}
}
return that;
}
Buffer1.allocUnsafe = function(size) {
return allocUnsafe1(null, size);
};
Buffer1.allocUnsafeSlow = function(size) {
return allocUnsafe1(null, size);
};
function fromString1(that, string, encoding) {
if (typeof encoding !== "string" || encoding === "") {
encoding = "utf8";
}
if (!Buffer1.isEncoding(encoding)) {
throw new TypeError('"encoding" must be a valid string encoding');
}
var length = byteLength1(string, encoding) | 0;
that = createBuffer1(that, length);
var actual = that.write(string, encoding);
if (actual !== length) {
that = that.slice(0, actual);
}
return that;
}
function fromArrayLike1(that, array) {
var length = array.length < 0 ? 0 : checked1(array.length) | 0;
that = createBuffer1(that, length);
for(var i = 0; i < length; i += 1){
that[i] = array[i] & 255;
}
return that;
}
function fromArrayBuffer1(that, array, byteOffset, length) {
array.byteLength;
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError("'offset' is out of bounds");
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError("'length' is out of bounds");
}
if (byteOffset === void 0 && length === void 0) {
array = new Uint8Array(array);
} else if (length === void 0) {
array = new Uint8Array(array, byteOffset);
} else {
array = new Uint8Array(array, byteOffset, length);
}
if (Buffer1.TYPED_ARRAY_SUPPORT) {
that = array;
// that.__proto__ = Buffer1.prototype;
Object.setPrototypeOf(that, Buffer1.prototype);
} else {
that = fromArrayLike1(that, array);
}
return that;
}
function fromObject1(that, obj) {
if (internalIsBuffer1(obj)) {
var len = checked1(obj.length) | 0;
that = createBuffer1(that, len);
if (that.length === 0) {
return that;
}
obj.copy(that, 0, 0, len);
return that;
}
if (obj) {
if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
if (typeof obj.length !== "number" || isnan1(obj.length)) {
return createBuffer1(that, 0);
}
return fromArrayLike1(that, obj);
}
if (obj.type === "Buffer" && isArray1(obj.data)) {
return fromArrayLike1(that, obj.data);
}
}
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
}
function checked1(length) {
if (length >= kMaxLength1()) {
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength1().toString(16) + " bytes");
}
return length | 0;
}
Buffer1.isBuffer = isBuffer1;
function internalIsBuffer1(b) {
return !!(b != null && b._isBuffer);
}
Buffer1.compare = function compare(a, b) {
if (!internalIsBuffer1(a) || !internalIsBuffer1(b)) {
throw new TypeError("Arguments must be Buffers");
}
if (a === b) return 0;
var x = a.length;
var y = b.length;
for(var i = 0, len = Math.min(x, y); i < len; ++i){
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y) return -1;
if (y < x) return 1;
return 0;
};
Buffer1.isEncoding = function isEncoding(encoding) {
switch(String(encoding).toLowerCase()){
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return true;
default:
return false;
}
};
Buffer1.concat = function concat(list, length) {
if (!isArray1(list)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
if (list.length === 0) {
return Buffer1.alloc(0);
}
var i;
if (length === void 0) {
length = 0;
for(i = 0; i < list.length; ++i){
length += list[i].length;
}
}
var buffer = Buffer1.allocUnsafe(length);
var pos = 0;
for(i = 0; i < list.length; ++i){
var buf = list[i];
if (!internalIsBuffer1(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
buf.copy(buffer, pos);
pos += buf.length;
}
return buffer;
};
function byteLength1(string, encoding) {
if (internalIsBuffer1(string)) {
return string.length;
}
if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength;
}
if (typeof string !== "string") {
string = "" + string;
}
var len = string.length;
if (len === 0) return 0;
var loweredCase = false;
for(;;){
switch(encoding){
case "ascii":
case "latin1":
case "binary":
return len;
case "utf8":
case "utf-8":
case void 0:
return utf8ToBytes1(string).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return len * 2;
case "hex":
return len >>> 1;
case "base64":
return base64ToBytes1(string).length;
default:
if (loweredCase) return utf8ToBytes1(string).length;
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
}
Buffer1.byteLength = byteLength1;
function slowToString1(encoding, start, end) {
var loweredCase = false;
if (start === void 0 || start < 0) {
start = 0;
}
if (start > this.length) {
return "";
}
if (end === void 0 || end > this.length) {
end = this.length;
}
if (end <= 0) {
return "";
}
end >>>= 0;
start >>>= 0;
if (end <= start) {
return "";
}
if (!encoding) encoding = "utf8";
while(true){
switch(encoding){
case "hex":
return hexSlice1(this, start, end);
case "utf8":
case "utf-8":
return utf8Slice1(this, start, end);
case "ascii":
return asciiSlice1(this, start, end);
case "latin1":
case "binary":
return latin1Slice1(this, start, end);
case "base64":
return base64Slice1(this, start, end);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return utf16leSlice1(this, start, end);
default:
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
encoding = (encoding + "").toLowerCase();
loweredCase = true;
}
}
}
Buffer1.prototype._isBuffer = true;
function swap1(b, n, m) {
var i = b[n];
b[n] = b[m];
b[m] = i;
}
Buffer1.prototype.swap16 = function swap16() {
var len = this.length;
if (len % 2 !== 0) {
throw new RangeError("Buffer size must be a multiple of 16-bits");
}
for(var i = 0; i < len; i += 2){
swap1(this, i, i + 1);
}
return this;
};
Buffer1.prototype.swap32 = function swap32() {
var len = this.length;
if (len % 4 !== 0) {
throw new RangeError("Buffer size must be a multiple of 32-bits");
}
for(var i = 0; i < len; i += 4){
swap1(this, i, i + 3);
swap1(this, i + 1, i + 2);
}
return this;
};
Buffer1.prototype.swap64 = function swap64() {
var len = this.length;
if (len % 8 !== 0) {
throw new RangeError("Buffer size must be a multiple of 64-bits");
}
for(var i = 0; i < len; i += 8){
swap1(this, i, i + 7);
swap1(this, i + 1, i + 6);
swap1(this, i + 2, i + 5);
swap1(this, i + 3, i + 4);
}
return this;
};
Buffer1.prototype.toString = function toString2() {
var length = this.length | 0;
if (length === 0) return "";
if (arguments.length === 0) return utf8Slice1(this, 0, length);
return slowToString1.apply(this, arguments);
};
Buffer1.prototype.equals = function equals(b) {
if (!internalIsBuffer1(b)) throw new TypeError("Argument must be a Buffer");
if (this === b) return true;
return Buffer1.compare(this, b) === 0;
};
Buffer1.prototype.inspect = function inspect() {
var str = "";
var max = INSPECT_MAX_BYTES1;
if (this.length > 0) {
str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
if (this.length > max) str += " ... ";
}
return "<Buffer " + str + ">";
};
Buffer1.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
if (!internalIsBuffer1(target)) {
throw new TypeError("Argument must be a Buffer");
}
if (start === void 0) {
start = 0;
}
if (end === void 0) {
end = target ? target.length : 0;
}
if (thisStart === void 0) {
thisStart = 0;
}
if (thisEnd === void 0) {
thisEnd = this.length;
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new RangeError("out of range index");
}
if (thisStart >= thisEnd && start >= end) {
return 0;
}
if (thisStart >= thisEnd) {
return -1;
}
if (start >= end) {
return 1;
}
start >>>= 0;
end >>>= 0;
thisStart >>>= 0;
thisEnd >>>= 0;
if (this === target) return 0;
var x = thisEnd - thisStart;
var y = end - start;
var len = Math.min(x, y);
var thisCopy = this.slice(thisStart, thisEnd);
var targetCopy = target.slice(start, end);
for(var i = 0; i < len; ++i){
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i];
y = targetCopy[i];
break;
}
}
if (x < y) return -1;
if (y < x) return 1;
return 0;
};
function bidirectionalIndexOf1(buffer, val, byteOffset, encoding, dir) {
if (buffer.length === 0) return -1;
if (typeof byteOffset === "string") {
encoding = byteOffset;
byteOffset = 0;
} else if (byteOffset > 2147483647) {
byteOffset = 2147483647;
} else if (byteOffset < -2147483648) {
byteOffset = -2147483648;
}
byteOffset = +byteOffset;
if (isNaN(byteOffset)) {
byteOffset = dir ? 0 : buffer.length - 1;
}
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
if (byteOffset >= buffer.length) {
if (dir) return -1;
else byteOffset = buffer.length - 1;
} else if (byteOffset < 0) {
if (dir) byteOffset = 0;
else return -1;
}
if (typeof val === "string") {
val = Buffer1.from(val, encoding);
}
if (internalIsBuffer1(val)) {
if (val.length === 0) {
return -1;
}
return arrayIndexOf1(buffer, val, byteOffset, encoding, dir);
} else if (typeof val === "number") {
val = val & 255;
if (Buffer1.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
}
}
return arrayIndexOf1(buffer, [
val
], byteOffset, encoding, dir);
}
throw new TypeError("val must be string, number or Buffer");
}
function arrayIndexOf1(arr, val, byteOffset, encoding, dir) {
var indexSize = 1;
var arrLength = arr.length;
var valLength = val.length;
if (encoding !== void 0) {
encoding = String(encoding).toLowerCase();
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
if (arr.length < 2 || val.length < 2) {
return -1;
}
indexSize = 2;
arrLength /= 2;
valLength /= 2;
byteOffset /= 2;
}
}
function read2(buf, i2) {
if (indexSize === 1) {
return buf[i2];
} else {
return buf.readUInt16BE(i2 * indexSize);
}
}
var i;
if (dir) {
var foundIndex = -1;
for(i = byteOffset; i < arrLength; i++){
if (read2(arr, i) === read2(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i;
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
} else {
if (foundIndex !== -1) i -= i - foundIndex;
foundIndex = -1;
}
}
} else {
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
for(i = byteOffset; i >= 0; i--){
var found = true;
for(var j = 0; j < valLength; j++){
if (read2(arr, i + j) !== read2(val, j)) {
found = false;
break;
}
}
if (found) return i;
}
}
return -1;
}
Buffer1.prototype.includes = function includes(val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1;
};
Buffer1.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf1(this, val, byteOffset, encoding, true);
};
Buffer1.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf1(this, val, byteOffset, encoding, false);
};
function hexWrite1(buf, string, offset, length) {
offset = Number(offset) || 0;
var remaining = buf.length - offset;
if (!length) {
length = remaining;
} else {
length = Number(length);
if (length > remaining) {
length = remaining;
}
}
var strLen = string.length;
if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
if (length > strLen / 2) {
length = strLen / 2;
}
for(var i = 0; i < length; ++i){
var parsed = parseInt(string.substr(i * 2, 2), 16);
if (isNaN(parsed)) return i;
buf[offset + i] = parsed;
}
return i;
}
function utf8Write1(buf, string, offset, length) {
return blitBuffer1(utf8ToBytes1(string, buf.length - offset), buf, offset, length);
}
function asciiWrite1(buf, string, offset, length) {
return blitBuffer1(asciiToBytes1(string), buf, offset, length);
}
function latin1Write1(buf, string, offset, length) {
return asciiWrite1(buf, string, offset, length);
}
function base64Write1(buf, string, offset, length) {
return blitBuffer1(base64ToBytes1(string), buf, offset, length);
}
function ucs2Write1(buf, string, offset, length) {
return blitBuffer1(utf16leToBytes1(string, buf.length - offset), buf, offset, length);
}
Buffer1.prototype.write = function write2(string, offset, length, encoding) {
if (offset === void 0) {
encoding = "utf8";
length = this.length;
offset = 0;
} else if (length === void 0 && typeof offset === "string") {
encoding = offset;
length = this.length;
offset = 0;
} else if (isFinite(offset)) {
offset = offset | 0;
if (isFinite(length)) {
length = length | 0;
if (encoding === void 0) encoding = "utf8";
} else {
encoding = length;
length = void 0;
}
} else {
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
}
var remaining = this.length - offset;
if (length === void 0 || length > remaining) length = remaining;
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
throw new RangeError("Attempt to write outside buffer bounds");
}
if (!encoding) encoding = "utf8";
var loweredCase = false;
for(;;){
switch(encoding){
case "hex":
return hexWrite1(this, string, offset, length);
case "utf8":
case "utf-8":
return utf8Write1(this, string, offset, length);
case "ascii":
return asciiWrite1(this, string, offset, length);
case "latin1":
case "binary":
return latin1Write1(this, string, offset, length);
case "base64":
return base64Write1(this, string, offset, length);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return ucs2Write1(this, string, offset, length);
default:
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
};
Buffer1.prototype.toJSON = function toJSON() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function base64Slice1(buf, start, end) {
if (start === 0 && end === buf.length) {
return fromByteArray1(buf);
} else {
return fromByteArray1(buf.slice(start, end));
}
}
function utf8Slice1(buf, start, end) {
end = Math.min(buf.length, end);
var res = [];
var i = start;
while(i < end){
var firstByte = buf[i];
var codePoint = null;
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint;
switch(bytesPerSequence){
case 1:
if (firstByte < 128) {
codePoint = firstByte;
}
break;
case 2:
secondByte = buf[i + 1];
if ((secondByte & 192) === 128) {
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
if (tempCodePoint > 127) {
codePoint = tempCodePoint;
}
}
break;
case 3:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
codePoint = tempCodePoint;
}
}
break;
case 4:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
fourthByte = buf[i + 3];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
codePoint = tempCodePoint;
}
}
}
}
if (codePoint === null) {
codePoint = 65533;
bytesPerSequence = 1;
} else if (codePoint > 65535) {
codePoint -= 65536;
res.push(codePoint >>> 10 & 1023 | 55296);
codePoint = 56320 | codePoint & 1023;
}
res.push(codePoint);
i += bytesPerSequence;
}
return decodeCodePointsArray1(res);
}
var MAX_ARGUMENTS_LENGTH1 = 4096;
function decodeCodePointsArray1(codePoints) {
var len = codePoints.length;
if (len <= MAX_ARGUMENTS_LENGTH1) {
return String.fromCharCode.apply(String, codePoints);
}
var res = "";
var i = 0;
while(i < len){
res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH1));
}
return res;
}
function asciiSlice1(buf, start, end) {
var ret = "";
end = Math.min(buf.length, end);
for(var i = start; i < end; ++i){
ret += String.fromCharCode(buf[i] & 127);
}
return ret;
}
function latin1Slice1(buf, start, end) {
var ret = "";
end = Math.min(buf.length, end);
for(var i = start; i < end; ++i){
ret += String.fromCharCode(buf[i]);
}
return ret;
}
function hexSlice1(buf, start, end) {
var len = buf.length;
if (!start || start < 0) start = 0;
if (!end || end < 0 || end > len) end = len;
var out = "";
for(var i = start; i < end; ++i){
out += toHex2(buf[i]);
}
return out;
}
function utf16leSlice1(buf, start, end) {
var bytes = buf.slice(start, end);
var res = "";
for(var i = 0; i < bytes.length; i += 2){
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
}
return res;
}
Buffer1.prototype.slice = function slice(start, end) {
var len = this.length;
start = ~~start;
end = end === void 0 ? len : ~~end;
if (start < 0) {
start += len;
if (start < 0) start = 0;
} else if (start > len) {
start = len;
}
if (end < 0) {
end += len;
if (end < 0) end = 0;
} else if (end > len) {
end = len;
}
if (end < start) end = start;
var newBuf;
if (Buffer1.TYPED_ARRAY_SUPPORT) {
newBuf = this.subarray(start, end);
// newBuf.__proto__ = Buffer1.prototype;
Object.setPrototypeOf(newBuf, Buffer1.prototype);
} else {
var sliceLen = end - start;
newBuf = new Buffer1(sliceLen, void 0);
for(var i = 0; i < sliceLen; ++i){
newBuf[i] = this[i + start];
}
}
return newBuf;
};
function checkOffset1(offset, ext, length) {
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
}
Buffer1.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset1(offset, byteLength2, this.length);
var val = this[offset];
var mul = 1;
var i = 0;
while(++i < byteLength2 && (mul *= 256)){
val += this[offset + i] * mul;
}
return val;
};
Buffer1.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
checkOffset1(offset, byteLength2, this.length);
}
var val = this[offset + --byteLength2];
var mul = 1;
while(byteLength2 > 0 && (mul *= 256)){
val += this[offset + --byteLength2] * mul;
}
return val;
};
Buffer1.prototype.readUInt8 = function readUInt8(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 1, this.length);
return this[offset];
};
Buffer1.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 2, this.length);
return this[offset] | this[offset + 1] << 8;
};
Buffer1.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 2, this.length);
return this[offset] << 8 | this[offset + 1];
};
Buffer1.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
};
Buffer1.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
};
Buffer1.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset1(offset, byteLength2, this.length);
var val = this[offset];
var mul = 1;
var i = 0;
while(++i < byteLength2 && (mul *= 256)){
val += this[offset + i] * mul;
}
mul *= 128;
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer1.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) checkOffset1(offset, byteLength2, this.length);
var i = byteLength2;
var mul = 1;
var val = this[offset + --i];
while(i > 0 && (mul *= 256)){
val += this[offset + --i] * mul;
}
mul *= 128;
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer1.prototype.readInt8 = function readInt8(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 1, this.length);
if (!(this[offset] & 128)) return this[offset];
return (255 - this[offset] + 1) * -1;
};
Buffer1.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 2, this.length);
var val = this[offset] | this[offset + 1] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer1.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 2, this.length);
var val = this[offset + 1] | this[offset] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer1.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
};
Buffer1.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
};
Buffer1.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return read1(this, offset, true, 23, 4);
};
Buffer1.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 4, this.length);
return read1(this, offset, false, 23, 4);
};
Buffer1.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 8, this.length);
return read1(this, offset, true, 52, 8);
};
Buffer1.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
if (!noAssert) checkOffset1(offset, 8, this.length);
return read1(this, offset, false, 52, 8);
};
function checkInt1(buf, value, offset, ext, max, min) {
if (!internalIsBuffer1(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
if (offset + ext > buf.length) throw new RangeError("Index out of range");
}
Buffer1.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt1(this, value, offset, byteLength2, maxBytes, 0);
}
var mul = 1;
var i = 0;
this[offset] = value & 255;
while(++i < byteLength2 && (mul *= 256)){
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer1.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
byteLength2 = byteLength2 | 0;
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt1(this, value, offset, byteLength2, maxBytes, 0);
}
var i = byteLength2 - 1;
var mul = 1;
this[offset + i] = value & 255;
while(--i >= 0 && (mul *= 256)){
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer1.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 1, 255, 0);
if (!Buffer1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
this[offset] = value & 255;
return offset + 1;
};
function objectWriteUInt161(buf, value, offset, littleEndian) {
if (value < 0) value = 65535 + value + 1;
for(var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i){
buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
}
}
Buffer1.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 2, 65535, 0);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
} else {
objectWriteUInt161(this, value, offset, true);
}
return offset + 2;
};
Buffer1.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 2, 65535, 0);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
} else {
objectWriteUInt161(this, value, offset, false);
}
return offset + 2;
};
function objectWriteUInt321(buf, value, offset, littleEndian) {
if (value < 0) value = 4294967295 + value + 1;
for(var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i){
buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
}
}
Buffer1.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 4, 4294967295, 0);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset + 3] = value >>> 24;
this[offset + 2] = value >>> 16;
this[offset + 1] = value >>> 8;
this[offset] = value & 255;
} else {
objectWriteUInt321(this, value, offset, true);
}
return offset + 4;
};
Buffer1.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 4, 4294967295, 0);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
} else {
objectWriteUInt321(this, value, offset, false);
}
return offset + 4;
};
Buffer1.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt1(this, value, offset, byteLength2, limit - 1, -limit);
}
var i = 0;
var mul = 1;
var sub = 0;
this[offset] = value & 255;
while(++i < byteLength2 && (mul *= 256)){
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer1.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt1(this, value, offset, byteLength2, limit - 1, -limit);
}
var i = byteLength2 - 1;
var mul = 1;
var sub = 0;
this[offset + i] = value & 255;
while(--i >= 0 && (mul *= 256)){
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer1.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 1, 127, -128);
if (!Buffer1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
if (value < 0) value = 255 + value + 1;
this[offset] = value & 255;
return offset + 1;
};
Buffer1.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 2, 32767, -32768);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
} else {
objectWriteUInt161(this, value, offset, true);
}
return offset + 2;
};
Buffer1.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 2, 32767, -32768);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
} else {
objectWriteUInt161(this, value, offset, false);
}
return offset + 2;
};
Buffer1.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 4, 2147483647, -2147483648);
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
this[offset + 2] = value >>> 16;
this[offset + 3] = value >>> 24;
} else {
objectWriteUInt321(this, value, offset, true);
}
return offset + 4;
};
Buffer1.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
value = +value;
offset = offset | 0;
if (!noAssert) checkInt1(this, value, offset, 4, 2147483647, -2147483648);
if (value < 0) value = 4294967295 + value + 1;
if (Buffer1.TYPED_ARRAY_SUPPORT) {
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
} else {
objectWriteUInt321(this, value, offset, false);
}
return offset + 4;
};
function checkIEEE7541(buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError("Index out of range");
if (offset < 0) throw new RangeError("Index out of range");
}
function writeFloat1(buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE7541(buf, value, offset, 4);
}
write1(buf, value, offset, littleEndian, 23, 4);
return offset + 4;
}
Buffer1.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
return writeFloat1(this, value, offset, true, noAssert);
};
Buffer1.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
return writeFloat1(this, value, offset, false, noAssert);
};
function writeDouble1(buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE7541(buf, value, offset, 8);
}
write1(buf, value, offset, littleEndian, 52, 8);
return offset + 8;
}
Buffer1.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
return writeDouble1(this, value, offset, true, noAssert);
};
Buffer1.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
return writeDouble1(this, value, offset, false, noAssert);
};
Buffer1.prototype.copy = function copy(target, targetStart, start, end) {
if (!start) start = 0;
if (!end && end !== 0) end = this.length;
if (targetStart >= target.length) targetStart = target.length;
if (!targetStart) targetStart = 0;
if (end > 0 && end < start) end = start;
if (end === start) return 0;
if (target.length === 0 || this.length === 0) return 0;
if (targetStart < 0) {
throw new RangeError("targetStart out of bounds");
}
if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
if (end < 0) throw new RangeError("sourceEnd out of bounds");
if (end > this.length) end = this.length;
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start;
}
var len = end - start;
var i;
if (this === target && start < targetStart && targetStart < end) {
for(i = len - 1; i >= 0; --i){
target[i + targetStart] = this[i + start];
}
} else if (len < 1e3 || !Buffer1.TYPED_ARRAY_SUPPORT) {
for(i = 0; i < len; ++i){
target[i + targetStart] = this[i + start];
}
} else {
Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
}
return len;
};
Buffer1.prototype.fill = function fill(val, start, end, encoding) {
if (typeof val === "string") {
if (typeof start === "string") {
encoding = start;
start = 0;
end = this.length;
} else if (typeof end === "string") {
encoding = end;
end = this.length;
}
if (val.length === 1) {
var code = val.charCodeAt(0);
if (code < 256) {
val = code;
}
}
if (encoding !== void 0 && typeof encoding !== "string") {
throw new TypeError("encoding must be a string");
}
if (typeof encoding === "string" && !Buffer1.isEncoding(encoding)) {
throw new TypeError("Unknown encoding: " + encoding);
}
} else if (typeof val === "number") {
val = val & 255;
}
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError("Out of range index");
}
if (end <= start) {
return this;
}
start = start >>> 0;
end = end === void 0 ? this.length : end >>> 0;
if (!val) val = 0;
var i;
if (typeof val === "number") {
for(i = start; i < end; ++i){
this[i] = val;
}
} else {
var bytes = internalIsBuffer1(val) ? val : utf8ToBytes1(new Buffer1(val, encoding).toString());
var len = bytes.length;
for(i = 0; i < end - start; ++i){
this[i + start] = bytes[i % len];
}
}
return this;
};
var INVALID_BASE64_RE1 = /[^+\/0-9A-Za-z-_]/g;
function base64clean1(str) {
str = stringtrim1(str).replace(INVALID_BASE64_RE1, "");
if (str.length < 2) return "";
while(str.length % 4 !== 0){
str = str + "=";
}
return str;
}
function stringtrim1(str) {
if (str.trim) return str.trim();
return str.replace(/^\s+|\s+$/g, "");
}
function toHex2(n) {
if (n < 16) return "0" + n.toString(16);
return n.toString(16);
}
function utf8ToBytes1(string, units) {
units = units || Infinity;
var codePoint;
var length = string.length;
var leadSurrogate = null;
var bytes = [];
for(var i = 0; i < length; ++i){
codePoint = string.charCodeAt(i);
if (codePoint > 55295 && codePoint < 57344) {
if (!leadSurrogate) {
if (codePoint > 56319) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
continue;
} else if (i + 1 === length) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
continue;
}
leadSurrogate = codePoint;
continue;
}
if (codePoint < 56320) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
leadSurrogate = codePoint;
continue;
}
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
} else if (leadSurrogate) {
if ((units -= 3) > -1) bytes.push(239, 191, 189);
}
leadSurrogate = null;
if (codePoint < 128) {
if ((units -= 1) < 0) break;
bytes.push(codePoint);
} else if (codePoint < 2048) {
if ((units -= 2) < 0) break;
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
} else if (codePoint < 65536) {
if ((units -= 3) < 0) break;
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else if (codePoint < 1114112) {
if ((units -= 4) < 0) break;
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else {
throw new Error("Invalid code point");
}
}
return bytes;
}
function asciiToBytes1(str) {
var byteArray = [];
for(var i = 0; i < str.length; ++i){
byteArray.push(str.charCodeAt(i) & 255);
}
return byteArray;
}
function utf16leToBytes1(str, units) {
var c, hi, lo;
var byteArray = [];
for(var i = 0; i < str.length; ++i){
if ((units -= 2) < 0) break;
c = str.charCodeAt(i);
hi = c >> 8;
lo = c % 256;
byteArray.push(lo);
byteArray.push(hi);
}
return byteArray;
}
function base64ToBytes1(str) {
return toByteArray1(base64clean1(str));
}
function blitBuffer1(src, dst, offset, length) {
for(var i = 0; i < length; ++i){
if (i + offset >= dst.length || i >= src.length) break;
dst[i + offset] = src[i];
}
return i;
}
function isnan1(val) {
return val !== val;
}
function isBuffer1(obj) {
return obj != null && (!!obj._isBuffer || isFastBuffer1(obj) || isSlowBuffer1(obj));
}
function isFastBuffer1(obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
}
function isSlowBuffer1(obj) {
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer1(obj.slice(0, 0));
}
const fromString$1 = (input, encoding)=>{
if (typeof input !== "string") {
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
}
return encoding ? Buffer1.from(input, encoding) : Buffer1.from(input);
};
const fromUtf82 = (input)=>{
const buf = fromString$1(input, "utf8");
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
};
const BLOCK_SIZE = 64;
const INIT = [
1732584193,
4023233417,
2562383102,
271733878
];
class Md5 {
constructor(){
this.state = Uint32Array.from(INIT);
this.buffer = new DataView(new ArrayBuffer(BLOCK_SIZE));
this.bufferLength = 0;
this.bytesHashed = 0;
this.finished = false;
}
update(sourceData) {
if (isEmptyData(sourceData)) {
return;
} else if (this.finished) {
throw new Error("Attempted to update an already finished hash.");
}
const data = convertToBuffer(sourceData);
let position = 0;
let { byteLength } = data;
this.bytesHashed += byteLength;
while(byteLength > 0){
this.buffer.setUint8(this.bufferLength++, data[position++]);
byteLength--;
if (this.bufferLength === 64) {
this.hashBuffer();
this.bufferLength = 0;
}
}
}
async digest() {
if (!this.finished) {
const { buffer , bufferLength: undecoratedLength , bytesHashed } = this;
const bitsHashed = bytesHashed * 8;
buffer.setUint8(this.bufferLength++, 128);
if (undecoratedLength % 64 >= 64 - 8) {
for(let i = this.bufferLength; i < 64; i++){
buffer.setUint8(i, 0);
}
this.hashBuffer();
this.bufferLength = 0;
}
for(let i1 = this.bufferLength; i1 < 64 - 8; i1++){
buffer.setUint8(i1, 0);
}
buffer.setUint32(64 - 8, bitsHashed >>> 0, true);
buffer.setUint32(64 - 4, Math.floor(bitsHashed / 4294967296), true);
this.hashBuffer();
this.finished = true;
}
const out = new DataView(new ArrayBuffer(16));
for(let i2 = 0; i2 < 4; i2++){
out.setUint32(i2 * 4, this.state[i2], true);
}
return new Uint8Array(out.buffer, out.byteOffset, out.byteLength);
}
hashBuffer() {
const { buffer , state } = this;
let a = state[0], b = state[1], c = state[2], d = state[3];
a = ff(a, b, c, d, buffer.getUint32(0, true), 7, 3614090360);
d = ff(d, a, b, c, buffer.getUint32(4, true), 12, 3905402710);
c = ff(c, d, a, b, buffer.getUint32(8, true), 17, 606105819);
b = ff(b, c, d, a, buffer.getUint32(12, true), 22, 3250441966);
a = ff(a, b, c, d, buffer.getUint32(16, true), 7, 4118548399);
d = ff(d, a, b, c, buffer.getUint32(20, true), 12, 1200080426);
c = ff(c, d, a, b, buffer.getUint32(24, true), 17, 2821735955);
b = ff(b, c, d, a, buffer.getUint32(28, true), 22, 4249261313);
a = ff(a, b, c, d, buffer.getUint32(32, true), 7, 1770035416);
d = ff(d, a, b, c, buffer.getUint32(36, true), 12, 2336552879);
c = ff(c, d, a, b, buffer.getUint32(40, true), 17, 4294925233);
b = ff(b, c, d, a, buffer.getUint32(44, true), 22, 2304563134);
a = ff(a, b, c, d, buffer.getUint32(48, true), 7, 1804603682);
d = ff(d, a, b, c, buffer.getUint32(52, true), 12, 4254626195);
c = ff(c, d, a, b, buffer.getUint32(56, true), 17, 2792965006);
b = ff(b, c, d, a, buffer.getUint32(60, true), 22, 1236535329);
a = gg(a, b, c, d, buffer.getUint32(4, true), 5, 4129170786);
d = gg(d, a, b, c, buffer.getUint32(24, true), 9, 3225465664);
c = gg(c, d, a, b, buffer.getUint32(44, true), 14, 643717713);
b = gg(b, c, d, a, buffer.getUint32(0, true), 20, 3921069994);
a = gg(a, b, c, d, buffer.getUint32(20, true), 5, 3593408605);
d = gg(d, a, b, c, buffer.getUint32(40, true), 9, 38016083);
c = gg(c, d, a, b, buffer.getUint32(60, true), 14, 3634488961);
b = gg(b, c, d, a, buffer.getUint32(16, true), 20, 3889429448);
a = gg(a, b, c, d, buffer.getUint32(36, true), 5, 568446438);
d = gg(d, a, b, c, buffer.getUint32(56, true), 9, 3275163606);
c = gg(c, d, a, b, buffer.getUint32(12, true), 14, 4107603335);
b = gg(b, c, d, a, buffer.getUint32(32, true), 20, 1163531501);
a = gg(a, b, c, d, buffer.getUint32(52, true), 5, 2850285829);
d = gg(d, a, b, c, buffer.getUint32(8, true), 9, 4243563512);
c = gg(c, d, a, b, buffer.getUint32(28, true), 14, 1735328473);
b = gg(b, c, d, a, buffer.getUint32(48, true), 20, 2368359562);
a = hh(a, b, c, d, buffer.getUint32(20, true), 4, 4294588738);
d = hh(d, a, b, c, buffer.getUint32(32, true), 11, 2272392833);
c = hh(c, d, a, b, buffer.getUint32(44, true), 16, 1839030562);
b = hh(b, c, d, a, buffer.getUint32(56, true), 23, 4259657740);
a = hh(a, b, c, d, buffer.getUint32(4, true), 4, 2763975236);
d = hh(d, a, b, c, buffer.getUint32(16, true), 11, 1272893353);
c = hh(c, d, a, b, buffer.getUint32(28, true), 16, 4139469664);
b = hh(b, c, d, a, buffer.getUint32(40, true), 23, 3200236656);
a = hh(a, b, c, d, buffer.getUint32(52, true), 4, 681279174);
d = hh(d, a, b, c, buffer.getUint32(0, true), 11, 3936430074);
c = hh(c, d, a, b, buffer.getUint32(12, true), 16, 3572445317);
b = hh(b, c, d, a, buffer.getUint32(24, true), 23, 76029189);
a = hh(a, b, c, d, buffer.getUint32(36, true), 4, 3654602809);
d = hh(d, a, b, c, buffer.getUint32(48, true), 11, 3873151461);
c = hh(c, d, a, b, buffer.getUint32(60, true), 16, 530742520);
b = hh(b, c, d, a, buffer.getUint32(8, true), 23, 3299628645);
a = ii(a, b, c, d, buffer.getUint32(0, true), 6, 4096336452);
d = ii(d, a, b, c, buffer.getUint32(28, true), 10, 1126891415);
c = ii(c, d, a, b, buffer.getUint32(56, true), 15, 2878612391);
b = ii(b, c, d, a, buffer.getUint32(20, true), 21, 4237533241);
a = ii(a, b, c, d, buffer.getUint32(48, true), 6, 1700485571);
d = ii(d, a, b, c, buffer.getUint32(12, true), 10, 2399980690);
c = ii(c, d, a, b, buffer.getUint32(40, true), 15, 4293915773);
b = ii(b, c, d, a, buffer.getUint32(4, true), 21, 2240044497);
a = ii(a, b, c, d, buffer.getUint32(32, true), 6, 1873313359);
d = ii(d, a, b, c, buffer.getUint32(60, true), 10, 4264355552);
c = ii(c, d, a, b, buffer.getUint32(24, true), 15, 2734768916);
b = ii(b, c, d, a, buffer.getUint32(52, true), 21, 1309151649);
a = ii(a, b, c, d, buffer.getUint32(16, true), 6, 4149444226);
d = ii(d, a, b, c, buffer.getUint32(44, true), 10, 3174756917);
c = ii(c, d, a, b, buffer.getUint32(8, true), 15, 718787259);
b = ii(b, c, d, a, buffer.getUint32(36, true), 21, 3951481745);
state[0] = a + state[0] & 4294967295;
state[1] = b + state[1] & 4294967295;
state[2] = c + state[2] & 4294967295;
state[3] = d + state[3] & 4294967295;
}
}
function cmn(q, a, b, x, s, t) {
a = (a + q & 4294967295) + (x + t & 4294967295) & 4294967295;
return (a << s | a >>> 32 - s) + b & 4294967295;
}
function ff(a, b, c, d, x, s, t) {
return cmn(b & c | ~b & d, a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t) {
return cmn(b & d | c & ~d, a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t) {
return cmn(b ^ c ^ d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t) {
return cmn(c ^ (b | ~d), a, b, x, s, t);
}
function isEmptyData(data) {
if (typeof data === "string") {
return data.length === 0;
}
return data.byteLength === 0;
}
function convertToBuffer(data) {
if (typeof data === "string") {
return fromUtf82(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}
const calculateBodyLength = (body)=>{
if (typeof body === "string") {
let len = body.length;
for(let i = len - 1; i >= 0; i--){
const code = body.charCodeAt(i);
if (code > 127 && code <= 2047) len++;
else if (code > 2047 && code <= 65535) len += 2;
if (code >= 56320 && code <= 57343) i--;
}
return len;
} else if (typeof body.byteLength === "number") {
return body.byteLength;
} else if (typeof body.size === "number") {
return body.size;
}
throw new Error(`Body Length computation failed for ${body}`);
};
const fromUtf83 = (input)=>{
const bytes = [];
for(let i = 0, len = input.length; i < len; i++){
const value = input.charCodeAt(i);
if (value < 128) {
bytes.push(value);
} else if (value < 2048) {
bytes.push(value >> 6 | 192, value & 63 | 128);
} else if (i + 1 < input.length && (value & 64512) === 55296 && (input.charCodeAt(i + 1) & 64512) === 56320) {
const surrogatePair = 65536 + ((value & 1023) << 10) + (input.charCodeAt(++i) & 1023);
bytes.push(surrogatePair >> 18 | 240, surrogatePair >> 12 & 63 | 128, surrogatePair >> 6 & 63 | 128, surrogatePair & 63 | 128);
} else {
bytes.push(value >> 12 | 224, value >> 6 & 63 | 128, value & 63 | 128);
}
}
return Uint8Array.from(bytes);
};
const toUtf82 = (input)=>{
let decoded = "";
for(let i = 0, len = input.length; i < len; i++){
const __byte = input[i];
if (__byte < 128) {
decoded += String.fromCharCode(__byte);
} else if (192 <= __byte && __byte < 224) {
const nextByte = input[++i];
decoded += String.fromCharCode((__byte & 31) << 6 | nextByte & 63);
} else if (240 <= __byte && __byte < 365) {
const surrogatePair = [
__byte,
input[++i],
input[++i],
input[++i]
];
const encoded = "%" + surrogatePair.map((byteValue)=>byteValue.toString(16)).join("%");
decoded += decodeURIComponent(encoded);
} else {
decoded += String.fromCharCode((__byte & 15) << 12 | (input[++i] & 63) << 6 | input[++i] & 63);
}
}
return decoded;
};
function fromUtf8$12(input) {
return new TextEncoder().encode(input);
}
function toUtf8$12(input) {
return new TextDecoder("utf-8").decode(input);
}
const fromUtf8$22 = (input)=>typeof TextEncoder === "function" ? fromUtf8$12(input) : fromUtf83(input);
const toUtf8$22 = (input)=>typeof TextDecoder === "function" ? toUtf8$12(input) : toUtf82(input);
const getAwsChunkedEncodingStream = (readableStream, options)=>{
const { base64Encoder , bodyLengthChecker , checksumAlgorithmFn , checksumLocationName , streamHasher } = options;
const checksumRequired = base64Encoder !== void 0 && bodyLengthChecker !== void 0 && checksumAlgorithmFn !== void 0 && checksumLocationName !== void 0 && streamHasher !== void 0;
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : void 0;
const reader = readableStream.getReader();
return new ReadableStream({
async pull (controller) {
const { value , done } = await reader.read();
if (done) {
controller.enqueue(`0\r
`);
if (checksumRequired) {
const checksum = base64Encoder(await digest);
controller.enqueue(`${checksumLocationName}:${checksum}\r
`);
controller.enqueue(`\r
`);
}
controller.close();
} else {
controller.enqueue(`${(bodyLengthChecker(value) || 0).toString(16)}\r
${value}\r
`);
}
}
});
};
const ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
const sdkStreamMixin = (stream)=>{
var _a, _b;
if (!isBlobInstance(stream) && !isReadableStreamInstance(stream)) {
const name = ((_b = (_a = stream == null ? void 0 : stream.__proto__) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name) || stream;
throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${name}`);
}
let transformed = false;
const transformToByteArray = async ()=>{
if (transformed) {
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
}
transformed = true;
return await streamCollector(stream);
};
const blobToWebStream = (blob)=>{
if (typeof blob.stream !== "function") {
throw new Error("Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.\nIf you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");
}
return blob.stream();
};
return Object.assign(stream, {
transformToByteArray,
transformToString: async (encoding)=>{
const buf = await transformToByteArray();
if (encoding === "base64") {
return toBase64(buf);
} else if (encoding === "hex") {
return toHex1(buf);
} else if (encoding === void 0 || encoding === "utf8" || encoding === "utf-8") {
return toUtf8$22(buf);
} else if (typeof TextDecoder === "function") {
return new TextDecoder(encoding).decode(buf);
} else {
throw new Error("TextDecoder is not available, please make sure polyfill is provided.");
}
},
transformToWebStream: ()=>{
if (transformed) {
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
}
transformed = true;
if (isBlobInstance(stream)) {
return blobToWebStream(stream);
} else if (isReadableStreamInstance(stream)) {
return stream;
} else {
throw new Error(`Cannot transform payload to web stream, got ${stream}`);
}
}
});
};
const isBlobInstance = (stream)=>typeof Blob === "function" && stream instanceof Blob;
const isReadableStreamInstance = (stream)=>typeof ReadableStream === "function" && stream instanceof ReadableStream;
const BROWSER_ALIASES_MAP = {
"Amazon Silk": "amazon_silk",
"Android Browser": "android",
Bada: "bada",
BlackBerry: "blackberry",
Chrome: "chrome",
Chromium: "chromium",
Electron: "electron",
Epiphany: "epiphany",
Firefox: "firefox",
Focus: "focus",
Generic: "generic",
"Google Search": "google_search",
Googlebot: "googlebot",
"Internet Explorer": "ie",
"K-Meleon": "k_meleon",
Maxthon: "maxthon",
"Microsoft Edge": "edge",
"MZ Browser": "mz",
"NAVER Whale Browser": "naver",
Opera: "opera",
"Opera Coast": "opera_coast",
PhantomJS: "phantomjs",
Puffin: "puffin",
QupZilla: "qupzilla",
QQ: "qq",
QQLite: "qqlite",
Safari: "safari",
Sailfish: "sailfish",
"Samsung Internet for Android": "samsung_internet",
SeaMonkey: "seamonkey",
Sleipnir: "sleipnir",
Swing: "swing",
Tizen: "tizen",
"UC Browser": "uc",
Vivaldi: "vivaldi",
"WebOS Browser": "webos",
WeChat: "wechat",
"Yandex Browser": "yandex",
Roku: "roku"
};
const BROWSER_MAP = {
amazon_silk: "Amazon Silk",
android: "Android Browser",
bada: "Bada",
blackberry: "BlackBerry",
chrome: "Chrome",
chromium: "Chromium",
electron: "Electron",
epiphany: "Epiphany",
firefox: "Firefox",
focus: "Focus",
generic: "Generic",
googlebot: "Googlebot",
google_search: "Google Search",
ie: "Internet Explorer",
k_meleon: "K-Meleon",
maxthon: "Maxthon",
edge: "Microsoft Edge",
mz: "MZ Browser",
naver: "NAVER Whale Browser",
opera: "Opera",
opera_coast: "Opera Coast",
phantomjs: "PhantomJS",
puffin: "Puffin",
qupzilla: "QupZilla",
qq: "QQ Browser",
qqlite: "QQ Browser Lite",
safari: "Safari",
sailfish: "Sailfish",
samsung_internet: "Samsung Internet for Android",
seamonkey: "SeaMonkey",
sleipnir: "Sleipnir",
swing: "Swing",
tizen: "Tizen",
uc: "UC Browser",
vivaldi: "Vivaldi",
webos: "WebOS Browser",
wechat: "WeChat",
yandex: "Yandex Browser"
};
const PLATFORMS_MAP = {
tablet: "tablet",
mobile: "mobile",
desktop: "desktop",
tv: "tv"
};
const OS_MAP = {
WindowsPhone: "Windows Phone",
Windows: "Windows",
MacOS: "macOS",
iOS: "iOS",
Android: "Android",
WebOS: "WebOS",
BlackBerry: "BlackBerry",
Bada: "Bada",
Tizen: "Tizen",
Linux: "Linux",
ChromeOS: "Chrome OS",
PlayStation4: "PlayStation 4",
Roku: "Roku"
};
const ENGINE_MAP = {
EdgeHTML: "EdgeHTML",
Blink: "Blink",
Trident: "Trident",
Presto: "Presto",
Gecko: "Gecko",
WebKit: "WebKit"
};
class Utils {
static getFirstMatch(regexp, ua) {
const match = ua.match(regexp);
return match && match.length > 0 && match[1] || "";
}
static getSecondMatch(regexp, ua) {
const match = ua.match(regexp);
return match && match.length > 1 && match[2] || "";
}
static matchAndReturnConst(regexp, ua, _const) {
if (regexp.test(ua)) {
return _const;
}
return void 0;
}
static getWindowsVersionName(version) {
switch(version){
case "NT":
return "NT";
case "XP":
return "XP";
case "NT 5.0":
return "2000";
case "NT 5.1":
return "XP";
case "NT 5.2":
return "2003";
case "NT 6.0":
return "Vista";
case "NT 6.1":
return "7";
case "NT 6.2":
return "8";
case "NT 6.3":
return "8.1";
case "NT 10.0":
return "10";
default:
return void 0;
}
}
static getMacOSVersionName(version) {
const v = version.split(".").splice(0, 2).map((s)=>parseInt(s, 10) || 0);
v.push(0);
if (v[0] !== 10) return void 0;
switch(v[1]){
case 5:
return "Leopard";
case 6:
return "Snow Leopard";
case 7:
return "Lion";
case 8:
return "Mountain Lion";
case 9:
return "Mavericks";
case 10:
return "Yosemite";
case 11:
return "El Capitan";
case 12:
return "Sierra";
case 13:
return "High Sierra";
case 14:
return "Mojave";
case 15:
return "Catalina";
default:
return void 0;
}
}
static getAndroidVersionName(version) {
const v = version.split(".").splice(0, 2).map((s)=>parseInt(s, 10) || 0);
v.push(0);
if (v[0] === 1 && v[1] < 5) return void 0;
if (v[0] === 1 && v[1] < 6) return "Cupcake";
if (v[0] === 1 && v[1] >= 6) return "Donut";
if (v[0] === 2 && v[1] < 2) return "Eclair";
if (v[0] === 2 && v[1] === 2) return "Froyo";
if (v[0] === 2 && v[1] > 2) return "Gingerbread";
if (v[0] === 3) return "Honeycomb";
if (v[0] === 4 && v[1] < 1) return "Ice Cream Sandwich";
if (v[0] === 4 && v[1] < 4) return "Jelly Bean";
if (v[0] === 4 && v[1] >= 4) return "KitKat";
if (v[0] === 5) return "Lollipop";
if (v[0] === 6) return "Marshmallow";
if (v[0] === 7) return "Nougat";
if (v[0] === 8) return "Oreo";
if (v[0] === 9) return "Pie";
return void 0;
}
static getVersionPrecision(version) {
return version.split(".").length;
}
static compareVersions(versionA, versionB, isLoose = false) {
const versionAPrecision = Utils.getVersionPrecision(versionA);
const versionBPrecision = Utils.getVersionPrecision(versionB);
let precision = Math.max(versionAPrecision, versionBPrecision);
let lastPrecision = 0;
const chunks = Utils.map([
versionA,
versionB
], (version)=>{
const delta = precision - Utils.getVersionPrecision(version);
const _version = version + new Array(delta + 1).join(".0");
return Utils.map(_version.split("."), (chunk)=>new Array(20 - chunk.length).join("0") + chunk).reverse();
});
if (isLoose) {
lastPrecision = precision - Math.min(versionAPrecision, versionBPrecision);
}
precision -= 1;
while(precision >= lastPrecision){
if (chunks[0][precision] > chunks[1][precision]) {
return 1;
}
if (chunks[0][precision] === chunks[1][precision]) {
if (precision === lastPrecision) {
return 0;
}
precision -= 1;
} else if (chunks[0][precision] < chunks[1][precision]) {
return -1;
}
}
return void 0;
}
static map(arr, iterator) {
const result = [];
let i;
if (Array.prototype.map) {
return Array.prototype.map.call(arr, iterator);
}
for(i = 0; i < arr.length; i += 1){
result.push(iterator(arr[i]));
}
return result;
}
static find(arr, predicate) {
let i;
let l;
if (Array.prototype.find) {
return Array.prototype.find.call(arr, predicate);
}
for(i = 0, l = arr.length; i < l; i += 1){
const value = arr[i];
if (predicate(value, i)) {
return value;
}
}
return void 0;
}
static assign(obj, ...assigners) {
const result = obj;
let i;
let l;
if (Object.assign) {
return Object.assign(obj, ...assigners);
}
for(i = 0, l = assigners.length; i < l; i += 1){
const assigner = assigners[i];
if (typeof assigner === "object" && assigner !== null) {
const keys = Object.keys(assigner);
keys.forEach((key)=>{
result[key] = assigner[key];
});
}
}
return obj;
}
static getBrowserAlias(browserName) {
return BROWSER_ALIASES_MAP[browserName];
}
static getBrowserTypeByAlias(browserAlias) {
return BROWSER_MAP[browserAlias] || "";
}
}
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
const browsersList = [
{
test: [
/googlebot/i
],
describe (ua) {
const browser = {
name: "Googlebot"
};
const version = Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/opera/i
],
describe (ua) {
const browser = {
name: "Opera"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/opr\/|opios/i
],
describe (ua) {
const browser = {
name: "Opera"
};
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/SamsungBrowser/i
],
describe (ua) {
const browser = {
name: "Samsung Internet for Android"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/Whale/i
],
describe (ua) {
const browser = {
name: "NAVER Whale Browser"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/MZBrowser/i
],
describe (ua) {
const browser = {
name: "MZ Browser"
};
const version = Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/focus/i
],
describe (ua) {
const browser = {
name: "Focus"
};
const version = Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/swing/i
],
describe (ua) {
const browser = {
name: "Swing"
};
const version = Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/coast/i
],
describe (ua) {
const browser = {
name: "Opera Coast"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/opt\/\d+(?:.?_?\d+)+/i
],
describe (ua) {
const browser = {
name: "Opera Touch"
};
const version = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/yabrowser/i
],
describe (ua) {
const browser = {
name: "Yandex Browser"
};
const version = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/ucbrowser/i
],
describe (ua) {
const browser = {
name: "UC Browser"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/Maxthon|mxios/i
],
describe (ua) {
const browser = {
name: "Maxthon"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/epiphany/i
],
describe (ua) {
const browser = {
name: "Epiphany"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/puffin/i
],
describe (ua) {
const browser = {
name: "Puffin"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/sleipnir/i
],
describe (ua) {
const browser = {
name: "Sleipnir"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/k-meleon/i
],
describe (ua) {
const browser = {
name: "K-Meleon"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/micromessenger/i
],
describe (ua) {
const browser = {
name: "WeChat"
};
const version = Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/qqbrowser/i
],
describe (ua) {
const browser = {
name: /qqbrowserlite/i.test(ua) ? "QQ Browser Lite" : "QQ Browser"
};
const version = Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/msie|trident/i
],
describe (ua) {
const browser = {
name: "Internet Explorer"
};
const version = Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/\sedg\//i
],
describe (ua) {
const browser = {
name: "Microsoft Edge"
};
const version = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/edg([ea]|ios)/i
],
describe (ua) {
const browser = {
name: "Microsoft Edge"
};
const version = Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/vivaldi/i
],
describe (ua) {
const browser = {
name: "Vivaldi"
};
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/seamonkey/i
],
describe (ua) {
const browser = {
name: "SeaMonkey"
};
const version = Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/sailfish/i
],
describe (ua) {
const browser = {
name: "Sailfish"
};
const version = Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/silk/i
],
describe (ua) {
const browser = {
name: "Amazon Silk"
};
const version = Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/phantom/i
],
describe (ua) {
const browser = {
name: "PhantomJS"
};
const version = Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/slimerjs/i
],
describe (ua) {
const browser = {
name: "SlimerJS"
};
const version = Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/blackberry|\bbb\d+/i,
/rim\stablet/i
],
describe (ua) {
const browser = {
name: "BlackBerry"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/(web|hpw)[o0]s/i
],
describe (ua) {
const browser = {
name: "WebOS Browser"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/bada/i
],
describe (ua) {
const browser = {
name: "Bada"
};
const version = Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/tizen/i
],
describe (ua) {
const browser = {
name: "Tizen"
};
const version = Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/qupzilla/i
],
describe (ua) {
const browser = {
name: "QupZilla"
};
const version = Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/firefox|iceweasel|fxios/i
],
describe (ua) {
const browser = {
name: "Firefox"
};
const version = Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/electron/i
],
describe (ua) {
const browser = {
name: "Electron"
};
const version = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/MiuiBrowser/i
],
describe (ua) {
const browser = {
name: "Miui"
};
const version = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/chromium/i
],
describe (ua) {
const browser = {
name: "Chromium"
};
const version = Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/chrome|crios|crmo/i
],
describe (ua) {
const browser = {
name: "Chrome"
};
const version = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/GSA/i
],
describe (ua) {
const browser = {
name: "Google Search"
};
const version = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test (parser) {
const notLikeAndroid = !parser.test(/like android/i);
const butAndroid = parser.test(/android/i);
return notLikeAndroid && butAndroid;
},
describe (ua) {
const browser = {
name: "Android Browser"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/playstation 4/i
],
describe (ua) {
const browser = {
name: "PlayStation 4"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/safari|applewebkit/i
],
describe (ua) {
const browser = {
name: "Safari"
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
if (version) {
browser.version = version;
}
return browser;
}
},
{
test: [
/.*/i
],
describe (ua) {
const regexpWithoutDeviceSpec = /^(.*)\/(.*) /;
const regexpWithDeviceSpec = /^(.*)\/(.*)[ \t]\((.*)/;
const hasDeviceSpec = ua.search("\\(") !== -1;
const regexp = hasDeviceSpec ? regexpWithDeviceSpec : regexpWithoutDeviceSpec;
return {
name: Utils.getFirstMatch(regexp, ua),
version: Utils.getSecondMatch(regexp, ua)
};
}
}
];
var osParsersList = [
{
test: [
/Roku\/DVP/
],
describe (ua) {
const version = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
return {
name: OS_MAP.Roku,
version
};
}
},
{
test: [
/windows phone/i
],
describe (ua) {
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
return {
name: OS_MAP.WindowsPhone,
version
};
}
},
{
test: [
/windows /i
],
describe (ua) {
const version = Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i, ua);
const versionName = Utils.getWindowsVersionName(version);
return {
name: OS_MAP.Windows,
version,
versionName
};
}
},
{
test: [
/Macintosh(.*?) FxiOS(.*?)\//
],
describe (ua) {
const result = {
name: OS_MAP.iOS
};
const version = Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/, ua);
if (version) {
result.version = version;
}
return result;
}
},
{
test: [
/macintosh/i
],
describe (ua) {
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, ".");
const versionName = Utils.getMacOSVersionName(version);
const os = {
name: OS_MAP.MacOS,
version
};
if (versionName) {
os.versionName = versionName;
}
return os;
}
},
{
test: [
/(ipod|iphone|ipad)/i
],
describe (ua) {
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, ".");
return {
name: OS_MAP.iOS,
version
};
}
},
{
test (parser) {
const notLikeAndroid = !parser.test(/like android/i);
const butAndroid = parser.test(/android/i);
return notLikeAndroid && butAndroid;
},
describe (ua) {
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
const versionName = Utils.getAndroidVersionName(version);
const os = {
name: OS_MAP.Android,
version
};
if (versionName) {
os.versionName = versionName;
}
return os;
}
},
{
test: [
/(web|hpw)[o0]s/i
],
describe (ua) {
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
const os = {
name: OS_MAP.WebOS
};
if (version && version.length) {
os.version = version;
}
return os;
}
},
{
test: [
/blackberry|\bbb\d+/i,
/rim\stablet/i
],
describe (ua) {
const version = Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i, ua) || Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i, ua) || Utils.getFirstMatch(/\bbb(\d+)/i, ua);
return {
name: OS_MAP.BlackBerry,
version
};
}
},
{
test: [
/bada/i
],
describe (ua) {
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
return {
name: OS_MAP.Bada,
version
};
}
},
{
test: [
/tizen/i
],
describe (ua) {
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
return {
name: OS_MAP.Tizen,
version
};
}
},
{
test: [
/linux/i
],
describe () {
return {
name: OS_MAP.Linux
};
}
},
{
test: [
/CrOS/
],
describe () {
return {
name: OS_MAP.ChromeOS
};
}
},
{
test: [
/PlayStation 4/
],
describe (ua) {
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
return {
name: OS_MAP.PlayStation4,
version
};
}
}
];
var platformParsersList = [
{
test: [
/googlebot/i
],
describe () {
return {
type: "bot",
vendor: "Google"
};
}
},
{
test: [
/huawei/i
],
describe (ua) {
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && "Nova";
const platform = {
type: PLATFORMS_MAP.mobile,
vendor: "Huawei"
};
if (model) {
platform.model = model;
}
return platform;
}
},
{
test: [
/nexus\s*(?:7|8|9|10).*/i
],
describe () {
return {
type: PLATFORMS_MAP.tablet,
vendor: "Nexus"
};
}
},
{
test: [
/ipad/i
],
describe () {
return {
type: PLATFORMS_MAP.tablet,
vendor: "Apple",
model: "iPad"
};
}
},
{
test: [
/Macintosh(.*?) FxiOS(.*?)\//
],
describe () {
return {
type: PLATFORMS_MAP.tablet,
vendor: "Apple",
model: "iPad"
};
}
},
{
test: [
/kftt build/i
],
describe () {
return {
type: PLATFORMS_MAP.tablet,
vendor: "Amazon",
model: "Kindle Fire HD 7"
};
}
},
{
test: [
/silk/i
],
describe () {
return {
type: PLATFORMS_MAP.tablet,
vendor: "Amazon"
};
}
},
{
test: [
/tablet(?! pc)/i
],
describe () {
return {
type: PLATFORMS_MAP.tablet
};
}
},
{
test (parser) {
const iDevice = parser.test(/ipod|iphone/i);
const likeIDevice = parser.test(/like (ipod|iphone)/i);
return iDevice && !likeIDevice;
},
describe (ua) {
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
return {
type: PLATFORMS_MAP.mobile,
vendor: "Apple",
model
};
}
},
{
test: [
/nexus\s*[0-6].*/i,
/galaxy nexus/i
],
describe () {
return {
type: PLATFORMS_MAP.mobile,
vendor: "Nexus"
};
}
},
{
test: [
/[^-]mobi/i
],
describe () {
return {
type: PLATFORMS_MAP.mobile
};
}
},
{
test (parser) {
return parser.getBrowserName(true) === "blackberry";
},
describe () {
return {
type: PLATFORMS_MAP.mobile,
vendor: "BlackBerry"
};
}
},
{
test (parser) {
return parser.getBrowserName(true) === "bada";
},
describe () {
return {
type: PLATFORMS_MAP.mobile
};
}
},
{
test (parser) {
return parser.getBrowserName() === "windows phone";
},
describe () {
return {
type: PLATFORMS_MAP.mobile,
vendor: "Microsoft"
};
}
},
{
test (parser) {
const osMajorVersion = Number(String(parser.getOSVersion()).split(".")[0]);
return parser.getOSName(true) === "android" && osMajorVersion >= 3;
},
describe () {
return {
type: PLATFORMS_MAP.tablet
};
}
},
{
test (parser) {
return parser.getOSName(true) === "android";
},
describe () {
return {
type: PLATFORMS_MAP.mobile
};
}
},
{
test (parser) {
return parser.getOSName(true) === "macos";
},
describe () {
return {
type: PLATFORMS_MAP.desktop,
vendor: "Apple"
};
}
},
{
test (parser) {
return parser.getOSName(true) === "windows";
},
describe () {
return {
type: PLATFORMS_MAP.desktop
};
}
},
{
test (parser) {
return parser.getOSName(true) === "linux";
},
describe () {
return {
type: PLATFORMS_MAP.desktop
};
}
},
{
test (parser) {
return parser.getOSName(true) === "playstation 4";
},
describe () {
return {
type: PLATFORMS_MAP.tv
};
}
},
{
test (parser) {
return parser.getOSName(true) === "roku";
},
describe () {
return {
type: PLATFORMS_MAP.tv
};
}
}
];
var enginesParsersList = [
{
test (parser) {
return parser.getBrowserName(true) === "microsoft edge";
},
describe (ua) {
const isBlinkBased = /\sedg\//i.test(ua);
if (isBlinkBased) {
return {
name: ENGINE_MAP.Blink
};
}
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
return {
name: ENGINE_MAP.EdgeHTML,
version
};
}
},
{
test: [
/trident/i
],
describe (ua) {
const engine = {
name: ENGINE_MAP.Trident
};
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
engine.version = version;
}
return engine;
}
},
{
test (parser) {
return parser.test(/presto/i);
},
describe (ua) {
const engine = {
name: ENGINE_MAP.Presto
};
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
engine.version = version;
}
return engine;
}
},
{
test (parser) {
const isGecko = parser.test(/gecko/i);
const likeGecko = parser.test(/like gecko/i);
return isGecko && !likeGecko;
},
describe (ua) {
const engine = {
name: ENGINE_MAP.Gecko
};
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
engine.version = version;
}
return engine;
}
},
{
test: [
/(apple)?webkit\/537\.36/i
],
describe () {
return {
name: ENGINE_MAP.Blink
};
}
},
{
test: [
/(apple)?webkit/i
],
describe (ua) {
const engine = {
name: ENGINE_MAP.WebKit
};
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
if (version) {
engine.version = version;
}
return engine;
}
}
];
class Parser {
constructor(UA, skipParsing = false){
if (UA === void 0 || UA === null || UA === "") {
throw new Error("UserAgent parameter can't be empty");
}
this._ua = UA;
this.parsedResult = {};
if (skipParsing !== true) {
this.parse();
}
}
getUA() {
return this._ua;
}
test(regex) {
return regex.test(this._ua);
}
parseBrowser() {
this.parsedResult.browser = {};
const browserDescriptor = Utils.find(browsersList, (_browser)=>{
if (typeof _browser.test === "function") {
return _browser.test(this);
}
if (_browser.test instanceof Array) {
return _browser.test.some((condition)=>this.test(condition));
}
throw new Error("Browser's test function is not valid");
});
if (browserDescriptor) {
this.parsedResult.browser = browserDescriptor.describe(this.getUA());
}
return this.parsedResult.browser;
}
getBrowser() {
if (this.parsedResult.browser) {
return this.parsedResult.browser;
}
return this.parseBrowser();
}
getBrowserName(toLowerCase) {
if (toLowerCase) {
return String(this.getBrowser().name).toLowerCase() || "";
}
return this.getBrowser().name || "";
}
getBrowserVersion() {
return this.getBrowser().version;
}
getOS() {
if (this.parsedResult.os) {
return this.parsedResult.os;
}
return this.parseOS();
}
parseOS() {
this.parsedResult.os = {};
const os = Utils.find(osParsersList, (_os)=>{
if (typeof _os.test === "function") {
return _os.test(this);
}
if (_os.test instanceof Array) {
return _os.test.some((condition)=>this.test(condition));
}
throw new Error("Browser's test function is not valid");
});
if (os) {
this.parsedResult.os = os.describe(this.getUA());
}
return this.parsedResult.os;
}
getOSName(toLowerCase) {
const { name } = this.getOS();
if (toLowerCase) {
return String(name).toLowerCase() || "";
}
return name || "";
}
getOSVersion() {
return this.getOS().version;
}
getPlatform() {
if (this.parsedResult.platform) {
return this.parsedResult.platform;
}
return this.parsePlatform();
}
getPlatformType(toLowerCase = false) {
const { type } = this.getPlatform();
if (toLowerCase) {
return String(type).toLowerCase() || "";
}
return type || "";
}
parsePlatform() {
this.parsedResult.platform = {};
const platform = Utils.find(platformParsersList, (_platform)=>{
if (typeof _platform.test === "function") {
return _platform.test(this);
}
if (_platform.test instanceof Array) {
return _platform.test.some((condition)=>this.test(condition));
}
throw new Error("Browser's test function is not valid");
});
if (platform) {
this.parsedResult.platform = platform.describe(this.getUA());
}
return this.parsedResult.platform;
}
getEngine() {
if (this.parsedResult.engine) {
return this.parsedResult.engine;
}
return this.parseEngine();
}
getEngineName(toLowerCase) {
if (toLowerCase) {
return String(this.getEngine().name).toLowerCase() || "";
}
return this.getEngine().name || "";
}
parseEngine() {
this.parsedResult.engine = {};
const engine = Utils.find(enginesParsersList, (_engine)=>{
if (typeof _engine.test === "function") {
return _engine.test(this);
}
if (_engine.test instanceof Array) {
return _engine.test.some((condition)=>this.test(condition));
}
throw new Error("Browser's test function is not valid");
});
if (engine) {
this.parsedResult.engine = engine.describe(this.getUA());
}
return this.parsedResult.engine;
}
parse() {
this.parseBrowser();
this.parseOS();
this.parsePlatform();
this.parseEngine();
return this;
}
getResult() {
return Utils.assign({}, this.parsedResult);
}
satisfies(checkTree) {
const platformsAndOSes = {};
let platformsAndOSCounter = 0;
const browsers = {};
let browsersCounter = 0;
const allDefinitions = Object.keys(checkTree);
allDefinitions.forEach((key)=>{
const currentDefinition = checkTree[key];
if (typeof currentDefinition === "string") {
browsers[key] = currentDefinition;
browsersCounter += 1;
} else if (typeof currentDefinition === "object") {
platformsAndOSes[key] = currentDefinition;
platformsAndOSCounter += 1;
}
});
if (platformsAndOSCounter > 0) {
const platformsAndOSNames = Object.keys(platformsAndOSes);
const OSMatchingDefinition = Utils.find(platformsAndOSNames, (name)=>this.isOS(name));
if (OSMatchingDefinition) {
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
if (osResult !== void 0) {
return osResult;
}
}
const platformMatchingDefinition = Utils.find(platformsAndOSNames, (name)=>this.isPlatform(name));
if (platformMatchingDefinition) {
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
if (platformResult !== void 0) {
return platformResult;
}
}
}
if (browsersCounter > 0) {
const browserNames = Object.keys(browsers);
const matchingDefinition = Utils.find(browserNames, (name)=>this.isBrowser(name, true));
if (matchingDefinition !== void 0) {
return this.compareVersion(browsers[matchingDefinition]);
}
}
return void 0;
}
isBrowser(browserName, includingAlias = false) {
const defaultBrowserName = this.getBrowserName().toLowerCase();
let browserNameLower = browserName.toLowerCase();
const alias = Utils.getBrowserTypeByAlias(browserNameLower);
if (includingAlias && alias) {
browserNameLower = alias.toLowerCase();
}
return browserNameLower === defaultBrowserName;
}
compareVersion(version) {
let expectedResults = [
0
];
let comparableVersion = version;
let isLoose = false;
const currentBrowserVersion = this.getBrowserVersion();
if (typeof currentBrowserVersion !== "string") {
return void 0;
}
if (version[0] === ">" || version[0] === "<") {
comparableVersion = version.substr(1);
if (version[1] === "=") {
isLoose = true;
comparableVersion = version.substr(2);
} else {
expectedResults = [];
}
if (version[0] === ">") {
expectedResults.push(1);
} else {
expectedResults.push(-1);
}
} else if (version[0] === "=") {
comparableVersion = version.substr(1);
} else if (version[0] === "~") {
isLoose = true;
comparableVersion = version.substr(1);
}
return expectedResults.indexOf(Utils.compareVersions(currentBrowserVersion, comparableVersion, isLoose)) > -1;
}
isOS(osName) {
return this.getOSName(true) === String(osName).toLowerCase();
}
isPlatform(platformType) {
return this.getPlatformType(true) === String(platformType).toLowerCase();
}
isEngine(engineName) {
return this.getEngineName(true) === String(engineName).toLowerCase();
}
is(anything, includingAlias = false) {
return this.isBrowser(anything, includingAlias) || this.isOS(anything) || this.isPlatform(anything);
}
some(anythings = []) {
return anythings.some((anything)=>this.is(anything));
}
}
class Bowser {
static getParser(UA, skipParsing = false) {
if (typeof UA !== "string") {
throw new Error("UserAgent should be a string");
}
return new Parser(UA, skipParsing);
}
static parse(UA) {
return new Parser(UA).getResult();
}
static get BROWSER_MAP() {
return BROWSER_MAP;
}
static get ENGINE_MAP() {
return ENGINE_MAP;
}
static get OS_MAP() {
return OS_MAP;
}
static get PLATFORMS_MAP() {
return PLATFORMS_MAP;
}
}
const defaultUserAgent = ({ serviceId , clientVersion })=>async ()=>{
var _a, _b, _c, _d, _e, _f, _g;
const parsedUA = typeof window !== "undefined" && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) ? Bowser.parse(window.navigator.userAgent) : void 0;
const sections = [
[
"aws-sdk-js",
clientVersion
],
[
`os/${((_b = parsedUA == null ? void 0 : parsedUA.os) == null ? void 0 : _b.name) || "other"}`,
(_c = parsedUA == null ? void 0 : parsedUA.os) == null ? void 0 : _c.version
],
[
"lang/js"
],
[
"md/browser",
`${(_e = (_d = parsedUA == null ? void 0 : parsedUA.browser) == null ? void 0 : _d.name) != null ? _e : "unknown"}_${(_g = (_f = parsedUA == null ? void 0 : parsedUA.browser) == null ? void 0 : _f.version) != null ? _g : "unknown"}`
]
];
if (serviceId) {
sections.push([
`api/${serviceId}`,
clientVersion
]);
}
return sections;
};
class SignatureV4MultiRegion {
constructor(options){
this.sigv4Signer = new SignatureV4(options);
this.signerOptions = options;
}
async sign(requestToSign, options = {}) {
if (options.signingRegion === "*") {
if (this.signerOptions.runtime !== "node") throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
return this.getSigv4aSigner().sign(requestToSign, options);
}
return this.sigv4Signer.sign(requestToSign, options);
}
async presign(originalRequest, options = {}) {
if (options.signingRegion === "*") {
if (this.signerOptions.runtime !== "node") throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
return this.getSigv4aSigner().presign(originalRequest, options);
}
return this.sigv4Signer.presign(originalRequest, options);
}
getSigv4aSigner() {
if (!this.sigv4aSigner) {
let CrtSignerV4;
try {
CrtSignerV4 = typeof require === "function" && require("@aws-sdk/signature-v4-crt").CrtSignerV4;
if (typeof CrtSignerV4 !== "function") throw new Error();
} catch (e) {
e.message = `${e.message}
Please check if you have installed "@aws-sdk/signature-v4-crt" package explicitly.
For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`;
throw e;
}
this.sigv4aSigner = new CrtSignerV4({
...this.signerOptions,
signingAlgorithm: 1
});
}
return this.sigv4aSigner;
}
}
var EndpointURLScheme;
(function(EndpointURLScheme2) {
EndpointURLScheme2["HTTP"] = "http";
EndpointURLScheme2["HTTPS"] = "https";
})(EndpointURLScheme || (EndpointURLScheme = {}));
const version1 = "1.1";
const partitions = [
{
id: "aws",
regionRegex: "^(us|eu|ap|sa|ca|me|af)-\\w+-\\d+$",
regions: {
"af-south-1": {},
"af-east-1": {},
"ap-northeast-1": {},
"ap-northeast-2": {},
"ap-northeast-3": {},
"ap-south-1": {},
"ap-southeast-1": {},
"ap-southeast-2": {},
"ap-southeast-3": {},
"ca-central-1": {},
"eu-central-1": {},
"eu-north-1": {},
"eu-south-1": {},
"eu-west-1": {},
"eu-west-2": {},
"eu-west-3": {},
"me-south-1": {},
"sa-east-1": {},
"us-east-1": {},
"us-east-2": {},
"us-west-1": {},
"us-west-2": {},
"aws-global": {}
},
outputs: {
name: "aws",
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
supportsFIPS: true,
supportsDualStack: true
}
},
{
id: "aws-us-gov",
regionRegex: "^us\\-gov\\-\\w+\\-\\d+$",
regions: {
"us-gov-west-1": {},
"us-gov-east-1": {},
"aws-us-gov-global": {}
},
outputs: {
name: "aws-us-gov",
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
supportsFIPS: true,
supportsDualStack: true
}
},
{
id: "aws-cn",
regionRegex: "^cn\\-\\w+\\-\\d+$",
regions: {
"cn-north-1": {},
"cn-northwest-1": {},
"aws-cn-global": {}
},
outputs: {
name: "aws-cn",
dnsSuffix: "amazonaws.com.cn",
dualStackDnsSuffix: "api.amazonwebservices.com.cn",
supportsFIPS: true,
supportsDualStack: true
}
},
{
id: "aws-iso",
regionRegex: "^us\\-iso\\-\\w+\\-\\d+$",
outputs: {
name: "aws-iso",
dnsSuffix: "c2s.ic.gov",
supportsFIPS: true,
supportsDualStack: false,
dualStackDnsSuffix: "c2s.ic.gov"
},
regions: {
"aws-iso-global": {}
}
},
{
id: "aws-iso-b",
regionRegex: "^us\\-isob\\-\\w+\\-\\d+$",
outputs: {
name: "aws-iso-b",
dnsSuffix: "sc2s.sgov.gov",
supportsFIPS: true,
supportsDualStack: false,
dualStackDnsSuffix: "sc2s.sgov.gov"
},
regions: {
"aws-iso-b-global": {}
}
}
];
var partitionsInfo = {
version: version1,
partitions
};
const { partitions: partitions$1 } = partitionsInfo;
const DEFAULT_PARTITION = partitions$1.find((partition2)=>partition2.id === "aws");
const partition = (value)=>{
for (const partition2 of partitions$1){
const { regions , outputs } = partition2;
for (const [region, regionData] of Object.entries(regions)){
if (region === value) {
return {
...outputs,
...regionData
};
}
}
}
for (const partition21 of partitions$1){
const { regionRegex , outputs: outputs1 } = partition21;
if (new RegExp(regionRegex).test(value)) {
return {
...outputs1
};
}
}
if (!DEFAULT_PARTITION) {
throw new Error("Provided region was not found in the partition array or regex, and default partition with id 'aws' doesn't exist.");
}
return {
...DEFAULT_PARTITION.outputs
};
};
const debugId = "endpoints";
function toDebugString(input) {
if (typeof input !== "object" || input == null) {
return input;
}
if ("ref" in input) {
return `$${toDebugString(input.ref)}`;
}
if ("fn" in input) {
return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`;
}
return JSON.stringify(input, null, 2);
}
class EndpointError extends Error {
constructor(message){
super(message);
this.name = "EndpointError";
}
}
const IP_V4_REGEX = new RegExp(`^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$`);
const isIpAddress = (value)=>IP_V4_REGEX.test(value) || value.startsWith("[") && value.endsWith("]");
const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`);
const isValidHostLabel = (value, allowSubDomains = false)=>{
if (!allowSubDomains) {
return VALID_HOST_LABEL_REGEX.test(value);
}
const labels = value.split(".");
for (const label of labels){
if (!isValidHostLabel(label)) {
return false;
}
}
return true;
};
const isVirtualHostableS3Bucket = (value, allowSubDomains = false)=>{
if (allowSubDomains) {
for (const label of value.split(".")){
if (!isVirtualHostableS3Bucket(label)) {
return false;
}
}
return true;
}
if (!isValidHostLabel(value)) {
return false;
}
if (value.length < 3 || value.length > 63) {
return false;
}
if (value !== value.toLowerCase()) {
return false;
}
if (isIpAddress(value)) {
return false;
}
return true;
};
const parseArn = (value)=>{
const segments = value.split(":");
if (segments.length < 6) return null;
const [arn, partition2, service, region, accountId, ...resourceId] = segments;
if (arn !== "arn" || partition2 === "" || service === "" || resourceId[0] === "") return null;
return {
partition: partition2,
service,
region,
accountId,
resourceId: resourceId[0].includes("/") ? resourceId[0].split("/") : resourceId
};
};
var index4 = Object.freeze({
__proto__: null,
isVirtualHostableS3Bucket,
parseArn,
partition
});
const booleanEquals = (value1, value2)=>value1 === value2;
const getAttrPathList = (path)=>{
const parts = path.split(".");
const pathList = [];
for (const part of parts){
const squareBracketIndex = part.indexOf("[");
if (squareBracketIndex !== -1) {
if (part.indexOf("]") !== part.length - 1) {
throw new EndpointError(`Path: '${path}' does not end with ']'`);
}
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
if (Number.isNaN(parseInt(arrayIndex))) {
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path}'`);
}
if (squareBracketIndex !== 0) {
pathList.push(part.slice(0, squareBracketIndex));
}
pathList.push(arrayIndex);
} else {
pathList.push(part);
}
}
return pathList;
};
const getAttr = (value, path)=>getAttrPathList(path).reduce((acc, index2)=>{
if (typeof acc !== "object") {
throw new EndpointError(`Index '${index2}' in '${path}' not found in '${JSON.stringify(value)}'`);
} else if (Array.isArray(acc)) {
return acc[parseInt(index2)];
}
return acc[index2];
}, value);
const isSet = (value)=>value != null;
const not = (value)=>!value;
const DEFAULT_PORTS = {
[EndpointURLScheme.HTTP]: 80,
[EndpointURLScheme.HTTPS]: 443
};
const parseURL = (value)=>{
const whatwgURL = (()=>{
try {
if (value instanceof URL) {
return value;
}
if (typeof value === "object" && "hostname" in value) {
const { hostname: hostname2 , port , protocol: protocol2 = "" , path ="" , query ={} } = value;
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path}`);
url.search = Object.entries(query).map(([k, v])=>`${k}=${v}`).join("&");
return url;
}
return new URL(value);
} catch (error) {
return null;
}
})();
if (!whatwgURL) {
console.error(`Unable to parse ${JSON.stringify(value)} as a whatwg URL.`);
return null;
}
const urlString = whatwgURL.href;
const { host , hostname , pathname , protocol , search } = whatwgURL;
if (search) {
return null;
}
const scheme = protocol.slice(0, -1);
if (!Object.values(EndpointURLScheme).includes(scheme)) {
return null;
}
const isIp = isIpAddress(hostname);
const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) || typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`);
const authority = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
return {
scheme,
authority,
path: pathname,
normalizedPath: pathname.endsWith("/") ? pathname : `${pathname}/`,
isIp
};
};
const stringEquals = (value1, value2)=>value1 === value2;
const substring = (input, start, stop, reverse)=>{
if (start >= stop || input.length < stop) {
return null;
}
if (!reverse) {
return input.substring(start, stop);
}
return input.substring(input.length - stop, input.length - start);
};
const uriEncode = (value)=>encodeURIComponent(value).replace(/[!*'()]/g, (c)=>`%${c.charCodeAt(0).toString(16).toUpperCase()}`);
var lib = Object.freeze({
__proto__: null,
aws: index4,
booleanEquals,
getAttr,
isSet,
isValidHostLabel,
not,
parseURL,
stringEquals,
substring,
uriEncode
});
const ATTR_SHORTHAND_REGEX = new RegExp("\\${([\\w]+)#([\\w]+)}", "g");
const evaluateTemplate = (template, options)=>{
const templateToEvaluate = template.replace(new RegExp(`{([^{}]+)}`, "g"), "${$1}").replace(new RegExp(`{\\\${([^{}]+)}}`, "g"), "{$1}");
const templateContext = {
...options.endpointParams,
...options.referenceRecord
};
const attrShortHandList = templateToEvaluate.match(ATTR_SHORTHAND_REGEX) || [];
const attrShortHandMap = attrShortHandList.reduce((acc, attrShortHand)=>{
const indexOfHash = attrShortHand.indexOf("#");
const refName = attrShortHand.substring(2, indexOfHash);
const attrName = attrShortHand.substring(indexOfHash + 1, attrShortHand.length - 1);
acc[attrShortHand] = getAttr(templateContext[refName], attrName);
return acc;
}, {});
const templateWithAttr = Object.entries(attrShortHandMap).reduce((acc, [shortHand, value])=>acc.replace(shortHand, value), templateToEvaluate);
const templateContextNames = Object.keys(templateContext);
const templateContextValues = Object.values(templateContext);
const templateWithTildeEscaped = templateWithAttr.replace(/\`/g, "\\`");
return new Function(...templateContextNames, `return \`${templateWithTildeEscaped}\``)(...templateContextValues);
};
const getReferenceValue = ({ ref }, options)=>{
const referenceRecord = {
...options.endpointParams,
...options.referenceRecord
};
return referenceRecord[ref];
};
const evaluateExpression = (obj, keyName, options)=>{
if (typeof obj === "string") {
return evaluateTemplate(obj, options);
} else if (obj["fn"]) {
return callFunction(obj, options);
} else if (obj["ref"]) {
return getReferenceValue(obj, options);
}
throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`);
};
const callFunction = ({ fn , argv }, options)=>{
const evaluatedArgs = argv.map((arg)=>[
"boolean",
"number"
].includes(typeof arg) ? arg : evaluateExpression(arg, "arg", options));
return fn.split(".").reduce((acc, key)=>acc[key], lib)(...evaluatedArgs);
};
const evaluateCondition = ({ assign , ...fnArgs }, options)=>{
var _a, _b;
if (assign && assign in options.referenceRecord) {
throw new EndpointError(`'${assign}' is already defined in Reference Record.`);
}
const value = callFunction(fnArgs, options);
(_b = (_a = options.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);
return {
result: value === "" ? true : !!value,
...assign != null && {
toAssign: {
name: assign,
value
}
}
};
};
const evaluateConditions = (conditions = [], options)=>{
var _a, _b;
const conditionsReferenceRecord = {};
for (const condition of conditions){
const { result , toAssign } = evaluateCondition(condition, {
...options,
referenceRecord: {
...options.referenceRecord,
...conditionsReferenceRecord
}
});
if (!result) {
return {
result
};
}
if (toAssign) {
conditionsReferenceRecord[toAssign.name] = toAssign.value;
(_b = (_a = options.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
}
}
return {
result: true,
referenceRecord: conditionsReferenceRecord
};
};
const getEndpointHeaders = (headers, options)=>Object.entries(headers).reduce((acc, [headerKey, headerVal])=>({
...acc,
[headerKey]: headerVal.map((headerValEntry)=>{
const processedExpr = evaluateExpression(headerValEntry, "Header value entry", options);
if (typeof processedExpr !== "string") {
throw new EndpointError(`Header '${headerKey}' value '${processedExpr}' is not a string`);
}
return processedExpr;
})
}), {});
const getEndpointProperty = (property, options)=>{
if (Array.isArray(property)) {
return property.map((propertyEntry)=>getEndpointProperty(propertyEntry, options));
}
switch(typeof property){
case "string":
return evaluateTemplate(property, options);
case "object":
if (property === null) {
throw new EndpointError(`Unexpected endpoint property: ${property}`);
}
return getEndpointProperties(property, options);
case "boolean":
return property;
default:
throw new EndpointError(`Unexpected endpoint property type: ${typeof property}`);
}
};
const getEndpointProperties = (properties, options)=>Object.entries(properties).reduce((acc, [propertyKey, propertyVal])=>({
...acc,
[propertyKey]: getEndpointProperty(propertyVal, options)
}), {});
const getEndpointUrl = (endpointUrl, options)=>{
const expression = evaluateExpression(endpointUrl, "Endpoint URL", options);
if (typeof expression === "string") {
try {
return new URL(expression);
} catch (error) {
console.error(`Failed to construct URL with ${expression}`, error);
throw error;
}
}
throw new EndpointError(`Endpoint URL must be a string, got ${typeof expression}`);
};
const evaluateEndpointRule = (endpointRule, options)=>{
var _a, _b;
const { conditions , endpoint } = endpointRule;
const { result , referenceRecord } = evaluateConditions(conditions, options);
if (!result) {
return;
}
const endpointRuleOptions = {
...options,
referenceRecord: {
...options.referenceRecord,
...referenceRecord
}
};
const { url , properties , headers } = endpoint;
(_b = (_a = options.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);
return {
...headers != void 0 && {
headers: getEndpointHeaders(headers, endpointRuleOptions)
},
...properties != void 0 && {
properties: getEndpointProperties(properties, endpointRuleOptions)
},
url: getEndpointUrl(url, endpointRuleOptions)
};
};
const evaluateErrorRule = (errorRule, options)=>{
const { conditions , error } = errorRule;
const { result , referenceRecord } = evaluateConditions(conditions, options);
if (!result) {
return;
}
throw new EndpointError(evaluateExpression(error, "Error", {
...options,
referenceRecord: {
...options.referenceRecord,
...referenceRecord
}
}));
};
const evaluateTreeRule = (treeRule, options)=>{
const { conditions , rules } = treeRule;
const { result , referenceRecord } = evaluateConditions(conditions, options);
if (!result) {
return;
}
return evaluateRules(rules, {
...options,
referenceRecord: {
...options.referenceRecord,
...referenceRecord
}
});
};
const evaluateRules = (rules, options)=>{
for (const rule of rules){
if (rule.type === "endpoint") {
const endpointOrUndefined = evaluateEndpointRule(rule, options);
if (endpointOrUndefined) {
return endpointOrUndefined;
}
} else if (rule.type === "error") {
evaluateErrorRule(rule, options);
} else if (rule.type === "tree") {
const endpointOrUndefined1 = evaluateTreeRule(rule, options);
if (endpointOrUndefined1) {
return endpointOrUndefined1;
}
} else {
throw new EndpointError(`Unknown endpoint rule: ${rule}`);
}
}
throw new EndpointError(`Rules evaluation failed`);
};
const resolveEndpoint = (ruleSetObject, options)=>{
var _a, _b, _c, _d, _e, _f;
const { endpointParams , logger } = options;
const { parameters , rules } = ruleSetObject;
(_b = (_a = options.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);
const paramsWithDefault = Object.entries(parameters).filter(([, v])=>v.default != null).map(([k, v])=>[
k,
v.default
]);
if (paramsWithDefault.length > 0) {
for (const [paramKey, paramDefaultValue] of paramsWithDefault){
endpointParams[paramKey] = (_c = endpointParams[paramKey]) != null ? _c : paramDefaultValue;
}
}
const requiredParams = Object.entries(parameters).filter(([, v])=>v.required).map(([k])=>k);
for (const requiredParam of requiredParams){
if (endpointParams[requiredParam] == null) {
throw new EndpointError(`Missing required parameter: '${requiredParam}'`);
}
}
const endpoint = evaluateRules(rules, {
endpointParams,
logger,
referenceRecord: {}
});
if ((_d = options.endpointParams) == null ? void 0 : _d.Endpoint) {
try {
const givenEndpoint = new URL(options.endpointParams.Endpoint);
const { protocol , port } = givenEndpoint;
endpoint.url.protocol = protocol;
endpoint.url.port = port;
} catch (e) {}
}
(_f = (_e = options.logger) == null ? void 0 : _e.debug) == null ? void 0 : _f.call(_e, debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);
return endpoint;
};
const DEFAULTS_MODE_OPTIONS = [
"in-region",
"cross-region",
"mobile",
"standard",
"legacy"
];
const resolveDefaultsModeConfig = ({ defaultsMode } = {})=>memoize(async ()=>{
const mode = typeof defaultsMode === "function" ? await defaultsMode() : defaultsMode;
switch(mode == null ? void 0 : mode.toLowerCase()){
case "auto":
return Promise.resolve(isMobileBrowser() ? "mobile" : "standard");
case "mobile":
case "in-region":
case "cross-region":
case "standard":
case "legacy":
return Promise.resolve(mode == null ? void 0 : mode.toLocaleLowerCase());
case void 0:
return Promise.resolve("legacy");
default:
throw new Error(`Invalid parameter for "defaultsMode", expect ${DEFAULTS_MODE_OPTIONS.join(", ")}, got ${mode}`);
}
});
const isMobileBrowser = ()=>{
var _a, _b;
const parsedUA = typeof window !== "undefined" && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) ? Bowser.parse(window.navigator.userAgent) : void 0;
const platform = (_b = parsedUA == null ? void 0 : parsedUA.platform) == null ? void 0 : _b.type;
return platform === "tablet" || platform === "mobile";
};
const sleep = (seconds)=>{
return new Promise((resolve)=>setTimeout(resolve, seconds * 1e3));
};
const waiterServiceDefaults = {
minDelay: 2,
maxDelay: 120
};
var WaiterState;
(function(WaiterState2) {
WaiterState2["ABORTED"] = "ABORTED";
WaiterState2["FAILURE"] = "FAILURE";
WaiterState2["SUCCESS"] = "SUCCESS";
WaiterState2["RETRY"] = "RETRY";
WaiterState2["TIMEOUT"] = "TIMEOUT";
})(WaiterState || (WaiterState = {}));
const checkExceptions = (result)=>{
if (result.state === WaiterState.ABORTED) {
const abortError = new Error(`${JSON.stringify({
...result,
reason: "Request was aborted"
})}`);
abortError.name = "AbortError";
throw abortError;
} else if (result.state === WaiterState.TIMEOUT) {
const timeoutError = new Error(`${JSON.stringify({
...result,
reason: "Waiter has timed out"
})}`);
timeoutError.name = "TimeoutError";
throw timeoutError;
} else if (result.state !== WaiterState.SUCCESS) {
throw new Error(`${JSON.stringify({
result
})}`);
}
return result;
};
const exponentialBackoffWithJitter = (minDelay, maxDelay, attemptCeiling, attempt)=>{
if (attempt > attemptCeiling) return maxDelay;
const delay = minDelay * 2 ** (attempt - 1);
return randomInRange(minDelay, delay);
};
const randomInRange = (min, max)=>min + Math.random() * (max - min);
const runPolling = async ({ minDelay , maxDelay , maxWaitTime , abortController , client , abortSignal }, input, acceptorChecks)=>{
var _a;
const { state , reason } = await acceptorChecks(client, input);
if (state !== WaiterState.RETRY) {
return {
state,
reason
};
}
let currentAttempt = 1;
const waitUntil = Date.now() + maxWaitTime * 1e3;
const attemptCeiling = Math.log(maxDelay / minDelay) / Math.log(2) + 1;
while(true){
if (((_a = abortController == null ? void 0 : abortController.signal) == null ? void 0 : _a.aborted) || (abortSignal == null ? void 0 : abortSignal.aborted)) {
return {
state: WaiterState.ABORTED
};
}
const delay = exponentialBackoffWithJitter(minDelay, maxDelay, attemptCeiling, currentAttempt);
if (Date.now() + delay * 1e3 > waitUntil) {
return {
state: WaiterState.TIMEOUT
};
}
await sleep(delay);
const { state: state2 , reason: reason2 } = await acceptorChecks(client, input);
if (state2 !== WaiterState.RETRY) {
return {
state: state2,
reason: reason2
};
}
currentAttempt += 1;
}
};
const validateWaiterOptions = (options)=>{
if (options.maxWaitTime < 1) {
throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`);
} else if (options.minDelay < 1) {
throw new Error(`WaiterConfiguration.minDelay must be greater than 0`);
} else if (options.maxDelay < 1) {
throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`);
} else if (options.maxWaitTime <= options.minDelay) {
throw new Error(`WaiterConfiguration.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`);
} else if (options.maxDelay < options.minDelay) {
throw new Error(`WaiterConfiguration.maxDelay [${options.maxDelay}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`);
}
};
const abortTimeout = async (abortSignal)=>{
return new Promise((resolve)=>{
abortSignal.onabort = ()=>resolve({
state: WaiterState.ABORTED
});
});
};
const createWaiter = async (options, input, acceptorChecks)=>{
const params = {
...waiterServiceDefaults,
...options
};
validateWaiterOptions(params);
const exitConditions = [
runPolling(params, input, acceptorChecks)
];
if (options.abortController) {
exitConditions.push(abortTimeout(options.abortController.signal));
}
if (options.abortSignal) {
exitConditions.push(abortTimeout(options.abortSignal));
}
return Promise.race(exitConditions);
};
const { XMLParser: XMLParser1 } = fxp;
const { Sha1 } = __pika_web_default_export_for_treeshaking__3;
const { Sha256 } = __pika_web_default_export_for_treeshaking__4;
class S3ServiceException extends ServiceException {
constructor(options){
super(options);
Object.setPrototypeOf(this, S3ServiceException.prototype);
}
}
var RequestCharged;
(function(RequestCharged2) {
RequestCharged2["requester"] = "requester";
})(RequestCharged || (RequestCharged = {}));
var RequestPayer;
(function(RequestPayer2) {
RequestPayer2["requester"] = "requester";
})(RequestPayer || (RequestPayer = {}));
class NoSuchUpload extends S3ServiceException {
constructor(opts){
super({
name: "NoSuchUpload",
$fault: "client",
...opts
});
this.name = "NoSuchUpload";
this.$fault = "client";
Object.setPrototypeOf(this, NoSuchUpload.prototype);
}
}
var BucketAccelerateStatus;
(function(BucketAccelerateStatus2) {
BucketAccelerateStatus2["Enabled"] = "Enabled";
BucketAccelerateStatus2["Suspended"] = "Suspended";
})(BucketAccelerateStatus || (BucketAccelerateStatus = {}));
var Type;
(function(Type2) {
Type2["AmazonCustomerByEmail"] = "AmazonCustomerByEmail";
Type2["CanonicalUser"] = "CanonicalUser";
Type2["Group"] = "Group";
})(Type || (Type = {}));
var Permission;
(function(Permission2) {
Permission2["FULL_CONTROL"] = "FULL_CONTROL";
Permission2["READ"] = "READ";
Permission2["READ_ACP"] = "READ_ACP";
Permission2["WRITE"] = "WRITE";
Permission2["WRITE_ACP"] = "WRITE_ACP";
})(Permission || (Permission = {}));
var OwnerOverride;
(function(OwnerOverride2) {
OwnerOverride2["Destination"] = "Destination";
})(OwnerOverride || (OwnerOverride = {}));
var ServerSideEncryption;
(function(ServerSideEncryption2) {
ServerSideEncryption2["AES256"] = "AES256";
ServerSideEncryption2["aws_kms"] = "aws:kms";
})(ServerSideEncryption || (ServerSideEncryption = {}));
var ObjectCannedACL;
(function(ObjectCannedACL2) {
ObjectCannedACL2["authenticated_read"] = "authenticated-read";
ObjectCannedACL2["aws_exec_read"] = "aws-exec-read";
ObjectCannedACL2["bucket_owner_full_control"] = "bucket-owner-full-control";
ObjectCannedACL2["bucket_owner_read"] = "bucket-owner-read";
ObjectCannedACL2["private"] = "private";
ObjectCannedACL2["public_read"] = "public-read";
ObjectCannedACL2["public_read_write"] = "public-read-write";
})(ObjectCannedACL || (ObjectCannedACL = {}));
var ChecksumAlgorithm1;
(function(ChecksumAlgorithm2) {
ChecksumAlgorithm2["CRC32"] = "CRC32";
ChecksumAlgorithm2["CRC32C"] = "CRC32C";
ChecksumAlgorithm2["SHA1"] = "SHA1";
ChecksumAlgorithm2["SHA256"] = "SHA256";
})(ChecksumAlgorithm1 || (ChecksumAlgorithm1 = {}));
var MetadataDirective;
(function(MetadataDirective2) {
MetadataDirective2["COPY"] = "COPY";
MetadataDirective2["REPLACE"] = "REPLACE";
})(MetadataDirective || (MetadataDirective = {}));
var ObjectLockLegalHoldStatus;
(function(ObjectLockLegalHoldStatus2) {
ObjectLockLegalHoldStatus2["OFF"] = "OFF";
ObjectLockLegalHoldStatus2["ON"] = "ON";
})(ObjectLockLegalHoldStatus || (ObjectLockLegalHoldStatus = {}));
var ObjectLockMode;
(function(ObjectLockMode2) {
ObjectLockMode2["COMPLIANCE"] = "COMPLIANCE";
ObjectLockMode2["GOVERNANCE"] = "GOVERNANCE";
})(ObjectLockMode || (ObjectLockMode = {}));
var StorageClass;
(function(StorageClass2) {
StorageClass2["DEEP_ARCHIVE"] = "DEEP_ARCHIVE";
StorageClass2["GLACIER"] = "GLACIER";
StorageClass2["GLACIER_IR"] = "GLACIER_IR";
StorageClass2["INTELLIGENT_TIERING"] = "INTELLIGENT_TIERING";
StorageClass2["ONEZONE_IA"] = "ONEZONE_IA";
StorageClass2["OUTPOSTS"] = "OUTPOSTS";
StorageClass2["REDUCED_REDUNDANCY"] = "REDUCED_REDUNDANCY";
StorageClass2["STANDARD"] = "STANDARD";
StorageClass2["STANDARD_IA"] = "STANDARD_IA";
})(StorageClass || (StorageClass = {}));
var TaggingDirective;
(function(TaggingDirective2) {
TaggingDirective2["COPY"] = "COPY";
TaggingDirective2["REPLACE"] = "REPLACE";
})(TaggingDirective || (TaggingDirective = {}));
class ObjectNotInActiveTierError extends S3ServiceException {
constructor(opts){
super({
name: "ObjectNotInActiveTierError",
$fault: "client",
...opts
});
this.name = "ObjectNotInActiveTierError";
this.$fault = "client";
Object.setPrototypeOf(this, ObjectNotInActiveTierError.prototype);
}
}
class BucketAlreadyExists extends S3ServiceException {
constructor(opts){
super({
name: "BucketAlreadyExists",
$fault: "client",
...opts
});
this.name = "BucketAlreadyExists";
this.$fault = "client";
Object.setPrototypeOf(this, BucketAlreadyExists.prototype);
}
}
class BucketAlreadyOwnedByYou extends S3ServiceException {
constructor(opts){
super({
name: "BucketAlreadyOwnedByYou",
$fault: "client",
...opts
});
this.name = "BucketAlreadyOwnedByYou";
this.$fault = "client";
Object.setPrototypeOf(this, BucketAlreadyOwnedByYou.prototype);
}
}
var BucketCannedACL;
(function(BucketCannedACL2) {
BucketCannedACL2["authenticated_read"] = "authenticated-read";
BucketCannedACL2["private"] = "private";
BucketCannedACL2["public_read"] = "public-read";
BucketCannedACL2["public_read_write"] = "public-read-write";
})(BucketCannedACL || (BucketCannedACL = {}));
var BucketLocationConstraint;
(function(BucketLocationConstraint2) {
BucketLocationConstraint2["EU"] = "EU";
BucketLocationConstraint2["af_south_1"] = "af-south-1";
BucketLocationConstraint2["ap_east_1"] = "ap-east-1";
BucketLocationConstraint2["ap_northeast_1"] = "ap-northeast-1";
BucketLocationConstraint2["ap_northeast_2"] = "ap-northeast-2";
BucketLocationConstraint2["ap_northeast_3"] = "ap-northeast-3";
BucketLocationConstraint2["ap_south_1"] = "ap-south-1";
BucketLocationConstraint2["ap_southeast_1"] = "ap-southeast-1";
BucketLocationConstraint2["ap_southeast_2"] = "ap-southeast-2";
BucketLocationConstraint2["ap_southeast_3"] = "ap-southeast-3";
BucketLocationConstraint2["ca_central_1"] = "ca-central-1";
BucketLocationConstraint2["cn_north_1"] = "cn-north-1";
BucketLocationConstraint2["cn_northwest_1"] = "cn-northwest-1";
BucketLocationConstraint2["eu_central_1"] = "eu-central-1";
BucketLocationConstraint2["eu_north_1"] = "eu-north-1";
BucketLocationConstraint2["eu_south_1"] = "eu-south-1";
BucketLocationConstraint2["eu_west_1"] = "eu-west-1";
BucketLocationConstraint2["eu_west_2"] = "eu-west-2";
BucketLocationConstraint2["eu_west_3"] = "eu-west-3";
BucketLocationConstraint2["me_south_1"] = "me-south-1";
BucketLocationConstraint2["sa_east_1"] = "sa-east-1";
BucketLocationConstraint2["us_east_2"] = "us-east-2";
BucketLocationConstraint2["us_gov_east_1"] = "us-gov-east-1";
BucketLocationConstraint2["us_gov_west_1"] = "us-gov-west-1";
BucketLocationConstraint2["us_west_1"] = "us-west-1";
BucketLocationConstraint2["us_west_2"] = "us-west-2";
})(BucketLocationConstraint || (BucketLocationConstraint = {}));
var ObjectOwnership;
(function(ObjectOwnership2) {
ObjectOwnership2["BucketOwnerEnforced"] = "BucketOwnerEnforced";
ObjectOwnership2["BucketOwnerPreferred"] = "BucketOwnerPreferred";
ObjectOwnership2["ObjectWriter"] = "ObjectWriter";
})(ObjectOwnership || (ObjectOwnership = {}));
var AnalyticsFilter;
(function(AnalyticsFilter2) {
AnalyticsFilter2.visit = (value, visitor)=>{
if (value.Prefix !== void 0) return visitor.Prefix(value.Prefix);
if (value.Tag !== void 0) return visitor.Tag(value.Tag);
if (value.And !== void 0) return visitor.And(value.And);
return visitor._(value.$unknown[0], value.$unknown[1]);
};
})(AnalyticsFilter || (AnalyticsFilter = {}));
var AnalyticsS3ExportFileFormat;
(function(AnalyticsS3ExportFileFormat2) {
AnalyticsS3ExportFileFormat2["CSV"] = "CSV";
})(AnalyticsS3ExportFileFormat || (AnalyticsS3ExportFileFormat = {}));
var StorageClassAnalysisSchemaVersion;
(function(StorageClassAnalysisSchemaVersion2) {
StorageClassAnalysisSchemaVersion2["V_1"] = "V_1";
})(StorageClassAnalysisSchemaVersion || (StorageClassAnalysisSchemaVersion = {}));
var IntelligentTieringStatus;
(function(IntelligentTieringStatus2) {
IntelligentTieringStatus2["Disabled"] = "Disabled";
IntelligentTieringStatus2["Enabled"] = "Enabled";
})(IntelligentTieringStatus || (IntelligentTieringStatus = {}));
var IntelligentTieringAccessTier;
(function(IntelligentTieringAccessTier2) {
IntelligentTieringAccessTier2["ARCHIVE_ACCESS"] = "ARCHIVE_ACCESS";
IntelligentTieringAccessTier2["DEEP_ARCHIVE_ACCESS"] = "DEEP_ARCHIVE_ACCESS";
})(IntelligentTieringAccessTier || (IntelligentTieringAccessTier = {}));
var InventoryFormat;
(function(InventoryFormat2) {
InventoryFormat2["CSV"] = "CSV";
InventoryFormat2["ORC"] = "ORC";
InventoryFormat2["Parquet"] = "Parquet";
})(InventoryFormat || (InventoryFormat = {}));
var InventoryIncludedObjectVersions;
(function(InventoryIncludedObjectVersions2) {
InventoryIncludedObjectVersions2["All"] = "All";
InventoryIncludedObjectVersions2["Current"] = "Current";
})(InventoryIncludedObjectVersions || (InventoryIncludedObjectVersions = {}));
var InventoryOptionalField;
(function(InventoryOptionalField2) {
InventoryOptionalField2["BucketKeyStatus"] = "BucketKeyStatus";
InventoryOptionalField2["ChecksumAlgorithm"] = "ChecksumAlgorithm";
InventoryOptionalField2["ETag"] = "ETag";
InventoryOptionalField2["EncryptionStatus"] = "EncryptionStatus";
InventoryOptionalField2["IntelligentTieringAccessTier"] = "IntelligentTieringAccessTier";
InventoryOptionalField2["IsMultipartUploaded"] = "IsMultipartUploaded";
InventoryOptionalField2["LastModifiedDate"] = "LastModifiedDate";
InventoryOptionalField2["ObjectLockLegalHoldStatus"] = "ObjectLockLegalHoldStatus";
InventoryOptionalField2["ObjectLockMode"] = "ObjectLockMode";
InventoryOptionalField2["ObjectLockRetainUntilDate"] = "ObjectLockRetainUntilDate";
InventoryOptionalField2["ReplicationStatus"] = "ReplicationStatus";
InventoryOptionalField2["Size"] = "Size";
InventoryOptionalField2["StorageClass"] = "StorageClass";
})(InventoryOptionalField || (InventoryOptionalField = {}));
var InventoryFrequency;
(function(InventoryFrequency2) {
InventoryFrequency2["Daily"] = "Daily";
InventoryFrequency2["Weekly"] = "Weekly";
})(InventoryFrequency || (InventoryFrequency = {}));
var LifecycleRuleFilter;
(function(LifecycleRuleFilter2) {
LifecycleRuleFilter2.visit = (value, visitor)=>{
if (value.Prefix !== void 0) return visitor.Prefix(value.Prefix);
if (value.Tag !== void 0) return visitor.Tag(value.Tag);
if (value.ObjectSizeGreaterThan !== void 0) return visitor.ObjectSizeGreaterThan(value.ObjectSizeGreaterThan);
if (value.ObjectSizeLessThan !== void 0) return visitor.ObjectSizeLessThan(value.ObjectSizeLessThan);
if (value.And !== void 0) return visitor.And(value.And);
return visitor._(value.$unknown[0], value.$unknown[1]);
};
})(LifecycleRuleFilter || (LifecycleRuleFilter = {}));
var TransitionStorageClass;
(function(TransitionStorageClass2) {
TransitionStorageClass2["DEEP_ARCHIVE"] = "DEEP_ARCHIVE";
TransitionStorageClass2["GLACIER"] = "GLACIER";
TransitionStorageClass2["GLACIER_IR"] = "GLACIER_IR";
TransitionStorageClass2["INTELLIGENT_TIERING"] = "INTELLIGENT_TIERING";
TransitionStorageClass2["ONEZONE_IA"] = "ONEZONE_IA";
TransitionStorageClass2["STANDARD_IA"] = "STANDARD_IA";
})(TransitionStorageClass || (TransitionStorageClass = {}));
var ExpirationStatus;
(function(ExpirationStatus2) {
ExpirationStatus2["Disabled"] = "Disabled";
ExpirationStatus2["Enabled"] = "Enabled";
})(ExpirationStatus || (ExpirationStatus = {}));
var BucketLogsPermission;
(function(BucketLogsPermission2) {
BucketLogsPermission2["FULL_CONTROL"] = "FULL_CONTROL";
BucketLogsPermission2["READ"] = "READ";
BucketLogsPermission2["WRITE"] = "WRITE";
})(BucketLogsPermission || (BucketLogsPermission = {}));
var MetricsFilter;
(function(MetricsFilter2) {
MetricsFilter2.visit = (value, visitor)=>{
if (value.Prefix !== void 0) return visitor.Prefix(value.Prefix);
if (value.Tag !== void 0) return visitor.Tag(value.Tag);
if (value.AccessPointArn !== void 0) return visitor.AccessPointArn(value.AccessPointArn);
if (value.And !== void 0) return visitor.And(value.And);
return visitor._(value.$unknown[0], value.$unknown[1]);
};
})(MetricsFilter || (MetricsFilter = {}));
var FilterRuleName;
(function(FilterRuleName2) {
FilterRuleName2["prefix"] = "prefix";
FilterRuleName2["suffix"] = "suffix";
})(FilterRuleName || (FilterRuleName = {}));
var DeleteMarkerReplicationStatus;
(function(DeleteMarkerReplicationStatus2) {
DeleteMarkerReplicationStatus2["Disabled"] = "Disabled";
DeleteMarkerReplicationStatus2["Enabled"] = "Enabled";
})(DeleteMarkerReplicationStatus || (DeleteMarkerReplicationStatus = {}));
var MetricsStatus;
(function(MetricsStatus2) {
MetricsStatus2["Disabled"] = "Disabled";
MetricsStatus2["Enabled"] = "Enabled";
})(MetricsStatus || (MetricsStatus = {}));
var ReplicationTimeStatus;
(function(ReplicationTimeStatus2) {
ReplicationTimeStatus2["Disabled"] = "Disabled";
ReplicationTimeStatus2["Enabled"] = "Enabled";
})(ReplicationTimeStatus || (ReplicationTimeStatus = {}));
var ExistingObjectReplicationStatus;
(function(ExistingObjectReplicationStatus2) {
ExistingObjectReplicationStatus2["Disabled"] = "Disabled";
ExistingObjectReplicationStatus2["Enabled"] = "Enabled";
})(ExistingObjectReplicationStatus || (ExistingObjectReplicationStatus = {}));
var ReplicationRuleFilter;
(function(ReplicationRuleFilter2) {
ReplicationRuleFilter2.visit = (value, visitor)=>{
if (value.Prefix !== void 0) return visitor.Prefix(value.Prefix);
if (value.Tag !== void 0) return visitor.Tag(value.Tag);
if (value.And !== void 0) return visitor.And(value.And);
return visitor._(value.$unknown[0], value.$unknown[1]);
};
})(ReplicationRuleFilter || (ReplicationRuleFilter = {}));
var ReplicaModificationsStatus;
(function(ReplicaModificationsStatus2) {
ReplicaModificationsStatus2["Disabled"] = "Disabled";
ReplicaModificationsStatus2["Enabled"] = "Enabled";
})(ReplicaModificationsStatus || (ReplicaModificationsStatus = {}));
var SseKmsEncryptedObjectsStatus;
(function(SseKmsEncryptedObjectsStatus2) {
SseKmsEncryptedObjectsStatus2["Disabled"] = "Disabled";
SseKmsEncryptedObjectsStatus2["Enabled"] = "Enabled";
})(SseKmsEncryptedObjectsStatus || (SseKmsEncryptedObjectsStatus = {}));
var ReplicationRuleStatus;
(function(ReplicationRuleStatus2) {
ReplicationRuleStatus2["Disabled"] = "Disabled";
ReplicationRuleStatus2["Enabled"] = "Enabled";
})(ReplicationRuleStatus || (ReplicationRuleStatus = {}));
var Payer;
(function(Payer2) {
Payer2["BucketOwner"] = "BucketOwner";
Payer2["Requester"] = "Requester";
})(Payer || (Payer = {}));
var MFADeleteStatus;
(function(MFADeleteStatus2) {
MFADeleteStatus2["Disabled"] = "Disabled";
MFADeleteStatus2["Enabled"] = "Enabled";
})(MFADeleteStatus || (MFADeleteStatus = {}));
var BucketVersioningStatus;
(function(BucketVersioningStatus2) {
BucketVersioningStatus2["Enabled"] = "Enabled";
BucketVersioningStatus2["Suspended"] = "Suspended";
})(BucketVersioningStatus || (BucketVersioningStatus = {}));
var Protocol;
(function(Protocol2) {
Protocol2["http"] = "http";
Protocol2["https"] = "https";
})(Protocol || (Protocol = {}));
var ReplicationStatus;
(function(ReplicationStatus2) {
ReplicationStatus2["COMPLETE"] = "COMPLETE";
ReplicationStatus2["FAILED"] = "FAILED";
ReplicationStatus2["PENDING"] = "PENDING";
ReplicationStatus2["REPLICA"] = "REPLICA";
})(ReplicationStatus || (ReplicationStatus = {}));
var ChecksumMode;
(function(ChecksumMode2) {
ChecksumMode2["ENABLED"] = "ENABLED";
})(ChecksumMode || (ChecksumMode = {}));
class InvalidObjectState extends S3ServiceException {
constructor(opts){
super({
name: "InvalidObjectState",
$fault: "client",
...opts
});
this.name = "InvalidObjectState";
this.$fault = "client";
Object.setPrototypeOf(this, InvalidObjectState.prototype);
this.StorageClass = opts.StorageClass;
this.AccessTier = opts.AccessTier;
}
}
class NoSuchKey extends S3ServiceException {
constructor(opts){
super({
name: "NoSuchKey",
$fault: "client",
...opts
});
this.name = "NoSuchKey";
this.$fault = "client";
Object.setPrototypeOf(this, NoSuchKey.prototype);
}
}
var ObjectAttributes;
(function(ObjectAttributes2) {
ObjectAttributes2["CHECKSUM"] = "Checksum";
ObjectAttributes2["ETAG"] = "ETag";
ObjectAttributes2["OBJECT_PARTS"] = "ObjectParts";
ObjectAttributes2["OBJECT_SIZE"] = "ObjectSize";
ObjectAttributes2["STORAGE_CLASS"] = "StorageClass";
})(ObjectAttributes || (ObjectAttributes = {}));
var ObjectLockEnabled;
(function(ObjectLockEnabled2) {
ObjectLockEnabled2["Enabled"] = "Enabled";
})(ObjectLockEnabled || (ObjectLockEnabled = {}));
var ObjectLockRetentionMode;
(function(ObjectLockRetentionMode2) {
ObjectLockRetentionMode2["COMPLIANCE"] = "COMPLIANCE";
ObjectLockRetentionMode2["GOVERNANCE"] = "GOVERNANCE";
})(ObjectLockRetentionMode || (ObjectLockRetentionMode = {}));
class NotFound extends S3ServiceException {
constructor(opts){
super({
name: "NotFound",
$fault: "client",
...opts
});
this.name = "NotFound";
this.$fault = "client";
Object.setPrototypeOf(this, NotFound.prototype);
}
}
var ArchiveStatus;
(function(ArchiveStatus2) {
ArchiveStatus2["ARCHIVE_ACCESS"] = "ARCHIVE_ACCESS";
ArchiveStatus2["DEEP_ARCHIVE_ACCESS"] = "DEEP_ARCHIVE_ACCESS";
})(ArchiveStatus || (ArchiveStatus = {}));
var EncodingType;
(function(EncodingType2) {
EncodingType2["url"] = "url";
})(EncodingType || (EncodingType = {}));
var ObjectStorageClass;
(function(ObjectStorageClass2) {
ObjectStorageClass2["DEEP_ARCHIVE"] = "DEEP_ARCHIVE";
ObjectStorageClass2["GLACIER"] = "GLACIER";
ObjectStorageClass2["GLACIER_IR"] = "GLACIER_IR";
ObjectStorageClass2["INTELLIGENT_TIERING"] = "INTELLIGENT_TIERING";
ObjectStorageClass2["ONEZONE_IA"] = "ONEZONE_IA";
ObjectStorageClass2["OUTPOSTS"] = "OUTPOSTS";
ObjectStorageClass2["REDUCED_REDUNDANCY"] = "REDUCED_REDUNDANCY";
ObjectStorageClass2["STANDARD"] = "STANDARD";
ObjectStorageClass2["STANDARD_IA"] = "STANDARD_IA";
})(ObjectStorageClass || (ObjectStorageClass = {}));
class NoSuchBucket extends S3ServiceException {
constructor(opts){
super({
name: "NoSuchBucket",
$fault: "client",
...opts
});
this.name = "NoSuchBucket";
this.$fault = "client";
Object.setPrototypeOf(this, NoSuchBucket.prototype);
}
}
var ObjectVersionStorageClass;
(function(ObjectVersionStorageClass2) {
ObjectVersionStorageClass2["STANDARD"] = "STANDARD";
})(ObjectVersionStorageClass || (ObjectVersionStorageClass = {}));
var MFADelete;
(function(MFADelete2) {
MFADelete2["Disabled"] = "Disabled";
MFADelete2["Enabled"] = "Enabled";
})(MFADelete || (MFADelete = {}));
const AbortIncompleteMultipartUploadFilterSensitiveLog = (obj)=>({
...obj
});
const AbortMultipartUploadOutputFilterSensitiveLog = (obj)=>({
...obj
});
const AbortMultipartUploadRequestFilterSensitiveLog = (obj)=>({
...obj
});
const AccelerateConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const GranteeFilterSensitiveLog = (obj)=>({
...obj
});
const GrantFilterSensitiveLog = (obj)=>({
...obj
});
const OwnerFilterSensitiveLog = (obj)=>({
...obj
});
const AccessControlPolicyFilterSensitiveLog = (obj)=>({
...obj
});
const AccessControlTranslationFilterSensitiveLog = (obj)=>({
...obj
});
const CompleteMultipartUploadOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const CompletedPartFilterSensitiveLog = (obj)=>({
...obj
});
const CompletedMultipartUploadFilterSensitiveLog = (obj)=>({
...obj
});
const CompleteMultipartUploadRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const CopyObjectResultFilterSensitiveLog = (obj)=>({
...obj
});
const CopyObjectOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
}
});
const CopyObjectRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
},
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
},
...obj.CopySourceSSECustomerKey && {
CopySourceSSECustomerKey: SENSITIVE_STRING
}
});
const CreateBucketOutputFilterSensitiveLog = (obj)=>({
...obj
});
const CreateBucketConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const CreateBucketRequestFilterSensitiveLog = (obj)=>({
...obj
});
const CreateMultipartUploadOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
}
});
const CreateMultipartUploadRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
},
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
}
});
const DeleteBucketRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketAnalyticsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketCorsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketEncryptionRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketIntelligentTieringConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketInventoryConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketLifecycleRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketMetricsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketOwnershipControlsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketPolicyRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketReplicationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteBucketWebsiteRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectOutputFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeletedObjectFilterSensitiveLog = (obj)=>({
...obj
});
const _ErrorFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectIdentifierFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectTaggingOutputFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteObjectTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeletePublicAccessBlockRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketAccelerateConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketAccelerateConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketAclOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketAclRequestFilterSensitiveLog = (obj)=>({
...obj
});
const TagFilterSensitiveLog = (obj)=>({
...obj
});
const AnalyticsAndOperatorFilterSensitiveLog = (obj)=>({
...obj
});
const AnalyticsFilterFilterSensitiveLog = (obj)=>{
if (obj.Prefix !== void 0) return {
Prefix: obj.Prefix
};
if (obj.Tag !== void 0) return {
Tag: TagFilterSensitiveLog(obj.Tag)
};
if (obj.And !== void 0) return {
And: AnalyticsAndOperatorFilterSensitiveLog(obj.And)
};
if (obj.$unknown !== void 0) return {
[obj.$unknown[0]]: "UNKNOWN"
};
};
const AnalyticsS3BucketDestinationFilterSensitiveLog = (obj)=>({
...obj
});
const AnalyticsExportDestinationFilterSensitiveLog = (obj)=>({
...obj
});
const StorageClassAnalysisDataExportFilterSensitiveLog = (obj)=>({
...obj
});
const StorageClassAnalysisFilterSensitiveLog = (obj)=>({
...obj
});
const AnalyticsConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Filter && {
Filter: AnalyticsFilterFilterSensitiveLog(obj.Filter)
}
});
const GetBucketAnalyticsConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.AnalyticsConfiguration && {
AnalyticsConfiguration: AnalyticsConfigurationFilterSensitiveLog(obj.AnalyticsConfiguration)
}
});
const GetBucketAnalyticsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const CORSRuleFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketCorsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketCorsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ServerSideEncryptionByDefaultFilterSensitiveLog = (obj)=>({
...obj,
...obj.KMSMasterKeyID && {
KMSMasterKeyID: SENSITIVE_STRING
}
});
const ServerSideEncryptionRuleFilterSensitiveLog = (obj)=>({
...obj,
...obj.ApplyServerSideEncryptionByDefault && {
ApplyServerSideEncryptionByDefault: ServerSideEncryptionByDefaultFilterSensitiveLog(obj.ApplyServerSideEncryptionByDefault)
}
});
const ServerSideEncryptionConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Rules && {
Rules: obj.Rules.map((item)=>ServerSideEncryptionRuleFilterSensitiveLog(item))
}
});
const GetBucketEncryptionOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.ServerSideEncryptionConfiguration && {
ServerSideEncryptionConfiguration: ServerSideEncryptionConfigurationFilterSensitiveLog(obj.ServerSideEncryptionConfiguration)
}
});
const GetBucketEncryptionRequestFilterSensitiveLog = (obj)=>({
...obj
});
const IntelligentTieringAndOperatorFilterSensitiveLog = (obj)=>({
...obj
});
const IntelligentTieringFilterFilterSensitiveLog = (obj)=>({
...obj
});
const TieringFilterSensitiveLog = (obj)=>({
...obj
});
const IntelligentTieringConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketIntelligentTieringConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketIntelligentTieringConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const SSEKMSFilterSensitiveLog = (obj)=>({
...obj,
...obj.KeyId && {
KeyId: SENSITIVE_STRING
}
});
const SSES3FilterSensitiveLog = (obj)=>({
...obj
});
const InventoryEncryptionFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMS && {
SSEKMS: SSEKMSFilterSensitiveLog(obj.SSEKMS)
}
});
const InventoryS3BucketDestinationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Encryption && {
Encryption: InventoryEncryptionFilterSensitiveLog(obj.Encryption)
}
});
const InventoryDestinationFilterSensitiveLog = (obj)=>({
...obj,
...obj.S3BucketDestination && {
S3BucketDestination: InventoryS3BucketDestinationFilterSensitiveLog(obj.S3BucketDestination)
}
});
const InventoryFilterFilterSensitiveLog = (obj)=>({
...obj
});
const InventoryScheduleFilterSensitiveLog = (obj)=>({
...obj
});
const InventoryConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Destination && {
Destination: InventoryDestinationFilterSensitiveLog(obj.Destination)
}
});
const GetBucketInventoryConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.InventoryConfiguration && {
InventoryConfiguration: InventoryConfigurationFilterSensitiveLog(obj.InventoryConfiguration)
}
});
const GetBucketInventoryConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const LifecycleExpirationFilterSensitiveLog = (obj)=>({
...obj
});
const LifecycleRuleAndOperatorFilterSensitiveLog = (obj)=>({
...obj
});
const LifecycleRuleFilterFilterSensitiveLog = (obj)=>{
if (obj.Prefix !== void 0) return {
Prefix: obj.Prefix
};
if (obj.Tag !== void 0) return {
Tag: TagFilterSensitiveLog(obj.Tag)
};
if (obj.ObjectSizeGreaterThan !== void 0) return {
ObjectSizeGreaterThan: obj.ObjectSizeGreaterThan
};
if (obj.ObjectSizeLessThan !== void 0) return {
ObjectSizeLessThan: obj.ObjectSizeLessThan
};
if (obj.And !== void 0) return {
And: LifecycleRuleAndOperatorFilterSensitiveLog(obj.And)
};
if (obj.$unknown !== void 0) return {
[obj.$unknown[0]]: "UNKNOWN"
};
};
const NoncurrentVersionExpirationFilterSensitiveLog = (obj)=>({
...obj
});
const NoncurrentVersionTransitionFilterSensitiveLog = (obj)=>({
...obj
});
const TransitionFilterSensitiveLog = (obj)=>({
...obj
});
const LifecycleRuleFilterSensitiveLog = (obj)=>({
...obj,
...obj.Filter && {
Filter: LifecycleRuleFilterFilterSensitiveLog(obj.Filter)
}
});
const GetBucketLifecycleConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.Rules && {
Rules: obj.Rules.map((item)=>LifecycleRuleFilterSensitiveLog(item))
}
});
const GetBucketLifecycleConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketLocationOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketLocationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const TargetGrantFilterSensitiveLog = (obj)=>({
...obj
});
const LoggingEnabledFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketLoggingOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketLoggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const MetricsAndOperatorFilterSensitiveLog = (obj)=>({
...obj
});
const MetricsFilterFilterSensitiveLog = (obj)=>{
if (obj.Prefix !== void 0) return {
Prefix: obj.Prefix
};
if (obj.Tag !== void 0) return {
Tag: TagFilterSensitiveLog(obj.Tag)
};
if (obj.AccessPointArn !== void 0) return {
AccessPointArn: obj.AccessPointArn
};
if (obj.And !== void 0) return {
And: MetricsAndOperatorFilterSensitiveLog(obj.And)
};
if (obj.$unknown !== void 0) return {
[obj.$unknown[0]]: "UNKNOWN"
};
};
const MetricsConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Filter && {
Filter: MetricsFilterFilterSensitiveLog(obj.Filter)
}
});
const GetBucketMetricsConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.MetricsConfiguration && {
MetricsConfiguration: MetricsConfigurationFilterSensitiveLog(obj.MetricsConfiguration)
}
});
const GetBucketMetricsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketNotificationConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const EventBridgeConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const FilterRuleFilterSensitiveLog = (obj)=>({
...obj
});
const S3KeyFilterFilterSensitiveLog = (obj)=>({
...obj
});
const NotificationConfigurationFilterFilterSensitiveLog = (obj)=>({
...obj
});
const LambdaFunctionConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const QueueConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const TopicConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const NotificationConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const OwnershipControlsRuleFilterSensitiveLog = (obj)=>({
...obj
});
const OwnershipControlsFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketOwnershipControlsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketOwnershipControlsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketPolicyOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketPolicyRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PolicyStatusFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketPolicyStatusOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketPolicyStatusRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteMarkerReplicationFilterSensitiveLog = (obj)=>({
...obj
});
const EncryptionConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const ReplicationTimeValueFilterSensitiveLog = (obj)=>({
...obj
});
const MetricsFilterSensitiveLog = (obj)=>({
...obj
});
const ReplicationTimeFilterSensitiveLog = (obj)=>({
...obj
});
const DestinationFilterSensitiveLog = (obj)=>({
...obj
});
const ExistingObjectReplicationFilterSensitiveLog = (obj)=>({
...obj
});
const ReplicationRuleAndOperatorFilterSensitiveLog = (obj)=>({
...obj
});
const ReplicationRuleFilterFilterSensitiveLog = (obj)=>{
if (obj.Prefix !== void 0) return {
Prefix: obj.Prefix
};
if (obj.Tag !== void 0) return {
Tag: TagFilterSensitiveLog(obj.Tag)
};
if (obj.And !== void 0) return {
And: ReplicationRuleAndOperatorFilterSensitiveLog(obj.And)
};
if (obj.$unknown !== void 0) return {
[obj.$unknown[0]]: "UNKNOWN"
};
};
const ReplicaModificationsFilterSensitiveLog = (obj)=>({
...obj
});
const SseKmsEncryptedObjectsFilterSensitiveLog = (obj)=>({
...obj
});
const SourceSelectionCriteriaFilterSensitiveLog = (obj)=>({
...obj
});
const ReplicationRuleFilterSensitiveLog = (obj)=>({
...obj,
...obj.Filter && {
Filter: ReplicationRuleFilterFilterSensitiveLog(obj.Filter)
}
});
const ReplicationConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Rules && {
Rules: obj.Rules.map((item)=>ReplicationRuleFilterSensitiveLog(item))
}
});
const GetBucketReplicationOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.ReplicationConfiguration && {
ReplicationConfiguration: ReplicationConfigurationFilterSensitiveLog(obj.ReplicationConfiguration)
}
});
const GetBucketReplicationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketRequestPaymentOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketRequestPaymentRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketTaggingOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketVersioningOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketVersioningRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ErrorDocumentFilterSensitiveLog = (obj)=>({
...obj
});
const IndexDocumentFilterSensitiveLog = (obj)=>({
...obj
});
const RedirectAllRequestsToFilterSensitiveLog = (obj)=>({
...obj
});
const ConditionFilterSensitiveLog = (obj)=>({
...obj
});
const RedirectFilterSensitiveLog = (obj)=>({
...obj
});
const RoutingRuleFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketWebsiteOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetBucketWebsiteRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const GetObjectRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const GetObjectAclOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectAclRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ChecksumFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectPartFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectAttributesPartsFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectAttributesOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectAttributesRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const ObjectLockLegalHoldFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectLegalHoldOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectLegalHoldRequestFilterSensitiveLog = (obj)=>({
...obj
});
const DefaultRetentionFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectLockRuleFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectLockConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectLockConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectLockConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectLockRetentionFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectRetentionOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectRetentionRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectTaggingOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectTorrentOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetObjectTorrentRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PublicAccessBlockConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const GetPublicAccessBlockOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GetPublicAccessBlockRequestFilterSensitiveLog = (obj)=>({
...obj
});
const HeadBucketRequestFilterSensitiveLog = (obj)=>({
...obj
});
const HeadObjectOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const HeadObjectRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const ListBucketAnalyticsConfigurationsOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.AnalyticsConfigurationList && {
AnalyticsConfigurationList: obj.AnalyticsConfigurationList.map((item)=>AnalyticsConfigurationFilterSensitiveLog(item))
}
});
const ListBucketAnalyticsConfigurationsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ListBucketIntelligentTieringConfigurationsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListBucketIntelligentTieringConfigurationsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ListBucketInventoryConfigurationsOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.InventoryConfigurationList && {
InventoryConfigurationList: obj.InventoryConfigurationList.map((item)=>InventoryConfigurationFilterSensitiveLog(item))
}
});
const ListBucketInventoryConfigurationsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ListBucketMetricsConfigurationsOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.MetricsConfigurationList && {
MetricsConfigurationList: obj.MetricsConfigurationList.map((item)=>MetricsConfigurationFilterSensitiveLog(item))
}
});
const ListBucketMetricsConfigurationsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const BucketFilterSensitiveLog = (obj)=>({
...obj
});
const ListBucketsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const CommonPrefixFilterSensitiveLog = (obj)=>({
...obj
});
const InitiatorFilterSensitiveLog = (obj)=>({
...obj
});
const MultipartUploadFilterSensitiveLog = (obj)=>({
...obj
});
const ListMultipartUploadsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListMultipartUploadsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const _ObjectFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectsV2OutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectsV2RequestFilterSensitiveLog = (obj)=>({
...obj
});
const DeleteMarkerEntryFilterSensitiveLog = (obj)=>({
...obj
});
const ObjectVersionFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectVersionsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListObjectVersionsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PartFilterSensitiveLog = (obj)=>({
...obj
});
const ListPartsOutputFilterSensitiveLog = (obj)=>({
...obj
});
const ListPartsRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const PutBucketAccelerateConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketAclRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketAnalyticsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.AnalyticsConfiguration && {
AnalyticsConfiguration: AnalyticsConfigurationFilterSensitiveLog(obj.AnalyticsConfiguration)
}
});
const CORSConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketCorsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketEncryptionRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.ServerSideEncryptionConfiguration && {
ServerSideEncryptionConfiguration: ServerSideEncryptionConfigurationFilterSensitiveLog(obj.ServerSideEncryptionConfiguration)
}
});
const PutBucketIntelligentTieringConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketInventoryConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.InventoryConfiguration && {
InventoryConfiguration: InventoryConfigurationFilterSensitiveLog(obj.InventoryConfiguration)
}
});
const BucketLifecycleConfigurationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Rules && {
Rules: obj.Rules.map((item)=>LifecycleRuleFilterSensitiveLog(item))
}
});
const PutBucketLifecycleConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.LifecycleConfiguration && {
LifecycleConfiguration: BucketLifecycleConfigurationFilterSensitiveLog(obj.LifecycleConfiguration)
}
});
const BucketLoggingStatusFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketLoggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketMetricsConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.MetricsConfiguration && {
MetricsConfiguration: MetricsConfigurationFilterSensitiveLog(obj.MetricsConfiguration)
}
});
const PutBucketNotificationConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketOwnershipControlsRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketPolicyRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketReplicationRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.ReplicationConfiguration && {
ReplicationConfiguration: ReplicationConfigurationFilterSensitiveLog(obj.ReplicationConfiguration)
}
});
const RequestPaymentConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketRequestPaymentRequestFilterSensitiveLog = (obj)=>({
...obj
});
const TaggingFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const VersioningConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketVersioningRequestFilterSensitiveLog = (obj)=>({
...obj
});
const WebsiteConfigurationFilterSensitiveLog = (obj)=>({
...obj
});
const PutBucketWebsiteRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
}
});
const PutObjectRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
},
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
},
...obj.SSEKMSEncryptionContext && {
SSEKMSEncryptionContext: SENSITIVE_STRING
}
});
const PutObjectAclOutputFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectAclRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectLegalHoldOutputFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectLegalHoldRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectLockConfigurationOutputFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectLockConfigurationRequestFilterSensitiveLog = (obj)=>({
...obj
});
class ObjectAlreadyInActiveTierError extends S3ServiceException {
constructor(opts){
super({
name: "ObjectAlreadyInActiveTierError",
$fault: "client",
...opts
});
this.name = "ObjectAlreadyInActiveTierError";
this.$fault = "client";
Object.setPrototypeOf(this, ObjectAlreadyInActiveTierError.prototype);
}
}
var Tier;
(function(Tier2) {
Tier2["Bulk"] = "Bulk";
Tier2["Expedited"] = "Expedited";
Tier2["Standard"] = "Standard";
})(Tier || (Tier = {}));
var ExpressionType;
(function(ExpressionType2) {
ExpressionType2["SQL"] = "SQL";
})(ExpressionType || (ExpressionType = {}));
var CompressionType;
(function(CompressionType2) {
CompressionType2["BZIP2"] = "BZIP2";
CompressionType2["GZIP"] = "GZIP";
CompressionType2["NONE"] = "NONE";
})(CompressionType || (CompressionType = {}));
var FileHeaderInfo;
(function(FileHeaderInfo2) {
FileHeaderInfo2["IGNORE"] = "IGNORE";
FileHeaderInfo2["NONE"] = "NONE";
FileHeaderInfo2["USE"] = "USE";
})(FileHeaderInfo || (FileHeaderInfo = {}));
var JSONType;
(function(JSONType2) {
JSONType2["DOCUMENT"] = "DOCUMENT";
JSONType2["LINES"] = "LINES";
})(JSONType || (JSONType = {}));
var QuoteFields;
(function(QuoteFields2) {
QuoteFields2["ALWAYS"] = "ALWAYS";
QuoteFields2["ASNEEDED"] = "ASNEEDED";
})(QuoteFields || (QuoteFields = {}));
var RestoreRequestType;
(function(RestoreRequestType2) {
RestoreRequestType2["SELECT"] = "SELECT";
})(RestoreRequestType || (RestoreRequestType = {}));
var SelectObjectContentEventStream;
(function(SelectObjectContentEventStream2) {
SelectObjectContentEventStream2.visit = (value, visitor)=>{
if (value.Records !== void 0) return visitor.Records(value.Records);
if (value.Stats !== void 0) return visitor.Stats(value.Stats);
if (value.Progress !== void 0) return visitor.Progress(value.Progress);
if (value.Cont !== void 0) return visitor.Cont(value.Cont);
if (value.End !== void 0) return visitor.End(value.End);
return visitor._(value.$unknown[0], value.$unknown[1]);
};
})(SelectObjectContentEventStream || (SelectObjectContentEventStream = {}));
const PutObjectRetentionOutputFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectRetentionRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectTaggingOutputFilterSensitiveLog = (obj)=>({
...obj
});
const PutObjectTaggingRequestFilterSensitiveLog = (obj)=>({
...obj
});
const PutPublicAccessBlockRequestFilterSensitiveLog = (obj)=>({
...obj
});
const RestoreObjectOutputFilterSensitiveLog = (obj)=>({
...obj
});
const GlacierJobParametersFilterSensitiveLog = (obj)=>({
...obj
});
const EncryptionFilterSensitiveLog = (obj)=>({
...obj,
...obj.KMSKeyId && {
KMSKeyId: SENSITIVE_STRING
}
});
const MetadataEntryFilterSensitiveLog = (obj)=>({
...obj
});
const S3LocationFilterSensitiveLog = (obj)=>({
...obj,
...obj.Encryption && {
Encryption: EncryptionFilterSensitiveLog(obj.Encryption)
}
});
const OutputLocationFilterSensitiveLog = (obj)=>({
...obj,
...obj.S3 && {
S3: S3LocationFilterSensitiveLog(obj.S3)
}
});
const CSVInputFilterSensitiveLog = (obj)=>({
...obj
});
const JSONInputFilterSensitiveLog = (obj)=>({
...obj
});
const ParquetInputFilterSensitiveLog = (obj)=>({
...obj
});
const InputSerializationFilterSensitiveLog = (obj)=>({
...obj
});
const CSVOutputFilterSensitiveLog = (obj)=>({
...obj
});
const JSONOutputFilterSensitiveLog = (obj)=>({
...obj
});
const OutputSerializationFilterSensitiveLog = (obj)=>({
...obj
});
const SelectParametersFilterSensitiveLog = (obj)=>({
...obj
});
const RestoreRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.OutputLocation && {
OutputLocation: OutputLocationFilterSensitiveLog(obj.OutputLocation)
}
});
const RestoreObjectRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.RestoreRequest && {
RestoreRequest: RestoreRequestFilterSensitiveLog(obj.RestoreRequest)
}
});
const ContinuationEventFilterSensitiveLog = (obj)=>({
...obj
});
const EndEventFilterSensitiveLog = (obj)=>({
...obj
});
const ProgressFilterSensitiveLog = (obj)=>({
...obj
});
const ProgressEventFilterSensitiveLog = (obj)=>({
...obj
});
const RecordsEventFilterSensitiveLog = (obj)=>({
...obj
});
const StatsFilterSensitiveLog = (obj)=>({
...obj
});
const StatsEventFilterSensitiveLog = (obj)=>({
...obj
});
const SelectObjectContentEventStreamFilterSensitiveLog = (obj)=>{
if (obj.Records !== void 0) return {
Records: RecordsEventFilterSensitiveLog(obj.Records)
};
if (obj.Stats !== void 0) return {
Stats: StatsEventFilterSensitiveLog(obj.Stats)
};
if (obj.Progress !== void 0) return {
Progress: ProgressEventFilterSensitiveLog(obj.Progress)
};
if (obj.Cont !== void 0) return {
Cont: ContinuationEventFilterSensitiveLog(obj.Cont)
};
if (obj.End !== void 0) return {
End: EndEventFilterSensitiveLog(obj.End)
};
if (obj.$unknown !== void 0) return {
[obj.$unknown[0]]: "UNKNOWN"
};
};
const SelectObjectContentOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.Payload && {
Payload: "STREAMING_CONTENT"
}
});
const RequestProgressFilterSensitiveLog = (obj)=>({
...obj
});
const ScanRangeFilterSensitiveLog = (obj)=>({
...obj
});
const SelectObjectContentRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const UploadPartOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const UploadPartRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
}
});
const CopyPartResultFilterSensitiveLog = (obj)=>({
...obj
});
const UploadPartCopyOutputFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const UploadPartCopyRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSECustomerKey && {
SSECustomerKey: SENSITIVE_STRING
},
...obj.CopySourceSSECustomerKey && {
CopySourceSSECustomerKey: SENSITIVE_STRING
}
});
const WriteGetObjectResponseRequestFilterSensitiveLog = (obj)=>({
...obj,
...obj.SSEKMSKeyId && {
SSEKMSKeyId: SENSITIVE_STRING
}
});
const serializeAws_restXmlAbortMultipartUploadCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"AbortMultipartUpload"
],
uploadId: [
,
input.UploadId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlCompleteMultipartUploadCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-checksum-crc32": input.ChecksumCRC32,
"x-amz-checksum-crc32c": input.ChecksumCRC32C,
"x-amz-checksum-sha1": input.ChecksumSHA1,
"x-amz-checksum-sha256": input.ChecksumSHA256,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"CompleteMultipartUpload"
],
uploadId: [
,
input.UploadId
]
});
let body;
if (input.MultipartUpload !== void 0) {
body = serializeAws_restXmlCompletedMultipartUpload(input.MultipartUpload);
}
let contents;
if (input.MultipartUpload !== void 0) {
contents = serializeAws_restXmlCompletedMultipartUpload(input.MultipartUpload);
contents = contents.withName("CompleteMultipartUpload");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlCopyObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-acl": input.ACL,
"cache-control": input.CacheControl,
"x-amz-checksum-algorithm": input.ChecksumAlgorithm,
"content-disposition": input.ContentDisposition,
"content-encoding": input.ContentEncoding,
"content-language": input.ContentLanguage,
"content-type": input.ContentType,
"x-amz-copy-source": input.CopySource,
"x-amz-copy-source-if-match": input.CopySourceIfMatch,
"x-amz-copy-source-if-modified-since": [
()=>isSerializableHeaderValue(input.CopySourceIfModifiedSince),
()=>dateToUtcString(input.CopySourceIfModifiedSince).toString()
],
"x-amz-copy-source-if-none-match": input.CopySourceIfNoneMatch,
"x-amz-copy-source-if-unmodified-since": [
()=>isSerializableHeaderValue(input.CopySourceIfUnmodifiedSince),
()=>dateToUtcString(input.CopySourceIfUnmodifiedSince).toString()
],
expires: [
()=>isSerializableHeaderValue(input.Expires),
()=>dateToUtcString(input.Expires).toString()
],
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-metadata-directive": input.MetadataDirective,
"x-amz-tagging-directive": input.TaggingDirective,
"x-amz-server-side-encryption": input.ServerSideEncryption,
"x-amz-storage-class": input.StorageClass,
"x-amz-website-redirect-location": input.WebsiteRedirectLocation,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId,
"x-amz-server-side-encryption-context": input.SSEKMSEncryptionContext,
"x-amz-server-side-encryption-bucket-key-enabled": [
()=>isSerializableHeaderValue(input.BucketKeyEnabled),
()=>input.BucketKeyEnabled.toString()
],
"x-amz-copy-source-server-side-encryption-customer-algorithm": input.CopySourceSSECustomerAlgorithm,
"x-amz-copy-source-server-side-encryption-customer-key": input.CopySourceSSECustomerKey,
"x-amz-copy-source-server-side-encryption-customer-key-md5": input.CopySourceSSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-tagging": input.Tagging,
"x-amz-object-lock-mode": input.ObjectLockMode,
"x-amz-object-lock-retain-until-date": [
()=>isSerializableHeaderValue(input.ObjectLockRetainUntilDate),
()=>(input.ObjectLockRetainUntilDate.toISOString().split(".")[0] + "Z").toString()
],
"x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-source-expected-bucket-owner": input.ExpectedSourceBucketOwner,
...input.Metadata !== void 0 && Object.keys(input.Metadata).reduce((acc, suffix)=>({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata[suffix]
}), {})
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"CopyObject"
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlCreateBucketCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-acl": input.ACL,
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write": input.GrantWrite,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-bucket-object-lock-enabled": [
()=>isSerializableHeaderValue(input.ObjectLockEnabledForBucket),
()=>input.ObjectLockEnabledForBucket.toString()
],
"x-amz-object-ownership": input.ObjectOwnership
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
let body;
if (input.CreateBucketConfiguration !== void 0) {
body = serializeAws_restXmlCreateBucketConfiguration(input.CreateBucketConfiguration);
}
let contents;
if (input.CreateBucketConfiguration !== void 0) {
contents = serializeAws_restXmlCreateBucketConfiguration(input.CreateBucketConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
body
});
};
const serializeAws_restXmlCreateMultipartUploadCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-acl": input.ACL,
"cache-control": input.CacheControl,
"content-disposition": input.ContentDisposition,
"content-encoding": input.ContentEncoding,
"content-language": input.ContentLanguage,
"content-type": input.ContentType,
expires: [
()=>isSerializableHeaderValue(input.Expires),
()=>dateToUtcString(input.Expires).toString()
],
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-server-side-encryption": input.ServerSideEncryption,
"x-amz-storage-class": input.StorageClass,
"x-amz-website-redirect-location": input.WebsiteRedirectLocation,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId,
"x-amz-server-side-encryption-context": input.SSEKMSEncryptionContext,
"x-amz-server-side-encryption-bucket-key-enabled": [
()=>isSerializableHeaderValue(input.BucketKeyEnabled),
()=>input.BucketKeyEnabled.toString()
],
"x-amz-request-payer": input.RequestPayer,
"x-amz-tagging": input.Tagging,
"x-amz-object-lock-mode": input.ObjectLockMode,
"x-amz-object-lock-retain-until-date": [
()=>isSerializableHeaderValue(input.ObjectLockRetainUntilDate),
()=>(input.ObjectLockRetainUntilDate.toISOString().split(".")[0] + "Z").toString()
],
"x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-checksum-algorithm": input.ChecksumAlgorithm,
...input.Metadata !== void 0 && Object.keys(input.Metadata).reduce((acc, suffix)=>({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata[suffix]
}), {})
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
uploads: [
,
""
],
"x-id": [
,
"CreateMultipartUpload"
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
body
});
};
const serializeAws_restXmlDeleteBucketAnalyticsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
analytics: [
,
""
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketCorsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
cors: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketEncryptionCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
encryption: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = {};
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"intelligent-tiering": [
,
""
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketInventoryConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
inventory: [
,
""
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketLifecycleCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
lifecycle: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketMetricsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
metrics: [
,
""
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketOwnershipControlsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
ownershipControls: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketPolicyCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
policy: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketReplicationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
replication: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
tagging: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteBucketWebsiteCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
website: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-mfa": input.MFA,
"x-amz-request-payer": input.RequestPayer,
"x-amz-bypass-governance-retention": [
()=>isSerializableHeaderValue(input.BypassGovernanceRetention),
()=>input.BypassGovernanceRetention.toString()
],
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"DeleteObject"
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteObjectsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-mfa": input.MFA,
"x-amz-request-payer": input.RequestPayer,
"x-amz-bypass-governance-retention": [
()=>isSerializableHeaderValue(input.BypassGovernanceRetention),
()=>input.BypassGovernanceRetention.toString()
],
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
delete: [
,
""
],
"x-id": [
,
"DeleteObjects"
]
});
let body;
if (input.Delete !== void 0) {
body = serializeAws_restXmlDelete(input.Delete);
}
let contents;
if (input.Delete !== void 0) {
contents = serializeAws_restXmlDelete(input.Delete);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeleteObjectTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
tagging: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlDeletePublicAccessBlockCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
publicAccessBlock: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketAccelerateConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
accelerate: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketAclCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
acl: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketAnalyticsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
analytics: [
,
""
],
"x-id": [
,
"GetBucketAnalyticsConfiguration"
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketCorsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
cors: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketEncryptionCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
encryption: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketIntelligentTieringConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = {};
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"intelligent-tiering": [
,
""
],
"x-id": [
,
"GetBucketIntelligentTieringConfiguration"
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketInventoryConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
inventory: [
,
""
],
"x-id": [
,
"GetBucketInventoryConfiguration"
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketLifecycleConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
lifecycle: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketLocationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
location: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketLoggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
logging: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketMetricsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
metrics: [
,
""
],
"x-id": [
,
"GetBucketMetricsConfiguration"
],
id: [
,
input.Id
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketNotificationConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
notification: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketOwnershipControlsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
ownershipControls: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketPolicyCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
policy: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketPolicyStatusCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
policyStatus: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketReplicationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
replication: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketRequestPaymentCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
requestPayment: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
tagging: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketVersioningCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
versioning: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetBucketWebsiteCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
website: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"if-match": input.IfMatch,
"if-modified-since": [
()=>isSerializableHeaderValue(input.IfModifiedSince),
()=>dateToUtcString(input.IfModifiedSince).toString()
],
"if-none-match": input.IfNoneMatch,
"if-unmodified-since": [
()=>isSerializableHeaderValue(input.IfUnmodifiedSince),
()=>dateToUtcString(input.IfUnmodifiedSince).toString()
],
range: input.Range,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-checksum-mode": input.ChecksumMode
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"GetObject"
],
"response-cache-control": [
,
input.ResponseCacheControl
],
"response-content-disposition": [
,
input.ResponseContentDisposition
],
"response-content-encoding": [
,
input.ResponseContentEncoding
],
"response-content-language": [
,
input.ResponseContentLanguage
],
"response-content-type": [
,
input.ResponseContentType
],
"response-expires": [
()=>input.ResponseExpires !== void 0,
()=>dateToUtcString(input.ResponseExpires).toString()
],
versionId: [
,
input.VersionId
],
partNumber: [
()=>input.PartNumber !== void 0,
()=>input.PartNumber.toString()
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectAclCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
acl: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectAttributesCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-max-parts": [
()=>isSerializableHeaderValue(input.MaxParts),
()=>input.MaxParts.toString()
],
"x-amz-part-number-marker": input.PartNumberMarker,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-object-attributes": [
()=>isSerializableHeaderValue(input.ObjectAttributes),
()=>(input.ObjectAttributes || []).map((_entry)=>_entry).join(", ")
]
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
attributes: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectLegalHoldCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"legal-hold": [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectLockConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"object-lock": [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectRetentionCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
retention: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-request-payer": input.RequestPayer
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
tagging: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetObjectTorrentCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
torrent: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlGetPublicAccessBlockCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
publicAccessBlock: [
,
""
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlHeadBucketCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "HEAD",
headers,
path: resolvedPath$1,
body
});
};
const serializeAws_restXmlHeadObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"if-match": input.IfMatch,
"if-modified-since": [
()=>isSerializableHeaderValue(input.IfModifiedSince),
()=>dateToUtcString(input.IfModifiedSince).toString()
],
"if-none-match": input.IfNoneMatch,
"if-unmodified-since": [
()=>isSerializableHeaderValue(input.IfUnmodifiedSince),
()=>dateToUtcString(input.IfUnmodifiedSince).toString()
],
range: input.Range,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-checksum-mode": input.ChecksumMode
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
versionId: [
,
input.VersionId
],
partNumber: [
()=>input.PartNumber !== void 0,
()=>input.PartNumber.toString()
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "HEAD",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListBucketAnalyticsConfigurationsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
analytics: [
,
""
],
"x-id": [
,
"ListBucketAnalyticsConfigurations"
],
"continuation-token": [
,
input.ContinuationToken
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListBucketIntelligentTieringConfigurationsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = {};
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"intelligent-tiering": [
,
""
],
"x-id": [
,
"ListBucketIntelligentTieringConfigurations"
],
"continuation-token": [
,
input.ContinuationToken
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListBucketInventoryConfigurationsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
inventory: [
,
""
],
"x-id": [
,
"ListBucketInventoryConfigurations"
],
"continuation-token": [
,
input.ContinuationToken
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListBucketMetricsConfigurationsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
metrics: [
,
""
],
"x-id": [
,
"ListBucketMetricsConfigurations"
],
"continuation-token": [
,
input.ContinuationToken
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListBucketsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = {
"content-type": "application/xml"
};
const resolvedPath2 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
let body;
body = "";
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath2,
body
});
};
const serializeAws_restXmlListMultipartUploadsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
uploads: [
,
""
],
delimiter: [
,
input.Delimiter
],
"encoding-type": [
,
input.EncodingType
],
"key-marker": [
,
input.KeyMarker
],
"max-uploads": [
()=>input.MaxUploads !== void 0,
()=>input.MaxUploads.toString()
],
prefix: [
,
input.Prefix
],
"upload-id-marker": [
,
input.UploadIdMarker
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListObjectsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
delimiter: [
,
input.Delimiter
],
"encoding-type": [
,
input.EncodingType
],
marker: [
,
input.Marker
],
"max-keys": [
()=>input.MaxKeys !== void 0,
()=>input.MaxKeys.toString()
],
prefix: [
,
input.Prefix
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListObjectsV2Command = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"list-type": [
,
"2"
],
delimiter: [
,
input.Delimiter
],
"encoding-type": [
,
input.EncodingType
],
"max-keys": [
()=>input.MaxKeys !== void 0,
()=>input.MaxKeys.toString()
],
prefix: [
,
input.Prefix
],
"continuation-token": [
,
input.ContinuationToken
],
"fetch-owner": [
()=>input.FetchOwner !== void 0,
()=>input.FetchOwner.toString()
],
"start-after": [
,
input.StartAfter
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListObjectVersionsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
versions: [
,
""
],
delimiter: [
,
input.Delimiter
],
"encoding-type": [
,
input.EncodingType
],
"key-marker": [
,
input.KeyMarker
],
"max-keys": [
()=>input.MaxKeys !== void 0,
()=>input.MaxKeys.toString()
],
prefix: [
,
input.Prefix
],
"version-id-marker": [
,
input.VersionIdMarker
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlListPartsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"ListParts"
],
"max-parts": [
()=>input.MaxParts !== void 0,
()=>input.MaxParts.toString()
],
"part-number-marker": [
,
input.PartNumberMarker
],
uploadId: [
,
input.UploadId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "GET",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketAccelerateConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
accelerate: [
,
""
]
});
let body;
if (input.AccelerateConfiguration !== void 0) {
body = serializeAws_restXmlAccelerateConfiguration(input.AccelerateConfiguration);
}
let contents;
if (input.AccelerateConfiguration !== void 0) {
contents = serializeAws_restXmlAccelerateConfiguration(input.AccelerateConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketAclCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-acl": input.ACL,
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write": input.GrantWrite,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
acl: [
,
""
]
});
let body;
if (input.AccessControlPolicy !== void 0) {
body = serializeAws_restXmlAccessControlPolicy(input.AccessControlPolicy);
}
let contents;
if (input.AccessControlPolicy !== void 0) {
contents = serializeAws_restXmlAccessControlPolicy(input.AccessControlPolicy);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketAnalyticsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
analytics: [
,
""
],
id: [
,
input.Id
]
});
let body;
if (input.AnalyticsConfiguration !== void 0) {
body = serializeAws_restXmlAnalyticsConfiguration(input.AnalyticsConfiguration);
}
let contents;
if (input.AnalyticsConfiguration !== void 0) {
contents = serializeAws_restXmlAnalyticsConfiguration(input.AnalyticsConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketCorsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
cors: [
,
""
]
});
let body;
if (input.CORSConfiguration !== void 0) {
body = serializeAws_restXmlCORSConfiguration(input.CORSConfiguration);
}
let contents;
if (input.CORSConfiguration !== void 0) {
contents = serializeAws_restXmlCORSConfiguration(input.CORSConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketEncryptionCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
encryption: [
,
""
]
});
let body;
if (input.ServerSideEncryptionConfiguration !== void 0) {
body = serializeAws_restXmlServerSideEncryptionConfiguration(input.ServerSideEncryptionConfiguration);
}
let contents;
if (input.ServerSideEncryptionConfiguration !== void 0) {
contents = serializeAws_restXmlServerSideEncryptionConfiguration(input.ServerSideEncryptionConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketIntelligentTieringConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = {
"content-type": "application/xml"
};
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"intelligent-tiering": [
,
""
],
id: [
,
input.Id
]
});
let body;
if (input.IntelligentTieringConfiguration !== void 0) {
body = serializeAws_restXmlIntelligentTieringConfiguration(input.IntelligentTieringConfiguration);
}
let contents;
if (input.IntelligentTieringConfiguration !== void 0) {
contents = serializeAws_restXmlIntelligentTieringConfiguration(input.IntelligentTieringConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketInventoryConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
inventory: [
,
""
],
id: [
,
input.Id
]
});
let body;
if (input.InventoryConfiguration !== void 0) {
body = serializeAws_restXmlInventoryConfiguration(input.InventoryConfiguration);
}
let contents;
if (input.InventoryConfiguration !== void 0) {
contents = serializeAws_restXmlInventoryConfiguration(input.InventoryConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketLifecycleConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
lifecycle: [
,
""
]
});
let body;
if (input.LifecycleConfiguration !== void 0) {
body = serializeAws_restXmlBucketLifecycleConfiguration(input.LifecycleConfiguration);
}
let contents;
if (input.LifecycleConfiguration !== void 0) {
contents = serializeAws_restXmlBucketLifecycleConfiguration(input.LifecycleConfiguration);
contents = contents.withName("LifecycleConfiguration");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketLoggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
logging: [
,
""
]
});
let body;
if (input.BucketLoggingStatus !== void 0) {
body = serializeAws_restXmlBucketLoggingStatus(input.BucketLoggingStatus);
}
let contents;
if (input.BucketLoggingStatus !== void 0) {
contents = serializeAws_restXmlBucketLoggingStatus(input.BucketLoggingStatus);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketMetricsConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
metrics: [
,
""
],
id: [
,
input.Id
]
});
let body;
if (input.MetricsConfiguration !== void 0) {
body = serializeAws_restXmlMetricsConfiguration(input.MetricsConfiguration);
}
let contents;
if (input.MetricsConfiguration !== void 0) {
contents = serializeAws_restXmlMetricsConfiguration(input.MetricsConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketNotificationConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-skip-destination-validation": [
()=>isSerializableHeaderValue(input.SkipDestinationValidation),
()=>input.SkipDestinationValidation.toString()
]
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
notification: [
,
""
]
});
let body;
if (input.NotificationConfiguration !== void 0) {
body = serializeAws_restXmlNotificationConfiguration(input.NotificationConfiguration);
}
let contents;
if (input.NotificationConfiguration !== void 0) {
contents = serializeAws_restXmlNotificationConfiguration(input.NotificationConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketOwnershipControlsCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
ownershipControls: [
,
""
]
});
let body;
if (input.OwnershipControls !== void 0) {
body = serializeAws_restXmlOwnershipControls(input.OwnershipControls);
}
let contents;
if (input.OwnershipControls !== void 0) {
contents = serializeAws_restXmlOwnershipControls(input.OwnershipControls);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketPolicyCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "text/plain",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-confirm-remove-self-bucket-access": [
()=>isSerializableHeaderValue(input.ConfirmRemoveSelfBucketAccess),
()=>input.ConfirmRemoveSelfBucketAccess.toString()
],
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
policy: [
,
""
]
});
let body;
if (input.Policy !== void 0) {
body = input.Policy;
}
let contents;
if (input.Policy !== void 0) {
contents = input.Policy;
body = contents;
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketReplicationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-bucket-object-lock-token": input.Token,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
replication: [
,
""
]
});
let body;
if (input.ReplicationConfiguration !== void 0) {
body = serializeAws_restXmlReplicationConfiguration(input.ReplicationConfiguration);
}
let contents;
if (input.ReplicationConfiguration !== void 0) {
contents = serializeAws_restXmlReplicationConfiguration(input.ReplicationConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketRequestPaymentCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
requestPayment: [
,
""
]
});
let body;
if (input.RequestPaymentConfiguration !== void 0) {
body = serializeAws_restXmlRequestPaymentConfiguration(input.RequestPaymentConfiguration);
}
let contents;
if (input.RequestPaymentConfiguration !== void 0) {
contents = serializeAws_restXmlRequestPaymentConfiguration(input.RequestPaymentConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
tagging: [
,
""
]
});
let body;
if (input.Tagging !== void 0) {
body = serializeAws_restXmlTagging(input.Tagging);
}
let contents;
if (input.Tagging !== void 0) {
contents = serializeAws_restXmlTagging(input.Tagging);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketVersioningCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-mfa": input.MFA,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
versioning: [
,
""
]
});
let body;
if (input.VersioningConfiguration !== void 0) {
body = serializeAws_restXmlVersioningConfiguration(input.VersioningConfiguration);
}
let contents;
if (input.VersioningConfiguration !== void 0) {
contents = serializeAws_restXmlVersioningConfiguration(input.VersioningConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutBucketWebsiteCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
website: [
,
""
]
});
let body;
if (input.WebsiteConfiguration !== void 0) {
body = serializeAws_restXmlWebsiteConfiguration(input.WebsiteConfiguration);
}
let contents;
if (input.WebsiteConfiguration !== void 0) {
contents = serializeAws_restXmlWebsiteConfiguration(input.WebsiteConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": input.ContentType || "application/octet-stream",
"x-amz-acl": input.ACL,
"cache-control": input.CacheControl,
"content-disposition": input.ContentDisposition,
"content-encoding": input.ContentEncoding,
"content-language": input.ContentLanguage,
"content-length": [
()=>isSerializableHeaderValue(input.ContentLength),
()=>input.ContentLength.toString()
],
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-checksum-crc32": input.ChecksumCRC32,
"x-amz-checksum-crc32c": input.ChecksumCRC32C,
"x-amz-checksum-sha1": input.ChecksumSHA1,
"x-amz-checksum-sha256": input.ChecksumSHA256,
expires: [
()=>isSerializableHeaderValue(input.Expires),
()=>dateToUtcString(input.Expires).toString()
],
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-server-side-encryption": input.ServerSideEncryption,
"x-amz-storage-class": input.StorageClass,
"x-amz-website-redirect-location": input.WebsiteRedirectLocation,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId,
"x-amz-server-side-encryption-context": input.SSEKMSEncryptionContext,
"x-amz-server-side-encryption-bucket-key-enabled": [
()=>isSerializableHeaderValue(input.BucketKeyEnabled),
()=>input.BucketKeyEnabled.toString()
],
"x-amz-request-payer": input.RequestPayer,
"x-amz-tagging": input.Tagging,
"x-amz-object-lock-mode": input.ObjectLockMode,
"x-amz-object-lock-retain-until-date": [
()=>isSerializableHeaderValue(input.ObjectLockRetainUntilDate),
()=>(input.ObjectLockRetainUntilDate.toISOString().split(".")[0] + "Z").toString()
],
"x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
...input.Metadata !== void 0 && Object.keys(input.Metadata).reduce((acc, suffix)=>({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata[suffix]
}), {})
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"PutObject"
]
});
let body;
if (input.Body !== void 0) {
body = input.Body;
}
let contents;
if (input.Body !== void 0) {
contents = input.Body;
body = contents;
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectAclCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-acl": input.ACL,
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-grant-full-control": input.GrantFullControl,
"x-amz-grant-read": input.GrantRead,
"x-amz-grant-read-acp": input.GrantReadACP,
"x-amz-grant-write": input.GrantWrite,
"x-amz-grant-write-acp": input.GrantWriteACP,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
acl: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
if (input.AccessControlPolicy !== void 0) {
body = serializeAws_restXmlAccessControlPolicy(input.AccessControlPolicy);
}
let contents;
if (input.AccessControlPolicy !== void 0) {
contents = serializeAws_restXmlAccessControlPolicy(input.AccessControlPolicy);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectLegalHoldCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-request-payer": input.RequestPayer,
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"legal-hold": [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
if (input.LegalHold !== void 0) {
body = serializeAws_restXmlObjectLockLegalHold(input.LegalHold);
}
let contents;
if (input.LegalHold !== void 0) {
contents = serializeAws_restXmlObjectLockLegalHold(input.LegalHold);
contents = contents.withName("LegalHold");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectLockConfigurationCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-request-payer": input.RequestPayer,
"x-amz-bucket-object-lock-token": input.Token,
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
"object-lock": [
,
""
]
});
let body;
if (input.ObjectLockConfiguration !== void 0) {
body = serializeAws_restXmlObjectLockConfiguration(input.ObjectLockConfiguration);
}
let contents;
if (input.ObjectLockConfiguration !== void 0) {
contents = serializeAws_restXmlObjectLockConfiguration(input.ObjectLockConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectRetentionCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-request-payer": input.RequestPayer,
"x-amz-bypass-governance-retention": [
()=>isSerializableHeaderValue(input.BypassGovernanceRetention),
()=>input.BypassGovernanceRetention.toString()
],
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
retention: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
if (input.Retention !== void 0) {
body = serializeAws_restXmlObjectLockRetention(input.Retention);
}
let contents;
if (input.Retention !== void 0) {
contents = serializeAws_restXmlObjectLockRetention(input.Retention);
contents = contents.withName("Retention");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutObjectTaggingCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-request-payer": input.RequestPayer
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
tagging: [
,
""
],
versionId: [
,
input.VersionId
]
});
let body;
if (input.Tagging !== void 0) {
body = serializeAws_restXmlTagging(input.Tagging);
}
let contents;
if (input.Tagging !== void 0) {
contents = serializeAws_restXmlTagging(input.Tagging);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlPutPublicAccessBlockCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
const query = map1({
publicAccessBlock: [
,
""
]
});
let body;
if (input.PublicAccessBlockConfiguration !== void 0) {
body = serializeAws_restXmlPublicAccessBlockConfiguration(input.PublicAccessBlockConfiguration);
}
let contents;
if (input.PublicAccessBlockConfiguration !== void 0) {
contents = serializeAws_restXmlPublicAccessBlockConfiguration(input.PublicAccessBlockConfiguration);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlRestoreObjectCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-request-payer": input.RequestPayer,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
restore: [
,
""
],
"x-id": [
,
"RestoreObject"
],
versionId: [
,
input.VersionId
]
});
let body;
if (input.RestoreRequest !== void 0) {
body = serializeAws_restXmlRestoreRequest(input.RestoreRequest);
}
let contents;
if (input.RestoreRequest !== void 0) {
contents = serializeAws_restXmlRestoreRequest(input.RestoreRequest);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
return new HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlSelectObjectContentCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/xml",
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
select: [
,
""
],
"select-type": [
,
"2"
],
"x-id": [
,
"SelectObjectContent"
]
});
let body;
body = '<?xml version="1.0" encoding="UTF-8"?>';
const bodyNode = new XmlNode("SelectObjectContentRequest");
bodyNode.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
if (input.Expression !== void 0) {
const node = XmlNode.of("Expression", input.Expression).withName("Expression");
bodyNode.addChildNode(node);
}
if (input.ExpressionType !== void 0) {
const node1 = XmlNode.of("ExpressionType", input.ExpressionType).withName("ExpressionType");
bodyNode.addChildNode(node1);
}
if (input.InputSerialization !== void 0) {
const node2 = serializeAws_restXmlInputSerialization(input.InputSerialization).withName("InputSerialization");
bodyNode.addChildNode(node2);
}
if (input.OutputSerialization !== void 0) {
const node3 = serializeAws_restXmlOutputSerialization(input.OutputSerialization).withName("OutputSerialization");
bodyNode.addChildNode(node3);
}
if (input.RequestProgress !== void 0) {
const node4 = serializeAws_restXmlRequestProgress(input.RequestProgress).withName("RequestProgress");
bodyNode.addChildNode(node4);
}
if (input.ScanRange !== void 0) {
const node5 = serializeAws_restXmlScanRange(input.ScanRange).withName("ScanRange");
bodyNode.addChildNode(node5);
}
body += bodyNode.toString();
return new HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlUploadPartCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"content-type": "application/octet-stream",
"content-length": [
()=>isSerializableHeaderValue(input.ContentLength),
()=>input.ContentLength.toString()
],
"content-md5": input.ContentMD5,
"x-amz-sdk-checksum-algorithm": input.ChecksumAlgorithm,
"x-amz-checksum-crc32": input.ChecksumCRC32,
"x-amz-checksum-crc32c": input.ChecksumCRC32C,
"x-amz-checksum-sha1": input.ChecksumSHA1,
"x-amz-checksum-sha256": input.ChecksumSHA256,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"UploadPart"
],
partNumber: [
()=>input.PartNumber !== void 0,
()=>input.PartNumber.toString()
],
uploadId: [
,
input.UploadId
]
});
let body;
if (input.Body !== void 0) {
body = input.Body;
}
let contents;
if (input.Body !== void 0) {
contents = input.Body;
body = contents;
}
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlUploadPartCopyCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-copy-source": input.CopySource,
"x-amz-copy-source-if-match": input.CopySourceIfMatch,
"x-amz-copy-source-if-modified-since": [
()=>isSerializableHeaderValue(input.CopySourceIfModifiedSince),
()=>dateToUtcString(input.CopySourceIfModifiedSince).toString()
],
"x-amz-copy-source-if-none-match": input.CopySourceIfNoneMatch,
"x-amz-copy-source-if-unmodified-since": [
()=>isSerializableHeaderValue(input.CopySourceIfUnmodifiedSince),
()=>dateToUtcString(input.CopySourceIfUnmodifiedSince).toString()
],
"x-amz-copy-source-range": input.CopySourceRange,
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey,
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-copy-source-server-side-encryption-customer-algorithm": input.CopySourceSSECustomerAlgorithm,
"x-amz-copy-source-server-side-encryption-customer-key": input.CopySourceSSECustomerKey,
"x-amz-copy-source-server-side-encryption-customer-key-md5": input.CopySourceSSECustomerKeyMD5,
"x-amz-request-payer": input.RequestPayer,
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner,
"x-amz-source-expected-bucket-owner": input.ExpectedSourceBucketOwner
});
let resolvedPath$1 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/{Key+}`;
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Bucket", ()=>input.Bucket, "{Bucket}", false);
resolvedPath$1 = resolvedPath(resolvedPath$1, input, "Key", ()=>input.Key, "{Key+}", true);
const query = map1({
"x-id": [
,
"UploadPartCopy"
],
partNumber: [
()=>input.PartNumber !== void 0,
()=>input.PartNumber.toString()
],
uploadId: [
,
input.UploadId
]
});
let body;
return new HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath$1,
query,
body
});
};
const serializeAws_restXmlWriteGetObjectResponseCommand = async (input, context)=>{
const { hostname , protocol ="https" , port , path: basePath } = await context.endpoint();
const headers = map1({}, isSerializableHeaderValue, {
"x-amz-content-sha256": "UNSIGNED-PAYLOAD",
"content-type": "application/octet-stream",
"x-amz-request-route": input.RequestRoute,
"x-amz-request-token": input.RequestToken,
"x-amz-fwd-status": [
()=>isSerializableHeaderValue(input.StatusCode),
()=>input.StatusCode.toString()
],
"x-amz-fwd-error-code": input.ErrorCode,
"x-amz-fwd-error-message": input.ErrorMessage,
"x-amz-fwd-header-accept-ranges": input.AcceptRanges,
"x-amz-fwd-header-cache-control": input.CacheControl,
"x-amz-fwd-header-content-disposition": input.ContentDisposition,
"x-amz-fwd-header-content-encoding": input.ContentEncoding,
"x-amz-fwd-header-content-language": input.ContentLanguage,
"content-length": [
()=>isSerializableHeaderValue(input.ContentLength),
()=>input.ContentLength.toString()
],
"x-amz-fwd-header-content-range": input.ContentRange,
"x-amz-fwd-header-content-type": input.ContentType,
"x-amz-fwd-header-x-amz-checksum-crc32": input.ChecksumCRC32,
"x-amz-fwd-header-x-amz-checksum-crc32c": input.ChecksumCRC32C,
"x-amz-fwd-header-x-amz-checksum-sha1": input.ChecksumSHA1,
"x-amz-fwd-header-x-amz-checksum-sha256": input.ChecksumSHA256,
"x-amz-fwd-header-x-amz-delete-marker": [
()=>isSerializableHeaderValue(input.DeleteMarker),
()=>input.DeleteMarker.toString()
],
"x-amz-fwd-header-etag": input.ETag,
"x-amz-fwd-header-expires": [
()=>isSerializableHeaderValue(input.Expires),
()=>dateToUtcString(input.Expires).toString()
],
"x-amz-fwd-header-x-amz-expiration": input.Expiration,
"x-amz-fwd-header-last-modified": [
()=>isSerializableHeaderValue(input.LastModified),
()=>dateToUtcString(input.LastModified).toString()
],
"x-amz-fwd-header-x-amz-missing-meta": [
()=>isSerializableHeaderValue(input.MissingMeta),
()=>input.MissingMeta.toString()
],
"x-amz-fwd-header-x-amz-object-lock-mode": input.ObjectLockMode,
"x-amz-fwd-header-x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus,
"x-amz-fwd-header-x-amz-object-lock-retain-until-date": [
()=>isSerializableHeaderValue(input.ObjectLockRetainUntilDate),
()=>(input.ObjectLockRetainUntilDate.toISOString().split(".")[0] + "Z").toString()
],
"x-amz-fwd-header-x-amz-mp-parts-count": [
()=>isSerializableHeaderValue(input.PartsCount),
()=>input.PartsCount.toString()
],
"x-amz-fwd-header-x-amz-replication-status": input.ReplicationStatus,
"x-amz-fwd-header-x-amz-request-charged": input.RequestCharged,
"x-amz-fwd-header-x-amz-restore": input.Restore,
"x-amz-fwd-header-x-amz-server-side-encryption": input.ServerSideEncryption,
"x-amz-fwd-header-x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm,
"x-amz-fwd-header-x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId,
"x-amz-fwd-header-x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5,
"x-amz-fwd-header-x-amz-storage-class": input.StorageClass,
"x-amz-fwd-header-x-amz-tagging-count": [
()=>isSerializableHeaderValue(input.TagCount),
()=>input.TagCount.toString()
],
"x-amz-fwd-header-x-amz-version-id": input.VersionId,
"x-amz-fwd-header-x-amz-server-side-encryption-bucket-key-enabled": [
()=>isSerializableHeaderValue(input.BucketKeyEnabled),
()=>input.BucketKeyEnabled.toString()
],
...input.Metadata !== void 0 && Object.keys(input.Metadata).reduce((acc, suffix)=>({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata[suffix]
}), {})
});
const resolvedPath2 = `${(basePath == null ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/WriteGetObjectResponse`;
const query = map1({
"x-id": [
,
"WriteGetObjectResponse"
]
});
let body;
if (input.Body !== void 0) {
body = input.Body;
}
let contents;
if (input.Body !== void 0) {
contents = input.Body;
body = contents;
}
let { hostname: resolvedHostname } = await context.endpoint();
if (context.disableHostPrefix !== true) {
resolvedHostname = "{RequestRoute}." + resolvedHostname;
if (input.RequestRoute === void 0) {
throw new Error("Empty value provided for input host prefix: RequestRoute.");
}
resolvedHostname = resolvedHostname.replace("{RequestRoute}", input.RequestRoute);
if (!isValidHostname(resolvedHostname)) {
throw new Error("ValidationError: prefixed hostname must be hostname compatible.");
}
}
return new HttpRequest({
protocol,
hostname: resolvedHostname,
port,
method: "POST",
headers,
path: resolvedPath2,
query,
body
});
};
const deserializeAws_restXmlAbortMultipartUploadCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlAbortMultipartUploadCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlAbortMultipartUploadCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchUpload":
case "com.amazonaws.s3#NoSuchUpload":
throw await deserializeAws_restXmlNoSuchUploadResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlCompleteMultipartUploadCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlCompleteMultipartUploadCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
Expiration: [
,
output.headers["x-amz-expiration"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Bucket"] !== void 0) {
contents.Bucket = expectString(data["Bucket"]);
}
if (data["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(data["ChecksumCRC32"]);
}
if (data["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(data["ChecksumCRC32C"]);
}
if (data["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(data["ChecksumSHA1"]);
}
if (data["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(data["ChecksumSHA256"]);
}
if (data["ETag"] !== void 0) {
contents.ETag = expectString(data["ETag"]);
}
if (data["Key"] !== void 0) {
contents.Key = expectString(data["Key"]);
}
if (data["Location"] !== void 0) {
contents.Location = expectString(data["Location"]);
}
return contents;
};
const deserializeAws_restXmlCompleteMultipartUploadCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlCopyObjectCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlCopyObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
Expiration: [
,
output.headers["x-amz-expiration"]
],
CopySourceVersionId: [
,
output.headers["x-amz-copy-source-version-id"]
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
SSEKMSEncryptionContext: [
,
output.headers["x-amz-server-side-encryption-context"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectObject(await parseBody(output.body, context));
contents.CopyObjectResult = deserializeAws_restXmlCopyObjectResult(data);
return contents;
};
const deserializeAws_restXmlCopyObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "ObjectNotInActiveTierError":
case "com.amazonaws.s3#ObjectNotInActiveTierError":
throw await deserializeAws_restXmlObjectNotInActiveTierErrorResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlCreateBucketCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlCreateBucketCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
Location: [
,
output.headers["location"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlCreateBucketCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "BucketAlreadyExists":
case "com.amazonaws.s3#BucketAlreadyExists":
throw await deserializeAws_restXmlBucketAlreadyExistsResponse(parsedOutput);
case "BucketAlreadyOwnedByYou":
case "com.amazonaws.s3#BucketAlreadyOwnedByYou":
throw await deserializeAws_restXmlBucketAlreadyOwnedByYouResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlCreateMultipartUploadCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlCreateMultipartUploadCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
AbortDate: [
()=>output.headers["x-amz-abort-date"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["x-amz-abort-date"]))
],
AbortRuleId: [
,
output.headers["x-amz-abort-rule-id"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
SSEKMSEncryptionContext: [
,
output.headers["x-amz-server-side-encryption-context"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
],
ChecksumAlgorithm: [
,
output.headers["x-amz-checksum-algorithm"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Bucket"] !== void 0) {
contents.Bucket = expectString(data["Bucket"]);
}
if (data["Key"] !== void 0) {
contents.Key = expectString(data["Key"]);
}
if (data["UploadId"] !== void 0) {
contents.UploadId = expectString(data["UploadId"]);
}
return contents;
};
const deserializeAws_restXmlCreateMultipartUploadCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketAnalyticsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketAnalyticsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketAnalyticsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketCorsCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketCorsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketCorsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketEncryptionCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketEncryptionCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketEncryptionCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketInventoryConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketInventoryConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketInventoryConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketLifecycleCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketLifecycleCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketLifecycleCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketMetricsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketMetricsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketMetricsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketOwnershipControlsCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketOwnershipControlsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketOwnershipControlsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketPolicyCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketPolicyCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketPolicyCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketReplicationCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketReplicationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketReplicationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketTaggingCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteBucketWebsiteCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteBucketWebsiteCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteBucketWebsiteCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteObjectCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
DeleteMarker: [
()=>output.headers["x-amz-delete-marker"] !== void 0,
()=>parseBoolean(output.headers["x-amz-delete-marker"])
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteObjectsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteObjectsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.Deleted === "") {
contents.Deleted = [];
} else if (data["Deleted"] !== void 0) {
contents.Deleted = deserializeAws_restXmlDeletedObjects(getArrayIfSingleItem(data["Deleted"]));
}
if (data.Error === "") {
contents.Errors = [];
} else if (data["Error"] !== void 0) {
contents.Errors = deserializeAws_restXmlErrors(getArrayIfSingleItem(data["Error"]));
}
return contents;
};
const deserializeAws_restXmlDeleteObjectsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeleteObjectTaggingCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeleteObjectTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
VersionId: [
,
output.headers["x-amz-version-id"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeleteObjectTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlDeletePublicAccessBlockCommand = async (output, context)=>{
if (output.statusCode !== 204 && output.statusCode >= 300) {
return deserializeAws_restXmlDeletePublicAccessBlockCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlDeletePublicAccessBlockCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketAccelerateConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketAccelerateConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Status"] !== void 0) {
contents.Status = expectString(data["Status"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketAccelerateConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketAclCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketAclCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.AccessControlList === "") {
contents.Grants = [];
} else if (data["AccessControlList"] !== void 0 && data["AccessControlList"]["Grant"] !== void 0) {
contents.Grants = deserializeAws_restXmlGrants(getArrayIfSingleItem(data["AccessControlList"]["Grant"]));
}
if (data["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(data["Owner"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketAclCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketAnalyticsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketAnalyticsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.AnalyticsConfiguration = deserializeAws_restXmlAnalyticsConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketAnalyticsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketCorsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketCorsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.CORSRule === "") {
contents.CORSRules = [];
} else if (data["CORSRule"] !== void 0) {
contents.CORSRules = deserializeAws_restXmlCORSRules(getArrayIfSingleItem(data["CORSRule"]));
}
return contents;
};
const deserializeAws_restXmlGetBucketCorsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketEncryptionCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketEncryptionCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.ServerSideEncryptionConfiguration = deserializeAws_restXmlServerSideEncryptionConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketEncryptionCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketIntelligentTieringConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketIntelligentTieringConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.IntelligentTieringConfiguration = deserializeAws_restXmlIntelligentTieringConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketIntelligentTieringConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketInventoryConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketInventoryConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.InventoryConfiguration = deserializeAws_restXmlInventoryConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketInventoryConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketLifecycleConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketLifecycleConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.Rule === "") {
contents.Rules = [];
} else if (data["Rule"] !== void 0) {
contents.Rules = deserializeAws_restXmlLifecycleRules(getArrayIfSingleItem(data["Rule"]));
}
return contents;
};
const deserializeAws_restXmlGetBucketLifecycleConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketLocationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketLocationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["LocationConstraint"] !== void 0) {
contents.LocationConstraint = expectString(data["LocationConstraint"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketLocationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketLoggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketLoggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["LoggingEnabled"] !== void 0) {
contents.LoggingEnabled = deserializeAws_restXmlLoggingEnabled(data["LoggingEnabled"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketLoggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketMetricsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketMetricsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.MetricsConfiguration = deserializeAws_restXmlMetricsConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketMetricsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketNotificationConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketNotificationConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["EventBridgeConfiguration"] !== void 0) {
contents.EventBridgeConfiguration = deserializeAws_restXmlEventBridgeConfiguration(data["EventBridgeConfiguration"]);
}
if (data.CloudFunctionConfiguration === "") {
contents.LambdaFunctionConfigurations = [];
} else if (data["CloudFunctionConfiguration"] !== void 0) {
contents.LambdaFunctionConfigurations = deserializeAws_restXmlLambdaFunctionConfigurationList(getArrayIfSingleItem(data["CloudFunctionConfiguration"]));
}
if (data.QueueConfiguration === "") {
contents.QueueConfigurations = [];
} else if (data["QueueConfiguration"] !== void 0) {
contents.QueueConfigurations = deserializeAws_restXmlQueueConfigurationList(getArrayIfSingleItem(data["QueueConfiguration"]));
}
if (data.TopicConfiguration === "") {
contents.TopicConfigurations = [];
} else if (data["TopicConfiguration"] !== void 0) {
contents.TopicConfigurations = deserializeAws_restXmlTopicConfigurationList(getArrayIfSingleItem(data["TopicConfiguration"]));
}
return contents;
};
const deserializeAws_restXmlGetBucketNotificationConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketOwnershipControlsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketOwnershipControlsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.OwnershipControls = deserializeAws_restXmlOwnershipControls(data);
return contents;
};
const deserializeAws_restXmlGetBucketOwnershipControlsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketPolicyCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketPolicyCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = await collectBodyString1(output.body, context);
contents.Policy = expectString(data);
return contents;
};
const deserializeAws_restXmlGetBucketPolicyCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketPolicyStatusCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketPolicyStatusCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.PolicyStatus = deserializeAws_restXmlPolicyStatus(data);
return contents;
};
const deserializeAws_restXmlGetBucketPolicyStatusCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketReplicationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketReplicationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.ReplicationConfiguration = deserializeAws_restXmlReplicationConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetBucketReplicationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketRequestPaymentCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketRequestPaymentCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Payer"] !== void 0) {
contents.Payer = expectString(data["Payer"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketRequestPaymentCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketTaggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.TagSet === "") {
contents.TagSet = [];
} else if (data["TagSet"] !== void 0 && data["TagSet"]["Tag"] !== void 0) {
contents.TagSet = deserializeAws_restXmlTagSet(getArrayIfSingleItem(data["TagSet"]["Tag"]));
}
return contents;
};
const deserializeAws_restXmlGetBucketTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketVersioningCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketVersioningCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["MfaDelete"] !== void 0) {
contents.MFADelete = expectString(data["MfaDelete"]);
}
if (data["Status"] !== void 0) {
contents.Status = expectString(data["Status"]);
}
return contents;
};
const deserializeAws_restXmlGetBucketVersioningCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetBucketWebsiteCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetBucketWebsiteCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["ErrorDocument"] !== void 0) {
contents.ErrorDocument = deserializeAws_restXmlErrorDocument(data["ErrorDocument"]);
}
if (data["IndexDocument"] !== void 0) {
contents.IndexDocument = deserializeAws_restXmlIndexDocument(data["IndexDocument"]);
}
if (data["RedirectAllRequestsTo"] !== void 0) {
contents.RedirectAllRequestsTo = deserializeAws_restXmlRedirectAllRequestsTo(data["RedirectAllRequestsTo"]);
}
if (data.RoutingRules === "") {
contents.RoutingRules = [];
} else if (data["RoutingRules"] !== void 0 && data["RoutingRules"]["RoutingRule"] !== void 0) {
contents.RoutingRules = deserializeAws_restXmlRoutingRules(getArrayIfSingleItem(data["RoutingRules"]["RoutingRule"]));
}
return contents;
};
const deserializeAws_restXmlGetBucketWebsiteCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetObjectCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
DeleteMarker: [
()=>output.headers["x-amz-delete-marker"] !== void 0,
()=>parseBoolean(output.headers["x-amz-delete-marker"])
],
AcceptRanges: [
,
output.headers["accept-ranges"]
],
Expiration: [
,
output.headers["x-amz-expiration"]
],
Restore: [
,
output.headers["x-amz-restore"]
],
LastModified: [
()=>output.headers["last-modified"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["last-modified"]))
],
ContentLength: [
()=>output.headers["content-length"] !== void 0,
()=>strictParseLong(output.headers["content-length"])
],
ETag: [
,
output.headers["etag"]
],
ChecksumCRC32: [
,
output.headers["x-amz-checksum-crc32"]
],
ChecksumCRC32C: [
,
output.headers["x-amz-checksum-crc32c"]
],
ChecksumSHA1: [
,
output.headers["x-amz-checksum-sha1"]
],
ChecksumSHA256: [
,
output.headers["x-amz-checksum-sha256"]
],
MissingMeta: [
()=>output.headers["x-amz-missing-meta"] !== void 0,
()=>strictParseInt32(output.headers["x-amz-missing-meta"])
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
CacheControl: [
,
output.headers["cache-control"]
],
ContentDisposition: [
,
output.headers["content-disposition"]
],
ContentEncoding: [
,
output.headers["content-encoding"]
],
ContentLanguage: [
,
output.headers["content-language"]
],
ContentRange: [
,
output.headers["content-range"]
],
ContentType: [
,
output.headers["content-type"]
],
Expires: [
()=>output.headers["expires"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["expires"]))
],
WebsiteRedirectLocation: [
,
output.headers["x-amz-website-redirect-location"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
StorageClass: [
,
output.headers["x-amz-storage-class"]
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
],
ReplicationStatus: [
,
output.headers["x-amz-replication-status"]
],
PartsCount: [
()=>output.headers["x-amz-mp-parts-count"] !== void 0,
()=>strictParseInt32(output.headers["x-amz-mp-parts-count"])
],
TagCount: [
()=>output.headers["x-amz-tagging-count"] !== void 0,
()=>strictParseInt32(output.headers["x-amz-tagging-count"])
],
ObjectLockMode: [
,
output.headers["x-amz-object-lock-mode"]
],
ObjectLockRetainUntilDate: [
()=>output.headers["x-amz-object-lock-retain-until-date"] !== void 0,
()=>expectNonNull(parseRfc3339DateTime(output.headers["x-amz-object-lock-retain-until-date"]))
],
ObjectLockLegalHoldStatus: [
,
output.headers["x-amz-object-lock-legal-hold"]
],
Metadata: [
,
Object.keys(output.headers).filter((header)=>header.startsWith("x-amz-meta-")).reduce((acc, header)=>{
acc[header.substring(11)] = output.headers[header];
return acc;
}, {})
]
});
const data = output.body;
context.sdkStreamMixin(data);
contents.Body = data;
return contents;
};
const deserializeAws_restXmlGetObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "InvalidObjectState":
case "com.amazonaws.s3#InvalidObjectState":
throw await deserializeAws_restXmlInvalidObjectStateResponse(parsedOutput);
case "NoSuchKey":
case "com.amazonaws.s3#NoSuchKey":
throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlGetObjectAclCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectAclCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.AccessControlList === "") {
contents.Grants = [];
} else if (data["AccessControlList"] !== void 0 && data["AccessControlList"]["Grant"] !== void 0) {
contents.Grants = deserializeAws_restXmlGrants(getArrayIfSingleItem(data["AccessControlList"]["Grant"]));
}
if (data["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(data["Owner"]);
}
return contents;
};
const deserializeAws_restXmlGetObjectAclCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchKey":
case "com.amazonaws.s3#NoSuchKey":
throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlGetObjectAttributesCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectAttributesCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
DeleteMarker: [
()=>output.headers["x-amz-delete-marker"] !== void 0,
()=>parseBoolean(output.headers["x-amz-delete-marker"])
],
LastModified: [
()=>output.headers["last-modified"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["last-modified"]))
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Checksum"] !== void 0) {
contents.Checksum = deserializeAws_restXmlChecksum(data["Checksum"]);
}
if (data["ETag"] !== void 0) {
contents.ETag = expectString(data["ETag"]);
}
if (data["ObjectParts"] !== void 0) {
contents.ObjectParts = deserializeAws_restXmlGetObjectAttributesParts(data["ObjectParts"]);
}
if (data["ObjectSize"] !== void 0) {
contents.ObjectSize = strictParseLong(data["ObjectSize"]);
}
if (data["StorageClass"] !== void 0) {
contents.StorageClass = expectString(data["StorageClass"]);
}
return contents;
};
const deserializeAws_restXmlGetObjectAttributesCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchKey":
case "com.amazonaws.s3#NoSuchKey":
throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlGetObjectLegalHoldCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectLegalHoldCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.LegalHold = deserializeAws_restXmlObjectLockLegalHold(data);
return contents;
};
const deserializeAws_restXmlGetObjectLegalHoldCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetObjectLockConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectLockConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.ObjectLockConfiguration = deserializeAws_restXmlObjectLockConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetObjectLockConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetObjectRetentionCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectRetentionCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.Retention = deserializeAws_restXmlObjectLockRetention(data);
return contents;
};
const deserializeAws_restXmlGetObjectRetentionCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetObjectTaggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
VersionId: [
,
output.headers["x-amz-version-id"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.TagSet === "") {
contents.TagSet = [];
} else if (data["TagSet"] !== void 0 && data["TagSet"]["Tag"] !== void 0) {
contents.TagSet = deserializeAws_restXmlTagSet(getArrayIfSingleItem(data["TagSet"]["Tag"]));
}
return contents;
};
const deserializeAws_restXmlGetObjectTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetObjectTorrentCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetObjectTorrentCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = output.body;
context.sdkStreamMixin(data);
contents.Body = data;
return contents;
};
const deserializeAws_restXmlGetObjectTorrentCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlGetPublicAccessBlockCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlGetPublicAccessBlockCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectObject(await parseBody(output.body, context));
contents.PublicAccessBlockConfiguration = deserializeAws_restXmlPublicAccessBlockConfiguration(data);
return contents;
};
const deserializeAws_restXmlGetPublicAccessBlockCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlHeadBucketCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlHeadBucketCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlHeadBucketCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NotFound":
case "com.amazonaws.s3#NotFound":
throw await deserializeAws_restXmlNotFoundResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlHeadObjectCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlHeadObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
DeleteMarker: [
()=>output.headers["x-amz-delete-marker"] !== void 0,
()=>parseBoolean(output.headers["x-amz-delete-marker"])
],
AcceptRanges: [
,
output.headers["accept-ranges"]
],
Expiration: [
,
output.headers["x-amz-expiration"]
],
Restore: [
,
output.headers["x-amz-restore"]
],
ArchiveStatus: [
,
output.headers["x-amz-archive-status"]
],
LastModified: [
()=>output.headers["last-modified"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["last-modified"]))
],
ContentLength: [
()=>output.headers["content-length"] !== void 0,
()=>strictParseLong(output.headers["content-length"])
],
ChecksumCRC32: [
,
output.headers["x-amz-checksum-crc32"]
],
ChecksumCRC32C: [
,
output.headers["x-amz-checksum-crc32c"]
],
ChecksumSHA1: [
,
output.headers["x-amz-checksum-sha1"]
],
ChecksumSHA256: [
,
output.headers["x-amz-checksum-sha256"]
],
ETag: [
,
output.headers["etag"]
],
MissingMeta: [
()=>output.headers["x-amz-missing-meta"] !== void 0,
()=>strictParseInt32(output.headers["x-amz-missing-meta"])
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
CacheControl: [
,
output.headers["cache-control"]
],
ContentDisposition: [
,
output.headers["content-disposition"]
],
ContentEncoding: [
,
output.headers["content-encoding"]
],
ContentLanguage: [
,
output.headers["content-language"]
],
ContentType: [
,
output.headers["content-type"]
],
Expires: [
()=>output.headers["expires"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["expires"]))
],
WebsiteRedirectLocation: [
,
output.headers["x-amz-website-redirect-location"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
StorageClass: [
,
output.headers["x-amz-storage-class"]
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
],
ReplicationStatus: [
,
output.headers["x-amz-replication-status"]
],
PartsCount: [
()=>output.headers["x-amz-mp-parts-count"] !== void 0,
()=>strictParseInt32(output.headers["x-amz-mp-parts-count"])
],
ObjectLockMode: [
,
output.headers["x-amz-object-lock-mode"]
],
ObjectLockRetainUntilDate: [
()=>output.headers["x-amz-object-lock-retain-until-date"] !== void 0,
()=>expectNonNull(parseRfc3339DateTime(output.headers["x-amz-object-lock-retain-until-date"]))
],
ObjectLockLegalHoldStatus: [
,
output.headers["x-amz-object-lock-legal-hold"]
],
Metadata: [
,
Object.keys(output.headers).filter((header)=>header.startsWith("x-amz-meta-")).reduce((acc, header)=>{
acc[header.substring(11)] = output.headers[header];
return acc;
}, {})
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlHeadObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NotFound":
case "com.amazonaws.s3#NotFound":
throw await deserializeAws_restXmlNotFoundResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlListBucketAnalyticsConfigurationsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListBucketAnalyticsConfigurationsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.AnalyticsConfiguration === "") {
contents.AnalyticsConfigurationList = [];
} else if (data["AnalyticsConfiguration"] !== void 0) {
contents.AnalyticsConfigurationList = deserializeAws_restXmlAnalyticsConfigurationList(getArrayIfSingleItem(data["AnalyticsConfiguration"]));
}
if (data["ContinuationToken"] !== void 0) {
contents.ContinuationToken = expectString(data["ContinuationToken"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["NextContinuationToken"] !== void 0) {
contents.NextContinuationToken = expectString(data["NextContinuationToken"]);
}
return contents;
};
const deserializeAws_restXmlListBucketAnalyticsConfigurationsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListBucketIntelligentTieringConfigurationsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListBucketIntelligentTieringConfigurationsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["ContinuationToken"] !== void 0) {
contents.ContinuationToken = expectString(data["ContinuationToken"]);
}
if (data.IntelligentTieringConfiguration === "") {
contents.IntelligentTieringConfigurationList = [];
} else if (data["IntelligentTieringConfiguration"] !== void 0) {
contents.IntelligentTieringConfigurationList = deserializeAws_restXmlIntelligentTieringConfigurationList(getArrayIfSingleItem(data["IntelligentTieringConfiguration"]));
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["NextContinuationToken"] !== void 0) {
contents.NextContinuationToken = expectString(data["NextContinuationToken"]);
}
return contents;
};
const deserializeAws_restXmlListBucketIntelligentTieringConfigurationsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListBucketInventoryConfigurationsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListBucketInventoryConfigurationsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["ContinuationToken"] !== void 0) {
contents.ContinuationToken = expectString(data["ContinuationToken"]);
}
if (data.InventoryConfiguration === "") {
contents.InventoryConfigurationList = [];
} else if (data["InventoryConfiguration"] !== void 0) {
contents.InventoryConfigurationList = deserializeAws_restXmlInventoryConfigurationList(getArrayIfSingleItem(data["InventoryConfiguration"]));
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["NextContinuationToken"] !== void 0) {
contents.NextContinuationToken = expectString(data["NextContinuationToken"]);
}
return contents;
};
const deserializeAws_restXmlListBucketInventoryConfigurationsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListBucketMetricsConfigurationsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListBucketMetricsConfigurationsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["ContinuationToken"] !== void 0) {
contents.ContinuationToken = expectString(data["ContinuationToken"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data.MetricsConfiguration === "") {
contents.MetricsConfigurationList = [];
} else if (data["MetricsConfiguration"] !== void 0) {
contents.MetricsConfigurationList = deserializeAws_restXmlMetricsConfigurationList(getArrayIfSingleItem(data["MetricsConfiguration"]));
}
if (data["NextContinuationToken"] !== void 0) {
contents.NextContinuationToken = expectString(data["NextContinuationToken"]);
}
return contents;
};
const deserializeAws_restXmlListBucketMetricsConfigurationsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListBucketsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListBucketsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.Buckets === "") {
contents.Buckets = [];
} else if (data["Buckets"] !== void 0 && data["Buckets"]["Bucket"] !== void 0) {
contents.Buckets = deserializeAws_restXmlBuckets(getArrayIfSingleItem(data["Buckets"]["Bucket"]));
}
if (data["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(data["Owner"]);
}
return contents;
};
const deserializeAws_restXmlListBucketsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListMultipartUploadsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListMultipartUploadsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Bucket"] !== void 0) {
contents.Bucket = expectString(data["Bucket"]);
}
if (data.CommonPrefixes === "") {
contents.CommonPrefixes = [];
} else if (data["CommonPrefixes"] !== void 0) {
contents.CommonPrefixes = deserializeAws_restXmlCommonPrefixList(getArrayIfSingleItem(data["CommonPrefixes"]));
}
if (data["Delimiter"] !== void 0) {
contents.Delimiter = expectString(data["Delimiter"]);
}
if (data["EncodingType"] !== void 0) {
contents.EncodingType = expectString(data["EncodingType"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["KeyMarker"] !== void 0) {
contents.KeyMarker = expectString(data["KeyMarker"]);
}
if (data["MaxUploads"] !== void 0) {
contents.MaxUploads = strictParseInt32(data["MaxUploads"]);
}
if (data["NextKeyMarker"] !== void 0) {
contents.NextKeyMarker = expectString(data["NextKeyMarker"]);
}
if (data["NextUploadIdMarker"] !== void 0) {
contents.NextUploadIdMarker = expectString(data["NextUploadIdMarker"]);
}
if (data["Prefix"] !== void 0) {
contents.Prefix = expectString(data["Prefix"]);
}
if (data["UploadIdMarker"] !== void 0) {
contents.UploadIdMarker = expectString(data["UploadIdMarker"]);
}
if (data.Upload === "") {
contents.Uploads = [];
} else if (data["Upload"] !== void 0) {
contents.Uploads = deserializeAws_restXmlMultipartUploadList(getArrayIfSingleItem(data["Upload"]));
}
return contents;
};
const deserializeAws_restXmlListMultipartUploadsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListObjectsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListObjectsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.CommonPrefixes === "") {
contents.CommonPrefixes = [];
} else if (data["CommonPrefixes"] !== void 0) {
contents.CommonPrefixes = deserializeAws_restXmlCommonPrefixList(getArrayIfSingleItem(data["CommonPrefixes"]));
}
if (data.Contents === "") {
contents.Contents = [];
} else if (data["Contents"] !== void 0) {
contents.Contents = deserializeAws_restXmlObjectList(getArrayIfSingleItem(data["Contents"]));
}
if (data["Delimiter"] !== void 0) {
contents.Delimiter = expectString(data["Delimiter"]);
}
if (data["EncodingType"] !== void 0) {
contents.EncodingType = expectString(data["EncodingType"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["Marker"] !== void 0) {
contents.Marker = expectString(data["Marker"]);
}
if (data["MaxKeys"] !== void 0) {
contents.MaxKeys = strictParseInt32(data["MaxKeys"]);
}
if (data["Name"] !== void 0) {
contents.Name = expectString(data["Name"]);
}
if (data["NextMarker"] !== void 0) {
contents.NextMarker = expectString(data["NextMarker"]);
}
if (data["Prefix"] !== void 0) {
contents.Prefix = expectString(data["Prefix"]);
}
return contents;
};
const deserializeAws_restXmlListObjectsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchBucket":
case "com.amazonaws.s3#NoSuchBucket":
throw await deserializeAws_restXmlNoSuchBucketResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlListObjectsV2Command = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListObjectsV2CommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.CommonPrefixes === "") {
contents.CommonPrefixes = [];
} else if (data["CommonPrefixes"] !== void 0) {
contents.CommonPrefixes = deserializeAws_restXmlCommonPrefixList(getArrayIfSingleItem(data["CommonPrefixes"]));
}
if (data.Contents === "") {
contents.Contents = [];
} else if (data["Contents"] !== void 0) {
contents.Contents = deserializeAws_restXmlObjectList(getArrayIfSingleItem(data["Contents"]));
}
if (data["ContinuationToken"] !== void 0) {
contents.ContinuationToken = expectString(data["ContinuationToken"]);
}
if (data["Delimiter"] !== void 0) {
contents.Delimiter = expectString(data["Delimiter"]);
}
if (data["EncodingType"] !== void 0) {
contents.EncodingType = expectString(data["EncodingType"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["KeyCount"] !== void 0) {
contents.KeyCount = strictParseInt32(data["KeyCount"]);
}
if (data["MaxKeys"] !== void 0) {
contents.MaxKeys = strictParseInt32(data["MaxKeys"]);
}
if (data["Name"] !== void 0) {
contents.Name = expectString(data["Name"]);
}
if (data["NextContinuationToken"] !== void 0) {
contents.NextContinuationToken = expectString(data["NextContinuationToken"]);
}
if (data["Prefix"] !== void 0) {
contents.Prefix = expectString(data["Prefix"]);
}
if (data["StartAfter"] !== void 0) {
contents.StartAfter = expectString(data["StartAfter"]);
}
return contents;
};
const deserializeAws_restXmlListObjectsV2CommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchBucket":
case "com.amazonaws.s3#NoSuchBucket":
throw await deserializeAws_restXmlNoSuchBucketResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlListObjectVersionsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListObjectVersionsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data.CommonPrefixes === "") {
contents.CommonPrefixes = [];
} else if (data["CommonPrefixes"] !== void 0) {
contents.CommonPrefixes = deserializeAws_restXmlCommonPrefixList(getArrayIfSingleItem(data["CommonPrefixes"]));
}
if (data.DeleteMarker === "") {
contents.DeleteMarkers = [];
} else if (data["DeleteMarker"] !== void 0) {
contents.DeleteMarkers = deserializeAws_restXmlDeleteMarkers(getArrayIfSingleItem(data["DeleteMarker"]));
}
if (data["Delimiter"] !== void 0) {
contents.Delimiter = expectString(data["Delimiter"]);
}
if (data["EncodingType"] !== void 0) {
contents.EncodingType = expectString(data["EncodingType"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["KeyMarker"] !== void 0) {
contents.KeyMarker = expectString(data["KeyMarker"]);
}
if (data["MaxKeys"] !== void 0) {
contents.MaxKeys = strictParseInt32(data["MaxKeys"]);
}
if (data["Name"] !== void 0) {
contents.Name = expectString(data["Name"]);
}
if (data["NextKeyMarker"] !== void 0) {
contents.NextKeyMarker = expectString(data["NextKeyMarker"]);
}
if (data["NextVersionIdMarker"] !== void 0) {
contents.NextVersionIdMarker = expectString(data["NextVersionIdMarker"]);
}
if (data["Prefix"] !== void 0) {
contents.Prefix = expectString(data["Prefix"]);
}
if (data["VersionIdMarker"] !== void 0) {
contents.VersionIdMarker = expectString(data["VersionIdMarker"]);
}
if (data.Version === "") {
contents.Versions = [];
} else if (data["Version"] !== void 0) {
contents.Versions = deserializeAws_restXmlObjectVersionList(getArrayIfSingleItem(data["Version"]));
}
return contents;
};
const deserializeAws_restXmlListObjectVersionsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlListPartsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlListPartsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
AbortDate: [
()=>output.headers["x-amz-abort-date"] !== void 0,
()=>expectNonNull(parseRfc7231DateTime(output.headers["x-amz-abort-date"]))
],
AbortRuleId: [
,
output.headers["x-amz-abort-rule-id"]
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectNonNull(expectObject(await parseBody(output.body, context)), "body");
if (data["Bucket"] !== void 0) {
contents.Bucket = expectString(data["Bucket"]);
}
if (data["ChecksumAlgorithm"] !== void 0) {
contents.ChecksumAlgorithm = expectString(data["ChecksumAlgorithm"]);
}
if (data["Initiator"] !== void 0) {
contents.Initiator = deserializeAws_restXmlInitiator(data["Initiator"]);
}
if (data["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(data["IsTruncated"]);
}
if (data["Key"] !== void 0) {
contents.Key = expectString(data["Key"]);
}
if (data["MaxParts"] !== void 0) {
contents.MaxParts = strictParseInt32(data["MaxParts"]);
}
if (data["NextPartNumberMarker"] !== void 0) {
contents.NextPartNumberMarker = expectString(data["NextPartNumberMarker"]);
}
if (data["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(data["Owner"]);
}
if (data["PartNumberMarker"] !== void 0) {
contents.PartNumberMarker = expectString(data["PartNumberMarker"]);
}
if (data.Part === "") {
contents.Parts = [];
} else if (data["Part"] !== void 0) {
contents.Parts = deserializeAws_restXmlParts(getArrayIfSingleItem(data["Part"]));
}
if (data["StorageClass"] !== void 0) {
contents.StorageClass = expectString(data["StorageClass"]);
}
if (data["UploadId"] !== void 0) {
contents.UploadId = expectString(data["UploadId"]);
}
return contents;
};
const deserializeAws_restXmlListPartsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketAccelerateConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketAccelerateConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketAccelerateConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketAclCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketAclCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketAclCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketAnalyticsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketAnalyticsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketAnalyticsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketCorsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketCorsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketCorsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketEncryptionCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketEncryptionCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketEncryptionCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketIntelligentTieringConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketIntelligentTieringConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketIntelligentTieringConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketInventoryConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketInventoryConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketInventoryConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketLifecycleConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketLifecycleConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketLifecycleConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketLoggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketLoggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketLoggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketMetricsConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketMetricsConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketMetricsConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketNotificationConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketNotificationConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketNotificationConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketOwnershipControlsCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketOwnershipControlsCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketOwnershipControlsCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketPolicyCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketPolicyCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketPolicyCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketReplicationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketReplicationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketReplicationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketRequestPaymentCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketRequestPaymentCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketRequestPaymentCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketTaggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketVersioningCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketVersioningCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketVersioningCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutBucketWebsiteCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutBucketWebsiteCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutBucketWebsiteCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutObjectCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
Expiration: [
,
output.headers["x-amz-expiration"]
],
ETag: [
,
output.headers["etag"]
],
ChecksumCRC32: [
,
output.headers["x-amz-checksum-crc32"]
],
ChecksumCRC32C: [
,
output.headers["x-amz-checksum-crc32c"]
],
ChecksumSHA1: [
,
output.headers["x-amz-checksum-sha1"]
],
ChecksumSHA256: [
,
output.headers["x-amz-checksum-sha256"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
VersionId: [
,
output.headers["x-amz-version-id"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
SSEKMSEncryptionContext: [
,
output.headers["x-amz-server-side-encryption-context"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutObjectAclCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectAclCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectAclCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "NoSuchKey":
case "com.amazonaws.s3#NoSuchKey":
throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlPutObjectLegalHoldCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectLegalHoldCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectLegalHoldCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutObjectLockConfigurationCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectLockConfigurationCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectLockConfigurationCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutObjectRetentionCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectRetentionCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectRetentionCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutObjectTaggingCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutObjectTaggingCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
VersionId: [
,
output.headers["x-amz-version-id"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutObjectTaggingCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlPutPublicAccessBlockCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlPutPublicAccessBlockCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlPutPublicAccessBlockCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlRestoreObjectCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlRestoreObjectCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
RequestCharged: [
,
output.headers["x-amz-request-charged"]
],
RestoreOutputPath: [
,
output.headers["x-amz-restore-output-path"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlRestoreObjectCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
switch(errorCode){
case "ObjectAlreadyInActiveTierError":
case "com.amazonaws.s3#ObjectAlreadyInActiveTierError":
throw await deserializeAws_restXmlObjectAlreadyInActiveTierErrorResponse(parsedOutput);
default:
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
}
};
const deserializeAws_restXmlSelectObjectContentCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlSelectObjectContentCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
const data = output.body;
contents.Payload = deserializeAws_restXmlSelectObjectContentEventStream(data, context);
return contents;
};
const deserializeAws_restXmlSelectObjectContentCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlUploadPartCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlUploadPartCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
ETag: [
,
output.headers["etag"]
],
ChecksumCRC32: [
,
output.headers["x-amz-checksum-crc32"]
],
ChecksumCRC32C: [
,
output.headers["x-amz-checksum-crc32c"]
],
ChecksumSHA1: [
,
output.headers["x-amz-checksum-sha1"]
],
ChecksumSHA256: [
,
output.headers["x-amz-checksum-sha256"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlUploadPartCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlUploadPartCopyCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlUploadPartCopyCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output),
CopySourceVersionId: [
,
output.headers["x-amz-copy-source-version-id"]
],
ServerSideEncryption: [
,
output.headers["x-amz-server-side-encryption"]
],
SSECustomerAlgorithm: [
,
output.headers["x-amz-server-side-encryption-customer-algorithm"]
],
SSECustomerKeyMD5: [
,
output.headers["x-amz-server-side-encryption-customer-key-md5"]
],
SSEKMSKeyId: [
,
output.headers["x-amz-server-side-encryption-aws-kms-key-id"]
],
BucketKeyEnabled: [
()=>output.headers["x-amz-server-side-encryption-bucket-key-enabled"] !== void 0,
()=>parseBoolean(output.headers["x-amz-server-side-encryption-bucket-key-enabled"])
],
RequestCharged: [
,
output.headers["x-amz-request-charged"]
]
});
const data = expectObject(await parseBody(output.body, context));
contents.CopyPartResult = deserializeAws_restXmlCopyPartResult(data);
return contents;
};
const deserializeAws_restXmlUploadPartCopyCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const deserializeAws_restXmlWriteGetObjectResponseCommand = async (output, context)=>{
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restXmlWriteGetObjectResponseCommandError(output, context);
}
const contents = map1({
$metadata: deserializeMetadata1(output)
});
await collectBody1(output.body, context);
return contents;
};
const deserializeAws_restXmlWriteGetObjectResponseCommandError = async (output, context)=>{
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context)
};
const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);
const parsedBody = parsedOutput.body;
throwDefaultError({
output,
parsedBody,
exceptionCtor: S3ServiceException,
errorCode
});
};
const map1 = map;
const deserializeAws_restXmlBucketAlreadyExistsResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new BucketAlreadyExists({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlBucketAlreadyOwnedByYouResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new BucketAlreadyOwnedByYou({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlInvalidObjectStateResponse = async (parsedOutput, context)=>{
const contents = map({});
const data = parsedOutput.body;
if (data["AccessTier"] !== void 0) {
contents.AccessTier = expectString(data["AccessTier"]);
}
if (data["StorageClass"] !== void 0) {
contents.StorageClass = expectString(data["StorageClass"]);
}
const exception = new InvalidObjectState({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlNoSuchBucketResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new NoSuchBucket({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlNoSuchKeyResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new NoSuchKey({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlNoSuchUploadResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new NoSuchUpload({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlNotFoundResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new NotFound({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlObjectAlreadyInActiveTierErrorResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new ObjectAlreadyInActiveTierError({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlObjectNotInActiveTierErrorResponse = async (parsedOutput, context)=>{
const contents = map({});
parsedOutput.body;
const exception = new ObjectNotInActiveTierError({
$metadata: deserializeMetadata1(parsedOutput),
...contents
});
return decorateServiceException(exception, parsedOutput.body);
};
const deserializeAws_restXmlSelectObjectContentEventStream = (output, context)=>{
return context.eventStreamMarshaller.deserialize(output, async (event)=>{
if (event["Records"] != null) {
return {
Records: await deserializeAws_restXmlRecordsEvent_event(event["Records"])
};
}
if (event["Stats"] != null) {
return {
Stats: await deserializeAws_restXmlStatsEvent_event(event["Stats"], context)
};
}
if (event["Progress"] != null) {
return {
Progress: await deserializeAws_restXmlProgressEvent_event(event["Progress"], context)
};
}
if (event["Cont"] != null) {
return {
Cont: await deserializeAws_restXmlContinuationEvent_event(event["Cont"], context)
};
}
if (event["End"] != null) {
return {
End: await deserializeAws_restXmlEndEvent_event(event["End"], context)
};
}
return {
$unknown: output
};
});
};
const deserializeAws_restXmlContinuationEvent_event = async (output, context)=>{
const contents = {};
await parseBody(output.body, context);
Object.assign(contents, deserializeAws_restXmlContinuationEvent());
return contents;
};
const deserializeAws_restXmlEndEvent_event = async (output, context)=>{
const contents = {};
await parseBody(output.body, context);
Object.assign(contents, deserializeAws_restXmlEndEvent());
return contents;
};
const deserializeAws_restXmlProgressEvent_event = async (output, context)=>{
const contents = {};
const data = await parseBody(output.body, context);
contents.Details = deserializeAws_restXmlProgress(data);
return contents;
};
const deserializeAws_restXmlRecordsEvent_event = async (output, context)=>{
const contents = {};
contents.Payload = output.body;
return contents;
};
const deserializeAws_restXmlStatsEvent_event = async (output, context)=>{
const contents = {};
const data = await parseBody(output.body, context);
contents.Details = deserializeAws_restXmlStats(data);
return contents;
};
const serializeAws_restXmlAbortIncompleteMultipartUpload = (input, context)=>{
const bodyNode = new XmlNode("AbortIncompleteMultipartUpload");
if (input.DaysAfterInitiation != null) {
const node = XmlNode.of("DaysAfterInitiation", String(input.DaysAfterInitiation)).withName("DaysAfterInitiation");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlAccelerateConfiguration = (input, context)=>{
const bodyNode = new XmlNode("AccelerateConfiguration");
if (input.Status != null) {
const node = XmlNode.of("BucketAccelerateStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlAccessControlPolicy = (input, context)=>{
const bodyNode = new XmlNode("AccessControlPolicy");
if (input.Grants != null) {
const nodes = serializeAws_restXmlGrants(input.Grants);
const containerNode = new XmlNode("AccessControlList");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
if (input.Owner != null) {
const node = serializeAws_restXmlOwner(input.Owner).withName("Owner");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlAccessControlTranslation = (input, context)=>{
const bodyNode = new XmlNode("AccessControlTranslation");
if (input.Owner != null) {
const node = XmlNode.of("OwnerOverride", input.Owner).withName("Owner");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlAllowedHeaders = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("AllowedHeader", entry);
return node.withName("member");
});
};
const serializeAws_restXmlAllowedMethods = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("AllowedMethod", entry);
return node.withName("member");
});
};
const serializeAws_restXmlAllowedOrigins = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("AllowedOrigin", entry);
return node.withName("member");
});
};
const serializeAws_restXmlAnalyticsAndOperator = (input, context)=>{
const bodyNode = new XmlNode("AnalyticsAndOperator");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tags != null) {
const nodes = serializeAws_restXmlTagSet(input.Tags);
nodes.map((node)=>{
node = node.withName("Tag");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlAnalyticsConfiguration = (input, context)=>{
const bodyNode = new XmlNode("AnalyticsConfiguration");
if (input.Id != null) {
const node = XmlNode.of("AnalyticsId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.Filter != null) {
const node1 = serializeAws_restXmlAnalyticsFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node1);
}
if (input.StorageClassAnalysis != null) {
const node2 = serializeAws_restXmlStorageClassAnalysis(input.StorageClassAnalysis).withName("StorageClassAnalysis");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlAnalyticsExportDestination = (input, context)=>{
const bodyNode = new XmlNode("AnalyticsExportDestination");
if (input.S3BucketDestination != null) {
const node = serializeAws_restXmlAnalyticsS3BucketDestination(input.S3BucketDestination).withName("S3BucketDestination");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlAnalyticsFilter = (input, context)=>{
const bodyNode = new XmlNode("AnalyticsFilter");
AnalyticsFilter.visit(input, {
Prefix: (value)=>{
const node = XmlNode.of("Prefix", value).withName("Prefix");
bodyNode.addChildNode(node);
},
Tag: (value)=>{
const node = serializeAws_restXmlTag(value).withName("Tag");
bodyNode.addChildNode(node);
},
And: (value)=>{
const node = serializeAws_restXmlAnalyticsAndOperator(value).withName("And");
bodyNode.addChildNode(node);
},
_: (name2, value)=>{
if (!(value instanceof XmlNode || value instanceof XmlText)) {
throw new Error("Unable to serialize unknown union members in XML.");
}
bodyNode.addChildNode(new XmlNode(name2).addChildNode(value));
}
});
return bodyNode;
};
const serializeAws_restXmlAnalyticsS3BucketDestination = (input, context)=>{
const bodyNode = new XmlNode("AnalyticsS3BucketDestination");
if (input.Format != null) {
const node = XmlNode.of("AnalyticsS3ExportFileFormat", input.Format).withName("Format");
bodyNode.addChildNode(node);
}
if (input.BucketAccountId != null) {
const node1 = XmlNode.of("AccountId", input.BucketAccountId).withName("BucketAccountId");
bodyNode.addChildNode(node1);
}
if (input.Bucket != null) {
const node2 = XmlNode.of("BucketName", input.Bucket).withName("Bucket");
bodyNode.addChildNode(node2);
}
if (input.Prefix != null) {
const node3 = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node3);
}
return bodyNode;
};
const serializeAws_restXmlBucketLifecycleConfiguration = (input, context)=>{
const bodyNode = new XmlNode("BucketLifecycleConfiguration");
if (input.Rules != null) {
const nodes = serializeAws_restXmlLifecycleRules(input.Rules);
nodes.map((node)=>{
node = node.withName("Rule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlBucketLoggingStatus = (input, context)=>{
const bodyNode = new XmlNode("BucketLoggingStatus");
if (input.LoggingEnabled != null) {
const node = serializeAws_restXmlLoggingEnabled(input.LoggingEnabled).withName("LoggingEnabled");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlCompletedMultipartUpload = (input, context)=>{
const bodyNode = new XmlNode("CompletedMultipartUpload");
if (input.Parts != null) {
const nodes = serializeAws_restXmlCompletedPartList(input.Parts);
nodes.map((node)=>{
node = node.withName("Part");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlCompletedPart = (input, context)=>{
const bodyNode = new XmlNode("CompletedPart");
if (input.ETag != null) {
const node = XmlNode.of("ETag", input.ETag).withName("ETag");
bodyNode.addChildNode(node);
}
if (input.ChecksumCRC32 != null) {
const node1 = XmlNode.of("ChecksumCRC32", input.ChecksumCRC32).withName("ChecksumCRC32");
bodyNode.addChildNode(node1);
}
if (input.ChecksumCRC32C != null) {
const node2 = XmlNode.of("ChecksumCRC32C", input.ChecksumCRC32C).withName("ChecksumCRC32C");
bodyNode.addChildNode(node2);
}
if (input.ChecksumSHA1 != null) {
const node3 = XmlNode.of("ChecksumSHA1", input.ChecksumSHA1).withName("ChecksumSHA1");
bodyNode.addChildNode(node3);
}
if (input.ChecksumSHA256 != null) {
const node4 = XmlNode.of("ChecksumSHA256", input.ChecksumSHA256).withName("ChecksumSHA256");
bodyNode.addChildNode(node4);
}
if (input.PartNumber != null) {
const node5 = XmlNode.of("PartNumber", String(input.PartNumber)).withName("PartNumber");
bodyNode.addChildNode(node5);
}
return bodyNode;
};
const serializeAws_restXmlCompletedPartList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlCompletedPart(entry);
return node.withName("member");
});
};
const serializeAws_restXmlCondition = (input, context)=>{
const bodyNode = new XmlNode("Condition");
if (input.HttpErrorCodeReturnedEquals != null) {
const node = XmlNode.of("HttpErrorCodeReturnedEquals", input.HttpErrorCodeReturnedEquals).withName("HttpErrorCodeReturnedEquals");
bodyNode.addChildNode(node);
}
if (input.KeyPrefixEquals != null) {
const node1 = XmlNode.of("KeyPrefixEquals", input.KeyPrefixEquals).withName("KeyPrefixEquals");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlCORSConfiguration = (input, context)=>{
const bodyNode = new XmlNode("CORSConfiguration");
if (input.CORSRules != null) {
const nodes = serializeAws_restXmlCORSRules(input.CORSRules);
nodes.map((node)=>{
node = node.withName("CORSRule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlCORSRule = (input, context)=>{
const bodyNode = new XmlNode("CORSRule");
if (input.ID != null) {
const node = XmlNode.of("ID", input.ID).withName("ID");
bodyNode.addChildNode(node);
}
if (input.AllowedHeaders != null) {
const nodes = serializeAws_restXmlAllowedHeaders(input.AllowedHeaders);
nodes.map((node)=>{
node = node.withName("AllowedHeader");
bodyNode.addChildNode(node);
});
}
if (input.AllowedMethods != null) {
const nodes1 = serializeAws_restXmlAllowedMethods(input.AllowedMethods);
nodes1.map((node)=>{
node = node.withName("AllowedMethod");
bodyNode.addChildNode(node);
});
}
if (input.AllowedOrigins != null) {
const nodes2 = serializeAws_restXmlAllowedOrigins(input.AllowedOrigins);
nodes2.map((node)=>{
node = node.withName("AllowedOrigin");
bodyNode.addChildNode(node);
});
}
if (input.ExposeHeaders != null) {
const nodes3 = serializeAws_restXmlExposeHeaders(input.ExposeHeaders);
nodes3.map((node)=>{
node = node.withName("ExposeHeader");
bodyNode.addChildNode(node);
});
}
if (input.MaxAgeSeconds != null) {
const node1 = XmlNode.of("MaxAgeSeconds", String(input.MaxAgeSeconds)).withName("MaxAgeSeconds");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlCORSRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlCORSRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlCreateBucketConfiguration = (input, context)=>{
const bodyNode = new XmlNode("CreateBucketConfiguration");
if (input.LocationConstraint != null) {
const node = XmlNode.of("BucketLocationConstraint", input.LocationConstraint).withName("LocationConstraint");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlCSVInput = (input, context)=>{
const bodyNode = new XmlNode("CSVInput");
if (input.FileHeaderInfo != null) {
const node = XmlNode.of("FileHeaderInfo", input.FileHeaderInfo).withName("FileHeaderInfo");
bodyNode.addChildNode(node);
}
if (input.Comments != null) {
const node1 = XmlNode.of("Comments", input.Comments).withName("Comments");
bodyNode.addChildNode(node1);
}
if (input.QuoteEscapeCharacter != null) {
const node2 = XmlNode.of("QuoteEscapeCharacter", input.QuoteEscapeCharacter).withName("QuoteEscapeCharacter");
bodyNode.addChildNode(node2);
}
if (input.RecordDelimiter != null) {
const node3 = XmlNode.of("RecordDelimiter", input.RecordDelimiter).withName("RecordDelimiter");
bodyNode.addChildNode(node3);
}
if (input.FieldDelimiter != null) {
const node4 = XmlNode.of("FieldDelimiter", input.FieldDelimiter).withName("FieldDelimiter");
bodyNode.addChildNode(node4);
}
if (input.QuoteCharacter != null) {
const node5 = XmlNode.of("QuoteCharacter", input.QuoteCharacter).withName("QuoteCharacter");
bodyNode.addChildNode(node5);
}
if (input.AllowQuotedRecordDelimiter != null) {
const node6 = XmlNode.of("AllowQuotedRecordDelimiter", String(input.AllowQuotedRecordDelimiter)).withName("AllowQuotedRecordDelimiter");
bodyNode.addChildNode(node6);
}
return bodyNode;
};
const serializeAws_restXmlCSVOutput = (input, context)=>{
const bodyNode = new XmlNode("CSVOutput");
if (input.QuoteFields != null) {
const node = XmlNode.of("QuoteFields", input.QuoteFields).withName("QuoteFields");
bodyNode.addChildNode(node);
}
if (input.QuoteEscapeCharacter != null) {
const node1 = XmlNode.of("QuoteEscapeCharacter", input.QuoteEscapeCharacter).withName("QuoteEscapeCharacter");
bodyNode.addChildNode(node1);
}
if (input.RecordDelimiter != null) {
const node2 = XmlNode.of("RecordDelimiter", input.RecordDelimiter).withName("RecordDelimiter");
bodyNode.addChildNode(node2);
}
if (input.FieldDelimiter != null) {
const node3 = XmlNode.of("FieldDelimiter", input.FieldDelimiter).withName("FieldDelimiter");
bodyNode.addChildNode(node3);
}
if (input.QuoteCharacter != null) {
const node4 = XmlNode.of("QuoteCharacter", input.QuoteCharacter).withName("QuoteCharacter");
bodyNode.addChildNode(node4);
}
return bodyNode;
};
const serializeAws_restXmlDefaultRetention = (input, context)=>{
const bodyNode = new XmlNode("DefaultRetention");
if (input.Mode != null) {
const node = XmlNode.of("ObjectLockRetentionMode", input.Mode).withName("Mode");
bodyNode.addChildNode(node);
}
if (input.Days != null) {
const node1 = XmlNode.of("Days", String(input.Days)).withName("Days");
bodyNode.addChildNode(node1);
}
if (input.Years != null) {
const node2 = XmlNode.of("Years", String(input.Years)).withName("Years");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlDelete = (input, context)=>{
const bodyNode = new XmlNode("Delete");
if (input.Objects != null) {
const nodes = serializeAws_restXmlObjectIdentifierList(input.Objects);
nodes.map((node)=>{
node = node.withName("Object");
bodyNode.addChildNode(node);
});
}
if (input.Quiet != null) {
const node = XmlNode.of("Quiet", String(input.Quiet)).withName("Quiet");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlDeleteMarkerReplication = (input, context)=>{
const bodyNode = new XmlNode("DeleteMarkerReplication");
if (input.Status != null) {
const node = XmlNode.of("DeleteMarkerReplicationStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlDestination = (input, context)=>{
const bodyNode = new XmlNode("Destination");
if (input.Bucket != null) {
const node = XmlNode.of("BucketName", input.Bucket).withName("Bucket");
bodyNode.addChildNode(node);
}
if (input.Account != null) {
const node1 = XmlNode.of("AccountId", input.Account).withName("Account");
bodyNode.addChildNode(node1);
}
if (input.StorageClass != null) {
const node2 = XmlNode.of("StorageClass", input.StorageClass).withName("StorageClass");
bodyNode.addChildNode(node2);
}
if (input.AccessControlTranslation != null) {
const node3 = serializeAws_restXmlAccessControlTranslation(input.AccessControlTranslation).withName("AccessControlTranslation");
bodyNode.addChildNode(node3);
}
if (input.EncryptionConfiguration != null) {
const node4 = serializeAws_restXmlEncryptionConfiguration(input.EncryptionConfiguration).withName("EncryptionConfiguration");
bodyNode.addChildNode(node4);
}
if (input.ReplicationTime != null) {
const node5 = serializeAws_restXmlReplicationTime(input.ReplicationTime).withName("ReplicationTime");
bodyNode.addChildNode(node5);
}
if (input.Metrics != null) {
const node6 = serializeAws_restXmlMetrics(input.Metrics).withName("Metrics");
bodyNode.addChildNode(node6);
}
return bodyNode;
};
const serializeAws_restXmlEncryption = (input, context)=>{
const bodyNode = new XmlNode("Encryption");
if (input.EncryptionType != null) {
const node = XmlNode.of("ServerSideEncryption", input.EncryptionType).withName("EncryptionType");
bodyNode.addChildNode(node);
}
if (input.KMSKeyId != null) {
const node1 = XmlNode.of("SSEKMSKeyId", input.KMSKeyId).withName("KMSKeyId");
bodyNode.addChildNode(node1);
}
if (input.KMSContext != null) {
const node2 = XmlNode.of("KMSContext", input.KMSContext).withName("KMSContext");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlEncryptionConfiguration = (input, context)=>{
const bodyNode = new XmlNode("EncryptionConfiguration");
if (input.ReplicaKmsKeyID != null) {
const node = XmlNode.of("ReplicaKmsKeyID", input.ReplicaKmsKeyID).withName("ReplicaKmsKeyID");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlErrorDocument = (input, context)=>{
const bodyNode = new XmlNode("ErrorDocument");
if (input.Key != null) {
const node = XmlNode.of("ObjectKey", input.Key).withName("Key");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlEventBridgeConfiguration = (input, context)=>{
const bodyNode = new XmlNode("EventBridgeConfiguration");
return bodyNode;
};
const serializeAws_restXmlEventList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("Event", entry);
return node.withName("member");
});
};
const serializeAws_restXmlExistingObjectReplication = (input, context)=>{
const bodyNode = new XmlNode("ExistingObjectReplication");
if (input.Status != null) {
const node = XmlNode.of("ExistingObjectReplicationStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlExposeHeaders = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("ExposeHeader", entry);
return node.withName("member");
});
};
const serializeAws_restXmlFilterRule = (input, context)=>{
const bodyNode = new XmlNode("FilterRule");
if (input.Name != null) {
const node = XmlNode.of("FilterRuleName", input.Name).withName("Name");
bodyNode.addChildNode(node);
}
if (input.Value != null) {
const node1 = XmlNode.of("FilterRuleValue", input.Value).withName("Value");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlFilterRuleList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlFilterRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlGlacierJobParameters = (input, context)=>{
const bodyNode = new XmlNode("GlacierJobParameters");
if (input.Tier != null) {
const node = XmlNode.of("Tier", input.Tier).withName("Tier");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlGrant = (input, context)=>{
const bodyNode = new XmlNode("Grant");
if (input.Grantee != null) {
const node = serializeAws_restXmlGrantee(input.Grantee).withName("Grantee");
node.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
bodyNode.addChildNode(node);
}
if (input.Permission != null) {
const node1 = XmlNode.of("Permission", input.Permission).withName("Permission");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlGrantee = (input, context)=>{
const bodyNode = new XmlNode("Grantee");
if (input.DisplayName != null) {
const node = XmlNode.of("DisplayName", input.DisplayName).withName("DisplayName");
bodyNode.addChildNode(node);
}
if (input.EmailAddress != null) {
const node1 = XmlNode.of("EmailAddress", input.EmailAddress).withName("EmailAddress");
bodyNode.addChildNode(node1);
}
if (input.ID != null) {
const node2 = XmlNode.of("ID", input.ID).withName("ID");
bodyNode.addChildNode(node2);
}
if (input.URI != null) {
const node3 = XmlNode.of("URI", input.URI).withName("URI");
bodyNode.addChildNode(node3);
}
if (input.Type != null) {
bodyNode.addAttribute("xsi:type", input.Type);
}
return bodyNode;
};
const serializeAws_restXmlGrants = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlGrant(entry);
return node.withName("Grant");
});
};
const serializeAws_restXmlIndexDocument = (input, context)=>{
const bodyNode = new XmlNode("IndexDocument");
if (input.Suffix != null) {
const node = XmlNode.of("Suffix", input.Suffix).withName("Suffix");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlInputSerialization = (input, context)=>{
const bodyNode = new XmlNode("InputSerialization");
if (input.CSV != null) {
const node = serializeAws_restXmlCSVInput(input.CSV).withName("CSV");
bodyNode.addChildNode(node);
}
if (input.CompressionType != null) {
const node1 = XmlNode.of("CompressionType", input.CompressionType).withName("CompressionType");
bodyNode.addChildNode(node1);
}
if (input.JSON != null) {
const node2 = serializeAws_restXmlJSONInput(input.JSON).withName("JSON");
bodyNode.addChildNode(node2);
}
if (input.Parquet != null) {
const node3 = serializeAws_restXmlParquetInput(input.Parquet).withName("Parquet");
bodyNode.addChildNode(node3);
}
return bodyNode;
};
const serializeAws_restXmlIntelligentTieringAndOperator = (input, context)=>{
const bodyNode = new XmlNode("IntelligentTieringAndOperator");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tags != null) {
const nodes = serializeAws_restXmlTagSet(input.Tags);
nodes.map((node)=>{
node = node.withName("Tag");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlIntelligentTieringConfiguration = (input, context)=>{
const bodyNode = new XmlNode("IntelligentTieringConfiguration");
if (input.Id != null) {
const node = XmlNode.of("IntelligentTieringId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.Filter != null) {
const node1 = serializeAws_restXmlIntelligentTieringFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node1);
}
if (input.Status != null) {
const node2 = XmlNode.of("IntelligentTieringStatus", input.Status).withName("Status");
bodyNode.addChildNode(node2);
}
if (input.Tierings != null) {
const nodes = serializeAws_restXmlTieringList(input.Tierings);
nodes.map((node)=>{
node = node.withName("Tiering");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlIntelligentTieringFilter = (input, context)=>{
const bodyNode = new XmlNode("IntelligentTieringFilter");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tag != null) {
const node1 = serializeAws_restXmlTag(input.Tag).withName("Tag");
bodyNode.addChildNode(node1);
}
if (input.And != null) {
const node2 = serializeAws_restXmlIntelligentTieringAndOperator(input.And).withName("And");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlInventoryConfiguration = (input, context)=>{
const bodyNode = new XmlNode("InventoryConfiguration");
if (input.Destination != null) {
const node = serializeAws_restXmlInventoryDestination(input.Destination).withName("Destination");
bodyNode.addChildNode(node);
}
if (input.IsEnabled != null) {
const node1 = XmlNode.of("IsEnabled", String(input.IsEnabled)).withName("IsEnabled");
bodyNode.addChildNode(node1);
}
if (input.Filter != null) {
const node2 = serializeAws_restXmlInventoryFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node2);
}
if (input.Id != null) {
const node3 = XmlNode.of("InventoryId", input.Id).withName("Id");
bodyNode.addChildNode(node3);
}
if (input.IncludedObjectVersions != null) {
const node4 = XmlNode.of("InventoryIncludedObjectVersions", input.IncludedObjectVersions).withName("IncludedObjectVersions");
bodyNode.addChildNode(node4);
}
if (input.OptionalFields != null) {
const nodes = serializeAws_restXmlInventoryOptionalFields(input.OptionalFields);
const containerNode = new XmlNode("OptionalFields");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
if (input.Schedule != null) {
const node5 = serializeAws_restXmlInventorySchedule(input.Schedule).withName("Schedule");
bodyNode.addChildNode(node5);
}
return bodyNode;
};
const serializeAws_restXmlInventoryDestination = (input, context)=>{
const bodyNode = new XmlNode("InventoryDestination");
if (input.S3BucketDestination != null) {
const node = serializeAws_restXmlInventoryS3BucketDestination(input.S3BucketDestination).withName("S3BucketDestination");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlInventoryEncryption = (input, context)=>{
const bodyNode = new XmlNode("InventoryEncryption");
if (input.SSES3 != null) {
const node = serializeAws_restXmlSSES3(input.SSES3).withName("SSE-S3");
bodyNode.addChildNode(node);
}
if (input.SSEKMS != null) {
const node1 = serializeAws_restXmlSSEKMS(input.SSEKMS).withName("SSE-KMS");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlInventoryFilter = (input, context)=>{
const bodyNode = new XmlNode("InventoryFilter");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlInventoryOptionalFields = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = XmlNode.of("InventoryOptionalField", entry);
return node.withName("Field");
});
};
const serializeAws_restXmlInventoryS3BucketDestination = (input, context)=>{
const bodyNode = new XmlNode("InventoryS3BucketDestination");
if (input.AccountId != null) {
const node = XmlNode.of("AccountId", input.AccountId).withName("AccountId");
bodyNode.addChildNode(node);
}
if (input.Bucket != null) {
const node1 = XmlNode.of("BucketName", input.Bucket).withName("Bucket");
bodyNode.addChildNode(node1);
}
if (input.Format != null) {
const node2 = XmlNode.of("InventoryFormat", input.Format).withName("Format");
bodyNode.addChildNode(node2);
}
if (input.Prefix != null) {
const node3 = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node3);
}
if (input.Encryption != null) {
const node4 = serializeAws_restXmlInventoryEncryption(input.Encryption).withName("Encryption");
bodyNode.addChildNode(node4);
}
return bodyNode;
};
const serializeAws_restXmlInventorySchedule = (input, context)=>{
const bodyNode = new XmlNode("InventorySchedule");
if (input.Frequency != null) {
const node = XmlNode.of("InventoryFrequency", input.Frequency).withName("Frequency");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlJSONInput = (input, context)=>{
const bodyNode = new XmlNode("JSONInput");
if (input.Type != null) {
const node = XmlNode.of("JSONType", input.Type).withName("Type");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlJSONOutput = (input, context)=>{
const bodyNode = new XmlNode("JSONOutput");
if (input.RecordDelimiter != null) {
const node = XmlNode.of("RecordDelimiter", input.RecordDelimiter).withName("RecordDelimiter");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlLambdaFunctionConfiguration = (input, context)=>{
const bodyNode = new XmlNode("LambdaFunctionConfiguration");
if (input.Id != null) {
const node = XmlNode.of("NotificationId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.LambdaFunctionArn != null) {
const node1 = XmlNode.of("LambdaFunctionArn", input.LambdaFunctionArn).withName("CloudFunction");
bodyNode.addChildNode(node1);
}
if (input.Events != null) {
const nodes = serializeAws_restXmlEventList(input.Events);
nodes.map((node)=>{
node = node.withName("Event");
bodyNode.addChildNode(node);
});
}
if (input.Filter != null) {
const node2 = serializeAws_restXmlNotificationConfigurationFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlLambdaFunctionConfigurationList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlLambdaFunctionConfiguration(entry);
return node.withName("member");
});
};
const serializeAws_restXmlLifecycleExpiration = (input, context)=>{
const bodyNode = new XmlNode("LifecycleExpiration");
if (input.Date != null) {
const node = XmlNode.of("Date", input.Date.toISOString().split(".")[0] + "Z").withName("Date");
bodyNode.addChildNode(node);
}
if (input.Days != null) {
const node1 = XmlNode.of("Days", String(input.Days)).withName("Days");
bodyNode.addChildNode(node1);
}
if (input.ExpiredObjectDeleteMarker != null) {
const node2 = XmlNode.of("ExpiredObjectDeleteMarker", String(input.ExpiredObjectDeleteMarker)).withName("ExpiredObjectDeleteMarker");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlLifecycleRule = (input, context)=>{
const bodyNode = new XmlNode("LifecycleRule");
if (input.Expiration != null) {
const node = serializeAws_restXmlLifecycleExpiration(input.Expiration).withName("Expiration");
bodyNode.addChildNode(node);
}
if (input.ID != null) {
const node1 = XmlNode.of("ID", input.ID).withName("ID");
bodyNode.addChildNode(node1);
}
if (input.Prefix != null) {
const node2 = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node2);
}
if (input.Filter != null) {
const node3 = serializeAws_restXmlLifecycleRuleFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node3);
}
if (input.Status != null) {
const node4 = XmlNode.of("ExpirationStatus", input.Status).withName("Status");
bodyNode.addChildNode(node4);
}
if (input.Transitions != null) {
const nodes = serializeAws_restXmlTransitionList(input.Transitions);
nodes.map((node)=>{
node = node.withName("Transition");
bodyNode.addChildNode(node);
});
}
if (input.NoncurrentVersionTransitions != null) {
const nodes1 = serializeAws_restXmlNoncurrentVersionTransitionList(input.NoncurrentVersionTransitions);
nodes1.map((node)=>{
node = node.withName("NoncurrentVersionTransition");
bodyNode.addChildNode(node);
});
}
if (input.NoncurrentVersionExpiration != null) {
const node5 = serializeAws_restXmlNoncurrentVersionExpiration(input.NoncurrentVersionExpiration).withName("NoncurrentVersionExpiration");
bodyNode.addChildNode(node5);
}
if (input.AbortIncompleteMultipartUpload != null) {
const node6 = serializeAws_restXmlAbortIncompleteMultipartUpload(input.AbortIncompleteMultipartUpload).withName("AbortIncompleteMultipartUpload");
bodyNode.addChildNode(node6);
}
return bodyNode;
};
const serializeAws_restXmlLifecycleRuleAndOperator = (input, context)=>{
const bodyNode = new XmlNode("LifecycleRuleAndOperator");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tags != null) {
const nodes = serializeAws_restXmlTagSet(input.Tags);
nodes.map((node)=>{
node = node.withName("Tag");
bodyNode.addChildNode(node);
});
}
if (input.ObjectSizeGreaterThan != null) {
const node1 = XmlNode.of("ObjectSizeGreaterThanBytes", String(input.ObjectSizeGreaterThan)).withName("ObjectSizeGreaterThan");
bodyNode.addChildNode(node1);
}
if (input.ObjectSizeLessThan != null) {
const node2 = XmlNode.of("ObjectSizeLessThanBytes", String(input.ObjectSizeLessThan)).withName("ObjectSizeLessThan");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlLifecycleRuleFilter = (input, context)=>{
const bodyNode = new XmlNode("LifecycleRuleFilter");
LifecycleRuleFilter.visit(input, {
Prefix: (value)=>{
const node = XmlNode.of("Prefix", value).withName("Prefix");
bodyNode.addChildNode(node);
},
Tag: (value)=>{
const node = serializeAws_restXmlTag(value).withName("Tag");
bodyNode.addChildNode(node);
},
ObjectSizeGreaterThan: (value)=>{
const node = XmlNode.of("ObjectSizeGreaterThanBytes", String(value)).withName("ObjectSizeGreaterThan");
bodyNode.addChildNode(node);
},
ObjectSizeLessThan: (value)=>{
const node = XmlNode.of("ObjectSizeLessThanBytes", String(value)).withName("ObjectSizeLessThan");
bodyNode.addChildNode(node);
},
And: (value)=>{
const node = serializeAws_restXmlLifecycleRuleAndOperator(value).withName("And");
bodyNode.addChildNode(node);
},
_: (name2, value)=>{
if (!(value instanceof XmlNode || value instanceof XmlText)) {
throw new Error("Unable to serialize unknown union members in XML.");
}
bodyNode.addChildNode(new XmlNode(name2).addChildNode(value));
}
});
return bodyNode;
};
const serializeAws_restXmlLifecycleRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlLifecycleRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlLoggingEnabled = (input, context)=>{
const bodyNode = new XmlNode("LoggingEnabled");
if (input.TargetBucket != null) {
const node = XmlNode.of("TargetBucket", input.TargetBucket).withName("TargetBucket");
bodyNode.addChildNode(node);
}
if (input.TargetGrants != null) {
const nodes = serializeAws_restXmlTargetGrants(input.TargetGrants);
const containerNode = new XmlNode("TargetGrants");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
if (input.TargetPrefix != null) {
const node1 = XmlNode.of("TargetPrefix", input.TargetPrefix).withName("TargetPrefix");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlMetadataEntry = (input, context)=>{
const bodyNode = new XmlNode("MetadataEntry");
if (input.Name != null) {
const node = XmlNode.of("MetadataKey", input.Name).withName("Name");
bodyNode.addChildNode(node);
}
if (input.Value != null) {
const node1 = XmlNode.of("MetadataValue", input.Value).withName("Value");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlMetrics = (input, context)=>{
const bodyNode = new XmlNode("Metrics");
if (input.Status != null) {
const node = XmlNode.of("MetricsStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
if (input.EventThreshold != null) {
const node1 = serializeAws_restXmlReplicationTimeValue(input.EventThreshold).withName("EventThreshold");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlMetricsAndOperator = (input, context)=>{
const bodyNode = new XmlNode("MetricsAndOperator");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tags != null) {
const nodes = serializeAws_restXmlTagSet(input.Tags);
nodes.map((node)=>{
node = node.withName("Tag");
bodyNode.addChildNode(node);
});
}
if (input.AccessPointArn != null) {
const node1 = XmlNode.of("AccessPointArn", input.AccessPointArn).withName("AccessPointArn");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlMetricsConfiguration = (input, context)=>{
const bodyNode = new XmlNode("MetricsConfiguration");
if (input.Id != null) {
const node = XmlNode.of("MetricsId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.Filter != null) {
const node1 = serializeAws_restXmlMetricsFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlMetricsFilter = (input, context)=>{
const bodyNode = new XmlNode("MetricsFilter");
MetricsFilter.visit(input, {
Prefix: (value)=>{
const node = XmlNode.of("Prefix", value).withName("Prefix");
bodyNode.addChildNode(node);
},
Tag: (value)=>{
const node = serializeAws_restXmlTag(value).withName("Tag");
bodyNode.addChildNode(node);
},
AccessPointArn: (value)=>{
const node = XmlNode.of("AccessPointArn", value).withName("AccessPointArn");
bodyNode.addChildNode(node);
},
And: (value)=>{
const node = serializeAws_restXmlMetricsAndOperator(value).withName("And");
bodyNode.addChildNode(node);
},
_: (name2, value)=>{
if (!(value instanceof XmlNode || value instanceof XmlText)) {
throw new Error("Unable to serialize unknown union members in XML.");
}
bodyNode.addChildNode(new XmlNode(name2).addChildNode(value));
}
});
return bodyNode;
};
const serializeAws_restXmlNoncurrentVersionExpiration = (input, context)=>{
const bodyNode = new XmlNode("NoncurrentVersionExpiration");
if (input.NoncurrentDays != null) {
const node = XmlNode.of("Days", String(input.NoncurrentDays)).withName("NoncurrentDays");
bodyNode.addChildNode(node);
}
if (input.NewerNoncurrentVersions != null) {
const node1 = XmlNode.of("VersionCount", String(input.NewerNoncurrentVersions)).withName("NewerNoncurrentVersions");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlNoncurrentVersionTransition = (input, context)=>{
const bodyNode = new XmlNode("NoncurrentVersionTransition");
if (input.NoncurrentDays != null) {
const node = XmlNode.of("Days", String(input.NoncurrentDays)).withName("NoncurrentDays");
bodyNode.addChildNode(node);
}
if (input.StorageClass != null) {
const node1 = XmlNode.of("TransitionStorageClass", input.StorageClass).withName("StorageClass");
bodyNode.addChildNode(node1);
}
if (input.NewerNoncurrentVersions != null) {
const node2 = XmlNode.of("VersionCount", String(input.NewerNoncurrentVersions)).withName("NewerNoncurrentVersions");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlNoncurrentVersionTransitionList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlNoncurrentVersionTransition(entry);
return node.withName("member");
});
};
const serializeAws_restXmlNotificationConfiguration = (input, context)=>{
const bodyNode = new XmlNode("NotificationConfiguration");
if (input.TopicConfigurations != null) {
const nodes = serializeAws_restXmlTopicConfigurationList(input.TopicConfigurations);
nodes.map((node)=>{
node = node.withName("TopicConfiguration");
bodyNode.addChildNode(node);
});
}
if (input.QueueConfigurations != null) {
const nodes1 = serializeAws_restXmlQueueConfigurationList(input.QueueConfigurations);
nodes1.map((node)=>{
node = node.withName("QueueConfiguration");
bodyNode.addChildNode(node);
});
}
if (input.LambdaFunctionConfigurations != null) {
const nodes2 = serializeAws_restXmlLambdaFunctionConfigurationList(input.LambdaFunctionConfigurations);
nodes2.map((node)=>{
node = node.withName("CloudFunctionConfiguration");
bodyNode.addChildNode(node);
});
}
if (input.EventBridgeConfiguration != null) {
const node = serializeAws_restXmlEventBridgeConfiguration(input.EventBridgeConfiguration).withName("EventBridgeConfiguration");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlNotificationConfigurationFilter = (input, context)=>{
const bodyNode = new XmlNode("NotificationConfigurationFilter");
if (input.Key != null) {
const node = serializeAws_restXmlS3KeyFilter(input.Key).withName("S3Key");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlObjectIdentifier = (input, context)=>{
const bodyNode = new XmlNode("ObjectIdentifier");
if (input.Key != null) {
const node = XmlNode.of("ObjectKey", input.Key).withName("Key");
bodyNode.addChildNode(node);
}
if (input.VersionId != null) {
const node1 = XmlNode.of("ObjectVersionId", input.VersionId).withName("VersionId");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlObjectIdentifierList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlObjectIdentifier(entry);
return node.withName("member");
});
};
const serializeAws_restXmlObjectLockConfiguration = (input, context)=>{
const bodyNode = new XmlNode("ObjectLockConfiguration");
if (input.ObjectLockEnabled != null) {
const node = XmlNode.of("ObjectLockEnabled", input.ObjectLockEnabled).withName("ObjectLockEnabled");
bodyNode.addChildNode(node);
}
if (input.Rule != null) {
const node1 = serializeAws_restXmlObjectLockRule(input.Rule).withName("Rule");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlObjectLockLegalHold = (input, context)=>{
const bodyNode = new XmlNode("ObjectLockLegalHold");
if (input.Status != null) {
const node = XmlNode.of("ObjectLockLegalHoldStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlObjectLockRetention = (input, context)=>{
const bodyNode = new XmlNode("ObjectLockRetention");
if (input.Mode != null) {
const node = XmlNode.of("ObjectLockRetentionMode", input.Mode).withName("Mode");
bodyNode.addChildNode(node);
}
if (input.RetainUntilDate != null) {
const node1 = XmlNode.of("Date", input.RetainUntilDate.toISOString().split(".")[0] + "Z").withName("RetainUntilDate");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlObjectLockRule = (input, context)=>{
const bodyNode = new XmlNode("ObjectLockRule");
if (input.DefaultRetention != null) {
const node = serializeAws_restXmlDefaultRetention(input.DefaultRetention).withName("DefaultRetention");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlOutputLocation = (input, context)=>{
const bodyNode = new XmlNode("OutputLocation");
if (input.S3 != null) {
const node = serializeAws_restXmlS3Location(input.S3).withName("S3");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlOutputSerialization = (input, context)=>{
const bodyNode = new XmlNode("OutputSerialization");
if (input.CSV != null) {
const node = serializeAws_restXmlCSVOutput(input.CSV).withName("CSV");
bodyNode.addChildNode(node);
}
if (input.JSON != null) {
const node1 = serializeAws_restXmlJSONOutput(input.JSON).withName("JSON");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlOwner = (input, context)=>{
const bodyNode = new XmlNode("Owner");
if (input.DisplayName != null) {
const node = XmlNode.of("DisplayName", input.DisplayName).withName("DisplayName");
bodyNode.addChildNode(node);
}
if (input.ID != null) {
const node1 = XmlNode.of("ID", input.ID).withName("ID");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlOwnershipControls = (input, context)=>{
const bodyNode = new XmlNode("OwnershipControls");
if (input.Rules != null) {
const nodes = serializeAws_restXmlOwnershipControlsRules(input.Rules);
nodes.map((node)=>{
node = node.withName("Rule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlOwnershipControlsRule = (input, context)=>{
const bodyNode = new XmlNode("OwnershipControlsRule");
if (input.ObjectOwnership != null) {
const node = XmlNode.of("ObjectOwnership", input.ObjectOwnership).withName("ObjectOwnership");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlOwnershipControlsRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlOwnershipControlsRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlParquetInput = (input, context)=>{
const bodyNode = new XmlNode("ParquetInput");
return bodyNode;
};
const serializeAws_restXmlPublicAccessBlockConfiguration = (input, context)=>{
const bodyNode = new XmlNode("PublicAccessBlockConfiguration");
if (input.BlockPublicAcls != null) {
const node = XmlNode.of("Setting", String(input.BlockPublicAcls)).withName("BlockPublicAcls");
bodyNode.addChildNode(node);
}
if (input.IgnorePublicAcls != null) {
const node1 = XmlNode.of("Setting", String(input.IgnorePublicAcls)).withName("IgnorePublicAcls");
bodyNode.addChildNode(node1);
}
if (input.BlockPublicPolicy != null) {
const node2 = XmlNode.of("Setting", String(input.BlockPublicPolicy)).withName("BlockPublicPolicy");
bodyNode.addChildNode(node2);
}
if (input.RestrictPublicBuckets != null) {
const node3 = XmlNode.of("Setting", String(input.RestrictPublicBuckets)).withName("RestrictPublicBuckets");
bodyNode.addChildNode(node3);
}
return bodyNode;
};
const serializeAws_restXmlQueueConfiguration = (input, context)=>{
const bodyNode = new XmlNode("QueueConfiguration");
if (input.Id != null) {
const node = XmlNode.of("NotificationId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.QueueArn != null) {
const node1 = XmlNode.of("QueueArn", input.QueueArn).withName("Queue");
bodyNode.addChildNode(node1);
}
if (input.Events != null) {
const nodes = serializeAws_restXmlEventList(input.Events);
nodes.map((node)=>{
node = node.withName("Event");
bodyNode.addChildNode(node);
});
}
if (input.Filter != null) {
const node2 = serializeAws_restXmlNotificationConfigurationFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlQueueConfigurationList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlQueueConfiguration(entry);
return node.withName("member");
});
};
const serializeAws_restXmlRedirect = (input, context)=>{
const bodyNode = new XmlNode("Redirect");
if (input.HostName != null) {
const node = XmlNode.of("HostName", input.HostName).withName("HostName");
bodyNode.addChildNode(node);
}
if (input.HttpRedirectCode != null) {
const node1 = XmlNode.of("HttpRedirectCode", input.HttpRedirectCode).withName("HttpRedirectCode");
bodyNode.addChildNode(node1);
}
if (input.Protocol != null) {
const node2 = XmlNode.of("Protocol", input.Protocol).withName("Protocol");
bodyNode.addChildNode(node2);
}
if (input.ReplaceKeyPrefixWith != null) {
const node3 = XmlNode.of("ReplaceKeyPrefixWith", input.ReplaceKeyPrefixWith).withName("ReplaceKeyPrefixWith");
bodyNode.addChildNode(node3);
}
if (input.ReplaceKeyWith != null) {
const node4 = XmlNode.of("ReplaceKeyWith", input.ReplaceKeyWith).withName("ReplaceKeyWith");
bodyNode.addChildNode(node4);
}
return bodyNode;
};
const serializeAws_restXmlRedirectAllRequestsTo = (input, context)=>{
const bodyNode = new XmlNode("RedirectAllRequestsTo");
if (input.HostName != null) {
const node = XmlNode.of("HostName", input.HostName).withName("HostName");
bodyNode.addChildNode(node);
}
if (input.Protocol != null) {
const node1 = XmlNode.of("Protocol", input.Protocol).withName("Protocol");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlReplicaModifications = (input, context)=>{
const bodyNode = new XmlNode("ReplicaModifications");
if (input.Status != null) {
const node = XmlNode.of("ReplicaModificationsStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlReplicationConfiguration = (input, context)=>{
const bodyNode = new XmlNode("ReplicationConfiguration");
if (input.Role != null) {
const node = XmlNode.of("Role", input.Role).withName("Role");
bodyNode.addChildNode(node);
}
if (input.Rules != null) {
const nodes = serializeAws_restXmlReplicationRules(input.Rules);
nodes.map((node)=>{
node = node.withName("Rule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlReplicationRule = (input, context)=>{
const bodyNode = new XmlNode("ReplicationRule");
if (input.ID != null) {
const node = XmlNode.of("ID", input.ID).withName("ID");
bodyNode.addChildNode(node);
}
if (input.Priority != null) {
const node1 = XmlNode.of("Priority", String(input.Priority)).withName("Priority");
bodyNode.addChildNode(node1);
}
if (input.Prefix != null) {
const node2 = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node2);
}
if (input.Filter != null) {
const node3 = serializeAws_restXmlReplicationRuleFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node3);
}
if (input.Status != null) {
const node4 = XmlNode.of("ReplicationRuleStatus", input.Status).withName("Status");
bodyNode.addChildNode(node4);
}
if (input.SourceSelectionCriteria != null) {
const node5 = serializeAws_restXmlSourceSelectionCriteria(input.SourceSelectionCriteria).withName("SourceSelectionCriteria");
bodyNode.addChildNode(node5);
}
if (input.ExistingObjectReplication != null) {
const node6 = serializeAws_restXmlExistingObjectReplication(input.ExistingObjectReplication).withName("ExistingObjectReplication");
bodyNode.addChildNode(node6);
}
if (input.Destination != null) {
const node7 = serializeAws_restXmlDestination(input.Destination).withName("Destination");
bodyNode.addChildNode(node7);
}
if (input.DeleteMarkerReplication != null) {
const node8 = serializeAws_restXmlDeleteMarkerReplication(input.DeleteMarkerReplication).withName("DeleteMarkerReplication");
bodyNode.addChildNode(node8);
}
return bodyNode;
};
const serializeAws_restXmlReplicationRuleAndOperator = (input, context)=>{
const bodyNode = new XmlNode("ReplicationRuleAndOperator");
if (input.Prefix != null) {
const node = XmlNode.of("Prefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node);
}
if (input.Tags != null) {
const nodes = serializeAws_restXmlTagSet(input.Tags);
nodes.map((node)=>{
node = node.withName("Tag");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlReplicationRuleFilter = (input, context)=>{
const bodyNode = new XmlNode("ReplicationRuleFilter");
ReplicationRuleFilter.visit(input, {
Prefix: (value)=>{
const node = XmlNode.of("Prefix", value).withName("Prefix");
bodyNode.addChildNode(node);
},
Tag: (value)=>{
const node = serializeAws_restXmlTag(value).withName("Tag");
bodyNode.addChildNode(node);
},
And: (value)=>{
const node = serializeAws_restXmlReplicationRuleAndOperator(value).withName("And");
bodyNode.addChildNode(node);
},
_: (name2, value)=>{
if (!(value instanceof XmlNode || value instanceof XmlText)) {
throw new Error("Unable to serialize unknown union members in XML.");
}
bodyNode.addChildNode(new XmlNode(name2).addChildNode(value));
}
});
return bodyNode;
};
const serializeAws_restXmlReplicationRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlReplicationRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlReplicationTime = (input, context)=>{
const bodyNode = new XmlNode("ReplicationTime");
if (input.Status != null) {
const node = XmlNode.of("ReplicationTimeStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
if (input.Time != null) {
const node1 = serializeAws_restXmlReplicationTimeValue(input.Time).withName("Time");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlReplicationTimeValue = (input, context)=>{
const bodyNode = new XmlNode("ReplicationTimeValue");
if (input.Minutes != null) {
const node = XmlNode.of("Minutes", String(input.Minutes)).withName("Minutes");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlRequestPaymentConfiguration = (input, context)=>{
const bodyNode = new XmlNode("RequestPaymentConfiguration");
if (input.Payer != null) {
const node = XmlNode.of("Payer", input.Payer).withName("Payer");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlRequestProgress = (input, context)=>{
const bodyNode = new XmlNode("RequestProgress");
if (input.Enabled != null) {
const node = XmlNode.of("EnableRequestProgress", String(input.Enabled)).withName("Enabled");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlRestoreRequest = (input, context)=>{
const bodyNode = new XmlNode("RestoreRequest");
if (input.Days != null) {
const node = XmlNode.of("Days", String(input.Days)).withName("Days");
bodyNode.addChildNode(node);
}
if (input.GlacierJobParameters != null) {
const node1 = serializeAws_restXmlGlacierJobParameters(input.GlacierJobParameters).withName("GlacierJobParameters");
bodyNode.addChildNode(node1);
}
if (input.Type != null) {
const node2 = XmlNode.of("RestoreRequestType", input.Type).withName("Type");
bodyNode.addChildNode(node2);
}
if (input.Tier != null) {
const node3 = XmlNode.of("Tier", input.Tier).withName("Tier");
bodyNode.addChildNode(node3);
}
if (input.Description != null) {
const node4 = XmlNode.of("Description", input.Description).withName("Description");
bodyNode.addChildNode(node4);
}
if (input.SelectParameters != null) {
const node5 = serializeAws_restXmlSelectParameters(input.SelectParameters).withName("SelectParameters");
bodyNode.addChildNode(node5);
}
if (input.OutputLocation != null) {
const node6 = serializeAws_restXmlOutputLocation(input.OutputLocation).withName("OutputLocation");
bodyNode.addChildNode(node6);
}
return bodyNode;
};
const serializeAws_restXmlRoutingRule = (input, context)=>{
const bodyNode = new XmlNode("RoutingRule");
if (input.Condition != null) {
const node = serializeAws_restXmlCondition(input.Condition).withName("Condition");
bodyNode.addChildNode(node);
}
if (input.Redirect != null) {
const node1 = serializeAws_restXmlRedirect(input.Redirect).withName("Redirect");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlRoutingRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlRoutingRule(entry);
return node.withName("RoutingRule");
});
};
const serializeAws_restXmlS3KeyFilter = (input, context)=>{
const bodyNode = new XmlNode("S3KeyFilter");
if (input.FilterRules != null) {
const nodes = serializeAws_restXmlFilterRuleList(input.FilterRules);
nodes.map((node)=>{
node = node.withName("FilterRule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlS3Location = (input, context)=>{
const bodyNode = new XmlNode("S3Location");
if (input.BucketName != null) {
const node = XmlNode.of("BucketName", input.BucketName).withName("BucketName");
bodyNode.addChildNode(node);
}
if (input.Prefix != null) {
const node1 = XmlNode.of("LocationPrefix", input.Prefix).withName("Prefix");
bodyNode.addChildNode(node1);
}
if (input.Encryption != null) {
const node2 = serializeAws_restXmlEncryption(input.Encryption).withName("Encryption");
bodyNode.addChildNode(node2);
}
if (input.CannedACL != null) {
const node3 = XmlNode.of("ObjectCannedACL", input.CannedACL).withName("CannedACL");
bodyNode.addChildNode(node3);
}
if (input.AccessControlList != null) {
const nodes = serializeAws_restXmlGrants(input.AccessControlList);
const containerNode = new XmlNode("AccessControlList");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
if (input.Tagging != null) {
const node4 = serializeAws_restXmlTagging(input.Tagging).withName("Tagging");
bodyNode.addChildNode(node4);
}
if (input.UserMetadata != null) {
const nodes1 = serializeAws_restXmlUserMetadata(input.UserMetadata);
const containerNode1 = new XmlNode("UserMetadata");
nodes1.map((node)=>{
containerNode1.addChildNode(node);
});
bodyNode.addChildNode(containerNode1);
}
if (input.StorageClass != null) {
const node5 = XmlNode.of("StorageClass", input.StorageClass).withName("StorageClass");
bodyNode.addChildNode(node5);
}
return bodyNode;
};
const serializeAws_restXmlScanRange = (input, context)=>{
const bodyNode = new XmlNode("ScanRange");
if (input.Start != null) {
const node = XmlNode.of("Start", String(input.Start)).withName("Start");
bodyNode.addChildNode(node);
}
if (input.End != null) {
const node1 = XmlNode.of("End", String(input.End)).withName("End");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlSelectParameters = (input, context)=>{
const bodyNode = new XmlNode("SelectParameters");
if (input.InputSerialization != null) {
const node = serializeAws_restXmlInputSerialization(input.InputSerialization).withName("InputSerialization");
bodyNode.addChildNode(node);
}
if (input.ExpressionType != null) {
const node1 = XmlNode.of("ExpressionType", input.ExpressionType).withName("ExpressionType");
bodyNode.addChildNode(node1);
}
if (input.Expression != null) {
const node2 = XmlNode.of("Expression", input.Expression).withName("Expression");
bodyNode.addChildNode(node2);
}
if (input.OutputSerialization != null) {
const node3 = serializeAws_restXmlOutputSerialization(input.OutputSerialization).withName("OutputSerialization");
bodyNode.addChildNode(node3);
}
return bodyNode;
};
const serializeAws_restXmlServerSideEncryptionByDefault = (input, context)=>{
const bodyNode = new XmlNode("ServerSideEncryptionByDefault");
if (input.SSEAlgorithm != null) {
const node = XmlNode.of("ServerSideEncryption", input.SSEAlgorithm).withName("SSEAlgorithm");
bodyNode.addChildNode(node);
}
if (input.KMSMasterKeyID != null) {
const node1 = XmlNode.of("SSEKMSKeyId", input.KMSMasterKeyID).withName("KMSMasterKeyID");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlServerSideEncryptionConfiguration = (input, context)=>{
const bodyNode = new XmlNode("ServerSideEncryptionConfiguration");
if (input.Rules != null) {
const nodes = serializeAws_restXmlServerSideEncryptionRules(input.Rules);
nodes.map((node)=>{
node = node.withName("Rule");
bodyNode.addChildNode(node);
});
}
return bodyNode;
};
const serializeAws_restXmlServerSideEncryptionRule = (input, context)=>{
const bodyNode = new XmlNode("ServerSideEncryptionRule");
if (input.ApplyServerSideEncryptionByDefault != null) {
const node = serializeAws_restXmlServerSideEncryptionByDefault(input.ApplyServerSideEncryptionByDefault).withName("ApplyServerSideEncryptionByDefault");
bodyNode.addChildNode(node);
}
if (input.BucketKeyEnabled != null) {
const node1 = XmlNode.of("BucketKeyEnabled", String(input.BucketKeyEnabled)).withName("BucketKeyEnabled");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlServerSideEncryptionRules = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlServerSideEncryptionRule(entry);
return node.withName("member");
});
};
const serializeAws_restXmlSourceSelectionCriteria = (input, context)=>{
const bodyNode = new XmlNode("SourceSelectionCriteria");
if (input.SseKmsEncryptedObjects != null) {
const node = serializeAws_restXmlSseKmsEncryptedObjects(input.SseKmsEncryptedObjects).withName("SseKmsEncryptedObjects");
bodyNode.addChildNode(node);
}
if (input.ReplicaModifications != null) {
const node1 = serializeAws_restXmlReplicaModifications(input.ReplicaModifications).withName("ReplicaModifications");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlSSEKMS = (input, context)=>{
const bodyNode = new XmlNode("SSE-KMS");
if (input.KeyId != null) {
const node = XmlNode.of("SSEKMSKeyId", input.KeyId).withName("KeyId");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlSseKmsEncryptedObjects = (input, context)=>{
const bodyNode = new XmlNode("SseKmsEncryptedObjects");
if (input.Status != null) {
const node = XmlNode.of("SseKmsEncryptedObjectsStatus", input.Status).withName("Status");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlSSES3 = (input, context)=>{
const bodyNode = new XmlNode("SSE-S3");
return bodyNode;
};
const serializeAws_restXmlStorageClassAnalysis = (input, context)=>{
const bodyNode = new XmlNode("StorageClassAnalysis");
if (input.DataExport != null) {
const node = serializeAws_restXmlStorageClassAnalysisDataExport(input.DataExport).withName("DataExport");
bodyNode.addChildNode(node);
}
return bodyNode;
};
const serializeAws_restXmlStorageClassAnalysisDataExport = (input, context)=>{
const bodyNode = new XmlNode("StorageClassAnalysisDataExport");
if (input.OutputSchemaVersion != null) {
const node = XmlNode.of("StorageClassAnalysisSchemaVersion", input.OutputSchemaVersion).withName("OutputSchemaVersion");
bodyNode.addChildNode(node);
}
if (input.Destination != null) {
const node1 = serializeAws_restXmlAnalyticsExportDestination(input.Destination).withName("Destination");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlTag = (input, context)=>{
const bodyNode = new XmlNode("Tag");
if (input.Key != null) {
const node = XmlNode.of("ObjectKey", input.Key).withName("Key");
bodyNode.addChildNode(node);
}
if (input.Value != null) {
const node1 = XmlNode.of("Value", input.Value).withName("Value");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlTagging = (input, context)=>{
const bodyNode = new XmlNode("Tagging");
if (input.TagSet != null) {
const nodes = serializeAws_restXmlTagSet(input.TagSet);
const containerNode = new XmlNode("TagSet");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
return bodyNode;
};
const serializeAws_restXmlTagSet = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlTag(entry);
return node.withName("Tag");
});
};
const serializeAws_restXmlTargetGrant = (input, context)=>{
const bodyNode = new XmlNode("TargetGrant");
if (input.Grantee != null) {
const node = serializeAws_restXmlGrantee(input.Grantee).withName("Grantee");
node.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
bodyNode.addChildNode(node);
}
if (input.Permission != null) {
const node1 = XmlNode.of("BucketLogsPermission", input.Permission).withName("Permission");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlTargetGrants = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlTargetGrant(entry);
return node.withName("Grant");
});
};
const serializeAws_restXmlTiering = (input, context)=>{
const bodyNode = new XmlNode("Tiering");
if (input.Days != null) {
const node = XmlNode.of("IntelligentTieringDays", String(input.Days)).withName("Days");
bodyNode.addChildNode(node);
}
if (input.AccessTier != null) {
const node1 = XmlNode.of("IntelligentTieringAccessTier", input.AccessTier).withName("AccessTier");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlTieringList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlTiering(entry);
return node.withName("member");
});
};
const serializeAws_restXmlTopicConfiguration = (input, context)=>{
const bodyNode = new XmlNode("TopicConfiguration");
if (input.Id != null) {
const node = XmlNode.of("NotificationId", input.Id).withName("Id");
bodyNode.addChildNode(node);
}
if (input.TopicArn != null) {
const node1 = XmlNode.of("TopicArn", input.TopicArn).withName("Topic");
bodyNode.addChildNode(node1);
}
if (input.Events != null) {
const nodes = serializeAws_restXmlEventList(input.Events);
nodes.map((node)=>{
node = node.withName("Event");
bodyNode.addChildNode(node);
});
}
if (input.Filter != null) {
const node2 = serializeAws_restXmlNotificationConfigurationFilter(input.Filter).withName("Filter");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlTopicConfigurationList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlTopicConfiguration(entry);
return node.withName("member");
});
};
const serializeAws_restXmlTransition = (input, context)=>{
const bodyNode = new XmlNode("Transition");
if (input.Date != null) {
const node = XmlNode.of("Date", input.Date.toISOString().split(".")[0] + "Z").withName("Date");
bodyNode.addChildNode(node);
}
if (input.Days != null) {
const node1 = XmlNode.of("Days", String(input.Days)).withName("Days");
bodyNode.addChildNode(node1);
}
if (input.StorageClass != null) {
const node2 = XmlNode.of("TransitionStorageClass", input.StorageClass).withName("StorageClass");
bodyNode.addChildNode(node2);
}
return bodyNode;
};
const serializeAws_restXmlTransitionList = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlTransition(entry);
return node.withName("member");
});
};
const serializeAws_restXmlUserMetadata = (input, context)=>{
return input.filter((e)=>e != null).map((entry)=>{
const node = serializeAws_restXmlMetadataEntry(entry);
return node.withName("MetadataEntry");
});
};
const serializeAws_restXmlVersioningConfiguration = (input, context)=>{
const bodyNode = new XmlNode("VersioningConfiguration");
if (input.MFADelete != null) {
const node = XmlNode.of("MFADelete", input.MFADelete).withName("MfaDelete");
bodyNode.addChildNode(node);
}
if (input.Status != null) {
const node1 = XmlNode.of("BucketVersioningStatus", input.Status).withName("Status");
bodyNode.addChildNode(node1);
}
return bodyNode;
};
const serializeAws_restXmlWebsiteConfiguration = (input, context)=>{
const bodyNode = new XmlNode("WebsiteConfiguration");
if (input.ErrorDocument != null) {
const node = serializeAws_restXmlErrorDocument(input.ErrorDocument).withName("ErrorDocument");
bodyNode.addChildNode(node);
}
if (input.IndexDocument != null) {
const node1 = serializeAws_restXmlIndexDocument(input.IndexDocument).withName("IndexDocument");
bodyNode.addChildNode(node1);
}
if (input.RedirectAllRequestsTo != null) {
const node2 = serializeAws_restXmlRedirectAllRequestsTo(input.RedirectAllRequestsTo).withName("RedirectAllRequestsTo");
bodyNode.addChildNode(node2);
}
if (input.RoutingRules != null) {
const nodes = serializeAws_restXmlRoutingRules(input.RoutingRules);
const containerNode = new XmlNode("RoutingRules");
nodes.map((node)=>{
containerNode.addChildNode(node);
});
bodyNode.addChildNode(containerNode);
}
return bodyNode;
};
const deserializeAws_restXmlAbortIncompleteMultipartUpload = (output, context)=>{
const contents = {
DaysAfterInitiation: void 0
};
if (output["DaysAfterInitiation"] !== void 0) {
contents.DaysAfterInitiation = strictParseInt32(output["DaysAfterInitiation"]);
}
return contents;
};
const deserializeAws_restXmlAccessControlTranslation = (output, context)=>{
const contents = {
Owner: void 0
};
if (output["Owner"] !== void 0) {
contents.Owner = expectString(output["Owner"]);
}
return contents;
};
const deserializeAws_restXmlAllowedHeaders = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlAllowedMethods = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlAllowedOrigins = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlAnalyticsAndOperator = (output, context)=>{
const contents = {
Prefix: void 0,
Tags: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Tag === "") {
contents.Tags = [];
} else if (output["Tag"] !== void 0) {
contents.Tags = deserializeAws_restXmlTagSet(getArrayIfSingleItem(output["Tag"]));
}
return contents;
};
const deserializeAws_restXmlAnalyticsConfiguration = (output, context)=>{
const contents = {
Id: void 0,
Filter: void 0,
StorageClassAnalysis: void 0
};
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output.Filter === "") ;
else if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlAnalyticsFilter(expectUnion(output["Filter"]));
}
if (output["StorageClassAnalysis"] !== void 0) {
contents.StorageClassAnalysis = deserializeAws_restXmlStorageClassAnalysis(output["StorageClassAnalysis"]);
}
return contents;
};
const deserializeAws_restXmlAnalyticsConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlAnalyticsConfiguration(entry);
});
};
const deserializeAws_restXmlAnalyticsExportDestination = (output, context)=>{
const contents = {
S3BucketDestination: void 0
};
if (output["S3BucketDestination"] !== void 0) {
contents.S3BucketDestination = deserializeAws_restXmlAnalyticsS3BucketDestination(output["S3BucketDestination"]);
}
return contents;
};
const deserializeAws_restXmlAnalyticsFilter = (output, context)=>{
if (output["Prefix"] !== void 0) {
return {
Prefix: expectString(output["Prefix"])
};
}
if (output["Tag"] !== void 0) {
return {
Tag: deserializeAws_restXmlTag(output["Tag"])
};
}
if (output["And"] !== void 0) {
return {
And: deserializeAws_restXmlAnalyticsAndOperator(output["And"])
};
}
return {
$unknown: Object.entries(output)[0]
};
};
const deserializeAws_restXmlAnalyticsS3BucketDestination = (output, context)=>{
const contents = {
Format: void 0,
BucketAccountId: void 0,
Bucket: void 0,
Prefix: void 0
};
if (output["Format"] !== void 0) {
contents.Format = expectString(output["Format"]);
}
if (output["BucketAccountId"] !== void 0) {
contents.BucketAccountId = expectString(output["BucketAccountId"]);
}
if (output["Bucket"] !== void 0) {
contents.Bucket = expectString(output["Bucket"]);
}
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
return contents;
};
const deserializeAws_restXmlBucket = (output, context)=>{
const contents = {
Name: void 0,
CreationDate: void 0
};
if (output["Name"] !== void 0) {
contents.Name = expectString(output["Name"]);
}
if (output["CreationDate"] !== void 0) {
contents.CreationDate = expectNonNull(parseRfc3339DateTime(output["CreationDate"]));
}
return contents;
};
const deserializeAws_restXmlBuckets = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlBucket(entry);
});
};
const deserializeAws_restXmlChecksum = (output, context)=>{
const contents = {
ChecksumCRC32: void 0,
ChecksumCRC32C: void 0,
ChecksumSHA1: void 0,
ChecksumSHA256: void 0
};
if (output["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(output["ChecksumCRC32"]);
}
if (output["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(output["ChecksumCRC32C"]);
}
if (output["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(output["ChecksumSHA1"]);
}
if (output["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(output["ChecksumSHA256"]);
}
return contents;
};
const deserializeAws_restXmlChecksumAlgorithmList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlCommonPrefix = (output, context)=>{
const contents = {
Prefix: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
return contents;
};
const deserializeAws_restXmlCommonPrefixList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlCommonPrefix(entry);
});
};
const deserializeAws_restXmlCondition = (output, context)=>{
const contents = {
HttpErrorCodeReturnedEquals: void 0,
KeyPrefixEquals: void 0
};
if (output["HttpErrorCodeReturnedEquals"] !== void 0) {
contents.HttpErrorCodeReturnedEquals = expectString(output["HttpErrorCodeReturnedEquals"]);
}
if (output["KeyPrefixEquals"] !== void 0) {
contents.KeyPrefixEquals = expectString(output["KeyPrefixEquals"]);
}
return contents;
};
const deserializeAws_restXmlContinuationEvent = (output, context)=>{
const contents = {};
return contents;
};
const deserializeAws_restXmlCopyObjectResult = (output, context)=>{
const contents = {
ETag: void 0,
LastModified: void 0,
ChecksumCRC32: void 0,
ChecksumCRC32C: void 0,
ChecksumSHA1: void 0,
ChecksumSHA256: void 0
};
if (output["ETag"] !== void 0) {
contents.ETag = expectString(output["ETag"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
if (output["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(output["ChecksumCRC32"]);
}
if (output["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(output["ChecksumCRC32C"]);
}
if (output["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(output["ChecksumSHA1"]);
}
if (output["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(output["ChecksumSHA256"]);
}
return contents;
};
const deserializeAws_restXmlCopyPartResult = (output, context)=>{
const contents = {
ETag: void 0,
LastModified: void 0,
ChecksumCRC32: void 0,
ChecksumCRC32C: void 0,
ChecksumSHA1: void 0,
ChecksumSHA256: void 0
};
if (output["ETag"] !== void 0) {
contents.ETag = expectString(output["ETag"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
if (output["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(output["ChecksumCRC32"]);
}
if (output["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(output["ChecksumCRC32C"]);
}
if (output["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(output["ChecksumSHA1"]);
}
if (output["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(output["ChecksumSHA256"]);
}
return contents;
};
const deserializeAws_restXmlCORSRule = (output, context)=>{
const contents = {
ID: void 0,
AllowedHeaders: void 0,
AllowedMethods: void 0,
AllowedOrigins: void 0,
ExposeHeaders: void 0,
MaxAgeSeconds: void 0
};
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
if (output.AllowedHeader === "") {
contents.AllowedHeaders = [];
} else if (output["AllowedHeader"] !== void 0) {
contents.AllowedHeaders = deserializeAws_restXmlAllowedHeaders(getArrayIfSingleItem(output["AllowedHeader"]));
}
if (output.AllowedMethod === "") {
contents.AllowedMethods = [];
} else if (output["AllowedMethod"] !== void 0) {
contents.AllowedMethods = deserializeAws_restXmlAllowedMethods(getArrayIfSingleItem(output["AllowedMethod"]));
}
if (output.AllowedOrigin === "") {
contents.AllowedOrigins = [];
} else if (output["AllowedOrigin"] !== void 0) {
contents.AllowedOrigins = deserializeAws_restXmlAllowedOrigins(getArrayIfSingleItem(output["AllowedOrigin"]));
}
if (output.ExposeHeader === "") {
contents.ExposeHeaders = [];
} else if (output["ExposeHeader"] !== void 0) {
contents.ExposeHeaders = deserializeAws_restXmlExposeHeaders(getArrayIfSingleItem(output["ExposeHeader"]));
}
if (output["MaxAgeSeconds"] !== void 0) {
contents.MaxAgeSeconds = strictParseInt32(output["MaxAgeSeconds"]);
}
return contents;
};
const deserializeAws_restXmlCORSRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlCORSRule(entry);
});
};
const deserializeAws_restXmlDefaultRetention = (output, context)=>{
const contents = {
Mode: void 0,
Days: void 0,
Years: void 0
};
if (output["Mode"] !== void 0) {
contents.Mode = expectString(output["Mode"]);
}
if (output["Days"] !== void 0) {
contents.Days = strictParseInt32(output["Days"]);
}
if (output["Years"] !== void 0) {
contents.Years = strictParseInt32(output["Years"]);
}
return contents;
};
const deserializeAws_restXmlDeletedObject = (output, context)=>{
const contents = {
Key: void 0,
VersionId: void 0,
DeleteMarker: void 0,
DeleteMarkerVersionId: void 0
};
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["VersionId"] !== void 0) {
contents.VersionId = expectString(output["VersionId"]);
}
if (output["DeleteMarker"] !== void 0) {
contents.DeleteMarker = parseBoolean(output["DeleteMarker"]);
}
if (output["DeleteMarkerVersionId"] !== void 0) {
contents.DeleteMarkerVersionId = expectString(output["DeleteMarkerVersionId"]);
}
return contents;
};
const deserializeAws_restXmlDeletedObjects = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlDeletedObject(entry);
});
};
const deserializeAws_restXmlDeleteMarkerEntry = (output, context)=>{
const contents = {
Owner: void 0,
Key: void 0,
VersionId: void 0,
IsLatest: void 0,
LastModified: void 0
};
if (output["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(output["Owner"]);
}
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["VersionId"] !== void 0) {
contents.VersionId = expectString(output["VersionId"]);
}
if (output["IsLatest"] !== void 0) {
contents.IsLatest = parseBoolean(output["IsLatest"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
return contents;
};
const deserializeAws_restXmlDeleteMarkerReplication = (output, context)=>{
const contents = {
Status: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
return contents;
};
const deserializeAws_restXmlDeleteMarkers = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlDeleteMarkerEntry(entry);
});
};
const deserializeAws_restXmlDestination = (output, context)=>{
const contents = {
Bucket: void 0,
Account: void 0,
StorageClass: void 0,
AccessControlTranslation: void 0,
EncryptionConfiguration: void 0,
ReplicationTime: void 0,
Metrics: void 0
};
if (output["Bucket"] !== void 0) {
contents.Bucket = expectString(output["Bucket"]);
}
if (output["Account"] !== void 0) {
contents.Account = expectString(output["Account"]);
}
if (output["StorageClass"] !== void 0) {
contents.StorageClass = expectString(output["StorageClass"]);
}
if (output["AccessControlTranslation"] !== void 0) {
contents.AccessControlTranslation = deserializeAws_restXmlAccessControlTranslation(output["AccessControlTranslation"]);
}
if (output["EncryptionConfiguration"] !== void 0) {
contents.EncryptionConfiguration = deserializeAws_restXmlEncryptionConfiguration(output["EncryptionConfiguration"]);
}
if (output["ReplicationTime"] !== void 0) {
contents.ReplicationTime = deserializeAws_restXmlReplicationTime(output["ReplicationTime"]);
}
if (output["Metrics"] !== void 0) {
contents.Metrics = deserializeAws_restXmlMetrics(output["Metrics"]);
}
return contents;
};
const deserializeAws_restXmlEncryptionConfiguration = (output, context)=>{
const contents = {
ReplicaKmsKeyID: void 0
};
if (output["ReplicaKmsKeyID"] !== void 0) {
contents.ReplicaKmsKeyID = expectString(output["ReplicaKmsKeyID"]);
}
return contents;
};
const deserializeAws_restXmlEndEvent = (output, context)=>{
const contents = {};
return contents;
};
const deserializeAws_restXml_Error = (output, context)=>{
const contents = {
Key: void 0,
VersionId: void 0,
Code: void 0,
Message: void 0
};
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["VersionId"] !== void 0) {
contents.VersionId = expectString(output["VersionId"]);
}
if (output["Code"] !== void 0) {
contents.Code = expectString(output["Code"]);
}
if (output["Message"] !== void 0) {
contents.Message = expectString(output["Message"]);
}
return contents;
};
const deserializeAws_restXmlErrorDocument = (output, context)=>{
const contents = {
Key: void 0
};
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
return contents;
};
const deserializeAws_restXmlErrors = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXml_Error(entry);
});
};
const deserializeAws_restXmlEventBridgeConfiguration = (output, context)=>{
const contents = {};
return contents;
};
const deserializeAws_restXmlEventList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlExistingObjectReplication = (output, context)=>{
const contents = {
Status: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
return contents;
};
const deserializeAws_restXmlExposeHeaders = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlFilterRule = (output, context)=>{
const contents = {
Name: void 0,
Value: void 0
};
if (output["Name"] !== void 0) {
contents.Name = expectString(output["Name"]);
}
if (output["Value"] !== void 0) {
contents.Value = expectString(output["Value"]);
}
return contents;
};
const deserializeAws_restXmlFilterRuleList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlFilterRule(entry);
});
};
const deserializeAws_restXmlGetObjectAttributesParts = (output, context)=>{
const contents = {
TotalPartsCount: void 0,
PartNumberMarker: void 0,
NextPartNumberMarker: void 0,
MaxParts: void 0,
IsTruncated: void 0,
Parts: void 0
};
if (output["PartsCount"] !== void 0) {
contents.TotalPartsCount = strictParseInt32(output["PartsCount"]);
}
if (output["PartNumberMarker"] !== void 0) {
contents.PartNumberMarker = expectString(output["PartNumberMarker"]);
}
if (output["NextPartNumberMarker"] !== void 0) {
contents.NextPartNumberMarker = expectString(output["NextPartNumberMarker"]);
}
if (output["MaxParts"] !== void 0) {
contents.MaxParts = strictParseInt32(output["MaxParts"]);
}
if (output["IsTruncated"] !== void 0) {
contents.IsTruncated = parseBoolean(output["IsTruncated"]);
}
if (output.Part === "") {
contents.Parts = [];
} else if (output["Part"] !== void 0) {
contents.Parts = deserializeAws_restXmlPartsList(getArrayIfSingleItem(output["Part"]));
}
return contents;
};
const deserializeAws_restXmlGrant = (output, context)=>{
const contents = {
Grantee: void 0,
Permission: void 0
};
if (output["Grantee"] !== void 0) {
contents.Grantee = deserializeAws_restXmlGrantee(output["Grantee"]);
}
if (output["Permission"] !== void 0) {
contents.Permission = expectString(output["Permission"]);
}
return contents;
};
const deserializeAws_restXmlGrantee = (output, context)=>{
const contents = {
DisplayName: void 0,
EmailAddress: void 0,
ID: void 0,
URI: void 0,
Type: void 0
};
if (output["DisplayName"] !== void 0) {
contents.DisplayName = expectString(output["DisplayName"]);
}
if (output["EmailAddress"] !== void 0) {
contents.EmailAddress = expectString(output["EmailAddress"]);
}
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
if (output["URI"] !== void 0) {
contents.URI = expectString(output["URI"]);
}
if (output["xsi:type"] !== void 0) {
contents.Type = expectString(output["xsi:type"]);
}
return contents;
};
const deserializeAws_restXmlGrants = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlGrant(entry);
});
};
const deserializeAws_restXmlIndexDocument = (output, context)=>{
const contents = {
Suffix: void 0
};
if (output["Suffix"] !== void 0) {
contents.Suffix = expectString(output["Suffix"]);
}
return contents;
};
const deserializeAws_restXmlInitiator = (output, context)=>{
const contents = {
ID: void 0,
DisplayName: void 0
};
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
if (output["DisplayName"] !== void 0) {
contents.DisplayName = expectString(output["DisplayName"]);
}
return contents;
};
const deserializeAws_restXmlIntelligentTieringAndOperator = (output, context)=>{
const contents = {
Prefix: void 0,
Tags: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Tag === "") {
contents.Tags = [];
} else if (output["Tag"] !== void 0) {
contents.Tags = deserializeAws_restXmlTagSet(getArrayIfSingleItem(output["Tag"]));
}
return contents;
};
const deserializeAws_restXmlIntelligentTieringConfiguration = (output, context)=>{
const contents = {
Id: void 0,
Filter: void 0,
Status: void 0,
Tierings: void 0
};
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlIntelligentTieringFilter(output["Filter"]);
}
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
if (output.Tiering === "") {
contents.Tierings = [];
} else if (output["Tiering"] !== void 0) {
contents.Tierings = deserializeAws_restXmlTieringList(getArrayIfSingleItem(output["Tiering"]));
}
return contents;
};
const deserializeAws_restXmlIntelligentTieringConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlIntelligentTieringConfiguration(entry);
});
};
const deserializeAws_restXmlIntelligentTieringFilter = (output, context)=>{
const contents = {
Prefix: void 0,
Tag: void 0,
And: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output["Tag"] !== void 0) {
contents.Tag = deserializeAws_restXmlTag(output["Tag"]);
}
if (output["And"] !== void 0) {
contents.And = deserializeAws_restXmlIntelligentTieringAndOperator(output["And"]);
}
return contents;
};
const deserializeAws_restXmlInventoryConfiguration = (output, context)=>{
const contents = {
Destination: void 0,
IsEnabled: void 0,
Filter: void 0,
Id: void 0,
IncludedObjectVersions: void 0,
OptionalFields: void 0,
Schedule: void 0
};
if (output["Destination"] !== void 0) {
contents.Destination = deserializeAws_restXmlInventoryDestination(output["Destination"]);
}
if (output["IsEnabled"] !== void 0) {
contents.IsEnabled = parseBoolean(output["IsEnabled"]);
}
if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlInventoryFilter(output["Filter"]);
}
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output["IncludedObjectVersions"] !== void 0) {
contents.IncludedObjectVersions = expectString(output["IncludedObjectVersions"]);
}
if (output.OptionalFields === "") {
contents.OptionalFields = [];
} else if (output["OptionalFields"] !== void 0 && output["OptionalFields"]["Field"] !== void 0) {
contents.OptionalFields = deserializeAws_restXmlInventoryOptionalFields(getArrayIfSingleItem(output["OptionalFields"]["Field"]));
}
if (output["Schedule"] !== void 0) {
contents.Schedule = deserializeAws_restXmlInventorySchedule(output["Schedule"]);
}
return contents;
};
const deserializeAws_restXmlInventoryConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlInventoryConfiguration(entry);
});
};
const deserializeAws_restXmlInventoryDestination = (output, context)=>{
const contents = {
S3BucketDestination: void 0
};
if (output["S3BucketDestination"] !== void 0) {
contents.S3BucketDestination = deserializeAws_restXmlInventoryS3BucketDestination(output["S3BucketDestination"]);
}
return contents;
};
const deserializeAws_restXmlInventoryEncryption = (output, context)=>{
const contents = {
SSES3: void 0,
SSEKMS: void 0
};
if (output["SSE-S3"] !== void 0) {
contents.SSES3 = deserializeAws_restXmlSSES3(output["SSE-S3"]);
}
if (output["SSE-KMS"] !== void 0) {
contents.SSEKMS = deserializeAws_restXmlSSEKMS(output["SSE-KMS"]);
}
return contents;
};
const deserializeAws_restXmlInventoryFilter = (output, context)=>{
const contents = {
Prefix: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
return contents;
};
const deserializeAws_restXmlInventoryOptionalFields = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return expectString(entry);
});
};
const deserializeAws_restXmlInventoryS3BucketDestination = (output, context)=>{
const contents = {
AccountId: void 0,
Bucket: void 0,
Format: void 0,
Prefix: void 0,
Encryption: void 0
};
if (output["AccountId"] !== void 0) {
contents.AccountId = expectString(output["AccountId"]);
}
if (output["Bucket"] !== void 0) {
contents.Bucket = expectString(output["Bucket"]);
}
if (output["Format"] !== void 0) {
contents.Format = expectString(output["Format"]);
}
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output["Encryption"] !== void 0) {
contents.Encryption = deserializeAws_restXmlInventoryEncryption(output["Encryption"]);
}
return contents;
};
const deserializeAws_restXmlInventorySchedule = (output, context)=>{
const contents = {
Frequency: void 0
};
if (output["Frequency"] !== void 0) {
contents.Frequency = expectString(output["Frequency"]);
}
return contents;
};
const deserializeAws_restXmlLambdaFunctionConfiguration = (output, context)=>{
const contents = {
Id: void 0,
LambdaFunctionArn: void 0,
Events: void 0,
Filter: void 0
};
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output["CloudFunction"] !== void 0) {
contents.LambdaFunctionArn = expectString(output["CloudFunction"]);
}
if (output.Event === "") {
contents.Events = [];
} else if (output["Event"] !== void 0) {
contents.Events = deserializeAws_restXmlEventList(getArrayIfSingleItem(output["Event"]));
}
if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlNotificationConfigurationFilter(output["Filter"]);
}
return contents;
};
const deserializeAws_restXmlLambdaFunctionConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlLambdaFunctionConfiguration(entry);
});
};
const deserializeAws_restXmlLifecycleExpiration = (output, context)=>{
const contents = {
Date: void 0,
Days: void 0,
ExpiredObjectDeleteMarker: void 0
};
if (output["Date"] !== void 0) {
contents.Date = expectNonNull(parseRfc3339DateTime(output["Date"]));
}
if (output["Days"] !== void 0) {
contents.Days = strictParseInt32(output["Days"]);
}
if (output["ExpiredObjectDeleteMarker"] !== void 0) {
contents.ExpiredObjectDeleteMarker = parseBoolean(output["ExpiredObjectDeleteMarker"]);
}
return contents;
};
const deserializeAws_restXmlLifecycleRule = (output, context)=>{
const contents = {
Expiration: void 0,
ID: void 0,
Prefix: void 0,
Filter: void 0,
Status: void 0,
Transitions: void 0,
NoncurrentVersionTransitions: void 0,
NoncurrentVersionExpiration: void 0,
AbortIncompleteMultipartUpload: void 0
};
if (output["Expiration"] !== void 0) {
contents.Expiration = deserializeAws_restXmlLifecycleExpiration(output["Expiration"]);
}
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Filter === "") ;
else if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlLifecycleRuleFilter(expectUnion(output["Filter"]));
}
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
if (output.Transition === "") {
contents.Transitions = [];
} else if (output["Transition"] !== void 0) {
contents.Transitions = deserializeAws_restXmlTransitionList(getArrayIfSingleItem(output["Transition"]));
}
if (output.NoncurrentVersionTransition === "") {
contents.NoncurrentVersionTransitions = [];
} else if (output["NoncurrentVersionTransition"] !== void 0) {
contents.NoncurrentVersionTransitions = deserializeAws_restXmlNoncurrentVersionTransitionList(getArrayIfSingleItem(output["NoncurrentVersionTransition"]));
}
if (output["NoncurrentVersionExpiration"] !== void 0) {
contents.NoncurrentVersionExpiration = deserializeAws_restXmlNoncurrentVersionExpiration(output["NoncurrentVersionExpiration"]);
}
if (output["AbortIncompleteMultipartUpload"] !== void 0) {
contents.AbortIncompleteMultipartUpload = deserializeAws_restXmlAbortIncompleteMultipartUpload(output["AbortIncompleteMultipartUpload"]);
}
return contents;
};
const deserializeAws_restXmlLifecycleRuleAndOperator = (output, context)=>{
const contents = {
Prefix: void 0,
Tags: void 0,
ObjectSizeGreaterThan: void 0,
ObjectSizeLessThan: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Tag === "") {
contents.Tags = [];
} else if (output["Tag"] !== void 0) {
contents.Tags = deserializeAws_restXmlTagSet(getArrayIfSingleItem(output["Tag"]));
}
if (output["ObjectSizeGreaterThan"] !== void 0) {
contents.ObjectSizeGreaterThan = strictParseLong(output["ObjectSizeGreaterThan"]);
}
if (output["ObjectSizeLessThan"] !== void 0) {
contents.ObjectSizeLessThan = strictParseLong(output["ObjectSizeLessThan"]);
}
return contents;
};
const deserializeAws_restXmlLifecycleRuleFilter = (output, context)=>{
if (output["Prefix"] !== void 0) {
return {
Prefix: expectString(output["Prefix"])
};
}
if (output["Tag"] !== void 0) {
return {
Tag: deserializeAws_restXmlTag(output["Tag"])
};
}
if (output["ObjectSizeGreaterThan"] !== void 0) {
return {
ObjectSizeGreaterThan: strictParseLong(output["ObjectSizeGreaterThan"])
};
}
if (output["ObjectSizeLessThan"] !== void 0) {
return {
ObjectSizeLessThan: strictParseLong(output["ObjectSizeLessThan"])
};
}
if (output["And"] !== void 0) {
return {
And: deserializeAws_restXmlLifecycleRuleAndOperator(output["And"])
};
}
return {
$unknown: Object.entries(output)[0]
};
};
const deserializeAws_restXmlLifecycleRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlLifecycleRule(entry);
});
};
const deserializeAws_restXmlLoggingEnabled = (output, context)=>{
const contents = {
TargetBucket: void 0,
TargetGrants: void 0,
TargetPrefix: void 0
};
if (output["TargetBucket"] !== void 0) {
contents.TargetBucket = expectString(output["TargetBucket"]);
}
if (output.TargetGrants === "") {
contents.TargetGrants = [];
} else if (output["TargetGrants"] !== void 0 && output["TargetGrants"]["Grant"] !== void 0) {
contents.TargetGrants = deserializeAws_restXmlTargetGrants(getArrayIfSingleItem(output["TargetGrants"]["Grant"]));
}
if (output["TargetPrefix"] !== void 0) {
contents.TargetPrefix = expectString(output["TargetPrefix"]);
}
return contents;
};
const deserializeAws_restXmlMetrics = (output, context)=>{
const contents = {
Status: void 0,
EventThreshold: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
if (output["EventThreshold"] !== void 0) {
contents.EventThreshold = deserializeAws_restXmlReplicationTimeValue(output["EventThreshold"]);
}
return contents;
};
const deserializeAws_restXmlMetricsAndOperator = (output, context)=>{
const contents = {
Prefix: void 0,
Tags: void 0,
AccessPointArn: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Tag === "") {
contents.Tags = [];
} else if (output["Tag"] !== void 0) {
contents.Tags = deserializeAws_restXmlTagSet(getArrayIfSingleItem(output["Tag"]));
}
if (output["AccessPointArn"] !== void 0) {
contents.AccessPointArn = expectString(output["AccessPointArn"]);
}
return contents;
};
const deserializeAws_restXmlMetricsConfiguration = (output, context)=>{
const contents = {
Id: void 0,
Filter: void 0
};
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output.Filter === "") ;
else if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlMetricsFilter(expectUnion(output["Filter"]));
}
return contents;
};
const deserializeAws_restXmlMetricsConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlMetricsConfiguration(entry);
});
};
const deserializeAws_restXmlMetricsFilter = (output, context)=>{
if (output["Prefix"] !== void 0) {
return {
Prefix: expectString(output["Prefix"])
};
}
if (output["Tag"] !== void 0) {
return {
Tag: deserializeAws_restXmlTag(output["Tag"])
};
}
if (output["AccessPointArn"] !== void 0) {
return {
AccessPointArn: expectString(output["AccessPointArn"])
};
}
if (output["And"] !== void 0) {
return {
And: deserializeAws_restXmlMetricsAndOperator(output["And"])
};
}
return {
$unknown: Object.entries(output)[0]
};
};
const deserializeAws_restXmlMultipartUpload = (output, context)=>{
const contents = {
UploadId: void 0,
Key: void 0,
Initiated: void 0,
StorageClass: void 0,
Owner: void 0,
Initiator: void 0,
ChecksumAlgorithm: void 0
};
if (output["UploadId"] !== void 0) {
contents.UploadId = expectString(output["UploadId"]);
}
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["Initiated"] !== void 0) {
contents.Initiated = expectNonNull(parseRfc3339DateTime(output["Initiated"]));
}
if (output["StorageClass"] !== void 0) {
contents.StorageClass = expectString(output["StorageClass"]);
}
if (output["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(output["Owner"]);
}
if (output["Initiator"] !== void 0) {
contents.Initiator = deserializeAws_restXmlInitiator(output["Initiator"]);
}
if (output["ChecksumAlgorithm"] !== void 0) {
contents.ChecksumAlgorithm = expectString(output["ChecksumAlgorithm"]);
}
return contents;
};
const deserializeAws_restXmlMultipartUploadList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlMultipartUpload(entry);
});
};
const deserializeAws_restXmlNoncurrentVersionExpiration = (output, context)=>{
const contents = {
NoncurrentDays: void 0,
NewerNoncurrentVersions: void 0
};
if (output["NoncurrentDays"] !== void 0) {
contents.NoncurrentDays = strictParseInt32(output["NoncurrentDays"]);
}
if (output["NewerNoncurrentVersions"] !== void 0) {
contents.NewerNoncurrentVersions = strictParseInt32(output["NewerNoncurrentVersions"]);
}
return contents;
};
const deserializeAws_restXmlNoncurrentVersionTransition = (output, context)=>{
const contents = {
NoncurrentDays: void 0,
StorageClass: void 0,
NewerNoncurrentVersions: void 0
};
if (output["NoncurrentDays"] !== void 0) {
contents.NoncurrentDays = strictParseInt32(output["NoncurrentDays"]);
}
if (output["StorageClass"] !== void 0) {
contents.StorageClass = expectString(output["StorageClass"]);
}
if (output["NewerNoncurrentVersions"] !== void 0) {
contents.NewerNoncurrentVersions = strictParseInt32(output["NewerNoncurrentVersions"]);
}
return contents;
};
const deserializeAws_restXmlNoncurrentVersionTransitionList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlNoncurrentVersionTransition(entry);
});
};
const deserializeAws_restXmlNotificationConfigurationFilter = (output, context)=>{
const contents = {
Key: void 0
};
if (output["S3Key"] !== void 0) {
contents.Key = deserializeAws_restXmlS3KeyFilter(output["S3Key"]);
}
return contents;
};
const deserializeAws_restXml_Object = (output, context)=>{
const contents = {
Key: void 0,
LastModified: void 0,
ETag: void 0,
ChecksumAlgorithm: void 0,
Size: void 0,
StorageClass: void 0,
Owner: void 0
};
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
if (output["ETag"] !== void 0) {
contents.ETag = expectString(output["ETag"]);
}
if (output.ChecksumAlgorithm === "") {
contents.ChecksumAlgorithm = [];
} else if (output["ChecksumAlgorithm"] !== void 0) {
contents.ChecksumAlgorithm = deserializeAws_restXmlChecksumAlgorithmList(getArrayIfSingleItem(output["ChecksumAlgorithm"]));
}
if (output["Size"] !== void 0) {
contents.Size = strictParseLong(output["Size"]);
}
if (output["StorageClass"] !== void 0) {
contents.StorageClass = expectString(output["StorageClass"]);
}
if (output["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(output["Owner"]);
}
return contents;
};
const deserializeAws_restXmlObjectList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXml_Object(entry);
});
};
const deserializeAws_restXmlObjectLockConfiguration = (output, context)=>{
const contents = {
ObjectLockEnabled: void 0,
Rule: void 0
};
if (output["ObjectLockEnabled"] !== void 0) {
contents.ObjectLockEnabled = expectString(output["ObjectLockEnabled"]);
}
if (output["Rule"] !== void 0) {
contents.Rule = deserializeAws_restXmlObjectLockRule(output["Rule"]);
}
return contents;
};
const deserializeAws_restXmlObjectLockLegalHold = (output, context)=>{
const contents = {
Status: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
return contents;
};
const deserializeAws_restXmlObjectLockRetention = (output, context)=>{
const contents = {
Mode: void 0,
RetainUntilDate: void 0
};
if (output["Mode"] !== void 0) {
contents.Mode = expectString(output["Mode"]);
}
if (output["RetainUntilDate"] !== void 0) {
contents.RetainUntilDate = expectNonNull(parseRfc3339DateTime(output["RetainUntilDate"]));
}
return contents;
};
const deserializeAws_restXmlObjectLockRule = (output, context)=>{
const contents = {
DefaultRetention: void 0
};
if (output["DefaultRetention"] !== void 0) {
contents.DefaultRetention = deserializeAws_restXmlDefaultRetention(output["DefaultRetention"]);
}
return contents;
};
const deserializeAws_restXmlObjectPart = (output, context)=>{
const contents = {
PartNumber: void 0,
Size: void 0,
ChecksumCRC32: void 0,
ChecksumCRC32C: void 0,
ChecksumSHA1: void 0,
ChecksumSHA256: void 0
};
if (output["PartNumber"] !== void 0) {
contents.PartNumber = strictParseInt32(output["PartNumber"]);
}
if (output["Size"] !== void 0) {
contents.Size = strictParseLong(output["Size"]);
}
if (output["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(output["ChecksumCRC32"]);
}
if (output["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(output["ChecksumCRC32C"]);
}
if (output["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(output["ChecksumSHA1"]);
}
if (output["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(output["ChecksumSHA256"]);
}
return contents;
};
const deserializeAws_restXmlObjectVersion = (output, context)=>{
const contents = {
ETag: void 0,
ChecksumAlgorithm: void 0,
Size: void 0,
StorageClass: void 0,
Key: void 0,
VersionId: void 0,
IsLatest: void 0,
LastModified: void 0,
Owner: void 0
};
if (output["ETag"] !== void 0) {
contents.ETag = expectString(output["ETag"]);
}
if (output.ChecksumAlgorithm === "") {
contents.ChecksumAlgorithm = [];
} else if (output["ChecksumAlgorithm"] !== void 0) {
contents.ChecksumAlgorithm = deserializeAws_restXmlChecksumAlgorithmList(getArrayIfSingleItem(output["ChecksumAlgorithm"]));
}
if (output["Size"] !== void 0) {
contents.Size = strictParseLong(output["Size"]);
}
if (output["StorageClass"] !== void 0) {
contents.StorageClass = expectString(output["StorageClass"]);
}
if (output["Key"] !== void 0) {
contents.Key = expectString(output["Key"]);
}
if (output["VersionId"] !== void 0) {
contents.VersionId = expectString(output["VersionId"]);
}
if (output["IsLatest"] !== void 0) {
contents.IsLatest = parseBoolean(output["IsLatest"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
if (output["Owner"] !== void 0) {
contents.Owner = deserializeAws_restXmlOwner(output["Owner"]);
}
return contents;
};
const deserializeAws_restXmlObjectVersionList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlObjectVersion(entry);
});
};
const deserializeAws_restXmlOwner = (output, context)=>{
const contents = {
DisplayName: void 0,
ID: void 0
};
if (output["DisplayName"] !== void 0) {
contents.DisplayName = expectString(output["DisplayName"]);
}
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
return contents;
};
const deserializeAws_restXmlOwnershipControls = (output, context)=>{
const contents = {
Rules: void 0
};
if (output.Rule === "") {
contents.Rules = [];
} else if (output["Rule"] !== void 0) {
contents.Rules = deserializeAws_restXmlOwnershipControlsRules(getArrayIfSingleItem(output["Rule"]));
}
return contents;
};
const deserializeAws_restXmlOwnershipControlsRule = (output, context)=>{
const contents = {
ObjectOwnership: void 0
};
if (output["ObjectOwnership"] !== void 0) {
contents.ObjectOwnership = expectString(output["ObjectOwnership"]);
}
return contents;
};
const deserializeAws_restXmlOwnershipControlsRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlOwnershipControlsRule(entry);
});
};
const deserializeAws_restXmlPart = (output, context)=>{
const contents = {
PartNumber: void 0,
LastModified: void 0,
ETag: void 0,
Size: void 0,
ChecksumCRC32: void 0,
ChecksumCRC32C: void 0,
ChecksumSHA1: void 0,
ChecksumSHA256: void 0
};
if (output["PartNumber"] !== void 0) {
contents.PartNumber = strictParseInt32(output["PartNumber"]);
}
if (output["LastModified"] !== void 0) {
contents.LastModified = expectNonNull(parseRfc3339DateTime(output["LastModified"]));
}
if (output["ETag"] !== void 0) {
contents.ETag = expectString(output["ETag"]);
}
if (output["Size"] !== void 0) {
contents.Size = strictParseLong(output["Size"]);
}
if (output["ChecksumCRC32"] !== void 0) {
contents.ChecksumCRC32 = expectString(output["ChecksumCRC32"]);
}
if (output["ChecksumCRC32C"] !== void 0) {
contents.ChecksumCRC32C = expectString(output["ChecksumCRC32C"]);
}
if (output["ChecksumSHA1"] !== void 0) {
contents.ChecksumSHA1 = expectString(output["ChecksumSHA1"]);
}
if (output["ChecksumSHA256"] !== void 0) {
contents.ChecksumSHA256 = expectString(output["ChecksumSHA256"]);
}
return contents;
};
const deserializeAws_restXmlParts = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlPart(entry);
});
};
const deserializeAws_restXmlPartsList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlObjectPart(entry);
});
};
const deserializeAws_restXmlPolicyStatus = (output, context)=>{
const contents = {
IsPublic: void 0
};
if (output["IsPublic"] !== void 0) {
contents.IsPublic = parseBoolean(output["IsPublic"]);
}
return contents;
};
const deserializeAws_restXmlProgress = (output, context)=>{
const contents = {
BytesScanned: void 0,
BytesProcessed: void 0,
BytesReturned: void 0
};
if (output["BytesScanned"] !== void 0) {
contents.BytesScanned = strictParseLong(output["BytesScanned"]);
}
if (output["BytesProcessed"] !== void 0) {
contents.BytesProcessed = strictParseLong(output["BytesProcessed"]);
}
if (output["BytesReturned"] !== void 0) {
contents.BytesReturned = strictParseLong(output["BytesReturned"]);
}
return contents;
};
const deserializeAws_restXmlPublicAccessBlockConfiguration = (output, context)=>{
const contents = {
BlockPublicAcls: void 0,
IgnorePublicAcls: void 0,
BlockPublicPolicy: void 0,
RestrictPublicBuckets: void 0
};
if (output["BlockPublicAcls"] !== void 0) {
contents.BlockPublicAcls = parseBoolean(output["BlockPublicAcls"]);
}
if (output["IgnorePublicAcls"] !== void 0) {
contents.IgnorePublicAcls = parseBoolean(output["IgnorePublicAcls"]);
}
if (output["BlockPublicPolicy"] !== void 0) {
contents.BlockPublicPolicy = parseBoolean(output["BlockPublicPolicy"]);
}
if (output["RestrictPublicBuckets"] !== void 0) {
contents.RestrictPublicBuckets = parseBoolean(output["RestrictPublicBuckets"]);
}
return contents;
};
const deserializeAws_restXmlQueueConfiguration = (output, context)=>{
const contents = {
Id: void 0,
QueueArn: void 0,
Events: void 0,
Filter: void 0
};
if (output["Id"] !== void 0) {
contents.Id = expectString(output["Id"]);
}
if (output["Queue"] !== void 0) {
contents.QueueArn = expectString(output["Queue"]);
}
if (output.Event === "") {
contents.Events = [];
} else if (output["Event"] !== void 0) {
contents.Events = deserializeAws_restXmlEventList(getArrayIfSingleItem(output["Event"]));
}
if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlNotificationConfigurationFilter(output["Filter"]);
}
return contents;
};
const deserializeAws_restXmlQueueConfigurationList = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlQueueConfiguration(entry);
});
};
const deserializeAws_restXmlRedirect = (output, context)=>{
const contents = {
HostName: void 0,
HttpRedirectCode: void 0,
Protocol: void 0,
ReplaceKeyPrefixWith: void 0,
ReplaceKeyWith: void 0
};
if (output["HostName"] !== void 0) {
contents.HostName = expectString(output["HostName"]);
}
if (output["HttpRedirectCode"] !== void 0) {
contents.HttpRedirectCode = expectString(output["HttpRedirectCode"]);
}
if (output["Protocol"] !== void 0) {
contents.Protocol = expectString(output["Protocol"]);
}
if (output["ReplaceKeyPrefixWith"] !== void 0) {
contents.ReplaceKeyPrefixWith = expectString(output["ReplaceKeyPrefixWith"]);
}
if (output["ReplaceKeyWith"] !== void 0) {
contents.ReplaceKeyWith = expectString(output["ReplaceKeyWith"]);
}
return contents;
};
const deserializeAws_restXmlRedirectAllRequestsTo = (output, context)=>{
const contents = {
HostName: void 0,
Protocol: void 0
};
if (output["HostName"] !== void 0) {
contents.HostName = expectString(output["HostName"]);
}
if (output["Protocol"] !== void 0) {
contents.Protocol = expectString(output["Protocol"]);
}
return contents;
};
const deserializeAws_restXmlReplicaModifications = (output, context)=>{
const contents = {
Status: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
return contents;
};
const deserializeAws_restXmlReplicationConfiguration = (output, context)=>{
const contents = {
Role: void 0,
Rules: void 0
};
if (output["Role"] !== void 0) {
contents.Role = expectString(output["Role"]);
}
if (output.Rule === "") {
contents.Rules = [];
} else if (output["Rule"] !== void 0) {
contents.Rules = deserializeAws_restXmlReplicationRules(getArrayIfSingleItem(output["Rule"]));
}
return contents;
};
const deserializeAws_restXmlReplicationRule = (output, context)=>{
const contents = {
ID: void 0,
Priority: void 0,
Prefix: void 0,
Filter: void 0,
Status: void 0,
SourceSelectionCriteria: void 0,
ExistingObjectReplication: void 0,
Destination: void 0,
DeleteMarkerReplication: void 0
};
if (output["ID"] !== void 0) {
contents.ID = expectString(output["ID"]);
}
if (output["Priority"] !== void 0) {
contents.Priority = strictParseInt32(output["Priority"]);
}
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Filter === "") ;
else if (output["Filter"] !== void 0) {
contents.Filter = deserializeAws_restXmlReplicationRuleFilter(expectUnion(output["Filter"]));
}
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
if (output["SourceSelectionCriteria"] !== void 0) {
contents.SourceSelectionCriteria = deserializeAws_restXmlSourceSelectionCriteria(output["SourceSelectionCriteria"]);
}
if (output["ExistingObjectReplication"] !== void 0) {
contents.ExistingObjectReplication = deserializeAws_restXmlExistingObjectReplication(output["ExistingObjectReplication"]);
}
if (output["Destination"] !== void 0) {
contents.Destination = deserializeAws_restXmlDestination(output["Destination"]);
}
if (output["DeleteMarkerReplication"] !== void 0) {
contents.DeleteMarkerReplication = deserializeAws_restXmlDeleteMarkerReplication(output["DeleteMarkerReplication"]);
}
return contents;
};
const deserializeAws_restXmlReplicationRuleAndOperator = (output, context)=>{
const contents = {
Prefix: void 0,
Tags: void 0
};
if (output["Prefix"] !== void 0) {
contents.Prefix = expectString(output["Prefix"]);
}
if (output.Tag === "") {
contents.Tags = [];
} else if (output["Tag"] !== void 0) {
contents.Tags = deserializeAws_restXmlTagSet(getArrayIfSingleItem(output["Tag"]));
}
return contents;
};
const deserializeAws_restXmlReplicationRuleFilter = (output, context)=>{
if (output["Prefix"] !== void 0) {
return {
Prefix: expectString(output["Prefix"])
};
}
if (output["Tag"] !== void 0) {
return {
Tag: deserializeAws_restXmlTag(output["Tag"])
};
}
if (output["And"] !== void 0) {
return {
And: deserializeAws_restXmlReplicationRuleAndOperator(output["And"])
};
}
return {
$unknown: Object.entries(output)[0]
};
};
const deserializeAws_restXmlReplicationRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlReplicationRule(entry);
});
};
const deserializeAws_restXmlReplicationTime = (output, context)=>{
const contents = {
Status: void 0,
Time: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
if (output["Time"] !== void 0) {
contents.Time = deserializeAws_restXmlReplicationTimeValue(output["Time"]);
}
return contents;
};
const deserializeAws_restXmlReplicationTimeValue = (output, context)=>{
const contents = {
Minutes: void 0
};
if (output["Minutes"] !== void 0) {
contents.Minutes = strictParseInt32(output["Minutes"]);
}
return contents;
};
const deserializeAws_restXmlRoutingRule = (output, context)=>{
const contents = {
Condition: void 0,
Redirect: void 0
};
if (output["Condition"] !== void 0) {
contents.Condition = deserializeAws_restXmlCondition(output["Condition"]);
}
if (output["Redirect"] !== void 0) {
contents.Redirect = deserializeAws_restXmlRedirect(output["Redirect"]);
}
return contents;
};
const deserializeAws_restXmlRoutingRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlRoutingRule(entry);
});
};
const deserializeAws_restXmlS3KeyFilter = (output, context)=>{
const contents = {
FilterRules: void 0
};
if (output.FilterRule === "") {
contents.FilterRules = [];
} else if (output["FilterRule"] !== void 0) {
contents.FilterRules = deserializeAws_restXmlFilterRuleList(getArrayIfSingleItem(output["FilterRule"]));
}
return contents;
};
const deserializeAws_restXmlServerSideEncryptionByDefault = (output, context)=>{
const contents = {
SSEAlgorithm: void 0,
KMSMasterKeyID: void 0
};
if (output["SSEAlgorithm"] !== void 0) {
contents.SSEAlgorithm = expectString(output["SSEAlgorithm"]);
}
if (output["KMSMasterKeyID"] !== void 0) {
contents.KMSMasterKeyID = expectString(output["KMSMasterKeyID"]);
}
return contents;
};
const deserializeAws_restXmlServerSideEncryptionConfiguration = (output, context)=>{
const contents = {
Rules: void 0
};
if (output.Rule === "") {
contents.Rules = [];
} else if (output["Rule"] !== void 0) {
contents.Rules = deserializeAws_restXmlServerSideEncryptionRules(getArrayIfSingleItem(output["Rule"]));
}
return contents;
};
const deserializeAws_restXmlServerSideEncryptionRule = (output, context)=>{
const contents = {
ApplyServerSideEncryptionByDefault: void 0,
BucketKeyEnabled: void 0
};
if (output["ApplyServerSideEncryptionByDefault"] !== void 0) {
contents.ApplyServerSideEncryptionByDefault = deserializeAws_restXmlServerSideEncryptionByDefault(output["ApplyServerSideEncryptionByDefault"]);
}
if (output["BucketKeyEnabled"] !== void 0) {
contents.BucketKeyEnabled = parseBoolean(output["BucketKeyEnabled"]);
}
return contents;
};
const deserializeAws_restXmlServerSideEncryptionRules = (output, context)=>{
return (output || []).filter((e)=>e != null).map((entry)=>{
return deserializeAws_restXmlServerSideEncryptionRule(entry);
});
};
const deserializeAws_restXmlSourceSelectionCriteria = (output, context)=>{
const contents = {
SseKmsEncryptedObjects: void 0,
ReplicaModifications: void 0
};
if (output["SseKmsEncryptedObjects"] !== void 0) {
contents.SseKmsEncryptedObjects = deserializeAws_restXmlSseKmsEncryptedObjects(output["SseKmsEncryptedObjects"]);
}
if (output["ReplicaModifications"] !== void 0) {
contents.ReplicaModifications = deserializeAws_restXmlReplicaModifications(output["ReplicaModifications"]);
}
return contents;
};
const deserializeAws_restXmlSSEKMS = (output, context)=>{
const contents = {
KeyId: void 0
};
if (output["KeyId"] !== void 0) {
contents.KeyId = expectString(output["KeyId"]);
}
return contents;
};
const deserializeAws_restXmlSseKmsEncryptedObjects = (output, context)=>{
const contents = {
Status: void 0
};
if (output["Status"] !== void 0) {
contents.Status = expectString(output["Status"]);
}
return contents;
};
const deserializeAws_restXmlSSES3 = (output, context)=>{
const contents = {};
return contents;
};
const deserializeAws_restXmlStats = (output, context)=>{
const contents = {
BytesScanned: void 0,
BytesProcessed: void 0,
BytesReturned: void 0
};
if (output["BytesScanned"] !== void 0) {
contents.BytesScanned = strictParseLong(output["BytesScanned"]);
}
if (output["BytesProcessed"] !== void 0) {
contents.BytesProcessed = strictParse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment