verdaccio-doreamon-oauth2
Version:
A GitLab OAuth Plugin for [Verdaccio](https://www.verdaccio.org)
2 lines (1 loc) • 16.9 kB
JavaScript
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=function(t){return t&&t.Math==Math&&t},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),o=function(t){try{return!!t()}catch(t){return!0}},i=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),u={}.propertyIsEnumerable,c=Object.getOwnPropertyDescriptor,a={f:c&&!u.call({1:2},1)?function(t){var e=c(this,t);return!!e&&e.enumerable}:u},l=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},f={}.toString,s=function(t){return f.call(t).slice(8,-1)},p="".split,d=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==s(t)?p.call(t,""):Object(t)}:Object,g=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},h=function(t){return d(g(t))},v=function(t){return"object"==typeof t?null!==t:"function"==typeof t},y=function(t,e){if(!v(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!v(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},m={}.hasOwnProperty,x=function(t,e){return m.call(t,e)},b=r.document,S=v(b)&&v(b.createElement),E=!i&&!o((function(){return 7!=Object.defineProperty((t="div",S?b.createElement(t):{}),"a",{get:function(){return 7}}).a;var t})),w=Object.getOwnPropertyDescriptor,I={f:i?w:function(t,e){if(t=h(t),e=y(e,!0),E)try{return w(t,e)}catch(t){}if(x(t,e))return l(!a.f.call(t,e),t[e])}},O=function(t){if(!v(t))throw TypeError(String(t)+" is not an object");return t},T=Object.defineProperty,j={f:i?T:function(t,e,n){if(O(t),e=y(e,!0),O(n),E)try{return T(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},R=i?function(t,e,n){return j.f(t,e,l(1,n))}:function(t,e,n){return t[e]=n,t},A=function(t,e){try{R(r,t,e)}catch(n){r[t]=e}return e},P=r["__core-js_shared__"]||A("__core-js_shared__",{}),_=Function.toString;"function"!=typeof P.inspectSource&&(P.inspectSource=function(t){return _.call(t)});var C,k,M,N,U=P.inspectSource,D=r.WeakMap,L="function"==typeof D&&/native code/.test(U(D)),B=e((function(t){(t.exports=function(t,e){return P[t]||(P[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),F=0,$=Math.random(),z=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++F+$).toString(36)},K=B("keys"),q={},G=r.WeakMap;if(L){var W=new G,Y=W.get,V=W.has,X=W.set;C=function(t,e){return X.call(W,t,e),e},k=function(t){return Y.call(W,t)||{}},M=function(t){return V.call(W,t)}}else{var H=K[N="state"]||(K[N]=z(N));q[H]=!0,C=function(t,e){return R(t,H,e),e},k=function(t){return x(t,H)?t[H]:{}},M=function(t){return x(t,H)}}var J,Q,Z={set:C,get:k,has:M,enforce:function(t){return M(t)?k(t):C(t,{})},getterFor:function(t){return function(e){var n;if(!v(e)||(n=k(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},tt=e((function(t){var e=Z.get,n=Z.enforce,o=String(String).split("String");(t.exports=function(t,e,i,u){var c=!!u&&!!u.unsafe,a=!!u&&!!u.enumerable,l=!!u&&!!u.noTargetGet;"function"==typeof i&&("string"!=typeof e||x(i,"name")||R(i,"name",e),n(i).source=o.join("string"==typeof e?e:"")),t!==r?(c?!l&&t[e]&&(a=!0):delete t[e],a?t[e]=i:R(t,e,i)):a?t[e]=i:A(e,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&e(this).source||U(this)}))})),et=r,nt=function(t){return"function"==typeof t?t:void 0},rt=function(t,e){return arguments.length<2?nt(et[t])||nt(r[t]):et[t]&&et[t][e]||r[t]&&r[t][e]},ot=Math.ceil,it=Math.floor,ut=function(t){return isNaN(t=+t)?0:(t>0?it:ot)(t)},ct=Math.min,at=function(t){return t>0?ct(ut(t),9007199254740991):0},lt=Math.max,ft=Math.min,st=function(t){return function(e,n,r){var o,i=h(e),u=at(i.length),c=function(t,e){var n=ut(t);return n<0?lt(n+e,0):ft(n,e)}(r,u);if(t&&n!=n){for(;u>c;)if((o=i[c++])!=o)return!0}else for(;u>c;c++)if((t||c in i)&&i[c]===n)return t||c||0;return!t&&-1}},pt={includes:st(!0),indexOf:st(!1)},dt=pt.indexOf,gt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype"),ht={f:Object.getOwnPropertyNames||function(t){return function(t,e){var n,r=h(t),o=0,i=[];for(n in r)!x(q,n)&&x(r,n)&&i.push(n);for(;e.length>o;)x(r,n=e[o++])&&(~dt(i,n)||i.push(n));return i}(t,gt)}},vt={f:Object.getOwnPropertySymbols},yt=rt("Reflect","ownKeys")||function(t){var e=ht.f(O(t)),n=vt.f;return n?e.concat(n(t)):e},mt=function(t,e){for(var n=yt(e),r=j.f,o=I.f,i=0;i<n.length;i++){var u=n[i];x(t,u)||r(t,u,o(e,u))}},xt=/#|\.prototype\./,bt=function(t,e){var n=Et[St(t)];return n==It||n!=wt&&("function"==typeof e?o(e):!!e)},St=bt.normalize=function(t){return String(t).replace(xt,".").toLowerCase()},Et=bt.data={},wt=bt.NATIVE="N",It=bt.POLYFILL="P",Ot=bt,Tt=I.f,jt=function(t,e){var n,o,i,u,c,a=t.target,l=t.global,f=t.stat;if(n=l?r:f?r[a]||A(a,{}):(r[a]||{}).prototype)for(o in e){if(u=e[o],i=t.noTargetGet?(c=Tt(n,o))&&c.value:n[o],!Ot(l?o:a+(f?".":"#")+o,t.forced)&&void 0!==i){if(typeof u==typeof i)continue;mt(u,i)}(t.sham||i&&i.sham)&&R(u,"sham",!0),tt(n,o,u,t)}},Rt=Array.isArray||function(t){return"Array"==s(t)},At=function(t){return Object(g(t))},Pt=function(t,e,n){var r=y(e);r in t?j.f(t,r,l(0,n)):t[r]=n},_t=!!Object.getOwnPropertySymbols&&!o((function(){return!String(Symbol())})),Ct=_t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,kt=B("wks"),Mt=r.Symbol,Nt=Ct?Mt:Mt&&Mt.withoutSetter||z,Ut=function(t){return x(kt,t)||(_t&&x(Mt,t)?kt[t]=Mt[t]:kt[t]=Nt("Symbol."+t)),kt[t]},Dt=Ut("species"),Lt=function(t,e){var n;return Rt(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Rt(n.prototype)?v(n)&&null===(n=n[Dt])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},Bt=rt("navigator","userAgent")||"",Ft=r.process,$t=Ft&&Ft.versions,zt=$t&&$t.v8;zt?Q=(J=zt.split("."))[0]+J[1]:Bt&&(!(J=Bt.match(/Edge\/(\d+)/))||J[1]>=74)&&(J=Bt.match(/Chrome\/(\d+)/))&&(Q=J[1]);var Kt=Q&&+Q,qt=Ut("species"),Gt=function(t){return Kt>=51||!o((function(){var e=[];return(e.constructor={})[qt]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},Wt=Ut("isConcatSpreadable"),Yt=Kt>=51||!o((function(){var t=[];return t[Wt]=!1,t.concat()[0]!==t})),Vt=Gt("concat"),Xt=function(t){if(!v(t))return!1;var e=t[Wt];return void 0!==e?!!e:Rt(t)};jt({target:"Array",proto:!0,forced:!Yt||!Vt},{concat:function(t){var e,n,r,o,i,u=At(this),c=Lt(u,0),a=0;for(e=-1,r=arguments.length;e<r;e++)if(Xt(i=-1===e?u:arguments[e])){if(a+(o=at(i.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<o;n++,a++)n in i&&Pt(c,a,i[n])}else{if(a>=9007199254740991)throw TypeError("Maximum allowed index exceeded");Pt(c,a++,i)}return c.length=a,c}});var Ht=function(t,e){var n=[][t];return!!n&&o((function(){n.call(null,e||function(){throw 1},1)}))},Jt=Object.defineProperty,Qt={},Zt=function(t){throw t},te=function(t,e){if(x(Qt,t))return Qt[t];e||(e={});var n=[][t],r=!!x(e,"ACCESSORS")&&e.ACCESSORS,u=x(e,0)?e[0]:Zt,c=x(e,1)?e[1]:void 0;return Qt[t]=!!n&&!o((function(){if(r&&!i)return!0;var t={length:-1};r?Jt(t,1,{enumerable:!0,get:Zt}):t[1]=1,n.call(t,u,c)}))},ee=pt.indexOf,ne=[].indexOf,re=!!ne&&1/[1].indexOf(1,-0)<0,oe=Ht("indexOf"),ie=te("indexOf",{ACCESSORS:!0,1:0});jt({target:"Array",proto:!0,forced:re||!oe||!ie},{indexOf:function(t){return re?ne.apply(this,arguments)||0:ee(this,t,arguments.length>1?arguments[1]:void 0)}});var ue=[].join,ce=d!=Object,ae=Ht("join",",");jt({target:"Array",proto:!0,forced:ce||!ae},{join:function(t){return ue.call(h(this),void 0===t?",":t)}});var le=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},fe=[].push,se=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,u=5==t||i;return function(c,a,l,f){for(var s,p,g=At(c),h=d(g),v=function(t,e,n){if(le(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}(a,l,3),y=at(h.length),m=0,x=f||Lt,b=e?x(c,y):n?x(c,0):void 0;y>m;m++)if((u||m in h)&&(p=v(s=h[m],m,g),t))if(e)b[m]=p;else if(p)switch(t){case 3:return!0;case 5:return s;case 6:return m;case 2:fe.call(b,s)}else if(o)return!1;return i?-1:r||o?o:b}},pe={forEach:se(0),map:se(1),filter:se(2),some:se(3),every:se(4),find:se(5),findIndex:se(6)},de=pe.filter,ge=Gt("filter"),he=te("filter");jt({target:"Array",proto:!0,forced:!ge||!he},{filter:function(t){return de(this,t,arguments.length>1?arguments[1]:void 0)}});var ve=pe.map,ye=Gt("map"),me=te("map");jt({target:"Array",proto:!0,forced:!ye||!me},{map:function(t){return ve(this,t,arguments.length>1?arguments[1]:void 0)}});var xe=function(t){return function(e,n,r,o){le(n);var i=At(e),u=d(i),c=at(i.length),a=t?c-1:0,l=t?-1:1;if(r<2)for(;;){if(a in u){o=u[a],a+=l;break}if(a+=l,t?a<0:c<=a)throw TypeError("Reduce of empty array with no initial value")}for(;t?a>=0:c>a;a+=l)a in u&&(o=n(o,u[a],a,i));return o}},be={left:xe(!1),right:xe(!0)}.left,Se=Ht("reduce"),Ee=te("reduce",{1:0});jt({target:"Array",proto:!0,forced:!Se||!Ee},{reduce:function(t){return be(this,t,arguments.length,arguments.length>1?arguments[1]:void 0)}});var we=function(){var t=O(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e};function Ie(t,e){return RegExp(t,e)}var Oe,Te,je={UNSUPPORTED_Y:o((function(){var t=Ie("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),BROKEN_CARET:o((function(){var t=Ie("^r","gy");return t.lastIndex=2,null!=t.exec("str")}))},Re=RegExp.prototype.exec,Ae=String.prototype.replace,Pe=Re,_e=(Oe=/a/,Te=/b*/g,Re.call(Oe,"a"),Re.call(Te,"a"),0!==Oe.lastIndex||0!==Te.lastIndex),Ce=je.UNSUPPORTED_Y||je.BROKEN_CARET,ke=void 0!==/()??/.exec("")[1];(_e||ke||Ce)&&(Pe=function(t){var e,n,r,o,i=this,u=Ce&&i.sticky,c=we.call(i),a=i.source,l=0,f=t;return u&&(-1===(c=c.replace("y","")).indexOf("g")&&(c+="g"),f=String(t).slice(i.lastIndex),i.lastIndex>0&&(!i.multiline||i.multiline&&"\n"!==t[i.lastIndex-1])&&(a="(?: "+a+")",f=" "+f,l++),n=new RegExp("^(?:"+a+")",c)),ke&&(n=new RegExp("^"+a+"$(?!\\s)",c)),_e&&(e=i.lastIndex),r=Re.call(u?n:i,f),u?r?(r.input=r.input.slice(l),r[0]=r[0].slice(l),r.index=i.lastIndex,i.lastIndex+=r[0].length):i.lastIndex=0:_e&&r&&(i.lastIndex=i.global?r.index+r[0].length:e),ke&&r&&r.length>1&&Ae.call(r[0],n,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(r[o]=void 0)})),r});var Me=Pe;jt({target:"RegExp",proto:!0,forced:/./.exec!==Me},{exec:Me});var Ne=Ut("species"),Ue=!o((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})),De="$0"==="a".replace(/./,"$0"),Le=Ut("replace"),Be=!!/./[Le]&&""===/./[Le]("a","$0"),Fe=!o((function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),$e=function(t,e,n,r){var i=Ut(t),u=!o((function(){var e={};return e[i]=function(){return 7},7!=""[t](e)})),c=u&&!o((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[Ne]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return e=!0,null},n[i](""),!e}));if(!u||!c||"replace"===t&&(!Ue||!De||Be)||"split"===t&&!Fe){var a=/./[i],l=n(i,""[t],(function(t,e,n,r,o){return e.exec===Me?u&&!o?{done:!0,value:a.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),{REPLACE_KEEPS_$0:De,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Be}),f=l[0],s=l[1];tt(String.prototype,t,f),tt(RegExp.prototype,i,2==e?function(t,e){return s.call(t,this,e)}:function(t){return s.call(t,this)})}r&&R(RegExp.prototype[i],"sham",!0)},ze=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},Ke=function(t,e){var n=t.exec;if("function"==typeof n){var r=n.call(t,e);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==s(t))throw TypeError("RegExp#exec called on incompatible receiver");return Me.call(t,e)};$e("search",1,(function(t,e,n){return[function(e){var n=g(this),r=null==e?void 0:e[t];return void 0!==r?r.call(e,n):new RegExp(e)[t](String(n))},function(t){var r=n(e,t,this);if(r.done)return r.value;var o=O(t),i=String(this),u=o.lastIndex;ze(u,0)||(o.lastIndex=0);var c=Ke(o,i);return ze(o.lastIndex,u)||(o.lastIndex=u),null===c?-1:c.index}]}));var qe=Ut("match"),Ge=Ut("species"),We=function(t){return function(e,n){var r,o,i=String(g(e)),u=ut(n),c=i.length;return u<0||u>=c?t?"":void 0:(r=i.charCodeAt(u))<55296||r>56319||u+1===c||(o=i.charCodeAt(u+1))<56320||o>57343?t?i.charAt(u):r:t?i.slice(u,u+2):o-56320+(r-55296<<10)+65536}},Ye={codeAt:We(!1),charAt:We(!0)}.charAt,Ve=function(t,e,n){return e+(n?Ye(t,e).length:1)},Xe=[].push,He=Math.min,Je=!o((function(){return!RegExp(4294967295,"y")}));$e("split",2,(function(t,e,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,n){var r,o,i=String(g(this)),u=void 0===n?4294967295:n>>>0;if(0===u)return[];if(void 0===t)return[i];if(!v(r=t)||!(void 0!==(o=r[qe])?o:"RegExp"==s(r)))return e.call(i,t,u);for(var c,a,l,f=[],p=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),d=0,h=new RegExp(t.source,p+"g");(c=Me.call(h,i))&&!((a=h.lastIndex)>d&&(f.push(i.slice(d,c.index)),c.length>1&&c.index<i.length&&Xe.apply(f,c.slice(1)),l=c[0].length,d=a,f.length>=u));)h.lastIndex===c.index&&h.lastIndex++;return d===i.length?!l&&h.test("")||f.push(""):f.push(i.slice(d)),f.length>u?f.slice(0,u):f}:"0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:e.call(this,t,n)}:e,[function(e,n){var o=g(this),i=null==e?void 0:e[t];return void 0!==i?i.call(e,o,n):r.call(String(o),e,n)},function(t,o){var i=n(r,t,this,o,r!==e);if(i.done)return i.value;var u=O(t),c=String(this),a=function(t,e){var n,r=O(t).constructor;return void 0===r||null==(n=O(r)[Ge])?e:le(n)}(u,RegExp),l=u.unicode,f=(u.ignoreCase?"i":"")+(u.multiline?"m":"")+(u.unicode?"u":"")+(Je?"y":"g"),s=new a(Je?u:"^(?:"+u.source+")",f),p=void 0===o?4294967295:o>>>0;if(0===p)return[];if(0===c.length)return null===Ke(s,c)?[c]:[];for(var d=0,g=0,h=[];g<c.length;){s.lastIndex=Je?g:0;var v,y=Ke(s,Je?c:c.slice(g));if(null===y||(v=He(at(s.lastIndex+(Je?0:g)),c.length))===d)g=Ve(c,g,l);else{if(h.push(c.slice(d,g)),h.length===p)return h;for(var m=1;m<=y.length-1;m++)if(h.push(y[m]),h.length===p)return h;g=d=v}}return h.push(c.slice(d)),h}]}),!Je);function Qe(t,e){document.addEventListener("click",(function(n){(function(t,e){var n=e.path||e.composedPath&&e.composedPath(),r=document.querySelector(t);return n.indexOf(r)>=0})(t,n)&&(n.preventDefault(),n.stopPropagation(),e())}),!0)}function Ze(){if(!(localStorage.getItem("username")&&localStorage.getItem("token")&&localStorage.getItem("npm"))){var t=(location.search||"?").substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=").concat(["true"])})).reduce((function(t,e){return t[e[0]]=decodeURIComponent(e[1]),t}),{});(function(t){return t.username&&t.jwtToken&&t.npmToken})(t)&&(!function(t){localStorage.setItem("username",t.username),localStorage.setItem("token",t.jwtToken),localStorage.setItem("npm",t.npmToken)}(t),history.replaceState(null,"",location.pathname),location.reload())}}function tn(t){for(var e=0;e<10;e++)setTimeout((function(){return t()}),100*e)}!function(t){Ze();var e=t.loginButton,n=t.logoutButton,r=t.updateUsageInfo;Qe(e,(function(){location.href="/-/oauth/authorize"})),Qe(n,(function(){localStorage.removeItem("username"),localStorage.removeItem("token"),localStorage.removeItem("npm"),location.href="/"})),document.addEventListener("click",(function(){return tn(r)})),tn(r)}({loginButton:".header-button-login",logoutButton:".header-button-logout",updateUsageInfo:function t(){var e=function(){if(!localStorage.getItem("username"))return"Click the login button to authenticate with Doreamon.";var t="//"+location.host+"/",e=localStorage.getItem("npm");return["npm config set ".concat(t,':_authToken "').concat(e,'"')].join("\n")}(),n=document.querySelector("[class*='header__headerWrap'] figure");n?n.innerText=e:setTimeout(t,0)}})}));