").append(f).html(),v="data:image/svg+xml;base64,"+window.btoa(unescape(encodeURIComponent(h))),y=angular.element("
").attr({src:v,title:e.data});"true"===r.round&&y.css("border-radius","50%"),"true"===r.border&&y.css("border",r.borderStyle),r.class&&y.addClass(r.class),"true"===r.dynamic?(t.empty(),t.append(y)):t.replaceWith(y)}"true"===r.dynamic?e.$watch("data",function(){o()}):o()}}}),angular.module("bit.directives").directive("masterPassword",["cryptoService","authService",function(e,t){return{require:"ngModel",restrict:"A",link:function(n,r,o,a){t.getUserProfile().then(function(t){a.$parsers.unshift(function(n){if(n)return e.makeKey(n,t.email).then(function(t){var r=t.keyB64===e.getKey().keyB64;return a.$setValidity("masterPassword",r),r?n:void 0})}),a.$formatters.unshift(function(n){if(n)return e.makeKey(n,t.email).then(function(t){var r=t.keyB64===e.getKey().keyB64;return a.$setValidity("masterPassword",r),n})})})}}}]),angular.module("bit.directives").directive("pageTitle",["$rootScope","$timeout","appSettings",function(e,t,n){return{link:function(n,r){e.$on("$stateChangeStart",function(e,n,o,a,i){var s="Bitwarden Web Vault";n.data&&n.data.pageTitle&&(s=n.data.pageTitle+" - "+s),t(function(){r.text(s)})})}}}]),angular.module("bit.directives").directive("passwordMeter",function(){return{template:'
',restrict:"A",scope:{password:"=passwordMeter",username:"=passwordMeterUsername",outerClass:"@?"},link:function(e){var t=function(e){e.value=function(e,t){if(!t||t===e)return 0;var n=t.length;return e&&""!==e&&(-1!==e.indexOf(t)&&(n-=15),-1!==t.indexOf(e)&&(n-=e.length)),t.length>0&&t.length<=4?n+=t.length:t.length>=5&&t.length<=7?n+=6:t.length>=8&&t.length<=15?n+=12:t.length>=16&&(n+=18),t.match(/[a-z]/)&&(n+=1),t.match(/[A-Z]/)&&(n+=5),t.match(/\d/)&&(n+=5),t.match(/.*\d.*\d.*\d/)&&(n+=5),t.match(/[!,@,#,$,%,^,&,*,?,_,~]/)&&(n+=5),t.match(/.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~]/)&&(n+=5),t.match(/(?=.*[a-z])(?=.*[A-Z])/)&&(n+=2),t.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/)&&(n+=2),t.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!,@,#,$,%,^,&,*,?,_,~])/)&&(n+=2),n=Math.round(2*n),Math.max(0,Math.min(100,n))}(e.username,e.password),e.valueClass=function(e){switch(Math.round(e/33)){case 0:case 1:return"danger";case 2:return"warning";case 3:return"success"}}(e.value)};e.$watch("password",function(){t(e)}),e.$watch("username",function(){t(e)})}}}),angular.module("bit.directives").directive("passwordViewer",function(){return{restrict:"A",link:function(e,t,n){var r=n.passwordViewer;r&&(t.onclick=function(e){},t.on("click",function(e){var n=$(r);n&&"password"===n.attr("type")?(t.removeClass("fa-eye").addClass("fa-eye-slash"),n.attr("type","text")):n&&"text"===n.attr("type")&&(t.removeClass("fa-eye-slash").addClass("fa-eye"),n.attr("type","password"))}))}}}),angular.module("bit.directives").directive("stopClick",function(){return function(e,t,n){$(t).click(function(e){e.preventDefault()})}}),angular.module("bit.directives").directive("stopProp",function(){return function(e,t,n){$(t).click(function(e){e.stopPropagation()})}}),angular.module("bit.directives").directive("totp",["$timeout","$q",function(e,t){return{template:'
',restrict:"A",scope:{key:"=totp"},link:function(n){var r=null,o=new function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=function(e,t,n){return t+1>=e.length&&(e=Array(t+1-e.length).join(n)+e),e},r=function(e){return parseInt(e,16)},o=function(e){for(var t=new Uint8Array(e.length/2),n=0;n
>>4).toString(16)),n.push((15&t[r]).toString(16));return n.join("")}(e)}).catch(function(e){return null})};this.getCode=function(e){var s,l=Math.round((new Date).getTime()/1e3),c=n(((s=Math.floor(l/30))<15.5?"0":"")+Math.round(s).toString(16),16,"0"),u=o(c),d=a(e);return d.length&&u.length?i(d,u).then(function(e){if(!e)return null;var t=r(e.substring(e.length-1)),n=(r(e.substr(2*t,8))&r("7fffffff"))+"";return n=n.substr(n.length-6,6)}):t(function(e,t){e(null)})}},a=function(t){o.getCode(t.key).then(function(n){e(function(){n?(t.codeFormatted=n.substring(0,3)+" "+n.substring(3),t.code=n):(t.code=null,r&&clearInterval(r))})})},i=function(t){e(function(){var e=Math.round((new Date).getTime()/1e3)%30,n=30-e;t.sec=n,t.dash=(2.62*e).toFixed(2),t.low=n<=7,0===e&&a(t)})};n.$watch("key",function(){if(!n.key)return n.code=null,void(r&&clearInterval(r));a(n),i(n),r&&clearInterval(r),r=setInterval(function(){i(n)},1e3)}),n.$on("$destroy",function(){r&&clearInterval(r)}),n.clipboardError=function(e){alert("Your web browser does not support easy clipboard copying.")}}}}]),angular.module("bit.global").controller("mainController",["$scope","$state","authService","appSettings","toastr","$window","$document","cryptoService","$uibModal","apiService",function(e,t,n,r,o,a,i,s,l,c){var u,d,p,m=this;m.skinClass=r.selfHosted?"skin-blue-light":"skin-blue",m.bodyClass="",m.usingControlSidebar=m.openControlSidebar=!1,m.searchVaultText=null,m.version=r.version,m.outdatedBrowser=-1!==a.navigator.userAgent.indexOf("MSIE")||-1!==a.navigator.userAgent.indexOf("SamsungBrowser"),e.currentYear=(new Date).getFullYear(),e.$on("$viewContentLoaded",function(){n.getUserProfile().then(function(e){m.userProfile=e}),$.AdminLTE&&($.AdminLTE.layout&&($.AdminLTE.layout.fix(),$.AdminLTE.layout.fixSidebar()),$.AdminLTE.pushMenu&&$.AdminLTE.pushMenu.expandOnHover(),i.off("click",".sidebar li a"))}),e.$on("$stateChangeSuccess",function(e,t,n,r,o){m.usingEncKey=!!s.getEncKey(),m.searchVaultText=null,t.data.bodyClass?m.bodyClass=t.data.bodyClass:(m.bodyClass="",m.usingControlSidebar=!!t.data.controlSidebar,m.openControlSidebar=m.usingControlSidebar&&i.width()>768)}),e.addCipher=function(){e.$broadcast("vaultAddCipher")},e.addFolder=function(){e.$broadcast("vaultAddFolder")},e.addOrganizationCipher=function(){e.$broadcast("organizationVaultAddCipher")},e.addOrganizationCollection=function(){e.$broadcast("organizationCollectionsAdd")},e.inviteOrganizationUser=function(){e.$broadcast("organizationPeopleInvite")},e.addOrganizationGroup=function(){e.$broadcast("organizationGroupsAdd")},e.updateKey=function(){l.open({animation:!0,templateUrl:"app/settings/views/settingsUpdateKey.html",controller:"settingsUpdateKeyController"})},e.verifyEmail=function(){e.sendingVerify||(e.sendingVerify=!0,c.accounts.verifyEmail({},null).$promise.then(function(){o.success("Verification email sent."),e.sendingVerify=!1,e.verifyEmailSent=!0}).catch(function(){o.success("Verification email failed."),e.sendingVerify=!1}))},e.updateBrowser=function(){a.open("https://browser-update.org/update.html","_blank")};var g={scrollbarWidth:function(){if(!u){var e=$("body");e.addClass("bit-position-body-scrollbar-measure"),u=a.innerWidth-e[0].clientWidth,u=isFinite(u)?u:0,e.removeClass("bit-position-body-scrollbar-measure")}return u},scrollbarInfo:function(){return{width:g.scrollbarWidth(),visible:i.height()>$(a).height()}}};$(window).on("show.bs.dropdown",function(e){var t=p=$(e.target),n=t.data("appendTo");if(!n)return!0;d=t.find(".dropdown-menu"),$(n).append(d.detach());var r=t.offset(),o={display:"block",top:r.top+t.outerHeight()-("body"!==n?$(window).scrollTop():0)};if(d.hasClass("dropdown-menu-right")){var i=g.scrollbarInfo(),s=0;i.visible&&i.width&&(s=i.width),o.right=a.innerWidth-s-(r.left+t.prop("offsetWidth"))+"px",o.left="auto"}else o.left=r.left+"px",o.right="auto";d.css(o)}),$(window).on("hide.bs.dropdown",function(e){if(!d)return!0;$(e.target).append(d.detach()),d.hide(),d=null,p=null}),e.$on("removeAppendedDropdownMenu",function(e,t){if(!d&&!p)return!0;p.append(d.detach()),d.hide(),d=null,p=null})}]),angular.module("bit.global").controller("paidOrgRequiredController",["$scope","$state","$uibModalInstance","$analytics","$uibModalStack","orgId","constants","authService",function(e,t,n,r,o,a,i,s){r.eventTrack("paidOrgRequiredController",{category:"Modal"}),s.getUserProfile().then(function(t){e.admin=t.organizations[a].type!==i.orgUserType.user}),e.go=function(){e.admin&&(r.eventTrack("Get Paid Org"),t.go("backend.org.billing",{orgId:a}).then(function(){o.dismissAll()}))},e.close=function(){n.dismiss("close")}}]),angular.module("bit.global").controller("premiumRequiredController",["$scope","$state","$uibModalInstance","$analytics","$uibModalStack",function(e,t,n,r,o){r.eventTrack("premiumRequiredController",{category:"Modal"}),e.go=function(){r.eventTrack("Get Premium"),t.go("backend.user.settingsPremium").then(function(){o.dismissAll()})},e.close=function(){n.dismiss("close")}}]),angular.module("bit.global").controller("sideNavController",["$scope","$state","authService","toastr","$analytics","constants","appSettings",function(e,t,n,r,o,a,i){e.$state=t,e.params=t.params,e.orgs=[],e.name="",i.selfHosted?(e.orgIconBgColor="#ffffff",e.orgIconBorder="3px solid #a0a0a0",e.orgIconTextColor="#333333"):(e.orgIconBgColor="#2c3b41",e.orgIconBorder="3px solid #1a2226",e.orgIconTextColor="#ffffff"),n.getUserProfile().then(function(n){if(e.name=n.extended&&n.extended.name?n.extended.name:n.email,n.organizations)if(t.includes("backend.org")&&t.params.orgId in n.organizations)e.orgProfile=n.organizations[t.params.orgId];else{var r=[];for(var o in n.organizations)n.organizations.hasOwnProperty(o)&&(n.organizations[o].enabled||n.organizations[o].type<2)&&r.push(n.organizations[o]);e.orgs=r}}),e.viewOrganization=function(e){e.type!==a.orgUserType.user?(o.eventTrack("View Organization From Side Nav"),t.go("backend.org.dashboard",{orgId:e.id})):r.error("You cannot manage this organization.")},e.isOrgOwner=function(e){return e&&e.type===a.orgUserType.owner}}]),angular.module("bit.global").controller("topNavController",["$scope",function(e){e.toggleControlSidebar=function(){var e=$("body");e.hasClass("control-sidebar-open")?e.removeClass("control-sidebar-open"):e.addClass("control-sidebar-open")}}]),angular.module("bit.filters").filter("enumLabelClass",function(){return function(e,t){if("number"!=typeof e)return e.toString();var n;switch(t){case"OrgUserStatus":switch(e){case 0:n="label-default";break;case 1:n="label-warning";break;case 2:default:n="label-success"}break;default:n="label-default"}return n}}),angular.module("bit.filters").filter("enumName",function(){return function(e,t){if("number"!=typeof e)return e.toString();var n;switch(t){case"OrgUserStatus":switch(e){case 0:n="Invited";break;case 1:n="Accepted";break;case 2:default:n="Confirmed"}break;case"OrgUserType":switch(e){case 0:n="Owner";break;case 1:n="Admin";break;case 2:default:n="User"}break;default:n=e.toString()}return n}}),angular.module("bit.organization").controller("organizationBillingAdjustSeatsController",["$scope","$state","$uibModalInstance","apiService","$analytics","toastr","add",function(e,t,n,r,o,a,i){o.eventTrack("organizationBillingAdjustSeatsController",{category:"Modal"}),e.add=i,e.seatAdjustment=0,e.submit=function(){var s={seatAdjustment:e.seatAdjustment};i||(s.seatAdjustment*=-1),e.submitPromise=r.organizations.putSeat({id:t.params.orgId},s).$promise.then(function(t){i?(o.eventTrack("Added Seats"),a.success("You have added "+e.seatAdjustment+" seats.")):(o.eventTrack("Removed Seats"),a.success("You have removed "+e.seatAdjustment+" seats.")),n.close()})},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationBillingAdjustStorageController",["$scope","$state","$uibModalInstance","apiService","$analytics","toastr","add",function(e,t,n,r,o,a,i){o.eventTrack("organizationBillingAdjustStorageController",{category:"Modal"}),e.add=i,e.storageAdjustment=0,e.submit=function(){var s={storageGbAdjustment:e.storageAdjustment};i||(s.storageGbAdjustment*=-1),e.submitPromise=r.organizations.putStorage({id:t.params.orgId},s).$promise.then(function(t){i?(o.eventTrack("Added Organization Storage"),a.success("You have added "+e.storageAdjustment+" GB.")):(o.eventTrack("Removed Organization Storage"),a.success("You have removed "+e.storageAdjustment+" GB.")),n.close()})},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationBillingChangePaymentController",["$scope","$state","$uibModalInstance","apiService","$analytics","toastr","existingPaymentMethod",function(e,t,n,r,o,a,i){o.eventTrack("organizationBillingChangePaymentController",{category:"Modal"}),e.existingPaymentMethod=i,e.paymentMethod="card",e.showPaymentOptions=!0,e.hidePaypal=!0,e.card={},e.bank={},e.changePaymentMethod=function(t){e.paymentMethod=t},e.submit=function(){var s=null;if("card"===e.paymentMethod)s=stripe.card.createToken(e.card);else{if("bank"!==e.paymentMethod)return;e.bank.currency="USD",e.bank.country="US",s=stripe.bankAccount.createToken(e.bank)}e.submitPromise=s.then(function(e){var n={paymentToken:e.id};return r.organizations.putPayment({id:t.params.orgId},n).$promise},function(e){throw e.message}).then(function(t){e.card=null,i?(o.eventTrack("Changed Organization Payment Method"),a.success("You have changed your payment method.")):(o.eventTrack("Added Organization Payment Method"),a.success("You have added a payment method.")),n.close()})},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationBillingChangePlanController",["$scope","$state","apiService","$uibModalInstance","toastr","$analytics",function(e,t,n,r,o,a){a.eventTrack("organizationBillingChangePlanController",{category:"Modal"}),e.submit=function(){},e.close=function(){r.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationBillingController",["$scope","apiService","$state","$uibModal","toastr","$analytics","appSettings","tokenService","$window",function(e,t,n,r,o,a,i,s,l){e.selfHosted=i.selfHosted,e.charges=[],e.paymentSource=null,e.plan=null,e.subscription=null,e.loading=!0;function c(){t.organizations.getBilling({id:n.params.orgId},function(t){e.loading=!1,e.noSubscription=0===t.PlanType,e.canAdjustSeats=t.PlanType>1;var n=0;if(e.expiration=t.Expiration,t.License,e.plan={name:t.Plan,type:t.PlanType,seats:t.Seats},e.storage=null,e&&t.MaxStorageGb&&(e.storage={currentGb:t.StorageGb||0,maxGb:t.MaxStorageGb,currentName:t.StorageName||"0 GB"},e.storage.percentage=+(e.storage.currentGb/e.storage.maxGb*100).toFixed(2)),e.subscription=null,t.Subscription&&(e.subscription={trialEndDate:t.Subscription.TrialEndDate,cancelledDate:t.Subscription.CancelledDate,status:t.Subscription.Status,cancelled:t.Subscription.Cancelled,markedForCancel:!t.Subscription.Cancelled&&t.Subscription.CancelAtEndDate}),e.nextInvoice=null,t.UpcomingInvoice&&(e.nextInvoice={date:t.UpcomingInvoice.Date,amount:t.UpcomingInvoice.Amount}),t.Subscription&&t.Subscription.Items)for(e.subscription.items=[],n=0;n=s},e.submit=function(i){var s=o.encryptCollection(i,t.params.orgId);if(e.useGroups)for(var l in s.groups=[],e.selectedGroups)if(e.selectedGroups.hasOwnProperty(l))for(var c=0;c0&&(n[0].name=t.name)})},e.users=function(e){r.open({animation:!0,templateUrl:"app/organization/views/organizationCollectionsUsers.html",controller:"organizationCollectionsUsersController",size:"lg",resolve:{collection:function(){return e}}}).result.then(function(){})},e.groups=function(e){r.open({animation:!0,templateUrl:"app/organization/views/organizationCollectionsGroups.html",controller:"organizationCollectionsGroupsController",resolve:{collection:function(){return e}}}).result.then(function(){})},e.delete=function(r){confirm("Are you sure you want to delete this collection ("+r.name+")?")&&n.collections.del({orgId:t.params.orgId,id:r.id},function(){var t=e.collections.indexOf(r);t>-1&&e.collections.splice(t,1),s.eventTrack("Deleted Collection"),i.success(r.name+" has been deleted.","Collection Deleted")},function(){i.error(r.name+" was not able to be deleted.","Error")})}}]),angular.module("bit.organization").controller("organizationCollectionsEditController",["$scope","$state","$uibModalInstance","apiService","cipherService","$analytics","id","authService",function(e,t,n,r,o,a,i,s){a.eventTrack("organizationCollectionsEditController",{category:"Modal"});var l=0;e.collection={},e.groups=[],e.selectedGroups={},e.loading=!0,e.useGroups=!1,n.opened.then(function(){return r.collections.getDetails({orgId:t.params.orgId,id:i}).$promise}).then(function(t){e.collection=o.decryptCollection(t);var n={};if(t.Groups)for(var r=0;r=l},e.submit=function(s){var l=o.encryptCollection(s,t.params.orgId);if(e.useGroups)for(var c in l.groups=[],e.selectedGroups)if(e.selectedGroups.hasOwnProperty(c))for(var u=0;u-1&&e.users.splice(t,1)},function(){s.error("Unable to remove user.","Error")})},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationDashboardController",["$scope","authService","$state","appSettings",function(e,t,n,r){e.selfHosted=r.selfHosted,e.$on("$viewContentLoaded",function(){t.getUserProfile().then(function(t){t.organizations&&(e.orgProfile=t.organizations[n.params.orgId])})}),e.goBilling=function(){n.go("backend.org.billing",{orgId:n.params.orgId})}}]),angular.module("bit.organization").controller("organizationDeleteController",["$scope","$state","apiService","$uibModalInstance","cryptoService","authService","toastr","$analytics",function(e,t,n,r,o,a,i,s){s.eventTrack("organizationDeleteController",{category:"Modal"}),e.submit=function(){e.submitPromise=o.hashPassword(e.masterPassword).then(function(e){return n.organizations.del({id:t.params.orgId},{masterPasswordHash:e}).$promise}).then(function(){return r.dismiss("cancel"),a.removeProfileOrganization(t.params.orgId),s.eventTrack("Deleted Organization"),t.go("backend.user.vault")}).then(function(){i.success("This organization and all associated data has been deleted.","Organization Deleted")})},e.close=function(){r.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationEventsController",["$scope","$state","apiService","$uibModal","$filter","toastr","$analytics","constants","eventService","$compile","$sce",function(e,t,n,r,o,a,i,s,l,c,u){e.events=[],e.orgUsers=[],e.loading=!0,e.continuationToken=null;var d=l.getDefaultDateFilters();e.filterStart=d.start,e.filterEnd=d.end,e.$on("$viewContentLoaded",function(){n.organizationUsers.list({orgId:t.params.orgId}).$promise.then(function(t){var n=[];for(p=0;p"+o.message+"")(e);n.push({message:u.trustAsHtml(a[0].outerHTML),appIcon:o.appIcon,appName:o.appName,userId:r,userName:r&&m[r]||"-",date:t.Data[p].Date,ip:t.Data[p].IpAddress})}e.events&&e.events.length>0?e.events=e.events.concat(n):e.events=n,e.loading=!1});alert(o.error)}}]),angular.module("bit.organization").controller("organizationGroupsAddController",["$scope","$state","$uibModalInstance","apiService","cipherService","$analytics",function(e,t,n,r,o,a){a.eventTrack("organizationGroupsAddController",{category:"Modal"}),e.collections=[],e.selectedCollections={},e.loading=!0,n.opened.then(function(){return r.collections.listOrganization({orgId:t.params.orgId}).$promise}).then(function(n){e.collections=o.decryptCollections(n.Data,t.params.orgId,!0),e.loading=!1}),e.toggleCollectionSelectionAll=function(t){var n={};if(t.target.checked)for(var r=0;r0&&(n[0].name=t.name)})},e.users=function(e){r.open({animation:!0,templateUrl:"app/organization/views/organizationGroupsUsers.html",controller:"organizationGroupsUsersController",size:"lg",resolve:{group:function(){return e}}}).result.then(function(){})},e.delete=function(r){confirm("Are you sure you want to delete this group ("+r.name+")?")&&n.groups.del({orgId:t.params.orgId,id:r.id},function(){var t=e.groups.indexOf(r);t>-1&&e.groups.splice(t,1),i.eventTrack("Deleted Group"),a.success(r.name+" has been deleted.","Group Deleted")},function(){a.error(r.name+" was not able to be deleted.","Error")})}}]),angular.module("bit.organization").controller("organizationGroupsEditController",["$scope","$state","$uibModalInstance","apiService","cipherService","$analytics","id",function(e,t,n,r,o,a,i){a.eventTrack("organizationGroupsEditController",{category:"Modal"}),e.collections=[],e.selectedCollections={},e.loading=!0,n.opened.then(function(){return r.groups.getDetails({orgId:t.params.orgId,id:i}).$promise}).then(function(n){e.group={id:i,name:n.Name,externalId:n.ExternalId,accessAll:n.AccessAll};var o={};if(n.Collections)for(var a=0;a-1&&e.users.splice(t,1)},function(){i.error("Unable to remove user.","Error")})},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationPeopleController",["$scope","$state","$uibModal","cryptoService","apiService","authService","toastr","$analytics","$filter","$uibModalStack",function(e,t,n,r,o,a,i,s,l,c){function u(){o.organizationUsers.list({orgId:t.params.orgId},function(n){for(var r=[],o=0;o-1&&e.users.splice(t,1)},function(){i.error("Unable to remove user.","Error")})},e.confirm=function(e){o.users.getPublicKey({id:e.userId},function(n){var a=r.getOrgKey(t.params.orgId);if(a){var l=r.rsaEncrypt(a.key,n.PublicKey);o.organizationUsers.confirm({orgId:t.params.orgId,id:e.id},{key:l},function(){e.status=2,s.eventTrack("Confirmed User"),i.success(e.email+" has been confirmed.","User Confirmed")},function(){i.error("Unable to confirm user.","Error")})}else i.error("Unable to confirm user.","Error")},function(){i.error("Unable to confirm user.","Error")})},e.$on("organizationPeopleInvite",function(t,n){e.invite()}),e.invite=function(){n.open({animation:!0,templateUrl:"app/organization/views/organizationPeopleInvite.html",controller:"organizationPeopleInviteController"}).result.then(function(){u()})},e.edit=function(e){n.open({animation:!0,templateUrl:"app/organization/views/organizationPeopleEdit.html",controller:"organizationPeopleEditController",resolve:{orgUser:function(){return e}}}).result.then(function(){u()})},e.groups=function(e){n.open({animation:!0,templateUrl:"app/organization/views/organizationPeopleGroups.html",controller:"organizationPeopleGroupsController",resolve:{orgUser:function(){return e}}}).result.then(function(){})},e.events=function(e){n.open({animation:!0,templateUrl:"app/organization/views/organizationPeopleEvents.html",controller:"organizationPeopleEventsController",resolve:{orgUser:function(){return e},orgId:function(){return t.params.orgId}}})}}]),angular.module("bit.organization").controller("organizationPeopleEditController",["$scope","$state","$uibModalInstance","apiService","cipherService","orgUser","$analytics",function(e,t,n,r,o,a,i){i.eventTrack("organizationPeopleEditController",{category:"Modal"}),e.loading=!0,e.collections=[],e.selectedCollections={},n.opened.then(function(){r.collections.listOrganization({orgId:t.params.orgId},function(n){e.collections=o.decryptCollections(n.Data,t.params.orgId,!0),e.loading=!1}),r.organizationUsers.get({orgId:t.params.orgId,id:a.id},function(t){var n={};if(t&&t.Collections)for(var r=0;r"+o.message+"")(e);n.push({message:l.trustAsHtml(i[0].outerHTML),appIcon:o.appIcon,appName:o.appName,date:t.Data[r].Date,ip:t.Data[r].IpAddress})}e.events&&e.events.length>0?e.events=e.events.concat(n):e.events=n,e.loading=!1});alert(o.error)}e.filterStart=c.start,e.filterEnd=c.end,n.opened.then(function(){u(!0)}),e.refresh=function(){u(!0)},e.next=function(){u(!1)},e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationPeopleGroupsController",["$scope","$state","$uibModalInstance","apiService","orgUser","$analytics",function(e,t,n,r,o,a){a.eventTrack("organizationPeopleGroupsController",{category:"Modal"}),e.loading=!0,e.groups=[],e.selectedGroups={},e.orgUser=o,n.opened.then(function(){return r.groups.listOrganization({orgId:t.params.orgId}).$promise}).then(function(n){for(var a=[],i=0;i=t?e:new Array(t-e.length+1).join(n)+e}i.eventTrack("organizationSettingsExportController",{category:"Modal"}),e.export=function(n){e.startedExport=!0;var u=[],d=[],p=t.collections.listOrganization({orgId:s.params.orgId},function(e){d=r.decryptCollections(e.Data,s.params.orgId,!0)}).$promise,m=t.ciphers.listOrganizationDetails({organizationId:s.params.orgId},function(e){u=r.decryptCiphers(e.Data)}).$promise;o.all([p,m]).then(function(){if(!u.length)return a.error("Nothing to export.","Error!"),void e.close();var t,n={};for(t=0;t "Tools" > "Export".')},{id:"lastpass",name:"LastPass (csv)",featured:!0,sort:2,instructions:l.trustAsHtml('See detailed instructions on our help site at https://help.bitwarden.com/article/import-from-lastpass/')}],e.setSource=function(){for(var t=0;t-1&&e.cipher.login.uris.splice(n,1)}},e.uriMatchChanged=function(e){!e.matchValue&&0!==e.matchValue||""===e.matchValue?e.match=null:e.match=parseInt(e.matchValue)},e.addField=function(){e.cipher.fields||(e.cipher.fields=[]),e.cipher.fields.push({type:u.fieldType.text.toString(),name:null,value:null})},e.removeField=function(t){var n=e.cipher.fields.indexOf(t);n>-1&&e.cipher.fields.splice(n,1)},e.clipboardSuccess=function(e){e.clearSelection(),p(e)},e.clipboardError=function(e,t){t&&p(e),alert("Your web browser does not support easy clipboard copying. Copy it manually instead.")},e.close=function(){n.dismiss("close")},e.showUpgrade=function(){c.open({animation:!0,templateUrl:"app/views/paidOrgRequired.html",controller:"paidOrgRequiredController",resolve:{orgId:function(){return l}}})}}]),angular.module("bit.organization").controller("organizationVaultAttachmentsController",["$scope","apiService","$uibModalInstance","cryptoService","cipherService","cipherId","$analytics","validationService","toastr","$timeout",function(e,t,n,r,o,a,i,s,l,c){i.eventTrack("organizationVaultAttachmentsController",{category:"Modal"}),e.cipher={},e.loading=!0,e.isPremium=!0,e.canUseAttachments=!0;var u=!1;t.ciphers.getAdmin({id:a},function(t){e.cipher=o.decryptCipher(t),e.loading=!1},function(){e.loading=!1}),e.save=function(c){var d=document.getElementById("file").files;if(d&&d.length){var p=r.getOrgKey(e.cipher.organizationId);e.savePromise=o.encryptAttachmentFile(p,d[0]).then(function(e){var n=new FormData,r=new Blob([e.data],{type:"application/octet-stream"});return n.append("data",r,e.fileName),t.ciphers.postAttachmentAdmin({id:a},n).$promise}).then(function(e){i.eventTrack("Added Attachment"),l.success("The attachment has been added."),u=!0,n.close(!0)},function(e){var t=s.parseErrors(e);l.error(t.length?t[0]:"An error occurred.")})}else s.addError(c,"file","Select a file.",!0)},e.download=function(t){t.loading=!0;var n=r.getOrgKey(e.cipher.organizationId);o.downloadAndDecryptAttachment(n,t,!0).then(function(e){c(function(){t.loading=!1})},function(){c(function(){t.loading=!1})})},e.remove=function(n){confirm("Are you sure you want to delete this attachment ("+n.fileName+")?")&&(n.loading=!0,t.ciphers.delAttachmentAdmin({id:a,attachmentId:n.id}).$promise.then(function(){n.loading=!1,i.eventTrack("Deleted Organization Attachment");var t=e.cipher.attachments.indexOf(n);t>-1&&e.cipher.attachments.splice(t,1)},function(){l.error("Cannot delete attachment."),n.loading=!1}))},e.close=function(){n.dismiss("cancel")},e.$on("modal.closing",function(t,r,o){u||(t.preventDefault(),u=!0,n.close(!!e.cipher.attachments&&e.cipher.attachments.length>0))})}]),angular.module("bit.organization").controller("organizationVaultCipherCollectionsController",["$scope","apiService","$uibModalInstance","cipherService","cipher","$analytics","collections",function(e,t,n,r,o,a,i){a.eventTrack("organizationVaultCipherCollectionsController",{category:"Modal"}),e.cipher={},e.collections=[],e.selectedCollections={},n.opened.then(function(){for(var t=[],n=0;n0?e.events=e.events.concat(n):e.events=n,e.loading=!1});alert(o.error)}e.close=function(){n.dismiss("cancel")}}]),angular.module("bit.organization").controller("organizationVaultController",["$scope","apiService","cipherService","$analytics","$q","$state","$localStorage","$uibModal","$filter","authService","$uibModalStack","constants","$timeout",function(e,t,n,r,o,a,i,s,l,c,u,d,p){function m(){e.selectedCollection=void 0,e.selectedType=void 0,e.selectedAll=!1}function g(){$.AdminLTE&&$.AdminLTE.layout&&p(function(){$.AdminLTE.layout.fix()},0)}e.ciphers=[],e.collections=[],e.loading=!0,e.useEvents=!1,e.constants=d,e.filter=void 0,e.selectedType=void 0,e.selectedCollection=void 0,e.selectedAll=!0,e.selectedTitle="All",e.selectedIcon="fa-th",e.$on("$viewContentLoaded",function(){c.getUserProfile().then(function(t){if(t.organizations){var n=t.organizations[a.params.orgId];e.useEvents=!!n.useEvents}});var r=t.collections.listOrganization({orgId:a.params.orgId},function(t){for(var r=[{id:null,name:"Unassigned"}],o=0;o-1&&(n.data.collectionIds=e.ciphers[r].collectionIds,e.ciphers[r]=n.data):"delete"===n.action&&(r=e.ciphers.indexOf(t))>-1&&e.ciphers.splice(r,1)})},e.$on("organizationVaultAddCipher",function(t,n){e.addCipher()}),e.addCipher=function(){s.open({animation:!0,templateUrl:"app/vault/views/vaultAddCipher.html",controller:"organizationVaultAddCipherController",resolve:{orgId:function(){return a.params.orgId},selectedType:function(){return e.selectedType}}}).result.then(function(t){e.ciphers.push(t)})},e.editCollections=function(t){s.open({animation:!0,templateUrl:"app/organization/views/organizationVaultCipherCollections.html",controller:"organizationVaultCipherCollectionsController",resolve:{cipher:function(){return t},collections:function(){return e.collections}}}).result.then(function(e){e.collectionIds&&(t.collectionIds=e.collectionIds)})},e.viewEvents=function(e){s.open({animation:!0,templateUrl:"app/organization/views/organizationVaultCipherEvents.html",controller:"organizationVaultCipherEventsController",resolve:{cipher:function(){return e}}})},e.attachments=function(e){c.getUserProfile().then(function(t){return!!t.organizations[e.organizationId].maxStorageGb}).then(function(t){t?s.open({animation:!0,templateUrl:"app/vault/views/vaultAttachments.html",controller:"organizationVaultAttachmentsController",resolve:{cipherId:function(){return e.id}}}).result.then(function(t){e.hasAttachments=t}):s.open({animation:!0,templateUrl:"app/views/paidOrgRequired.html",controller:"paidOrgRequiredController",resolve:{orgId:function(){return e.organizationId}}})})},e.deleteCipher=function(n){confirm("Are you sure you want to delete this item ("+n.name+")?")&&t.ciphers.delAdmin({id:n.id},function(){r.eventTrack("Deleted Cipher");var t=e.ciphers.indexOf(n);t>-1&&e.ciphers.splice(t,1)})},e.filterCollection=function(t){m(),e.selectedCollection=t,e.selectedIcon="fa-cube",e.filter=function(e){return e.collectionIds&&e.collectionIds.indexOf(t.id)>-1},g()},e.filterType=function(t){switch(m(),e.selectedType=t,t){case d.cipherType.login:e.selectedTitle="Login",e.selectedIcon="fa-globe";break;case d.cipherType.card:e.selectedTitle="Card",e.selectedIcon="fa-credit-card";break;case d.cipherType.identity:e.selectedTitle="Identity",e.selectedIcon="fa-id-card-o";break;case d.cipherType.secureNote:e.selectedTitle="Secure Note",e.selectedIcon="fa-sticky-note-o"}e.filter=function(e){return e.type===t},g()},e.filterAll=function(){m(),e.selectedAll=!0,e.selectedTitle="All",e.selectedIcon="fa-th",e.filter=null,g()},e.cipherFilter=function(){return function(t){return!e.filter||e.filter(t)}}}]),angular.module("bit.organization").controller("organizationVaultEditCipherController",["$scope","apiService","$uibModalInstance","cryptoService","cipherService","passwordService","cipherId","$analytics","orgId","$uibModal","constants",function(e,t,n,r,o,a,i,s,l,c,u){function d(e){var t=$(e.trigger).parent().prev();"text"===t.attr("type")&&t.select()}s.eventTrack("organizationVaultEditCipherController",{category:"Modal"}),e.cipher={},e.hideFolders=e.hideFavorite=e.fromOrg=!0,e.constants=u,t.ciphers.getAdmin({id:i},function(t){e.cipher=o.decryptCipher(t),e.useTotp=e.cipher.organizationUseTotp,function(){if(e.cipher.login&&e.cipher.login.uris)for(var t=0;t-1&&e.cipher.login.uris.splice(n,1)}},e.uriMatchChanged=function(e){!e.matchValue&&0!==e.matchValue||""===e.matchValue?e.match=null:e.match=parseInt(e.matchValue)},e.addField=function(){e.cipher.login.fields||(e.cipher.login.fields=[]),e.cipher.fields.push({type:u.fieldType.text.toString(),name:null,value:null})},e.removeField=function(t){var n=e.cipher.fields.indexOf(t);n>-1&&e.cipher.fields.splice(n,1)},e.clipboardSuccess=function(e){e.clearSelection(),d(e)},e.clipboardError=function(e,t){t&&d(e),alert("Your web browser does not support easy clipboard copying. Copy it manually instead.")},e.delete=function(){confirm("Are you sure you want to delete this item ("+e.cipher.name+")?")&&t.ciphers.delAdmin({id:e.cipher.id},function(){s.eventTrack("Deleted Organization Cipher From Edit"),n.close({action:"delete",data:e.cipher.id})})},e.close=function(){n.dismiss("cancel")},e.showUpgrade=function(){c.open({animation:!0,templateUrl:"app/views/paidOrgRequired.html",controller:"paidOrgRequiredController",resolve:{orgId:function(){return l}}})}}]),angular.module("bit.tools").controller("reportsBreachController",["$scope","apiService","toastr","authService",function(e,t,n,r){e.loading=!0,e.error=!1,e.breachAccounts=[],e.email=null,e.$on("$viewContentLoaded",function(){r.getUserProfile().then(function(n){return e.email=n.email,t.hibp.get({email:e.email}).$promise}).then(function(t){for(var n=[],r=0;r0,meta:{},icon:null};switch(r.type){case o.cipherType.login:r.subTitle=s.decryptProperty(t.Login.Username,n,!0,!0),r.meta.password=s.decryptProperty(t.Login.Password,n,!0,!0),r.meta.uri=null,t.Login.Uris&&t.Login.Uris.length&&(r.meta.uri=s.decryptProperty(t.Login.Uris[0].Uri,n,!0,!0)),function(e,t,n){if(!s.disableWebsiteIcons&&t){var r=t,o=!1;if(0===r.indexOf("androidapp://")?e.icon="fa-android":0===r.indexOf("iosapp://")?e.icon="fa-apple":-1===r.indexOf("://")&&r.indexOf(".")>-1?(r="http://"+r,o=!0):o=0===r.indexOf("http")&&r.indexOf(".")>-1,n&&o)try{var i=new URL(r);e.meta.image=a.iconsUri+"/"+i.hostname+"/icon.png"}catch(e){}}e.icon||(e.icon="fa-globe")}(r,r.meta.uri,!0);break;case o.cipherType.secureNote:r.subTitle=null,r.icon="fa-sticky-note-o";break;case o.cipherType.card:r.subTitle="",r.meta.number=s.decryptProperty(t.Card.Number,n,!0,!0);var i=s.decryptProperty(t.Card.Brand,n,!0,!0);i&&(r.subTitle=i),r.meta.number&&r.meta.number.length>=4&&(""!==r.subTitle&&(r.subTitle+=", "),r.subTitle+="*"+r.meta.number.substr(r.meta.number.length-4)),r.icon="fa-credit-card";break;case o.cipherType.identity:var l=s.decryptProperty(t.Identity.FirstName,n,!0,!0),c=s.decryptProperty(t.Identity.LastName,n,!0,!0);r.subTitle="",l&&(r.subTitle=l),c&&(""!==r.subTitle&&(r.subTitle+=" "),r.subTitle+=c),r.icon="fa-id-card-o"}return""===r.subTitle&&(r.subTitle=null),r},s.decryptAttachment=function(t,n){if(!n)throw"encryptedAttachment is undefined or null";return{id:n.Id,url:n.Url,fileName:e.decrypt(n.FileName,t),size:n.SizeName}},s.downloadAndDecryptAttachment=function(t,o,a){var i=n.defer(),s=new XMLHttpRequest;return s.open("GET",o.url,!0),s.responseType="arraybuffer",s.onload=function(n){s.response?e.decryptFromBytes(s.response,t).then(function(e){if(a){var t=new Blob([e]);if(r.navigator.msSaveOrOpenBlob)r.navigator.msSaveBlob(t,o.fileName);else{var n=r.document.createElement("a");n.href=r.URL.createObjectURL(t),n.download=o.fileName,r.document.body.appendChild(n),n.click(),r.document.body.removeChild(n)}}i.resolve(new Uint8Array(e))}):i.reject("No response")},s.send(null),i.promise},s.decryptFields=function(e,t){var n=[];if(t)for(var r=0;r104857600)){var a=new FileReader;return a.readAsArrayBuffer(r),a.onload=function(n){e.encryptToBytes(n.target.result,t).then(function(n){o.resolve({fileName:e.encrypt(r.name,t),data:new Uint8Array(n),size:r.size})})},a.onerror=function(e){o.reject("Error reading file.")},o.promise}o.reject("Maximum file size is 100 MB.")},s.encryptFields=function(e,t){if(!e||!e.length)return null;for(var n=[],r=0;r2)if(!h(forge.util.decode64(a[2]),g(l+c,n.macKey,!1)))return console.error("MAC failed."),null;var d=forge.util.createBuffer(c),p=forge.cipher.createDecipher("AES-CBC",n.encKey);return p.start({iv:l}),p.update(d),p.finish(),"utf8"===(r=r||"utf8")?p.output.toString("utf8"):p.output.getBytes()}catch(e){throw console.error("Caught unhandled error in decrypt: "+e),e}},u.decryptFromBytes=function(e,n){try{if(!e)throw"no encBuf.";var r=new Uint8Array(e),o=r[0],a=null,i=null,s=null;switch(o){case t.encType.AesCbc128_HmacSha256_B64:case t.encType.AesCbc256_HmacSha256_B64:if(r.length<=49)return console.error("Enc type ("+o+") not valid."),null;i=w(r,1,17),s=w(r,17,49),a=w(r,49);break;case t.encType.AesCbc256_B64:if(r.length<=17)return console.error("Enc type ("+o+") not valid."),null;i=w(r,1,17),a=w(r,17);break;default:return console.error("Enc type ("+o+") not supported."),null}return function(e,t,n,r,o){if(!(o=o||u.getEncKey()||u.getKey()))throw"Encryption key unavailable.";if(o.macKey&&!r)throw"macBuf required for this type of key.";if(e!==o.encType)throw"encType unavailable.";var a=o.getBuffers(),i=null;return p.importKey("raw",a.encKey,{name:"AES-CBC"},!1,["decrypt"]).then(function(e){if(i=e,!o.macKey||!r)return null;var s=new Uint8Array(n.byteLength+t.byteLength);return s.set(new Uint8Array(n),0),s.set(new Uint8Array(t),n.byteLength),f(s.buffer,a.macKey)}).then(function(e){return null===e?null:(t=r,n=e,i=new Uint8Array(32),d.getRandomValues(i),window.crypto.subtle.importKey("raw",i.buffer,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]).then(function(e){return a=e,window.crypto.subtle.sign({name:"HMAC",hash:{name:"SHA-256"}},a,t)}).then(function(e){return o=e,window.crypto.subtle.sign({name:"HMAC",hash:{name:"SHA-256"}},a,n)}).then(function(e){if(o.byteLength!==e.byteLength)return!1;for(var t=new Uint8Array(o),n=new Uint8Array(e),r=0;r1&&!h(forge.util.decode64(a[1]),g(l,r.macKey,!1)))return console.error("MAC failed."),null;if(o===t.encType.Rsa2048_OaepSha256_B64||o===t.encType.Rsa2048_OaepSha256_HmacSha256_B64)s=forge.md.sha256.create();else{if(o!==t.encType.Rsa2048_OaepSha1_B64&&o!==t.encType.Rsa2048_OaepSha1_HmacSha256_B64)throw"encType unavailable.";s=forge.md.sha1.create()}return n.decrypt(l,"RSA-OAEP",{md:s})},v.prototype.getBuffers=function(){if(this.keyBuf)return this.keyBuf;var e=function(e){for(var t=r.atob(e),n=new Uint8Array(t.length),o=0;o"+t+"
":""+t+"
"}function o(e){var t=e.GroupId.substring(0,8);return'"+t+"
"}function a(e){var t=e.CollectionId.substring(0,8);return'"+t+"
"}function i(e){var t=e.OrganizationUserId.substring(0,8);return'"+t+"
"}return n.getDefaultDateFilters=function(){var e=new Date,t=new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59);return e.setDate(e.getDate()-30),{start:new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0),end:t}},n.formatDateFilters=function(e,n){var r={start:null,end:null,error:null};try{var o="yyyy-MM-ddTHH:mm";r.start=t("date")(e,o+"Z","UTC"),r.end=t("date")(n,o+":59.999Z","UTC")}catch(e){}return(!r.start||!r.end||r.endf+2&&(h.value=g[a].substr(f+2)),m.fields.push(h)}}}var v=t.type?t.type.toLowerCase():null;switch(v){case"login":case null:case void 0:m.type=e.cipherType.login;var y=t.login_totp||t.totp,b=l(t.login_uri||t.uri),w=t.login_username||t.username,C=t.login_password||t.password;m.login={totp:y&&""!==y?y:null,uris:s(b),username:w&&""!==w?w:null,password:C&&""!==C?C:null};break;case"note":m.type=e.cipherType.secureNote,m.secureNote={type:0}}if(r.push(m),p&&n.push({name:t.folder}),d){var S={key:u,value:c};o.push(S)}}),Y(n,r,o)}});break;case"lastpass":p(i,m,g,!1);break;case"safeincloudxml":!function(t,n,r){var o=[],a=[],i=[],l=[],c=0,u=0;d(t,function(t){var d=$(t).find("database");if(d.length){var p=d.find("> label");if(p.length)for(c=0;c card");if(g.length)for(c=0;c field");for(u=0;u200?h.notes+=C+": "+b+"\n":(h.fields||(h.fields=[]),h.fields.push({name:C,value:b,type:e.fieldType.text})))}}var S=f.find("> notes");for(u=0;u label_id")).length){var k=$(p[0]).text(),T=l[k];null!==k&&""!==k&&null!==T&&i.push({key:a.length-1,value:T})}}}n(o,a,i)}else r()},r)}(i,m,g);break;case"keepass2xml":!function(t,n,r){var o=[],a=[],i=[];d(t,function(t){var l=$(t).find("Root");if(l.length){var c=l.find("> Group");c.length&&(!function t(n,r,l){var c=o.length;var u=l;r||(""!==u&&(u+=" > "),u+=n.find("> Name").text(),o.push({name:u}));var d=n.find("> Entry");if(d.length)for(var p=0;p String"),v=0;v Key").text(),w=y.find("> Value").text();if(""!==w)switch(b){case"URL":f.login.uris=s(w);break;case"UserName":f.login.username=w;break;case"Password":f.login.password=w;break;case"Title":f.name=w;break;case"Notes":f.notes=null===f.notes?w+"\n":f.notes+w+"\n";break;default:w.length>200||w.indexOf("\n")>-1?(f.notes||(f.notes=""),f.notes+=b+": "+w+"\n"):(f.fields||(f.fields=[]),f.fields.push({name:b,value:w,type:e.fieldType.text}))}}null===f.name&&(f.name="--"),a.push(f),r||i.push({key:g,value:c})}var C=n.find("> Group");if(C.length)for(var S=0;S "):null,l=n.length,c=r.length,u=null!==i,d=u,p=0;if(u)for(p=0;p-1||l.length>200?(null===n.notes?n.notes="":n.notes+="\n",n.notes+=c+": "+l.split("\\r\\n").join("\n").split("\\n").join("\n")):(n.fields||(n.fields=[]),n.fields.push({name:c,value:l,type:e.fieldType.text}))}}}}u(t,function(t){var r=t.split(/(?:\r\n|\r|\n)/);for(i=0;i=6){var i=n.length,l=r.length,c=t[0]&&""!==t[0],u=c,d=0;if(c)for(d=0;d6)for(d=6;d200?(p.notes||(p.notes=""),p.notes+=t[d]+": "+t[d+1]+"\n"):(p.fields||(p.fields=[]),p.fields.push({name:t[d],value:t[d+1],type:e.fieldType.text}));if(r.push(p),u&&n.push({name:t[0]}),c){var m={key:l,value:i};o.push(m)}}}),D(n,r,o)}});break;case"passworddragonxml":!function(t,n,r){var o=[],a=[],i=[],l=0;d(t,function(t){var c=$(t).find("PasswordManager");if(c.length){var u=c.find("> record");if(u.length)for(var d=0;d Account-Name"),g=m.length?$(m):null,f=p.find("> User-Id"),h=f.length?$(f):null,v=p.find("> Password"),y=v.length?$(v):null,b=p.find("> URL"),w=b.length?$(b):null,C=p.find("> Notes"),S=C.length?$(C):null,k=p.find("> Category"),T=k.length?$(k):null,P=T?T.text():null,I=o.length,E=a.length,z=P&&""!==P&&"Unfiled"!==P,O=z;if(z)for(l=0;l Attribute-"+l,l<10&&(U+=", ");var x=p.find(U);if(x.length)for(l=0;l200?(A.notes||(A.notes=""),A.notes+=F+": "+M+"\n"):(A.fields||(A.fields=[]),A.fields.push({name:F,value:M,type:e.fieldType.text})))}if(a.push(A),O&&o.push({name:P}),z){var N={key:E,value:I};i.push(N)}}n(o,a,i)}else r()},r)}(i,m,g);break;case"enpasscsv":A=i,U=m,Papa.parse(A,{encoding:"UTF-8",complete:function(t){c(t);for(var n=[],r=0;r2&&o.length%2==0)for(var l=0;l200?(i.notes||(i.notes=""),i.notes+=d+": "+u+"\n"):(i.fields||(i.fields=[]),i.fields.push({name:d,value:u,type:e.fieldType.text})):i.login.totp=u:i.login.password=u:i.login.username=u:i.login.uris=s(u)}}n.push(i)}}U([],n,[])}});break;case"pwsafexml":!function(t,n,r){var o=[],a=[],i=[],l=0;d(t,function(t){var c=$(t).find("passwordsafe");if(c.length){var u=c.attr("delimiter"),d=c.find("> entry");if(d.length)for(var p=0;p title"),f=g.length?$(g):null,h=m.find("> username"),v=h.length?$(h):null,y=m.find("> email"),b=y.length?$(y):null,w=b?b.text():null,C=m.find("> password"),S=C.length?$(C):null,k=m.find("> url"),T=k.length?$(k):null,P=m.find("> notes"),I=P.length?$(P):null,E=I?I.text().split(u).join("\n"):null,z=m.find("> group"),O=z.length?$(z):null,A=O?O.text().split(".").join(" > "):null,U=o.length,x=a.length,D=A&&""!==A,F=D;if(D)for(l=0;l Groups > Group[ID="'+t+'"]');if(r.length){n&&""!==n&&(n=" > "+n),n=r.attr("Name")+n;var o=r.attr("ParentID");return c(e,o,n)}return n}d(t,function(t){var u=$(t).find("root > Database");if(u.length){var d=u.find("> Logins > Login");if(d.length)for(var p=0;p Accounts > Account > LoginLinks > Login[SourceLoginID="'+h+'"]');if(S.length){var k=S.parent().parent();k.length&&(v=k.attr("Name"),y=k.attr("Link"),w=k.attr("ParentID"),(b=k.attr("Comments"))&&(b=b.split("/n").join("\n")))}}w&&""!==w&&(C=c(u,w,""));var T=o.length,P=a.length,I=C&&""!==C,E=I;if(I)for(l=0;l=3){var i=n.length,l=r.length,c=t[0]&&""!==t[0]&&"Unassigned"!==t[0],u=c,d=0;if(c)for(d=0;d3)for(var m=3;m200?(r.notes||(r.notes=""),r.notes+=o+": "+t[o]+"\n"):(r.fields||(r.fields=[]),r.fields.push({name:o,value:t[o],type:e.fieldType.text})));T.push(r)}),S(k,T,[])}});break;case"clipperzhtml":!function(t,o,i){var l=[],c=[];u(t,function(t){var i=$(t).find("textarea"),u=i&&i.length?i.val():null,d=u?JSON.parse(u):null;if(d&&d.length)for(var p=0;p200?(g.notes||(g.notes=""),g.notes+=h.label+": "+h.value+"\n"):(g.fields||(g.fields=[]),g.fields.push({name:h.label,value:h.value,type:e.fieldType.text}))}}""===g.notes&&(g.notes=null),c.push(g)}o(l,c,[])},i)}(i,m,g);break;case"avirajson":!function(t,n,r){var o=[],a=[],i=0;u(t,function(t){var r=JSON.parse(t);if(r&&r.accounts)for(i=0;i").join("")).find("table.nobr");if(i.length)for(var u=0;u200?(p.notes||(p.notes=""),p.notes+=h+": "+v+"\n"):(p.fields||(p.fields=[]),p.fields.push({name:h,value:v,type:e.fieldType.text}))}p.notes&&""!==p.notes||(p.notes=null),p.name&&""!==p.name||(p.name="--"),c.push(p)}o(l,c,[])},i)}(i,m,g);break;case"saferpasscsv":!function(t,n,r){var o=[],a=[];Papa.parse(t,{header:!0,encoding:"UTF-8",complete:function(t){c(t),angular.forEach(t.data,function(t,n){var r,o;a.push({type:e.cipherType.login,favorite:!1,notes:t.notes&&""!==t.notes?t.notes:null,name:t.url&&""!==t.url?(r=t.url,o=document.createElement("a"),o.href=r,o.hostname.startsWith("www.")?o.hostname.replace("www.",""):o.hostname):"--",login:{uris:s(t.url),username:t.username&&""!==t.username?t.username:null,password:t.password&&""!==t.password?t.password:null}})}),n(o,a,[])}})}(i,m);break;case"ascendocsv":b=i,w=m,Papa.parse(b,{encoding:"UTF-8",complete:function(t){c(t);for(var i=[],l=0;l2&&u.length%2==0)for(var m=0;m200?(p.notes||(p.notes=""),p.notes+=f+": "+g+"\n"):(p.fields||(p.fields=[]),p.fields.push({name:f,value:g,type:e.fieldType.text})))}i.push(p)}}w([],i,[])}});break;case"passwordbossjson":!function(t,n,r){var o=[],a=[],i=0;u(t,function(t){var r=JSON.parse(t);if(r&&r.length)for(i=0;i200?(c.notes||(c.notes=""),c.notes+=u+": "+d+"\n"):(c.fields||(c.fields=[]),c.fields.push({name:u,value:d,type:e.fieldType.text}))}""===c.notes&&(c.notes=null),a.push(c)}}n(o,a,[])},r)}(i,m,g);break;case"zohovaultcsv":!function(t,n,r){function o(t,n){if(t&&""!==t)for(var r=t.split(/(?:\r\n|\r|\n)/),o=0;oi?a.substring(i+1):null;if(s&&""!==s&&l&&""!==l&&"SecretType"!==s){var c=s.toLowerCase();"user name"===c?n.login.username=l:"password"===c?n.login.password=l:l.length>200?(n.notes||(n.notes=""),n.notes+=s+": "+l+"\n"):(n.fields||(n.fields=[]),n.fields.push({name:s,value:l,type:e.fieldType.text}))}}}}Papa.parse(t,{header:!0,encoding:"UTF-8",complete:function(t){c(t);var r=[],a=[],i=[];angular.forEach(t.data,function(t,n){var l=t.ChamberName,c=r.length,u=a.length,d=l&&""!==l,p=d,m=0;if(d)for(m=0;m2&&a(2,l,b),b.name&&"--"!==b.name&&"Web Logins"!==p&&"Servers"!==p&&"Email Accounts"!==p&&(b.name=p+": "+b.name),""===b.notes&&(b.notes=null),r.push(b),h&&n.push({name:u}),f){var w={key:g,value:m};o.push(w)}}y(n,r,o)}});break;case"meldiumcsv":f=i,h=m,Papa.parse(f,{header:!0,encoding:"UTF-8",complete:function(t){c(t);for(var n=[],r=0;r30&&(m.name=m.name.substring(0,30)),p.attributes)p.attributes.hasOwnProperty(g)&&"username_value"!==g&&"xdg:schema"!==g&&(""!==m.notes&&(m.notes+="\n"),m.notes+=g+": "+p.attributes[g]);""===m.notes&&(m.notes=null),a.push(m),i.push({key:u,value:c})}}n(o,a,i)},r)}(i,m,g);break;default:g()}else g()},t.importOrg=function(t,n,r,o){var a,i;if(n)switch(t){case"bitwardencsv":a=n,i=r,Papa.parse(a,{header:!0,encoding:"UTF-8",complete:function(t){c(t);var n,r=[],o=[],a=[];angular.forEach(t.data,function(t,i){var c=o.length;if(t.collections&&""!==t.collections){var u=t.collections.split(",");for(n=0;nh+2&&(v.value=f[n].substr(h+2)),g.fields.push(v)}}}var y=t.type?t.type.toLowerCase():null;switch(y){case"login":case null:case void 0:g.type=e.cipherType.login;var b=t.login_totp||t.totp,w=l(t.login_uri||t.uri),C=t.login_username||t.username,S=t.login_password||t.password;g.login={totp:b&&""!==b?b:null,uris:s(w),username:C&&""!==C?C:null,password:S&&""!==S?S:null};break;case"note":g.type=e.cipherType.secureNote,g.secureNote={type:0}}o.push(g)}),i(r,o,a)}});break;case"lastpass":p(n,r,o,!0);break;default:o()}else o()};var n=["password","pass word","passphrase","pass phrase","pass","code","code word","codeword","secret","secret word","personpwd","key","keyword","key word","keyphrase","key phrase","form_pw","wppassword","pin","pwd","pw","pword","passwd","p","serial","serial#","license key","reg #","passwort"],r=["user","name","user name","username","login name","email","e-mail","id","userid","user id","login","form_loginname","wpname","mail","loginid","login id","log","personlogin","first name","last name","card#","account #","member","member #","nom","benutzername"],o=["url","hyper link","hyperlink","link","host","hostname","host name","server","address","hyper ref","href","web","website","web site","site","web-site","uri","ort","adresse"];function a(e,t){if(!e||""===e)return!1;e=e.trim().toLowerCase();for(var n=0;n=0&&(e="http://"+e),e.length>1e3?e.substring(0,1e3):e}function s(e){if(!e)return null;if("string"==typeof e)return[{uri:i(e),match:null}];if(e.length){for(var t=[],n=0;n-1||!a[1]||""===a[1]||("Notes"===a[0]?r.notes?r.notes+="\n"+a[1]:r.notes=a[1]:t.hasOwnProperty(a[0])?r.dataObj[t[a[0]]]=a[1]:(r.notes?r.notes+="\n":r.notes="",r.notes+=a[0]+": "+a[1]))}return r}function l(e){var t={cardholderName:e.ccname&&""!==e.ccname?e.ccname:null,number:e.ccnum&&""!==e.ccnum?e.ccnum:null,brand:e.ccnum&&""!==e.ccnum?function(e){if(!e)return null;var t=new RegExp("^4");return null!=e.match(t)?"Visa":/^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$/.test(e)?"Mastercard":(t=new RegExp("^3[47]"),null!=e.match(t)?"Amex":(t=new RegExp("^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)"),null!=e.match(t)?"Discover":(t=new RegExp("^36"),null!=e.match(t)?"Diners Club":(t=new RegExp("^30[0-5]"),null!=e.match(t)?"Diners Club":(t=new RegExp("^35(2[89]|[3-8][0-9])"),null!=e.match(t)?"JCB":(t=new RegExp("^(4026|417500|4508|4844|491(3|7))"),null!=e.match(t)?"Visa":null))))))}(e.ccnum):null,code:e.cccsc&&""!==e.cccsc?e.cccsc:null};if(e.ccexp&&""!==e.ccexp&&e.ccexp.indexOf("-")>-1){var n=e.ccexp.split("-");n.length>1&&(t.expYear=n[0],t.expMonth=n[1],2===t.expMonth.length&&"0"===t.expMonth[0]&&(t.expMonth=t.expMonth[1]))}return t}function u(t){var r=[],a=[],c=[],u=0;angular.forEach(t,function(t,n){var d,p=r.length,m=a.length,g=t.grouping&&""!==t.grouping&&"(none)"!==t.grouping,f=g;if(g)for(u=0;u1&&"NoteType"===y[0]&&("Credit Card"===y[1]||"Address"===y[1])){var b=null;"Credit Card"===y[1]?(b=i(h,{Number:"number","Name on Card":"cardholderName","Security Code":"code"},[]),d.type=e.cipherType.card,d.card=b.dataObj):"Address"===y[1]&&(b=i(h,{Title:"title","First Name":"firstName","Last Name":"lastName","Middle Name":"middleName",Company:"company","Address 1":"address1","Address 2":"address2","Address 3":"address3","City / Town":"city",State:"state","Zip / Postal Code":"postalCode",Country:"country","Email Address":"email",Username:"username"},[]),d.type=e.cipherType.identity,d.identity=b.dataObj),v=!0,d.notes=b.notes}}v||(d.secureNote={type:0},d.notes=t.extra&&""!==t.extra?t.extra:null)}else if(d.type===e.cipherType.card)d.card=l(t),d.notes=t.notes&&""!==t.notes?t.notes:null;else if(d.type===e.cipherType.identity&&(d.identity={title:t.title&&""!==t.title?t.title:null,firstName:t.firstname&&""!==t.firstname?t.firstname:null,middleName:t.middlename&&""!==t.middlename?t.middlename:null,lastName:t.lastname&&""!==t.lastname?t.lastname:null,username:t.username&&""!==t.username?t.username:null,company:t.company&&""!==t.company?t.company:null,ssn:t.ssn&&""!==t.ssn?t.ssn:null,address1:t.address1&&""!==t.address1?t.address1:null,address2:t.address2&&""!==t.address2?t.address2:null,address3:t.address3&&""!==t.address3?t.address3:null,city:t.city&&""!==t.city?t.city:null,state:t.state&&""!==t.state?t.state:null,postalCode:t.zip&&""!==t.zip?t.zip:null,country:t.country&&""!==t.country?t.country:null,email:t.email&&""!==t.email?t.email:null,phone:t.phone&&""!==t.phone?t.phone:null},d.notes=t.notes&&""!==t.notes?t.notes:null,d.identity.title&&(d.identity.title=d.identity.title.charAt(0).toUpperCase()+d.identity.title.slice(1)),t.ccnum&&""!==t.ccnum)){var w=JSON.parse(JSON.stringify(d));w.identity=null,w.type=e.cipherType.card,w.card=l(t),a.push(w)}if(a.push(d),f&&r.push({name:t.grouping}),g){var C={key:m,value:p};c.push(C)}}),n(r,a,c)}}return t}]),angular.module("bit.services").factory("passwordService",function(){var e={};function t(e,n){var r=0,o=n-e,a=Math.ceil(Math.log2(o));if(a>53)throw new Exception("We cannot generate numbers larger than 53 bits.");var i=Math.ceil(a/8),s=Math.pow(2,a)-1,l=new Uint8Array(i);window.crypto.getRandomValues(l);for(var c=8*(i-1),u=0;u=o?t(e,n):e+r}return e.generatePassword=function(e){var n=angular.extend({},{length:10,ambiguous:!1,number:!0,minNumber:1,uppercase:!0,minUppercase:1,lowercase:!0,minLowercase:1,special:!1,minSpecial:1},e);n.uppercase&&n.minUppercase<0&&(n.minUppercase=1),n.lowercase&&n.minLowercase<0&&(n.minLowercase=1),n.number&&n.minNumber<0&&(n.minNumber=1),n.special&&n.minSpecial<0&&(n.minSpecial=1),(!n.length||n.length<1)&&(n.length=10);var r=n.minUppercase+n.minLowercase+n.minNumber+n.minSpecial;n.length0)for(var a=0;a0)for(var i=0;i0)for(var s=0;s0)for(var l=0;l=0?e.deviceType.vivaldi:window.chrome&&window.chrome.webstore?e.deviceType.chrome:"undefined"!=typeof InstallTrigger?e.deviceType.firefox:window.opr&&opr.addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0?e.deviceType.firefox:/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString()?e.deviceType.opera:document.documentMode?e.deviceType.ie:window.StyleMedia?e.deviceType.edge:e.deviceType.unknown)},n}]),angular.module("bit.services").factory("validationService",function(){var e={addErrors:function(t,n){var r=n.data,o="An unexpected error has occurred.";if(t.$errors=[],r&&angular.isObject(r))if(r&&r.ErrorModel&&(r=r.ErrorModel),r.ValidationErrors){for(var a in r.ValidationErrors)if(r.ValidationErrors.hasOwnProperty(a))for(var i=0;i-1&&e.model.organizations.splice(n,1),o.success("You have left the organization."),c()})},function(e){o.error("Unable to leave this organization."),c()})},e.sessions=function(){n.open({animation:!0,templateUrl:"app/settings/views/settingsSessions.html",controller:"settingsSessionsController"})},e.delete=function(){n.open({animation:!0,templateUrl:"app/settings/views/settingsDelete.html",controller:"settingsDeleteController"})},e.purge=function(){n.open({animation:!0,templateUrl:"app/settings/views/settingsPurge.html",controller:"settingsPurgeController"})}}]),angular.module("bit.settings").controller("settingsCreateOrganizationController",["$scope","$state","apiService","cryptoService","toastr","$analytics","authService","constants","appSettings","validationService",function(e,t,n,r,o,a,i,s,l,c){e.plans=s.plans,e.storageGb=s.storageGb,e.paymentMethod="card",e.selfHosted=l.selfHosted,e.model={plan:"free",additionalSeats:0,interval:"year",ownedBusiness:!1,additionalStorageGb:null},e.totalPrice=function(){return"month"===e.model.interval?(e.model.additionalSeats||0)*(e.plans[e.model.plan].monthlySeatPrice||0)+(e.model.additionalStorageGb||0)*e.storageGb.monthlyPrice+(e.plans[e.model.plan].monthlyBasePrice||0):(e.model.additionalSeats||0)*(e.plans[e.model.plan].annualSeatPrice||0)+(e.model.additionalStorageGb||0)*e.storageGb.yearlyPrice+(e.plans[e.model.plan].annualBasePrice||0)},e.changePaymentMethod=function(t){e.paymentMethod=t},e.changedPlan=function(){e.plans[e.model.plan].hasOwnProperty("monthPlanType")&&(e.model.interval="year"),e.plans[e.model.plan].noAdditionalSeats?e.model.additionalSeats=0:e.model.additionalSeats||e.plans[e.model.plan].baseSeats||e.plans[e.model.plan].noAdditionalSeats||(e.model.additionalSeats=1)},e.changedBusiness=function(){e.model.ownedBusiness&&(e.model.plan="teams")},e.submit=function(s,l){var u=r.makeShareKey(),d=r.encrypt("Default Collection",u.key);if(e.selfHosted){var p=document.getElementById("file").files;if(!p||!p.length)return void c.addError(l,"file","Select a license file.",!0);var m=new FormData;m.append("license",p[0]),m.append("key",u.ct),m.append("collectionName",d),e.submitPromise=n.organizations.postLicense(m).$promise.then(h)}else if("free"===s.plan){var g={name:s.name,planType:s.plan,key:u.ct,billingEmail:s.billingEmail,collectionName:d};e.submitPromise=n.organizations.post(g).$promise.then(h)}else{var f=null;if("card"===e.paymentMethod)f=stripe.card.createToken(s.card);else{if("bank"!==e.paymentMethod)return;s.bank.currency="USD",s.bank.country="US",f=stripe.bankAccount.createToken(s.bank)}e.submitPromise=f.then(function(t){var r={name:s.name,planType:"month"===s.interval?e.plans[s.plan].monthPlanType:e.plans[s.plan].annualPlanType,key:u.ct,paymentToken:t.id,additionalSeats:s.additionalSeats,additionalStorageGb:s.additionalStorageGb,billingEmail:s.billingEmail,businessName:s.ownedBusiness?s.businessName:null,country:"card"===e.paymentMethod?s.card.address_country:null,collectionName:d};return n.organizations.post(r).$promise},function(e){throw e.message}).then(h)}function h(e){a.eventTrack("Created Organization"),i.addProfileOrganizationOwner(e,u.ct),i.refreshAccessToken().then(function(){v(e.Id)},function(){v(e.Id)})}function v(e){t.go("backend.org.dashboard",{orgId:e}).then(function(){o.success("Your new organization is ready to go!","Organization Created")})}}}]),angular.module("bit.settings").controller("settingsDeleteController",["$scope","$state","apiService","$uibModalInstance","cryptoService","authService","toastr","$analytics","tokenService",function(e,t,n,r,o,a,i,s,l){s.eventTrack("settingsDeleteController",{category:"Modal"}),e.submit=function(c){var u;e.submitPromise=a.getUserProfile().then(function(e){return u=e,o.hashPassword(c.masterPassword)}).then(function(e){return n.accounts.postDelete({masterPasswordHash:e}).$promise}).then(function(){return r.dismiss("cancel"),a.logOut(),l.clearTwoFactorToken(u.email),s.eventTrack("Deleted Account"),t.go("frontend.login.info")}).then(function(){i.success("Your account has been closed and all associated data has been deleted.","Account Deleted")})},e.close=function(){r.dismiss("cancel")}}]),angular.module("bit.settings").controller("settingsDomainsController",["$scope","$state","apiService","toastr","$analytics","$uibModal",function(e,t,n,r,o,a){e.globalEquivalentDomains=[],e.equivalentDomains=[],n.settings.getDomains({},function(t){var n;if(t.EquivalentDomains)for(n=0;nBitwarden two-step login recovery code:
'+e.code+'