{
  "version": 3,
  "sources": ["../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/util.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/validator.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js", "../../../../../../../node_modules/.pnpm/strnum@1.0.5/node_modules/strnum/strnum.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/node2json.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js", "../../../../../../../node_modules/.pnpm/fast-xml-parser@4.4.1/node_modules/fast-xml-parser/src/fxp.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/middleware/cors/index.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/compose.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/request/constants.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/utils/body.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/utils/url.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/request.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/utils/html.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/context.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/router.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/utils/constants.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/hono-base.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/router/pattern-router/router.js", "../../../../../../../node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/preset/tiny.js", "../../../../../src/workers/core/constants.ts", "../../../../../src/workers/r2/s3/account.worker.ts", "../../../../../src/workers/r2/constants.ts", "../../../../../src/workers/r2/s3/auth.worker.ts", "../../../../../src/workers/r2/s3/common.worker.ts", "../../../../../src/workers/r2/s3/errors.worker.ts", "../../../../../src/workers/r2/s3/detect.worker.ts", "../../../../../src/workers/r2/s3/dispatch.worker.ts", "../../../../../src/workers/r2/s3/operations.worker.ts", "../../../../../src/workers/r2/serve.worker.ts", "../../../../../src/workers/r2/s3/index.worker.ts"],
  "sourcesContent": ["'use strict';\n\nconst 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';\nconst nameChar = nameStartChar + '\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040';\nconst nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*'\nconst regexName = new RegExp('^' + nameRegexp + '$');\n\nconst getAllMatches = function(string, regex) {\n  const matches = [];\n  let match = regex.exec(string);\n  while (match) {\n    const allmatches = [];\n    allmatches.startIndex = regex.lastIndex - match[0].length;\n    const len = match.length;\n    for (let index = 0; index < len; index++) {\n      allmatches.push(match[index]);\n    }\n    matches.push(allmatches);\n    match = regex.exec(string);\n  }\n  return matches;\n};\n\nconst isName = function(string) {\n  const match = regexName.exec(string);\n  return !(match === null || typeof match === 'undefined');\n};\n\nexports.isExist = function(v) {\n  return typeof v !== 'undefined';\n};\n\nexports.isEmptyObject = function(obj) {\n  return Object.keys(obj).length === 0;\n};\n\n/**\n * Copy all the properties of a into b.\n * @param {*} target\n * @param {*} a\n */\nexports.merge = function(target, a, arrayMode) {\n  if (a) {\n    const keys = Object.keys(a); // will return an array of own properties\n    const len = keys.length; //don't make it inline\n    for (let i = 0; i < len; i++) {\n      if (arrayMode === 'strict') {\n        target[keys[i]] = [ a[keys[i]] ];\n      } else {\n        target[keys[i]] = a[keys[i]];\n      }\n    }\n  }\n};\n/* exports.merge =function (b,a){\n  return Object.assign(b,a);\n} */\n\nexports.getValue = function(v) {\n  if (exports.isExist(v)) {\n    return v;\n  } else {\n    return '';\n  }\n};\n\n// const fakeCall = function(a) {return a;};\n// const fakeCallNoReturn = function() {};\n\nexports.isName = isName;\nexports.getAllMatches = getAllMatches;\nexports.nameRegexp = nameRegexp;\n", "'use strict';\n\nconst util = require('./util');\n\nconst defaultOptions = {\n  allowBooleanAttributes: false, //A tag can have attributes without any value\n  unpairedTags: []\n};\n\n//const tagsPattern = new RegExp(\"<\\\\/?([\\\\w:\\\\-_\\.]+)\\\\s*\\/?>\",\"g\");\nexports.validate = function (xmlData, options) {\n  options = Object.assign({}, defaultOptions, options);\n\n  //xmlData = xmlData.replace(/(\\r\\n|\\n|\\r)/gm,\"\");//make it single line\n  //xmlData = xmlData.replace(/(^\\s*<\\?xml.*?\\?>)/g,\"\");//Remove XML starting tag\n  //xmlData = xmlData.replace(/(<!DOCTYPE[\\s\\w\\\"\\.\\/\\-\\:]+(\\[.*\\])*\\s*>)/g,\"\");//Remove DOCTYPE\n  const tags = [];\n  let tagFound = false;\n\n  //indicates that the root tag has been closed (aka. depth 0 has been reached)\n  let reachedRoot = false;\n\n  if (xmlData[0] === '\\ufeff') {\n    // check for byte order mark (BOM)\n    xmlData = xmlData.substr(1);\n  }\n  \n  for (let i = 0; i < xmlData.length; i++) {\n\n    if (xmlData[i] === '<' && xmlData[i+1] === '?') {\n      i+=2;\n      i = readPI(xmlData,i);\n      if (i.err) return i;\n    }else if (xmlData[i] === '<') {\n      //starting of tag\n      //read until you reach to '>' avoiding any '>' in attribute value\n      let tagStartPos = i;\n      i++;\n      \n      if (xmlData[i] === '!') {\n        i = readCommentAndCDATA(xmlData, i);\n        continue;\n      } else {\n        let closingTag = false;\n        if (xmlData[i] === '/') {\n          //closing tag\n          closingTag = true;\n          i++;\n        }\n        //read tagname\n        let tagName = '';\n        for (; i < xmlData.length &&\n          xmlData[i] !== '>' &&\n          xmlData[i] !== ' ' &&\n          xmlData[i] !== '\\t' &&\n          xmlData[i] !== '\\n' &&\n          xmlData[i] !== '\\r'; i++\n        ) {\n          tagName += xmlData[i];\n        }\n        tagName = tagName.trim();\n        //console.log(tagName);\n\n        if (tagName[tagName.length - 1] === '/') {\n          //self closing tag without attributes\n          tagName = tagName.substring(0, tagName.length - 1);\n          //continue;\n          i--;\n        }\n        if (!validateTagName(tagName)) {\n          let msg;\n          if (tagName.trim().length === 0) {\n            msg = \"Invalid space after '<'.\";\n          } else {\n            msg = \"Tag '\"+tagName+\"' is an invalid name.\";\n          }\n          return getErrorObject('InvalidTag', msg, getLineNumberForPosition(xmlData, i));\n        }\n\n        const result = readAttributeStr(xmlData, i);\n        if (result === false) {\n          return getErrorObject('InvalidAttr', \"Attributes for '\"+tagName+\"' have open quote.\", getLineNumberForPosition(xmlData, i));\n        }\n        let attrStr = result.value;\n        i = result.index;\n\n        if (attrStr[attrStr.length - 1] === '/') {\n          //self closing tag\n          const attrStrStart = i - attrStr.length;\n          attrStr = attrStr.substring(0, attrStr.length - 1);\n          const isValid = validateAttributeString(attrStr, options);\n          if (isValid === true) {\n            tagFound = true;\n            //continue; //text may presents after self closing tag\n          } else {\n            //the result from the nested function returns the position of the error within the attribute\n            //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n            //this gives us the absolute index in the entire xml, which we can use to find the line at last\n            return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));\n          }\n        } else if (closingTag) {\n          if (!result.tagClosed) {\n            return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' doesn't have proper closing.\", getLineNumberForPosition(xmlData, i));\n          } else if (attrStr.trim().length > 0) {\n            return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' can't have attributes or invalid starting.\", getLineNumberForPosition(xmlData, tagStartPos));\n          } else if (tags.length === 0) {\n            return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' has not been opened.\", getLineNumberForPosition(xmlData, tagStartPos));\n          } else {\n            const otg = tags.pop();\n            if (tagName !== otg.tagName) {\n              let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);\n              return getErrorObject('InvalidTag',\n                \"Expected closing tag '\"+otg.tagName+\"' (opened in line \"+openPos.line+\", col \"+openPos.col+\") instead of closing tag '\"+tagName+\"'.\",\n                getLineNumberForPosition(xmlData, tagStartPos));\n            }\n\n            //when there are no more tags, we reached the root level.\n            if (tags.length == 0) {\n              reachedRoot = true;\n            }\n          }\n        } else {\n          const isValid = validateAttributeString(attrStr, options);\n          if (isValid !== true) {\n            //the result from the nested function returns the position of the error within the attribute\n            //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n            //this gives us the absolute index in the entire xml, which we can use to find the line at last\n            return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));\n          }\n\n          //if the root level has been reached before ...\n          if (reachedRoot === true) {\n            return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i));\n          } else if(options.unpairedTags.indexOf(tagName) !== -1){\n            //don't push into stack\n          } else {\n            tags.push({tagName, tagStartPos});\n          }\n          tagFound = true;\n        }\n\n        //skip tag text value\n        //It may include comments and CDATA value\n        for (i++; i < xmlData.length; i++) {\n          if (xmlData[i] === '<') {\n            if (xmlData[i + 1] === '!') {\n              //comment or CADATA\n              i++;\n              i = readCommentAndCDATA(xmlData, i);\n              continue;\n            } else if (xmlData[i+1] === '?') {\n              i = readPI(xmlData, ++i);\n              if (i.err) return i;\n            } else{\n              break;\n            }\n          } else if (xmlData[i] === '&') {\n            const afterAmp = validateAmpersand(xmlData, i);\n            if (afterAmp == -1)\n              return getErrorObject('InvalidChar', \"char '&' is not expected.\", getLineNumberForPosition(xmlData, i));\n            i = afterAmp;\n          }else{\n            if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {\n              return getErrorObject('InvalidXml', \"Extra text at the end\", getLineNumberForPosition(xmlData, i));\n            }\n          }\n        } //end of reading tag text value\n        if (xmlData[i] === '<') {\n          i--;\n        }\n      }\n    } else {\n      if ( isWhiteSpace(xmlData[i])) {\n        continue;\n      }\n      return getErrorObject('InvalidChar', \"char '\"+xmlData[i]+\"' is not expected.\", getLineNumberForPosition(xmlData, i));\n    }\n  }\n\n  if (!tagFound) {\n    return getErrorObject('InvalidXml', 'Start tag expected.', 1);\n  }else if (tags.length == 1) {\n      return getErrorObject('InvalidTag', \"Unclosed tag '\"+tags[0].tagName+\"'.\", getLineNumberForPosition(xmlData, tags[0].tagStartPos));\n  }else if (tags.length > 0) {\n      return getErrorObject('InvalidXml', \"Invalid '\"+\n          JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\\r?\\n/g, '')+\n          \"' found.\", {line: 1, col: 1});\n  }\n\n  return true;\n};\n\nfunction isWhiteSpace(char){\n  return char === ' ' || char === '\\t' || char === '\\n'  || char === '\\r';\n}\n/**\n * Read Processing insstructions and skip\n * @param {*} xmlData\n * @param {*} i\n */\nfunction readPI(xmlData, i) {\n  const start = i;\n  for (; i < xmlData.length; i++) {\n    if (xmlData[i] == '?' || xmlData[i] == ' ') {\n      //tagname\n      const tagname = xmlData.substr(start, i - start);\n      if (i > 5 && tagname === 'xml') {\n        return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i));\n      } else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {\n        //check if valid attribut string\n        i++;\n        break;\n      } else {\n        continue;\n      }\n    }\n  }\n  return i;\n}\n\nfunction readCommentAndCDATA(xmlData, i) {\n  if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {\n    //comment\n    for (i += 3; i < xmlData.length; i++) {\n      if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {\n        i += 2;\n        break;\n      }\n    }\n  } else if (\n    xmlData.length > i + 8 &&\n    xmlData[i + 1] === 'D' &&\n    xmlData[i + 2] === 'O' &&\n    xmlData[i + 3] === 'C' &&\n    xmlData[i + 4] === 'T' &&\n    xmlData[i + 5] === 'Y' &&\n    xmlData[i + 6] === 'P' &&\n    xmlData[i + 7] === 'E'\n  ) {\n    let angleBracketsCount = 1;\n    for (i += 8; i < xmlData.length; i++) {\n      if (xmlData[i] === '<') {\n        angleBracketsCount++;\n      } else if (xmlData[i] === '>') {\n        angleBracketsCount--;\n        if (angleBracketsCount === 0) {\n          break;\n        }\n      }\n    }\n  } else if (\n    xmlData.length > i + 9 &&\n    xmlData[i + 1] === '[' &&\n    xmlData[i + 2] === 'C' &&\n    xmlData[i + 3] === 'D' &&\n    xmlData[i + 4] === 'A' &&\n    xmlData[i + 5] === 'T' &&\n    xmlData[i + 6] === 'A' &&\n    xmlData[i + 7] === '['\n  ) {\n    for (i += 8; i < xmlData.length; i++) {\n      if (xmlData[i] === ']' && xmlData[i + 1] === ']' && xmlData[i + 2] === '>') {\n        i += 2;\n        break;\n      }\n    }\n  }\n\n  return i;\n}\n\nconst doubleQuote = '\"';\nconst singleQuote = \"'\";\n\n/**\n * Keep reading xmlData until '<' is found outside the attribute value.\n * @param {string} xmlData\n * @param {number} i\n */\nfunction readAttributeStr(xmlData, i) {\n  let attrStr = '';\n  let startChar = '';\n  let tagClosed = false;\n  for (; i < xmlData.length; i++) {\n    if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {\n      if (startChar === '') {\n        startChar = xmlData[i];\n      } else if (startChar !== xmlData[i]) {\n        //if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa\n      } else {\n        startChar = '';\n      }\n    } else if (xmlData[i] === '>') {\n      if (startChar === '') {\n        tagClosed = true;\n        break;\n      }\n    }\n    attrStr += xmlData[i];\n  }\n  if (startChar !== '') {\n    return false;\n  }\n\n  return {\n    value: attrStr,\n    index: i,\n    tagClosed: tagClosed\n  };\n}\n\n/**\n * Select all the attributes whether valid or invalid.\n */\nconst validAttrStrRegxp = new RegExp('(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*([\\'\"])(([\\\\s\\\\S])*?)\\\\5)?', 'g');\n\n//attr, =\"sd\", a=\"amit's\", a=\"sd\"b=\"saf\", ab  cd=\"\"\n\nfunction validateAttributeString(attrStr, options) {\n  //console.log(\"start:\"+attrStr+\":end\");\n\n  //if(attrStr.trim().length === 0) return true; //empty string\n\n  const matches = util.getAllMatches(attrStr, validAttrStrRegxp);\n  const attrNames = {};\n\n  for (let i = 0; i < matches.length; i++) {\n    if (matches[i][1].length === 0) {\n      //nospace before attribute name: a=\"sd\"b=\"saf\"\n      return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' has no space in starting.\", getPositionFromMatch(matches[i]))\n    } else if (matches[i][3] !== undefined && matches[i][4] === undefined) {\n      return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' is without value.\", getPositionFromMatch(matches[i]));\n    } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {\n      //independent attribute: ab\n      return getErrorObject('InvalidAttr', \"boolean attribute '\"+matches[i][2]+\"' is not allowed.\", getPositionFromMatch(matches[i]));\n    }\n    /* else if(matches[i][6] === undefined){//attribute without value: ab=\n                    return { err: { code:\"InvalidAttr\",msg:\"attribute \" + matches[i][2] + \" has no value assigned.\"}};\n                } */\n    const attrName = matches[i][2];\n    if (!validateAttrName(attrName)) {\n      return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is an invalid name.\", getPositionFromMatch(matches[i]));\n    }\n    if (!attrNames.hasOwnProperty(attrName)) {\n      //check for duplicate attribute.\n      attrNames[attrName] = 1;\n    } else {\n      return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is repeated.\", getPositionFromMatch(matches[i]));\n    }\n  }\n\n  return true;\n}\n\nfunction validateNumberAmpersand(xmlData, i) {\n  let re = /\\d/;\n  if (xmlData[i] === 'x') {\n    i++;\n    re = /[\\da-fA-F]/;\n  }\n  for (; i < xmlData.length; i++) {\n    if (xmlData[i] === ';')\n      return i;\n    if (!xmlData[i].match(re))\n      break;\n  }\n  return -1;\n}\n\nfunction validateAmpersand(xmlData, i) {\n  // https://www.w3.org/TR/xml/#dt-charref\n  i++;\n  if (xmlData[i] === ';')\n    return -1;\n  if (xmlData[i] === '#') {\n    i++;\n    return validateNumberAmpersand(xmlData, i);\n  }\n  let count = 0;\n  for (; i < xmlData.length; i++, count++) {\n    if (xmlData[i].match(/\\w/) && count < 20)\n      continue;\n    if (xmlData[i] === ';')\n      break;\n    return -1;\n  }\n  return i;\n}\n\nfunction getErrorObject(code, message, lineNumber) {\n  return {\n    err: {\n      code: code,\n      msg: message,\n      line: lineNumber.line || lineNumber,\n      col: lineNumber.col,\n    },\n  };\n}\n\nfunction validateAttrName(attrName) {\n  return util.isName(attrName);\n}\n\n// const startsWithXML = /^xml/i;\n\nfunction validateTagName(tagname) {\n  return util.isName(tagname) /* && !tagname.match(startsWithXML) */;\n}\n\n//this function returns the line number for the character at the given index\nfunction getLineNumberForPosition(xmlData, index) {\n  const lines = xmlData.substring(0, index).split(/\\r?\\n/);\n  return {\n    line: lines.length,\n\n    // column number is last line's length + 1, because column numbering starts at 1:\n    col: lines[lines.length - 1].length + 1\n  };\n}\n\n//this function returns the position of the first character of match within attrStr\nfunction getPositionFromMatch(match) {\n  return match.startIndex + match[1].length;\n}\n", "\nconst defaultOptions = {\n    preserveOrder: false,\n    attributeNamePrefix: '@_',\n    attributesGroupName: false,\n    textNodeName: '#text',\n    ignoreAttributes: true,\n    removeNSPrefix: false, // remove NS from tag name or attribute name if true\n    allowBooleanAttributes: false, //a tag can have attributes without any value\n    //ignoreRootElement : false,\n    parseTagValue: true,\n    parseAttributeValue: false,\n    trimValues: true, //Trim string values of tag and attributes\n    cdataPropName: false,\n    numberParseOptions: {\n      hex: true,\n      leadingZeros: true,\n      eNotation: true\n    },\n    tagValueProcessor: function(tagName, val) {\n      return val;\n    },\n    attributeValueProcessor: function(attrName, val) {\n      return val;\n    },\n    stopNodes: [], //nested tags will not be parsed even for errors\n    alwaysCreateTextNode: false,\n    isArray: () => false,\n    commentPropName: false,\n    unpairedTags: [],\n    processEntities: true,\n    htmlEntities: false,\n    ignoreDeclaration: false,\n    ignorePiTags: false,\n    transformTagName: false,\n    transformAttributeName: false,\n    updateTag: function(tagName, jPath, attrs){\n      return tagName\n    },\n    // skipEmptyListItem: false\n};\n   \nconst buildOptions = function(options) {\n    return Object.assign({}, defaultOptions, options);\n};\n\nexports.buildOptions = buildOptions;\nexports.defaultOptions = defaultOptions;", "'use strict';\n\nclass XmlNode{\n  constructor(tagname) {\n    this.tagname = tagname;\n    this.child = []; //nested tags, text, cdata, comments in order\n    this[\":@\"] = {}; //attributes map\n  }\n  add(key,val){\n    // this.child.push( {name : key, val: val, isCdata: isCdata });\n    if(key === \"__proto__\") key = \"#__proto__\";\n    this.child.push( {[key]: val });\n  }\n  addChild(node) {\n    if(node.tagname === \"__proto__\") node.tagname = \"#__proto__\";\n    if(node[\":@\"] && Object.keys(node[\":@\"]).length > 0){\n      this.child.push( { [node.tagname]: node.child, [\":@\"]: node[\":@\"] });\n    }else{\n      this.child.push( { [node.tagname]: node.child });\n    }\n  };\n};\n\n\nmodule.exports = XmlNode;", "const util = require('../util');\n\n//TODO: handle comments\nfunction readDocType(xmlData, i){\n    \n    const entities = {};\n    if( xmlData[i + 3] === 'O' &&\n         xmlData[i + 4] === 'C' &&\n         xmlData[i + 5] === 'T' &&\n         xmlData[i + 6] === 'Y' &&\n         xmlData[i + 7] === 'P' &&\n         xmlData[i + 8] === 'E')\n    {    \n        i = i+9;\n        let angleBracketsCount = 1;\n        let hasBody = false, comment = false;\n        let exp = \"\";\n        for(;i<xmlData.length;i++){\n            if (xmlData[i] === '<' && !comment) { //Determine the tag type\n                if( hasBody && isEntity(xmlData, i)){\n                    i += 7; \n                    [entityName, val,i] = readEntityExp(xmlData,i+1);\n                    if(val.indexOf(\"&\") === -1) //Parameter entities are not supported\n                        entities[ validateEntityName(entityName) ] = {\n                            regx : RegExp( `&${entityName};`,\"g\"),\n                            val: val\n                        };\n                }\n                else if( hasBody && isElement(xmlData, i))  i += 8;//Not supported\n                else if( hasBody && isAttlist(xmlData, i))  i += 8;//Not supported\n                else if( hasBody && isNotation(xmlData, i)) i += 9;//Not supported\n                else if( isComment)                         comment = true;\n                else                                        throw new Error(\"Invalid DOCTYPE\");\n\n                angleBracketsCount++;\n                exp = \"\";\n            } else if (xmlData[i] === '>') { //Read tag content\n                if(comment){\n                    if( xmlData[i - 1] === \"-\" && xmlData[i - 2] === \"-\"){\n                        comment = false;\n                        angleBracketsCount--;\n                    }\n                }else{\n                    angleBracketsCount--;\n                }\n                if (angleBracketsCount === 0) {\n                  break;\n                }\n            }else if( xmlData[i] === '['){\n                hasBody = true;\n            }else{\n                exp += xmlData[i];\n            }\n        }\n        if(angleBracketsCount !== 0){\n            throw new Error(`Unclosed DOCTYPE`);\n        }\n    }else{\n        throw new Error(`Invalid Tag instead of DOCTYPE`);\n    }\n    return {entities, i};\n}\n\nfunction readEntityExp(xmlData,i){\n    //External entities are not supported\n    //    <!ENTITY ext SYSTEM \"http://normal-website.com\" >\n\n    //Parameter entities are not supported\n    //    <!ENTITY entityname \"&anotherElement;\">\n\n    //Internal entities are supported\n    //    <!ENTITY entityname \"replacement text\">\n    \n    //read EntityName\n    let entityName = \"\";\n    for (; i < xmlData.length && (xmlData[i] !== \"'\" && xmlData[i] !== '\"' ); i++) {\n        // if(xmlData[i] === \" \") continue;\n        // else \n        entityName += xmlData[i];\n    }\n    entityName = entityName.trim();\n    if(entityName.indexOf(\" \") !== -1) throw new Error(\"External entites are not supported\");\n\n    //read Entity Value\n    const startChar = xmlData[i++];\n    let val = \"\"\n    for (; i < xmlData.length && xmlData[i] !== startChar ; i++) {\n        val += xmlData[i];\n    }\n    return [entityName, val, i];\n}\n\nfunction isComment(xmlData, i){\n    if(xmlData[i+1] === '!' &&\n    xmlData[i+2] === '-' &&\n    xmlData[i+3] === '-') return true\n    return false\n}\nfunction isEntity(xmlData, i){\n    if(xmlData[i+1] === '!' &&\n    xmlData[i+2] === 'E' &&\n    xmlData[i+3] === 'N' &&\n    xmlData[i+4] === 'T' &&\n    xmlData[i+5] === 'I' &&\n    xmlData[i+6] === 'T' &&\n    xmlData[i+7] === 'Y') return true\n    return false\n}\nfunction isElement(xmlData, i){\n    if(xmlData[i+1] === '!' &&\n    xmlData[i+2] === 'E' &&\n    xmlData[i+3] === 'L' &&\n    xmlData[i+4] === 'E' &&\n    xmlData[i+5] === 'M' &&\n    xmlData[i+6] === 'E' &&\n    xmlData[i+7] === 'N' &&\n    xmlData[i+8] === 'T') return true\n    return false\n}\n\nfunction isAttlist(xmlData, i){\n    if(xmlData[i+1] === '!' &&\n    xmlData[i+2] === 'A' &&\n    xmlData[i+3] === 'T' &&\n    xmlData[i+4] === 'T' &&\n    xmlData[i+5] === 'L' &&\n    xmlData[i+6] === 'I' &&\n    xmlData[i+7] === 'S' &&\n    xmlData[i+8] === 'T') return true\n    return false\n}\nfunction isNotation(xmlData, i){\n    if(xmlData[i+1] === '!' &&\n    xmlData[i+2] === 'N' &&\n    xmlData[i+3] === 'O' &&\n    xmlData[i+4] === 'T' &&\n    xmlData[i+5] === 'A' &&\n    xmlData[i+6] === 'T' &&\n    xmlData[i+7] === 'I' &&\n    xmlData[i+8] === 'O' &&\n    xmlData[i+9] === 'N') return true\n    return false\n}\n\nfunction validateEntityName(name){\n    if (util.isName(name))\n\treturn name;\n    else\n        throw new Error(`Invalid entity name ${name}`);\n}\n\nmodule.exports = readDocType;\n", "const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;\nconst numRegex = /^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;\n// const octRegex = /0x[a-z0-9]+/;\n// const binRegex = /0x[a-z0-9]+/;\n\n\n//polyfill\nif (!Number.parseInt && window.parseInt) {\n    Number.parseInt = window.parseInt;\n}\nif (!Number.parseFloat && window.parseFloat) {\n    Number.parseFloat = window.parseFloat;\n}\n\n  \nconst consider = {\n    hex :  true,\n    leadingZeros: true,\n    decimalPoint: \"\\.\",\n    eNotation: true\n    //skipLike: /regex/\n};\n\nfunction toNumber(str, options = {}){\n    // const options = Object.assign({}, consider);\n    // if(opt.leadingZeros === false){\n    //     options.leadingZeros = false;\n    // }else if(opt.hex === false){\n    //     options.hex = false;\n    // }\n\n    options = Object.assign({}, consider, options );\n    if(!str || typeof str !== \"string\" ) return str;\n    \n    let trimmedStr  = str.trim();\n    // if(trimmedStr === \"0.0\") return 0;\n    // else if(trimmedStr === \"+0.0\") return 0;\n    // else if(trimmedStr === \"-0.0\") return -0;\n\n    if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;\n    else if (options.hex && hexRegex.test(trimmedStr)) {\n        return Number.parseInt(trimmedStr, 16);\n    // } else if (options.parseOct && octRegex.test(str)) {\n    //     return Number.parseInt(val, 8);\n    // }else if (options.parseBin && binRegex.test(str)) {\n    //     return Number.parseInt(val, 2);\n    }else{\n        //separate negative sign, leading zeros, and rest number\n        const match = numRegex.exec(trimmedStr);\n        if(match){\n            const sign = match[1];\n            const leadingZeros = match[2];\n            let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros\n            //trim ending zeros for floating number\n            \n            const eNotation = match[4] || match[6];\n            if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== \".\") return str; //-0123\n            else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== \".\") return str; //0123\n            else{//no leading zeros or leading zeros are allowed\n                const num = Number(trimmedStr);\n                const numStr = \"\" + num;\n                if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation\n                    if(options.eNotation) return num;\n                    else return str;\n                }else if(eNotation){ //given number has enotation\n                    if(options.eNotation) return num;\n                    else return str;\n                }else if(trimmedStr.indexOf(\".\") !== -1){ //floating number\n                    // const decimalPart = match[5].substr(1);\n                    // const intPart = trimmedStr.substr(0,trimmedStr.indexOf(\".\"));\n\n                    \n                    // const p = numStr.indexOf(\".\");\n                    // const givenIntPart = numStr.substr(0,p);\n                    // const givenDecPart = numStr.substr(p+1);\n                    if(numStr === \"0\" && (numTrimmedByZeros === \"\") ) return num; //0.0\n                    else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000\n                    else if( sign && numStr === \"-\"+numTrimmedByZeros) return num;\n                    else return str;\n                }\n                \n                if(leadingZeros){\n                    // if(numTrimmedByZeros === numStr){\n                    //     if(options.leadingZeros) return num;\n                    //     else return str;\n                    // }else return str;\n                    if(numTrimmedByZeros === numStr) return num;\n                    else if(sign+numTrimmedByZeros === numStr) return num;\n                    else return str;\n                }\n\n                if(trimmedStr === numStr) return num;\n                else if(trimmedStr === sign+numStr) return num;\n                // else{\n                //     //number with +/- sign\n                //     trimmedStr.test(/[-+][0-9]);\n\n                // }\n                return str;\n            }\n            // else if(!eNotation && trimmedStr && trimmedStr !== Number(trimmedStr) ) return str;\n            \n        }else{ //non-numeric string\n            return str;\n        }\n    }\n}\n\n/**\n * \n * @param {string} numStr without leading zeros\n * @returns \n */\nfunction trimZeros(numStr){\n    if(numStr && numStr.indexOf(\".\") !== -1){//float\n        numStr = numStr.replace(/0+$/, \"\"); //remove ending zeros\n        if(numStr === \".\")  numStr = \"0\";\n        else if(numStr[0] === \".\")  numStr = \"0\"+numStr;\n        else if(numStr[numStr.length-1] === \".\")  numStr = numStr.substr(0,numStr.length-1);\n        return numStr;\n    }\n    return numStr;\n}\nmodule.exports = toNumber\n", "'use strict';\n///@ts-check\n\nconst util = require('../util');\nconst xmlNode = require('./xmlNode');\nconst readDocType = require(\"./DocTypeReader\");\nconst toNumber = require(\"strnum\");\n\n// const regx =\n//   '<((!\\\\[CDATA\\\\[([\\\\s\\\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\\\/)(NAME)\\\\s*>))([^<]*)'\n//   .replace(/NAME/g, util.nameRegexp);\n\n//const tagsRegx = new RegExp(\"<(\\\\/?[\\\\w:\\\\-\\._]+)([^>]*)>(\\\\s*\"+cdataRegx+\")*([^<]+)?\",\"g\");\n//const tagsRegx = new RegExp(\"<(\\\\/?)((\\\\w*:)?([\\\\w:\\\\-\\._]+))([^>]*)>([^<]*)(\"+cdataRegx+\"([^<]*))*([^<]+)?\",\"g\");\n\nclass OrderedObjParser{\n  constructor(options){\n    this.options = options;\n    this.currentNode = null;\n    this.tagsNodeStack = [];\n    this.docTypeEntities = {};\n    this.lastEntities = {\n      \"apos\" : { regex: /&(apos|#39|#x27);/g, val : \"'\"},\n      \"gt\" : { regex: /&(gt|#62|#x3E);/g, val : \">\"},\n      \"lt\" : { regex: /&(lt|#60|#x3C);/g, val : \"<\"},\n      \"quot\" : { regex: /&(quot|#34|#x22);/g, val : \"\\\"\"},\n    };\n    this.ampEntity = { regex: /&(amp|#38|#x26);/g, val : \"&\"};\n    this.htmlEntities = {\n      \"space\": { regex: /&(nbsp|#160);/g, val: \" \" },\n      // \"lt\" : { regex: /&(lt|#60);/g, val: \"<\" },\n      // \"gt\" : { regex: /&(gt|#62);/g, val: \">\" },\n      // \"amp\" : { regex: /&(amp|#38);/g, val: \"&\" },\n      // \"quot\" : { regex: /&(quot|#34);/g, val: \"\\\"\" },\n      // \"apos\" : { regex: /&(apos|#39);/g, val: \"'\" },\n      \"cent\" : { regex: /&(cent|#162);/g, val: \"\u00A2\" },\n      \"pound\" : { regex: /&(pound|#163);/g, val: \"\u00A3\" },\n      \"yen\" : { regex: /&(yen|#165);/g, val: \"\u00A5\" },\n      \"euro\" : { regex: /&(euro|#8364);/g, val: \"\u20AC\" },\n      \"copyright\" : { regex: /&(copy|#169);/g, val: \"\u00A9\" },\n      \"reg\" : { regex: /&(reg|#174);/g, val: \"\u00AE\" },\n      \"inr\" : { regex: /&(inr|#8377);/g, val: \"\u20B9\" },\n      \"num_dec\": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },\n      \"num_hex\": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 16)) },\n    };\n    this.addExternalEntities = addExternalEntities;\n    this.parseXml = parseXml;\n    this.parseTextData = parseTextData;\n    this.resolveNameSpace = resolveNameSpace;\n    this.buildAttributesMap = buildAttributesMap;\n    this.isItStopNode = isItStopNode;\n    this.replaceEntitiesValue = replaceEntitiesValue;\n    this.readStopNodeData = readStopNodeData;\n    this.saveTextToParentTag = saveTextToParentTag;\n    this.addChild = addChild;\n  }\n\n}\n\nfunction addExternalEntities(externalEntities){\n  const entKeys = Object.keys(externalEntities);\n  for (let i = 0; i < entKeys.length; i++) {\n    const ent = entKeys[i];\n    this.lastEntities[ent] = {\n       regex: new RegExp(\"&\"+ent+\";\",\"g\"),\n       val : externalEntities[ent]\n    }\n  }\n}\n\n/**\n * @param {string} val\n * @param {string} tagName\n * @param {string} jPath\n * @param {boolean} dontTrim\n * @param {boolean} hasAttributes\n * @param {boolean} isLeafNode\n * @param {boolean} escapeEntities\n */\nfunction parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {\n  if (val !== undefined) {\n    if (this.options.trimValues && !dontTrim) {\n      val = val.trim();\n    }\n    if(val.length > 0){\n      if(!escapeEntities) val = this.replaceEntitiesValue(val);\n      \n      const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);\n      if(newval === null || newval === undefined){\n        //don't parse\n        return val;\n      }else if(typeof newval !== typeof val || newval !== val){\n        //overwrite\n        return newval;\n      }else if(this.options.trimValues){\n        return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n      }else{\n        const trimmedVal = val.trim();\n        if(trimmedVal === val){\n          return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n        }else{\n          return val;\n        }\n      }\n    }\n  }\n}\n\nfunction resolveNameSpace(tagname) {\n  if (this.options.removeNSPrefix) {\n    const tags = tagname.split(':');\n    const prefix = tagname.charAt(0) === '/' ? '/' : '';\n    if (tags[0] === 'xmlns') {\n      return '';\n    }\n    if (tags.length === 2) {\n      tagname = prefix + tags[1];\n    }\n  }\n  return tagname;\n}\n\n//TODO: change regex to capture NS\n//const attrsRegx = new RegExp(\"([\\\\w\\\\-\\\\.\\\\:]+)\\\\s*=\\\\s*(['\\\"])((.|\\n)*?)\\\\2\",\"gm\");\nconst attrsRegx = new RegExp('([^\\\\s=]+)\\\\s*(=\\\\s*([\\'\"])([\\\\s\\\\S]*?)\\\\3)?', 'gm');\n\nfunction buildAttributesMap(attrStr, jPath, tagName) {\n  if (!this.options.ignoreAttributes && typeof attrStr === 'string') {\n    // attrStr = attrStr.replace(/\\r?\\n/g, ' ');\n    //attrStr = attrStr || attrStr.trim();\n\n    const matches = util.getAllMatches(attrStr, attrsRegx);\n    const len = matches.length; //don't make it inline\n    const attrs = {};\n    for (let i = 0; i < len; i++) {\n      const attrName = this.resolveNameSpace(matches[i][1]);\n      let oldVal = matches[i][4];\n      let aName = this.options.attributeNamePrefix + attrName;\n      if (attrName.length) {\n        if (this.options.transformAttributeName) {\n          aName = this.options.transformAttributeName(aName);\n        }\n        if(aName === \"__proto__\") aName  = \"#__proto__\";\n        if (oldVal !== undefined) {\n          if (this.options.trimValues) {\n            oldVal = oldVal.trim();\n          }\n          oldVal = this.replaceEntitiesValue(oldVal);\n          const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);\n          if(newVal === null || newVal === undefined){\n            //don't parse\n            attrs[aName] = oldVal;\n          }else if(typeof newVal !== typeof oldVal || newVal !== oldVal){\n            //overwrite\n            attrs[aName] = newVal;\n          }else{\n            //parse\n            attrs[aName] = parseValue(\n              oldVal,\n              this.options.parseAttributeValue,\n              this.options.numberParseOptions\n            );\n          }\n        } else if (this.options.allowBooleanAttributes) {\n          attrs[aName] = true;\n        }\n      }\n    }\n    if (!Object.keys(attrs).length) {\n      return;\n    }\n    if (this.options.attributesGroupName) {\n      const attrCollection = {};\n      attrCollection[this.options.attributesGroupName] = attrs;\n      return attrCollection;\n    }\n    return attrs\n  }\n}\n\nconst parseXml = function(xmlData) {\n  xmlData = xmlData.replace(/\\r\\n?/g, \"\\n\"); //TODO: remove this line\n  const xmlObj = new xmlNode('!xml');\n  let currentNode = xmlObj;\n  let textData = \"\";\n  let jPath = \"\";\n  for(let i=0; i< xmlData.length; i++){//for each char in XML data\n    const ch = xmlData[i];\n    if(ch === '<'){\n      // const nextIndex = i+1;\n      // const _2ndChar = xmlData[nextIndex];\n      if( xmlData[i+1] === '/') {//Closing Tag\n        const closeIndex = findClosingIndex(xmlData, \">\", i, \"Closing Tag is not closed.\")\n        let tagName = xmlData.substring(i+2,closeIndex).trim();\n\n        if(this.options.removeNSPrefix){\n          const colonIndex = tagName.indexOf(\":\");\n          if(colonIndex !== -1){\n            tagName = tagName.substr(colonIndex+1);\n          }\n        }\n\n        if(this.options.transformTagName) {\n          tagName = this.options.transformTagName(tagName);\n        }\n\n        if(currentNode){\n          textData = this.saveTextToParentTag(textData, currentNode, jPath);\n        }\n\n        //check if last tag of nested tag was unpaired tag\n        const lastTagName = jPath.substring(jPath.lastIndexOf(\".\")+1);\n        if(tagName && this.options.unpairedTags.indexOf(tagName) !== -1 ){\n          throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);\n        }\n        let propIndex = 0\n        if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){\n          propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1)\n          this.tagsNodeStack.pop();\n        }else{\n          propIndex = jPath.lastIndexOf(\".\");\n        }\n        jPath = jPath.substring(0, propIndex);\n\n        currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope\n        textData = \"\";\n        i = closeIndex;\n      } else if( xmlData[i+1] === '?') {\n\n        let tagData = readTagExp(xmlData,i, false, \"?>\");\n        if(!tagData) throw new Error(\"Pi Tag is not closed.\");\n\n        textData = this.saveTextToParentTag(textData, currentNode, jPath);\n        if( (this.options.ignoreDeclaration && tagData.tagName === \"?xml\") || this.options.ignorePiTags){\n\n        }else{\n  \n          const childNode = new xmlNode(tagData.tagName);\n          childNode.add(this.options.textNodeName, \"\");\n          \n          if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){\n            childNode[\":@\"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);\n          }\n          this.addChild(currentNode, childNode, jPath)\n\n        }\n\n\n        i = tagData.closeIndex + 1;\n      } else if(xmlData.substr(i + 1, 3) === '!--') {\n        const endIndex = findClosingIndex(xmlData, \"-->\", i+4, \"Comment is not closed.\")\n        if(this.options.commentPropName){\n          const comment = xmlData.substring(i + 4, endIndex - 2);\n\n          textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n          currentNode.add(this.options.commentPropName, [ { [this.options.textNodeName] : comment } ]);\n        }\n        i = endIndex;\n      } else if( xmlData.substr(i + 1, 2) === '!D') {\n        const result = readDocType(xmlData, i);\n        this.docTypeEntities = result.entities;\n        i = result.i;\n      }else if(xmlData.substr(i + 1, 2) === '![') {\n        const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"CDATA is not closed.\") - 2;\n        const tagExp = xmlData.substring(i + 9,closeIndex);\n\n        textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n        let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);\n        if(val == undefined) val = \"\";\n\n        //cdata should be set even if it is 0 length string\n        if(this.options.cdataPropName){\n          currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]);\n        }else{\n          currentNode.add(this.options.textNodeName, val);\n        }\n        \n        i = closeIndex + 2;\n      }else {//Opening tag\n        let result = readTagExp(xmlData,i, this.options.removeNSPrefix);\n        let tagName= result.tagName;\n        const rawTagName = result.rawTagName;\n        let tagExp = result.tagExp;\n        let attrExpPresent = result.attrExpPresent;\n        let closeIndex = result.closeIndex;\n\n        if (this.options.transformTagName) {\n          tagName = this.options.transformTagName(tagName);\n        }\n        \n        //save text as child node\n        if (currentNode && textData) {\n          if(currentNode.tagname !== '!xml'){\n            //when nested tag is found\n            textData = this.saveTextToParentTag(textData, currentNode, jPath, false);\n          }\n        }\n\n        //check if last tag was unpaired tag\n        const lastTag = currentNode;\n        if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){\n          currentNode = this.tagsNodeStack.pop();\n          jPath = jPath.substring(0, jPath.lastIndexOf(\".\"));\n        }\n        if(tagName !== xmlObj.tagname){\n          jPath += jPath ? \".\" + tagName : tagName;\n        }\n        if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {\n          let tagContent = \"\";\n          //self-closing tag\n          if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n            if(tagName[tagName.length - 1] === \"/\"){ //remove trailing '/'\n              tagName = tagName.substr(0, tagName.length - 1);\n              jPath = jPath.substr(0, jPath.length - 1);\n              tagExp = tagName;\n            }else{\n              tagExp = tagExp.substr(0, tagExp.length - 1);\n            }\n            i = result.closeIndex;\n          }\n          //unpaired tag\n          else if(this.options.unpairedTags.indexOf(tagName) !== -1){\n            \n            i = result.closeIndex;\n          }\n          //normal tag\n          else{\n            //read until closing tag is found\n            const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);\n            if(!result) throw new Error(`Unexpected end of ${rawTagName}`);\n            i = result.i;\n            tagContent = result.tagContent;\n          }\n\n          const childNode = new xmlNode(tagName);\n          if(tagName !== tagExp && attrExpPresent){\n            childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n          }\n          if(tagContent) {\n            tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);\n          }\n          \n          jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n          childNode.add(this.options.textNodeName, tagContent);\n          \n          this.addChild(currentNode, childNode, jPath)\n        }else{\n  //selfClosing tag\n          if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n            if(tagName[tagName.length - 1] === \"/\"){ //remove trailing '/'\n              tagName = tagName.substr(0, tagName.length - 1);\n              jPath = jPath.substr(0, jPath.length - 1);\n              tagExp = tagName;\n            }else{\n              tagExp = tagExp.substr(0, tagExp.length - 1);\n            }\n            \n            if(this.options.transformTagName) {\n              tagName = this.options.transformTagName(tagName);\n            }\n\n            const childNode = new xmlNode(tagName);\n            if(tagName !== tagExp && attrExpPresent){\n              childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n            }\n            this.addChild(currentNode, childNode, jPath)\n            jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n          }\n    //opening tag\n          else{\n            const childNode = new xmlNode( tagName);\n            this.tagsNodeStack.push(currentNode);\n            \n            if(tagName !== tagExp && attrExpPresent){\n              childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n            }\n            this.addChild(currentNode, childNode, jPath)\n            currentNode = childNode;\n          }\n          textData = \"\";\n          i = closeIndex;\n        }\n      }\n    }else{\n      textData += xmlData[i];\n    }\n  }\n  return xmlObj.child;\n}\n\nfunction addChild(currentNode, childNode, jPath){\n  const result = this.options.updateTag(childNode.tagname, jPath, childNode[\":@\"])\n  if(result === false){\n  }else if(typeof result === \"string\"){\n    childNode.tagname = result\n    currentNode.addChild(childNode);\n  }else{\n    currentNode.addChild(childNode);\n  }\n}\n\nconst replaceEntitiesValue = function(val){\n\n  if(this.options.processEntities){\n    for(let entityName in this.docTypeEntities){\n      const entity = this.docTypeEntities[entityName];\n      val = val.replace( entity.regx, entity.val);\n    }\n    for(let entityName in this.lastEntities){\n      const entity = this.lastEntities[entityName];\n      val = val.replace( entity.regex, entity.val);\n    }\n    if(this.options.htmlEntities){\n      for(let entityName in this.htmlEntities){\n        const entity = this.htmlEntities[entityName];\n        val = val.replace( entity.regex, entity.val);\n      }\n    }\n    val = val.replace( this.ampEntity.regex, this.ampEntity.val);\n  }\n  return val;\n}\nfunction saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {\n  if (textData) { //store previously collected data as textNode\n    if(isLeafNode === undefined) isLeafNode = Object.keys(currentNode.child).length === 0\n    \n    textData = this.parseTextData(textData,\n      currentNode.tagname,\n      jPath,\n      false,\n      currentNode[\":@\"] ? Object.keys(currentNode[\":@\"]).length !== 0 : false,\n      isLeafNode);\n\n    if (textData !== undefined && textData !== \"\")\n      currentNode.add(this.options.textNodeName, textData);\n    textData = \"\";\n  }\n  return textData;\n}\n\n//TODO: use jPath to simplify the logic\n/**\n * \n * @param {string[]} stopNodes \n * @param {string} jPath\n * @param {string} currentTagName \n */\nfunction isItStopNode(stopNodes, jPath, currentTagName){\n  const allNodesExp = \"*.\" + currentTagName;\n  for (const stopNodePath in stopNodes) {\n    const stopNodeExp = stopNodes[stopNodePath];\n    if( allNodesExp === stopNodeExp || jPath === stopNodeExp  ) return true;\n  }\n  return false;\n}\n\n/**\n * Returns the tag Expression and where it is ending handling single-double quotes situation\n * @param {string} xmlData \n * @param {number} i starting index\n * @returns \n */\nfunction tagExpWithClosingIndex(xmlData, i, closingChar = \">\"){\n  let attrBoundary;\n  let tagExp = \"\";\n  for (let index = i; index < xmlData.length; index++) {\n    let ch = xmlData[index];\n    if (attrBoundary) {\n        if (ch === attrBoundary) attrBoundary = \"\";//reset\n    } else if (ch === '\"' || ch === \"'\") {\n        attrBoundary = ch;\n    } else if (ch === closingChar[0]) {\n      if(closingChar[1]){\n        if(xmlData[index + 1] === closingChar[1]){\n          return {\n            data: tagExp,\n            index: index\n          }\n        }\n      }else{\n        return {\n          data: tagExp,\n          index: index\n        }\n      }\n    } else if (ch === '\\t') {\n      ch = \" \"\n    }\n    tagExp += ch;\n  }\n}\n\nfunction findClosingIndex(xmlData, str, i, errMsg){\n  const closingIndex = xmlData.indexOf(str, i);\n  if(closingIndex === -1){\n    throw new Error(errMsg)\n  }else{\n    return closingIndex + str.length - 1;\n  }\n}\n\nfunction readTagExp(xmlData,i, removeNSPrefix, closingChar = \">\"){\n  const result = tagExpWithClosingIndex(xmlData, i+1, closingChar);\n  if(!result) return;\n  let tagExp = result.data;\n  const closeIndex = result.index;\n  const separatorIndex = tagExp.search(/\\s/);\n  let tagName = tagExp;\n  let attrExpPresent = true;\n  if(separatorIndex !== -1){//separate tag name and attributes expression\n    tagName = tagExp.substring(0, separatorIndex);\n    tagExp = tagExp.substring(separatorIndex + 1).trimStart();\n  }\n\n  const rawTagName = tagName;\n  if(removeNSPrefix){\n    const colonIndex = tagName.indexOf(\":\");\n    if(colonIndex !== -1){\n      tagName = tagName.substr(colonIndex+1);\n      attrExpPresent = tagName !== result.data.substr(colonIndex + 1);\n    }\n  }\n\n  return {\n    tagName: tagName,\n    tagExp: tagExp,\n    closeIndex: closeIndex,\n    attrExpPresent: attrExpPresent,\n    rawTagName: rawTagName,\n  }\n}\n/**\n * find paired tag for a stop node\n * @param {string} xmlData \n * @param {string} tagName \n * @param {number} i \n */\nfunction readStopNodeData(xmlData, tagName, i){\n  const startIndex = i;\n  // Starting at 1 since we already have an open tag\n  let openTagCount = 1;\n\n  for (; i < xmlData.length; i++) {\n    if( xmlData[i] === \"<\"){ \n      if (xmlData[i+1] === \"/\") {//close tag\n          const closeIndex = findClosingIndex(xmlData, \">\", i, `${tagName} is not closed`);\n          let closeTagName = xmlData.substring(i+2,closeIndex).trim();\n          if(closeTagName === tagName){\n            openTagCount--;\n            if (openTagCount === 0) {\n              return {\n                tagContent: xmlData.substring(startIndex, i),\n                i : closeIndex\n              }\n            }\n          }\n          i=closeIndex;\n        } else if(xmlData[i+1] === '?') { \n          const closeIndex = findClosingIndex(xmlData, \"?>\", i+1, \"StopNode is not closed.\")\n          i=closeIndex;\n        } else if(xmlData.substr(i + 1, 3) === '!--') { \n          const closeIndex = findClosingIndex(xmlData, \"-->\", i+3, \"StopNode is not closed.\")\n          i=closeIndex;\n        } else if(xmlData.substr(i + 1, 2) === '![') { \n          const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"StopNode is not closed.\") - 2;\n          i=closeIndex;\n        } else {\n          const tagData = readTagExp(xmlData, i, '>')\n\n          if (tagData) {\n            const openTagName = tagData && tagData.tagName;\n            if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== \"/\") {\n              openTagCount++;\n            }\n            i=tagData.closeIndex;\n          }\n        }\n      }\n  }//end for loop\n}\n\nfunction parseValue(val, shouldParse, options) {\n  if (shouldParse && typeof val === 'string') {\n    //console.log(options)\n    const newval = val.trim();\n    if(newval === 'true' ) return true;\n    else if(newval === 'false' ) return false;\n    else return toNumber(val, options);\n  } else {\n    if (util.isExist(val)) {\n      return val;\n    } else {\n      return '';\n    }\n  }\n}\n\n\nmodule.exports = OrderedObjParser;\n", "'use strict';\n\n/**\n * \n * @param {array} node \n * @param {any} options \n * @returns \n */\nfunction prettify(node, options){\n  return compress( node, options);\n}\n\n/**\n * \n * @param {array} arr \n * @param {object} options \n * @param {string} jPath \n * @returns object\n */\nfunction compress(arr, options, jPath){\n  let text;\n  const compressedObj = {};\n  for (let i = 0; i < arr.length; i++) {\n    const tagObj = arr[i];\n    const property = propName(tagObj);\n    let newJpath = \"\";\n    if(jPath === undefined) newJpath = property;\n    else newJpath = jPath + \".\" + property;\n\n    if(property === options.textNodeName){\n      if(text === undefined) text = tagObj[property];\n      else text += \"\" + tagObj[property];\n    }else if(property === undefined){\n      continue;\n    }else if(tagObj[property]){\n      \n      let val = compress(tagObj[property], options, newJpath);\n      const isLeaf = isLeafTag(val, options);\n\n      if(tagObj[\":@\"]){\n        assignAttributes( val, tagObj[\":@\"], newJpath, options);\n      }else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){\n        val = val[options.textNodeName];\n      }else if(Object.keys(val).length === 0){\n        if(options.alwaysCreateTextNode) val[options.textNodeName] = \"\";\n        else val = \"\";\n      }\n\n      if(compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {\n        if(!Array.isArray(compressedObj[property])) {\n            compressedObj[property] = [ compressedObj[property] ];\n        }\n        compressedObj[property].push(val);\n      }else{\n        //TODO: if a node is not an array, then check if it should be an array\n        //also determine if it is a leaf node\n        if (options.isArray(property, newJpath, isLeaf )) {\n          compressedObj[property] = [val];\n        }else{\n          compressedObj[property] = val;\n        }\n      }\n    }\n    \n  }\n  // if(text && text.length > 0) compressedObj[options.textNodeName] = text;\n  if(typeof text === \"string\"){\n    if(text.length > 0) compressedObj[options.textNodeName] = text;\n  }else if(text !== undefined) compressedObj[options.textNodeName] = text;\n  return compressedObj;\n}\n\nfunction propName(obj){\n  const keys = Object.keys(obj);\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i];\n    if(key !== \":@\") return key;\n  }\n}\n\nfunction assignAttributes(obj, attrMap, jpath, options){\n  if (attrMap) {\n    const keys = Object.keys(attrMap);\n    const len = keys.length; //don't make it inline\n    for (let i = 0; i < len; i++) {\n      const atrrName = keys[i];\n      if (options.isArray(atrrName, jpath + \".\" + atrrName, true, true)) {\n        obj[atrrName] = [ attrMap[atrrName] ];\n      } else {\n        obj[atrrName] = attrMap[atrrName];\n      }\n    }\n  }\n}\n\nfunction isLeafTag(obj, options){\n  const { textNodeName } = options;\n  const propCount = Object.keys(obj).length;\n  \n  if (propCount === 0) {\n    return true;\n  }\n\n  if (\n    propCount === 1 &&\n    (obj[textNodeName] || typeof obj[textNodeName] === \"boolean\" || obj[textNodeName] === 0)\n  ) {\n    return true;\n  }\n\n  return false;\n}\nexports.prettify = prettify;\n", "const { buildOptions} = require(\"./OptionsBuilder\");\nconst OrderedObjParser = require(\"./OrderedObjParser\");\nconst { prettify} = require(\"./node2json\");\nconst validator = require('../validator');\n\nclass XMLParser{\n    \n    constructor(options){\n        this.externalEntities = {};\n        this.options = buildOptions(options);\n        \n    }\n    /**\n     * Parse XML dats to JS object \n     * @param {string|Buffer} xmlData \n     * @param {boolean|Object} validationOption \n     */\n    parse(xmlData,validationOption){\n        if(typeof xmlData === \"string\"){\n        }else if( xmlData.toString){\n            xmlData = xmlData.toString();\n        }else{\n            throw new Error(\"XML data is accepted in String or Bytes[] form.\")\n        }\n        if( validationOption){\n            if(validationOption === true) validationOption = {}; //validate with default options\n            \n            const result = validator.validate(xmlData, validationOption);\n            if (result !== true) {\n              throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )\n            }\n          }\n        const orderedObjParser = new OrderedObjParser(this.options);\n        orderedObjParser.addExternalEntities(this.externalEntities);\n        const orderedResult = orderedObjParser.parseXml(xmlData);\n        if(this.options.preserveOrder || orderedResult === undefined) return orderedResult;\n        else return prettify(orderedResult, this.options);\n    }\n\n    /**\n     * Add Entity which is not by default supported by this library\n     * @param {string} key \n     * @param {string} value \n     */\n    addEntity(key, value){\n        if(value.indexOf(\"&\") !== -1){\n            throw new Error(\"Entity value can't have '&'\")\n        }else if(key.indexOf(\"&\") !== -1 || key.indexOf(\";\") !== -1){\n            throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'\")\n        }else if(value === \"&\"){\n            throw new Error(\"An entity with value '&' is not permitted\");\n        }else{\n            this.externalEntities[key] = value;\n        }\n    }\n}\n\nmodule.exports = XMLParser;", "const EOL = \"\\n\";\n\n/**\n * \n * @param {array} jArray \n * @param {any} options \n * @returns \n */\nfunction toXml(jArray, options) {\n    let indentation = \"\";\n    if (options.format && options.indentBy.length > 0) {\n        indentation = EOL;\n    }\n    return arrToStr(jArray, options, \"\", indentation);\n}\n\nfunction arrToStr(arr, options, jPath, indentation) {\n    let xmlStr = \"\";\n    let isPreviousElementTag = false;\n\n    for (let i = 0; i < arr.length; i++) {\n        const tagObj = arr[i];\n        const tagName = propName(tagObj);\n        if(tagName === undefined) continue;\n\n        let newJPath = \"\";\n        if (jPath.length === 0) newJPath = tagName\n        else newJPath = `${jPath}.${tagName}`;\n\n        if (tagName === options.textNodeName) {\n            let tagText = tagObj[tagName];\n            if (!isStopNode(newJPath, options)) {\n                tagText = options.tagValueProcessor(tagName, tagText);\n                tagText = replaceEntitiesValue(tagText, options);\n            }\n            if (isPreviousElementTag) {\n                xmlStr += indentation;\n            }\n            xmlStr += tagText;\n            isPreviousElementTag = false;\n            continue;\n        } else if (tagName === options.cdataPropName) {\n            if (isPreviousElementTag) {\n                xmlStr += indentation;\n            }\n            xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;\n            isPreviousElementTag = false;\n            continue;\n        } else if (tagName === options.commentPropName) {\n            xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;\n            isPreviousElementTag = true;\n            continue;\n        } else if (tagName[0] === \"?\") {\n            const attStr = attr_to_str(tagObj[\":@\"], options);\n            const tempInd = tagName === \"?xml\" ? \"\" : indentation;\n            let piTextNodeName = tagObj[tagName][0][options.textNodeName];\n            piTextNodeName = piTextNodeName.length !== 0 ? \" \" + piTextNodeName : \"\"; //remove extra spacing\n            xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;\n            isPreviousElementTag = true;\n            continue;\n        }\n        let newIdentation = indentation;\n        if (newIdentation !== \"\") {\n            newIdentation += options.indentBy;\n        }\n        const attStr = attr_to_str(tagObj[\":@\"], options);\n        const tagStart = indentation + `<${tagName}${attStr}`;\n        const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);\n        if (options.unpairedTags.indexOf(tagName) !== -1) {\n            if (options.suppressUnpairedNode) xmlStr += tagStart + \">\";\n            else xmlStr += tagStart + \"/>\";\n        } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {\n            xmlStr += tagStart + \"/>\";\n        } else if (tagValue && tagValue.endsWith(\">\")) {\n            xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;\n        } else {\n            xmlStr += tagStart + \">\";\n            if (tagValue && indentation !== \"\" && (tagValue.includes(\"/>\") || tagValue.includes(\"</\"))) {\n                xmlStr += indentation + options.indentBy + tagValue + indentation;\n            } else {\n                xmlStr += tagValue;\n            }\n            xmlStr += `</${tagName}>`;\n        }\n        isPreviousElementTag = true;\n    }\n\n    return xmlStr;\n}\n\nfunction propName(obj) {\n    const keys = Object.keys(obj);\n    for (let i = 0; i < keys.length; i++) {\n        const key = keys[i];\n        if(!obj.hasOwnProperty(key)) continue;\n        if (key !== \":@\") return key;\n    }\n}\n\nfunction attr_to_str(attrMap, options) {\n    let attrStr = \"\";\n    if (attrMap && !options.ignoreAttributes) {\n        for (let attr in attrMap) {\n            if(!attrMap.hasOwnProperty(attr)) continue;\n            let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);\n            attrVal = replaceEntitiesValue(attrVal, options);\n            if (attrVal === true && options.suppressBooleanAttributes) {\n                attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;\n            } else {\n                attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}=\"${attrVal}\"`;\n            }\n        }\n    }\n    return attrStr;\n}\n\nfunction isStopNode(jPath, options) {\n    jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);\n    let tagName = jPath.substr(jPath.lastIndexOf(\".\") + 1);\n    for (let index in options.stopNodes) {\n        if (options.stopNodes[index] === jPath || options.stopNodes[index] === \"*.\" + tagName) return true;\n    }\n    return false;\n}\n\nfunction replaceEntitiesValue(textValue, options) {\n    if (textValue && textValue.length > 0 && options.processEntities) {\n        for (let i = 0; i < options.entities.length; i++) {\n            const entity = options.entities[i];\n            textValue = textValue.replace(entity.regex, entity.val);\n        }\n    }\n    return textValue;\n}\nmodule.exports = toXml;\n", "'use strict';\n//parse Empty Node as self closing node\nconst buildFromOrderedJs = require('./orderedJs2Xml');\n\nconst defaultOptions = {\n  attributeNamePrefix: '@_',\n  attributesGroupName: false,\n  textNodeName: '#text',\n  ignoreAttributes: true,\n  cdataPropName: false,\n  format: false,\n  indentBy: '  ',\n  suppressEmptyNode: false,\n  suppressUnpairedNode: true,\n  suppressBooleanAttributes: true,\n  tagValueProcessor: function(key, a) {\n    return a;\n  },\n  attributeValueProcessor: function(attrName, a) {\n    return a;\n  },\n  preserveOrder: false,\n  commentPropName: false,\n  unpairedTags: [],\n  entities: [\n    { regex: new RegExp(\"&\", \"g\"), val: \"&amp;\" },//it must be on top\n    { regex: new RegExp(\">\", \"g\"), val: \"&gt;\" },\n    { regex: new RegExp(\"<\", \"g\"), val: \"&lt;\" },\n    { regex: new RegExp(\"\\'\", \"g\"), val: \"&apos;\" },\n    { regex: new RegExp(\"\\\"\", \"g\"), val: \"&quot;\" }\n  ],\n  processEntities: true,\n  stopNodes: [],\n  // transformTagName: false,\n  // transformAttributeName: false,\n  oneListGroup: false\n};\n\nfunction Builder(options) {\n  this.options = Object.assign({}, defaultOptions, options);\n  if (this.options.ignoreAttributes || this.options.attributesGroupName) {\n    this.isAttribute = function(/*a*/) {\n      return false;\n    };\n  } else {\n    this.attrPrefixLen = this.options.attributeNamePrefix.length;\n    this.isAttribute = isAttribute;\n  }\n\n  this.processTextOrObjNode = processTextOrObjNode\n\n  if (this.options.format) {\n    this.indentate = indentate;\n    this.tagEndChar = '>\\n';\n    this.newLine = '\\n';\n  } else {\n    this.indentate = function() {\n      return '';\n    };\n    this.tagEndChar = '>';\n    this.newLine = '';\n  }\n}\n\nBuilder.prototype.build = function(jObj) {\n  if(this.options.preserveOrder){\n    return buildFromOrderedJs(jObj, this.options);\n  }else {\n    if(Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1){\n      jObj = {\n        [this.options.arrayNodeName] : jObj\n      }\n    }\n    return this.j2x(jObj, 0).val;\n  }\n};\n\nBuilder.prototype.j2x = function(jObj, level) {\n  let attrStr = '';\n  let val = '';\n  for (let key in jObj) {\n    if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;\n    if (typeof jObj[key] === 'undefined') {\n      // supress undefined node only if it is not an attribute\n      if (this.isAttribute(key)) {\n        val += '';\n      }\n    } else if (jObj[key] === null) {\n      // null attribute should be ignored by the attribute list, but should not cause the tag closing\n      if (this.isAttribute(key)) {\n        val += '';\n      } else if (key[0] === '?') {\n        val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n      } else {\n        val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n      }\n      // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n    } else if (jObj[key] instanceof Date) {\n      val += this.buildTextValNode(jObj[key], key, '', level);\n    } else if (typeof jObj[key] !== 'object') {\n      //premitive type\n      const attr = this.isAttribute(key);\n      if (attr) {\n        attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);\n      }else {\n        //tag value\n        if (key === this.options.textNodeName) {\n          let newval = this.options.tagValueProcessor(key, '' + jObj[key]);\n          val += this.replaceEntitiesValue(newval);\n        } else {\n          val += this.buildTextValNode(jObj[key], key, '', level);\n        }\n      }\n    } else if (Array.isArray(jObj[key])) {\n      //repeated nodes\n      const arrLen = jObj[key].length;\n      let listTagVal = \"\";\n      let listTagAttr = \"\";\n      for (let j = 0; j < arrLen; j++) {\n        const item = jObj[key][j];\n        if (typeof item === 'undefined') {\n          // supress undefined node\n        } else if (item === null) {\n          if(key[0] === \"?\") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n          else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n          // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n        } else if (typeof item === 'object') {\n          if(this.options.oneListGroup){\n            const result = this.j2x(item, level + 1);\n            listTagVal += result.val;\n            if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {\n              listTagAttr += result.attrStr\n            }\n          }else{\n            listTagVal += this.processTextOrObjNode(item, key, level)\n          }\n        } else {\n          if (this.options.oneListGroup) {\n            let textValue = this.options.tagValueProcessor(key, item);\n            textValue = this.replaceEntitiesValue(textValue);\n            listTagVal += textValue;\n          } else {\n            listTagVal += this.buildTextValNode(item, key, '', level);\n          }\n        }\n      }\n      if(this.options.oneListGroup){\n        listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);\n      }\n      val += listTagVal;\n    } else {\n      //nested node\n      if (this.options.attributesGroupName && key === this.options.attributesGroupName) {\n        const Ks = Object.keys(jObj[key]);\n        const L = Ks.length;\n        for (let j = 0; j < L; j++) {\n          attrStr += this.buildAttrPairStr(Ks[j], '' + jObj[key][Ks[j]]);\n        }\n      } else {\n        val += this.processTextOrObjNode(jObj[key], key, level)\n      }\n    }\n  }\n  return {attrStr: attrStr, val: val};\n};\n\nBuilder.prototype.buildAttrPairStr = function(attrName, val){\n  val = this.options.attributeValueProcessor(attrName, '' + val);\n  val = this.replaceEntitiesValue(val);\n  if (this.options.suppressBooleanAttributes && val === \"true\") {\n    return ' ' + attrName;\n  } else return ' ' + attrName + '=\"' + val + '\"';\n}\n\nfunction processTextOrObjNode (object, key, level) {\n  const result = this.j2x(object, level + 1);\n  if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {\n    return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);\n  } else {\n    return this.buildObjectNode(result.val, key, result.attrStr, level);\n  }\n}\n\nBuilder.prototype.buildObjectNode = function(val, key, attrStr, level) {\n  if(val === \"\"){\n    if(key[0] === \"?\") return  this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n    else {\n      return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n    }\n  }else{\n\n    let tagEndExp = '</' + key + this.tagEndChar;\n    let piClosingChar = \"\";\n    \n    if(key[0] === \"?\") {\n      piClosingChar = \"?\";\n      tagEndExp = \"\";\n    }\n  \n    // attrStr is an empty string in case the attribute came as undefined or null\n    if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {\n      return ( this.indentate(level) + '<' +  key + attrStr + piClosingChar + '>' + val + tagEndExp );\n    } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {\n      return this.indentate(level) + `<!--${val}-->` + this.newLine;\n    }else {\n      return (\n        this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +\n        val +\n        this.indentate(level) + tagEndExp    );\n    }\n  }\n}\n\nBuilder.prototype.closeTag = function(key){\n  let closeTag = \"\";\n  if(this.options.unpairedTags.indexOf(key) !== -1){ //unpaired\n    if(!this.options.suppressUnpairedNode) closeTag = \"/\"\n  }else if(this.options.suppressEmptyNode){ //empty\n    closeTag = \"/\";\n  }else{\n    closeTag = `></${key}`\n  }\n  return closeTag;\n}\n\nfunction buildEmptyObjNode(val, key, attrStr, level) {\n  if (val !== '') {\n    return this.buildObjectNode(val, key, attrStr, level);\n  } else {\n    if(key[0] === \"?\") return  this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n    else {\n      return  this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;\n      // return this.buildTagStr(level,key, attrStr);\n    }\n  }\n}\n\nBuilder.prototype.buildTextValNode = function(val, key, attrStr, level) {\n  if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {\n    return this.indentate(level) + `<![CDATA[${val}]]>` +  this.newLine;\n  }else if (this.options.commentPropName !== false && key === this.options.commentPropName) {\n    return this.indentate(level) + `<!--${val}-->` +  this.newLine;\n  }else if(key[0] === \"?\") {//PI tag\n    return  this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; \n  }else{\n    let textValue = this.options.tagValueProcessor(key, val);\n    textValue = this.replaceEntitiesValue(textValue);\n  \n    if( textValue === ''){\n      return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n    }else{\n      return this.indentate(level) + '<' + key + attrStr + '>' +\n         textValue +\n        '</' + key + this.tagEndChar;\n    }\n  }\n}\n\nBuilder.prototype.replaceEntitiesValue = function(textValue){\n  if(textValue && textValue.length > 0 && this.options.processEntities){\n    for (let i=0; i<this.options.entities.length; i++) {\n      const entity = this.options.entities[i];\n      textValue = textValue.replace(entity.regex, entity.val);\n    }\n  }\n  return textValue;\n}\n\nfunction indentate(level) {\n  return this.options.indentBy.repeat(level);\n}\n\nfunction isAttribute(name /*, options*/) {\n  if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {\n    return name.substr(this.attrPrefixLen);\n  } else {\n    return false;\n  }\n}\n\nmodule.exports = Builder;\n", "'use strict';\n\nconst validator = require('./validator');\nconst XMLParser = require('./xmlparser/XMLParser');\nconst XMLBuilder = require('./xmlbuilder/json2xml');\n\nmodule.exports = {\n  XMLParser: XMLParser,\n  XMLValidator: validator,\n  XMLBuilder: XMLBuilder\n}", "// src/middleware/cors/index.ts\nvar cors = (options) => {\n  const defaults = {\n    origin: \"*\",\n    allowMethods: [\"GET\", \"HEAD\", \"PUT\", \"POST\", \"DELETE\", \"PATCH\"],\n    allowHeaders: [],\n    exposeHeaders: []\n  };\n  const opts = {\n    ...defaults,\n    ...options\n  };\n  const findAllowOrigin = ((optsOrigin) => {\n    if (typeof optsOrigin === \"string\") {\n      if (optsOrigin === \"*\") {\n        return () => optsOrigin;\n      } else {\n        return (origin) => optsOrigin === origin ? origin : null;\n      }\n    } else if (typeof optsOrigin === \"function\") {\n      return optsOrigin;\n    } else {\n      return (origin) => optsOrigin.includes(origin) ? origin : null;\n    }\n  })(opts.origin);\n  const findAllowMethods = ((optsAllowMethods) => {\n    if (typeof optsAllowMethods === \"function\") {\n      return optsAllowMethods;\n    } else if (Array.isArray(optsAllowMethods)) {\n      return () => optsAllowMethods;\n    } else {\n      return () => [];\n    }\n  })(opts.allowMethods);\n  return async function cors2(c, next) {\n    function set(key, value) {\n      c.res.headers.set(key, value);\n    }\n    const allowOrigin = await findAllowOrigin(c.req.header(\"origin\") || \"\", c);\n    if (allowOrigin) {\n      set(\"Access-Control-Allow-Origin\", allowOrigin);\n    }\n    if (opts.credentials) {\n      set(\"Access-Control-Allow-Credentials\", \"true\");\n    }\n    if (opts.exposeHeaders?.length) {\n      set(\"Access-Control-Expose-Headers\", opts.exposeHeaders.join(\",\"));\n    }\n    if (c.req.method === \"OPTIONS\") {\n      if (opts.origin !== \"*\") {\n        set(\"Vary\", \"Origin\");\n      }\n      if (opts.maxAge != null) {\n        set(\"Access-Control-Max-Age\", opts.maxAge.toString());\n      }\n      const allowMethods = await findAllowMethods(c.req.header(\"origin\") || \"\", c);\n      if (allowMethods.length) {\n        set(\"Access-Control-Allow-Methods\", allowMethods.join(\",\"));\n      }\n      let headers = opts.allowHeaders;\n      if (!headers?.length) {\n        const requestHeaders = c.req.header(\"Access-Control-Request-Headers\");\n        if (requestHeaders) {\n          headers = requestHeaders.split(/\\s*,\\s*/);\n        }\n      }\n      if (headers?.length) {\n        set(\"Access-Control-Allow-Headers\", headers.join(\",\"));\n        c.res.headers.append(\"Vary\", \"Access-Control-Request-Headers\");\n      }\n      c.res.headers.delete(\"Content-Length\");\n      c.res.headers.delete(\"Content-Type\");\n      return new Response(null, {\n        headers: c.res.headers,\n        status: 204,\n        statusText: \"No Content\"\n      });\n    }\n    await next();\n    if (opts.origin !== \"*\") {\n      c.header(\"Vary\", \"Origin\", { append: true });\n    }\n  };\n};\nexport {\n  cors\n};\n", "// src/compose.ts\nvar compose = (middleware, onError, onNotFound) => {\n  return (context, next) => {\n    let index = -1;\n    return dispatch(0);\n    async function dispatch(i) {\n      if (i <= index) {\n        throw new Error(\"next() called multiple times\");\n      }\n      index = i;\n      let res;\n      let isError = false;\n      let handler;\n      if (middleware[i]) {\n        handler = middleware[i][0][0];\n        context.req.routeIndex = i;\n      } else {\n        handler = i === middleware.length && next || void 0;\n      }\n      if (handler) {\n        try {\n          res = await handler(context, () => dispatch(i + 1));\n        } catch (err) {\n          if (err instanceof Error && onError) {\n            context.error = err;\n            res = await onError(err, context);\n            isError = true;\n          } else {\n            throw err;\n          }\n        }\n      } else {\n        if (context.finalized === false && onNotFound) {\n          res = await onNotFound(context);\n        }\n      }\n      if (res && (context.finalized === false || isError)) {\n        context.res = res;\n      }\n      return context;\n    }\n  };\n};\nexport {\n  compose\n};\n", "// src/request/constants.ts\nvar GET_MATCH_RESULT = /* @__PURE__ */ Symbol();\nexport {\n  GET_MATCH_RESULT\n};\n", "// src/utils/body.ts\nimport { HonoRequest } from \"../request.js\";\nvar parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {\n  const { all = false, dot = false } = options;\n  const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;\n  const contentType = headers.get(\"Content-Type\");\n  if (contentType?.startsWith(\"multipart/form-data\") || contentType?.startsWith(\"application/x-www-form-urlencoded\")) {\n    return parseFormData(request, { all, dot });\n  }\n  return {};\n};\nasync function parseFormData(request, options) {\n  const formData = await request.formData();\n  if (formData) {\n    return convertFormDataToBodyData(formData, options);\n  }\n  return {};\n}\nfunction convertFormDataToBodyData(formData, options) {\n  const form = /* @__PURE__ */ Object.create(null);\n  formData.forEach((value, key) => {\n    const shouldParseAllValues = options.all || key.endsWith(\"[]\");\n    if (!shouldParseAllValues) {\n      form[key] = value;\n    } else {\n      handleParsingAllValues(form, key, value);\n    }\n  });\n  if (options.dot) {\n    Object.entries(form).forEach(([key, value]) => {\n      const shouldParseDotValues = key.includes(\".\");\n      if (shouldParseDotValues) {\n        handleParsingNestedValues(form, key, value);\n        delete form[key];\n      }\n    });\n  }\n  return form;\n}\nvar handleParsingAllValues = (form, key, value) => {\n  if (form[key] !== void 0) {\n    if (Array.isArray(form[key])) {\n      ;\n      form[key].push(value);\n    } else {\n      form[key] = [form[key], value];\n    }\n  } else {\n    if (!key.endsWith(\"[]\")) {\n      form[key] = value;\n    } else {\n      form[key] = [value];\n    }\n  }\n};\nvar handleParsingNestedValues = (form, key, value) => {\n  let nestedForm = form;\n  const keys = key.split(\".\");\n  keys.forEach((key2, index) => {\n    if (index === keys.length - 1) {\n      nestedForm[key2] = value;\n    } else {\n      if (!nestedForm[key2] || typeof nestedForm[key2] !== \"object\" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {\n        nestedForm[key2] = /* @__PURE__ */ Object.create(null);\n      }\n      nestedForm = nestedForm[key2];\n    }\n  });\n};\nexport {\n  parseBody\n};\n", "// src/utils/url.ts\nvar splitPath = (path) => {\n  const paths = path.split(\"/\");\n  if (paths[0] === \"\") {\n    paths.shift();\n  }\n  return paths;\n};\nvar splitRoutingPath = (routePath) => {\n  const { groups, path } = extractGroupsFromPath(routePath);\n  const paths = splitPath(path);\n  return replaceGroupMarks(paths, groups);\n};\nvar extractGroupsFromPath = (path) => {\n  const groups = [];\n  path = path.replace(/\\{[^}]+\\}/g, (match, index) => {\n    const mark = `@${index}`;\n    groups.push([mark, match]);\n    return mark;\n  });\n  return { groups, path };\n};\nvar replaceGroupMarks = (paths, groups) => {\n  for (let i = groups.length - 1; i >= 0; i--) {\n    const [mark] = groups[i];\n    for (let j = paths.length - 1; j >= 0; j--) {\n      if (paths[j].includes(mark)) {\n        paths[j] = paths[j].replace(mark, groups[i][1]);\n        break;\n      }\n    }\n  }\n  return paths;\n};\nvar patternCache = {};\nvar getPattern = (label, next) => {\n  if (label === \"*\") {\n    return \"*\";\n  }\n  const match = label.match(/^\\:([^\\{\\}]+)(?:\\{(.+)\\})?$/);\n  if (match) {\n    const cacheKey = `${label}#${next}`;\n    if (!patternCache[cacheKey]) {\n      if (match[2]) {\n        patternCache[cacheKey] = next && next[0] !== \":\" && next[0] !== \"*\" ? [cacheKey, match[1], new RegExp(`^${match[2]}(?=/${next})`)] : [label, match[1], new RegExp(`^${match[2]}$`)];\n      } else {\n        patternCache[cacheKey] = [label, match[1], true];\n      }\n    }\n    return patternCache[cacheKey];\n  }\n  return null;\n};\nvar tryDecode = (str, decoder) => {\n  try {\n    return decoder(str);\n  } catch {\n    return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {\n      try {\n        return decoder(match);\n      } catch {\n        return match;\n      }\n    });\n  }\n};\nvar tryDecodeURI = (str) => tryDecode(str, decodeURI);\nvar getPath = (request) => {\n  const url = request.url;\n  const start = url.indexOf(\"/\", url.indexOf(\":\") + 4);\n  let i = start;\n  for (; i < url.length; i++) {\n    const charCode = url.charCodeAt(i);\n    if (charCode === 37) {\n      const queryIndex = url.indexOf(\"?\", i);\n      const hashIndex = url.indexOf(\"#\", i);\n      const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);\n      const path = url.slice(start, end);\n      return tryDecodeURI(path.includes(\"%25\") ? path.replace(/%25/g, \"%2525\") : path);\n    } else if (charCode === 63 || charCode === 35) {\n      break;\n    }\n  }\n  return url.slice(start, i);\n};\nvar getQueryStrings = (url) => {\n  const queryIndex = url.indexOf(\"?\", 8);\n  return queryIndex === -1 ? \"\" : \"?\" + url.slice(queryIndex + 1);\n};\nvar getPathNoStrict = (request) => {\n  const result = getPath(request);\n  return result.length > 1 && result.at(-1) === \"/\" ? result.slice(0, -1) : result;\n};\nvar mergePath = (base, sub, ...rest) => {\n  if (rest.length) {\n    sub = mergePath(sub, ...rest);\n  }\n  return `${base?.[0] === \"/\" ? \"\" : \"/\"}${base}${sub === \"/\" ? \"\" : `${base?.at(-1) === \"/\" ? \"\" : \"/\"}${sub?.[0] === \"/\" ? sub.slice(1) : sub}`}`;\n};\nvar checkOptionalParameter = (path) => {\n  if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(\":\")) {\n    return null;\n  }\n  const segments = path.split(\"/\");\n  const results = [];\n  let basePath = \"\";\n  segments.forEach((segment) => {\n    if (segment !== \"\" && !/\\:/.test(segment)) {\n      basePath += \"/\" + segment;\n    } else if (/\\:/.test(segment)) {\n      if (/\\?/.test(segment)) {\n        if (results.length === 0 && basePath === \"\") {\n          results.push(\"/\");\n        } else {\n          results.push(basePath);\n        }\n        const optionalSegment = segment.replace(\"?\", \"\");\n        basePath += \"/\" + optionalSegment;\n        results.push(basePath);\n      } else {\n        basePath += \"/\" + segment;\n      }\n    }\n  });\n  return results.filter((v, i, a) => a.indexOf(v) === i);\n};\nvar _decodeURI = (value) => {\n  if (!/[%+]/.test(value)) {\n    return value;\n  }\n  if (value.indexOf(\"+\") !== -1) {\n    value = value.replace(/\\+/g, \" \");\n  }\n  return value.indexOf(\"%\") !== -1 ? tryDecode(value, decodeURIComponent_) : value;\n};\nvar _getQueryParam = (url, key, multiple) => {\n  let encoded;\n  if (!multiple && key && !/[%+]/.test(key)) {\n    let keyIndex2 = url.indexOf(\"?\", 8);\n    if (keyIndex2 === -1) {\n      return void 0;\n    }\n    if (!url.startsWith(key, keyIndex2 + 1)) {\n      keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);\n    }\n    while (keyIndex2 !== -1) {\n      const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);\n      if (trailingKeyCode === 61) {\n        const valueIndex = keyIndex2 + key.length + 2;\n        const endIndex = url.indexOf(\"&\", valueIndex);\n        return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));\n      } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {\n        return \"\";\n      }\n      keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);\n    }\n    encoded = /[%+]/.test(url);\n    if (!encoded) {\n      return void 0;\n    }\n  }\n  const results = {};\n  encoded ??= /[%+]/.test(url);\n  let keyIndex = url.indexOf(\"?\", 8);\n  while (keyIndex !== -1) {\n    const nextKeyIndex = url.indexOf(\"&\", keyIndex + 1);\n    let valueIndex = url.indexOf(\"=\", keyIndex);\n    if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {\n      valueIndex = -1;\n    }\n    let name = url.slice(\n      keyIndex + 1,\n      valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex\n    );\n    if (encoded) {\n      name = _decodeURI(name);\n    }\n    keyIndex = nextKeyIndex;\n    if (name === \"\") {\n      continue;\n    }\n    let value;\n    if (valueIndex === -1) {\n      value = \"\";\n    } else {\n      value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);\n      if (encoded) {\n        value = _decodeURI(value);\n      }\n    }\n    if (multiple) {\n      if (!(results[name] && Array.isArray(results[name]))) {\n        results[name] = [];\n      }\n      ;\n      results[name].push(value);\n    } else {\n      results[name] ??= value;\n    }\n  }\n  return key ? results[key] : results;\n};\nvar getQueryParam = _getQueryParam;\nvar getQueryParams = (url, key) => {\n  return _getQueryParam(url, key, true);\n};\nvar decodeURIComponent_ = decodeURIComponent;\nexport {\n  checkOptionalParameter,\n  decodeURIComponent_,\n  getPath,\n  getPathNoStrict,\n  getPattern,\n  getQueryParam,\n  getQueryParams,\n  getQueryStrings,\n  mergePath,\n  splitPath,\n  splitRoutingPath,\n  tryDecode,\n  tryDecodeURI\n};\n", "// src/request.ts\nimport { HTTPException } from \"./http-exception.js\";\nimport { GET_MATCH_RESULT } from \"./request/constants.js\";\nimport { parseBody } from \"./utils/body.js\";\nimport { decodeURIComponent_, getQueryParam, getQueryParams, tryDecode } from \"./utils/url.js\";\nvar tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);\nvar HonoRequest = class {\n  /**\n   * `.raw` can get the raw Request object.\n   *\n   * @see {@link https://hono.dev/docs/api/request#raw}\n   *\n   * @example\n   * ```ts\n   * // For Cloudflare Workers\n   * app.post('/', async (c) => {\n   *   const metadata = c.req.raw.cf?.hostMetadata?\n   *   ...\n   * })\n   * ```\n   */\n  raw;\n  #validatedData;\n  // Short name of validatedData\n  #matchResult;\n  routeIndex = 0;\n  /**\n   * `.path` can get the pathname of the request.\n   *\n   * @see {@link https://hono.dev/docs/api/request#path}\n   *\n   * @example\n   * ```ts\n   * app.get('/about/me', (c) => {\n   *   const pathname = c.req.path // `/about/me`\n   * })\n   * ```\n   */\n  path;\n  bodyCache = {};\n  constructor(request, path = \"/\", matchResult = [[]]) {\n    this.raw = request;\n    this.path = path;\n    this.#matchResult = matchResult;\n    this.#validatedData = {};\n  }\n  param(key) {\n    return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();\n  }\n  #getDecodedParam(key) {\n    const paramKey = this.#matchResult[0][this.routeIndex][1][key];\n    const param = this.#getParamValue(paramKey);\n    return param && /\\%/.test(param) ? tryDecodeURIComponent(param) : param;\n  }\n  #getAllDecodedParams() {\n    const decoded = {};\n    const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);\n    for (const key of keys) {\n      const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);\n      if (value !== void 0) {\n        decoded[key] = /\\%/.test(value) ? tryDecodeURIComponent(value) : value;\n      }\n    }\n    return decoded;\n  }\n  #getParamValue(paramKey) {\n    return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;\n  }\n  query(key) {\n    return getQueryParam(this.url, key);\n  }\n  queries(key) {\n    return getQueryParams(this.url, key);\n  }\n  header(name) {\n    if (name) {\n      return this.raw.headers.get(name) ?? void 0;\n    }\n    const headerData = {};\n    this.raw.headers.forEach((value, key) => {\n      headerData[key] = value;\n    });\n    return headerData;\n  }\n  async parseBody(options) {\n    return this.bodyCache.parsedBody ??= await parseBody(this, options);\n  }\n  #cachedBody = (key) => {\n    const { bodyCache, raw } = this;\n    const cachedBody = bodyCache[key];\n    if (cachedBody) {\n      return cachedBody;\n    }\n    const anyCachedKey = Object.keys(bodyCache)[0];\n    if (anyCachedKey) {\n      return bodyCache[anyCachedKey].then((body) => {\n        if (anyCachedKey === \"json\") {\n          body = JSON.stringify(body);\n        }\n        return new Response(body)[key]();\n      });\n    }\n    return bodyCache[key] = raw[key]();\n  };\n  /**\n   * `.json()` can parse Request body of type `application/json`\n   *\n   * @see {@link https://hono.dev/docs/api/request#json}\n   *\n   * @example\n   * ```ts\n   * app.post('/entry', async (c) => {\n   *   const body = await c.req.json()\n   * })\n   * ```\n   */\n  json() {\n    return this.#cachedBody(\"text\").then((text) => JSON.parse(text));\n  }\n  /**\n   * `.text()` can parse Request body of type `text/plain`\n   *\n   * @see {@link https://hono.dev/docs/api/request#text}\n   *\n   * @example\n   * ```ts\n   * app.post('/entry', async (c) => {\n   *   const body = await c.req.text()\n   * })\n   * ```\n   */\n  text() {\n    return this.#cachedBody(\"text\");\n  }\n  /**\n   * `.arrayBuffer()` parse Request body as an `ArrayBuffer`\n   *\n   * @see {@link https://hono.dev/docs/api/request#arraybuffer}\n   *\n   * @example\n   * ```ts\n   * app.post('/entry', async (c) => {\n   *   const body = await c.req.arrayBuffer()\n   * })\n   * ```\n   */\n  arrayBuffer() {\n    return this.#cachedBody(\"arrayBuffer\");\n  }\n  /**\n   * Parses the request body as a `Blob`.\n   * @example\n   * ```ts\n   * app.post('/entry', async (c) => {\n   *   const body = await c.req.blob();\n   * });\n   * ```\n   * @see https://hono.dev/docs/api/request#blob\n   */\n  blob() {\n    return this.#cachedBody(\"blob\");\n  }\n  /**\n   * Parses the request body as `FormData`.\n   * @example\n   * ```ts\n   * app.post('/entry', async (c) => {\n   *   const body = await c.req.formData();\n   * });\n   * ```\n   * @see https://hono.dev/docs/api/request#formdata\n   */\n  formData() {\n    return this.#cachedBody(\"formData\");\n  }\n  /**\n   * Adds validated data to the request.\n   *\n   * @param target - The target of the validation.\n   * @param data - The validated data to add.\n   */\n  addValidatedData(target, data) {\n    this.#validatedData[target] = data;\n  }\n  valid(target) {\n    return this.#validatedData[target];\n  }\n  /**\n   * `.url()` can get the request url strings.\n   *\n   * @see {@link https://hono.dev/docs/api/request#url}\n   *\n   * @example\n   * ```ts\n   * app.get('/about/me', (c) => {\n   *   const url = c.req.url // `http://localhost:8787/about/me`\n   *   ...\n   * })\n   * ```\n   */\n  get url() {\n    return this.raw.url;\n  }\n  /**\n   * `.method()` can get the method name of the request.\n   *\n   * @see {@link https://hono.dev/docs/api/request#method}\n   *\n   * @example\n   * ```ts\n   * app.get('/about/me', (c) => {\n   *   const method = c.req.method // `GET`\n   * })\n   * ```\n   */\n  get method() {\n    return this.raw.method;\n  }\n  get [GET_MATCH_RESULT]() {\n    return this.#matchResult;\n  }\n  /**\n   * `.matchedRoutes()` can return a matched route in the handler\n   *\n   * @deprecated\n   *\n   * Use matchedRoutes helper defined in \"hono/route\" instead.\n   *\n   * @see {@link https://hono.dev/docs/api/request#matchedroutes}\n   *\n   * @example\n   * ```ts\n   * app.use('*', async function logger(c, next) {\n   *   await next()\n   *   c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {\n   *     const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')\n   *     console.log(\n   *       method,\n   *       ' ',\n   *       path,\n   *       ' '.repeat(Math.max(10 - path.length, 0)),\n   *       name,\n   *       i === c.req.routeIndex ? '<- respond from here' : ''\n   *     )\n   *   })\n   * })\n   * ```\n   */\n  get matchedRoutes() {\n    return this.#matchResult[0].map(([[, route]]) => route);\n  }\n  /**\n   * `routePath()` can retrieve the path registered within the handler\n   *\n   * @deprecated\n   *\n   * Use routePath helper defined in \"hono/route\" instead.\n   *\n   * @see {@link https://hono.dev/docs/api/request#routepath}\n   *\n   * @example\n   * ```ts\n   * app.get('/posts/:id', (c) => {\n   *   return c.json({ path: c.req.routePath })\n   * })\n   * ```\n   */\n  get routePath() {\n    return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;\n  }\n};\nvar cloneRawRequest = async (req) => {\n  if (!req.raw.bodyUsed) {\n    return req.raw.clone();\n  }\n  const cacheKey = Object.keys(req.bodyCache)[0];\n  if (!cacheKey) {\n    throw new HTTPException(500, {\n      message: \"Cannot clone request: body was already consumed and not cached. Please use HonoRequest methods (e.g., req.json(), req.text()) instead of consuming req.raw directly.\"\n    });\n  }\n  const requestInit = {\n    body: await req[cacheKey](),\n    cache: req.raw.cache,\n    credentials: req.raw.credentials,\n    headers: req.header(),\n    integrity: req.raw.integrity,\n    keepalive: req.raw.keepalive,\n    method: req.method,\n    mode: req.raw.mode,\n    redirect: req.raw.redirect,\n    referrer: req.raw.referrer,\n    referrerPolicy: req.raw.referrerPolicy,\n    signal: req.raw.signal\n  };\n  return new Request(req.url, requestInit);\n};\nexport {\n  HonoRequest,\n  cloneRawRequest\n};\n", "// src/utils/html.ts\nvar HtmlEscapedCallbackPhase = {\n  Stringify: 1,\n  BeforeStream: 2,\n  Stream: 3\n};\nvar raw = (value, callbacks) => {\n  const escapedString = new String(value);\n  escapedString.isEscaped = true;\n  escapedString.callbacks = callbacks;\n  return escapedString;\n};\nvar escapeRe = /[&<>'\"]/;\nvar stringBufferToString = async (buffer, callbacks) => {\n  let str = \"\";\n  callbacks ||= [];\n  const resolvedBuffer = await Promise.all(buffer);\n  for (let i = resolvedBuffer.length - 1; ; i--) {\n    str += resolvedBuffer[i];\n    i--;\n    if (i < 0) {\n      break;\n    }\n    let r = resolvedBuffer[i];\n    if (typeof r === \"object\") {\n      callbacks.push(...r.callbacks || []);\n    }\n    const isEscaped = r.isEscaped;\n    r = await (typeof r === \"object\" ? r.toString() : r);\n    if (typeof r === \"object\") {\n      callbacks.push(...r.callbacks || []);\n    }\n    if (r.isEscaped ?? isEscaped) {\n      str += r;\n    } else {\n      const buf = [str];\n      escapeToBuffer(r, buf);\n      str = buf[0];\n    }\n  }\n  return raw(str, callbacks);\n};\nvar escapeToBuffer = (str, buffer) => {\n  const match = str.search(escapeRe);\n  if (match === -1) {\n    buffer[0] += str;\n    return;\n  }\n  let escape;\n  let index;\n  let lastIndex = 0;\n  for (index = match; index < str.length; index++) {\n    switch (str.charCodeAt(index)) {\n      case 34:\n        escape = \"&quot;\";\n        break;\n      case 39:\n        escape = \"&#39;\";\n        break;\n      case 38:\n        escape = \"&amp;\";\n        break;\n      case 60:\n        escape = \"&lt;\";\n        break;\n      case 62:\n        escape = \"&gt;\";\n        break;\n      default:\n        continue;\n    }\n    buffer[0] += str.substring(lastIndex, index) + escape;\n    lastIndex = index + 1;\n  }\n  buffer[0] += str.substring(lastIndex, index);\n};\nvar resolveCallbackSync = (str) => {\n  const callbacks = str.callbacks;\n  if (!callbacks?.length) {\n    return str;\n  }\n  const buffer = [str];\n  const context = {};\n  callbacks.forEach((c) => c({ phase: HtmlEscapedCallbackPhase.Stringify, buffer, context }));\n  return buffer[0];\n};\nvar resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {\n  if (typeof str === \"object\" && !(str instanceof String)) {\n    if (!(str instanceof Promise)) {\n      str = str.toString();\n    }\n    if (str instanceof Promise) {\n      str = await str;\n    }\n  }\n  const callbacks = str.callbacks;\n  if (!callbacks?.length) {\n    return Promise.resolve(str);\n  }\n  if (buffer) {\n    buffer[0] += str;\n  } else {\n    buffer = [str];\n  }\n  const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context }))).then(\n    (res) => Promise.all(\n      res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))\n    ).then(() => buffer[0])\n  );\n  if (preserveCallbacks) {\n    return raw(await resStr, callbacks);\n  } else {\n    return resStr;\n  }\n};\nexport {\n  HtmlEscapedCallbackPhase,\n  escapeToBuffer,\n  raw,\n  resolveCallback,\n  resolveCallbackSync,\n  stringBufferToString\n};\n", "// src/context.ts\nimport { HonoRequest } from \"./request.js\";\nimport { HtmlEscapedCallbackPhase, resolveCallback } from \"./utils/html.js\";\nvar TEXT_PLAIN = \"text/plain; charset=UTF-8\";\nvar setDefaultContentType = (contentType, headers) => {\n  return {\n    \"Content-Type\": contentType,\n    ...headers\n  };\n};\nvar createResponseInstance = (body, init) => new Response(body, init);\nvar Context = class {\n  #rawRequest;\n  #req;\n  /**\n   * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.\n   *\n   * @see {@link https://hono.dev/docs/api/context#env}\n   *\n   * @example\n   * ```ts\n   * // Environment object for Cloudflare Workers\n   * app.get('*', async c => {\n   *   const counter = c.env.COUNTER\n   * })\n   * ```\n   */\n  env = {};\n  #var;\n  finalized = false;\n  /**\n   * `.error` can get the error object from the middleware if the Handler throws an error.\n   *\n   * @see {@link https://hono.dev/docs/api/context#error}\n   *\n   * @example\n   * ```ts\n   * app.use('*', async (c, next) => {\n   *   await next()\n   *   if (c.error) {\n   *     // do something...\n   *   }\n   * })\n   * ```\n   */\n  error;\n  #status;\n  #executionCtx;\n  #res;\n  #layout;\n  #renderer;\n  #notFoundHandler;\n  #preparedHeaders;\n  #matchResult;\n  #path;\n  /**\n   * Creates an instance of the Context class.\n   *\n   * @param req - The Request object.\n   * @param options - Optional configuration options for the context.\n   */\n  constructor(req, options) {\n    this.#rawRequest = req;\n    if (options) {\n      this.#executionCtx = options.executionCtx;\n      this.env = options.env;\n      this.#notFoundHandler = options.notFoundHandler;\n      this.#path = options.path;\n      this.#matchResult = options.matchResult;\n    }\n  }\n  /**\n   * `.req` is the instance of {@link HonoRequest}.\n   */\n  get req() {\n    this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);\n    return this.#req;\n  }\n  /**\n   * @see {@link https://hono.dev/docs/api/context#event}\n   * The FetchEvent associated with the current request.\n   *\n   * @throws Will throw an error if the context does not have a FetchEvent.\n   */\n  get event() {\n    if (this.#executionCtx && \"respondWith\" in this.#executionCtx) {\n      return this.#executionCtx;\n    } else {\n      throw Error(\"This context has no FetchEvent\");\n    }\n  }\n  /**\n   * @see {@link https://hono.dev/docs/api/context#executionctx}\n   * The ExecutionContext associated with the current request.\n   *\n   * @throws Will throw an error if the context does not have an ExecutionContext.\n   */\n  get executionCtx() {\n    if (this.#executionCtx) {\n      return this.#executionCtx;\n    } else {\n      throw Error(\"This context has no ExecutionContext\");\n    }\n  }\n  /**\n   * @see {@link https://hono.dev/docs/api/context#res}\n   * The Response object for the current request.\n   */\n  get res() {\n    return this.#res ||= createResponseInstance(null, {\n      headers: this.#preparedHeaders ??= new Headers()\n    });\n  }\n  /**\n   * Sets the Response object for the current request.\n   *\n   * @param _res - The Response object to set.\n   */\n  set res(_res) {\n    if (this.#res && _res) {\n      _res = createResponseInstance(_res.body, _res);\n      for (const [k, v] of this.#res.headers.entries()) {\n        if (k === \"content-type\") {\n          continue;\n        }\n        if (k === \"set-cookie\") {\n          const cookies = this.#res.headers.getSetCookie();\n          _res.headers.delete(\"set-cookie\");\n          for (const cookie of cookies) {\n            _res.headers.append(\"set-cookie\", cookie);\n          }\n        } else {\n          _res.headers.set(k, v);\n        }\n      }\n    }\n    this.#res = _res;\n    this.finalized = true;\n  }\n  /**\n   * `.render()` can create a response within a layout.\n   *\n   * @see {@link https://hono.dev/docs/api/context#render-setrenderer}\n   *\n   * @example\n   * ```ts\n   * app.get('/', (c) => {\n   *   return c.render('Hello!')\n   * })\n   * ```\n   */\n  render = (...args) => {\n    this.#renderer ??= (content) => this.html(content);\n    return this.#renderer(...args);\n  };\n  /**\n   * Sets the layout for the response.\n   *\n   * @param layout - The layout to set.\n   * @returns The layout function.\n   */\n  setLayout = (layout) => this.#layout = layout;\n  /**\n   * Gets the current layout for the response.\n   *\n   * @returns The current layout function.\n   */\n  getLayout = () => this.#layout;\n  /**\n   * `.setRenderer()` can set the layout in the custom middleware.\n   *\n   * @see {@link https://hono.dev/docs/api/context#render-setrenderer}\n   *\n   * @example\n   * ```tsx\n   * app.use('*', async (c, next) => {\n   *   c.setRenderer((content) => {\n   *     return c.html(\n   *       <html>\n   *         <body>\n   *           <p>{content}</p>\n   *         </body>\n   *       </html>\n   *     )\n   *   })\n   *   await next()\n   * })\n   * ```\n   */\n  setRenderer = (renderer) => {\n    this.#renderer = renderer;\n  };\n  /**\n   * `.header()` can set headers.\n   *\n   * @see {@link https://hono.dev/docs/api/context#header}\n   *\n   * @example\n   * ```ts\n   * app.get('/welcome', (c) => {\n   *   // Set headers\n   *   c.header('X-Message', 'Hello!')\n   *   c.header('Content-Type', 'text/plain')\n   *\n   *   return c.body('Thank you for coming')\n   * })\n   * ```\n   */\n  header = (name, value, options) => {\n    if (this.finalized) {\n      this.#res = createResponseInstance(this.#res.body, this.#res);\n    }\n    const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();\n    if (value === void 0) {\n      headers.delete(name);\n    } else if (options?.append) {\n      headers.append(name, value);\n    } else {\n      headers.set(name, value);\n    }\n  };\n  status = (status) => {\n    this.#status = status;\n  };\n  /**\n   * `.set()` can set the value specified by the key.\n   *\n   * @see {@link https://hono.dev/docs/api/context#set-get}\n   *\n   * @example\n   * ```ts\n   * app.use('*', async (c, next) => {\n   *   c.set('message', 'Hono is hot!!')\n   *   await next()\n   * })\n   * ```\n   */\n  set = (key, value) => {\n    this.#var ??= /* @__PURE__ */ new Map();\n    this.#var.set(key, value);\n  };\n  /**\n   * `.get()` can use the value specified by the key.\n   *\n   * @see {@link https://hono.dev/docs/api/context#set-get}\n   *\n   * @example\n   * ```ts\n   * app.get('/', (c) => {\n   *   const message = c.get('message')\n   *   return c.text(`The message is \"${message}\"`)\n   * })\n   * ```\n   */\n  get = (key) => {\n    return this.#var ? this.#var.get(key) : void 0;\n  };\n  /**\n   * `.var` can access the value of a variable.\n   *\n   * @see {@link https://hono.dev/docs/api/context#var}\n   *\n   * @example\n   * ```ts\n   * const result = c.var.client.oneMethod()\n   * ```\n   */\n  // c.var.propName is a read-only\n  get var() {\n    if (!this.#var) {\n      return {};\n    }\n    return Object.fromEntries(this.#var);\n  }\n  #newResponse(data, arg, headers) {\n    const responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders ?? new Headers();\n    if (typeof arg === \"object\" && \"headers\" in arg) {\n      const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);\n      for (const [key, value] of argHeaders) {\n        if (key.toLowerCase() === \"set-cookie\") {\n          responseHeaders.append(key, value);\n        } else {\n          responseHeaders.set(key, value);\n        }\n      }\n    }\n    if (headers) {\n      for (const [k, v] of Object.entries(headers)) {\n        if (typeof v === \"string\") {\n          responseHeaders.set(k, v);\n        } else {\n          responseHeaders.delete(k);\n          for (const v2 of v) {\n            responseHeaders.append(k, v2);\n          }\n        }\n      }\n    }\n    const status = typeof arg === \"number\" ? arg : arg?.status ?? this.#status;\n    return createResponseInstance(data, { status, headers: responseHeaders });\n  }\n  newResponse = (...args) => this.#newResponse(...args);\n  /**\n   * `.body()` can return the HTTP response.\n   * You can set headers with `.header()` and set HTTP status code with `.status`.\n   * This can also be set in `.text()`, `.json()` and so on.\n   *\n   * @see {@link https://hono.dev/docs/api/context#body}\n   *\n   * @example\n   * ```ts\n   * app.get('/welcome', (c) => {\n   *   // Set headers\n   *   c.header('X-Message', 'Hello!')\n   *   c.header('Content-Type', 'text/plain')\n   *   // Set HTTP status code\n   *   c.status(201)\n   *\n   *   // Return the response body\n   *   return c.body('Thank you for coming')\n   * })\n   * ```\n   */\n  body = (data, arg, headers) => this.#newResponse(data, arg, headers);\n  /**\n   * `.text()` can render text as `Content-Type:text/plain`.\n   *\n   * @see {@link https://hono.dev/docs/api/context#text}\n   *\n   * @example\n   * ```ts\n   * app.get('/say', (c) => {\n   *   return c.text('Hello!')\n   * })\n   * ```\n   */\n  text = (text, arg, headers) => {\n    return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(\n      text,\n      arg,\n      setDefaultContentType(TEXT_PLAIN, headers)\n    );\n  };\n  /**\n   * `.json()` can render JSON as `Content-Type:application/json`.\n   *\n   * @see {@link https://hono.dev/docs/api/context#json}\n   *\n   * @example\n   * ```ts\n   * app.get('/api', (c) => {\n   *   return c.json({ message: 'Hello!' })\n   * })\n   * ```\n   */\n  json = (object, arg, headers) => {\n    return this.#newResponse(\n      JSON.stringify(object),\n      arg,\n      setDefaultContentType(\"application/json\", headers)\n    );\n  };\n  html = (html, arg, headers) => {\n    const res = (html2) => this.#newResponse(html2, arg, setDefaultContentType(\"text/html; charset=UTF-8\", headers));\n    return typeof html === \"object\" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);\n  };\n  /**\n   * `.redirect()` can Redirect, default status code is 302.\n   *\n   * @see {@link https://hono.dev/docs/api/context#redirect}\n   *\n   * @example\n   * ```ts\n   * app.get('/redirect', (c) => {\n   *   return c.redirect('/')\n   * })\n   * app.get('/redirect-permanently', (c) => {\n   *   return c.redirect('/', 301)\n   * })\n   * ```\n   */\n  redirect = (location, status) => {\n    const locationString = String(location);\n    this.header(\n      \"Location\",\n      // Multibyes should be encoded\n      // eslint-disable-next-line no-control-regex\n      !/[^\\x00-\\xFF]/.test(locationString) ? locationString : encodeURI(locationString)\n    );\n    return this.newResponse(null, status ?? 302);\n  };\n  /**\n   * `.notFound()` can return the Not Found Response.\n   *\n   * @see {@link https://hono.dev/docs/api/context#notfound}\n   *\n   * @example\n   * ```ts\n   * app.get('/notfound', (c) => {\n   *   return c.notFound()\n   * })\n   * ```\n   */\n  notFound = () => {\n    this.#notFoundHandler ??= () => createResponseInstance();\n    return this.#notFoundHandler(this);\n  };\n};\nexport {\n  Context,\n  TEXT_PLAIN\n};\n", "// src/router.ts\nvar METHOD_NAME_ALL = \"ALL\";\nvar METHOD_NAME_ALL_LOWERCASE = \"all\";\nvar METHODS = [\"get\", \"post\", \"put\", \"delete\", \"options\", \"patch\"];\nvar MESSAGE_MATCHER_IS_ALREADY_BUILT = \"Can not add a route since the matcher is already built.\";\nvar UnsupportedPathError = class extends Error {\n};\nexport {\n  MESSAGE_MATCHER_IS_ALREADY_BUILT,\n  METHODS,\n  METHOD_NAME_ALL,\n  METHOD_NAME_ALL_LOWERCASE,\n  UnsupportedPathError\n};\n", "// src/utils/constants.ts\nvar COMPOSED_HANDLER = \"__COMPOSED_HANDLER\";\nexport {\n  COMPOSED_HANDLER\n};\n", "// src/hono-base.ts\nimport { compose } from \"./compose.js\";\nimport { Context } from \"./context.js\";\nimport { METHODS, METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from \"./router.js\";\nimport { COMPOSED_HANDLER } from \"./utils/constants.js\";\nimport { getPath, getPathNoStrict, mergePath } from \"./utils/url.js\";\nvar notFoundHandler = (c) => {\n  return c.text(\"404 Not Found\", 404);\n};\nvar errorHandler = (err, c) => {\n  if (\"getResponse\" in err) {\n    const res = err.getResponse();\n    return c.newResponse(res.body, res);\n  }\n  console.error(err);\n  return c.text(\"Internal Server Error\", 500);\n};\nvar Hono = class _Hono {\n  get;\n  post;\n  put;\n  delete;\n  options;\n  patch;\n  all;\n  on;\n  use;\n  /*\n    This class is like an abstract class and does not have a router.\n    To use it, inherit the class and implement router in the constructor.\n  */\n  router;\n  getPath;\n  // Cannot use `#` because it requires visibility at JavaScript runtime.\n  _basePath = \"/\";\n  #path = \"/\";\n  routes = [];\n  constructor(options = {}) {\n    const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];\n    allMethods.forEach((method) => {\n      this[method] = (args1, ...args) => {\n        if (typeof args1 === \"string\") {\n          this.#path = args1;\n        } else {\n          this.#addRoute(method, this.#path, args1);\n        }\n        args.forEach((handler) => {\n          this.#addRoute(method, this.#path, handler);\n        });\n        return this;\n      };\n    });\n    this.on = (method, path, ...handlers) => {\n      for (const p of [path].flat()) {\n        this.#path = p;\n        for (const m of [method].flat()) {\n          handlers.map((handler) => {\n            this.#addRoute(m.toUpperCase(), this.#path, handler);\n          });\n        }\n      }\n      return this;\n    };\n    this.use = (arg1, ...handlers) => {\n      if (typeof arg1 === \"string\") {\n        this.#path = arg1;\n      } else {\n        this.#path = \"*\";\n        handlers.unshift(arg1);\n      }\n      handlers.forEach((handler) => {\n        this.#addRoute(METHOD_NAME_ALL, this.#path, handler);\n      });\n      return this;\n    };\n    const { strict, ...optionsWithoutStrict } = options;\n    Object.assign(this, optionsWithoutStrict);\n    this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;\n  }\n  #clone() {\n    const clone = new _Hono({\n      router: this.router,\n      getPath: this.getPath\n    });\n    clone.errorHandler = this.errorHandler;\n    clone.#notFoundHandler = this.#notFoundHandler;\n    clone.routes = this.routes;\n    return clone;\n  }\n  #notFoundHandler = notFoundHandler;\n  // Cannot use `#` because it requires visibility at JavaScript runtime.\n  errorHandler = errorHandler;\n  /**\n   * `.route()` allows grouping other Hono instance in routes.\n   *\n   * @see {@link https://hono.dev/docs/api/routing#grouping}\n   *\n   * @param {string} path - base Path\n   * @param {Hono} app - other Hono instance\n   * @returns {Hono} routed Hono instance\n   *\n   * @example\n   * ```ts\n   * const app = new Hono()\n   * const app2 = new Hono()\n   *\n   * app2.get(\"/user\", (c) => c.text(\"user\"))\n   * app.route(\"/api\", app2) // GET /api/user\n   * ```\n   */\n  route(path, app) {\n    const subApp = this.basePath(path);\n    app.routes.map((r) => {\n      let handler;\n      if (app.errorHandler === errorHandler) {\n        handler = r.handler;\n      } else {\n        handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;\n        handler[COMPOSED_HANDLER] = r.handler;\n      }\n      subApp.#addRoute(r.method, r.path, handler);\n    });\n    return this;\n  }\n  /**\n   * `.basePath()` allows base paths to be specified.\n   *\n   * @see {@link https://hono.dev/docs/api/routing#base-path}\n   *\n   * @param {string} path - base Path\n   * @returns {Hono} changed Hono instance\n   *\n   * @example\n   * ```ts\n   * const api = new Hono().basePath('/api')\n   * ```\n   */\n  basePath(path) {\n    const subApp = this.#clone();\n    subApp._basePath = mergePath(this._basePath, path);\n    return subApp;\n  }\n  /**\n   * `.onError()` handles an error and returns a customized Response.\n   *\n   * @see {@link https://hono.dev/docs/api/hono#error-handling}\n   *\n   * @param {ErrorHandler} handler - request Handler for error\n   * @returns {Hono} changed Hono instance\n   *\n   * @example\n   * ```ts\n   * app.onError((err, c) => {\n   *   console.error(`${err}`)\n   *   return c.text('Custom Error Message', 500)\n   * })\n   * ```\n   */\n  onError = (handler) => {\n    this.errorHandler = handler;\n    return this;\n  };\n  /**\n   * `.notFound()` allows you to customize a Not Found Response.\n   *\n   * @see {@link https://hono.dev/docs/api/hono#not-found}\n   *\n   * @param {NotFoundHandler} handler - request handler for not-found\n   * @returns {Hono} changed Hono instance\n   *\n   * @example\n   * ```ts\n   * app.notFound((c) => {\n   *   return c.text('Custom 404 Message', 404)\n   * })\n   * ```\n   */\n  notFound = (handler) => {\n    this.#notFoundHandler = handler;\n    return this;\n  };\n  /**\n   * `.mount()` allows you to mount applications built with other frameworks into your Hono application.\n   *\n   * @see {@link https://hono.dev/docs/api/hono#mount}\n   *\n   * @param {string} path - base Path\n   * @param {Function} applicationHandler - other Request Handler\n   * @param {MountOptions} [options] - options of `.mount()`\n   * @returns {Hono} mounted Hono instance\n   *\n   * @example\n   * ```ts\n   * import { Router as IttyRouter } from 'itty-router'\n   * import { Hono } from 'hono'\n   * // Create itty-router application\n   * const ittyRouter = IttyRouter()\n   * // GET /itty-router/hello\n   * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))\n   *\n   * const app = new Hono()\n   * app.mount('/itty-router', ittyRouter.handle)\n   * ```\n   *\n   * @example\n   * ```ts\n   * const app = new Hono()\n   * // Send the request to another application without modification.\n   * app.mount('/app', anotherApp, {\n   *   replaceRequest: (req) => req,\n   * })\n   * ```\n   */\n  mount(path, applicationHandler, options) {\n    let replaceRequest;\n    let optionHandler;\n    if (options) {\n      if (typeof options === \"function\") {\n        optionHandler = options;\n      } else {\n        optionHandler = options.optionHandler;\n        if (options.replaceRequest === false) {\n          replaceRequest = (request) => request;\n        } else {\n          replaceRequest = options.replaceRequest;\n        }\n      }\n    }\n    const getOptions = optionHandler ? (c) => {\n      const options2 = optionHandler(c);\n      return Array.isArray(options2) ? options2 : [options2];\n    } : (c) => {\n      let executionContext = void 0;\n      try {\n        executionContext = c.executionCtx;\n      } catch {\n      }\n      return [c.env, executionContext];\n    };\n    replaceRequest ||= (() => {\n      const mergedPath = mergePath(this._basePath, path);\n      const pathPrefixLength = mergedPath === \"/\" ? 0 : mergedPath.length;\n      return (request) => {\n        const url = new URL(request.url);\n        url.pathname = url.pathname.slice(pathPrefixLength) || \"/\";\n        return new Request(url, request);\n      };\n    })();\n    const handler = async (c, next) => {\n      const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));\n      if (res) {\n        return res;\n      }\n      await next();\n    };\n    this.#addRoute(METHOD_NAME_ALL, mergePath(path, \"*\"), handler);\n    return this;\n  }\n  #addRoute(method, path, handler) {\n    method = method.toUpperCase();\n    path = mergePath(this._basePath, path);\n    const r = { basePath: this._basePath, path, method, handler };\n    this.router.add(method, path, [handler, r]);\n    this.routes.push(r);\n  }\n  #handleError(err, c) {\n    if (err instanceof Error) {\n      return this.errorHandler(err, c);\n    }\n    throw err;\n  }\n  #dispatch(request, executionCtx, env, method) {\n    if (method === \"HEAD\") {\n      return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, \"GET\")))();\n    }\n    const path = this.getPath(request, { env });\n    const matchResult = this.router.match(method, path);\n    const c = new Context(request, {\n      path,\n      matchResult,\n      env,\n      executionCtx,\n      notFoundHandler: this.#notFoundHandler\n    });\n    if (matchResult[0].length === 1) {\n      let res;\n      try {\n        res = matchResult[0][0][0][0](c, async () => {\n          c.res = await this.#notFoundHandler(c);\n        });\n      } catch (err) {\n        return this.#handleError(err, c);\n      }\n      return res instanceof Promise ? res.then(\n        (resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))\n      ).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);\n    }\n    const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);\n    return (async () => {\n      try {\n        const context = await composed(c);\n        if (!context.finalized) {\n          throw new Error(\n            \"Context is not finalized. Did you forget to return a Response object or `await next()`?\"\n          );\n        }\n        return context.res;\n      } catch (err) {\n        return this.#handleError(err, c);\n      }\n    })();\n  }\n  /**\n   * `.fetch()` will be entry point of your app.\n   *\n   * @see {@link https://hono.dev/docs/api/hono#fetch}\n   *\n   * @param {Request} request - request Object of request\n   * @param {Env} Env - env Object\n   * @param {ExecutionContext} - context of execution\n   * @returns {Response | Promise<Response>} response of request\n   *\n   */\n  fetch = (request, ...rest) => {\n    return this.#dispatch(request, rest[1], rest[0], request.method);\n  };\n  /**\n   * `.request()` is a useful method for testing.\n   * You can pass a URL or pathname to send a GET request.\n   * app will return a Response object.\n   * ```ts\n   * test('GET /hello is ok', async () => {\n   *   const res = await app.request('/hello')\n   *   expect(res.status).toBe(200)\n   * })\n   * ```\n   * @see https://hono.dev/docs/api/hono#request\n   */\n  request = (input, requestInit, Env, executionCtx) => {\n    if (input instanceof Request) {\n      return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);\n    }\n    input = input.toString();\n    return this.fetch(\n      new Request(\n        /^https?:\\/\\//.test(input) ? input : `http://localhost${mergePath(\"/\", input)}`,\n        requestInit\n      ),\n      Env,\n      executionCtx\n    );\n  };\n  /**\n   * `.fire()` automatically adds a global fetch event listener.\n   * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.\n   * @deprecated\n   * Use `fire` from `hono/service-worker` instead.\n   * ```ts\n   * import { Hono } from 'hono'\n   * import { fire } from 'hono/service-worker'\n   *\n   * const app = new Hono()\n   * // ...\n   * fire(app)\n   * ```\n   * @see https://hono.dev/docs/api/hono#fire\n   * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n   * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/\n   */\n  fire = () => {\n    addEventListener(\"fetch\", (event) => {\n      event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));\n    });\n  };\n};\nexport {\n  Hono as HonoBase\n};\n", "// src/router/pattern-router/router.ts\nimport { METHOD_NAME_ALL, UnsupportedPathError } from \"../../router.js\";\nvar emptyParams = /* @__PURE__ */ Object.create(null);\nvar PatternRouter = class {\n  name = \"PatternRouter\";\n  #routes = [];\n  add(method, path, handler) {\n    const endsWithWildcard = path.at(-1) === \"*\";\n    if (endsWithWildcard) {\n      path = path.slice(0, -2);\n    }\n    if (path.at(-1) === \"?\") {\n      path = path.slice(0, -1);\n      this.add(method, path.replace(/\\/[^/]+$/, \"\"), handler);\n    }\n    const parts = (path.match(/\\/?(:\\w+(?:{(?:(?:{[\\d,]+})|[^}])+})?)|\\/?[^\\/\\?]+/g) || []).map(\n      (part) => {\n        const match = part.match(/^\\/:([^{]+)(?:{(.*)})?/);\n        return match ? `/(?<${match[1]}>${match[2] || \"[^/]+\"})` : part === \"/*\" ? \"/[^/]+\" : part.replace(/[.\\\\+*[^\\]$()]/g, \"\\\\$&\");\n      }\n    );\n    try {\n      this.#routes.push([\n        new RegExp(`^${parts.join(\"\")}${endsWithWildcard ? \"\" : \"/?$\"}`),\n        method,\n        handler\n      ]);\n    } catch {\n      throw new UnsupportedPathError();\n    }\n  }\n  match(method, path) {\n    const handlers = [];\n    for (let i = 0, len = this.#routes.length; i < len; i++) {\n      const [pattern, routeMethod, handler] = this.#routes[i];\n      if (routeMethod === method || routeMethod === METHOD_NAME_ALL) {\n        const match = pattern.exec(path);\n        if (match) {\n          handlers.push([handler, match.groups || emptyParams]);\n        }\n      }\n    }\n    return [handlers];\n  }\n};\nexport {\n  PatternRouter\n};\n", "// src/preset/tiny.ts\nimport { HonoBase } from \"../hono-base.js\";\nimport { PatternRouter } from \"../router/pattern-router/index.js\";\nvar Hono = class extends HonoBase {\n  constructor(options = {}) {\n    super(options);\n    this.router = new PatternRouter();\n  }\n};\nexport {\n  Hono\n};\n", "/**\n * Reserved paths for internal Miniflare endpoints.\n *\n * Paths under `/cdn-cgi/local/` are reserved by Cloudflare's network\n * and won't conflict with user routes. Paths under `/__cf_local/` live\n * outside `/cdn-cgi/` so they remain reachable over tunnels.\n */\nexport const CorePaths = {\n\t/** Magic proxy used by getPlatformProxy */\n\tPLATFORM_PROXY: \"/cdn-cgi/local/platform-proxy\",\n\t/** Trigger scheduled event handlers */\n\tSCHEDULED: \"/cdn-cgi/local/scheduled\",\n\t/** Trigger email event handlers */\n\tEMAIL: \"/cdn-cgi/local/email\",\n\t/** Local explorer UI and API */\n\tEXPLORER: \"/cdn-cgi/local/explorer\",\n\t/** Stream video serving endpoint (outside /cdn-cgi/ for tunnel access) */\n\tSTREAM_VIDEO: \"/__cf_local/stream\",\n\t/** Local image delivery endpoint (outside /cdn-cgi/ for tunnel access) */\n\tIMAGE_DELIVERY: \"/__cf_local/imagedelivery\",\n\t/** Public R2 bucket object serving endpoint */\n\tR2_PUBLIC: \"/cdn-cgi/local/r2/public\",\n\t/** S3-compatible API endpoint for local R2 buckets */\n\tR2_S3: \"/cdn-cgi/local/r2/s3\",\n} as const;\n\nexport const CoreHeaders = {\n\tCUSTOM_FETCH_SERVICE: \"MF-Custom-Fetch-Service\",\n\tCUSTOM_NODE_SERVICE: \"MF-Custom-Node-Service\",\n\tORIGINAL_URL: \"MF-Original-URL\",\n\t/**\n\t * Stores the original hostname when using the `upstream` option.\n\t * When requests are proxied to an upstream, the `Host` header is rewritten\n\t * to match the upstream. This header preserves the original hostname\n\t * so Workers can access it if needed.\n\t */\n\tORIGINAL_HOSTNAME: \"MF-Original-Hostname\",\n\tPROXY_SHARED_SECRET: \"MF-Proxy-Shared-Secret\",\n\tDISABLE_PRETTY_ERROR: \"MF-Disable-Pretty-Error\",\n\tERROR_STACK: \"MF-Experimental-Error-Stack\",\n\t/**\n\t * The serialised error, URI-encoded. `workerd` drops response bodies for\n\t * `HEAD` requests, so the body alone cannot carry the error out of the user\n\t * Worker. Producers set this in addition to the body; consumers fall back to\n\t * it whenever the body is unavailable.\n\t */\n\tERROR_STACK_PAYLOAD: \"MF-Experimental-Error-Stack-Payload\",\n\tROUTE_OVERRIDE: \"MF-Route-Override\",\n\tCF_BLOB: \"MF-CF-Blob\",\n\tACCESS_BLOB: \"MF-Access-Blob\",\n\t/** Used by the Vite plugin to pass through the original `sec-fetch-mode` header */\n\tSEC_FETCH_MODE: \"MF-Sec-Fetch-Mode\",\n\n\t// API Proxy\n\tOP_SECRET: \"MF-Op-Secret\",\n\tOP: \"MF-Op\",\n\tOP_TARGET: \"MF-Op-Target\",\n\tOP_KEY: \"MF-Op-Key\",\n\tOP_SYNC: \"MF-Op-Sync\",\n\tOP_STRINGIFIED_SIZE: \"MF-Op-Stringified-Size\",\n\tOP_RESULT_TYPE: \"MF-Op-Result-Type\",\n\tOP_ORIGINAL_URL: \"MF-Op-Original-URL\",\n} as const;\n\nexport const CoreBindings = {\n\tSERVICE_LOOPBACK: \"MINIFLARE_LOOPBACK\",\n\tSERVICE_USER_ROUTE_PREFIX: \"MINIFLARE_USER_ROUTE_\",\n\tSERVICE_USER_FALLBACK: \"MINIFLARE_USER_FALLBACK\",\n\tTEXT_CUSTOM_SERVICE: \"MINIFLARE_CUSTOM_SERVICE\",\n\t// Backs the Images binding (`env.IMAGES`) \u2014 see imagesLocalFetcher.\n\tIMAGES_BINDING_SERVICE: \"MINIFLARE_IMAGES_BINDING_SERVICE\",\n\t// Backs `fetch(url, { cf: { image } })` transforms \u2014 see cfImageLocalFetcher.\n\tIMAGES_FETCH_SERVICE: \"MINIFLARE_IMAGES_FETCH_SERVICE\",\n\tTEXT_UPSTREAM_URL: \"MINIFLARE_UPSTREAM_URL\",\n\tJSON_CF_BLOB: \"CF_BLOB\",\n\tJSON_ROUTES: \"MINIFLARE_ROUTES\",\n\tJSON_LOG_LEVEL: \"MINIFLARE_LOG_LEVEL\",\n\tDURABLE_OBJECT_NAMESPACE_PROXY: \"MINIFLARE_PROXY\",\n\tDATA_PROXY_SECRET: \"MINIFLARE_PROXY_SECRET\",\n\tDATA_PROXY_SHARED_SECRET: \"MINIFLARE_PROXY_SHARED_SECRET\",\n\tTRIGGER_HANDLERS: \"TRIGGER_HANDLERS\",\n\tLOG_REQUESTS: \"LOG_REQUESTS\",\n\tSTRIP_DISABLE_PRETTY_ERROR: \"STRIP_DISABLE_PRETTY_ERROR\",\n\tSERVICE_LOCAL_EXPLORER: \"MINIFLARE_LOCAL_EXPLORER\",\n\tEXPLORER_DISK: \"MINIFLARE_EXPLORER_DISK\",\n\tJSON_LOCAL_EXPLORER_BINDING_MAP: \"LOCAL_EXPLORER_BINDING_MAP\",\n\tJSON_LOCAL_EXPLORER_WORKER_NAMES: \"LOCAL_EXPLORER_WORKER_NAMES\",\n\tJSON_EXPLORER_WORKER_OPTS: \"MINIFLARE_EXPLORER_WORKER_OPTS\",\n\tSERVICE_CACHE: \"MINIFLARE_CACHE\",\n\tSERVICE_DEV_CONTROL: \"MINIFLARE_DEV_CONTROL\",\n\tSERVICE_DEV_REGISTRY_PROXY: \"MINIFLARE_DEV_REGISTRY_PROXY\",\n\tJSON_TELEMETRY_CONFIG: \"MINIFLARE_TELEMETRY_CONFIG\",\n\tDEV_REGISTRY_DEBUG_PORT: \"DEV_REGISTRY_DEBUG_PORT\",\n\tSERVICE_STREAM: \"MINIFLARE_STREAM\",\n\tSERVICE_IMAGES_DELIVERY: \"MINIFLARE_IMAGES_DELIVERY\",\n\tSERVICE_R2_PUBLIC: \"MINIFLARE_R2_PUBLIC\",\n\tSERVICE_R2_S3: \"MINIFLARE_R2_S3\",\n\tSERVICE_OBSERVABILITY_COLLECTOR: \"MINIFLARE_OBSERVABILITY_COLLECTOR\",\n\tJSON_ACCESS_BLOB_PREFIX: \"MINIFLARE_ACCESS_BLOB_\",\n\tTEXT_FALLBACK_WORKER_NAME: \"MINIFLARE_FALLBACK_WORKER_NAME\",\n} as const;\n\nexport const ProxyOps = {\n\t// Get the target or a property of the target\n\tGET: \"GET\",\n\t// Get the descriptor for a property of the target\n\tGET_OWN_DESCRIPTOR: \"GET_OWN_DESCRIPTOR\",\n\t// Get the target's own property names\n\tGET_OWN_KEYS: \"GET_OWN_KEYS\",\n\t// Call a method on the target\n\tCALL: \"CALL\",\n\t// Remove the strong reference to the target on the \"heap\", allowing it to be\n\t// garbage collected\n\tFREE: \"FREE\",\n} as const;\nexport const ProxyAddresses = {\n\tGLOBAL: 0, // globalThis\n\tENV: 1, // env\n\tUSER_START: 2,\n} as const;\n\n/**\n * Recovers the serialised error a Worker put in `ERROR_STACK_PAYLOAD`, for the\n * cases where the response body carrying it has been dropped (`HEAD` requests).\n * Returns `null` when the header is absent or malformed, so callers can fall\n * back rather than surfacing a decoding failure as the Worker's error.\n */\nexport function decodeErrorPayload(response: {\n\theaders: { get(name: string): string | null };\n}): string | null {\n\tconst payload = response.headers.get(CoreHeaders.ERROR_STACK_PAYLOAD);\n\tif (payload === null) {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn decodeURIComponent(payload);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n// ### Proxy Special Cases\n// The proxy supports serialising `Request`/`Response`s for the Cache API. It\n// doesn't support serialising `WebSocket`s though. Rather than attempting this,\n// we call `Fetcher#fetch()` using `dispatchFetch()` directly, using the passed\n// request. This gives us WebSocket support, and is much more efficient, since\n// there's no need to serialise the `Request`/`Response`: we just pass\n// everything to `dispatchFetch()` and return what that gives us.\nexport function isFetcherFetch(targetName: string, key: string) {\n\t// `DurableObject` and `WorkerRpc` are the internal names of `DurableObjectStub`:\n\t// https://github.com/cloudflare/workerd/blob/62b9ceee4c94d2b238692397dc4f604fef84f474/src/workerd/api/actor.h#L86\n\t// https://github.com/cloudflare/workerd/blob/62b9ceee4c94d2b238692397dc4f604fef84f474/src/workerd/api/worker-rpc.h#L30\n\treturn (\n\t\t(targetName === \"Fetcher\" ||\n\t\t\ttargetName === \"DurableObject\" ||\n\t\t\ttargetName === \"WorkerRpc\") &&\n\t\tkey === \"fetch\"\n\t);\n}\n// `R2Object#writeHttpMetadata()` is one of the few functions that mutates its\n// arguments. This would be proxied correctly if the argument were a native\n// target proxy itself, but `Headers` can be constructed in Node. Instead, we\n// respond with the updated headers in the proxy server, then copy them to the\n// original argument on the client.\nexport function isR2ObjectWriteHttpMetadata(targetName: string, key: string) {\n\t// `HeadResult` and `GetResult` are the internal names of `R2Object` and `R2ObjectBody` respectively:\n\t// https://github.com/cloudflare/workerd/blob/ae612f0563d864c82adbfa4c2e5ed78b547aa0a1/src/workerd/api/r2-bucket.h#L210\n\t// https://github.com/cloudflare/workerd/blob/ae612f0563d864c82adbfa4c2e5ed78b547aa0a1/src/workerd/api/r2-bucket.h#L263-L264\n\treturn (\n\t\t(targetName === \"HeadResult\" || targetName === \"GetResult\") &&\n\t\tkey === \"writeHttpMetadata\"\n\t);\n}\n\n/**\n * See #createMediaProxy() comment for why this is special\n */\nexport function isImagesInput(targetName: string, key: string) {\n\treturn targetName === \"ImagesBindingImpl\" && key === \"input\";\n}\n\n// Durable Object stub RPC calls should always be async to avoid blocking the\n// Node.js event loop. The internal names are \"DurableObject\" and \"WorkerRpc\".\n// https://github.com/cloudflare/workerd/blob/62b9ceee/src/workerd/api/actor.h#L86\n// https://github.com/cloudflare/workerd/blob/62b9ceee/src/workerd/api/worker-rpc.h#L30\nexport function isDurableObjectStub(targetName: string) {\n\treturn targetName === \"DurableObject\" || targetName === \"WorkerRpc\";\n}\n", "// The S3 API's one account-level operation: ListBuckets. There is no bucket\n// in the path to resolve credentials from, so authentication works\n// differently from the per-bucket operations in `dispatch.worker.ts`.\nimport assert from \"node:assert\";\nimport { R2S3Bindings } from \"../constants\";\nimport { credentialsEqual, verifyRequest } from \"./auth.worker\";\nimport { stripBodyForHead, xmlResponse } from \"./common.worker\";\nimport { isScreenedParam } from \"./detect.worker\";\nimport { notImplemented, routeNotFound } from \"./errors.worker\";\nimport type { S3Credentials } from \"../constants\";\nimport type { S3Context } from \"./common.worker\";\n\n/**\n * Verifies the request against every configured credential set, returning\n * the matching credentials, or the auth error if none verify. The request\n * can only have been signed with one set, so the first success is the match.\n */\nasync function verifyAgainstSome(\n\tc: S3Context\n): Promise<{ matched: S3Credentials } | { error: Response }> {\n\tlet error: Response | undefined;\n\tconst seenPairs = new Set<string>();\n\tfor (const credentials of Object.values(\n\t\tc.env[R2S3Bindings.JSON_CREDENTIALS]\n\t)) {\n\t\t// Buckets often share a credential pair; verify each pair once\n\t\tconst pair = `${credentials.accessKeyId}\\0${credentials.secretAccessKey}`;\n\t\tif (seenPairs.has(pair)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseenPairs.add(pair);\n\n\t\tconst result = await verifyRequest(c.req.raw, credentials);\n\t\tif (result === undefined) {\n\t\t\treturn { matched: credentials };\n\t\t}\n\n\t\t// A 401 just means this set's access key id didn't match; an error\n\t\t// from a set whose key id did match (e.g. SignatureDoesNotMatch) is\n\t\t// the precise one\n\t\tif (error === undefined || error.status === 401) {\n\t\t\terror = result;\n\t\t}\n\t}\n\n\t// The service only exists when at least one credential set is configured\n\tassert(error !== undefined);\n\treturn { error };\n}\n\n/**\n * ListBuckets is account-level: there is no bucket to resolve credentials\n * from, so try each configured credential set; the request can only have\n * been signed with one of them. Lists the buckets the matching credentials\n * grant access to (locally, all buckets sharing that credential pair).\n */\nexport async function listBuckets(c: S3Context): Promise<Response> {\n\treturn stripBodyForHead(c, await listBucketsInner(c));\n}\n\nasync function listBucketsInner(c: S3Context): Promise<Response> {\n\tif (c.req.method !== \"GET\") {\n\t\treturn routeNotFound();\n\t}\n\n\tconst credentialsById = c.env[R2S3Bindings.JSON_CREDENTIALS];\n\tconst verified = await verifyAgainstSome(c);\n\tif (\"error\" in verified) {\n\t\treturn verified.error;\n\t}\n\tconst matched = verified.matched;\n\n\tfor (const name of new URL(c.req.url).searchParams.keys()) {\n\t\tif (!isScreenedParam(name)) {\n\t\t\treturn notImplemented(\n\t\t\t\t`ListBuckets search parameter ${name} not implemented`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst buckets = Object.entries(credentialsById)\n\t\t.filter(([, credentials]) => credentialsEqual(credentials, matched))\n\t\t.map(([id]) => ({ Name: id }));\n\treturn xmlResponse(\"ListAllMyBucketsResult\", {\n\t\tBuckets: buckets.length > 0 ? { Bucket: buckets } : {},\n\t});\n}\n", "export const R2Limits = {\n\tMAX_LIST_KEYS: 1_000,\n\tMAX_KEY_SIZE: 1024,\n\t// https://developers.cloudflare.com/r2/platform/limits/\n\tMAX_VALUE_SIZE: 5_368_709_120 - 5_242_880, // 5 GiB - 5 MiB\n\tMAX_METADATA_SIZE: 2048, // 2048 B\n\tMIN_MULTIPART_PART_SIZE: 5 * 1024 * 1024,\n\tMIN_MULTIPART_PART_SIZE_TEST: 50,\n} as const;\n\n/** AWS SigV4 credentials guarding a bucket on the local S3 endpoint */\nexport interface S3Credentials {\n\taccessKeyId: string;\n\tsecretAccessKey: string;\n}\n\nexport const R2S3Bindings = {\n\t/** JSON map of bucket id to `{ accessKeyId, secretAccessKey }` */\n\tJSON_CREDENTIALS: \"MINIFLARE_R2_S3_CREDENTIALS\",\n\t/** Prefix for per-bucket `R2Bucket` bindings (followed by the bucket id) */\n\tBUCKET_PREFIX: \"MINIFLARE_R2_S3_BUCKET_\",\n} as const;\n\nexport const R2Headers = {\n\tERROR: \"cf-r2-error\",\n\tREQUEST: \"cf-r2-request\",\n\tMETADATA_SIZE: \"cf-r2-metadata-size\",\n} as const;\n", "// AWS Signature Version 4 verification for the local S3-compatible endpoint.\n// Implements both authentication methods defined by the SigV4 spec:\n// - HTTP `Authorization` header:\n//   https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-authentication-methods.html#aws-signing-authentication-methods-http\n// - Presigned URL query parameters:\n//   https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-authentication-methods.html#aws-signing-authentication-methods-query\n// Canonical request construction follows\n// https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html\n// with the S3-specific deviation that the canonical URI is the request path\n// used verbatim (single-encoded), not re-encoded.\n//\n// Error codes, messages, and check order mimic R2's S3 endpoint\n// (<account>.r2.cloudflarestorage.com), which differs from AWS S3: R2 uses\n// `InvalidArgument`/`InvalidRequest` for malformed auth, 401 `Unauthorized`\n// for unknown access keys (never `InvalidAccessKeyId`), 403\n// `SignatureDoesNotMatch` (with the canonical request and string-to-sign\n// echoed for debugging, like AWS) for signature mismatches, and 403\n// `ExpiredRequest` for expired presigned URLs.\n\nimport assert from \"node:assert\";\nimport { hex } from \"./common.worker\";\nimport { errorResponse } from \"./errors.worker\";\nimport type { S3Credentials } from \"../constants\";\n\nconst ALGORITHM = \"AWS4-HMAC-SHA256\";\nconst MAX_EXPIRES_SECONDS = 604_800;\nconst MAX_SKEW_MILLIS = 15 * 60 * 1000;\n\nconst encoder = new TextEncoder();\n\nasync function sha256Hex(data: BufferSource): Promise<string> {\n\treturn hex(await crypto.subtle.digest(\"SHA-256\", data));\n}\n\nasync function hmac(key: BufferSource, data: string): Promise<ArrayBuffer> {\n\tconst cryptoKey = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tkey,\n\t\t{ name: \"HMAC\", hash: \"SHA-256\" },\n\t\tfalse,\n\t\t[\"sign\"]\n\t);\n\treturn crypto.subtle.sign(\"HMAC\", cryptoKey, encoder.encode(data));\n}\n\n/**\n * AWS `UriEncode`: percent-encode everything except RFC 3986 unreserved\n * characters, with uppercase hex. `encodeURIComponent` matches except it\n * leaves `!'()*` unescaped. Used for query parameters only; the S3\n * canonical URI is the request path verbatim.\n */\nexport function awsUriEncode(value: string): string {\n\treturn encodeURIComponent(value).replace(\n\t\t/[!'()*]/g,\n\t\t(char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`\n\t);\n}\n\nconst invalidArgument = (message: string) =>\n\terrorResponse(400, \"InvalidArgument\", message);\n\nconst unauthorized = () => errorResponse(401, \"Unauthorized\", \"Unauthorized\");\n\nfunction byteDump(value: string): string {\n\treturn Array.from(encoder.encode(value), (byte) =>\n\t\tbyte.toString(16).padStart(2, \"0\")\n\t).join(\" \");\n}\n\nfunction signatureDoesNotMatch(\n\tcomputed: ComputedSignature,\n\tprovided: string\n): Response {\n\treturn errorResponse(\n\t\t403,\n\t\t\"SignatureDoesNotMatch\",\n\t\t\"The request signature we calculated does not match the signature you provided. Check your secret access key and signing method.\",\n\t\t{\n\t\t\tStringToSign: computed.stringToSign,\n\t\t\tStringToSignBytes: byteDump(computed.stringToSign),\n\t\t\tCanonicalRequest: computed.canonicalRequest,\n\t\t\tCanonicalRequestBytes: byteDump(computed.canonicalRequest),\n\t\t\tSignatureProvided: provided,\n\t\t}\n\t);\n}\n\nconst unsupportedAlgorithm = () =>\n\terrorResponse(400, \"InvalidRequest\", `Please use ${ALGORITHM}`);\n\ninterface ParsedCredential {\n\taccessKeyId: string;\n\tdate: string;\n\tregion: string;\n\tservice: string;\n}\n\n/**\n * Parses `<access-key-id>/<yyyymmdd>/<region>/<service>/aws4_request`,\n * validating in R2's order: part count, then service, then termination\n * string. Access key validity is checked by the caller (R2 checks the key's\n * length here, but local credentials are user-configured so any mismatch is\n * just an invalid key, reported as 401 after the scope checks).\n */\nfunction parseCredential(\n\tcredential: string\n): ParsedCredential | { error: Response } {\n\tconst parts = credential.split(\"/\");\n\tif (parts.length < 5) {\n\t\treturn {\n\t\t\terror: invalidArgument(\n\t\t\t\t`Credential sigv4 header should have at least 5 slash-separated parts, not ${parts.length}`\n\t\t\t),\n\t\t};\n\t}\n\n\t// R2 allows extra slashes by treating everything before the last four\n\t// parts as the access key\n\tconst accessKeyId = parts.slice(0, -4).join(\"/\");\n\tconst [date, region, service, terminator] = parts.slice(-4);\n\tif (service !== \"s3\") {\n\t\treturn {\n\t\t\terror: invalidArgument(`Credential service should be s3, not ${service}`),\n\t\t};\n\t}\n\tif (terminator !== \"aws4_request\") {\n\t\treturn {\n\t\t\terror: invalidArgument(\n\t\t\t\t`Credential termination string should be aws4_request, not ${terminator}`\n\t\t\t),\n\t\t};\n\t}\n\tif (date === undefined || region === undefined) {\n\t\treturn { error: unauthorized() };\n\t}\n\n\treturn { accessKeyId, date, region, service };\n}\n\n/** Dates must strictly be basic ISO 8601 format */\nfunction parseAmzDate(value: string): Date | undefined {\n\tconst match = /^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})Z$/.exec(value);\n\tif (match === null) {\n\t\treturn undefined;\n\t}\n\n\tconst [, year, month, day, hour, minute, second] = match;\n\tconst date = new Date(\n\t\tDate.UTC(\n\t\t\tNumber(year),\n\t\t\tNumber(month) - 1,\n\t\t\tNumber(day),\n\t\t\tNumber(hour),\n\t\t\tNumber(minute),\n\t\t\tNumber(second)\n\t\t)\n\t);\n\n\treturn Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Canonical query string: each name and value `UriEncode`d, sorted by\n * encoded name (then value), joined with `&`. For presigned requests,\n * `X-Amz-Signature` is excluded.\n */\nfunction canonicalQueryString(url: URL, excludeSignature: boolean): string {\n\tconst params: [string, string][] = [];\n\tfor (const [name, value] of url.searchParams) {\n\t\tif (excludeSignature && name === \"X-Amz-Signature\") {\n\t\t\tcontinue;\n\t\t}\n\t\tparams.push([awsUriEncode(name), awsUriEncode(value)]);\n\t}\n\tparams.sort(([name1, value1], [name2, value2]) => {\n\t\tif (name1 !== name2) {\n\t\t\treturn name1 < name2 ? -1 : 1;\n\t\t}\n\t\treturn value1 < value2 ? -1 : value1 > value2 ? 1 : 0;\n\t});\n\treturn params.map(([name, value]) => `${name}=${value}`).join(\"&\");\n}\n\n/**\n * Canonical headers: lowercase name, `:`, trimmed value with sequential\n * spaces collapsed, `\\n`, for each signed header in the order given\n * (the spec requires the SignedHeaders list to already be sorted).\n *\n * Known limitation: `Headers.get()` joins repeated headers with `\", \"`,\n * while SigV4 canonicalizes them joined with a bare comma. The Fetch API\n * offers no way to recover the original values, so signing a repeated\n * header produces a signature mismatch.\n */\nfunction canonicalHeaders(\n\trequest: Request,\n\turl: URL,\n\tsignedHeaders: string[]\n): string {\n\tlet result = \"\";\n\tfor (const name of signedHeaders) {\n\t\tconst value =\n\t\t\trequest.headers.get(name) ?? (name === \"host\" ? url.host : \"\");\n\t\tresult += `${name}:${value.trim().replace(/ +/g, \" \")}\\n`;\n\t}\n\treturn result;\n}\n\ninterface ComputedSignature {\n\tsignature: string;\n\tcanonicalRequest: string;\n\tstringToSign: string;\n}\n\nasync function computeSignature(\n\trequest: Request,\n\turl: URL,\n\tsecretAccessKey: string,\n\tcredential: ParsedCredential,\n\tamzDate: string,\n\tsignedHeaders: string[],\n\tpayloadHash: string,\n\tpresigned: boolean\n): Promise<ComputedSignature> {\n\tconst canonicalRequest = [\n\t\trequest.method,\n\t\turl.pathname,\n\t\tcanonicalQueryString(url, presigned),\n\t\tcanonicalHeaders(request, url, signedHeaders),\n\t\tsignedHeaders.join(\";\"),\n\t\tpayloadHash,\n\t].join(\"\\n\");\n\n\tconst scope = `${credential.date}/${credential.region}/${credential.service}/aws4_request`;\n\tconst stringToSign = [\n\t\tALGORITHM,\n\t\tamzDate,\n\t\tscope,\n\t\tawait sha256Hex(encoder.encode(canonicalRequest)),\n\t].join(\"\\n\");\n\n\t// DateKey = HMAC(\"AWS4\" + secret, date); DateRegionKey = HMAC(DateKey,\n\t// region); DateRegionServiceKey = HMAC(.., service); SigningKey =\n\t// HMAC(.., \"aws4_request\")\n\tlet key = await hmac(\n\t\tencoder.encode(`AWS4${secretAccessKey}`),\n\t\tcredential.date\n\t);\n\tkey = await hmac(key, credential.region);\n\tkey = await hmac(key, credential.service);\n\tkey = await hmac(key, \"aws4_request\");\n\n\treturn {\n\t\tsignature: hex(await hmac(key, stringToSign)),\n\t\tcanonicalRequest,\n\t\tstringToSign,\n\t};\n}\n\nfunction timingSafeStringsEqual(expected: string, actual: string): boolean {\n\tconst expectedBytes = encoder.encode(expected);\n\tconst actualBytes = encoder.encode(actual);\n\n\treturn actualBytes.byteLength === expectedBytes.byteLength\n\t\t? crypto.subtle.timingSafeEqual(expectedBytes, actualBytes)\n\t\t: !crypto.subtle.timingSafeEqual(expectedBytes, expectedBytes);\n}\n\n/**\n * Shared scope checks for both authentication methods: parse the credential,\n * match its signed date against the request date, then match the access key.\n * Real R2 reports the date mismatch as coming from the 'x-amz-date' header\n * even when the date came from the X-Amz-Date query parameter.\n */\nfunction checkCredentialScope(\n\tcredentialField: string,\n\tamzDate: string,\n\tcredentials: S3Credentials\n): ParsedCredential | { error: Response } {\n\tconst credential = parseCredential(credentialField);\n\tif (\"error\" in credential) {\n\t\treturn credential;\n\t}\n\tif (!amzDate.startsWith(credential.date)) {\n\t\treturn {\n\t\t\terror: invalidArgument(\n\t\t\t\t`Credential signed date ${credential.date} does not match ${amzDate.slice(0, 8)} from 'x-amz-date' header`\n\t\t\t),\n\t\t};\n\t}\n\tif (credential.accessKeyId !== credentials.accessKeyId) {\n\t\treturn { error: unauthorized() };\n\t}\n\treturn credential;\n}\n\nfunction parseSignedHeaders(field: string): string[] | { error: Response } {\n\tconst signedHeaders = field.split(\";\").map((name) => name.toLowerCase());\n\t// SigV4 requires the SignedHeaders list to include `host`\n\tif (!signedHeaders.includes(\"host\")) {\n\t\treturn { error: unauthorized() };\n\t}\n\treturn signedHeaders;\n}\n\nasync function checkSignature(\n\trequest: Request,\n\turl: URL,\n\tcredentials: S3Credentials,\n\tcredential: ParsedCredential,\n\tamzDate: string,\n\tsignedHeaders: string[],\n\tpayloadHash: string,\n\tpresigned: boolean,\n\tprovided: string\n): Promise<Response | undefined> {\n\tconst computed = await computeSignature(\n\t\trequest,\n\t\turl,\n\t\tcredentials.secretAccessKey,\n\t\tcredential,\n\t\tamzDate,\n\t\tsignedHeaders,\n\t\tpayloadHash,\n\t\tpresigned\n\t);\n\treturn timingSafeStringsEqual(computed.signature, provided)\n\t\t? undefined\n\t\t: signatureDoesNotMatch(computed, provided);\n}\n\nasync function verifyAuthorizationHeader(\n\trequest: Request,\n\turl: URL,\n\tcredentials: S3Credentials,\n\tauthorization: string\n): Promise<Response | undefined> {\n\tconst payloadHash = request.headers.get(\"x-amz-content-sha256\");\n\tif (payloadHash === null) {\n\t\treturn errorResponse(400, \"InvalidRequest\", \"Missing x-amz-content-sha256\");\n\t}\n\n\tlet amzDate = request.headers.get(\"x-amz-date\");\n\tlet dateSource = \"'x-amz-date' header\";\n\tif (amzDate === null) {\n\t\tamzDate = request.headers.get(\"date\");\n\t\tdateSource = \"'date' header\";\n\t}\n\tif (amzDate === null) {\n\t\treturn invalidArgument(\"No date provided in x-amz-date nor date header\");\n\t}\n\tconst date = parseAmzDate(amzDate);\n\tif (date === undefined) {\n\t\treturn invalidArgument(\n\t\t\t`Date provided in ${dateSource} (${amzDate}) didn't parse successfully`\n\t\t);\n\t}\n\tif (Math.abs(Date.now() - date.getTime()) > MAX_SKEW_MILLIS) {\n\t\treturn errorResponse(\n\t\t\t403,\n\t\t\t\"RequestTimeTooSkewed\",\n\t\t\t\"The difference between the request time and the server's time is too large.\"\n\t\t);\n\t}\n\n\t// `AWS4-HMAC-SHA256 Credential=<scope>, SignedHeaders=<h1;h2>, Signature=<hex>`\n\tconst fields = new Map<string, string>();\n\tif (authorization.startsWith(`${ALGORITHM} `)) {\n\t\tfor (const component of authorization.slice(ALGORITHM.length).split(\",\")) {\n\t\t\tconst separator = component.indexOf(\"=\");\n\t\t\tif (separator === -1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfields.set(\n\t\t\t\tcomponent.slice(0, separator).trim(),\n\t\t\t\tcomponent.slice(separator + 1).trim()\n\t\t\t);\n\t\t}\n\t}\n\tconst credentialField = fields.get(\"Credential\");\n\tconst signedHeadersField = fields.get(\"SignedHeaders\");\n\tconst signatureField = fields.get(\"Signature\");\n\tif (\n\t\tcredentialField === undefined ||\n\t\tsignedHeadersField === undefined ||\n\t\tsignatureField === undefined\n\t) {\n\t\treturn unsupportedAlgorithm();\n\t}\n\n\tconst credential = checkCredentialScope(\n\t\tcredentialField,\n\t\tamzDate,\n\t\tcredentials\n\t);\n\tif (\"error\" in credential) {\n\t\treturn credential.error;\n\t}\n\n\tconst signedHeaders = parseSignedHeaders(signedHeadersField);\n\tif (\"error\" in signedHeaders) {\n\t\treturn signedHeaders.error;\n\t}\n\n\tconst mismatch = await checkSignature(\n\t\trequest,\n\t\turl,\n\t\tcredentials,\n\t\tcredential,\n\t\tamzDate,\n\t\tsignedHeaders,\n\t\tpayloadHash,\n\t\tfalse,\n\t\tsignatureField\n\t);\n\tif (mismatch !== undefined) {\n\t\treturn mismatch;\n\t}\n\n\t// When a literal payload hash was signed (rather than UNSIGNED-PAYLOAD or\n\t// a streaming sentinel), verify the body actually matches it\n\tif (/^[0-9a-f]{64}$/.test(payloadHash)) {\n\t\tconst body = await request.clone().arrayBuffer();\n\t\tif ((await sha256Hex(body)) !== payloadHash) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"XAmzContentSHA256Mismatch\",\n\t\t\t\t\"The provided 'x-amz-content-sha256' header does not match what was computed.\"\n\t\t\t);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nasync function verifyPresigned(\n\trequest: Request,\n\turl: URL,\n\tcredentials: S3Credentials\n): Promise<Response | undefined> {\n\tconst params = url.searchParams;\n\n\tconst missing = [\n\t\t\"X-Amz-Algorithm\",\n\t\t\"X-Amz-Signature\",\n\t\t\"X-Amz-Date\",\n\t\t\"X-Amz-SignedHeaders\",\n\t\t\"X-Amz-Expires\",\n\t].filter((name) => !params.has(name));\n\tif (missing.length === 1) {\n\t\treturn invalidArgument(`Required search parameter ${missing[0]} missing`);\n\t}\n\tif (missing.length > 1) {\n\t\treturn invalidArgument(\n\t\t\t`Required search parameters ${missing.join(\",  \")} missing`\n\t\t);\n\t}\n\n\tif (params.get(\"X-Amz-Algorithm\") !== ALGORITHM) {\n\t\treturn unsupportedAlgorithm();\n\t}\n\n\tconst amzDate = params.get(\"X-Amz-Date\");\n\tconst expiresParam = params.get(\"X-Amz-Expires\");\n\tconst signedHeadersParam = params.get(\"X-Amz-SignedHeaders\");\n\tconst provided = params.get(\"X-Amz-Signature\");\n\tassert(\n\t\tamzDate !== null &&\n\t\t\texpiresParam !== null &&\n\t\t\tsignedHeadersParam !== null &&\n\t\t\tprovided !== null\n\t);\n\n\tconst date = parseAmzDate(amzDate);\n\tif (date === undefined) {\n\t\treturn invalidArgument(\n\t\t\t`Date provided in X-Amz-Date (${amzDate}) didn't parse successfully`\n\t\t);\n\t}\n\n\tconst credentialParam = params.get(\"X-Amz-Credential\");\n\tassert(credentialParam !== null);\n\tconst credential = checkCredentialScope(\n\t\tcredentialParam,\n\t\tamzDate,\n\t\tcredentials\n\t);\n\tif (\"error\" in credential) {\n\t\treturn credential.error;\n\t}\n\n\t// `Number(\"\")` is 0, but we must reject an empty X-Amz-Expires.\n\tconst expires =\n\t\texpiresParam.trim() === \"\" ? Number.NaN : Number(expiresParam);\n\tif (Number.isNaN(expires)) {\n\t\treturn invalidArgument(\"X-Amz-Expires should be a number\");\n\t}\n\tif (expires > MAX_EXPIRES_SECONDS) {\n\t\treturn invalidArgument(\n\t\t\t`X-Amz-Expires must be less than a week (in seconds); that is, the given X-Amz-Expires must be less than ${MAX_EXPIRES_SECONDS} seconds`\n\t\t);\n\t}\n\tif (expires < 1 || Date.now() > date.getTime() + expires * 1000) {\n\t\treturn errorResponse(403, \"ExpiredRequest\", \"Request has expired\");\n\t}\n\n\tconst signedHeaders = parseSignedHeaders(signedHeadersParam);\n\tif (\"error\" in signedHeaders) {\n\t\treturn signedHeaders.error;\n\t}\n\n\t// Presigned URLs sign the payload as UNSIGNED-PAYLOAD since the body is\n\t// not known at signing time\n\treturn checkSignature(\n\t\trequest,\n\t\turl,\n\t\tcredentials,\n\t\tcredential,\n\t\tamzDate,\n\t\tsignedHeaders,\n\t\t\"UNSIGNED-PAYLOAD\",\n\t\ttrue,\n\t\tprovided\n\t);\n}\n\n/** Timing-safe comparison of credential pairs */\nexport function credentialsEqual(\n\texpected: S3Credentials,\n\tprovided: S3Credentials\n): boolean {\n\treturn (\n\t\ttimingSafeStringsEqual(expected.accessKeyId, provided.accessKeyId) &&\n\t\ttimingSafeStringsEqual(expected.secretAccessKey, provided.secretAccessKey)\n\t);\n}\n\n/** Whether the request carries either SigV4 authentication method */\nexport function hasAuthentication(\n\trequest: Request,\n\tparams: URLSearchParams\n): boolean {\n\treturn (\n\t\trequest.headers.get(\"Authorization\") !== null ||\n\t\tparams.has(\"X-Amz-Credential\")\n\t);\n}\n\n/**\n * Verifies a request against AWS Signature Version 4, returning an R2-style\n * XML error `Response` on failure, or `undefined` if authentication succeeds.\n */\nexport async function verifyRequest(\n\trequest: Request,\n\tcredentials: S3Credentials\n): Promise<Response | undefined> {\n\tconst url = new URL(request.url);\n\n\t// The Authorization header takes precedence over presigned query params.\n\tconst authorization = request.headers.get(\"Authorization\");\n\tif (authorization !== null) {\n\t\treturn verifyAuthorizationHeader(request, url, credentials, authorization);\n\t}\n\n\tif (url.searchParams.has(\"X-Amz-Credential\")) {\n\t\treturn verifyPresigned(request, url, credentials);\n\t}\n\n\treturn invalidArgument(\"Authorization\");\n}\n", "import { Buffer } from \"node:buffer\";\nimport { XMLBuilder, XMLParser } from \"fast-xml-parser\";\nimport type { R2S3Bindings, S3Credentials } from \"../constants\";\nimport type { Context } from \"hono\";\n\nexport interface Env {\n\t[R2S3Bindings.JSON_CREDENTIALS]: Record<string, S3Credentials>;\n\t[bucket: `${typeof R2S3Bindings.BUCKET_PREFIX}${string}`]:\n\t\t| R2Bucket\n\t\t| undefined;\n}\n\nexport type S3Context = Context<{ Bindings: Env }>;\n\n/** HEAD responses must not include a body */\nexport function stripBodyForHead(c: S3Context, response: Response): Response {\n\treturn c.req.method === \"HEAD\" && response.body !== null\n\t\t? new Response(null, response)\n\t\t: response;\n}\n\nconst XMLNS = \"http://s3.amazonaws.com/doc/2006-03-01/\";\nexport const MAX_LIST_KEYS = 1000;\nexport const MAX_DELETE_KEYS = 1000;\n\nconst xmlBuilder = new XMLBuilder({ ignoreAttributes: false });\nexport const xmlParser = new XMLParser({\n\tignoreAttributes: true,\n\tparseTagValue: false,\n});\n\nexport function xmlResponse(\n\troot: string,\n\tcontent: Record<string, unknown>,\n\tstatus = 200\n): Response {\n\tconst body = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>${xmlBuilder.build({\n\t\t[root]: { \"@_xmlns\": XMLNS, ...content },\n\t})}`;\n\treturn new Response(body, {\n\t\tstatus,\n\t\theaders: { \"Content-Type\": \"application/xml\" },\n\t});\n}\n\nexport function hex(bytes: ArrayLike<number> | ArrayBuffer): string {\n\treturn Buffer.from(bytes).toString(\"hex\");\n}\n\nexport function coerceArray<T>(value: T | T[] | undefined): T[] {\n\tif (value === undefined) {\n\t\treturn [];\n\t}\n\n\treturn Array.isArray(value) ? value : [value];\n}\n", "function xmlEscape(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\n/**\n * https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html\n * Unlike success documents, R2's <Error> documents carry no xmlns.\n * `extraFields` are appended after <Message> in entry order (e.g.\n * SignatureDoesNotMatch's debug fields).\n *\n * Hand-built rather than with common.worker's XMLBuilder: R2 escapes `'` as\n * `&apos;` in error messages, which fast-xml-parser's entity processing\n * does not reproduce.\n */\nexport function errorResponse(\n\tstatus: number,\n\tcode: string,\n\tmessage: string,\n\textraFields: Record<string, string> = {}\n) {\n\tconst extra = Object.entries(extraFields)\n\t\t.map(([name, value]) => `<${name}>${xmlEscape(value)}</${name}>`)\n\t\t.join(\"\");\n\tconst body = `<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>${code}</Code><Message>${xmlEscape(message)}</Message>${extra}</Error>`;\n\treturn new Response(body, {\n\t\tstatus,\n\t\theaders: { \"Content-Type\": \"application/xml\" },\n\t});\n}\n\nexport const noSuchBucket = () =>\n\terrorResponse(404, \"NoSuchBucket\", \"The specified bucket does not exist.\");\n\nexport const notImplemented = (message: string) =>\n\terrorResponse(501, \"NotImplemented\", message);\n\nexport const routeNotFound = () =>\n\terrorResponse(404, \"RouteNotFound\", \"No route matches this url.\");\n", "import { errorResponse, notImplemented, routeNotFound } from \"./errors.worker\";\nimport type { S3Context } from \"./common.worker\";\n\nconst notImplementedOperation = (name: string) =>\n\tnotImplemented(`${name} not implemented`);\n\nexport type BucketOperation =\n\t| \"HeadBucket\"\n\t| \"GetBucketLocation\"\n\t| \"GetBucketEncryption\"\n\t| \"GetBucketVersioning\"\n\t| \"GetBucketTagging\"\n\t| \"GetObjectLockConfiguration\"\n\t| \"GetBucketReplication\"\n\t| \"ListObjects\"\n\t| \"ListObjectsV2\"\n\t| \"DeleteObjects\";\n\nexport type ObjectOperation =\n\t| \"GetObject\"\n\t| \"HeadObject\"\n\t| \"PutObject\"\n\t| \"CopyObject\"\n\t| \"DeleteObject\"\n\t| \"CreateMultipartUpload\";\n\n/** Operations on an in-progress multipart upload, addressed by ?uploadId */\nexport type MultipartOperation =\n\t| \"UploadPart\"\n\t| \"UploadPartCopy\"\n\t| \"CompleteMultipartUpload\"\n\t| \"AbortMultipartUpload\";\n\nexport type S3Operation =\n\t| BucketOperation\n\t| ObjectOperation\n\t| MultipartOperation;\n\nexport interface MultipartDetection {\n\toperation: MultipartOperation;\n\tuploadId: string;\n}\n\n/**\n * Object-level subresource query parameters map onto operations R2's S3\n * endpoint recognizes but does not implement. Subresource parameters\n * without an entry for the request method are silently ignored (e.g.\n * `DELETE ?tagging` is plain DeleteObject on R2).\n */\nconst OBJECT_SUBRESOURCES: Record<string, Partial<Record<string, string>>> = {\n\ttagging: { GET: \"GetObjectTagging\", PUT: \"PutObjectTagging\" },\n\tacl: { GET: \"GetObjectAcl\", PUT: \"PutObjectAcl\" },\n\tattributes: { GET: \"GetObjectAttributes\" },\n\ttorrent: { GET: \"GetObjectTorrent\" },\n\tretention: { GET: \"GetObjectRetention\", PUT: \"PutObjectRetention\" },\n\t\"legal-hold\": { GET: \"GetObjectLegalHold\", PUT: \"PutObjectLegalHold\" },\n};\n\n/**\n * Bucket-level GET subresources that respond with R2's templated\n * \"<name> not implemented\" error. Most are unimplemented on R2 too.\n * acl/cors/lifecycle are implemented by real R2 but return per-bucket state\n * (CORS rules, lifecycle rules, the account id in the ACL owner)\n * that the R2 binding does not expose.\n */\nconst BUCKET_GET_NOT_IMPLEMENTED: Partial<Record<string, string>> = {\n\tversions: \"ListObjectVersions\",\n\tpolicy: \"GetBucketPolicy\",\n\twebsite: \"GetBucketWebsite\",\n\tnotification: \"GetBucketNotificationConfiguration\",\n\trequestPayment: \"GetBucketRequestPayment\",\n\tlogging: \"GetBucketLogging\",\n\taccelerate: \"GetBucketAccelerateConfiguration\",\n\tpublicAccessBlock: \"GetPublicAccessBlock\",\n\townershipControls: \"GetBucketOwnershipControls\",\n\t\"intelligent-tiering\": \"GetBucketIntelligentTieringConfiguration\",\n\tinventory: \"GetBucketInventoryConfiguration\",\n\tmetrics: \"GetBucketMetricsConfiguration\",\n\tanalytics: \"GetBucketAnalyticsConfiguration\",\n\t// R2's typo, reproduced verbatim\n\tpolicyStatus: \"GetGetBucketPolicyStatus\",\n\tacl: \"GetBucketAcl\",\n\tcors: \"GetBucketCors\",\n\tlifecycle: \"GetBucketLifecycleConfiguration\",\n};\n\n/**\n * Bucket-level PUT subresources, all answered with R2's templated named\n * error. cors/encryption/lifecycle/versioning are implemented by real R2\n * (it validates the XML body before anything else) but write per-bucket\n * state the R2 binding cannot manage; since prod never reveals its names\n * for them, they use the AWS operation names.\n */\nconst BUCKET_PUT_NOT_IMPLEMENTED: Partial<Record<string, string>> = {\n\taccelerate: \"PutBucketAccelerateConfiguration\",\n\tacl: \"PutBucketAcl\",\n\tanalytics: \"PutBucketAnalyticsConfiguration\",\n\t\"intelligent-tiering\": \"PutBucketIntelligentTieringConfiguration\",\n\tinventory: \"PutBucketInventoryConfiguration\",\n\tlogging: \"PutBucketLogging\",\n\tmetrics: \"PutBucketMetricsConfiguration\",\n\tnotification: \"PutBucketNotificationConfiguration\",\n\t\"object-lock\": \"PutObjectLockConfiguration\",\n\townershipControls: \"PutBucketOwnershipControls\",\n\tpolicy: \"PutBucketPolicy\",\n\tpublicAccessBlock: \"PutPublicAccessBlock\",\n\treplication: \"PutBucketReplication\",\n\trequestPayment: \"PutBucketRequestPayment\",\n\ttagging: \"PutBucketTagging\",\n\twebsite: \"PutBucketWebsite\",\n\tcors: \"PutBucketCors\",\n\tencryption: \"PutBucketEncryption\",\n\tlifecycle: \"PutBucketLifecycleConfiguration\",\n\tversioning: \"PutBucketVersioning\",\n};\n\n/**\n * Bucket-level DELETE subresources. cors/encryption/lifecycle are\n * implemented by real R2 (permission-gated) but have no binding equivalent;\n * AWS operation names, as above. Subresources that exist only for other\n * methods (?versioning, ?acl, ...) are NOT special-cased on DELETE; R2\n * reports them via the \"Unsupported search param(s)\" error.\n */\nconst BUCKET_DELETE_NOT_IMPLEMENTED: Partial<Record<string, string>> = {\n\tanalytics: \"DeleteBucketAnalyticsConfiguration\",\n\t\"intelligent-tiering\": \"DeleteBucketIntelligentTieringConfiguration\",\n\tinventory: \"DeleteBucketInventoryConfiguration\",\n\tmetrics: \"DeleteBucketMetricsConfiguration\",\n\townershipControls: \"DeleteBucketOwnershipControls\",\n\tpolicy: \"DeleteBucketPolicy\",\n\treplication: \"DeleteBucketReplication\",\n\ttagging: \"DeleteBucketTagging\",\n\twebsite: \"DeleteBucketWebsite\",\n\tcors: \"DeleteBucketCors\",\n\tencryption: \"DeleteBucketEncryption\",\n\tlifecycle: \"DeleteBucketLifecycle\",\n};\n\n/**\n * Bucket-configuration reads with static responses on R2 (identical\n * for every bucket, since R2 has no versioning/tagging/object\n * lock/replication and always encrypts with AES256)\n */\nconst BUCKET_GET_STATIC: Partial<Record<string, BucketOperation>> = {\n\tencryption: \"GetBucketEncryption\",\n\tversioning: \"GetBucketVersioning\",\n\ttagging: \"GetBucketTagging\",\n\t\"object-lock\": \"GetObjectLockConfiguration\",\n\treplication: \"GetBucketReplication\",\n};\n\n/**\n * Query parameters R2 accepts on list requests. Reject anything else\n * (excluding presign parameters and the SDK's x-id) with R2's\n * \"search parameter\" error.\n */\nconst LIST_OBJECTS_PARAMS = new Set([\n\t\"prefix\",\n\t\"delimiter\",\n\t\"marker\",\n\t\"max-keys\",\n\t\"encoding-type\",\n]);\nconst LIST_OBJECTS_V2_PARAMS = new Set([\n\t\"list-type\",\n\t\"prefix\",\n\t\"delimiter\",\n\t\"continuation-token\",\n\t\"start-after\",\n\t\"max-keys\",\n\t\"encoding-type\",\n\t\"fetch-owner\",\n]);\n\nexport function isScreenedParam(name: string): boolean {\n\treturn name.startsWith(\"X-Amz-\") || name === \"x-id\";\n}\n\nfunction detectListOperation(\n\tparams: URLSearchParams\n): BucketOperation | Response {\n\tconst listType = params.get(\"list-type\");\n\tif (listType !== null && listType !== \"2\") {\n\t\treturn notImplementedOperation(`ListObjectsV${listType}`);\n\t}\n\n\tconst v2 = listType === \"2\";\n\t// Reject V2-only pagination on V1\n\tif (!v2 && params.has(\"continuation-token\")) {\n\t\treturn errorResponse(\n\t\t\t400,\n\t\t\t\"InvalidArgument\",\n\t\t\t\"continuation-token not supported in ListObjects\"\n\t\t);\n\t}\n\n\tconst allowed = v2 ? LIST_OBJECTS_V2_PARAMS : LIST_OBJECTS_PARAMS;\n\tfor (const name of params.keys()) {\n\t\tif (!allowed.has(name) && !isScreenedParam(name)) {\n\t\t\treturn notImplemented(\n\t\t\t\t`ListObjectsV${v2 ? \"2\" : \"1\"} search parameter ${name} not implemented`\n\t\t\t);\n\t\t}\n\t}\n\n\treturn v2 ? \"ListObjectsV2\" : \"ListObjects\";\n}\n\n/**\n * Bucket-level PUT/DELETE: a recognized subresource (in any position) wins\n * with its named templated error; otherwise every non-presign param is\n * rejected together. Only a bare PUT/DELETE reaches CreateBucket /\n * DeleteBucket; both are implemented by real R2, but local buckets are\n * statically configured, so they get the templated named error instead.\n */\nfunction detectBucketMutation(\n\tmethod: string,\n\tparams: URLSearchParams,\n\tsubresources: Partial<Record<string, string>>,\n\tbareOperation: string\n): Response {\n\tfor (const name of params.keys()) {\n\t\tconst operation = subresources[name];\n\t\tif (operation !== undefined) {\n\t\t\treturn notImplementedOperation(operation);\n\t\t}\n\t}\n\n\tconst unsupported = [...new Set(params.keys())].filter(\n\t\t(name) => !isScreenedParam(name)\n\t);\n\tif (unsupported.length > 0) {\n\t\treturn errorResponse(\n\t\t\t400,\n\t\t\t\"InvalidArgument\",\n\t\t\t`Unsupported search param(s) ${unsupported\n\t\t\t\t.map((name) => `\"${name}\"`)\n\t\t\t\t.join(\", \")} on a ${method} bucket route`\n\t\t);\n\t}\n\n\treturn notImplementedOperation(bareOperation);\n}\n\nexport function detectBucketOperation(\n\tmethod: string,\n\tparams: URLSearchParams\n): BucketOperation | Response {\n\tswitch (method) {\n\t\tcase \"HEAD\":\n\t\t\treturn \"HeadBucket\";\n\t\tcase \"PUT\":\n\t\t\treturn detectBucketMutation(\n\t\t\t\t\"PUT\",\n\t\t\t\tparams,\n\t\t\t\tBUCKET_PUT_NOT_IMPLEMENTED,\n\t\t\t\t\"CreateBucket\"\n\t\t\t);\n\t\tcase \"DELETE\":\n\t\t\treturn detectBucketMutation(\n\t\t\t\t\"DELETE\",\n\t\t\t\tparams,\n\t\t\t\tBUCKET_DELETE_NOT_IMPLEMENTED,\n\t\t\t\t\"DeleteBucket\"\n\t\t\t);\n\t\tcase \"POST\":\n\t\t\t// ?delete is DeleteObjects; respond 200 with an empty body to\n\t\t\t// any other bucket-level POST\n\t\t\treturn params.has(\"delete\")\n\t\t\t\t? \"DeleteObjects\"\n\t\t\t\t: new Response(null, { status: 200 });\n\t\tcase \"GET\": {\n\t\t\tif (params.has(\"uploads\")) {\n\t\t\t\treturn notImplementedOperation(\"ListMultipartUploads\");\n\t\t\t}\n\n\t\t\tif (params.has(\"location\")) {\n\t\t\t\tfor (const name of params.keys()) {\n\t\t\t\t\tif (name !== \"location\" && !isScreenedParam(name)) {\n\t\t\t\t\t\treturn errorResponse(\n\t\t\t\t\t\t\t400,\n\t\t\t\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\t\t\t`Search param ${name} is unsupported for bucket location`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn \"GetBucketLocation\";\n\t\t\t}\n\n\t\t\tfor (const name of params.keys()) {\n\t\t\t\tconst staticOperation = BUCKET_GET_STATIC[name];\n\t\t\t\tif (staticOperation !== undefined) {\n\t\t\t\t\treturn staticOperation;\n\t\t\t\t}\n\n\t\t\t\tconst notImplementedName = BUCKET_GET_NOT_IMPLEMENTED[name];\n\t\t\t\tif (notImplementedName !== undefined) {\n\t\t\t\t\treturn notImplementedOperation(notImplementedName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn detectListOperation(params);\n\t\t}\n\t\tdefault:\n\t\t\treturn routeNotFound();\n\t}\n}\n\n/** A recognized object subresource wins with its named templated error */\nfunction objectSubresourceError(\n\tparams: URLSearchParams,\n\tmethod: string\n): Response | undefined {\n\tfor (const name of params.keys()) {\n\t\tconst subresource = OBJECT_SUBRESOURCES[name]?.[method];\n\t\tif (subresource !== undefined) {\n\t\t\treturn notImplementedOperation(subresource);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function detectObjectOperation(\n\tc: S3Context,\n\tparams: URLSearchParams\n): ObjectOperation | MultipartDetection | Response {\n\tconst method = c.req.method;\n\n\tconst uploadId = params.get(\"uploadId\");\n\tif (uploadId !== null) {\n\t\t// R2's part routes only match when partNumber looks like an\n\t\t// (optionally space-padded, signed) integer; other values (e.g.\n\t\t// `1.0`) match no route at all, and range validation happens later\n\t\tconst partNumber = params.get(\"partNumber\");\n\t\tif (partNumber !== null && !/^ *-?\\d*$/.test(partNumber)) {\n\t\t\treturn routeNotFound();\n\t\t}\n\t\tswitch (method) {\n\t\t\tcase \"GET\":\n\t\t\t\t// Real R2 implements ListParts when partNumber is also present\n\t\t\t\t// (and reports it unimplemented otherwise). The local R2\n\t\t\t\t// binding cannot list parts either way.\n\t\t\t\treturn notImplementedOperation(\"ListParts\");\n\t\t\tcase \"PUT\":\n\t\t\t\tif (partNumber === null) {\n\t\t\t\t\t// Without partNumber, ignore `uploadId` entirely and\n\t\t\t\t\t// treat the request as a plain PutObject/CopyObject\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\toperation:\n\t\t\t\t\t\tc.req.header(\"x-amz-copy-source\") !== undefined\n\t\t\t\t\t\t\t? \"UploadPartCopy\"\n\t\t\t\t\t\t\t: \"UploadPart\",\n\t\t\t\t\tuploadId,\n\t\t\t\t};\n\t\t\tcase \"POST\":\n\t\t\t\treturn { operation: \"CompleteMultipartUpload\", uploadId };\n\t\t\tcase \"DELETE\":\n\t\t\t\treturn { operation: \"AbortMultipartUpload\", uploadId };\n\t\t\tcase \"HEAD\":\n\t\t\t\treturn \"HeadObject\";\n\t\t\tdefault:\n\t\t\t\treturn routeNotFound();\n\t\t}\n\t}\n\tif (params.has(\"uploads\")) {\n\t\tif (method === \"POST\") {\n\t\t\treturn \"CreateMultipartUpload\";\n\t\t}\n\n\t\t// Serve the bucket's upload list even on object paths\n\t\tif (method === \"GET\") {\n\t\t\treturn notImplementedOperation(\"ListMultipartUploads\");\n\t\t}\n\t}\n\tswitch (method) {\n\t\tcase \"GET\":\n\t\tcase \"HEAD\":\n\t\t\t// Real R2 serves individual parts; `bucket.get()` cannot\n\t\t\tif (params.has(\"partNumber\")) {\n\t\t\t\treturn notImplementedOperation(\"partNumber\");\n\t\t\t}\n\n\t\t\tif (method === \"HEAD\") {\n\t\t\t\t// Real R2 HEAD ignores subresource parameters\n\t\t\t\treturn \"HeadObject\";\n\t\t\t}\n\n\t\t\treturn objectSubresourceError(params, method) ?? \"GetObject\";\n\t\tcase \"PUT\": {\n\t\t\tconst subresource = objectSubresourceError(params, method);\n\t\t\tif (subresource !== undefined) {\n\t\t\t\treturn subresource;\n\t\t\t}\n\n\t\t\treturn c.req.header(\"x-amz-copy-source\") !== undefined\n\t\t\t\t? \"CopyObject\"\n\t\t\t\t: \"PutObject\";\n\t\t}\n\t\tcase \"POST\":\n\t\t\t// R2 treats POST on an object key as PutObject, ignoring\n\t\t\t// subresource parameters. Unlike PUT, x-amz-copy-source does NOT\n\t\t\t// make it a CopyObject: R2 ignores the header and stores the\n\t\t\t// request body.\n\t\t\treturn \"PutObject\";\n\t\tcase \"DELETE\":\n\t\t\treturn \"DeleteObject\";\n\t\tdefault:\n\t\t\treturn routeNotFound();\n\t}\n}\n", "// The per-bucket request pipeline: resolve the bucket and its credentials,\n// authenticate, detect the operation, screen its headers, then run it.\nimport assert from \"node:assert\";\nimport { R2S3Bindings } from \"../constants\";\nimport { hasAuthentication, verifyRequest } from \"./auth.worker\";\nimport { stripBodyForHead } from \"./common.worker\";\nimport { detectBucketOperation, detectObjectOperation } from \"./detect.worker\";\nimport { noSuchBucket, notImplemented } from \"./errors.worker\";\nimport {\n\tBUCKET_OPERATIONS,\n\tMULTIPART_OPERATIONS,\n\tOBJECT_OPERATIONS,\n\tscreenHeaders,\n} from \"./operations.worker\";\nimport type { S3Context } from \"./common.worker\";\nimport type { S3Operation } from \"./detect.worker\";\nimport type { OperationDefinition, ScreeningRules } from \"./operations.worker\";\nimport type { Awaitable } from \"miniflare:shared\";\n\nexport async function dispatch(\n\tc: S3Context,\n\tkey: string | undefined\n): Promise<Response> {\n\treturn stripBodyForHead(c, await dispatchInner(c, key));\n}\n\nasync function dispatchInner(\n\tc: S3Context,\n\tkey: string | undefined\n): Promise<Response> {\n\t// Both routes that reach `dispatch()` carry a :bucketId segment\n\tconst bucketId = c.req.param(\"bucketId\");\n\tassert(bucketId !== undefined);\n\n\tconst credentials = c.env[R2S3Bindings.JSON_CREDENTIALS][bucketId];\n\tif (credentials === undefined) {\n\t\t// Real R2 verifies the signature before bucket existence (auth errors\n\t\t// win over the 404), but its credentials are account-scoped while\n\t\t// local credentials are per-bucket: an unknown bucket has no\n\t\t// credential set to verify against, so existence is reported first.\n\t\treturn noSuchBucket();\n\t}\n\n\t// The plugin binds exactly the buckets in the credential map\n\tconst bucket = c.env[`${R2S3Bindings.BUCKET_PREFIX}${bucketId}`];\n\tassert(bucket !== undefined);\n\n\tconst params = new URL(c.req.url).searchParams;\n\n\t// R2 interprets a bucket-level POST carrying no auth at all as an\n\t// attempted browser form upload (AWS's POST Object, where auth travels in\n\t// the form fields), which it recognizes but does not implement. The\n\t// doubled \"not implemented\" is R2's, verbatim. `?delete` (DeleteObjects)\n\t// gets the normal missing-auth error instead.\n\tif (\n\t\tkey === undefined &&\n\t\tc.req.method === \"POST\" &&\n\t\t!params.has(\"delete\") &&\n\t\t!hasAuthentication(c.req.raw, params)\n\t) {\n\t\treturn notImplemented(\n\t\t\t\"Presigned post requests are not yet implemented not implemented\"\n\t\t);\n\t}\n\n\tconst authError = await verifyRequest(c.req.raw, credentials);\n\tif (authError !== undefined) {\n\t\treturn authError;\n\t}\n\n\tconst detected = detectOperation(c, bucket, bucketId, key, params);\n\tif (detected instanceof Response) {\n\t\treturn detected;\n\t}\n\n\tconst screenError = screenHeaders(c, detected.operation, detected.rules);\n\tif (screenError !== undefined) {\n\t\treturn screenError;\n\t}\n\n\treturn detected.run();\n}\n\n/** A detected operation, bound to the context its handler needs */\ninterface BoundOperation {\n\toperation: S3Operation;\n\trules: ScreeningRules;\n\trun(): Awaitable<Response>;\n}\n\n/**\n * Detection and the operation tables are split by addressing level (bucket-,\n * object-, and multipart-level operations take different contexts). Binding\n * the context here keeps those splits out of `dispatch()`.\n */\nfunction detectOperation(\n\tc: S3Context,\n\tbucket: R2Bucket,\n\tbucketId: string,\n\tkey: string | undefined,\n\tparams: URLSearchParams\n): BoundOperation | Response {\n\tif (key === undefined) {\n\t\tconst detected = detectBucketOperation(c.req.method, params);\n\t\tif (detected instanceof Response) {\n\t\t\treturn detected;\n\t\t}\n\n\t\treturn bind(detected, BUCKET_OPERATIONS, { c, bucket, bucketId, params });\n\t}\n\n\tconst detected = detectObjectOperation(c, params);\n\tif (detected instanceof Response) {\n\t\treturn detected;\n\t}\n\n\tconst context = { c, bucket, bucketId, key, params };\n\t// Multipart operations, uniquely, are detected as an `object`\n\tif (typeof detected === \"object\") {\n\t\treturn bind(detected.operation, MULTIPART_OPERATIONS, {\n\t\t\t...context,\n\t\t\tuploadId: detected.uploadId,\n\t\t});\n\t}\n\n\treturn bind(detected, OBJECT_OPERATIONS, context);\n}\n\nfunction bind<Operation extends S3Operation, Context>(\n\toperation: Operation,\n\ttable: Record<Operation, OperationDefinition<Context> & ScreeningRules>,\n\tcontext: Context\n): BoundOperation {\n\tconst definition = table[operation];\n\treturn {\n\t\toperation,\n\t\trules: definition,\n\t\trun: () => definition.handle(context),\n\t};\n}\n", "import assert from \"node:assert\";\nimport { XMLValidator } from \"fast-xml-parser\";\nimport { CorePaths } from \"../../core/constants\";\nimport { R2S3Bindings } from \"../constants\";\nimport { parseRangeHeader, serveR2Object } from \"../serve.worker\";\nimport { awsUriEncode, credentialsEqual } from \"./auth.worker\";\nimport {\n\tcoerceArray,\n\thex,\n\tMAX_DELETE_KEYS,\n\tMAX_LIST_KEYS,\n\txmlParser,\n\txmlResponse,\n} from \"./common.worker\";\nimport { errorResponse, noSuchBucket, notImplemented } from \"./errors.worker\";\nimport type { S3Context } from \"./common.worker\";\nimport type {\n\tBucketOperation,\n\tMultipartOperation,\n\tObjectOperation,\n\tS3Operation,\n} from \"./detect.worker\";\nimport type { Awaitable } from \"miniflare:shared\";\n\ninterface S3Error {\n\tstatus: number;\n\tcode: string;\n\tmessage: string;\n}\n\nconst NO_SUCH_KEY: S3Error = {\n\tstatus: 404,\n\tcode: \"NoSuchKey\",\n\tmessage: \"The specified key does not exist.\",\n};\nconst PRECONDITION_FAILED: S3Error = {\n\tstatus: 412,\n\tcode: \"PreconditionFailed\",\n\tmessage: \"At least one of the pre-conditions you specified did not hold.\",\n};\nconst NO_SUCH_UPLOAD: S3Error = {\n\tstatus: 404,\n\tcode: \"NoSuchUpload\",\n\tmessage: \"The specified multipart upload does not exist.\",\n};\n\nconst s3Error = (error: S3Error) =>\n\terrorResponse(error.status, error.code, error.message);\n\nconst noSuchKey = () => s3Error(NO_SUCH_KEY);\n\nconst preconditionFailed = () => s3Error(PRECONDITION_FAILED);\n\nconst malformedXml = () =>\n\terrorResponse(\n\t\t400,\n\t\t\"MalformedXML\",\n\t\t\"The XML you provided was not well formed or did not validate against our published schema.\"\n\t);\n\nconst notImplementedHeader = (name: string, value: string) =>\n\terrorResponse(\n\t\t501,\n\t\t\"NotImplemented\",\n\t\t`Header '${name}' with value '${value}' not implemented`\n\t);\n\n/**\n * R2 binding errors carry a stable v4 error code in their message (e.g.\n * \"completeMultipartUpload: The specified multipart upload does not exist.\n * (10024)\"); map those onto the S3 error responses real R2 returns.\n */\nconst BINDING_ERRORS: Partial<Record<number, S3Error>> = {\n\t// NO_SUCH_OBJECT_KEY\n\t10007: NO_SUCH_KEY,\n\t// ENTITY_TOO_SMALL\n\t10011: {\n\t\tstatus: 400,\n\t\tcode: \"EntityTooSmall\",\n\t\tmessage:\n\t\t\t\"Your proposed upload is smaller than the minimum allowed object size.\",\n\t},\n\t// NO_SUCH_UPLOAD\n\t10024: NO_SUCH_UPLOAD,\n\t// INVALID_PART\n\t10025: {\n\t\tstatus: 400,\n\t\tcode: \"InvalidPart\",\n\t\tmessage: \"One or more of the specified parts could not be found.\",\n\t},\n\t// PRECONDITION_FAILED\n\t10031: PRECONDITION_FAILED,\n\t// INVALID_RANGE\n\t10039: {\n\t\tstatus: 416,\n\t\tcode: \"InvalidRange\",\n\t\tmessage: \"The requested range is not satisfiable\",\n\t},\n};\n\n/**\n * Parsing the message is the only option: workerd deliberately throws plain\n * Errors formatted as \"<action>: <message> (<v4Code>)\"; its structured\n * R2Error type is disabled (r2-rpc.c++, \"all we can send back to the user\n * is a message\").\n */\nfunction bindingError(e: unknown): Response {\n\tconst message = e instanceof Error ? e.message : String(e);\n\tconst v4Code = /\\((\\d+)\\)$/.exec(message);\n\tconst known = v4Code === null ? undefined : BINDING_ERRORS[Number(v4Code[1])];\n\tif (known !== undefined) {\n\t\treturn s3Error(known);\n\t}\n\n\treturn errorResponse(500, \"InternalError\", message);\n}\n\nconst BUCKET_OWNER = [\"x-amz-expected-bucket-owner\"];\nconst SOURCE_BUCKET_OWNER = [\"x-amz-source-expected-bucket-owner\"];\nconst MFA_AND_LOCK_BYPASS = [\"x-amz-mfa\", \"x-amz-bypass-governance-retention\"];\nconst COPY_SOURCE_CONDITIONALS = [\n\t\"x-amz-copy-source-if-match\",\n\t\"x-amz-copy-source-if-none-match\",\n\t\"x-amz-copy-source-if-modified-since\",\n\t\"x-amz-copy-source-if-unmodified-since\",\n];\n/** Headers R2 recognizes but rejects on every write operation */\nconst WRITE_UNSUPPORTED = [\n\t...BUCKET_OWNER,\n\t\"x-amz-tagging\",\n\t\"x-amz-grant-full-control\",\n\t\"x-amz-grant-read\",\n\t\"x-amz-grant-read-acp\",\n\t\"x-amz-grant-write\",\n\t\"x-amz-grant-write-acp\",\n\t\"x-amz-website-redirect-location\",\n\t\"x-amz-object-lock-mode\",\n\t\"x-amz-object-lock-retain-until-date\",\n\t\"x-amz-object-lock-legal-hold\",\n\t\"x-amz-server-side-encryption-aws-kms-key-id\",\n\t\"x-amz-server-side-encryption-context\",\n\t\"x-amz-server-side-encryption-bucket-key-enabled\",\n];\n\n/** Everything a bucket-level handler might need, resolved once in `dispatch()` */\nexport interface BucketOperationContext {\n\tc: S3Context;\n\tbucket: R2Bucket;\n\tbucketId: string;\n\tparams: URLSearchParams;\n}\n\n/** Object-level operations additionally address a key within the bucket */\nexport interface ObjectOperationContext extends BucketOperationContext {\n\tkey: string;\n}\n\n/** Multipart operations additionally address an in-progress upload */\nexport interface MultipartOperationContext extends ObjectOperationContext {\n\tuploadId: string;\n}\n\nexport interface ScreeningRules {\n\t/** Headers rejected with the templated NotImplemented error */\n\tunsupportedHeaders: string[];\n\t/** Validate x-amz-server-side-encryption / x-amz-acl values */\n\tvalidatesWriteHeaders?: true;\n\t/**\n\t * SSE-C handling: real R2 supports SSE-C on these operations, but the\n\t * local simulator ignores encryption keys. \"read\" returns R2's standard\n\t * error for SSE-C parameters on an unencrypted object; \"write\" reports\n\t * the header as NotImplemented rather than silently storing plaintext.\n\t */\n\tssec?: \"read\" | \"write\";\n}\n\nexport interface OperationDefinition<Context> {\n\thandle(operation: Context): Awaitable<Response>;\n}\n\n/**\n * Accept canned ACLs as no-ops (R2 has no object ACLs); reject anything\n * else with the templated NotImplemented error\n */\nconst CANNED_ACLS = new Set([\n\t\"private\",\n\t\"public-read\",\n\t\"public-read-write\",\n\t\"authenticated-read\",\n\t\"aws-exec-read\",\n\t\"bucket-owner-read\",\n\t\"bucket-owner-full-control\",\n]);\n\nexport function screenHeaders(\n\tc: S3Context,\n\toperation: S3Operation,\n\trules: ScreeningRules\n): Response | undefined {\n\t// Reject session tokens on every operation (auth-level, not\n\t// operation-level)\n\tif (c.req.header(\"x-amz-security-token\") !== undefined) {\n\t\treturn errorResponse(400, \"InvalidArgument\", \"X-Amz-Security-Token\");\n\t}\n\n\tfor (const name of rules.unsupportedHeaders) {\n\t\tconst value = c.req.header(name);\n\t\tif (value !== undefined) {\n\t\t\treturn notImplementedHeader(name, value);\n\t\t}\n\t}\n\n\tif (rules.validatesWriteHeaders === true) {\n\t\t// R2 encrypts at rest with AES256 anyway, so that value is a truthful\n\t\t// no-op; KMS and other modes are not implemented\n\t\tconst sse = c.req.header(\"x-amz-server-side-encryption\");\n\t\tif (sse !== undefined && sse !== \"AES256\") {\n\t\t\treturn notImplementedHeader(\"x-amz-server-side-encryption\", sse);\n\t\t}\n\n\t\tconst acl = c.req.header(\"x-amz-acl\");\n\t\tif (acl !== undefined && !CANNED_ACLS.has(acl)) {\n\t\t\treturn notImplementedHeader(\"x-amz-acl\", acl);\n\t\t}\n\t}\n\n\tif (rules.ssec !== undefined) {\n\t\treturn screenSSECHeaders(c, operation, rules.ssec);\n\t}\n\n\treturn undefined;\n}\n\nfunction screenSSECHeaders(\n\tc: S3Context,\n\toperation: S3Operation,\n\tmode: \"read\" | \"write\"\n): Response | undefined {\n\tconst prefixes =\n\t\toperation === \"CopyObject\" || operation === \"UploadPartCopy\"\n\t\t\t? [\"x-amz-\", \"x-amz-copy-source-\"]\n\t\t\t: [\"x-amz-\"];\n\tfor (const prefix of prefixes) {\n\t\tconst algorithmName = `${prefix}server-side-encryption-customer-algorithm`;\n\t\tconst algorithm = c.req.header(algorithmName);\n\t\tconst key = c.req.header(`${prefix}server-side-encryption-customer-key`);\n\t\tconst keyMd5 = c.req.header(\n\t\t\t`${prefix}server-side-encryption-customer-key-MD5`\n\t\t);\n\t\tif (algorithm === undefined && key === undefined && keyMd5 === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// R2 requires the full header triple, checked in this order\n\t\tif (key === undefined) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\"Requests specifying Server Side Encryption with Customer provided keys must provide an appropriate secret key.\"\n\t\t\t);\n\t\t}\n\t\tif (keyMd5 === undefined) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\"Requests specifying Server Side Encryption with Customer provided keys must provide the client calculated MD5 of the secret key.\"\n\t\t\t);\n\t\t}\n\t\tif (algorithm === undefined) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\"Requests specifying Server Side Encryption with Customer provided keys must provide a valid encryption algorithm.\"\n\t\t\t);\n\t\t}\n\t\t// After the triple is complete, R2 validates the algorithm value (on\n\t\t// reads, writes, and copy sources alike) before anything else\n\t\tif (algorithm !== \"AES256\") {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidEncryptionAlgorithmError\",\n\t\t\t\t\"The encryption request that you specified is not valid. The valid value is AES256.\"\n\t\t\t);\n\t\t}\n\n\t\treturn mode === \"read\"\n\t\t\t? errorResponse(\n\t\t\t\t\t400,\n\t\t\t\t\t\"InvalidRequest\",\n\t\t\t\t\t\"The encryption parameters are not applicable to this object.\"\n\t\t\t\t)\n\t\t\t: notImplementedHeader(algorithmName, algorithm);\n\t}\n\n\treturn undefined;\n}\n\nconst CONDITIONAL_HEADERS = [\n\t\"If-Match\",\n\t\"If-None-Match\",\n\t\"If-Modified-Since\",\n\t\"If-Unmodified-Since\",\n];\n\n/**\n * The request body for a write: streamed through untouched unless\n * Content-MD5 verification requires buffering it.\n */\nasync function verifiedRequestBody(\n\tc: S3Context\n): Promise<ReadableStream | ArrayBuffer | string | Response> {\n\tif (c.req.header(\"Content-MD5\") === undefined) {\n\t\treturn c.req.raw.body ?? \"\";\n\t}\n\n\tconst buffered = await c.req.raw.arrayBuffer();\n\tconst digestError = await verifyContentMD5(c, buffered);\n\treturn digestError ?? buffered;\n}\n\nasync function verifyContentMD5(\n\tc: S3Context,\n\tbody: ArrayBuffer\n): Promise<Response | undefined> {\n\tconst contentMd5 = c.req.header(\"Content-MD5\");\n\tif (contentMd5 === undefined) {\n\t\treturn undefined;\n\t}\n\tlet provided: Uint8Array;\n\ttry {\n\t\tprovided = Uint8Array.from(atob(contentMd5), (char) => char.charCodeAt(0));\n\t\tif (provided.length !== 16) {\n\t\t\tthrow new Error(\"bad length\");\n\t\t}\n\t} catch {\n\t\treturn errorResponse(\n\t\t\t400,\n\t\t\t\"InvalidDigest\",\n\t\t\t\"The checksum or Content-MD5 you specified is not valid.\"\n\t\t);\n\t}\n\tconst computed = hex(await crypto.subtle.digest(\"MD5\", body));\n\tif (hex(provided) !== computed) {\n\t\treturn errorResponse(\n\t\t\t400,\n\t\t\t\"BadDigest\",\n\t\t\t`The MD5 checksum you specified did not match what we received.\\nYou provided a MD5 checksum with value: ${hex(provided)}\\nActual MD5 was: ${computed}`\n\t\t);\n\t}\n\treturn undefined;\n}\n\n/** Returns the R2 storage class for x-amz-storage-class, or an error */\nfunction parseStorageClass(c: S3Context): string | undefined | Response {\n\tconst header = c.req.header(\"x-amz-storage-class\");\n\tswitch (header) {\n\t\tcase undefined:\n\t\t\treturn undefined;\n\t\tcase \"STANDARD\":\n\t\t\treturn \"Standard\";\n\t\tcase \"STANDARD_IA\":\n\t\t\t// The simulator can't persist storage classes, so rather than\n\t\t\t// silently storing as STANDARD, reject non-default classes\n\t\t\treturn notImplementedHeader(\"x-amz-storage-class\", header);\n\t\tdefault:\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidStorageClass\",\n\t\t\t\t\"The storage class specified is not valid.\"\n\t\t\t);\n\t}\n}\n\nfunction collectCustomMetadata(c: S3Context): Record<string, string> {\n\tconst customMetadata: Record<string, string> = {};\n\tfor (const [name, value] of c.req.raw.headers) {\n\t\tif (name.startsWith(\"x-amz-meta-\")) {\n\t\t\tcustomMetadata[name.slice(\"x-amz-meta-\".length)] = value;\n\t\t}\n\t}\n\n\treturn customMetadata;\n}\n\n/**\n * Parses `x-amz-copy-source` (`/bucket/key` or `bucket/key`) and resolves\n * the source bucket binding.\n */\nfunction parseCopySource(\n\tc: S3Context,\n\tbucketId: string\n): { bucket: R2Bucket; key: string } | Response {\n\t// detectObjectOperation() only routes to copy operations when the header\n\t// exists\n\tconst header = c.req.header(\"x-amz-copy-source\");\n\tassert(header !== undefined);\n\tconst raw = decodeURIComponent(header);\n\tconst source = raw.startsWith(\"/\") ? raw.slice(1) : raw;\n\tconst separator = source.indexOf(\"/\");\n\tif (separator === -1 || separator === source.length - 1) {\n\t\treturn errorResponse(400, \"InvalidArgument\", \"copy source bucket name\");\n\t}\n\n\tconst sourceBucketId = source.slice(0, separator);\n\tconst bucket = c.env[`${R2S3Bindings.BUCKET_PREFIX}${sourceBucketId}`];\n\tif (bucket === undefined) {\n\t\treturn noSuchBucket();\n\t}\n\n\t// Credentials are per-bucket: the pair the request authenticated with\n\t// (the target bucket's) must also grant access to the source bucket.\n\t// Real R2 credentials are account-scoped, so it has no equivalent check.\n\tconst credentials = c.env[R2S3Bindings.JSON_CREDENTIALS];\n\tconst sourceCredentials = credentials[sourceBucketId];\n\tconst targetCredentials = credentials[bucketId];\n\tassert(sourceCredentials !== undefined && targetCredentials !== undefined);\n\tif (!credentialsEqual(sourceCredentials, targetCredentials)) {\n\t\treturn errorResponse(401, \"Unauthorized\", \"Unauthorized\");\n\t}\n\n\treturn { bucket, key: source.slice(separator + 1) };\n}\n\n/** Maps x-amz-copy-source-if-* headers onto standard conditional headers */\nfunction copySourceConditionals(c: S3Context): Headers | undefined {\n\tlet headers: Headers | undefined;\n\tfor (const standard of CONDITIONAL_HEADERS) {\n\t\tconst value = c.req.header(`x-amz-copy-source-${standard.toLowerCase()}`);\n\t\tif (value !== undefined) {\n\t\t\theaders ??= new Headers();\n\t\t\theaders.set(standard, value);\n\t\t}\n\t}\n\n\treturn headers;\n}\n\nfunction serveObject(\n\tc: S3Context,\n\tbucket: R2Bucket,\n\tkey: string\n): Awaitable<Response> {\n\tconst rangeHeader = c.req.header(\"Range\");\n\tconst range = rangeHeader === undefined ? {} : parseRangeHeader(rangeHeader);\n\tif (\"error\" in range) {\n\t\tswitch (range.error) {\n\t\t\tcase \"malformed\":\n\t\t\t\t// R2's message really ends with `.'`\n\t\t\t\treturn errorResponse(\n\t\t\t\t\t400,\n\t\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\t\"range must be in format 'bytes=start-end', 'bytes=start-' or 'bytes=-suffix'.'\"\n\t\t\t\t);\n\t\t\tcase \"inverted\":\n\t\t\t\treturn errorResponse(400, \"InvalidArgument\", \"range must be positive.\");\n\t\t\tcase \"unsatisfiable\":\n\t\t\t\treturn errorResponse(\n\t\t\t\t\t416,\n\t\t\t\t\t\"InvalidRange\",\n\t\t\t\t\t\"The requested range is not satisfiable\"\n\t\t\t\t);\n\t\t}\n\t}\n\n\treturn serveR2Object(\n\t\tc.req.raw,\n\t\tbucket,\n\t\tkey,\n\t\t{\n\t\t\tnotFound: noSuchKey,\n\t\t\tpreconditionFailed,\n\t\t\tinvalidRange: () =>\n\t\t\t\terrorResponse(\n\t\t\t\t\t416,\n\t\t\t\t\t\"InvalidRange\",\n\t\t\t\t\t\"The requested range is not satisfiable\"\n\t\t\t\t),\n\t\t\tdecorateHeaders(object, headers) {\n\t\t\t\tfor (const [name, value] of Object.entries(\n\t\t\t\t\tobject.customMetadata ?? {}\n\t\t\t\t)) {\n\t\t\t\t\theaders.set(`x-amz-meta-${name}`, value);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\trange\n\t);\n}\n\nasync function listObjects(\n\tparams: URLSearchParams,\n\tbucket: R2Bucket,\n\tbucketId: string,\n\tv2: boolean\n): Promise<Response> {\n\tconst encodingType = params.get(\"encoding-type\");\n\tif (encodingType !== null && encodingType !== \"url\") {\n\t\treturn notImplemented(\n\t\t\t`Unrecognized encoding-type \"${encodingType}\" not implemented`\n\t\t);\n\t}\n\n\tconst encode = (value: string) =>\n\t\tencodingType === \"url\" ? awsUriEncode(value) : value;\n\n\t// R2 floors fractional values and allows 0 and values above the limit\n\t// (clamping the effective page size but echoing the requested MaxKeys)\n\tlet maxKeys = MAX_LIST_KEYS;\n\tconst maxKeysParam = params.get(\"max-keys\");\n\tif (maxKeysParam !== null) {\n\t\t// `Number(\"\")` is 0, but R2 rejects an empty max-keys\n\t\tconst value =\n\t\t\tmaxKeysParam.trim() === \"\" ? Number.NaN : Number(maxKeysParam);\n\t\tif (!Number.isFinite(value) || value < 0) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\t\"InvalidMaxKeys\",\n\t\t\t\t\"MaxKeys params must be positive integer <= 1000.\"\n\t\t\t);\n\t\t}\n\n\t\tmaxKeys = Math.floor(value);\n\t}\n\tconst limit = Math.min(maxKeys, MAX_LIST_KEYS);\n\n\tconst prefix = params.get(\"prefix\") ?? \"\";\n\tconst delimiter = params.get(\"delimiter\") ?? undefined;\n\tconst marker = v2 ? undefined : (params.get(\"marker\") ?? undefined);\n\tconst startAfter = v2 ? (params.get(\"start-after\") ?? undefined) : marker;\n\tconst continuationToken = v2\n\t\t? (params.get(\"continuation-token\") ?? undefined)\n\t\t: undefined;\n\n\tlet objects: R2Object[] = [];\n\tlet delimitedPrefixes: string[] = [];\n\tlet truncated = false;\n\tlet cursor: string | undefined;\n\tlet result;\n\ttry {\n\t\tresult = await bucket.list({\n\t\t\tprefix,\n\t\t\tdelimiter,\n\t\t\t// For max-keys=0, list one key anyway: R2 reports IsTruncated based\n\t\t\t// on whether any matching keys exist\n\t\t\tlimit: Math.max(limit, 1),\n\t\t\tstartAfter,\n\t\t\tcursor: continuationToken,\n\t\t});\n\t} catch (e) {\n\t\treturn bindingError(e);\n\t}\n\n\tif (limit === 0) {\n\t\ttruncated =\n\t\t\tresult.objects.length > 0 || result.delimitedPrefixes.length > 0;\n\t} else {\n\t\tobjects = result.objects;\n\t\tdelimitedPrefixes = result.delimitedPrefixes;\n\t\ttruncated = result.truncated;\n\t\tcursor = result.truncated ? result.cursor : undefined;\n\t}\n\n\tconst contents = objects.map((object) => ({\n\t\tKey: encode(object.key),\n\t\tSize: object.size,\n\t\tLastModified: object.uploaded.toISOString(),\n\t\tETag: object.httpEtag,\n\t\t// The local simulator does not store storage classes\n\t\tStorageClass: \"STANDARD\",\n\t}));\n\tconst commonPrefixes = delimitedPrefixes.map((value) => ({\n\t\tPrefix: encode(value),\n\t}));\n\t// NextMarker is the lexicographically last returned item, which can be a\n\t// CommonPrefix (prefixes sort after the keys they group)\n\tconst lastObjectKey = objects[objects.length - 1]?.key;\n\tconst lastPrefix = delimitedPrefixes[delimitedPrefixes.length - 1];\n\tconst lastKey =\n\t\tlastPrefix !== undefined &&\n\t\t(lastObjectKey === undefined || lastPrefix > lastObjectKey)\n\t\t\t? lastPrefix\n\t\t\t: lastObjectKey;\n\n\treturn xmlResponse(\"ListBucketResult\", {\n\t\tName: bucketId,\n\t\t...(contents.length > 0 ? { Contents: contents } : {}),\n\t\tIsTruncated: truncated,\n\t\t...(commonPrefixes.length > 0 ? { CommonPrefixes: commonPrefixes } : {}),\n\t\tPrefix: encode(prefix),\n\t\t...(delimiter !== undefined ? { Delimiter: encode(delimiter) } : {}),\n\t\t...(v2\n\t\t\t? {\n\t\t\t\t\t...(startAfter !== undefined\n\t\t\t\t\t\t? { StartAfter: encode(startAfter) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(continuationToken !== undefined\n\t\t\t\t\t\t? { ContinuationToken: continuationToken }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(cursor !== undefined ? { NextContinuationToken: cursor } : {}),\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tMarker: encode(marker ?? \"\"),\n\t\t\t\t\t...(truncated && lastKey !== undefined\n\t\t\t\t\t\t? { NextMarker: encode(lastKey) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}),\n\t\tMaxKeys: maxKeys,\n\t\t...(v2 ? { KeyCount: contents.length + commonPrefixes.length } : {}),\n\t\t...(encodingType !== null ? { EncodingType: encodingType } : {}),\n\t});\n}\n\nfunction parsePartNumber(params: URLSearchParams): number | Response {\n\t// detectObjectOperation() only routes to part operations when partNumber is\n\t// present and integer-shaped (possibly empty, padded, or signed)\n\tconst raw = params.get(\"partNumber\");\n\tassert(raw !== null);\n\tconst partNumber = raw.trim() === \"\" ? Number.NaN : Number(raw);\n\tif (!Number.isInteger(partNumber) || partNumber < 1 || partNumber > 10000) {\n\t\treturn errorResponse(\n\t\t\t400,\n\t\t\t\"InvalidArgument\",\n\t\t\t\"Part number must be an integer between 1 and 10000, inclusive.\"\n\t\t);\n\t}\n\treturn partNumber;\n}\n\nexport const OBJECT_OPERATIONS: Record<\n\tObjectOperation,\n\tOperationDefinition<ObjectOperationContext> & ScreeningRules\n> = {\n\tGetObject: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\tssec: \"read\",\n\t\thandle: ({ c, bucket, key }) => serveObject(c, bucket, key),\n\t},\n\tHeadObject: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\tssec: \"read\",\n\t\thandle: ({ c, bucket, key }) => serveObject(c, bucket, key),\n\t},\n\tPutObject: {\n\t\tunsupportedHeaders: WRITE_UNSUPPORTED,\n\t\tvalidatesWriteHeaders: true,\n\t\tssec: \"write\",\n\t\tasync handle({ c, bucket, key }) {\n\t\t\tconst storageClass = parseStorageClass(c);\n\t\t\tif (storageClass instanceof Response) {\n\t\t\t\treturn storageClass;\n\t\t\t}\n\n\t\t\tconst body = await verifiedRequestBody(c);\n\t\t\tif (body instanceof Response) {\n\t\t\t\treturn body;\n\t\t\t}\n\n\t\t\tconst hasConditional = CONDITIONAL_HEADERS.some(\n\t\t\t\t(name) => c.req.header(name) !== undefined\n\t\t\t);\n\t\t\tconst object = await bucket.put(key, body, {\n\t\t\t\thttpMetadata: c.req.raw.headers,\n\t\t\t\tcustomMetadata: collectCustomMetadata(c),\n\t\t\t\tonlyIf: hasConditional ? c.req.raw.headers : undefined,\n\t\t\t\tstorageClass,\n\t\t\t});\n\t\t\tif (object === null) {\n\t\t\t\treturn preconditionFailed();\n\t\t\t}\n\t\t\treturn c.body(null, { headers: { ETag: object.httpEtag } });\n\t\t},\n\t},\n\tCopyObject: {\n\t\tunsupportedHeaders: [\n\t\t\t...WRITE_UNSUPPORTED,\n\t\t\t...SOURCE_BUCKET_OWNER,\n\t\t\t\"x-amz-tagging-directive\",\n\t\t\t\"x-amz-checksum-algorithm\",\n\t\t],\n\t\tvalidatesWriteHeaders: true,\n\t\tssec: \"write\",\n\t\tasync handle({ c, bucket, bucketId, key }) {\n\t\t\tconst directive = c.req.header(\"x-amz-metadata-directive\") ?? \"COPY\";\n\t\t\tif (directive !== \"COPY\" && directive !== \"REPLACE\") {\n\t\t\t\treturn errorResponse(\n\t\t\t\t\t400,\n\t\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\t`metadata directive ${directive}.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst storageClass = parseStorageClass(c);\n\t\t\tif (storageClass instanceof Response) {\n\t\t\t\treturn storageClass;\n\t\t\t}\n\t\t\tconst source = parseCopySource(c, bucketId);\n\t\t\tif (source instanceof Response) {\n\t\t\t\treturn source;\n\t\t\t}\n\n\t\t\tconst sourceObject = await source.bucket.get(source.key, {\n\t\t\t\tonlyIf: copySourceConditionals(c),\n\t\t\t});\n\t\t\tif (sourceObject === null) {\n\t\t\t\treturn noSuchKey();\n\t\t\t}\n\t\t\tif (!(\"body\" in sourceObject)) {\n\t\t\t\treturn preconditionFailed();\n\t\t\t}\n\n\t\t\tconst object = await bucket.put(key, sourceObject.body, {\n\t\t\t\thttpMetadata:\n\t\t\t\t\tdirective === \"COPY\" ? sourceObject.httpMetadata : c.req.raw.headers,\n\t\t\t\tcustomMetadata:\n\t\t\t\t\tdirective === \"COPY\"\n\t\t\t\t\t\t? sourceObject.customMetadata\n\t\t\t\t\t\t: collectCustomMetadata(c),\n\t\t\t\tstorageClass,\n\t\t\t});\n\t\t\tif (object === null) {\n\t\t\t\treturn preconditionFailed();\n\t\t\t}\n\t\t\treturn xmlResponse(\"CopyObjectResult\", {\n\t\t\t\tETag: object.httpEtag,\n\t\t\t\tLastModified: object.uploaded.toISOString(),\n\t\t\t});\n\t\t},\n\t},\n\tDeleteObject: {\n\t\tunsupportedHeaders: [...BUCKET_OWNER, ...MFA_AND_LOCK_BYPASS],\n\t\tasync handle({ c, bucket, key }) {\n\t\t\tawait bucket.delete(key);\n\t\t\treturn c.body(null, 204);\n\t\t},\n\t},\n\tCreateMultipartUpload: {\n\t\tunsupportedHeaders: WRITE_UNSUPPORTED,\n\t\tvalidatesWriteHeaders: true,\n\t\tssec: \"write\",\n\t\tasync handle({ c, bucket, bucketId, key }) {\n\t\t\tconst storageClass = parseStorageClass(c);\n\t\t\tif (storageClass instanceof Response) {\n\t\t\t\treturn storageClass;\n\t\t\t}\n\t\t\tconst upload = await bucket.createMultipartUpload(key, {\n\t\t\t\thttpMetadata: c.req.raw.headers,\n\t\t\t\tcustomMetadata: collectCustomMetadata(c),\n\t\t\t\tstorageClass,\n\t\t\t});\n\t\t\treturn xmlResponse(\"InitiateMultipartUploadResult\", {\n\t\t\t\tUploadId: upload.uploadId,\n\t\t\t\tBucket: bucketId,\n\t\t\t\tKey: key,\n\t\t\t});\n\t\t},\n\t},\n};\n\n/** Operations on an in-progress multipart upload (?uploadId) */\nexport const MULTIPART_OPERATIONS: Record<\n\tMultipartOperation,\n\tOperationDefinition<MultipartOperationContext> & ScreeningRules\n> = {\n\tUploadPart: {\n\t\tunsupportedHeaders: [...BUCKET_OWNER, \"x-amz-server-side-encryption\"],\n\t\tssec: \"write\",\n\t\tasync handle({ c, bucket, key, uploadId, params }) {\n\t\t\tconst partNumber = parsePartNumber(params);\n\t\t\tif (partNumber instanceof Response) {\n\t\t\t\treturn partNumber;\n\t\t\t}\n\n\t\t\tconst body = await verifiedRequestBody(c);\n\t\t\tif (body instanceof Response) {\n\t\t\t\treturn body;\n\t\t\t}\n\n\t\t\t// `resumeMultipartUpload` never validates: it just constructs the\n\t\t\t// upload object; an unknown id only fails once the upload is used\n\t\t\tconst upload = bucket.resumeMultipartUpload(key, uploadId);\n\t\t\ttry {\n\t\t\t\tconst part = await upload.uploadPart(partNumber, body);\n\t\t\t\treturn c.body(null, { headers: { ETag: `\"${part.etag}\"` } });\n\t\t\t} catch (e) {\n\t\t\t\treturn bindingError(e);\n\t\t\t}\n\t\t},\n\t},\n\tUploadPartCopy: {\n\t\tunsupportedHeaders: [\n\t\t\t...BUCKET_OWNER,\n\t\t\t...SOURCE_BUCKET_OWNER,\n\t\t\t...COPY_SOURCE_CONDITIONALS,\n\t\t],\n\t\tssec: \"write\",\n\t\tasync handle({ c, bucket, bucketId, key, uploadId, params }) {\n\t\t\tconst partNumber = parsePartNumber(params);\n\t\t\tif (partNumber instanceof Response) {\n\t\t\t\treturn partNumber;\n\t\t\t}\n\t\t\tconst source = parseCopySource(c, bucketId);\n\t\t\tif (source instanceof Response) {\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\tlet range: R2Range | undefined;\n\t\t\tconst rangeHeader = c.req.header(\"x-amz-copy-source-range\");\n\t\t\tif (rangeHeader !== undefined) {\n\t\t\t\tconst match = /^bytes=(\\d+)-(\\d+)$/.exec(rangeHeader);\n\t\t\t\tif (match === null) {\n\t\t\t\t\treturn errorResponse(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\t\t`Invalid x-amz-copy-source-range: ${rangeHeader}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst offset = Number(match[1]);\n\t\t\t\tconst end = Number(match[2]);\n\t\t\t\t// R2 clamps out-of-bounds ends (the simulator does too) but\n\t\t\t\t// rejects inverted ranges\n\t\t\t\tif (end < offset) {\n\t\t\t\t\treturn errorResponse(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\t\"InvalidArgument\",\n\t\t\t\t\t\t\"x-amz-copy-source-range must be positive.\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\trange = { offset, length: end - offset + 1 };\n\t\t\t}\n\n\t\t\tlet sourceObject;\n\t\t\ttry {\n\t\t\t\tsourceObject = await source.bucket.get(source.key, { range });\n\t\t\t} catch (e) {\n\t\t\t\treturn bindingError(e);\n\t\t\t}\n\t\t\tif (sourceObject === null) {\n\t\t\t\treturn noSuchKey();\n\t\t\t}\n\n\t\t\tconst upload = bucket.resumeMultipartUpload(key, uploadId);\n\t\t\ttry {\n\t\t\t\tconst part = await upload.uploadPart(partNumber, sourceObject.body);\n\t\t\t\treturn xmlResponse(\"CopyPartResult\", {\n\t\t\t\t\tETag: `\"${part.etag}\"`,\n\t\t\t\t\tLastModified: new Date().toISOString(),\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\treturn bindingError(e);\n\t\t\t}\n\t\t},\n\t},\n\tCompleteMultipartUpload: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\tasync handle({ c, bucket, bucketId, key, uploadId }) {\n\t\t\tconst text = await c.req.raw.text();\n\t\t\tif (XMLValidator.validate(text) !== true) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tconst parsed: unknown = xmlParser.parse(text);\n\t\t\tconst request = (\n\t\t\t\tparsed as { CompleteMultipartUpload?: { Part?: unknown } }\n\t\t\t).CompleteMultipartUpload;\n\t\t\tif (request === undefined) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tconst parts: R2UploadedPart[] = [];\n\t\t\tconst seenPartNumbers = new Set<number>();\n\t\t\tfor (const part of coerceArray(request.Part)) {\n\t\t\t\tconst { PartNumber, ETag } = part as {\n\t\t\t\t\tPartNumber?: unknown;\n\t\t\t\t\tETag?: unknown;\n\t\t\t\t};\n\n\t\t\t\tconst partNumber = Number(PartNumber);\n\t\t\t\tif (!Number.isInteger(partNumber) || typeof ETag !== \"string\") {\n\t\t\t\t\treturn malformedXml();\n\t\t\t\t}\n\n\t\t\t\t// Real R2 treats out-of-range part numbers in the XML as parts that\n\t\t\t\t// cannot exist, not as malformed arguments (unlike ?partNumber=)\n\t\t\t\tif (partNumber < 1 || partNumber > 10000) {\n\t\t\t\t\treturn errorResponse(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\t\"InvalidPart\",\n\t\t\t\t\t\t\"One or more of the specified parts could not be found.\"\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// The simulator reports duplicate part numbers with the same\n\t\t\t\t// internal error (10001) as an unknown upload id, so screen them\n\t\t\t\t// here with the error real R2 returns for duplicates\n\t\t\t\tif (seenPartNumbers.has(partNumber)) {\n\t\t\t\t\treturn errorResponse(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\t\"InvalidPart\",\n\t\t\t\t\t\t\"There was a problem with the multipart upload.\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tseenPartNumbers.add(partNumber);\n\n\t\t\t\tparts.push({ partNumber, etag: ETag.replace(/^\"|\"$/g, \"\") });\n\t\t\t}\n\n\t\t\tif (parts.length === 0) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tconst upload = bucket.resumeMultipartUpload(key, uploadId);\n\t\t\ttry {\n\t\t\t\tconst object = await upload.complete(parts);\n\t\t\t\tconst url = new URL(c.req.url);\n\t\t\t\treturn xmlResponse(\"CompleteMultipartUploadResult\", {\n\t\t\t\t\tBucket: bucketId,\n\t\t\t\t\tKey: key,\n\t\t\t\t\tETag: object.httpEtag,\n\t\t\t\t\tLocation: `${url.origin}${CorePaths.R2_S3}/${bucketId}/${awsUriEncode(key)}`,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tconst response = bindingError(e);\n\n\t\t\t\t// Like abort, the simulator reports an unknown upload id on\n\t\t\t\t// complete as an internal error (10001) rather than\n\t\t\t\t// NO_SUCH_UPLOAD. Duplicate part numbers, its only other 10001\n\t\t\t\t// source here, are screened during parsing above.\n\t\t\t\tif (response.status === 500) {\n\t\t\t\t\treturn s3Error(NO_SUCH_UPLOAD);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t}\n\t\t},\n\t},\n\tAbortMultipartUpload: {\n\t\tunsupportedHeaders: [],\n\t\tasync handle({ c, bucket, key, uploadId }) {\n\t\t\tconst upload = bucket.resumeMultipartUpload(key, uploadId);\n\t\t\ttry {\n\t\t\t\tawait upload.abort();\n\t\t\t} catch (e) {\n\t\t\t\tconst response = bindingError(e);\n\t\t\t\t// The simulator reports an unknown upload id on abort as an\n\t\t\t\t// internal error (10001) rather than NO_SUCH_UPLOAD; aborting is\n\t\t\t\t// its only failure mode, so map it onto the NoSuchUpload R2's S3\n\t\t\t\t// API returns\n\t\t\t\tif (response.status === 500) {\n\t\t\t\t\treturn s3Error(NO_SUCH_UPLOAD);\n\t\t\t\t}\n\t\t\t\treturn response;\n\t\t\t}\n\t\t\treturn c.body(null, 204);\n\t\t},\n\t},\n};\n\nexport const BUCKET_OPERATIONS: Record<\n\tBucketOperation,\n\tOperationDefinition<BucketOperationContext> & ScreeningRules\n> = {\n\tHeadBucket: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\t// The bucket exists, or routing would have 404ed already\n\t\thandle: ({ c }) => c.body(null, 200),\n\t},\n\tGetBucketLocation: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\t// Real R2 reports the bucket's location hint (e.g. ENAM); local\n\t\t// buckets have no location\n\t\thandle: () => xmlResponse(\"LocationConstraint\", { \"#text\": \"auto\" }),\n\t},\n\t// R2 always encrypts at rest with AES256; there is no per-bucket config\n\tGetBucketEncryption: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: () =>\n\t\t\txmlResponse(\"ServerSideEncryptionConfiguration\", {\n\t\t\t\tRule: {\n\t\t\t\t\tApplyServerSideEncryptionByDefault: { SSEAlgorithm: \"AES256\" },\n\t\t\t\t\tBucketKeyEnabled: true,\n\t\t\t\t},\n\t\t\t}),\n\t},\n\t// R2 has no bucket versioning, tagging, object lock, or replication;\n\t// these responses are identical for every bucket\n\tGetBucketVersioning: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: () => xmlResponse(\"VersioningConfiguration\", {}),\n\t},\n\tGetBucketTagging: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: () =>\n\t\t\terrorResponse(404, \"NoSuchTagSet\", \"The TagSet does not exist.\"),\n\t},\n\tGetObjectLockConfiguration: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: () =>\n\t\t\terrorResponse(\n\t\t\t\t404,\n\t\t\t\t\"ObjectLockConfigurationNotFoundError\",\n\t\t\t\t\"Object Lock configuration does not exist for this bucket.\"\n\t\t\t),\n\t},\n\tGetBucketReplication: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: () =>\n\t\t\terrorResponse(\n\t\t\t\t404,\n\t\t\t\t\"ReplicationConfigurationNotFoundError\",\n\t\t\t\t\"The replication configuration was not found.\"\n\t\t\t),\n\t},\n\tListObjects: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: ({ params, bucket, bucketId }) =>\n\t\t\tlistObjects(params, bucket, bucketId, false),\n\t},\n\tListObjectsV2: {\n\t\tunsupportedHeaders: BUCKET_OWNER,\n\t\thandle: ({ params, bucket, bucketId }) =>\n\t\t\tlistObjects(params, bucket, bucketId, true),\n\t},\n\tDeleteObjects: {\n\t\tunsupportedHeaders: [...BUCKET_OWNER, ...MFA_AND_LOCK_BYPASS],\n\t\tasync handle({ c, bucket }) {\n\t\t\tconst body = await c.req.raw.arrayBuffer();\n\t\t\tconst digestError = await verifyContentMD5(c, body);\n\t\t\tif (digestError !== undefined) {\n\t\t\t\treturn digestError;\n\t\t\t}\n\n\t\t\tconst text = new TextDecoder().decode(body);\n\t\t\tif (XMLValidator.validate(text) !== true) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tconst parsed: unknown = xmlParser.parse(text);\n\t\t\tconst request = (\n\t\t\t\tparsed as { Delete?: { Object?: unknown; Quiet?: unknown } }\n\t\t\t).Delete;\n\t\t\tif (request === undefined) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tconst keys: string[] = [];\n\t\t\tfor (const object of coerceArray(request.Object)) {\n\t\t\t\tconst key = (object as { Key?: unknown }).Key;\n\t\t\t\tif (typeof key !== \"string\") {\n\t\t\t\t\treturn malformedXml();\n\t\t\t\t}\n\n\t\t\t\tkeys.push(key);\n\t\t\t}\n\n\t\t\tif (keys.length === 0 || keys.length > MAX_DELETE_KEYS) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\t// R2 validates Quiet strictly but then ignores it.\n\t\t\t// The Deleted list is returned even in quiet mode.\n\t\t\tif (\n\t\t\t\trequest.Quiet !== undefined &&\n\t\t\t\trequest.Quiet !== \"true\" &&\n\t\t\t\trequest.Quiet !== \"false\"\n\t\t\t) {\n\t\t\t\treturn malformedXml();\n\t\t\t}\n\n\t\t\tawait bucket.delete(keys);\n\n\t\t\t// Deletes are idempotent: missing keys are still reported as Deleted\n\t\t\treturn xmlResponse(\"DeleteResult\", {\n\t\t\t\tDeleted: keys.map((key) => ({ Key: key })),\n\t\t\t});\n\t\t},\n\t},\n};\n", "// Accept only a single range with start <= end; reject anything else\n// (including multiple ranges) with an endpoint-specific 400 rather than\n// ignoring it\nconst RANGE_HEADER = /^bytes=(?:(\\d+)-(\\d+)?|-(\\d+))$/;\n\nexport type ParsedRangeHeader =\n\t| { error: \"malformed\" | \"inverted\" | \"unsatisfiable\" }\n\t// `start` is undefined for suffix ranges (`bytes=-N`)\n\t| { start?: number };\n\nexport function parseRangeHeader(header: string): ParsedRangeHeader {\n\tconst match = RANGE_HEADER.exec(header);\n\tif (match === null) {\n\t\treturn { error: \"malformed\" };\n\t}\n\tconst [, start, end, suffix] = match;\n\tif (start === undefined) {\n\t\t// A zero suffix length (`bytes=-0`) is unsatisfiable for any object;\n\t\t// the simulator would ignore the range and serve the full body\n\t\treturn Number(suffix) === 0 ? { error: \"unsatisfiable\" } : {};\n\t}\n\tif (end !== undefined && Number(start) > Number(end)) {\n\t\treturn { error: \"inverted\" };\n\t}\n\treturn { start: Number(start) };\n}\n\nfunction objectHeaders(object: R2Object): Headers {\n\tconst headers = new Headers();\n\tobject.writeHttpMetadata(headers);\n\tif (!headers.has(\"Content-Type\")) {\n\t\theaders.set(\"Content-Type\", \"application/octet-stream\");\n\t}\n\theaders.set(\"ETag\", object.httpEtag);\n\theaders.set(\"Last-Modified\", object.uploaded.toUTCString());\n\theaders.set(\"Accept-Ranges\", \"bytes\");\n\treturn headers;\n}\n\nexport interface ServeHandlers {\n\tnotFound(): Response | Promise<Response>;\n\tpreconditionFailed(): Response;\n\t/**\n\t * When provided, a range starting at or beyond the object size returns\n\t * this error (like R2's S3 API). When omitted, the simulator's behavior\n\t * of clamping the range applies.\n\t */\n\tinvalidRange?(): Response;\n\t/** Adds endpoint-specific headers to successful (2xx/304) responses */\n\tdecorateHeaders?(object: R2Object, headers: Headers): void;\n}\n\nexport async function serveR2Object(\n\trequest: Request,\n\tbucket: R2Bucket,\n\tkey: string,\n\thandlers: ServeHandlers,\n\t/** The caller's parse of the request's Range header, error-screened */\n\tparsedRange?: ParsedRangeHeader\n): Promise<Response> {\n\t// R2 honors Range on HEAD too (206 + Content-Range, no body)\n\tconst rangeHeader = request.headers.get(\"Range\");\n\tconst hasRange = rangeHeader !== null;\n\n\t// `bucket.head()` cannot evaluate conditional headers (the R2 head\n\t// operation only carries the key), so HEAD also uses `bucket.get()` and\n\t// discards the body.\n\tconst object = await bucket.get(key, {\n\t\tonlyIf: request.headers,\n\t\trange: hasRange ? request.headers : undefined,\n\t});\n\n\tif (object === null) {\n\t\treturn handlers.notFound();\n\t}\n\n\tconst headers = objectHeaders(object);\n\thandlers.decorateHeaders?.(object, headers);\n\n\tif (!(\"body\" in object)) {\n\t\t// Some conditional header failed, but `bucket.get()` reports the\n\t\t// failure without naming the header. We need to determine which header\n\t\t// failed to determine the status code to return.\n\t\t//\n\t\t// https://datatracker.ietf.org/doc/html/rfc7232#section-6 gives the\n\t\t// order for checking headers. We know at least one header failed.\n\t\t// We must first check for a precondition header failure.\n\t\t//\n\t\t// The logic in `_testR2Conditional` ensures we can simultaneously\n\t\t// check both \"If-Match\" and \"If-Unmodified-Since\" (since a failure in\n\t\t// \"If-Unmodified-Since\" can be suppressed by success for a present\n\t\t// \"If-Match\"). These both yield status 412s upon failure.\n\t\tlet preconditions: Headers | undefined;\n\t\tfor (const name of [\"If-Match\", \"If-Unmodified-Since\"]) {\n\t\t\tconst value = request.headers.get(name);\n\t\t\tif (value !== null) {\n\t\t\t\tpreconditions ??= new Headers();\n\t\t\t\tpreconditions.set(name, value);\n\t\t\t}\n\t\t}\n\t\tif (preconditions !== undefined) {\n\t\t\tconst recheck = await bucket.get(key, { onlyIf: preconditions });\n\t\t\tif (recheck === null) {\n\t\t\t\treturn handlers.notFound();\n\t\t\t}\n\t\t\tif (!(\"body\" in recheck)) {\n\t\t\t\treturn handlers.preconditionFailed();\n\t\t\t}\n\t\t\t// An unread recheck body would hold a read stream open\n\t\t\tvoid recheck.body.cancel();\n\t\t}\n\n\t\t// Otherwise, the preconditions hold, so the failure came from a cache\n\t\t// validator.\n\t\treturn new Response(null, { status: 304, headers });\n\t}\n\n\tconst body = request.method === \"HEAD\" ? null : object.body;\n\tif (body === null) {\n\t\t// An unread body would hold a read stream open\n\t\tvoid object.body.cancel();\n\t}\n\n\tconst range = object.range;\n\tif (hasRange && range !== undefined) {\n\t\t// The simulator clamps out-of-bounds ranges and serves a zero-length\n\t\t// range for empty objects; R2 rejects both with 416 (any range on a\n\t\t// 0-byte object, or a range starting at or beyond the object size)\n\t\tif (handlers.invalidRange !== undefined) {\n\t\t\tconst parsed = parsedRange ?? parseRangeHeader(rangeHeader);\n\t\t\tif (\n\t\t\t\t!(\"error\" in parsed) &&\n\t\t\t\t(object.size === 0 ||\n\t\t\t\t\t(parsed.start !== undefined && parsed.start >= object.size))\n\t\t\t) {\n\t\t\t\tif (body !== null) {\n\t\t\t\t\tvoid body.cancel();\n\t\t\t\t}\n\t\t\t\treturn handlers.invalidRange();\n\t\t\t}\n\t\t}\n\t\t// The returned range may carry all keys with some `undefined` (e.g.\n\t\t// `suffix` present but undefined on an offset range), so normalize by\n\t\t// value rather than by key presence\n\t\tconst normalized: { offset?: number; length?: number; suffix?: number } = {\n\t\t\t...range,\n\t\t};\n\t\tlet offset: number;\n\t\tlet length: number;\n\t\tif (normalized.suffix !== undefined) {\n\t\t\tlength = Math.min(normalized.suffix, object.size);\n\t\t\toffset = object.size - length;\n\t\t} else {\n\t\t\toffset = normalized.offset ?? 0;\n\t\t\tlength = normalized.length ?? object.size - offset;\n\t\t}\n\t\theaders.set(\n\t\t\t\"Content-Range\",\n\t\t\t`bytes ${offset}-${offset + length - 1}/${object.size}`\n\t\t);\n\t\theaders.set(\"Content-Length\", `${length}`);\n\t\treturn new Response(body, { status: 206, headers });\n\t}\n\n\theaders.set(\"Content-Length\", `${object.size}`);\n\treturn new Response(body, { headers });\n}\n", "// S3-compatible API for local R2 buckets. Status codes, headers, XML bodies,\n// and header-screening behavior mimic R2's S3 endpoint, captured from a real\n// bucket (2026-06-11).\n//\n// ## Gaps: surfaces real R2 implements, with no local equivalent\n//\n// These exist in real R2 but cannot be served faithfully here because the R2\n// binding backing this endpoint (and Miniflare's R2 simulator behind it)\n// exposes no equivalent. Operations among them respond exactly like the\n// operations R2's S3 endpoint itself does not implement: R2's templated\n// \"<name> not implemented\" error (plus list/bucket-route \"search parameter\"\n// errors and RouteNotFound for unknown methods).\n//\n// - SSE-C: the simulator ignores encryption keys entirely, so writes with\n//   SSE-C headers are rejected with NotImplemented rather than silently\n//   storing plaintext. Reads with SSE-C headers return the same error real\n//   R2 gives for unencrypted objects.\n// - x-amz-storage-class: the simulator can't persist storage classes, so\n//   non-default classes (STANDARD_IA) are rejected with NotImplemented\n//   rather than silently stored as STANDARD.\n// - Flexible checksums: real R2 validates, stores, and echoes\n//   x-amz-checksum-* request headers (returning BadDigest on mismatch); the\n//   local binding has no checksum surface beyond MD5, so they are silently\n//   ignored like other unrecognized x-amz-* headers (Content-MD5 IS\n//   verified). The aws-chunked content encoding SDKs use to stream trailing\n//   checksums is not decoded either; clients must send plain bodies.\n// - ListParts, ListMultipartUploads, the partNumber query parameter, the\n//   bucket-configuration reads ?acl, ?cors, and ?lifecycle, and the\n//   bucket-configuration writes/deletes for ?cors, ?encryption, ?lifecycle,\n//   and ?versioning answer the templated not-implemented error described\n//   above.\n// - Owner in listings is omitted; there's no account id to report locally.\n// - ListBuckets omits CreationDate; local buckets have no creation time.\n// - GetBucketLocation reports \"auto\"; real R2 reports the bucket's location\n//   hint (e.g. ENAM).\n//\n// ## By design: surfaces where the local architecture differs\n//\n// Local buckets and credentials are declared in Wrangler/Miniflare config,\n// not provisioned under a Cloudflare account, so some of real R2's account\n// semantics deliberately do not apply:\n//\n// - CreateBucket and DeleteBucket answer the templated not-implemented\n//   error: a bucket exists locally by being configured as a binding, and a\n//   bucket created over HTTP would not be reachable from any Worker.\n// - Credentials are per-bucket, not account-scoped. Requests for unknown\n//   buckets return NoSuchBucket without checking the signature (real R2\n//   verifies auth first), and ListBuckets lists the buckets sharing the\n//   presented credential pair rather than every bucket on an account.\n// - CORS: cross-origin use is always allowed, as if the bucket had a\n//   permissive CORS policy configured. Real R2 answers preflights according\n//   to the bucket's per-bucket CORS configuration, which has no R2 binding\n//   equivalent. Without preflight approval for `Authorization` and\n//   `x-amz-*` headers, no browser request could ever reach this endpoint\n//   (e.g. presigned uploads from a frontend dev server).\n//\n// ## Client quirks\n//\n// - workerd never responds with `100 Continue`, so clients sending\n//   `Expect: 100-continue` (the AWS SDKs do by default for requests with\n//   bodies) hang waiting for it. With @aws-sdk/client-s3, remove the\n//   `addExpectContinueMiddleware` from the client's middleware stack.\n\nimport { cors } from \"hono/cors\";\nimport { Hono } from \"hono/tiny\";\nimport { CorePaths } from \"../../core/constants\";\nimport { listBuckets } from \"./account.worker\";\nimport { dispatch } from \"./dispatch.worker\";\nimport type { Env } from \"./common.worker\";\n\nconst app = new Hono<{ Bindings: Env }>().basePath(CorePaths.R2_S3);\n\napp.use(\n\tcors({\n\t\torigin: \"*\",\n\t\tallowMethods: [\"GET\", \"HEAD\", \"PUT\", \"POST\", \"DELETE\"],\n\t\texposeHeaders: [\"*\"],\n\t})\n);\n\napp.all(\"/:bucketId/:key{.+}\", (c) => dispatch(c, c.req.param(\"key\")));\napp.all(\"/:bucketId\", (c) => dispatch(c, undefined));\napp.all(\"/\", (c) => listBuckets(c));\n\nexport default app;\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,QAAM,gBAAgB,iLAChB,WAAW,gBAAgB,gDAC3B,aAAa,MAAM,gBAAgB,OAAO,WAAW,MACrD,YAAY,IAAI,OAAO,MAAM,aAAa,GAAG,GAE7C,gBAAgB,SAAS,QAAQ,OAAO;AAC5C,UAAM,UAAU,CAAC,GACb,QAAQ,MAAM,KAAK,MAAM;AAC7B,aAAO,SAAO;AACZ,YAAM,aAAa,CAAC;AACpB,mBAAW,aAAa,MAAM,YAAY,MAAM,CAAC,EAAE;AACnD,YAAM,MAAM,MAAM;AAClB,iBAAS,QAAQ,GAAG,QAAQ,KAAK;AAC/B,qBAAW,KAAK,MAAM,KAAK,CAAC;AAE9B,gBAAQ,KAAK,UAAU,GACvB,QAAQ,MAAM,KAAK,MAAM;AAAA,MAC3B;AACA,aAAO;AAAA,IACT,GAEM,SAAS,SAAS,QAAQ;AAC9B,UAAM,QAAQ,UAAU,KAAK,MAAM;AACnC,aAAO,EAAE,UAAU,QAAQ,OAAO,QAAU;AAAA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C,GAAG;AAAA,EACpB,CAAC;AACF;AAEA,IAAI,IAAI,uBAAuB,CAAC,MAAM,SAAS,GAAG,EAAE,IAAI,MAAM,KAAK,CAAC,CAAC;AACrE,IAAI,IAAI,cAAc,CAAC,MAAM,SAAS,GAAG,MAAS,CAAC;AACnD,IAAI,IAAI,KAAK,CAAC,MAAM,YAAY,CAAC,CAAC;AAElC,IAAO,uBAAQ;",
  "names": ["val", "val", "entityName", "val", "val", "result", "entityName", "val", "XMLParser", "attStr", "val", "XMLParser", "XMLBuilder", "dispatch", "raw", "app", "Hono", "assert", "Buffer", "assert", "assert", "import_fast_xml_parser", "assert", "assert", "raw", "assert", "detected", "Hono"]
}
