diff options
Diffstat (limited to 'apps/settings/js/vue-settings-personal-webauthn.js')
-rw-r--r-- | apps/settings/js/vue-settings-personal-webauthn.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/settings/js/vue-settings-personal-webauthn.js b/apps/settings/js/vue-settings-personal-webauthn.js index a9eac1fe072..d96d1399858 100644 --- a/apps/settings/js/vue-settings-personal-webauthn.js +++ b/apps/settings/js/vue-settings-personal-webauthn.js @@ -135,7 +135,7 @@ r.VTooltip.options.defaultTemplate='<div class="vue-tooltip" role="tooltip" data * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - */function v(){return(v=h(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Object(A.generateUrl)("/settings/api/personal/webauthn/registration"),e.next=3,d.a.get(t);case 3:return n=e.sent,e.abrupt("return",n.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(e,t){return y.apply(this,arguments)}function y(){return(y=h(regeneratorRuntime.mark((function e(t,n){var r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object(A.generateUrl)("/settings/api/personal/webauthn/registration"),e.next=3,d.a.post(r,{name:t,data:n});case 3:return o=e.sent,e.abrupt("return",o.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(e){return x.apply(this,arguments)}function x(){return(x=h(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Object(A.generateUrl)("/settings/api/personal/webauthn/registration/".concat(t)),e.next=3,d.a.delete(n);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function T(e){return function(e){if(Array.isArray(e))return _(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var E=function(e){return function(t){return p.debug(e),t}},M=Object.freeze({READY:1,REGISTRATION:2,NAMING:3,PERSIST:4}),C={name:"AddDevice",props:{httpWarning:Boolean,isHttps:{type:Boolean,default:!1}},data:function(){return{name:"",credential:{},RegistrationSteps:M,step:M.READY}},methods:{arrayToBase64String:function(e){return btoa(String.fromCharCode.apply(String,T(e)))},start:function(){var e=this;return this.step=M.REGISTRATION,console.debug("Starting WebAuthn registration"),s()().then(this.getRegistrationData).then(this.register.bind(this)).then((function(){e.step=M.NAMING})).catch((function(t){console.error(t.name,t.message),e.step=M.READY}))},getRegistrationData:function(){console.debug("Fetching webauthn registration data");return function(){return v.apply(this,arguments)}().then((function(e){return console.debug(e),e.challenge=Uint8Array.from(function(e){var t=(e=e.replace(/-/g,"+").replace(/_/g,"/")).length%4;if(t){if(1===t)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");e+=new Array(5-t).join("=")}return window.atob(e)}(e.challenge),(function(e){return e.charCodeAt(0)})),e.user.id=Uint8Array.from(e.user.id,(function(e){return e.charCodeAt(0)})),e})).catch((function(e){throw console.error("Error getting webauthn registration data from server",e),new Error(t("settings","Server error while trying to add WebAuthn device"))}))},register:function(e){var t=this;return console.debug("starting webauthn registration"),navigator.credentials.create({publicKey:e}).then((function(e){t.credential={id:e.id,type:e.type,rawId:t.arrayToBase64String(new Uint8Array(e.rawId)),response:{clientDataJSON:t.arrayToBase64String(new Uint8Array(e.response.clientDataJSON)),attestationObject:t.arrayToBase64String(new Uint8Array(e.response.attestationObject))}}}))},submit:function(){var e=this;return this.step=M.PERSIST,s()().then(E("confirmed password")).then(this.saveRegistrationData).then(E("registration data saved")).then((function(){return e.reset()})).then(E("app reset")).catch(console.error.bind(this))},saveRegistrationData:function(){var e,n=this;return(e=regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g(n.name,JSON.stringify(n.credential));case 3:r=e.sent,p.info("new device added",{device:r}),n.$emit("added",r),e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),p.error("Error persisting webauthn registration",{error:e.t0}),new Error(t("settings","Server error while trying to complete WebAuthn device registration"));case 12:case"end":return e.stop()}}),e,null,[[0,8]])})),function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,s,"next",e)}function s(e){w(i,r,o,a,s,"throw",e)}a(void 0)}))})()},reset:function(){this.name="",this.registrationData={},this.step=M.READY}}},S=(r(643),r(41)),I=Object(S.a)(C,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.isHttps?n("div",[e.step===e.RegistrationSteps.READY?n("div",[n("button",{on:{click:e.start}},[e._v("\n\t\t\t"+e._s(e.t("settings","Add WebAuthn device"))+"\n\t\t")])]):e.step===e.RegistrationSteps.REGISTRATION?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v("\n\t\t"+e._s(e.t("settings","Please authorize your WebAuthn device."))+"\n\t")]):e.step===e.RegistrationSteps.NAMING?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.name,expression:"name"}],attrs:{type:"text",placeholder:e.t("settings","Name your device")},domProps:{value:e.name},on:{":keyup":function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.submit(t)},input:function(t){t.target.composing||(e.name=t.target.value)}}}),e._v(" "),n("button",{on:{click:e.submit}},[e._v("\n\t\t\t"+e._s(e.t("settings","Add"))+"\n\t\t")])]):e.step===e.RegistrationSteps.PERSIST?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v("\n\t\t"+e._s(e.t("settings","Adding your device …"))+"\n\t")]):n("div",[e._v("\n\t\tInvalid registration step. This should not have happened.\n\t")])]):n("div",[e._v("\n\t"+e._s(e.t("settings","Passwordless authentication requires a secure connection."))+"\n")])}),[],!1,null,"35971b5e",null).exports,O=r(472),N=r.n(O),j=r(407),L={name:"Device",components:{ActionButton:r.n(j).a,Actions:N.a},props:{name:{type:String,required:!0}}},k=(r(645),Object(S.a)(L,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"webauthn-device"},[n("span",{staticClass:"icon-webauthn-device"}),e._v("\n\t"+e._s(e.name||e.t("settings","Unnamed device"))+"\n\t"),n("Actions",{attrs:{"force-menu":!0}},[n("ActionButton",{attrs:{icon:"icon-delete"},on:{click:function(t){return e.$emit("delete")}}},[e._v("\n\t\t\t"+e._s(e.t("settings","Delete"))+"\n\t\t")])],1)],1)}),[],!1,null,"187f22d4",null).exports);function B(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}var P=c()("name"),R={components:{AddDevice:I,Device:k},props:{initialDevices:{type:Array,required:!0},isHttps:{type:Boolean,default:!1},hasPublicKeyCredential:{type:Boolean,default:!1}},data:function(){return{devices:this.initialDevices}},computed:{sortedDevices:function(){return P(this.devices)}},methods:{deviceAdded:function(e){p.debug("adding new device to the list ".concat(e.id)),this.devices.push(e)},deleteDevice:function(e){var t,n=this;return(t=regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return p.info("deleting webauthn device ".concat(e)),t.next=3,s()();case 3:return t.next=5,b(e);case 5:n.devices=n.devices.filter((function(t){return t.id!==e})),p.info("webauthn device ".concat(e," removed successfully"));case 7:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(e){B(i,r,o,a,s,"next",e)}function s(e){B(i,r,o,a,s,"throw",e)}a(void 0)}))})()}}},D=Object(S.a)(R,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"section",attrs:{id:"security-webauthn"}},[n("h2",[e._v(e._s(e.t("settings","Passwordless Authentication")))]),e._v(" "),n("p",{staticClass:"settings-hint hidden-when-empty"},[e._v("\n\t\t"+e._s(e.t("settings","Set up your account for passwordless authentication following the FIDO2 standard."))+"\n\t")]),e._v(" "),0===e.devices.length?n("p",[e._v("\n\t\t"+e._s(e.t("twofactor_u2f","No devices configured."))+"\n\t")]):n("p",[e._v("\n\t\t"+e._s(e.t("twofactor_u2f","The following devices are configured for your account:"))+"\n\t")]),e._v(" "),e._l(e.sortedDevices,(function(t){return n("Device",{key:t.id,attrs:{name:t.name},on:{delete:function(n){return e.deleteDevice(t.id)}}})})),e._v(" "),e.hasPublicKeyCredential?e._e():n("p",{staticClass:"warning"},[e._v("\n\t\t"+e._s(e.t("settings","Your browser does not support WebAuthn."))+"\n\t")]),e._v(" "),e.hasPublicKeyCredential?n("AddDevice",{attrs:{"is-https":e.isHttps},on:{added:e.deviceAdded}}):e._e()],2)}),[],!1,null,"6b439c6d",null).exports; + */function v(){return(v=h(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Object(A.generateUrl)("/settings/api/personal/webauthn/registration"),e.next=3,d.a.get(t);case 3:return n=e.sent,e.abrupt("return",n.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(e,t){return y.apply(this,arguments)}function y(){return(y=h(regeneratorRuntime.mark((function e(t,n){var r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object(A.generateUrl)("/settings/api/personal/webauthn/registration"),e.next=3,d.a.post(r,{name:t,data:n});case 3:return o=e.sent,e.abrupt("return",o.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(e){return x.apply(this,arguments)}function x(){return(x=h(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Object(A.generateUrl)("/settings/api/personal/webauthn/registration/".concat(t)),e.next=3,d.a.delete(n);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function T(e){return function(e){if(Array.isArray(e))return _(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var E=function(e){return function(t){return p.debug(e),t}},M=Object.freeze({READY:1,REGISTRATION:2,NAMING:3,PERSIST:4}),C={name:"AddDevice",props:{httpWarning:Boolean,isHttps:{type:Boolean,default:!1}},data:function(){return{name:"",credential:{},RegistrationSteps:M,step:M.READY}},methods:{arrayToBase64String:function(e){return btoa(String.fromCharCode.apply(String,T(e)))},start:function(){var e=this;return this.step=M.REGISTRATION,console.debug("Starting WebAuthn registration"),s()().then(this.getRegistrationData).then(this.register.bind(this)).then((function(){e.step=M.NAMING})).catch((function(t){console.error(t.name,t.message),e.step=M.READY}))},getRegistrationData:function(){console.debug("Fetching webauthn registration data");return function(){return v.apply(this,arguments)}().then((function(e){return console.debug(e),e.challenge=Uint8Array.from(function(e){var t=(e=e.replace(/-/g,"+").replace(/_/g,"/")).length%4;if(t){if(1===t)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");e+=new Array(5-t).join("=")}return window.atob(e)}(e.challenge),(function(e){return e.charCodeAt(0)})),e.user.id=Uint8Array.from(e.user.id,(function(e){return e.charCodeAt(0)})),e})).catch((function(e){throw console.error("Error getting webauthn registration data from server",e),new Error(t("settings","Server error while trying to add WebAuthn device"))}))},register:function(e){var t=this;return console.debug("starting webauthn registration"),navigator.credentials.create({publicKey:e}).then((function(e){t.credential={id:e.id,type:e.type,rawId:t.arrayToBase64String(new Uint8Array(e.rawId)),response:{clientDataJSON:t.arrayToBase64String(new Uint8Array(e.response.clientDataJSON)),attestationObject:t.arrayToBase64String(new Uint8Array(e.response.attestationObject))}}}))},submit:function(){var e=this;return this.step=M.PERSIST,s()().then(E("confirmed password")).then(this.saveRegistrationData).then(E("registration data saved")).then((function(){return e.reset()})).then(E("app reset")).catch(console.error.bind(this))},saveRegistrationData:function(){var e,n=this;return(e=regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g(n.name,JSON.stringify(n.credential));case 3:r=e.sent,p.info("new device added",{device:r}),n.$emit("added",r),e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),p.error("Error persisting webauthn registration",{error:e.t0}),new Error(t("settings","Server error while trying to complete WebAuthn device registration"));case 12:case"end":return e.stop()}}),e,null,[[0,8]])})),function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,s,"next",e)}function s(e){w(i,r,o,a,s,"throw",e)}a(void 0)}))})()},reset:function(){this.name="",this.registrationData={},this.step=M.READY}}},S=(r(643),r(41)),I=Object(S.a)(C,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.isHttps?n("div",[e.step===e.RegistrationSteps.READY?n("div",[n("button",{on:{click:e.start}},[e._v("\n\t\t\t"+e._s(e.t("settings","Add WebAuthn device"))+"\n\t\t")])]):e.step===e.RegistrationSteps.REGISTRATION?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v("\n\t\t"+e._s(e.t("settings","Please authorize your WebAuthn device."))+"\n\t")]):e.step===e.RegistrationSteps.NAMING?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.name,expression:"name"}],attrs:{type:"text",placeholder:e.t("settings","Name your device")},domProps:{value:e.name},on:{":keyup":function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.submit(t)},input:function(t){t.target.composing||(e.name=t.target.value)}}}),e._v(" "),n("button",{on:{click:e.submit}},[e._v("\n\t\t\t"+e._s(e.t("settings","Add"))+"\n\t\t")])]):e.step===e.RegistrationSteps.PERSIST?n("div",{staticClass:"new-webauthn-device"},[n("span",{staticClass:"icon-loading-small webauthn-loading"}),e._v("\n\t\t"+e._s(e.t("settings","Adding your device …"))+"\n\t")]):n("div",[e._v("\n\t\tInvalid registration step. This should not have happened.\n\t")])]):n("div",[e._v("\n\t"+e._s(e.t("settings","Passwordless authentication requires a secure connection."))+"\n")])}),[],!1,null,"35971b5e",null).exports,O=r(472),N=r.n(O),j=r(407),L={name:"Device",components:{ActionButton:r.n(j).a,Actions:N.a},props:{name:{type:String,required:!0}}},k=(r(645),Object(S.a)(L,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"webauthn-device"},[n("span",{staticClass:"icon-webauthn-device"}),e._v("\n\t"+e._s(e.name||e.t("settings","Unnamed device"))+"\n\t"),n("Actions",{attrs:{"force-menu":!0}},[n("ActionButton",{attrs:{icon:"icon-delete"},on:{click:function(t){return e.$emit("delete")}}},[e._v("\n\t\t\t"+e._s(e.t("settings","Delete"))+"\n\t\t")])],1)],1)}),[],!1,null,"187f22d4",null).exports);function B(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}var P=c()("name"),R={components:{AddDevice:I,Device:k},props:{initialDevices:{type:Array,required:!0},isHttps:{type:Boolean,default:!1},hasPublicKeyCredential:{type:Boolean,default:!1}},data:function(){return{devices:this.initialDevices}},computed:{sortedDevices:function(){return P(this.devices)}},methods:{deviceAdded:function(e){p.debug("adding new device to the list ".concat(e.id)),this.devices.push(e)},deleteDevice:function(e){var t,n=this;return(t=regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return p.info("deleting webauthn device ".concat(e)),t.next=3,s()();case 3:return t.next=5,b(e);case 5:n.devices=n.devices.filter((function(t){return t.id!==e})),p.info("webauthn device ".concat(e," removed successfully"));case 7:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(e){B(i,r,o,a,s,"next",e)}function s(e){B(i,r,o,a,s,"throw",e)}a(void 0)}))})()}}},D=Object(S.a)(R,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"section",attrs:{id:"security-webauthn"}},[n("h2",[e._v(e._s(e.t("settings","Passwordless Authentication")))]),e._v(" "),n("p",{staticClass:"settings-hint hidden-when-empty"},[e._v("\n\t\t"+e._s(e.t("settings","Set up your account for passwordless authentication following the FIDO2 standard."))+"\n\t")]),e._v(" "),0===e.devices.length?n("p",[e._v("\n\t\t"+e._s(e.t("twofactor_u2f","No devices configured."))+"\n\t")]):n("p",[e._v("\n\t\t"+e._s(e.t("twofactor_u2f","The following devices are configured for your account:"))+"\n\t")]),e._v(" "),e._l(e.sortedDevices,(function(t){return n("Device",{key:t.id,attrs:{name:t.name},on:{delete:function(n){return e.deleteDevice(t.id)}}})})),e._v(" "),e.hasPublicKeyCredential?e._e():n("p",{staticClass:"warning"},[e._v("\n\t\t"+e._s(e.t("settings","Your browser does not support WebAuthn."))+"\n\t")]),e._v(" "),e.hasPublicKeyCredential?n("AddDevice",{attrs:{"is-https":e.isHttps},on:{added:e.deviceAdded}}):e._e()],2)}),[],!1,null,"6b439c6d",null).exports; /** * @copyright 2020, Roeland Jago Douma <roeland@famdouma.nl> * @@ -157,4 +157,4 @@ r.VTooltip.options.defaultTemplate='<div class="vue-tooltip" role="tooltip" data * along with this program. If not, see <http://www.gnu.org/licenses/>. */ r.nc=btoa(OC.requestToken),o.default.prototype.t=t,new(o.default.extend(D))({propsData:{initialDevices:Object(i.loadState)("settings","webauthn-devices"),isHttps:"https:"===window.location.protocol,hasPublicKeyCredential:void 0!==window.PublicKeyCredential}}).$mount("#security-webauthn")}]); -//# sourceMappingURL=vue-settings-personal-webauthn.js.map?v=a8ea1323e8f781c49c97
\ No newline at end of file +//# sourceMappingURL=vue-settings-personal-webauthn.js.map?v=3d51d164bcd0ac6aea32
\ No newline at end of file |