1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[277],{34833(e,t,a){a.d(t,{nc:()=>l,lW:()=>u,$e:()=>c,Rk:()=>d,pF:()=>s,D4:()=>m});var r=a(63228);async function s(){return(await r.FH.get("/api/user/passkey")).data}async function n(){return(await r.FH.post("/api/user/passkey/register/begin")).data}async function i(e){return(await r.FH.post("/api/user/passkey/register/finish",e)).data}async function o(){return(await r.FH.delete("/api/user/passkey")).data}async function l(){return(await r.FH.post("/api/user/passkey/login/begin")).data}async function c(e){return(await r.FH.post("/api/user/passkey/login/finish",e)).data}async function u(){return(await r.FH.post("/api/user/passkey/verify/begin")).data}async function d(e){return(await r.FH.post("/api/user/passkey/verify/finish",e)).data}var f=a(54958),y=a(65311),p=a(26028),h=a(96208);function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onStatusChange:t}=e,[a,r]=(0,y.useState)(null),[l,c]=(0,y.useState)(!0),[u,d]=(0,y.useState)(!1),[m,g]=(0,y.useState)(!1),[w,k]=(0,y.useState)(!1),v=(0,y.useCallback)(async()=>{try{c(!0);let e=await s();e.success?(r(e.data??null),t?.(e.data??null)):(r(null),p.oR.error(e.message||f.Ay.t("Failed to load Passkey status")))}catch(e){console.error("[Passkey] Failed to fetch status",e),p.oR.error(f.Ay.t("Failed to load Passkey status")),r(null)}finally{c(!1)}},[t]);(0,y.useEffect)(()=>{v()},[v]),(0,y.useEffect)(()=>{(0,h.TA)().then(k).catch(()=>k(!1))},[]);let b=(0,y.useCallback)(async()=>{if(!w)return p.oR.error(f.Ay.t("This device does not support Passkey")),!1;if(!navigator?.credentials)return p.oR.error(f.Ay.t("Passkey is not supported in this environment")),!1;d(!0);try{let e=await n();if(!e.success)return p.oR.error(e.message||f.Ay.t("Failed to start Passkey registration")),!1;let t=(0,h.az)(e.data?.options??e.data),a=await (0,h.GO)(t);if(!a)return p.oR.error(f.Ay.t("Passkey registration was cancelled")),!1;let r=(0,h.$i)(a);if(!r)return p.oR.error(f.Ay.t("Invalid Passkey registration response")),!1;let s=await i(r);if(!s.success)return p.oR.error(s.message||f.Ay.t("Failed to register Passkey")),!1;return p.oR.success(f.Ay.t("Passkey registered successfully")),await v(),!0}catch(e){if(e instanceof DOMException&&"NotAllowedError"===e.name)return p.oR.info(f.Ay.t("Passkey registration was cancelled")),!1;return console.error("[Passkey] Registration error",e),p.oR.error(e instanceof Error?e.message:f.Ay.t("Failed to register Passkey")),!1}finally{d(!1)}},[w,v]),A=(0,y.useCallback)(async()=>{g(!0);try{let e=await o();if(!e.success)return p.oR.error(e.message||f.Ay.t("Failed to remove Passkey")),!1;return p.oR.success(f.Ay.t("Passkey removed successfully")),await v(),!0}catch(e){return console.error("[Passkey] Removal error",e),p.oR.error(f.Ay.t("Failed to remove Passkey")),!1}finally{g(!1)}},[v]),x=(0,y.useMemo)(()=>!!a?.enabled,[a]),P=(0,y.useMemo)(()=>a?.last_used_at??null,[a]);return{status:a,loading:l,registering:u,removing:m,supported:w,enabled:x,lastUsed:P,fetchStatus:v,register:b,remove:A}}},88836(e,t,a){a.d(t,{x9:()=>C,Yu:()=>h});var r=a(63228),s=a(96208),n=a(34833);async function i(){try{let[e,t,a]=await Promise.all([(0,r.sv)(),(0,n.pF)(),(0,s.TA)()]),i=!!e?.success&&!!e?.data?.enabled,o=!!t?.success&&!!t?.data?.enabled;return{has2FA:i,hasPasskey:o,passkeySupported:a}}catch(e){return console.error("[Secure Verification] Failed to check methods",e),{has2FA:!1,hasPasskey:!1,passkeySupported:!1}}}async function o(e,t){switch(e){case"2fa":return l(t);case"passkey":return c();default:throw Error(`Unsupported verification method: ${e}`)}}async function l(e){let t=e?.trim();if(!t)throw Error("Please enter the verification code or backup code");let a=await r.FH.post("/api/verify",{method:"2fa",code:t});if(!a.data?.success)throw Error(a.data?.message||"Verification failed")}async function c(){if("u"<typeof navigator||!navigator.credentials)throw Error("Passkey verification is not supported in this environment");try{let e=await (0,n.lW)();if(!e.success)throw Error(e.message||"Failed to start verification");let t=(0,s.ig)(e.data?.options??e.data),a=await navigator.credentials.get({publicKey:t});if(!a)throw Error("Passkey verification was cancelled");let i=(0,s.Il)(a);if(!i)throw Error("Unable to build Passkey assertion");let o=await (0,n.Rk)(i);if(!o.success)throw Error(o.message||"Passkey verification failed");let l=await r.FH.post("/api/verify",{method:"passkey"});if(!l.data?.success)throw Error(l.data?.message||"Failed to complete verification")}catch(e){if(e instanceof DOMException&&"NotAllowedError"===e.name)throw Error("Passkey verification was cancelled or timed out",{cause:e});if(e instanceof DOMException&&"InvalidStateError"===e.name)throw Error("Passkey verification is not available in the current state",{cause:e});throw e}}var u=a(54958),d=a(65311),f=a(26028);let y={has2FA:!1,hasPasskey:!1,passkeySupported:!1},p={method:null,loading:!1,code:"",title:void 0,description:void 0,apiCall:null};function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onSuccess:t,onError:a,successMessage:r,autoReset:s=!0}=e,[n,l]=(0,d.useState)(y),[c,h]=(0,d.useState)(p),[m,g]=(0,d.useState)(!1),w=(0,d.useCallback)(async()=>{let e=await i();return l(e),e},[]);(0,d.useEffect)(()=>{w()},[w]);let k=(0,d.useCallback)(()=>{h(p),g(!1)},[]),v=(0,d.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{preferredMethod:r,title:s,description:n}=t,i=await w();if(!i.has2FA&&!i.hasPasskey)return f.oR.error(u.Ay.t("Please enable Two-factor Authentication or Passkey before proceeding")),a?.(Error("No verification methods available. Enable 2FA or Passkey to continue.")),!1;let o=r??null;return!o&&(i.hasPasskey&&i.passkeySupported?o="passkey":i.has2FA&&(
1o="2fa")),h(t=>({...t,apiCall:e,method:o,title:s,description:n})),g(!0),!0},[w,a]),b=(0,d.useCallback)(async(e,n)=>{if(!c.apiCall)return void f.oR.error(u.Ay.t("Verification is not configured properly"));let i=e??c.method;if(!i)return void f.oR.error(u.Ay.t("Select a verification method first"));h(e=>({...e,loading:!0}));try{await o(i,n??c.code);let e=await c.apiCall();return r&&f.oR.success(r),t?.(e,i),s&&k(),e}catch(t){let e=t instanceof Error?t.message:u.Ay.t("Verification failed");throw f.oR.error(e),a?.(t),t}finally{h(e=>({...e,loading:!1}))}},[c,r,t,a,s,k]),A=(0,d.useCallback)(e=>{h(t=>({...t,code:e}))},[]),x=(0,d.useCallback)(e=>{h(t=>({...t,method:e,code:""}))},[]),P=(0,d.useCallback)(()=>{k()},[k]),C=(0,d.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await e()}catch(a){if(function(e){if(!e||"object"!=typeof e||403!==e.response?.status)return!1;let t=e.response?.data?.code;return!!t&&new Set(["VERIFICATION_REQUIRED","VERIFICATION_EXPIRED","VERIFICATION_INVA
1LID"]).has(t)}(a)){let r={code:a.response?.data?.code,message:a.response?.data?.message??"Secure verification is required",required:!0};return f.oR.info(r.message),await v(e,t),null}throw a}},[v]),E=(0,d.useCallback)(e=>"2fa"===e?n.has2FA:"passkey"===e&&n.hasPasskey&&n.passkeySupported,[n]),F=(0,d.useMemo)(()=>n.hasPasskey&&n.passkeySupported?"passkey":n.has2FA?"2fa":null,[n]);return{open:m,setOpen:g,methods:n,state:c,startVerification:v,executeVerification:b,cancel:P,reset:k,setCode:A,switchMethod:x,withVerification:C,fetchVerificationMethods:w,canUseMethod:E,recommendedMethod:F,hasAnyMethod:n.has2FA||n.hasPasskey,isLoading:c.loading,currentMethod:c.method,code:c.code}}var m=a(79015),g=a(26464),w=a(70326),k=a(68758),v=a(89077),b=a(31155),A=a(73178),x=a(62724),P=a(60106);function C(e){let{open:t,onOpenChange:a,methods:r,state:s,onVerify:n,onCancel:i,onCodeChange:o,onMethodChange:l}=e,{t:c}=(0,v.Bd)(),u=(0,d.useMemo)(()=>{let e=[];return r.has2FA&&e.push("2fa"),r.hasPasskey&&r.passkeySupported&&e.push("passkey"),e},[r]),f=s.method??(u.length>0?u[0]:null),y=s.title??(u.length?"Additional verification required":"Verification unavailable"),p=s.description??(u.length?"Confirm your identity before accessing this sensitive action.":"Enable Two-factor Authentication or Passkey in your profile settings to continue."),h=()=>{if(!f)return;let e="2fa"===f?s.code:void 0;n(f,e)},C=s.loading||"2fa"===f&&(!s.code.trim()||s.code.length<6);return(0,m.jsx)(b.l,{open:t,onOpenChange:a,title:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(g.A,{className:"text-primary h-5 w-5"}),y]}),description:p,contentClassName:"top-[8vh] max-w-[calc(100%-1.5rem)] translate-y-0 overflow-hidden border-none shadow-xl sm:top-1/2 sm:max-w-md sm:translate-y-[-50%] sm:rounded-xl",headerClassName:"border-b pb-4 text-left",titleClassName:"flex items-center gap-2 text-lg font-semibold",descriptionClassName:"text-left",contentHeight:"auto",bodyClassName:"px-1 py-1",showCloseButton:!s.loading,footerClassName:"bg-muted/30 border-t px-6 py-4 sm:flex-row sm:justify-end",footer:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(A.$,{type:"button",variant:"outline",disabled:s.loading,onClick:i,children:c("Cancel")}),(0,m.jsxs)(A.$,{type:"button",onClick:h,disabled:0===u.length||C,children:[s.loading&&(0,m.jsx)(w.A,{className:"h-4 w-4 animate-spin"}),c("Verify")]})]}),children:0===u.length?(0,m.jsxs)("div",{className:"grid place-items-center gap-4 text-center",children:[(0,m.jsx)("div",{className:"bg-muted flex h-16 w-16 items-center justify-center rounded-2xl",children:(0,m.jsx)(g.A,{className:"text-muted-foreground h-8 w-8"})}),(0,m.jsx)("p",{className:"text-muted-foreground text-sm",children:c("Enable Two-factor Authentication or Passkey in your profile to unlock sensitive operations.")})]}):(0,m.jsxs)(P.tU,{value:f??u[0],onValueChange:e=>l(e),className:"gap-4",children:[(0,m.jsxs)(P.j7,{children:[r.has2FA&&(0,m.jsx)(P.Xi,{value:"2fa",children:c("Authenticator code")}),r.hasPasskey&&r.passkeySupported&&(0,m.jsx)(P.Xi,{value:"passkey",children:c("Passkey")})]}),(0,m.jsxs)(P.av,{value:"2fa",className:"space-y-3",children:[(0,m.jsx)("p",{className:"text-muted-foreground text-sm",children:c("Enter the 6-digit Time-based One-Time Password or 8-character backup code from your authenticator app.")}),(0,m.jsx)(x.p,{inputMode:"numeric",maxLength:8,value:s.code,onChange:e=>o(e.target.value),placeholder:c("Enter verification code"),disabled:s.loading,autoFocus:"2fa"===f,onKeyDown:e=>{"Enter"!==e.key||C||(e.preventDefault(),h())}})]}),(0,m.jsxs)(P.av,{value:"passkey",className:"space-y-4",children:[(0,m.jsx)("div",{className:"bg-muted/50 flex items-center justify-center rounded-lg p-4",children:(0,m.jsxs)("div",{className:"text-muted-foreground flex items-center gap-3",children:[(0,m.jsx)(k.A,{className:"text-primary h-6 w-6"}),(0,m.jsxs)("div",{className:"text-left text-sm",children:[(0,m.jsx)("p",{className:"text-foreground font-medium",children:c("Use your Passkey")}),(0,m.jsx)("p",{children:c("We will prompt your device to confirm using biometrics or your hardware key.")})]})]})}),!r.passkeySupported&&(0,m.jsx)("p",{className:"text-destructive text-sm",children:c("This device does not support Passkey verification.")})]})]})})}},96208(e,t,a){function r(e){if(!e)return new ArrayBuffer(0);let t="=".repeat((4-e.length%4)%4),a=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=globalThis,s=("function"==typeof r.atob?r.atob.bind(r):e=>{if(void 0!==r.Buffer)return r.Buffer.from(e,"base64").toString("binary");throw Error("Base64 decoding is not supported in this environment")})(a),n=new ArrayBuffer(s.length),i=new Uint8Array(n);for(let e=0;e<s.length;e+=1)i[e]=s.charCodeAt(e);return n}function s(e){if(!e)return"";let t=globalThis,a=new Uint8Array(e),r="";for(let e=0;e<a.byteLength;e+=1)r+=String.fromCharCode(a[e]);return("function"==typeof t.btoa?t.btoa.bind(t):e=>{if(void 0!==t.Buffer)return t.Buffer.from(e,"binary").toString("base64");throw Error("Base64 encoding is not supported in this environment")})(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function n(e){let t=e?.publicKey??e?.PublicKey??e?.response??e?.Response;if(!t)throw Error("Unable to parse Passkey registration options from response");let a={...t,challenge:r(t.challenge),user:{...t.user,id:r(t.user?.id)}};return Array.isArray(t.excludeCredentials)&&(a.excludeCredentials=t.excludeCredentials.map(e=>({...e,id:r(e.id)}))),Array.isArray(t.attestationFormats)&&0===t.attestationFormats.length&&delete a.attestationFormats,a}function i(e){let t=e?.publicKey??e?.PublicKey??e?.response??e?.Response;
1if(!t)throw Error("Unable to parse Passkey login options from response");let a={...t,challenge:r(t.challenge)};return Array.isArray(t.allowCredentials)&&(a.allowCredentials=t.allowCredentials.map(e=>({...e,id:r(e.id)}))),a}function o(e){if(!e)return null;let t=e.response,a="function"==typeof t.getTransports?t.getTransports():void 0;return{id:e.id,rawId:s(e.rawId),type:e.type,authenticatorAttachment:e.authenticatorAttachment,response:{attestationObject:s(t.attestationObject),clientDataJSON:s(t.clientDataJSON),transports:a},clientExtensionResults:e.getClientExtensionResults?.()??{}}}function l(e){if(!e)return null;let t=e.response;return{id:e.id,rawId:s(e.rawId),type:e.type,authenticatorAttachment:e.authenticatorAttachment,response:{authenticatorData:s(t.authenticatorData),clientDataJSON:s(t.clientDataJSON),signature:s(t.signature),userHandle:t.userHandle?s(t.userHandle):null},clientExtensionResults:e.getClientExtensionResults?.()??{}}}async function c(){if("u"<typeof window)return!1;let{PublicKeyCredential:e}=window;if(!e)return!1;if("function"==typeof e.isConditionalMediationAvailable)try{if(await e.isConditionalMediationAvailable())return!0}catch{}if("function"==typeof e.isUserVerifyingPlatformAuthenticatorAvailable)try{return await e.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}return!0}async function u(e){return navigator.credentials.create({publicKey:e})}a.d(t,{$i:()=>o,GO:()=>u,Il:()=>l,TA:()=>c,az:()=>n,ig:()=>i})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.