PageSourceSearch

https://1profile.com/assets/VerifyDashboard-BGWqwPPC.js

js 1profile.com collected 2026-10-09 22:57:11 UTC 30,429 bytes, 21 lines download raw bytes

1import{r as v,j as e,k as Ie,B as b,n as ge,A as ee,C as ne,b as se,L as ve,Q as qe,by as Ee,p as Me}from"./index-CuLyYrHQ.js";import{B as te}from"./badge-C7kQAV5W.js";import{C as S,b as P,c as R,d as L,a as D}from"./card-Dthmc0xO.js";import{S as X,a as z,b as U,c as $,d as K}from"./select-CP1HfzOM.js";import{S as T}from"./nav-SyYRlCdQ.js";import{T as Pe,a as Re,b as le,c as V,d as Le,e as O}from"./table-Ct6cLuEK.js";import{T as Ae,a as Fe,b as W,c as G}from"./tabs-COcNfPg2.js";import{u as Ve}from"./useOAuthClients-DokBMN-L.js";import{a as Oe,V as ye,b as Ye,c as He}from"./VerifyStatusBadge-BlNQX1VZ.js";import{g as Ne,i as Be,h as Xe,f as ae,j as ze,k as Ue,t as $e,r as ce,o as Ke,b as We,l as Ge,d as Qe}from"./verify-7j0WeqkP.js";import{C as de}from"./checkbox-CLnfAopa.js";import{D as be,a as we,b as _e,c as ke,d as Ce,f as Se}from"./dialog-ITwai77E.js";import{I as A}from"./input-4LNJDi_5.js";import{L as C}from"./label-Cl8l4TQf.js";import{S as Je}from"./switch-CyW7Tlt_.js";import{T as Ze}from"./textarea-CV24vOAZ.js";import{L as re}from"./loader-circle-DrUMd5pB.js";import{u as De,C as Te}from"./useCopyToClipboard-eJwe3SF9.js";import{E as es}from"./external-link-CKgrvYgv.js";import{S as oe}from"./separator-DXhvmCwP.js";import{S as ss,a as ts,b as as,c as rs,bF as is}from"./mermaid-GHXKKRXX-DCf67RLx.js";import{R as ns}from"./refresh-cw-CwQ294ZW.js";import{t as y,c as ls,e as cs,g as me,m as ue,a as Y,b as ds,f as os}from"./format-CoLFXwEe.js";import{P as he}from"./endpoints-C4CBaMpw.js";import{T as ms}from"./triangle-alert-ChezEUUa.js";import{P as xe}from"./plus-DaUSbau8.js";import{R as us}from"./repeat-ccbUgyHR.js";import{P as hs}from"./pencil-CJBYRM-q.js";import{T as xs}from"./trash-2-Ccw6GthF.js";import"./Combination-Clzqp-dN.js";import"./index-CgnsySVI.js";import"./user-DhS_QLxS.js";import"./building-2-BhC2TU6O.js";import"./index-OjW1swG2.js";import"./clock-CZ-72Vtu.js";import"./circle-DhOhSwvQ.js";import"./collapsible-DSKhJ0jm.js";import"./circle-check-big-w-8rkG4W.js";import"./circle-x-CEhB_fCS.js";function B(s,t){const i=y(s),d=y(t),m=i.getTime()-d.getTime();return m<0?-1:m>0?1:m}function fs(s){return ls(s,Date.now())}function ps(s,t){const i=y(s),d=y(t),m=i.getFullYear()-d.getFullYear(),c=i.getMonth()-d.getMonth();return m*12+c}function js(s){return t=>{const d=(s?Math[s]:Math.trunc)(t);return d===0?0:d}}function gs(s,t){return+y(s)-+y(t)}function vs(s){const t=y(s);return t.setHours(23,59,59,999),t}function ys(s){const t=y(s),i=t.getMonth();return t.setFullYear(t.getFullYear(),i+1,0),t.setHours(23,59,59,999),t}function Ns(s){const t=y(s);return+vs(t)==+ys(t)}function bs(s,t){const i=y(s),d=y(t),m=B(i,d),c=Math.abs(ps(i,d));let o;if(c<1)o=0;else{i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-m*c);let n=B(i,d)===-m;Ns(y(s))&&c===1&&B(s,d)===1&&(n=!1),o=m*(c-Number(n))}return o===0?0:o}function ws(s,t,i){const d=gs(s,t)/1e3;return js(i==null?void 0:i.roundingMethod)(d)}function _s(s,t,i){const d=ds(),m=(i==null?void 0:i.locale)??d.locale??cs,c=2520,o=B(s,t);if(isNaN(o))throw new RangeError("Invalid time value");const n=Object.assign({},i,{addSuffix:i==null?void 0:i.addSuffix,comparison:o});let N,x;o>0?(N=y(t),x=y(s)):(N=y(s),x=y(t));const u=ws(x,N),g=(me(x)-me(N))/1e3,l=Math.round((u-g)/60);let f;if(l<2)return i!=null&&i.includeSeconds?u<5?m.formatDistance("lessThanXSeconds",5,n):u<10?m.formatDistance("lessThanXSeconds",10,n):u<20?m.formatDistance("lessThanXSeconds",20,n):u<40?m.formatDistance("halfAMinute",0,n):u<60?m.formatDistance("lessThanXMinutes",1,n):m.formatDistance("xMinutes",1,n):l===0?m.formatDistance("lessThanXMinutes",1,n):m.formatDistance("xMinutes",l,n);if(l<45)return m.formatDistance("xMinutes",l,n);if(l<90)return m.formatDistance("aboutXHours",1,n);if(l<ue){const p=Math.round(l/60);return m.formatDistance("aboutXHours",p,n)}else{if(l<c)return m.formatDistance("xDays",1,n);if(l<Y){const p=Math.round(l/ue);return m.formatDistance("xDays",p,n)}else if(l<Y*2)return f=Math.round(l/Y),m.formatDistance("aboutXMonths",f,n)}if(f=bs(x,N),f<12){const p=Math.round(l/Y);return m.formatDistance("xMonths",p,n)}else{const p=f%12,w=Math.trunc(f/12);return p<3?m.formatDistance("aboutXYears",w,n):p<9?m.formatDistance("overXYears",w,n):m.formatDistance("almostXYears",w+1,n)}}function ks(s,t){return _s(s,fs(s),t)}const Cs=[{value:0,label:"Always verify again"},{value:30,label:"Verified in the last 30 days"},{value:90,label:"Verified in the last 90 days"},{value:180,label:"Verified in the last 6 months"},{value:365,label:"Verified in the last year"},{value:730,label:"Verified in the last 2 years"}],Ss=[{value:24,label:"24 hours"},{value:72,label:"3 days"},{value:168,label:"7 days"},{value:720,label:"30 days"}],Ds=Array.from(new Set(Ne.map(s=>s.group)));function fe(s,t){return t?{client_id:t.client_id,name:t.name,description:t.description,required_checks:t.required_checks,shared_fields:t.shared_fields,reuse_window_days:t.reuse_window_days,inquiry_ttl_hours:t.inquiry_ttl_hours,redirect_url:t.redirect_url,is_active:t.is_active}:{client_id:s,name:"",description:null,required_checks:["document","selfie"],shared_fields:["full_name","date_of_birth"],reuse_window_days:365,inquiry_ttl_hours:72,redirect_url:null,is_active:!0}}function Ts({open:s,onOpenChange:t,clientId:i,template:d,saving:m,onSave:c}
1){const[o,n]=v.useState(()=>fe(i,d)),[N,x]=v.useState(null),[u,g]=v.useState([]);v.useEffect(()=>{s&&(n(fe(i,d)),x(null),g([]))},[s,i,d]);const l=o.required_checks??[],f=o.shared_fields??[],p=l.some(a=>a!=="document"&&Be(a)),w={checks:l,fields:f,stashed:u},k=(a,j)=>{const _=ze(w,a,j);g(_.stashed),n({...o,required_checks:_.checks,shared_fields:_.fields})},q=(a,j)=>{const _=Ue(w,a,j);g(_.stashed),n({...o,required_checks:_.checks,shared_fields:_.fields})},I=()=>{var j,_;if(!o.name.trim())return x("Give the template a name.");const a=$e(w);if(a)return x(a);if(o.redirect_url&&!/^https?:\/\//i.test(o.redirect_url))return x("The redirect URL must start with https://");x(null),c({...o,name:o.name.trim(),description:((j=o.description)==null?void 0:j.trim())||null,redirect_url:((_=o.redirect_url)==null?void 0:_.trim())||null})};return e.jsx(be,{open:s,onOpenChange:t,children:e.jsxs(we,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:d?"Edit template":"New verification template"}),e.jsx(Ce,{children:"A template decides what a person must prove and which verified details your app receives."})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(C,{htmlFor:"template-name",children:"Name"}),e.jsx(A,{id:"template-name",placeholder:"Seller onboarding",value:o.name,maxLength:120,onChange:a=>n({...o,name:a.target.value})})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(C,{htmlFor:"template-description",children:"Description"}),e.jsx(Ze,{id:"template-description",placeholder:"Shown to your team only",rows:2,value:o.description??"",onChange:a=>n({...o,description:a.target.value})})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Required checks"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every check the person must pass. A phone number on its own is a valid, much quicker template."})]}),e.jsx("div",{className:"space-y-2",children:Xe.map(a=>e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border p-3 cursor-pointer has-[:disabled]:cursor-default",children:[e.jsx(de,{checked:l.includes(a.key),disabled:a.key==="document"&&p,onCheckedChange:j=>k(a.key,j===!0),className:"mt-0.5"}),e.jsxs("span",{className:"space-y-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium",children:[a.label,a.key==="document"&&p&&e.jsx(Ie,{className:"h-3 w-3 text-muted-foreground","aria-label":"Required by another check"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a.description})]})]},a.key))})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Details your app receives"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The person sees this list before agreeing. Ask only for what you need."})]}),u.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.map(ae).join(", ")," ",u.length===1?"is":"are"," set aside because no selected check can prove ",u.length===1?"it":"them",". Turn the check back on to restore"," ",u.length===1?"it":"them","."]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:Ds.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a}),Ne.filter(j=>j.group===a).map(j=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx(de,{checked:f.includes(j.key),onCheckedChange:_=>q(j.key,_===!0)}),j.label]},j.key))]},a))})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Accept an existing 1Profile verification"}),e.jsxs(X,{value:String(o.reuse_window_days),onValueChange:a=>n({...o,reuse_window_days:Number(a)}),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsx($,{children:Cs.map(a=>
1e.jsx(K,{value:String(a.value),children:a.label},a.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"People who already hold everything this template asks for can share in one step instead of proving it again."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Links expire after"}),e.jsxs(X,{value:String(o.inquiry_ttl_hours),onValueChange:a=>n({...o,inquiry_ttl_hours:Number(a)}),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsx($,{children:Ss.map(a=>e.jsx(K,{value:String(a.value),children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(C,{htmlFor:"template-redirect",children:"Send people back to"}),e.jsx(A,{id:"template-redirect",type:"url",placeholder:"https://yourapp.com/verified",value:o.redirect_url??"",onChange:a=>n({...o,redirect_url:a.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be on one of your app’s registered redirect URI or website domains. We add inquiry_id and status to the URL."})]})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive templates cannot create new verifications."})]}),e.jsx(Je,{checked:o.is_active??!0,onCheckedChange:a=>n({...o,is_active:a})})]}),N&&e.jsx("p",{className:"text-sm text-destructive",role:"alert",children:N})]}),e.jsxs(Se,{children:[e.jsx(b,{variant:"outline",onClick:()=>t(!1),disabled:m,children:"Cancel"}),e.jsxs(b,{onClick:I,disabled:m,children:[m&&e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin"}),d?"Save changes":"Create template"]})]})]})})}function Is({open:s,onOpenChange:t,templates:i,creating:d,onCreate:m}){const c=i.filter(a=>a.is_active),[o,n]=v.useState(""),[N,x]=v.useState(""),[u,g]=v.useState(""),[l,f]=v.useState(null),{copy:p,isCopied:w}=De(),k=w("link");v.useEffect(()=>{var a;s&&(n(((a=c[0])==null?void 0:a.id)??""),x(""),g(""),f(null))},[s]);const q=async()=>{const a=await m({template_id:o,reference_id:N.trim()||void 0,email:u.trim()||void 0});a&&f(a)},I=async()=>{l!=null&&l.url&&await p(l.url,{key:"link",silent:!0})};return e.jsx(be,{open:s,onOpenChange:t,children:e.jsxs(we,{className:"max-w-lg",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:l?"Verification link ready":"New verification"}),e.jsx(Ce,{children:l?"Send this link to the person. It works once and belongs to whoever signs in first.":"Create a one-time link for a person to verify their identity. Apps usually do this through the API."})]}),l?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{readOnly:!0,value:l.url??"",className:"font-mono text-xs",onFocus:a=>a.target.select()}),e.jsx(b,{variant:"outline",size:"icon",onClick:I,"aria-label":"Copy link",children:k?e.jsx(ge,{className:"h-4 w-4"}):e.jsx(Te,{className:"h-4 w-4"})}),e.jsx(b,{variant:"outline",size:"icon",asChild:!0,"aria-label":"Open link",children:e.jsx("a",{href:l.url??"#",target:"_blank",rel:"noopener noreferrer",children:e.jsx(es,{className:"h-4 w-4"})})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Inquiry ",e.jsx("span",{className:"font-mono",children:l.id})," expires ",new Date(l.expires_at).toLocaleString(),"."]})]}):c.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create an active template first."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Template"}),e.jsxs(X,{value:o,onValueChange:n,children:[e.jsx(z,{children:e.jsx(U,{placeholder:"Choose a template"})}),e.jsx($,{children:c.map(a=>e.jsx(K,{value:a.id,children:a.name},a.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"inquiry-reference",children:"Your reference"}),e.jsx(A,{id:"inquiry-reference",placeholder:"user_8231",maxLength:255,value:N,onChange:a=>x(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your own ID for this person, returned with the result."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"inquiry-email",children:"Restrict to email"}),e.jsx(A,{id:"inquiry-email",type:"email",placeholder:"Optional",value:u,onChange:a=>g(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only a 1Profile account with this confirmed email can complete the verification."})]})]}),e.jsx(Se,{children:l?e.jsx(b,{onClick:()=>t(!1),children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"outline",onClick:()=>t(!1),disabled:d,children:"Cancel"}),e.jsxs(b,{onClick:q,disabled:d||!o,children:[d&&e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin"}),"Create link"]})]})})]})})}const qs={"verification.inquiry.created":"Link created","verification.inquiry.started":"Opened by a signed-in person","verification.inquiry.pending":"Consented and started verifying","verification.inquiry.approved":"Approved and details shared","verification.inquiry.declined":"Declined","verification.inquiry.expired":"Expired","verification.inquiry.canceled":"Canceled","verification.inquiry.revoked":"Person revoked access","verification.attempt.started":"ID check started","verification.attempt.processing":"ID submitted, checking","verification.attempt.failed":"ID check failed"};function Q(s){return s?os(new Date(s),"MMM d, yyyy h:mm a"):"—"}function Es({inquiryId:s,templates:t,onOpenChange:i,onCancel:d,canceling:m}){const{data:c,isLoading:o,error:n,refetch:N,isFetching:x}=Oe(s),u=t.find(l=>l.id===(c==null?void 0:c.template_id)),g=c&&["created","started","pending"].includes(c.status);return e.jsx(ss,{open:!!s,onOpenChange:i,children:e.jsxs(ts,{className:"w-full sm:max-w-lg overflow-y-auto",children:[e.jsxs(as,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rs,{children:"Verification"}),c&&e.jsx(ye,{status:c.status})]}),e.jsx(is,{className:"font-mono text-xs break-all",children:s})]}),o&&e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx(T,{className:"h-5 w-2/3"}),e.jsx(T,{className:"h-24 w-full"}),e.jsx(T,{className:"h-40 w-full"})]}),n&&e.jsxs(ee,{variant:"destructive",className:"mt-6",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx(se,{children:n instanceof Error?n.message:"Could not load this verification."})]}),c&&e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsxs("dl",{className:"grid grid-cols-[auto,1fr] gap-x-4 gap-y-2 text-sm",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Template"}),e.jsx("dd",{children:(u==null?void 0:u.name)??c.template_id}),e.jsx("dt",{className:"text-muted-foreground",children:"Your reference"}),e.jsx("dd",{className:"font-mono text-xs break-all",children:c.reference_id??"—"}),e.jsx("dt",{className:"text-muted-foreground",children:"1Profile user"}),e.jsx("dd",{className:"font-mono text-xs break-all",children:c.user_id??"—"}),e.jsx("dt",{className:"text-muted-foreground",children:"Created"}),e.jsx("dd",{children:Q(c.created_at)}),e.jsx("dt",{className:"text-muted-foreground",children:g?"Expires":"Completed"}
1),e.jsx("dd",{children:Q(g?c.expires_at:c.completed_at)})]}),c.decision_reason&&e.jsxs(ee,{children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx(se,{children:ce(c.decision_reason)})]}),c.status==="approved"&&c.shared_data&&e.jsxs("section",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold",children:["Shared details",e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:c.reused_existing_verification?"Reused an existing 1Profile verification":"Verified for this request"})]}),e.jsx("dl",{className:"rounded-lg border divide-y text-sm",children:Ke(c.shared_data).map(([l,f])=>e.jsxs("div",{className:"flex justify-between gap-4 px-3 py-2",children:[e.jsx("dt",{className:"text-muted-foreground",children:ae(l)}),e.jsx("dd",{className:"text-right break-words",children:We(f)})]},l))})]}),c.status==="revoked"&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"The person withdrew consent, so their details are no longer available. Delete any copies you stored."}),e.jsx(oe,{}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Timeline"}),e.jsxs(b,{variant:"ghost",size:"sm",onClick:()=>N(),disabled:x,children:[e.jsx(ns,{className:`h-3.5 w-3.5 mr-1.5 ${x?"animate-spin":""}`}),"Refresh"]})]}),e.jsx("ol",{className:"relative border-l pl-4 space-y-4",children:c.events.map((l,f)=>{var p;return e.jsxs("li",{className:"text-sm",children:[e.jsx("span",{className:"absolute -left-[5px] mt-1.5 h-2.5 w-2.5 rounded-full border bg-background"}),e.jsx("p",{className:"font-medium",children:qs[l.event]??l.event}),typeof((p=l.data)==null?void 0:p.code)=="string"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:ce(l.data.code)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Q(l.created_at)})]},f)})})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{}),e.jsxs(b,{variant:"outline",className:"w-full text-destructive hover:text-destructive",onClick:()=>d(c.id),disabled:m,children:[m&&e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancel verification"]})]})]})]})})}function J({code:s}){const{copy:t,isCopied:i}=De(),d=i("code");return e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-lg bg-muted/50 p-4 pr-12 text-xs overflow-x-auto",children:e.jsx("code",{children:s})}),e.jsx(b,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-7 w-7","aria-label":"Copy code",onClick:()=>t(s,{key:"code",silent:!0}),children:d?e.jsx(ge,{className:"h-3.5 w-3.5"}):e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}function Ms({templateId:s}){const i=`curl -X POST "${he}/verify/inquiries" \\
2  -H "x-api-key: $ONEPROFILE_API_KEY" \\
3  -H "Content-Type: application/json" \\
4  -d '{
5    "template_id": "${s??"TEMPLATE_ID"}",
6    "reference_id": "user_8231",
7    "email": "[email protected]",
8    "redirect_url": "https://yourapp.com/verified"
9  }'
10
11# => { "inquiry": { "id": "…", "status": "created", "url": "https://1profile.com/verify/vfy_…" } }`,d=`curl "${he}/verify/inquiries/INQUIRY_ID" \\
12  -H "x-api-key: $ONEPROFILE_API_KEY"
13
14# => { "inquiry": { "status": "approved", "shared_data": { "full_name": "…", "date_of_birth": "…" }, "events": [ … ] } }`;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsxs(P,{children:[e.jsx(R,{className:"text-base",children:"1. Create a verification for a person"}),e.jsxs(L,{children:["Call this from your server with an API key that has the ",e.jsx("code",{className:"text-xs",children:"write:verify"})," scope. Send the person to the returned ",e.jsx("code",{className:"text-xs",children:"url"}),"."," ",e.jsx(ve,{to:"/dashboard/api",className:"underline underline-offset-2",children:"Manage API keys"})]})]}),e.jsx(D,{children:e.jsx(J,{code:i})})]}),e.jsxs(S,{children:[e.jsxs(P,{children:[e.jsx(R,{className:"text-base",children:"2. Read the result"}),e.jsxs(L,{children:["When the person finishes, they return to your redirect URL with ",e.jsx("code",{className:"text-xs",children:"inquiry_id"})," and"," ",e.jsx("code",{className:"text-xs",children:"status"}),". Never trust those query parameters. Fetch the inquiry with the"," ",e.jsx("code",{className:"text-xs",children:"read:verify"})," scope to get the verified details."]})]}),e.jsx(D,{children:e.jsx(J,{code:d})})]}),e.jsxs(S,{children:[e.jsxs(P,{children:[e.jsx(R,{className:"text-base",children:"3. Listen for webhooks"}),e.jsx(L,{children:"Subscribe an endpoint to these events under API Keys, Webhooks. Payloads carry the inquiry status but never personal details."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:Ge.map(c=>e.jsx(te,{variant:"outline",className:"font-mono text-xs",children:c.value},c.value))}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Check the ",e.jsx("code",{className:"text-xs",children:"X-Webhook-Signature"})," header against the raw request body with your endpoint secret."]}),e.jsx(J,{code:`import crypto from "node:crypto";
15
16export function isFrom1Profile(rawBody, signatureHeader, secret) {
17  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
18  const a = Buffer.from(signatureHeader ?? "");
19  const b = Buffer.from(expected);
20  return a.length === b.length && crypto.timingSafeEqual(a, b);
21}`})]})]})]})}const pe="verify:selected-client";function H(s){return s instanceof Error?s.message:"Something went wrong"}function vt(){var ie;const{toast:s}
21=Me(),{clients:t,loading:i}=Ve(),[d,m]=v.useState(null);v.useEffect(()=>{var F;if(i||t.length===0||d&&t.some(M=>M.client_id===d))return;let r=null;try{r=localStorage.getItem(pe)}catch{}const h=t.find(M=>M.status==="active")??t[0];m(((F=t.find(M=>M.client_id===r))==null?void 0:F.client_id)??h.client_id)},[t,i,d]);const c=r=>{m(r);try{localStorage.setItem(pe,r)}catch{}},o=t.find(r=>r.client_id===d)??null,{templates:n,loading:N,save:x,remove:u}=Ye(d),{inquiries:g,loading:l,create:f,cancel:p}=He(d),[w,k]=v.useState({open:!1,template:null}),[q,I]=v.useState(!1),[a,j]=v.useState(null),_=v.useMemo(()=>new Map(n.map(r=>[r.id,r.name])),[n]),E=v.useMemo(()=>{const r=g.filter(h=>h.status==="approved");return{total:g.length,approved:r.length,reused:r.filter(h=>h.reused).length}},[g]);return i?e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{className:"h-10 w-72"}),e.jsx(T,{className:"h-64 w-full"})]}):t.length===0?e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(je,{}),e.jsx(S,{children:e.jsxs(D,{className:"py-12 text-center space-y-3",children:[e.jsx(qe,{className:"mx-auto h-10 w-10 text-muted-foreground"}),e.jsx("p",{className:"font-medium",children:"Register an app first"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Identity verification is requested on behalf of an app, so people know who is asking."}),e.jsx(b,{asChild:!0,children:e.jsx(ve,{to:"/oauth",children:"Register an app"})})]})})]}):e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[e.jsx(je,{}),e.jsx("div",{className:"w-full sm:w-64",children:e.jsxs(X,{value:d??void 0,onValueChange:c,children:[e.jsx(z,{"aria-label":"App",children:e.jsx(U,{placeholder:"Choose an app"})}),e.jsx($,{children:t.map(r=>e.jsx(K,{value:r.client_id,children:r.name},r.client_id))})]})})]}),o&&o.status!=="active"&&e.jsxs(ee,{children:[e.jsx(ms,{className:"h-4 w-4"}),e.jsxs(Ee,{children:[o.name," is awaiting approval"]}),e.jsx(se,{children:"You can set up templates now. 1Profile has to approve the app before it can ask anyone for their identity."})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(Z,{label:"Verifications",value:E.total}),e.jsx(Z,{label:"Approved",value:E.approved}),e.jsx(Z,{label:"Approved in one step",value:E.approved?`${Math.round(E.reused/E.approved*100)}%`:"—",hint:"People who shared an existing 1Profile verification"})]}),e.jsxs(Ae,{defaultValue:"inquiries",children:[e.jsxs(Fe,{children:[e.jsx(W,{value:"inquiries",children:"Verifications"}),e.jsx(W,{value:"templates",children:"Templates"}),e.jsx(W,{value:"integrate",children:"Integrate"})]}),e.jsx(G,{value:"inquiries",className:"mt-4",children:e.jsxs(S,{children:[e.jsxs(P,{className:"flex flex-row items-center justify-between space-y-0",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-base",children:"Verifications"}),e.jsx(L,{children:"Most recent first. Select a row for details."})]}),e.jsxs(b,{size:"sm",onClick:()=>I(!0),disabled:n.length===0,children:[e.jsx(xe,{className:"mr-1.5 h-4 w-4"})," New link"]})]}),e.jsx(D,{className:"p-0",children:l?e.jsx("div",{className:"p-6 space-y-2",children:[0,1,2].map(r=>e.jsx(T,{className:"h-10 w-full"},r))}):g.length===0?e.jsx("p",{className:"px-6 pb-6 text-sm text-muted-foreground",children:n.length===0?"Create a template, then start verifications from the API or with a link.":"No verifications yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pe,{children:[e.jsx(Re,{children:e.jsxs(le,{children:[e.jsx(V,{children:"Status"}),e.jsx(V,{children:"Reference"}),e.jsx(V,{className:"hidden md:table-cell",children:"Template"}),e.jsx(V,{className:"text-right",children:"Created"})]})}),e.jsx(Le,{children:g.map(r=>e.jsxs(le,{className:"cursor-pointer",tabIndex:0,onClick:()=>j(r.id),onKeyDown:h=>h.key==="Enter"&&j(r.id),children:[e.jsx(O,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{status:r.status}),r.reused&&e.jsx(us,{className:"h-3.5 w-3.5 text-muted-foreground","aria-label":"Reused an existing verification"})]})}),e.jsx(O,{className:"font-mono text-xs",children:r.reference_id??"—"}),e.jsx(O,{className:"hidden md:table-cell",children:_.get(r.template_id)??"—"}),e.jsx(O,{className:"text-right text-muted-foreground whitespace-nowrap",children:ks(new Date(r.created_at),{addSuffix:!0})})]},r.id))})]})})})]})}),e.jsxs(G,{value:"templates",className:"mt-4 space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{size:"sm",onClick:()=>k({open:!0,template:null}),children:[e.jsx(xe,{className:"mr-1.5 h-4 w-4"})," New template"]})}),N?e.jsx(T,{className:"h-40 w-full"}):n.length===0?e.jsx(S,{children:e.jsx(D,{className:"py-10 text-center text-sm text-muted-foreground",children:"No templates yet. A template set
21s the checks a person must pass and the details you receive."})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:n.map(r=>e.jsxs(S,{children:[e.jsxs(P,{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(R,{className:"text-base",children:r.name}),!r.is_active&&e.jsx(te,{variant:"secondary",children:"Inactive"})]}),r.description&&e.jsx(L,{children:r.description}),e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground break-all",children:r.id})]}),e.jsxs(D,{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Checks"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.required_checks.map(h=>e.jsx(te,{variant:"outline",children:Qe(h)},h))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"You receive"}),e.jsx("p",{children:r.shared_fields.map(ae).join(", ")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.reuse_window_days>0?`Accepts 1Profile verifications from the last ${r.reuse_window_days} days`:"Always requires a fresh verification"}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>k({open:!0,template:r}),children:[e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"})," Edit"]}),e.jsxs(b,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",disabled:u.isPending,onClick:()=>{window.confirm(`Delete "${r.name}"? Its verification history is deleted too.`)&&u.mutate(r.id,{onSuccess:()=>s({title:"Template deleted"}),onError:h=>s({variant:"destructive",title:"Could not delete",description:H(h)})})},children:[e.jsx(xs,{className:"mr-1.5 h-3.5 w-3.5"})," Delete"]})]})]})]},r.id))})]}),e.jsx(G,{value:"integrate",className:"mt-4",children:e.jsx(Ms,{templateId:((ie=n.find(r=>r.is_active))==null?void 0:ie.id)??null})})]}),d&&e.jsx(Ts,{open:w.open,onOpenChange:r=>k(h=>({...h,open:r})),clientId:d,template:w.template,saving:x.isPending,onSave:r=>{var h;return x.mutate({id:(h=w.template)==null?void 0:h.id,draft:r},{onSuccess:()=>{k({open:!1,template:null}),s({title:w.template?"Template saved":"Template created"})},onError:F=>s({variant:"destructive",title:"Could not save template",description:H(F)})})}}),e.jsx(Is,{open:q,onOpenChange:I,templates:n,creating:f.isPending,onCreate:async r=>{try{return(await f.mutateAsync(r)).inquiry}catch(h){return s({variant:"destructive",title:"Could not create verification",description:H(h)}),null}}}),e.jsx(Es,{inquiryId:a,templates:n,onOpenChange:r=>!r&&j(null),canceling:p.isPending,onCancel:r=>p.mutate(r,{onSuccess:()=>s({title:"Verification canceled"}),onError:h=>s({variant:"destructive",title:"Could not cancel",description:H(h)})})})]})}function je(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Identity Verification"}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:"Verify the people using your app with a government ID and selfie."})]})}function Z({label:s,value:t,hint:i}){return e.jsx(S,{children:e.jsxs(D,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",title:i,children:s}),e.jsx("p",{className:"text-2xl font-semibold tabular-nums",children:t})]})})}export{vt as default};

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.