You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nextcloud-server/dist/settings-vue-settings-perso...

3 lines
40 KiB

/*! For license information please see settings-vue-settings-personal-webauthn.js.LICENSE.txt */
(()=>{var e,n={58220:(e,n,r)=>{"use strict";var i=r(85471),a=r(38613),o=r(56760),s=r(12256),l=(r(51257),r(10854)),c=r.n(l),u=r(54576);const d=(0,r(53529).YK)().setApp("settings").detectUser().build();var p=r(26287),h=r(99498),f=r(96763);const g=t=>e=>(d.debug(t),e),v=Object.freeze({READY:1,REGISTRATION:2,NAMING:3,PERSIST:4}),y={name:"AddDevice",components:{NcButton:u.A},props:{httpWarning:Boolean,isHttps:{type:Boolean,default:!1},isLocalhost:{type:Boolean,default:!1}},data:()=>({name:"",credential:{},RegistrationSteps:v,step:v.READY}),methods:{arrayToBase64String:t=>btoa(String.fromCharCode(...t)),start(){return this.step=v.REGISTRATION,f.debug("Starting WebAuthn registration"),(0,o.C)().then(this.getRegistrationData).then(this.register.bind(this)).then((()=>{this.step=v.NAMING})).catch((t=>{f.error(t.name,t.message),this.step=v.READY}))},getRegistrationData:()=>(f.debug("Fetching webauthn registration data"),async function(){const t=(0,h.Jv)("/settings/api/personal/webauthn/registration");return(await p.A.get(t)).data}().then((t=>(f.debug(t),t.challenge=Uint8Array.from(function(t){const e=(t=t.replace(/-/g,"+").replace(/_/g,"/")).length%4;if(e){if(1===e)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");t+=new Array(5-e).join("=")}return window.atob(t)}(t.challenge),(t=>t.charCodeAt(0))),t.user.id=Uint8Array.from(t.user.id,(t=>t.charCodeAt(0))),t))).catch((e=>{throw f.error("Error getting webauthn registration data from server",e),new Error(t("settings","Server error while trying to add WebAuthn device"))}))),register(t){return f.debug("starting webauthn registration"),navigator.credentials.create({publicKey:t}).then((t=>{this.credential={id:t.id,type:t.type,rawId:this.arrayToBase64String(new Uint8Array(t.rawId)),response:{clientDataJSON:this.arrayToBase64String(new Uint8Array(t.response.clientDataJSON)),attestationObject:this.arrayToBase64String(new Uint8Array(t.response.attestationObject))}}}))},submit(){return this.step=v.PERSIST,(0,o.C)().then(g("confirmed password")).then(this.saveRegistrationData).then(g("registration data saved")).then((()=>this.reset())).then(g("app reset")).catch(f.error.bind(this))},async saveRegistrationData(){try{const t=await async function(t,e){const n=(0,h.Jv)("/settings/api/personal/webauthn/registration");return(await p.A.post(n,{name:t,data:e})).data}(this.name,JSON.stringify(this.credential));d.info("new device added",{device:t}),this.$emit("added",t)}catch(e){throw d.error("Error persisting webauthn registration",{error:e}),new Error(t("settings","Server error while trying to complete WebAuthn device registration"))}},reset(){this.name="",this.registrationData={},this.step=v.READY}}};var m=r(85072),A=r.n(m),b=r(97825),w=r.n(b),x=r(77659),_=r.n(x),R=r(55056),I=r.n(R),W=r(10540),S=r.n(W),C=r(41113),O=r.n(C),E=r(22834),B={};B.styleTagTransform=O(),B.setAttributes=I(),B.insert=_().bind(null,"head"),B.domAPI=w(),B.insertStyleElement=S(),A()(E.A,B),E.A&&E.A.locals&&E.A.locals;var N=r(14486);const k=(0,N.A)(y,(function(){var t=this,e=t._self._c;return t.isHttps||t.isLocalhost?e("div",[t.step===t.RegistrationSteps.READY?e("div",[e("NcButton",{attrs:{type:"primary"},on:{click:t.start}},[t._v("\n\t\t\t"+t._s(t.t("settings","Add WebAuthn device"))+"\n\t\t")])],1):t.step===t.RegistrationSteps.REGISTRATION?e("div",{staticClass:"new-webauthn-device"},[e("span",{staticClass:"icon-loading-small webauthn-loading"}),t._v("\n\t\t"+t._s(t.t("settings","Please authorize your WebAuthn device."))+"\n\t")]):t.step===t.RegistrationSteps.NAMING?e("div",{staticClass:"new-webauthn-device"},[e("span",{staticClass:"icon-loading-small webauthn-loading"}),t._v(" "),e("input",{directives:[{name:"model",rawName:"v-model",value:t.name,expression:"name"}],attrs:{type:"text",placeholder:t.t("settings","Name your device")},domProps:{value:t.name},on:{":keyup":function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.submit.apply(null,arguments)},input:function(e){e.target.composing||(t.name=e.target.value)}}}),t._v(" "),e("NcButton",{att
//# sourceMappingURL=settings-vue-settings-personal-webauthn.js.map?v=6df584e134b178db4d1f