{"version":3,"sources":["jsdelivr-header.js","/npm/uploader-for-google-drive-resumable-upload-url@2.0.3/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACHA,MAAM,aAAe,QAAQ,iBAE7B,SAAS,eAAe,GACtB,GAAI,GAAU,EAAO,aAAe,EAAO,QAErC,EAAO,SAAW,EAAO,YAC3B,MAAM,IAAI,MAAM,8CAA8C,KAAK,UAAU,GAGnF,CAEA,eAAe,0CAAyC,aACtD,EAAY,SACZ,EAAQ,IACR,EAAG,MACH,EAAK,UACL,EAAY,gCAEZ,GAAoB,iBAAV,EAAoB,MAAM,IAAI,MAAM,0BAC9C,IAAM,EAAI,WAAW,GAAa,MAAM,IAAI,MAAM,sBAAwB,GAC1E,IAAI,EACJ,MAAM,EAAW,aAAa,MAAO,OAAO,SAAU,GACpD,EAAM,CACR,IACM,GAAa,IAAe,EAAS,WAAW,QACtD,EAAa,GAAG,SAAS,SAAU,GAAK,MAAM,IAAI,MAAM,2BAA6B,EAAI,IACzF,MAAM,EAAa,EAAa,EAAa,KAAK,GAAY,EAI9D,GAAI,EAAM,CACR,MAAM,EAAU,CACd,QALY,CACZ,eAAgB,GAKhB,iBAAkB,cAClB,cAAe,eAEX,QAAiB,EAAM,KAAK,EAAI,EAAW,GACjD,GAAI,EAAS,QAAQ,IACnB,MAAM,IAAI,MAAM,sBAAsB,EAAS,UAAU,EAAS,cAEpE,MAAM,EAAS,EAAS,KAGxB,OAFA,EAAO,OAAS,EACZ,GAAU,eAAe,GACtB,CACT,CACA,MAAM,IAAI,MAAM,kGAClB,CAEA,OAAO,QAAU","file":"/npm/uploader-for-google-drive-resumable-upload-url@2.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/uploader-for-google-drive-resumable-upload-url@2.0.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Copyright 2017- Paul Brewer, Economic and Financial Technology Consulting LLC\n// License: MIT\n\nconst digestStream = require('digest-stream');\n\nfunction assertMD5Match(result){\n  if (result && result.md5Checksum && result.ourMD5) {\n    // check md5 only on binary data, and only if reported back by Google Drive API\n    if (result.ourMD5 !== result.md5Checksum) {\n      throw new Error('bad md5 checksum on upload to Google Drive:'+JSON.stringify(result));\n    }\n  }\n}\n\nasync function uploaderForGoogleDriveResumableUploadUrl({\n  sourceStream,\n  mimeType,\n  url,\n  axios,\n  urlPrefix = \"https://www.googleapis.com/\"\n}) {\n  if (typeof(url) !== \"string\") throw new Error(\"url should be a string\");\n  if (!(url.startsWith(urlPrefix))) throw new Error(\"incorrect url, got:\" + url);\n  let md5;\n  const md5buddy = digestStream('md5', 'hex', function (_md5) {\n    md5 = _md5;\n  });\n  const isBinary = (!mimeType) || (!mimeType.startsWith('text'));\n  sourceStream.on('error', function (e) { throw new Error(\"upload error on source: \" + e); });\n  const dataStream = (isBinary) ? sourceStream.pipe(md5buddy) : sourceStream;\n  const headers = {\n      'Content-Type': mimeType\n  };\n  if (axios){\n    const options = {\n      headers,\n      maxContentLength: 1024*1024*1024*1024, // 1 TB\n      maxBodyLength: 1024*1024*1024*1024\n    };\n    const response = await axios.post(url,dataStream,options);\n    if (response.status>=400){\n      throw new Error(`upload error code: ${response.status} ${response.statusText}`);\n    }\n    const result = response.data;\n    result.ourMD5 = md5; // set ours here too so the assert will find it\n    if (isBinary) assertMD5Match(result);\n    return result;\n  }\n  throw new Error(\"no https request module provided, must provide one of -- axios -- when initializing this module\");\n}\n\nmodule.exports = uploaderForGoogleDriveResumableUploadUrl;\n"]}