kyd-shared-badge 0.3.34 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kyd-shared-badge",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -0,0 +1,608 @@
1
+ 'use client';
2
+
3
+ import { FiAlertTriangle } from 'react-icons/fi';
4
+ import { PublicBadgeData, GraphInsightsPayload, ScoringSummary, BusinessRule, TopBusinessRule, EnterpriseMatch } from './types';
5
+ // import ShareButton from './components/ShareButton';
6
+ import ReportHeader from './components/ReportHeader';
7
+ import EnterpriseCoaching from './components/EnterpriseCoaching';
8
+ import AppendixTables from './components/AppendixTables';
9
+ import BusinessRuleLink from './components/BusinessRuleLink';
10
+ import IpRiskAnalysisDisplay from './components/IpRiskAnalysisDisplay';
11
+ // import Image from 'next/image';
12
+ import GraphInsights from './components/GraphInsights';
13
+ import ConnectedPlatforms from './components/ConnectedPlatforms';
14
+ import { FaGithub, FaGitlab, FaStackOverflow, FaLinkedin, FaGoogle, FaKaggle } from 'react-icons/fa';
15
+ import { SiCredly, SiFiverr } from 'react-icons/si';
16
+ import GaugeCard from './components/GaugeCard';
17
+ import RiskCard from './components/RiskCard';
18
+
19
+ import { yellow, green } from './colors';
20
+ import Skills from './components/Skills';
21
+ import CategoryBars from './components/CategoryBars';
22
+ import SkillsAppendixTable from './components/SkillsAppendixTable';
23
+ import { BusinessRulesProvider } from './components/BusinessRulesContext';
24
+ import Reveal from './components/Reveal';
25
+ import { formatLocalDateTime } from './utils/date';
26
+ import ChatWidget from './chat/ChatWidget';
27
+ import UseCases from './components/UseCases';
28
+ type ChatWidgetProps = Partial<{
29
+ api: string;
30
+ title: string;
31
+ hintText: string;
32
+ loginPath: string;
33
+ headerOffset: 'auto' | 'none' | number;
34
+ developerName: string;
35
+ }>;
36
+
37
+ // const hexToRgba = (hex: string, alpha: number) => {
38
+ // const clean = hex.replace('#', '');
39
+ // const r = parseInt(clean.substring(0, 2), 16);
40
+ // const g = parseInt(clean.substring(2, 4), 16);
41
+ // const b = parseInt(clean.substring(4, 6), 16);
42
+ // return `rgba(${r}, ${g}, ${b}, ${alpha})`;
43
+ // };
44
+
45
+ const SharedBadgeDisplay = ({ badgeData, chatProps, headless }: { badgeData: PublicBadgeData, chatProps?: ChatWidgetProps, headless?: boolean }) => {
46
+ const {
47
+ badgeId,
48
+ developerName,
49
+ assessmentResult,
50
+ updatedAt,
51
+ // connectedAccounts
52
+ } = badgeData;
53
+
54
+ const {
55
+ // report_summary,
56
+ // developer_trust_explanation,
57
+ screening_sources,
58
+ // industry_considerations
59
+ } = assessmentResult;
60
+
61
+ const graphInsights: GraphInsightsPayload = (assessmentResult)?.graph_insights || {} as GraphInsightsPayload;
62
+ const scoringSummary: ScoringSummary = (assessmentResult)?.scoring_summary || {} as ScoringSummary;
63
+
64
+
65
+ const wrapperMaxWidth = 'max-w-5xl';
66
+ const isHeadless = !!headless;
67
+
68
+ // Overall and genre scores
69
+ const overallFinalPercent = assessmentResult?.final_percent || 0;
70
+
71
+ // Build category display grouped by genres from scoring_summary.config.genre_mapping
72
+ const genreMapping = (scoringSummary?.config?.genre_mapping) || {};
73
+ const categoryScores = (scoringSummary?.category_scores) || {};
74
+ const categoryTopByGraph = (graphInsights?.categoryTopBusiness) || {};
75
+ const roleTargets: Record<string, number> | undefined = (() => {
76
+ try {
77
+ const em: EnterpriseMatch | undefined = assessmentResult?.enterprise_match;
78
+ return (em && em.role && em.role.categoryTargets) ? (em.role.categoryTargets as Record<string, number>) : undefined;
79
+ } catch {
80
+ return undefined;
81
+ }
82
+ })();
83
+
84
+ const topBusinessForGenre = (genre: string) => {
85
+ const cats: string[] = (genreMapping)?.[genre] || [];
86
+ const items = [];
87
+ for (const c of cats) {
88
+ const arr = (categoryTopByGraph)?.[c] || [];
89
+ for (const it of arr) items.push(it);
90
+ }
91
+ items.sort((a, b) => Number(b?.weight || 0) - Number(a?.weight || 0));
92
+ return items.slice(0, 3) as TopBusinessRule[];
93
+ };
94
+
95
+ const skillsMatrix = assessmentResult?.skills_matrix || { skills: [] };
96
+ const skillsAll = assessmentResult?.skills_all || { skills: [] };
97
+ const connected = badgeData?.connectedAccounts || [];
98
+ const ProviderIcon = ({ name }: { name?: string }) => {
99
+ const n = (name || '').toLowerCase();
100
+ if (n.includes('github')) return <FaGithub />;
101
+ if (n.includes('gitlab')) return <FaGitlab />;
102
+ if (n.includes('stack')) return <FaStackOverflow />;
103
+ if (n.includes('credly')) return <SiCredly />;
104
+ if (n.includes('fiverr')) return <SiFiverr />;
105
+ if (n.includes('kaggle')) return <FaKaggle />;
106
+ if (n.includes('google')) return <FaGoogle />;
107
+ if (n.includes('linkedin')) return <FaLinkedin />;
108
+ return <span className="inline-block w-3 h-3 rounded-full" style={{ backgroundColor: 'var(--icon-button-secondary)' }} />;
109
+ };
110
+
111
+ const getProviderDisplayName = (name?: string): string => {
112
+ const n = (name || '').toLowerCase();
113
+ if (n.includes('github')) return 'GitHub';
114
+ if (n.includes('gitlab')) return 'GitLab';
115
+ if (n.includes('stack')) return 'Stack Overflow';
116
+ if (n.includes('credly')) return 'Credly';
117
+ if (n.includes('fiverr')) return 'Fiverr';
118
+ if (n.includes('kaggle')) return 'Kaggle';
119
+ if (n.includes('google')) return 'Google Scholar';
120
+ if (n.includes('linkedin')) return 'LinkedIn';
121
+ return name || 'Provider';
122
+ };
123
+
124
+ const getProviderTooltipCopy = (provider?: string): string => {
125
+ const n = (provider || '').toLowerCase();
126
+ if (n.includes('github')) return 'Signals from open-source activity: commits, repos, stars, and collaboration patterns.';
127
+ if (n.includes('gitlab')) return 'Signals from GitLab projects and contributions that indicate delivery and collaboration.';
128
+ if (n.includes('stack')) return 'Signals from Q&A participation such as answers, reputation, and accepted solutions.';
129
+ if (n.includes('credly')) return 'Verified badges and certifications that validate specific skills or achievements.';
130
+ if (n.includes('fiverr')) return 'Client reviews, job history, and delivery consistency across freelance engagements.';
131
+ if (n.includes('kaggle')) return 'Competition results, notebooks, and dataset contributions that reflect analytical skill.';
132
+ if (n.includes('google')) return 'Publications, citations, and scholarly presence indicating research impact.';
133
+ if (n.includes('linkedin')) return 'Professional history, endorsements, and network signals indicating credibility.';
134
+ return 'Signals contributed from this provider relevant to capability and trust.';
135
+ };
136
+
137
+ const getCategoryTooltipCopy = (category: string): string => {
138
+ const name = (category || '').toLowerCase();
139
+ if (/network|connection|collab|peer/.test(name)) return 'Signals from the developer’s professional connections, collaborations, and peer recognition.';
140
+ if (/project|repo|portfolio|work/.test(name)) return 'Signals from a developer’s visible projects, repositories, or published work that indicate breadth and quality of output.';
141
+ if (/skill|cert|assessment|endorse/.test(name)) return 'Signals tied to specific technical abilities, such as verified certifications, assessments, or endorsements.';
142
+ if (/experience|tenure|history/.test(name)) return 'Signals of tenure and diversity of professional or project involvement over time.';
143
+ if (/activity|recency|frequency|engage/.test(name)) return 'Signals of recency and frequency of developer engagement in professional or technical platforms.';
144
+ if (/sanction|legal|criminal|regulatory|ofac|fbi|watchlist/.test(name)) return 'Signals of legal, criminal, or regulatory red flags linked to an identity.';
145
+ if (/identity|authentic|consisten/.test(name)) return 'Signals that indicate whether a developer’s identity is genuine and consistent across platforms.';
146
+ if (/reputation|review|rating|feedback|perceive|peer/.test(name)) return 'Signals of how peers, clients, and communities perceive the developer.';
147
+ if (/geo|jurisdiction|country|region|ip|location/.test(name)) return 'Signals tied to a developer’s geographic or jurisdictional context.';
148
+ if (/security|cyber/.test(name)) return 'Signals of security posture and potential cyber-risk exposure.';
149
+ if (/risk/.test(name)) return 'KYD Risk surfaces signals of authenticity, reputation, and environmental telemetry that indicate potential risks in engaging with a developer.';
150
+ if (/tech|technical/.test(name)) return 'KYD Technical surfaces signals from a developer’s portfolio, skills, experience, activity, and network to indicate the likelihood of technical capability.';
151
+ return 'Share of overall contribution by category based on applied weights.';
152
+ };
153
+
154
+ const barColor = (pct: number) => pct >= 60 ? green : pct >= 40 ? '#ffbb54' : '#EC6662';
155
+
156
+ return (
157
+ <BusinessRulesProvider items={graphInsights?.business_rules_all}>
158
+ <div className={`${wrapperMaxWidth} mx-auto`}>
159
+ {isHeadless && (
160
+ <style>
161
+ {`@page { margin: 0; }
162
+ html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
163
+ #__next, main { margin: 0 !important; padding: 0 !important; }
164
+ @media print {
165
+ .kyd-break-before { break-before: page; page-break-before: always; }
166
+ .kyd-break-after { break-after: page; page-break-after: always; }
167
+ .kyd-avoid-break { break-inside: avoid; page-break-inside: avoid; }
168
+ .kyd-keep-with-next { break-after: avoid; page-break-after: avoid; }
169
+ }`}
170
+ </style>
171
+ )}
172
+ {/* Share controls removed; app-level pages render their own actions */}
173
+ <Reveal headless={isHeadless} offsetY={8} durationMs={500}>
174
+ <ReportHeader
175
+ badgeId={badgeId}
176
+ developerName={badgeData.developerName}
177
+ updatedAt={updatedAt}
178
+ score={overallFinalPercent || 0}
179
+ isPublic={true}
180
+ badgeImageUrl={badgeData.badgeImageUrl || ''}
181
+ summary={assessmentResult?.report_summary || ''}
182
+ enterpriseMatch={(() => {
183
+ const em = assessmentResult?.enterprise_match;
184
+ if (!em) return null;
185
+ const role = em.role || {};
186
+ return { label: em.label, description: em.description, roleName: role.name };
187
+ })()}
188
+ countries={(assessmentResult?.screening_sources?.ip_risk_analysis?.raw_data?.countries) || []}
189
+ />
190
+ </Reveal>
191
+ {/* Coaching / Evidence under header when present */}
192
+ {(() => {
193
+ const em = assessmentResult.enterprise_match;
194
+ const coaching = em?.coaching;
195
+ if (!coaching || !(Array.isArray(coaching.items) && coaching.items.length)) return null;
196
+ return (
197
+ <Reveal headless={isHeadless}>
198
+ <EnterpriseCoaching roleName={em?.role?.name} matchLabel={em?.label} coaching={coaching} />
199
+ </Reveal>
200
+ );
201
+ })()}
202
+ <div
203
+ className={isHeadless ? 'p-6 sm:p-8 mt-2 border' : 'rounded-xl shadow-xl p-6 sm:p-8 mt-8 border'}
204
+ style={{ backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' }}
205
+ >
206
+ <div className={'space-y-12 divide-y'} style={{ borderColor: 'var(--icon-button-secondary)' }}>
207
+ <div className="pt-8 first:pt-0 kyd-avoid-break">
208
+ <Reveal headless={isHeadless} as={'h4'} offsetY={8} durationMs={500} className={'text-2xl font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Report Summary</Reveal>
209
+ <Reveal headless={isHeadless} as={'div'} offsetY={8} durationMs={500} className={'space-y-12 divide-y'} style={{ borderColor: 'var(--icon-button-secondary)' }}>
210
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-4 *:min-h-full kyd-avoid-break">
211
+ {/* Technical semicircle gauge (refactored) */}
212
+ {(() => {
213
+ const ui = graphInsights?.uiSummary?.technical || {};
214
+ const pct = Math.round(Number(ui?.percent ?? 0));
215
+ const label = ui?.label || 'EVIDENCE';
216
+ const top = ui?.top_movers && ui.top_movers.length > 0 ? ui.top_movers : topBusinessForGenre('Technical');
217
+ return (
218
+ <GaugeCard
219
+ key={'technical-card'}
220
+ title={'KYD Technical'}
221
+ description={'The gauge visualization shows a weighted composite of technical evidence, with rightward movement indicating stronger indications of developer capability'}
222
+ percent={pct}
223
+ label={label}
224
+ topMovers={top?.map(t => ({ label: t?.label, uid: t?.uid }))}
225
+ topMoversTitle={'Top Score Movers'}
226
+ />
227
+ );
228
+ })()}
229
+
230
+ {/* Risk descending bars card (abstracted) */}
231
+ {(() => {
232
+ const ui = graphInsights?.uiSummary?.risk || {};
233
+ const pctGood = Math.round(Number(ui?.percent_good ?? 0));
234
+ const label = ui?.label || 'RISK';
235
+ const top = ui?.top_movers && ui.top_movers.length > 0 ? ui.top_movers : topBusinessForGenre('Risk');
236
+ const tooltip = 'Higher bar filled indicates lower overall risk; movement to the right reflects improved risk posture.';
237
+ return (
238
+ <RiskCard
239
+ title={'KYD Risk'}
240
+ description={'The bar chart visualizes relative risk levels, where shorter bars denote lower risk and taller bars indicate greater exposure.'}
241
+ percentGood={pctGood}
242
+ label={label}
243
+ topMovers={top?.map(t => ({ label: t?.label, uid: t?.uid }))}
244
+ topMoversTitle={'Top Score Movers'}
245
+ tooltipText={tooltip}
246
+ />
247
+ );
248
+ })()}
249
+
250
+ {/* AI transparency semicircle gauge */}
251
+ {(() => {
252
+ const ai_usage_summary = assessmentResult?.ai_usage_summary;
253
+ const label = 'AI Transparency'// TODO: calculate label frontend
254
+ const topMovers = ai_usage_summary?.key_findings || []
255
+ return (
256
+ <GaugeCard
257
+ key={'ai-card'}
258
+ title={'KYD AI (Beta)'}
259
+ description={'Indicates the degree to which AI-assisted code is explicitly disclosed across analyzed files.'}
260
+ percent={ai_usage_summary?.transparency_score}
261
+ label={label}
262
+ // id non-functional
263
+ topMovers={topMovers.map(t => ({ label: t, uid: 'ai-usage' }))}
264
+ topMoversTitle={'Key Findings'}
265
+ />
266
+ );
267
+ })()}
268
+ </div>
269
+ </Reveal>
270
+ </div>
271
+
272
+ {/* Enterprise Use Cases (directly under the three summary cards) */}
273
+ {assessmentResult?.enterprise_use_cases?.items && assessmentResult.enterprise_use_cases.items.length > 0 && (
274
+ <UseCases useCases={assessmentResult.enterprise_use_cases} headless={isHeadless} badgeId={badgeId} />
275
+ )}
276
+
277
+ {/* Technical Scores */}
278
+ <div className="mt-8" >
279
+ <div key={'Technical'} className='pt-8 space-y-8 kyd-avoid-break' style={{ borderColor: 'var(--icon-button-secondary)'}}>
280
+ <Reveal headless={isHeadless} as={'h4'} offsetY={8} className={'text-2xl font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>KYD Technical</Reveal>
281
+ {/* technical graph insights */}
282
+ <Reveal headless={isHeadless}>
283
+ <div className="">
284
+ <GraphInsights
285
+ graphInsights={graphInsights}
286
+ categories={genreMapping?.['Technical'] as string[]}
287
+ genre={'Technical'}
288
+ scoringSummary={scoringSummary}
289
+ headless={isHeadless}
290
+ />
291
+ </div>
292
+ </Reveal>
293
+
294
+ {/* category bars and contributing factors */}
295
+ <div className="grid grid-cols-1 lg:grid-cols-12 w-full gap-8 items-stretch py-8 border-t" style={{ borderColor: 'var(--icon-button-secondary)'}}>
296
+
297
+ {/* Left: Bars */}
298
+ <Reveal headless={isHeadless} className="lg:col-span-8 h-full">
299
+ <CategoryBars
300
+ title={'Technical Category Contributions'}
301
+ categories={genreMapping?.['Technical'] as string[]}
302
+ categoryScores={categoryScores}
303
+ barColor={barColor}
304
+ getCategoryTooltipCopy={getCategoryTooltipCopy}
305
+ barHeight={16}
306
+ categoryTargets={roleTargets}
307
+ />
308
+ </Reveal>
309
+
310
+ {/* Right: Contributing Factors (hidden on small screens) */}
311
+ <Reveal headless={isHeadless} className="lg:col-span-4 w-full ml-0 lg:ml-20 hidden lg:flex flex-col items-start justify-start" delayMs={80}>
312
+ <div className={'text-sm font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Top Contributing Factors</div>
313
+ <div className="space-y-4">
314
+ {(genreMapping?.['Technical'] || []).map((cat: string) => {
315
+ const topRules = (categoryTopByGraph?.[cat] || []).slice(0, 3) as BusinessRule[];
316
+ if (!topRules || topRules.length === 0) return null;
317
+ return (
318
+ <div key={cat} className="pt-3 first:pt-0">
319
+ <div className={'text-xs font-semibold mb-1'} style={{ color: 'var(--text-main)' }}>{cat}</div>
320
+ <div className="space-y-1">
321
+ {topRules.map((r, idx: number) => (
322
+ <div key={idx} className="flex items-center gap-2 text-xs" style={{ color: 'var(--text-secondary)' }}>
323
+ <span className={'relative inline-flex items-center group'} style={{ color: 'var(--text-secondary)' }}>
324
+ <ProviderIcon name={r.provider} />
325
+ <div className="hidden group-hover:block absolute z-30 left-1/2 -translate-x-1/2 top-full mt-2 w-80">
326
+ <div style={{ background: 'var(--content-card-background)', border: '1px solid var(--icon-button-secondary)', color: 'var(--text-main)', padding: 10, borderRadius: 6 }}>
327
+ <div style={{ fontWeight: 600 }}>{getProviderDisplayName(r.provider)}</div>
328
+ <div style={{ marginTop: 6, fontSize: 12, color: 'var(--text-secondary)' }}>{getProviderTooltipCopy(r.provider)}</div>
329
+ </div>
330
+ </div>
331
+ </span>
332
+ <BusinessRuleLink uid={r.uid} label={r.label} />
333
+ </div>
334
+ ))}
335
+ </div>
336
+ </div>
337
+ );
338
+ })}
339
+ </div>
340
+ </Reveal>
341
+ </div>
342
+
343
+ <Reveal headless={isHeadless}>
344
+ <div className="pt-8 border-t kyd-avoid-break" style={{ borderColor: 'var(--icon-button-secondary)'}}>
345
+ <h3 className={'text-xl font-bold mb-3 kyd-keep-with-next'} style={{ color: 'var(--text-main)' }}>KYD Technical - Skills Insights</h3>
346
+ <div className={'prose prose-sm max-w-none mb-6 space-y-4'} style={{ color: 'var(--text-secondary)' }}>
347
+ <Skills skillsMatrix={skillsMatrix} skillsCategoryRadar={graphInsights?.skillsCategoryRadar} headless={isHeadless} />
348
+ </div>
349
+ </div>
350
+ </Reveal>
351
+
352
+ </div>
353
+ </div>
354
+
355
+
356
+
357
+ <div className="pt-8 space-y-8">
358
+ <Reveal headless={isHeadless} as={'h3'} offsetY={8} className={`text-2xl font-bold ${isHeadless ? 'kyd-break-before' : ''}`} style={{ color: 'var(--text-main)' }}>KYD Risk - Overview</Reveal>
359
+
360
+ {/* Risk Graph Insights and Category Bars */}
361
+ <Reveal headless={isHeadless}>
362
+ <div className="">
363
+ <GraphInsights
364
+ graphInsights={graphInsights}
365
+ categories={genreMapping?.['Risk'] as string[]}
366
+ genre={'Risk'}
367
+ scoringSummary={scoringSummary}
368
+ headless={isHeadless}
369
+ />
370
+ </div>
371
+ </Reveal>
372
+ <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 w-full items-stretch py-8 border-y kyd-avoid-break" style={{ borderColor: 'var(--icon-button-secondary)' }}>
373
+ {/* Left: Bars */}
374
+ <Reveal headless={isHeadless} className="lg:col-span-8 h-full">
375
+ <CategoryBars
376
+ title={'KYD Risk - Category Insights'}
377
+ categories={genreMapping?.['Risk'] as string[]}
378
+ categoryScores={categoryScores}
379
+ barColor={barColor}
380
+ getCategoryTooltipCopy={getCategoryTooltipCopy}
381
+ barHeight={16}
382
+ categoryTargets={roleTargets}
383
+ />
384
+ </Reveal>
385
+ {/* Right: Contributing Factors (hidden on small screens) */}
386
+ <Reveal headless={isHeadless} className="lg:col-span-4 w-full ml-0 lg:ml-20 hidden lg:flex flex-col items-start justify-start" delayMs={80}>
387
+ <div className={'text-sm font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Top Contributing Factors</div>
388
+ <div className="space-y-4">
389
+ {genreMapping?.['Risk']?.map((cat: string) => {
390
+ const topRules = (categoryTopByGraph?.[cat] || []).slice(0, 3) as BusinessRule[];
391
+ if (!topRules || topRules.length === 0) return null;
392
+ return (
393
+ <div key={cat} className="pt-3 first:pt-0">
394
+ <div className={'text-xs font-semibold mb-1'} style={{ color: 'var(--text-main)' }}>{cat}</div>
395
+ <div className="space-y-1">
396
+ {topRules.map((r, idx: number) => (
397
+ <div key={idx} className="flex items-center gap-2 text-xs" style={{ color: 'var(--text-secondary)' }}>
398
+ <span className={'relative inline-flex items-center group'} style={{ color: 'var(--text-secondary)' }}>
399
+ <ProviderIcon name={r.provider} />
400
+ <div className="hidden group-hover:block absolute z-30 left-1/2 -translate-x-1/2 top-full mt-2 w-80">
401
+ <div style={{ background: 'var(--content-card-background)', border: '1px solid var(--icon-button-secondary)', color: 'var(--text-main)', padding: 10, borderRadius: 6 }}>
402
+ <div style={{ fontWeight: 600 }}>{getProviderDisplayName(r.provider)}</div>
403
+ <div style={{ marginTop: 6, fontSize: 12, color: 'var(--text-secondary)' }}>{getProviderTooltipCopy(r.provider)}</div>
404
+ </div>
405
+ </div>
406
+ </span>
407
+ <BusinessRuleLink uid={r.uid} label={r.label} />
408
+ </div>
409
+ ))}
410
+ </div>
411
+ </div>
412
+ );
413
+ })}
414
+ </div>
415
+ </Reveal>
416
+ </div>
417
+
418
+ {/* cyber risk display */}
419
+ {badgeData.optOutScreening ? (
420
+ <Reveal headless={isHeadless} className={'p-4 rounded-lg border'} style={{ backgroundColor: 'var(--icon-button-secondary)', borderColor: 'var(--icon-button-secondary)' }}>
421
+ <div className="flex items-start">
422
+ <span className="h-5 w-5 mr-3 mt-0.5 flex-shrink-0" style={{ color: yellow }}>
423
+ <FiAlertTriangle size={20} />
424
+ </span>
425
+ <div>
426
+ <h4 className={'font-bold'} style={{ color: 'var(--text-main)' }}>User Opted Out of Screening</h4>
427
+ <p className={'text-sm mt-1'} style={{ color: 'var(--text-secondary)' }}>
428
+ The user chose not to participate in the automated sanctions and risk screening process. The risk score reflects this decision and is for informational purposes only.
429
+ </p>
430
+ </div>
431
+ </div>
432
+ </Reveal>
433
+ ) : (
434
+ <>
435
+ {(() => {
436
+ const ss = assessmentResult?.screening_sources;
437
+ const ofacMatches = ss?.ofac_screen?.matches && (ss.ofac_screen.matches.length > 0);
438
+ const cslDetails = ss?.csl_details && (Array.isArray(ss.csl_details) ? ss.csl_details.length > 0 : Object.keys(ss.csl_details).length > 0);
439
+ const fbiMatches = ss?.fbi_matches && (ss.fbi_matches.length > 0);
440
+ if (!(ofacMatches || cslDetails || fbiMatches)) return null;
441
+ return (
442
+ <Reveal headless={isHeadless} className={'mb-8 rounded-lg border p-4'} style={{ borderColor: 'var(--icon-button-secondary)', backgroundColor: 'var(--content-card-background)' }}>
443
+ <h4 className={'text-lg font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>3A. Sanctions Matches</h4>
444
+ {/* OFAC matches */}
445
+ {ofacMatches && (
446
+ <div className={'mb-4'}>
447
+ <h5 className={'font-semibold mb-2'} style={{ color: 'var(--text-main)' }}>OFAC API Matches</h5>
448
+ <div>
449
+ {ss!.ofac_screen!.matches!.map((m, i: number) => {
450
+ const s = m?.sanction;
451
+ const title = s?.name || 'Unknown';
452
+ const programs = (s?.programs && s?.programs.length) ? ` — Programs: ${s?.programs.join(', ')}` : '';
453
+ return (
454
+ <div key={i} style={{ display: 'grid', gridTemplateColumns: '12px 1fr', columnGap: 8, alignItems: 'start', marginBottom: 6 }}>
455
+ <div aria-hidden="true" style={{ width: 6, height: 6, borderRadius: '50%', marginTop: 6, backgroundColor: 'var(--text-secondary)' }} />
456
+ <div className={'text-sm'} style={{ color: 'var(--text-secondary)' }}>
457
+ <span className={'font-medium'} style={{ color: 'var(--text-main)' }}>{title}</span>
458
+ <span>{programs}</span>
459
+ {s?.entityLink ? (
460
+ <>
461
+ {' '}— <a href={s.entityLink} target='_blank' rel='noopener noreferrer' className={'underline'} style={{ color: 'var(--icon-accent)' }}>Details</a>
462
+ </>
463
+ ) : null}
464
+ </div>
465
+ </div>
466
+ );
467
+ })}
468
+ </div>
469
+ <details className={'mt-2'}>
470
+ <summary className={'cursor-pointer text-sm font-semibold'} style={{ color: 'var(--text-main)' }}>View OFAC Raw JSON</summary>
471
+ <pre className={'mt-2 overflow-auto text-xs p-3 rounded'} style={{ background: 'rgba(0,0,0,0.04)', color: 'var(--text-main)' }}>{JSON.stringify(ss!.ofac_screen!.raw, null, 2)}</pre>
472
+ </details>
473
+ </div>
474
+ )}
475
+ {/* CSL details */}
476
+ {cslDetails && (
477
+ <div className={'mb-4'}>
478
+ <h5 className={'font-semibold mb-2'} style={{ color: 'var(--text-main)' }}>U.S. CSL Details</h5>
479
+ <details>
480
+ <summary className={'cursor-pointer text-sm font-semibold'} style={{ color: 'var(--text-main)' }}>View CSL Raw JSON</summary>
481
+ <pre className={'mt-2 overflow-auto text-xs p-3 rounded'} style={{ background: 'rgba(0,0,0,0.04)', color: 'var(--text-main)' }}>{JSON.stringify(ss!.csl_details, null, 2)}</pre>
482
+ </details>
483
+ </div>
484
+ )}
485
+ {/* FBI matches */}
486
+ {fbiMatches && (
487
+ <div className={'mb-2'}>
488
+ <h5 className={'font-semibold mb-2'} style={{ color: 'var(--text-main)' }}>FBI Wanted List Matches</h5>
489
+ <div>
490
+ {ss!.fbi_matches!.map((f, i: number) => (
491
+ <div key={i} style={{ display: 'grid', gridTemplateColumns: '12px 1fr', columnGap: 8, alignItems: 'start', marginBottom: 6 }}>
492
+ <div aria-hidden="true" style={{ width: 6, height: 6, borderRadius: '50%', marginTop: 6, backgroundColor: 'var(--text-secondary)' }} />
493
+ <div className={'text-sm'} style={{ color: 'var(--text-secondary)' }}>
494
+ <span className={'font-medium'} style={{ color: 'var(--text-main)' }}>{f.title || 'Match'}</span>
495
+ {f.url ? <> — <a href={f.url} target='_blank' rel='noopener noreferrer' className={'underline'} style={{ color: 'var(--icon-accent)' }}>Details</a></> : null}
496
+ </div>
497
+ </div>
498
+ ))}
499
+ </div>
500
+ </div>
501
+ )}
502
+ </Reveal>
503
+ );
504
+ })()}
505
+ <Reveal headless={isHeadless}>
506
+ <IpRiskAnalysisDisplay ipRiskAnalysis={screening_sources?.ip_risk_analysis} />
507
+ </Reveal>
508
+ </>
509
+ )}
510
+
511
+ </div>
512
+
513
+ {/* Connected Platforms */}
514
+ <Reveal headless={isHeadless}>
515
+ <ConnectedPlatforms accounts={connected} />
516
+ </Reveal>
517
+
518
+
519
+ <div className="pt-8">
520
+ <h3 className={`text-2xl font-bold mb-4 ${isHeadless ? 'kyd-break-before' : ''}`} style={{ color: 'var(--text-main)' }}>Appendix</h3>
521
+ <div className="space-y-8">
522
+
523
+ {/* Skills */}
524
+ <Reveal headless={isHeadless}>
525
+ <div>
526
+ <h4 id="appendix-skills" className={'text-lg font-bold mb-1'} style={{ color: 'var(--text-main)' }}>Skills</h4>
527
+ <div className="text-sm mb-4" style={{ color: 'var(--text-secondary)' }}>
528
+ Skills are grouped by evidence: Observed when demonstrated in code, Self-reported when declared by the developer without independent verification, and Certified when confirmed through a credential. These categories distinguish between use, claim, and third-party validation.
529
+ </div>
530
+ <SkillsAppendixTable skillsAll={skillsAll} />
531
+ </div>
532
+ </Reveal>
533
+
534
+ {/* Observations */}
535
+ {Array.isArray(graphInsights?.business_rules_all) && graphInsights.business_rules_all.length > 0 && (
536
+ <Reveal headless={isHeadless}>
537
+ <div>
538
+ <h4 className={'text-lg font-bold mb-4'} style={{ color: 'var(--text-main)' }}>Observations</h4>
539
+ <AppendixTables
540
+ type="business_rules"
541
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
542
+ sources={graphInsights.business_rules_all as any}
543
+ searchedAt={updatedAt}
544
+ developerName={developerName || 'this developer'}
545
+ genreMapping={genreMapping as Record<string, string[]>}
546
+ headless={isHeadless}
547
+ />
548
+ </div>
549
+ </Reveal>
550
+ )}
551
+
552
+ {/* Sanctions & Watchlists */}
553
+ {!badgeData.optOutScreening && screening_sources && (
554
+ <Reveal headless={isHeadless}>
555
+ <div>
556
+ <h4 className={'text-lg font-bold mb-4'} style={{ color: 'var(--text-main)' }}>Sanctions & Watchlists</h4>
557
+ {(() => {
558
+ const ofacProvided = screening_sources.ofac_screen?.sources || [];
559
+ const lists = [...(screening_sources.ofac_lists || []), ...ofacProvided];
560
+ const seen: { [k: string]: boolean } = {};
561
+ const dedup: string[] = [];
562
+ for (let i = 0; i < lists.length; i++) {
563
+ const val = lists[i];
564
+ if (!seen[val]) { seen[val] = true; dedup.push(val); }
565
+ }
566
+ const detailed = screening_sources.sanctions_sources_detailed || [];
567
+ const useDetailed = detailed && detailed.length > 0;
568
+ return (
569
+ <AppendixTables
570
+ type="sanctions"
571
+ sources={useDetailed ? detailed : dedup}
572
+ searchedAt={updatedAt}
573
+ developerName={developerName || 'this developer'}
574
+ headless={isHeadless}
575
+ />
576
+ );
577
+ })()}
578
+ </div>
579
+ </Reveal>
580
+ )}
581
+
582
+ </div>
583
+ </div>
584
+
585
+ <Reveal headless={isHeadless}>
586
+ <div className={'pt-8 text-sm text-center'} style={{ color: 'var(--text-secondary)' }}>
587
+ Report Completed: {formatLocalDateTime(updatedAt)}
588
+ </div>
589
+ </Reveal>
590
+ </div>
591
+ </div>
592
+ <Reveal headless={isHeadless}>
593
+ <footer className={'mt-12 pt-6 border-t'} style={{ borderColor: 'var(--icon-button-secondary)' }}>
594
+ <p className={'text-center text-xs max-w-4xl mx-auto'} style={{ color: 'var(--text-secondary)' }}>
595
+ © 2025 Know Your Developer, LLC. All rights reserved. KYD Self-Check™, and associated marks are trademarks of Know Your Developer, LLC. This document is confidential, proprietary, and intended solely for the individual or entity to whom it is addressed. Unauthorized use, disclosure, copying, or distribution of this document or any of its contents is strictly prohibited and may be unlawful. Know Your Developer, LLC assumes no responsibility or liability for any errors or omissions contained herein. Report validity subject to the terms and conditions stated on the official Know Your Developer website located at https://knowyourdeveloper.ai.
596
+ </p>
597
+ </footer>
598
+ </Reveal>
599
+ {/* Floating chat widget */}
600
+ {!headless && (
601
+ <ChatWidget api={chatProps?.api || '/api/chat'} badgeId={badgeId} title={chatProps?.title} hintText={chatProps?.hintText} loginPath={chatProps?.loginPath} headerOffset={chatProps?.headerOffset} developerName={developerName} />
602
+ )}
603
+ </div>
604
+ </BusinessRulesProvider>
605
+ );
606
+ };
607
+
608
+ export default SharedBadgeDisplay;