1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[6552],{89806(e,t,a){a.d(t,{nc:()=>l,lW:()=>u,$e:()=>c,Rk:()=>d,pF:()=>s,D4:()=>m});var r=a(64577);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(68413),y=a(19376),p=a(20598),h=a(54369);function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onStatusChange:t}=e,[a,r]=(0,f.useState)(null),[l,c]=(0,f.useState)(!0),[u,d]=(0,f.useState)(!1),[m,g]=(0,f.useState)(!1),[w,k]=(0,f.useState)(!1),v=(0,f.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||y.Ay.t("Failed to load Passkey status")))}catch(e){console.error("[Passkey] Failed to fetch status",e),p.oR.error(y.Ay.t("Failed to load Passkey status")),r(null)}finally{c(!1)}},[t]);(0,f.useEffect)(()=>{v()},[v]),(0,f.useEffect)(()=>{(0,h.TA)().then(k).catch(()=>k(!1))},[]);let b=(0,f.useCallback)(async()=>{if(!w)return p.oR.error(y.Ay.t("This device does not support Passkey")),!1;if(!navigator?.credentials)return p.oR.error(y.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||y.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(y.Ay.t("Passkey registration was cancelled")),!1;let r=(0,h.$i)(a);if(!r)return p.oR.error(y.Ay.t("Invalid Passkey registration response")),!1;let s=await i(r);if(!s.success)return p.oR.error(s.message||y.Ay.t("Failed to register Passkey")),!1;return p.oR.success(y.Ay.t("Passkey registered successfully")),await v(),!0}catch(e){if(e instanceof DOMException&&"NotAllowedError"===e.name)return p.oR.info(y.Ay.t("Passkey registration was cancelled")),!1;return console.error("[Passkey] Registration error",e),p.oR.error(e instanceof Error?e.message:y.Ay.t("Failed to register Passkey")),!1}finally{d(!1)}},[w,v]),x=(0,f.useCallback)(async()=>{g(!0);try{let e=await o();if(!e.success)return p.oR.error(e.message||y.Ay.t("Failed to remove Passkey")),!1;return p.oR.success(y.Ay.t("Passkey removed successfully")),await v(),!0}catch(e){return console.error("[Passkey] Removal error",e),p.oR.error(y.Ay.t("Failed to remove Passkey")),!1}finally{g(!1)}},[v]),A=(0,f.useMemo)(()=>!!a?.enabled,[a]),P=(0,f.useMemo)(()=>a?.last_used_at??null,[a]);return{status:a,loading:l,registering:u,removing:m,supported:w,enabled:A,lastUsed:P,fetchStatus:v,register:b,remove:x}}},81275(e,t,a){a.d(t,{x9:()=>E,Yu:()=>h});var r=a(64577),s=a(54369),n=a(89806);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(68413),d=a(19376),f=a(20598);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,u.useState)(y),[c,h]=(0,u.useState)(p),[m,g]=(0,u.useState)(!1),w=(0,u.useCallback)(async()=>{let e=await i();return l(e),e},[]);(0,u.useEffect)(()=>{w()},[w]);let k=(0,u.useCallback)(()=>{h(p),g(!1)},[]),v=(0,u.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(d.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,u.useCallback)(async(e,n)=>{if(!c.apiCall)return void f.oR.error(d.Ay.t("Verification is not configured properly"));let i=e??c.method;if(!i)return void f.oR.error(d.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:d.Ay.t("Verification failed");throw f.oR.error(e),a?.(t),t}finally{h(e=>({...e,loading:!1}))}},[c,r,t,a,s,k]),x=(0,u.useCallback)(e=>{h(t=>({...t,code:e}))},[]),A=(0,u.useCallback)(e=>{h(t=>({...t,method:e,code:""}))},[]),P=(0,u.useCallback)(()=>{k()},[k]),E=(0,u.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]),C=(0,u.useCallback)(e=>"2fa"===e?n.has2FA:"passkey"===e&&n.hasPasskey&&n.passkeySupported,[n]),F=(0,u.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:x,switchMethod:A,withVerification:E,fetchVerificationMethods:w,canUseMethod:C,recommendedMethod:F,hasAnyMethod:n.has2FA||n.hasPasskey,isLoading:c.loading,currentMethod:c.method,code:c.code}}var m=a(72361),g=a(73606),w=a(47296),k=a(55724),v=a(6702),b=a(46775),x=a(1755),A=a(54023),P=a(34151);function E(e){let{open:t,onOpenChange:a,methods:r,state:s,onVerify:n,onCancel:i,onCodeChange:o,onMethodChange:l}=e,{t:c}=(0,v.Bd)(),d=(0,u.useMemo)(()=>{let e=[];return r.has2FA&&e.push("2fa"),r.hasPasskey&&r.passkeySupported&&e.push("passkey"),e},[r]),f=s.method??(d.length>0?d[0]:null),y=s.title??(d.length?"Additional verification required":"Verification unavailable"),p=s.description??(d.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)},E=s.loading||"2fa"===f&&(!s.code.trim()||s.code.length<6);return(0,m.jsx)(x.lG,{open:t,onOpenChange:a,children:(0,m.jsx)(x.Cf,{className:"top-[8vh] max-w-[calc(100%-1.5rem)] translate-y-0 gap-0 overflow-hidden border-none p-0 shadow-xl sm:top-1/2 sm:max-w-md sm:translate-y-[-50%] sm:rounded-xl",showCloseButton:!s.loading,children:(0,m.jsxs)("div",{className:"bg-background flex max-h-[calc(100dvh-2rem)] flex-col",children:[(0,m.jsxs)(x.c7,{className:"border-b px-6 py-5 text-left",children:[(0,m.jsxs)(x.L3,{className:"flex items-center gap-2 text-lg font-semibold",children:[(0,m.jsx)(g.A,{className:"text-primary h-5 w-5"}),y]}),(0,m.jsx)(x.rr,{className:"text-left",children:p})]}),(0,m.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:0===d.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??d[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)(A.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||E||(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)(w.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.")})]})]})}),(0,m.jsxs)(x.Es,{className:"bg-muted/30 border-t px-6 py-4 sm:flex-row sm:justify-end",children:[(0,m.jsx)(b.$,{type:"button",variant:"outline",disabled:s.loading,onClick:i,children:c("Cancel")}),(0,m.jsxs)(b.$,{type:"button",onClick:h,disabled:0===d.length||E,children:[s.loading&&(0,m.jsx)(k.A,{className:"h-4 w-4 animate-spin"}),c("Verify")]})]})]})})})}},54369(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.