generated from ShadowVR/AI_botter
2 lines
106 KiB
JavaScript
2 lines
106 KiB
JavaScript
|
/*! For license information please see digest-fetch.js.LICENSE.txt */
|
||
|
(()=>{var t={7934:(t,r,n)=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function i(t,r,n,e,i,o,u){try{var a=t[o](u),c=a.value}catch(t){return void n(t)}a.done?r(c):Promise.resolve(c).then(e,i)}function o(t){return function(){var r=this,n=arguments;return new Promise((function(e,o){var u=t.apply(r,n);function a(t){i(u,e,o,a,c,"next",t)}function c(t){i(u,e,o,a,c,"throw",t)}a(void 0)}))}}function u(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function a(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}if("function"!=typeof c)var c=n(759);var s=n(1586),f=n(5574),l=["MD5","MD5-sess"],h=function(t,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],e=new RegExp("".concat(r,'=("[^"]*"|[^,]*)'),"i"),i=e.exec(t);return i?n?i[1].replace(/[\s"]/g,""):i[1]:null},v=function(){function t(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),this.user=r,this.password=n,this.nonceRaw="abcdef0123456789",this.logger=e.logger,this.precomputedHash=e.precomputedHash;var i=e.algorithm||"MD5";l.includes(i)||(this.logger&&this.logger.warn("Unsupported algorithm ".concat(i,", will try with MD5")),i="MD5"),this.digest={nc:0,algorithm:i,realm:""},this.hasAuth=!1;var o=parseInt(e.cnonceSize);this.cnonceSize=isNaN(o)?32:o,this.statusCode=e.statusCode,this.basic=e.basic||!1}var r,n,i,v,p;return r=t,n=[{key:"fetch",value:(p=o(regeneratorRuntime.mark((function t(r){var n,e,i,o=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>1&&void 0!==o[1]?o[1]:{},!this.basic){t.next=3;break}return t.abrupt("return",c(r,this.addBasicAuth(n)));case 3:return t.next=5,c(r,this.addAuth(r,n));case 5:if(!(401==(e=t.sent).status||e.status==this.statusCode&&this.statusCode)){t.next=18;break}return this.hasAuth=!1,t.next=10,this.parseAuth(e.headers.get("www-authenticate"));case 10:if(!this.hasAuth){t.next=16;break}return t.next=13,c(r,this.addAuth(r,n));case 13:return 401==(i=t.sent).status||i.status==this.statusCode?this.hasAuth=!1:this.digest.nc++,t.abrupt("return",i);case 16:t.next=19;break;case 18:this.digest.nc++;case 19:return t.abrupt("return",e);case 20:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"addBasicAuth",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};r="function"==typeof t.factory?t.factory():t;var n="Basic "+f.encode(this.user+":"+this.password);return r.headers=r.headers||{},r.headers.Authorization=n,"function"==typeof r.headers.set&&r.headers.set("Authorization",n),this.logger&&this.logger.debug(t),r}},{key:"addAuth",value:function(r,n){if("function"==typeof n.factory&&(n=n.factory()),!this.hasAuth)return n;this.logger&&this.logger.info("requesting with auth carried");var i=("object"===e(r)&&"string"==typeof r.url?r.url:r).replace("//",""),o=-1==i.indexOf("/")?"/":i.slice(i.indexOf("/")),u=n.method?n.method.toUpperCase():"GET",a=this.precomputedHash?this.password:t.computeHash(this.user,this.digest.realm,this.password);"MD5-sess"===this.digest.algorithm&&(a=s("".concat(a,":").concat(this.digest.nonce,":").concat(this.digest.cnonce))),"auth-int"===this.digest.qop&&this.logger&&this.logger.warn("Sorry, auth-int is not implemented in this plugin");var c=s("".concat(u,":").concat(o).concat("")),f=("00000000"+this.digest.nc).slice(-8),l="".concat(a,":").concat(this.digest.nonce,":").concat(f,":").concat(this.digest.cnonce,":").concat(this.digest.qop,":").concat(c);this.digest.qop||(l="".concat(a,":").concat(this.digest.nonce,":").concat(c));var h=s(l),v=null!==this.digest.opaque?'opaque="'.concat(this.digest.opaque,'",'):"",p=this.digest.qop?'qop="'.concat(this.digest.qop,'",'):"",g="".concat(this.digest.scheme,' username="').concat(this.user,'",realm="').con
|