{"version":3,"sources":["jsdelivr-header.js","/npm/synquery-redirect-service@1.0.8/start.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACFA,MAEE,MAAM,EAAO,QAAQ,WAAR,CAAoB,QAAQ,KAAK,MAAM,IAI9C,EAAU,CACd,SAAU,OACV,KAAM,KAEN,WAAY,IACZ,gBAAiB,CAAE,GAEf,EAAS,CACb,SAAU,EAAQ,SAClB,KAAM,EAAQ,KACd,WAAY,EAAQ,WACpB,gBAAiB,EAAQ,iBAE3B,IACE,MAAM,EAAa,EAAK,EAAE,GACvB,GAAc,OAAO,OAAO,EAAQ,QAAS,GAClD,CAAE,MAAM,GAGN,QAAQ,IAAI,4BAA6B,EAC3C,CACA,MAAM,EAAO,EAAO,SAAS,cAAc,QAAQ,KAAM,IACzD,QAAQ,GAAM,aAAa,EAAO,eAAiB,CAAE,GAAG,CAAC,EAAK,KAC5D,IACE,MAA8F,GAAtE,EAAI,QAAgB,QAAK,CAAE,EAAO,MAAO,EAAI,QAAQ,MAAO,KAAK,KAAsC,QAAQ,EAAO,IAAK,QAAkB,QAAR,EAAiB,IAAK,IAAM,KACzL,EAAI,UAAU,EAAO,WAAY,OAAO,OAAO,EAAO,gBAAiB,CACrE,SAAY,CAAE,EAAgB,EAAI,KAAM,KAAK,OAE/C,EAAI,KACN,CAAE,MAAM,GACN,EAAI,IAAI,EAAI,EAAE,SAAW,EAAG,yBAC9B,KACC,OAAO,EAAO,MACjB,QAAQ,IAAI,iEAAiE,EAAO,OAErF,EAzCD","file":"/npm/synquery-redirect-service@1.0.8/start.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/synquery-redirect-service@1.0.8/start.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * [synquery.redirect] start.js\n * シンプルなリダイレクトサービスを提供する。\n */\n(g=>{ // g === module.expots\n\n  const argv = require('minimist')(process.argv.slice(2));\n  // console.log('[synquery.redirect]', argv);\n  // Configuration must be specified by a static json file\n  // TODO this gateway will a temporary buffer for maintenance situation\n  const Default = {\n    Protocol: 'http',\n    Port: 8080, // Assume that WELL-KNOWN PORT is supported by port-forwarding not to root execute for the redirect process\n    // e.g.) ssh -L 0.0.0.0:80:127.0.0.1:8080 -i ${HOME}/.ssh/pf_rsa 0.0.0.0 -N or docker ports: 80:8080\n    StatusCode: 307, // 301 Moved Permanently 307 Temporary Redirect 308 Permanent Redirect\n    ResponseHeaders: { }\n  };\n  const config = {\n    protocol: Default.Protocol,\n    port: Default.Port,\n    statusCode: Default.StatusCode,\n    responseHeaders: Default.ResponseHeaders\n  };\n  try {\n    const configPath = argv._[0];\n    if(configPath) { Object.assign(config, require( configPath )); }\n  } catch(e) {\n    /*BASICALLY IGNORE*/\n    // Notificate only when File Not Found or Could Not Parse\n    console.log('[synquery.redirect][Warn]', e);\n  }\n  const ptcl = config.protocol.toLowerCase().replace(/\\W/, '');\n  require(ptcl).createServer(config.serverOptions || { }, (req, res) => {\n    try {\n      const requestedOrigin = req.headers['origin'] || [ ptcl + '://', req.headers.host ].join(''), redirectOrigin = requestedOrigin.replace(ptcl + ':', 'http' + (ptcl == 'http' ? 's': '') + ':');\n      res.writeHead(config.statusCode, Object.assign(config.responseHeaders, {  // Moved Permanently\n        'Location': [ redirectOrigin, req.url ].join('')\n      }));\n      res.end();\n    } catch(e) {\n      res.end(e ? e.message || e: 'redirect service error');\n    }\n  }).listen(config.port);\n  console.log(`[synquery.redirect][Info] redirect service is working at port:${config.port}`);\n\n})(this);\n"]}