Viewing File: /usr/local/cpanel/whostmgr/docroot/templates/twofactorauth/index.cmb.min.js

define("app/services/tfaData",["angular","jquery","lodash","cjt/util/locale","cjt/util/parse","cjt/io/api","cjt/io/whm-v1-request","cjt/io/whm-v1","cjt/decorators/growlDecorator"],(function(e,t,r,o,n,s,i){"use strict";var a;try{a=e.module("App")}catch(t){a=e.module("App",[])}return a.factory("TwoFactorData",["$q","PAGE",function(e,t){var o={};function a(e){var t=[];if(null==e)return t;for(var r=Object.keys(e),o=r.length,s=0;s<o;s++){var i=e[r[s]];i.user_name=r[s],i.is_enabled=n.parsePerlBoolean(i.is_enabled),i.is_enabled&&t.push(i)}return t}return o.enabled=!1,o.currentUser={user_name:t.user,is_enabled:n.parsePerlBoolean(t.current_user_tfa_status)},o.userData={},o.issuer=t.issuer,o.systemWideIssuer=t.system_wide_issuer,o.getStatus=function(){var t=e.defer(),r=new i.Class;return r.initialize("","twofactorauth_policy_status"),s.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.enabled=n.parsePerlBoolean(e.data.is_enabled),t.resolve(o.enabled)):t.reject(e.error)})),t.promise},o.enable=function(){var t=e.defer(),r=new i.Class;return r.initialize("","twofactorauth_enable_policy"),s.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.enabled=!0,t.resolve(o.enabled)):t.reject(e.error)})),t.promise},o.disable=function(){var t=e.defer(),r=new i.Class;return r.initialize("","twofactorauth_disable_policy"),s.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(t.resolve(e.status),o.enabled=!1,t.resolve(o.enabled)):t.reject(e.error)})),t.promise},o.getUsers=function(t){var r=e.defer(),n=new i.Class;return n.initialize("","twofactorauth_get_user_configs"),void 0!==t&&n.addArgument("user",t),s.promise(n.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.userData=e.data,e.data&&delete e.data[o.currentUser.user_name],r.resolve(a(e.data))):r.reject(e.error)})),r.promise},o.saveIssuer=function(t){var r=e.defer(),n=new i.Class;return n.initialize("","twofactorauth_set_issuer"),n.addArgument("issuer",t),s.promise(n.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.issuer=t,"root"===o.currentUser.user_name&&(o.systemWideIssuer=t),r.resolve(t)):r.reject(e.error)})),r.promise},o.getIssuer=function(t){var r=e.defer(),n=new i.Class;return n.initialize("","twofactorauth_get_issuer"),s.promise(n.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.issuer=e.data.issuer,o.systemWideIssuer=e.data.system_wide_issuer,r.resolve()):r.reject(e.error)})),r.promise},o.disableFor=function(t){var n=e.defer(),u=new i.Class;if(u.initialize("","twofactorauth_remove_user_config"),"string"==typeof t)u.addArgument("user-0",t.user_name);else if("object"==typeof t)for(var l=0,c=t.length;l<c;l++)u.addArgument("user-"+l,t[l].user_name);return s.promise(u.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(o.userData=r.omit(o.userData,e.data.users_modified),e.data.users_modified.filter((function(e){return e===o.currentUser.user_name})).length>0&&(o.currentUser.is_enabled=!1),e.data.list=[],e.data.list=a(o.userData),n.resolve(e.data)):n.reject(e.error)})),n.promise},o.generateSetupData=function(){var t=new i.Class;return t.initialize("","twofactorauth_generate_tfa_config"),e.when(s.promise(t.getRunArguments())).then((function(t){return(t=t.parsedResponse).status?t.data:e.reject(t.error)}))},o.saveSetupData=function(t,r){var a=new i.Class;return a.initialize("","twofactorauth_set_tfa_config"),a.addArgument("secret",r),a.addArgument("tfa_token",t),e.when(s.promise(a.getRunArguments())).then((function(t){return(t=t.parsedResponse).status?(o.currentUser.is_enabled=n.parsePerlBoolean(t.data.success),o.currentUser.is_enabled):e.reject(t.error)}))},o}])})),define("app/views/disablePromptController",["angular","jquery","cjt/util/locale","uiBootstrap"],(function(e,t,r){return e.module("App").controller("disablePromptController",["$scope","$uibModalInstance","users","mode",function(e,t,o,n){var s=this;s.users=o,s.mode=n,s.cancelDisable=function(){t.close()},s.disableConfirmationMessage=function(){if("disableSelected"===s.mode){if(1===s.users.length)return r.maketext("Are you sure you want to remove two-factor authentication for “[_1]”?",s.users[0].user_name);if(s.users.length>1)return r.maketext("Are you sure you want to remove two-factor authentication for [quant,_1,user,users]?",s.users.length)}return r.maketext("Do you want to remove two-factor authentication for all users?")},s.disableTFAFor=function(){t.close(s.users,s.mode)}}])})),define("app/views/usersController",["angular","jquery","cjt/util/locale","lodash","uiBootstrap","cjt/validator/datatype-validators","cjt/validator/compare-validators","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/directives/toggleSortDirective","cjt/directives/pageSizeDirective","cjt/decorators/paginationDecorator","cjt/directives/actionButtonDirective","cjt/decorators/growlDecorator","app/services/tfaData"],(function(e,t,r,o){return e.module("App").controller("usersController",["$scope","$uibModal","TwoFactorData","growl","$timeout",function(e,n,s,i,a){var u=this;u.users=[],u.usersToDisable=[],u.disableInProgress=!1,u.isSingleDisable=!1,u.modalInstance=null,u.loadingUsers=!0,u.meta={sortDirection:"asc",sortBy:"user_name",sortType:"",maxPages:0,totalRows:u.users.length||0,pageNumber:1,pageNumberStart:0,pageNumberEnd:0,pageSize:20,pageSizes:[20,50,100],filteredList:[]},u.resetPagination=function(){u.meta.pageNumber=1,u.fetchPage()},u.fetchPage=function(){u.clearSelection();var e=u.meta.pageSize,t=(u.meta.pageNumber-1)*e+1,r=t+e-1;r>u.users.length&&(r=u.users.length),u.meta.totalRows=u.users.length,u.meta.filteredList=u.users.slice(t-1,r),u.meta.pageNumberStart=u.meta.filteredList.length>0?t:0,u.meta.pageNumberEnd=r},u.paginationMessage=function(){return r.maketext("Displaying [numf,_1] to [numf,_2] out of [quant,_3,item,items]",u.meta.pageNumberStart,u.meta.pageNumberEnd,u.meta.totalRows)},u.sortList=function(e){u.clearSelection();var t=u.users;t=o.sortBy(t,e.sortBy),"asc"!==e.sortDirection&&t.reverse(),u.users=t,u.resetPagination()},u.selectAllUsers=function(){0!==u.users.length&&(t(".userSelect").prop("checked",!0),t("#selectAllCheckbox").prop("checked",!0))},u.toggleSelectAll=function(){t("#selectAllCheckbox").is(":checked")?t(".userSelect").prop("checked",!0):t(".userSelect").prop("checked",!1)},u.clearSelection=function(){0!==u.users.length&&(t(".userSelect").prop("checked",!1),t("#selectAllCheckbox").prop("checked",!1))},u.atLeastOneUserIsSelected=function(){return t(".userSelect:checked").length>0},u.allUsersSelected=function(){return t(".userSelect:checked").length===u.users.length},u.confirmDisableTFAFor=function(e){if(0===u.users.length)return!1;if(u.disableInProgress=!0,void 0!==e)u.usersToDisable=[e],u.isSingleDisable=!0;else{var r=[],o=t(".userSelect:checked");if(0===o.length)return!1;o.each((function(){r.push(t(this).data("user"))})),u.usersToDisable=r}return u.modalInstance=n.open({templateUrl:"confirm_disable.html",controller:"disablePromptController",controllerAs:"dc",resolve:{users:function(){return u.usersToDisable},mode:function(){return"disableSelected"}}}),u.modalInstance.result.then((function(e,t){return u.removeUsers(e,t)}))},u.confirmDisableAll=function(){if(0!==u.users.length)return u.modalInstance=n.open({templateUrl:"confirm_disable.html",controller:"disablePromptController",controllerAs:"dc",resolve:{users:function(){return u.users},mode:function(){return"disableAll"}}}),u.modalInstance.result.then((function(e,t){return u.removeUsers(e,t)}))},u.removeUsers=function(e,t){if(void 0!==e)return s.disableFor(e).then((function(e){var o=Object.keys(e.failed);1===o.length?i.error(r.maketext("The system failed to remove two-factor authentication for “[_1]”.",o[0])):o.length>1&&i.error(r.maketext("The system failed to remove two-factor authentication for [quant,_1,user,users].",o.length)),"disableSelected"===t?1===e.users_modified.length?i.success(r.maketext("The system successfully removed two-factor authentication for “[_1]”.",e.users_modified[0])):e.users_modified.length>1&&i.success(r.maketext("The system successfully removed two-factor authentication for [quant,_1,user,users].",e.users_modified.length)):"disableAll"===t&&e.users_modified.length>0&&i.success(r.maketext("The system successfully removed two-factor authentication for all users.")),e.users_modified.length>0&&(u.users=e.list,u.sortList(u.meta))}),(function(e){i.error(e)}))},u.getUsers=function(){return u.loadingUsers=!0,s.getUsers().then((function(e){u.users=e,u.sortList(u.meta)}),(function(e){i.error(e)})).finally((function(){u.loadingUsers=!1}))},u.forceReload=function(){return u.users=[],u.getUsers()},u.getUsers()}])})),define("app/views/enableController",["angular","jquery","cjt/util/locale","cjt/util/parse","uiBootstrap","cjt/directives/toggleSortDirective","cjt/directives/actionButtonDirective","cjt/directives/toggleSwitchDirective","app/services/tfaData","cjt/decorators/growlDecorator"],(function(e,t,r,o){return e.module("App").controller("enableController",["TwoFactorData","growl","growlMessages","PAGE",function(e,n,s,i){var a=this;a.tfaEnabled=o.parsePerlBoolean(i.tfa_status),a.hasRoot=o.parsePerlBoolean(i.has_root),a.status_check_in_progress=!1,a.changing_status=!1,a.toggle_status=function(){a.hasRoot&&!a.changing_status&&(a.changing_status=!0,a.tfaEnabled?(s.destroyAllMessages(),e.disable().then((function(){a.tfaEnabled=!1,n.success(r.maketext("The Two-Factor Authentication security policy is now disabled."))}),(function(e){n.error(e)})).finally((function(){a.changing_status=!1}))):e.enable().then((function(){a.tfaEnabled=!0,n.success(r.maketext("The Two-Factor Authentication security policy is now enabled."))}),(function(e){n.error(e)})).finally((function(){a.changing_status=!1})))},a.getStatus=function(){if(!a.status_check_in_progress)return a.status_check_in_progress=!0,e.getStatus().then((function(e){e!==a.tfaEnabled&&(!1===e&&s.destroyAllMessages(),n.warning(r.maketext("The status for Two-Factor Authentication has changed, possibly in another browser session."))),a.tfaEnabled=e}),(function(e){n.error(e)})).finally((function(){a.status_check_in_progress=!1}))},a.init=function(){t(document).ready((function(){a.hasRoot&&t(window).on("focus",(function(){a.getStatus()}))}))},a.init()}])})),define("app/views/configController",["angular","cjt/util/locale","lodash","uiBootstrap","cjt/validator/datatype-validators","cjt/validator/compare-validators","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/directives/toggleSortDirective","cjt/directives/actionButtonDirective","cjt/decorators/growlDecorator","app/services/tfaData"],(function(e,t,r){return e.module("App").controller("configController",["$scope","TwoFactorData","growl","$timeout","PAGE",function(e,o,n,s,i){var a=this;function u(e){for(var t=r.keys(e),o=0,n=t.length;o<n;o++){var s=e[t[o]];s&&s.$setViewValue&&s.$setViewValue(s.$viewValue)}}a.issuer=o.issuer,a.systemWideIssuer=o.systemWideIssuer,a.saveInProgress=!1,a.loadingIssuer=!1,a.saveError=!1,a.currentUser=o.currentUser,a.disableSave=function(e){return a.saveInProgress||e.$dirty&&e.$invalid},a.issuerHelpText=t.maketext("The name associated with the service provider."),a.issuerPlaceholder=t.maketext("Provide a name for the authentication service."),a.rootIssuerPlaceholder=i.server_hostname,a.systemWideIssuerAlert=function(){var e=a.systemWideIssuer.replace(/ /g,"&nbsp;");return t.maketext("If you do not provide an issuer, the system will use: “[output,strong,_1]”",e)},a.saveIssuer=function(e){if(u(e),e.$valid)return a.saveInProgress=!0,o.saveIssuer(a.issuer).then((function(){a.systemWideIssuer=o.systemWideIssuer,n.success(t.maketext("The system successfully saved the issuer name.")),a.saveError=!1}),(function(e){a.saveError=!0,n.error(e)})).finally((function(){a.saveInProgress=!1}))},a.getIssuer=function(){return a.loadingIssuer=!0,o.getIssuer().then((function(){a.issuer=o.issuer,a.systemWideIssuer=o.systemWideIssuer}),(function(e){n.error(e)})).finally((function(){a.loadingIssuer=!1}))},a.init=function(){a.issuer||a.getIssuer(),s((function(){u(a.config_form)}))},a.init()}])})),function(e){define("qrcode",[],(function(){return function(){var t;return function(){function e(e){this.mode=o.MODE_8BIT_BYTE,this.data=e,this.parsedData=[];for(var t=0,r=this.data.length;t<r;t++){var n=[],s=this.data.charCodeAt(t);s>65536?(n[0]=240|(1835008&s)>>>18,n[1]=128|(258048&s)>>>12,n[2]=128|(4032&s)>>>6,n[3]=128|63&s):s>2048?(n[0]=224|(61440&s)>>>12,n[1]=128|(4032&s)>>>6,n[2]=128|63&s):s>128?(n[0]=192|(1984&s)>>>6,n[1]=128|63&s):n[0]=s,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function r(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}e.prototype={getLength:function(e){return this.parsedData.length},write:function(e){for(var t=0,r=this.parsedData.length;t<r;t++)e.put(this.parsedData[t],8)}},r.prototype={addData:function(t){var r=new e(t);this.dataList.push(r),this.dataCache=null},isDark:function(e,t){if(e<0||this.moduleCount<=e||t<0||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var n=0;n<this.moduleCount;n++)this.modules[o][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=r.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)t+o<=-1||this.moduleCount<=t+o||(this.modules[e+r][t+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=f.getLostPoint(this);(0==r||e>o)&&(e=o,t=r)}return t},createMovieClip:function(e,t,r){var o=e.createEmptyMovieClip(t,r);this.make();for(var n=0;n<this.modules.length;n++)for(var s=1*n,i=0;i<this.modules[n].length;i++){var a=1*i;this.modules[n][i]&&(o.beginFill(0,100),o.moveTo(a,s),o.lineTo(a+1,s),o.lineTo(a+1,s+1),o.lineTo(a,s+1),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)null==this.modules[e][6]&&(this.modules[e][6]=e%2==0);for(var t=8;t<this.moduleCount-8;t++)null==this.modules[6][t]&&(this.modules[6][t]=t%2==0)},setupPositionAdjustPattern:function(){for(var e=f.getPatternPosition(this.typeNumber),t=0;t<e.length;t++)for(var r=0;r<e.length;r++){var o=e[t],n=e[r];if(null==this.modules[o][n])for(var s=-2;s<=2;s++)for(var i=-2;i<=2;i++)this.modules[o+s][n+i]=-2==s||2==s||-2==i||2==i||0==s&&0==i}},setupTypeNumber:function(e){for(var t=f.getBCHTypeNumber(this.typeNumber),r=0;r<18;r++){var o=!e&&1==(t>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!e&&1==(t>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,o=f.getBCHTypeInfo(r),n=0;n<15;n++){var s=!e&&1==(o>>n&1);n<6?this.modules[n][8]=s:n<8?this.modules[n+1][8]=s:this.modules[this.moduleCount-15+n][8]=s}for(n=0;n<15;n++){s=!e&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=s:n<9?this.modules[8][15-n-1+1]=s:this.modules[8][15-n-1]=s}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,o=this.moduleCount-1,n=7,s=0,i=this.moduleCount-1;i>0;i-=2)for(6==i&&i--;;){for(var a=0;a<2;a++)if(null==this.modules[o][i-a]){var u=!1;s<e.length&&(u=1==(e[s]>>>n&1)),f.getMask(t,o,i-a)&&(u=!u),this.modules[o][i-a]=u,-1==--n&&(s++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},r.PAD0=236,r.PAD1=17,r.createData=function(e,t,o){for(var n=v.getRSBlocks(e,t),s=new _,i=0;i<o.length;i++){var a=o[i];s.put(a.mode,4),s.put(a.getLength(),f.getLengthInBits(a.mode,e)),a.write(s)}var u=0;for(i=0;i<n.length;i++)u+=n[i].dataCount;if(s.getLengthInBits()>8*u)throw new Error("code length overflow. ("+s.getLengthInBits()+">"+8*u+")");for(s.getLengthInBits()+4<=8*u&&s.put(0,4);s.getLengthInBits()%8!=0;)s.putBit(!1);for(;!(s.getLengthInBits()>=8*u||(s.put(r.PAD0,8),s.getLengthInBits()>=8*u));)s.put(r.PAD1,8);return r.createBytes(s,n)},r.createBytes=function(e,t){for(var r=0,o=0,n=0,s=new Array(t.length),i=new Array(t.length),a=0;a<t.length;a++){var u=t[a].dataCount,l=t[a].totalCount-u;o=Math.max(o,u),n=Math.max(n,l),s[a]=new Array(u);for(var c=0;c<s[a].length;c++)s[a][c]=255&e.buffer[c+r];r+=u;var h=f.getErrorCorrectPolynomial(l),d=new m(s[a],h.getLength()-1).mod(h);i[a]=new Array(h.getLength()-1);for(c=0;c<i[a].length;c++){var g=c+d.getLength()-i[a].length;i[a][c]=g>=0?d.get(g):0}}var p=0;for(c=0;c<t.length;c++)p+=t[c].totalCount;var v=new Array(p),_=0;for(c=0;c<o;c++)for(a=0;a<t.length;a++)c<s[a].length&&(v[_++]=s[a][c]);for(c=0;c<n;c++)for(a=0;a<t.length;a++)c<i[a].length&&(v[_++]=i[a][c]);return v};for(var o={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},s=0,i=1,a=2,u=3,l=4,c=5,h=6,d=7,f={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;f.getBCHDigit(t)-f.getBCHDigit(f.G15)>=0;)t^=f.G15<<f.getBCHDigit(t)-f.getBCHDigit(f.G15);return(e<<10|t)^f.G15_MASK},getBCHTypeNumber:function(e){for(var t=e<<12;f.getBCHDigit(t)-f.getBCHDigit(f.G18)>=0;)t^=f.G18<<f.getBCHDigit(t)-f.getBCHDigit(f.G18);return e<<12|t},getBCHDigit:function(e){for(var t=0;0!=e;)t++,e>>>=1;return t},getPatternPosition:function(e){return f.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case s:return(t+r)%2==0;case i:return t%2==0;case a:return r%3==0;case u:return(t+r)%3==0;case l:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case c:return t*r%2+t*r%3==0;case h:return(t*r%2+t*r%3)%2==0;case d:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new m([1],0),r=0;r<e;r++)t=t.multiply(new m([1,g.gexp(r)],0));return t},getLengthInBits:function(e,t){if(1<=t&&t<10)switch(e){case o.MODE_NUMBER:return 10;case o.MODE_ALPHA_NUM:return 9;case o.MODE_8BIT_BYTE:case o.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(t<27)switch(e){case o.MODE_NUMBER:return 12;case o.MODE_ALPHA_NUM:return 11;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else{if(!(t<41))throw new Error("type:"+t);switch(e){case o.MODE_NUMBER:return 14;case o.MODE_ALPHA_NUM:return 13;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),r=0,o=0;o<t;o++)for(var n=0;n<t;n++){for(var s=0,i=e.isDark(o,n),a=-1;a<=1;a++)if(!(o+a<0||t<=o+a))for(var u=-1;u<=1;u++)n+u<0||t<=n+u||0==a&&0==u||i==e.isDark(o+a,n+u)&&s++;s>5&&(r+=3+s-5)}for(o=0;o<t-1;o++)for(n=0;n<t-1;n++){var l=0;e.isDark(o,n)&&l++,e.isDark(o+1,n)&&l++,e.isDark(o,n+1)&&l++,e.isDark(o+1,n+1)&&l++,0!=l&&4!=l||(r+=3)}for(o=0;o<t;o++)for(n=0;n<t-6;n++)e.isDark(o,n)&&!e.isDark(o,n+1)&&e.isDark(o,n+2)&&e.isDark(o,n+3)&&e.isDark(o,n+4)&&!e.isDark(o,n+5)&&e.isDark(o,n+6)&&(r+=40);for(n=0;n<t;n++)for(o=0;o<t-6;o++)e.isDark(o,n)&&!e.isDark(o+1,n)&&e.isDark(o+2,n)&&e.isDark(o+3,n)&&e.isDark(o+4,n)&&!e.isDark(o+5,n)&&e.isDark(o+6,n)&&(r+=40);var c=0;for(n=0;n<t;n++)for(o=0;o<t;o++)e.isDark(o,n)&&c++;return r+=10*(Math.abs(100*c/t/t-50)/5)}},g={glog:function(e){if(e<1)throw new Error("glog("+e+")");return g.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return g.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},p=0;p<8;p++)g.EXP_TABLE[p]=1<<p;for(p=8;p<256;p++)g.EXP_TABLE[p]=g.EXP_TABLE[p-4]^g.EXP_TABLE[p-5]^g.EXP_TABLE[p-6]^g.EXP_TABLE[p-8];for(p=0;p<255;p++)g.LOG_TABLE[g.EXP_TABLE[p]]=p;function m(e,t){if(null==e.length)throw new Error(e.length+"/"+t);for(var r=0;r<e.length&&0==e[r];)r++;this.num=new Array(e.length-r+t);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}function v(e,t){this.totalCount=e,this.dataCount=t}function _(){this.buffer=[],this.length=0}m.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)t[r+o]^=g.gexp(g.glog(this.get(r))+g.glog(e.get(o)));return new m(t,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var t=g.glog(this.get(0))-g.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(o=0;o<e.getLength();o++)r[o]^=g.gexp(g.glog(e.get(o))+t);return new m(r,0).mod(e)}},v.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],v.getRSBlocks=function(e,t){var r=v.getRsBlockTable(e,t);if(null==r)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var o=r.length/3,n=[],s=0;s<o;s++)for(var i=r[3*s+0],a=r[3*s+1],u=r[3*s+2],l=0;l<i;l++)n.push(new v(a,u));return n},v.getRsBlockTable=function(e,t){switch(t){case n.L:return v.RS_BLOCK_TABLE[4*(e-1)+0];case n.M:return v.RS_BLOCK_TABLE[4*(e-1)+1];case n.Q:return v.RS_BLOCK_TABLE[4*(e-1)+2];case n.H:return v.RS_BLOCK_TABLE[4*(e-1)+3];default:return}},_.prototype={get:function(e){var t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(var r=0;r<t;r++)this.putBit(1==(e>>>t-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var w=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function b(){var e=!1,t=navigator.userAgent;if(/android/i.test(t)){e=!0;var r=t.toString().match(/android ([0-9]\.[0-9])/i);r&&r[1]&&(e=parseFloat(r[1]))}return e}var y=function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){var t=this._htOption,r=this._el,o=e.getModuleCount();Math.floor(t.width/o),Math.floor(t.height/o);function n(e,t){var r=document.createElementNS("http://www.w3.org/2000/svg",e);for(var o in t)t.hasOwnProperty(o)&&r.setAttribute(o,t[o]);return r}this.clear();var s=n("svg",{viewBox:"0 0 "+String(o)+" "+String(o),width:"100%",height:"100%",fill:t.colorLight});s.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),r.appendChild(s),s.appendChild(n("rect",{fill:t.colorLight,width:"100%",height:"100%"})),s.appendChild(n("rect",{fill:t.colorDark,width:"1",height:"1",id:"template"}));for(var i=0;i<o;i++)for(var a=0;a<o;a++)if(e.isDark(i,a)){var u=n("use",{x:String(a),y:String(i)});u.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),s.appendChild(u)}},e.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},e}(),D="svg"===document.documentElement.tagName.toLowerCase()?y:"undefined"==typeof CanvasRenderingContext2D?function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){for(var t=this._htOption,r=this._el,o=e.getModuleCount(),n=Math.floor(t.width/o),s=Math.floor(t.height/o),i=['<table style="border:0;border-collapse:collapse;">'],a=0;a<o;a++){i.push("<tr>");for(var u=0;u<o;u++)i.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:'+n+"px;height:"+s+"px;background-color:"+(e.isDark(a,u)?t.colorDark:t.colorLight)+';"></td>');i.push("</tr>")}i.push("</table>"),r.innerHTML=i.join("");var l=r.childNodes[0],c=(t.width-l.offsetWidth)/2,h=(t.height-l.offsetHeight)/2;c>0&&h>0&&(l.style.margin=h+"px "+c+"px")},e.prototype.clear=function(){this._el.innerHTML=""},e}():function(){function e(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}if(this._android&&this._android<=2.1){var t=1/window.devicePixelRatio,r=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(e,o,n,s,i,a,u,l,c){if("nodeName"in e&&/img/i.test(e.nodeName))for(var h=arguments.length-1;h>=1;h--)arguments[h]=arguments[h]*t;else void 0===l&&(arguments[1]*=t,arguments[2]*=t,arguments[3]*=t,arguments[4]*=t);r.apply(this,arguments)}}function o(e,t){var r=this;if(r._fFail=t,r._fSuccess=e,null===r._bSupportDataURI){var o=document.createElement("img"),n=function(){r._bSupportDataURI=!1,r._fFail&&r._fFail.call(r)};return o.onabort=n,o.onerror=n,o.onload=function(){r._bSupportDataURI=!0,r._fSuccess&&r._fSuccess.call(r)},void(o.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")}!0===r._bSupportDataURI&&r._fSuccess?r._fSuccess.call(r):!1===r._bSupportDataURI&&r._fFail&&r._fFail.call(r)}var n=function(e,t){this._bIsPainted=!1,this._android=b(),this._htOption=t,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=t.width,this._elCanvas.height=t.height,e.appendChild(this._elCanvas),this._el=e,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.alt="Scan me!",this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return n.prototype.draw=function(e){var t=this._elImage,r=this._oContext,o=this._htOption,n=e.getModuleCount(),s=o.width/n,i=o.height/n,a=Math.round(s),u=Math.round(i);t.style.display="none",this.clear();for(var l=0;l<n;l++)for(var c=0;c<n;c++){var h=e.isDark(l,c),d=c*s,f=l*i;r.strokeStyle=h?o.colorDark:o.colorLight,r.lineWidth=1,r.fillStyle=h?o.colorDark:o.colorLight,r.fillRect(d,f,s,i),r.strokeRect(Math.floor(d)+.5,Math.floor(f)+.5,a,u),r.strokeRect(Math.ceil(d)-.5,Math.ceil(f)-.5,a,u)}this._bIsPainted=!0},n.prototype.makeImage=function(){this._bIsPainted&&o.call(this,e)},n.prototype.isPainted=function(){return this._bIsPainted},n.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},n.prototype.round=function(e){return e?Math.floor(1e3*e)/1e3:e},n}();function C(e,t){for(var r=1,o=function(e){var t=encodeURI(e).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return t.length+(t.length!=e?3:0)}(e),s=0,i=w.length;s<=i;s++){var a=0;switch(t){case n.L:a=w[s][0];break;case n.M:a=w[s][1];break;case n.Q:a=w[s][2];break;case n.H:a=w[s][3]}if(o<=a)break;r++}if(r>w.length)throw new Error("Too long data");return r}t=function(e,t){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:n.H},"string"==typeof t&&(t={text:t}),t)for(var r in t)this._htOption[r]=t[r];"string"==typeof e&&(e=document.getElementById(e)),this._htOption.useSVG&&(D=y),this._android=b(),this._el=e,this._oQRCode=null,this._oDrawing=new D(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},t.prototype.makeCode=function(e){this._oQRCode=new r(C(e,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(e),this._oQRCode.make(),this._el.title=e,this._oDrawing.draw(this._oQRCode),this.makeImage()},t.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},t.prototype.clear=function(){this._oDrawing.clear()},t.CorrectLevel=n}(),e.QRCode=t}.apply(e,arguments)}))}(this),define("app/directives/create_qrcode",["angular","qrcode"],(function(e,t){var r;try{r=e.module("App")}catch(t){r=e.module("App",[])}r.directive("createQrCode",["$timeout",function(e){return{restrict:"A",scope:{qrCodeData:"="},link:function(e,r,o){var n=new t(r[0]);e.$watch("qrCodeData",(function(e,t){e&&e.length>0&&(n.clear(),n.makeCode(e))}))}}}])})),define("app/views/setupController",["angular","cjt/util/locale","cjt/util/parse","uiBootstrap","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/directives/actionButtonDirective","cjt/decorators/growlDecorator","app/directives/create_qrcode","app/services/tfaData"],(function(e,t,r){return e.module("App").controller("setupController",["$scope","TwoFactorData","growl","$timeout","$q","$uibModal",function(e,r,o,n,s,i){var a=this;a.setup_data={},a.setup_data.user=r.currentUser.user_name,a.isEnabled=r.currentUser.is_enabled,a.loading=!1,a.settingUp=!1,a.isSaving=!1,a.isReconfigure=!1,a.getSetupData=function(){return r.generateSetupData().then((function(e){a.setup_data.otpauth_str=e.otpauth_str,a.setup_data.secret=e.secret})).catch((function(e){o.error(e)}))},a.disableSave=function(e){return e.$invalid},a.goToSetup=function(){return a.isReconfigure=a.isEnabled,a.loading=!0,a.getSetupData().then((function(){a.settingUp=!0,a.loading=!1}))},a.goToMain=function(){a.settingUp=!1},a.save=function(e){if(e.$valid)return a.isSaving=!0,r.saveSetupData(a.security_token,a.setup_data.secret).then((function(e){a.isEnabled=e,a.isEnabled&&o.success(t.maketext("[output,strong,Success:] Two-factor authentication is now configured on your account.")),a.settingUp=!1})).catch((function(e){o.error(e)})).finally((function(){a.isSaving=!1}))},a.prompt=function(){return i.open({templateUrl:"confirm_disable.html",controller:"disablePromptController",controllerAs:"dc",resolve:{users:function(){return[{user_name:a.setup_data.user}]},mode:function(){return"disableSelected"}}}).result.then((function(e){if(void 0!==e)return r.disableFor(e).then((function(e){var r=Object.keys(e.failed);1===r.length&&o.error(t.maketext("The system failed to remove two-factor authentication for “[_1]”.",r[0])),1===e.users_modified.length&&(o.success(t.maketext("The system successfully removed two-factor authentication for “[_1]”.",e.users_modified[0])),a.isEnabled=!1)})).catch((function(e){o.error(e)}))}))}}])})),define("app/index",["angular","jquery","cjt/core","cjt/modules","ngRoute","uiBootstrap"],(function(e,t,r){return function(){return e.module("App",["cjt2.config.whm.configProvider","ngRoute","ui.bootstrap","angular-growl","cjt2.whm"]),require(["cjt/bootstrap","app/services/tfaData","angular-growl","app/views/disablePromptController","app/views/usersController","app/views/enableController","app/views/configController","app/views/setupController"],(function(t){var o=e.module("App");o.value("PAGE",PAGE),o.config(["$routeProvider",function(e){e.when("/config",{controller:"configController",controllerAs:"cc",templateUrl:r.buildFullPath("twofactorauth/views/configView.ptt")}),e.when("/users",{controller:"usersController",controllerAs:"uc",templateUrl:r.buildFullPath("twofactorauth/views/usersView.ptt")}),e.when("/myaccount",{controller:"setupController",controllerAs:"setup",templateUrl:r.buildFullPath("twofactorauth/views/setupView.ptt")}),e.otherwise({redirectTo:"/config"})}]),o.run(["$rootScope","$timeout","$location","TwoFactorData","growl","growlMessages",function(e,t,r,o,n,s){e.$on("$routeChangeStart",(function(){e.currentRoute=r.path()}))}]),t()}))}}));
Back to Directory File Manager