/*! For license information please see auth.464f7632222141a759a3.js.LICENSE.txt */
!function(t,e){"object"==typeofexports&&"object"==typeofmodule?module.exports=e():"function"==typeofdefine&&define.amd?define([],e):"object"==typeofexports?exports.swh=e():(t.swh=t.swh||{},t.swh.auth=e())}(self,(function(){returnfunction(){vart={87757:function(t,e,r){t.exports=r(35666)},59537:function(t,e,r){"use strict";r.d(e,{L3:function(){returna},e_:function(){returni},ry:function(){returno}});r(87757);varn=r(31955);functiono(t){if(!t.ok)throwt;returnt}functioni(t,e,r){returnvoid0===e&&(e={}),void0===r&&(r=null),e["X-CSRFToken"]=n.Z.get("csrftoken"),fetch(t,{credentials:"include",headers:e,method:"POST",body:r})}functiona(){history.replaceState("",document.title,window.location.pathname+window.location.search)}},35666:function(t){vare=function(t){"use strict";vare,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeofSymbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";functionu(t,e,r){returnObject.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){returnt[e]=r}}functions(t,e,r,n){varo=e&&e.prototypeinstanceofy?e:y,i=Object.create(o.prototype),a=newj(n||[]);returni._invoke=function(t,e,r){varn=f;returnfunction(o,i){if(n===p)thrownewError("Generator is already running");if(n===d){if("throw"===o)throwi;returnC()}for(r.method=o,r.arg=i;;){vara=r.delegate;if(a){varc=L(a,r);if(c){if(c===v)continue;returnc}}if("next"===r.method)r.sent=r._sent=r.arg;elseif("throw"===r.method){if(n===f)thrown=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;varu=l(t,e,r);if("normal"===u.type){if(n=r.done?d:h,u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=d,r.method="throw",r.arg=u.arg)}}}(t,r,a),i}functionl(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;varf="suspendedStart",h="suspendedYield",p="executing",d="completed",v={};functiony(){}functionw(){}functionm(){}varg={};g[i]=function(){returnthis};varb=Object.getPrototypeOf,k=b&&b(b(O([])));k&&k!==r&&n.call(k,i)&&(g=k);varx=m.prototype=y.prototype=Object.create(g);function_(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){returnthis._invoke(e,t)}))}))}functionE(t,e){functionr(o,i,a,c){varu=l(t[o],t,i);if("throw"!==u.type){vars=u.arg,f=s.value;returnf&&"object"==typeoff&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){returnr("throw",t,a,c)}))}c(u.arg)}varo;this._invoke=function(t,n){functioni(){returnnewe((function(e,o){r(t,n,e,o)}))}returno=o?o.then(i,i):i()}}functionL(t,r){varn=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,L(t,r),"throw"===r.method))returnv;r.method="throw",r.arg=newTypeError("The iterator does not provide a 'throw' method")}returnv}varo=l(n,t.iterator,r.arg);if("throw"===o.type)returnr.method="throw",r.arg=o.arg,r.delegate=null,v;vari=o.arg;returni?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=newTypeError("iterator result is not an object"),r.delegate=null,v)}functionS(t){vare={tryLoc:t[0]};1int&&(e.catchLoc=t[1]),2int&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}functionT(t){vare=t.completion||{};e.type="normal",deletee.arg,t.completion=e}functionj(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}functionO(t){if(t){varr=t[i];if(r)returnr.call(t);if("function"==typeoft.next)returnt;if(!isNaN(t.length)){varo=-1,a=functionr(){for(;++o<t.length;)if(n.call(t,o))returnr.value=t[o],r.done=!1,r;returnr.value=e,r.done=!0,r};returna.next=a}}return{next:C}}functionC(){return{value:e,done:!0}}returnw.prototype=x.constructor=m,m.constructor=w,w.displayName=u(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){vare="function"==typeoft&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){returnObject.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,u(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},_(E.prototype),E.prototype[a]=function(){returnthis},t.AsyncIterator=E,t.async=function(e,r,n,o,i){void0===i&&(i=Promise);vara=newE(s(e,r,n,o),i);returnt.isGeneratorFunction(r)?a:a.next().then((function(t){returnt.done?t.value:a.next()}))},_(x),u(x,c,"Generator"),x[i]=function(){returnthis},x.toString=function(){return"[object Generator]"},t.keys=function(t){vare=[];for(varrint)e.push(r);returne.reverse(),functionr(){for(;e.length;){varn=e.pop();if(nint)returnr.value=n,r.done=!1,r}returnr.done=!0,r}},t.values=O,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(varrinthis)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;vart=this.tryEntries[0].completion;if("throw"===t.type)throwt.arg;returnthis.rval},dispatchException:function(t){if(this.done)throwt;varr=this;functiono(n,o){returnc.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(vari=this.tryEntries.length-1;i>=0;--i){vara=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)returno("end");if(a.tryLoc<=this.prev){varu=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)returno(a.catchLoc,!0);if(this.prev<a.finallyLoc)returno(a.finallyLoc)}elseif(u){if(this.prev<a.catchLoc)returno(a.catchLoc,!0)}else{if(!s)thrownewError("try statement without catch or finally");if(this.prev<a.finallyLoc)returno(a.finallyLoc)}}}},abrupt:function(t,e){for(varr=this.tryEntries.length-1;r>=0;--r){varo=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){vari=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);vara=i?i.completion:{};returna.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throwt.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(vare=this.tryEntries.length-1;e>=0;--e){varr=this.tryEntries[e];if(r.finallyLoc===t)returnthis.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(vare=this.tryEntries.length-1;e>=0;--e){varr=this.tryEntries[e];if(r.tryLoc===t){varn=r.completion;if("throw"===n.type){varo=n.arg;T(r)}returno}}thrownewError("illegal catch attempt")},delegateYield:function(t,r,n){returnthis.delegate={iterator:O(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}},15861:function(t,e,r){"use strict";functionn(t,e,r,n,o,i,a){try{varc=t[i](a),u=c.value}catch(t){returnvoidr(t)}c.done?e(u):Promise.resolve(u).then(n,o)}functiono(t){returnfunction(){vare=this,r=arguments;returnnewPromise((function(o,i){vara=t.apply(e,r);functionc(t){n(a,o,i,c,u,"next",t)}functionu(t){n(a,o,i,c,u,"throw",t)}c(void0)}))}}r.d(e,{Z:function(){returno}})},31955:function(t,e){"use strict";functionr(t){for(vare=1;e<arguments.length;e++){varr=arguments[e];for(varninr)t[n]=r[n]}returnt}varn=functiont(e,n){functiono(t,o,i){if("undefined"!=typeofdocument){"number"==typeof(i=r({},n,i)).expires&&(i.expires=newDate(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);vara="";for(varcini)i[c]&&(a+="; "+c,!0!==i[c]&&(a+="="+i[c].split(";")[0]));returndocument.cookie=t+"="+e.write(o,t)+a}}returnObject.create({set:o,get:function(t){if("undefined"!=typeofdocument&&(!arguments.length||t)){for(varr=document.cookie?document.cookie.split("; "):[],n={},o=0;o<r.length;o++){vari=r[o].split("="),a=i.slice(1).join("=");try{varc=decodeURIComponent(i[0]);if(n[c]=e.read(a,c),t===c)break}catch(t){}}returnt?n[t]:n}},remove:function(t,e){o(t,"",r({},e,{expires:-1}))},withAttributes:function(e){returnt(this.converter,r({},this.attributes,e))},withConverter:function(e){returnt(r({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){returnencodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});e.Z=n}},e={};functionr(n){varo=e[n];if(void0!==o)returno.exports;vari=e[n]={exports:{}};returnt[n](i,i.exports,r),i.exports}r.n=function(t){vare=t&&t.__esModule?function(){returnt.default}:function(){returnt};returnr.d(e,{a:e}),e},r.d=function(t,e){for(varnine)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeofglobalThis)returnglobalThis;try{returnthis||newFunction("return this")()}catch(t){if("object"==typeofwindow)returnwindow}}(),r.o=function(t,e){returnObject.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};varn,o={};return(n="undefined"!=typeofwindow?window:void0!==r.g?r.g:"undefined"!=typeofself?self:{}).SENTRY_RELEASE={id:"0.1.2"},n.SENTRY_RELEASES=n.SENTRY_RELEASES||{},n.SENTRY_RELEASES["swh-webapp@swh"]={id:"0.1.2"},function(){"use strict";r.r(o),r.d(o,{applyTokenAction:function(){returnw},initProfilePage:function(){returnm}});vart,e=r(15861),n=r(87757),i=r.n(n),a=r(59537);functionc(t){return'<p id="swh-token-error-message" class="mt-3 swh-token-form-message">'+t+"</p>"}functionu(t){return'<p id="swh-token-success-message" class="mt-3 swh-token-form-message">'+t+"</p>"}functions(){$("#swh-token-form-submit").prop("disabled",!0)}functionl(){window.location=Urls.oidc_generate_bearer_token()}functionf(t){returnh.apply(this,arguments)}functionh(){return(h=(0,e.Z)(i().mark((functiont(e){varr,n,o,u,s,l;returni().wrap((function(t){for(;;)switch(t.prev=t.next){case0:returnr={token_id:e},t.prev=1,t.next=4,(0,a.e_)(Urls.oidc_get_bearer_token(),{},JSON.stringify(r));case4:returnn=t.sent,(0,a.ry)(n),t.next=8,n.text();case8:o=t.sent,u='<p>Below is your token.</p>\n <pre id="swh-bearer-token" class="mt-3">'+o+"</pre>",swh.webapp.showModalHtml("Display bearer token",u),t.next=21;break;case13:returnt.prev=13,t.t0=t.catch(1),t.next=17,t.t0.text();case17:s=t.sent,l="Internal server error.",400===t.t0.status&&(l=s),swh.webapp.showModalHtml("Display bearer token",c(l));case21:case"end":returnt.stop()}}),t,null,[[1,13]])})))).apply(this,arguments)}functionp(t){returnd.apply(this,arguments)}functiond(){return(d=(0,e.Z)(i().mark((functione(r){varn,o;returni().wrap((function(e){for(;;)switch(e.prev=e.next){case0:returnn={token_ids:r},e.prev=1,e.next=4,(0,a.e_)(Urls.oidc_revoke_bearer_tokens(),{},JSON.stringify(n));case4:o=e.sent,(0,a.ry)(o),s(),$("#swh-token-form-message").html(u("Bearer token"+(r.length>1?"s":"")+" successfully revoked.")),t.draw(),e.next=14;break;case11:e.prev=11,e.t0=e.catch(1),$("#swh-token-form-message").html(c("Internal server error."));case14:case"end":returne.stop()}}),e,null,[[1,11]])})))).apply(this,arguments)}functionv(t){p([t])}functiony(){for(vare=[],r=t.rows().data(),n=0;n<r.length;++n)e.push(r[n].id);p(e)}functionw(t,e){varr,n,o={display:{submitCallback:f},generate:{modalTitle:"Bearer token generation",infoText:"Click on the button to generate the token. You will be redirected to Software Heritage Authentication Service and might be asked to enter your password again.",buttonText:"Generate token",submitCallback:l},revoke:{modalTitle:"Revoke bearer token",infoText:"Click on the button to revoke the token.",buttonText:"Revoke token",submitCallback:v},revokeAll:{modalTitle:"Revoke all bearer tokens",infoText:"Click on the button to revoke all tokens.",buttonText:"Revoke tokens",submitCallback:y}};if(o[t])if("display"!==t){vari=(r=o[t].infoText,n=o[t].buttonText,'<form id="swh-token-form" class="text-center">\n <p id="swh-token-form-text">'+r+'</p>\n <input id="swh-token-form-submit" type="submit" value="'+n+'">\n <div id="swh-token-form-message"></div>\n </form>');swh.webapp.showModalHtml(o[t].modalTitle,i),$("#swh-token-form").submit((function(r){r.preventDefault(),r.stopPropagation(),o[t].submitCallback(e)}))}elseo[t].submitCallback(e)}functionm(){$(document).ready((function(){t=$("#swh-bearer-tokens-table").on("error.dt",(function(t,e,r,n){$("#swh-origin-save-request-list-error").text("An error occurred while retrieving the tokens list"),console.log(n)})).DataTable({serverSide:!0,ajax:Urls.oidc_list_bearer_tokens(),columns:[{data:"creation_date",name:"creation_date",render:function(t,e,r){return"display"===e?newDate(t).toLocaleString():t}},{render:function(t,e,r){return'<button class="btn btn-default"\n onclick="swh.auth.applyTokenAction(\'display\', '+r.id+')">\n Display token\n </button>\n <button class="btn btn-default"\n onclick="swh.auth.applyTokenAction(\'revoke\', '+r.id+')">\n Revoke token\n </button>'}}],ordering:!1,searching:!1,scrollY:"50vh",scrollCollapse:!0}),$("#swh-oidc-profile-tokens-tab").on("shown.bs.tab",(function(){t.draw(),window.location.hash="#tokens"})),$("#swh-oidc-profile-account-tab").on("shown.bs.tab",(function(){(0,a.L3)()})),"#tokens"===window.location.hash&&$('.nav-tabs a[href="#swh-oidc-profile-tokens"]').tab("show")}))}}(),o}()}));