1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
|
import MapKit
import SwiftUI
// Result detail section views extracted from ContentView.swift — one per
// inspection domain (availability/DNS, ownership, intelligence, subdomains,
// DNS records, web, email, network, ports). Pure presentation over the
// view-model report data; the shared primitives (CardView, SectionTitleView,
// LabeledValueRow, ResultColors, appLoadingStyle) remain in ContentView.swift.
struct DomainSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let rows: [InfoRowViewData]
let suggestions: [DomainSuggestionViewData]
let showSuggestions: Bool
let availabilityLoading: Bool
let suggestionsLoading: Bool
let provenance: SectionProvenance?
let confidence: ConfidenceLevel?
let snapshotNote: String?
let trackedDomain: TrackedDomain?
let workflows: [DomainWorkflow]
let trackingLimitMessage: String?
let pricingLoading: Bool
let pricingError: String?
let showsPricingPlaceholder: Bool
let onTrack: () -> Void
let onTogglePinned: () -> Void
let onEditNote: (() -> Void)?
let onAddToWorkflow: (() -> Void)?
let onOpenWorkflow: ((DomainWorkflow) -> Void)?
let onRunWorkflow: ((DomainWorkflow) -> Void)?
var body: some View {
CollapsibleSectionView(title: "Domain", isCollapsed: $isCollapsed) {
if let trackedDomain {
HStack(spacing: 8) {
// Icon-only: the header also carries Pin and Note, and the
// full "Tracked" pill compresses at larger text sizes.
// VoiceOver still hears the word via the label.
Image(systemName: "eye.fill")
.font(appDensity.font(.caption))
.foregroundStyle(Color(.statusPositive))
.padding(6)
.background(Color(.statusPositiveSurface), in: Circle())
.fixedSize()
.accessibilityLabel("Tracked")
Button {
onTogglePinned()
} label: {
Image(systemName: trackedDomain.isPinned ? "pin.fill" : "pin")
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption))
.accessibilityLabel("Pin domain")
.accessibilityValue(trackedDomain.isPinned ? "Pinned" : "Not pinned")
.accessibilityAddTraits(trackedDomain.isPinned ? .isSelected : [])
if let onEditNote {
Button("Note") {
onEditNote()
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption))
// Never compress into a vertical letter column.
.fixedSize()
}
}
} else {
Button("Track") {
AppHaptics.track()
onTrack()
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption))
.fixedSize()
}
} content: {
CardView(allowsHorizontalScroll: false) {
SectionTrustMetadataView(
provenance: provenance,
confidence: confidence,
note: snapshotNote == nil ? nil : "Audit note present"
)
ForEach(rows) { row in
LabeledValueRow(row: row)
}
if let trackedDomain {
TrackedDomainDetailHeaderView(trackedDomain: trackedDomain)
.padding(.top, 4)
} else if let trackingLimitMessage {
MessageRowView(text: trackingLimitMessage, isError: false)
.padding(.top, 4)
}
if let onAddToWorkflow {
Button {
onAddToWorkflow()
} label: {
Label("Add to workflow", systemImage: "plus.rectangle.on.folder")
.font(appDensity.font(.caption))
}
.buttonStyle(.bordered)
.padding(.top, 4)
}
if !workflows.isEmpty {
VStack(alignment: .leading, spacing: 8) {
Text("Part of workflow")
.font(appDensity.font(.caption))
.foregroundStyle(Color(.appTextSecondary))
ForEach(workflows) { workflow in
HStack {
Text(workflow.name)
.font(appDensity.font(.caption))
.foregroundStyle(.primary)
Spacer()
if let onOpenWorkflow {
Button("Open") {
onOpenWorkflow(workflow)
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption2))
}
if let onRunWorkflow {
Button("Run") {
onRunWorkflow(workflow)
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption2))
}
}
}
}
.padding(.top, 4)
}
if availabilityLoading {
ProgressView("Checking availability…")
.appLoadingStyle()
.padding(.top, 4)
}
if showSuggestions {
Text("Suggestions")
.font(appDensity.font(.caption))
.foregroundStyle(Color(.appTextSecondary))
.padding(.top, 4)
if suggestionsLoading {
ProgressView("Checking alternatives…")
.appLoadingStyle()
} else if suggestions.isEmpty {
MessageRowView(text: "No suggestions", isError: false)
} else {
ForEach(suggestions) { suggestion in
HStack {
Text(suggestion.domain)
.font(appDensity.font(.caption))
.foregroundStyle(.primary)
.textSelection(.enabled)
Spacer()
AppStatusBadgeView(model: AppStatusFactory.availability(suggestion.availabilityStatus))
}
}
}
}
if pricingLoading {
ProgressView("Loading external pricing…")
.appLoadingStyle()
.padding(.top, 4)
} else if let pricingError {
MessageRowView(text: pricingError, isError: false)
.padding(.top, 4)
} else if showsPricingPlaceholder {
MessageRowView(text: "Pricing signals available in Pro+", isError: false)
.padding(.top, 4)
}
}
}
}
}
struct OwnershipSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let rows: [InfoRowViewData]
let loading: Bool
let error: String?
let provenance: SectionProvenance?
let confidence: ConfidenceLevel?
let showsHistoryPlaceholder: Bool
let history: [DomainOwnershipHistoryEvent]
let historyLoading: Bool
let historyError: String?
let historyCreditStatus: UsageCreditStatus?
let onLoadHistory: (() -> Void)?
init(
isCollapsed: Binding<Bool>,
rows: [InfoRowViewData],
loading: Bool,
error: String?,
provenance: SectionProvenance?,
confidence: ConfidenceLevel?,
showsHistoryPlaceholder: Bool,
history: [DomainOwnershipHistoryEvent] = [],
historyLoading: Bool = false,
historyError: String? = nil,
historyCreditStatus: UsageCreditStatus? = nil,
onLoadHistory: (() -> Void)? = nil
) {
_isCollapsed = isCollapsed
self.rows = rows
self.loading = loading
self.error = error
self.provenance = provenance
self.confidence = confidence
self.showsHistoryPlaceholder = showsHistoryPlaceholder
self.history = history
self.historyLoading = historyLoading
self.historyError = historyError
self.historyCreditStatus = historyCreditStatus
self.onLoadHistory = onLoadHistory
}
var body: some View {
CollapsibleSectionView(title: "Ownership", isCollapsed: $isCollapsed) {
CardView(allowsHorizontalScroll: false) {
SectionTrustMetadataView(provenance: provenance, confidence: confidence)
if loading {
ProgressView("Fetching RDAP ownership…")
.appLoadingStyle()
} else {
ForEach(rows) { row in
LabeledValueRow(row: row)
}
if let error, rows.allSatisfy({ $0.value == "Unavailable" }) {
MessageRowView(text: error, isError: error != "Unavailable")
.padding(.top, 4)
}
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("History")
.font(appDensity.font(.caption))
.foregroundStyle(Color(.appTextSecondary))
Spacer()
if let onLoadHistory, history.isEmpty, !historyLoading, !showsHistoryPlaceholder {
Button("Load") {
onLoadHistory()
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption2))
}
}
if historyLoading {
ProgressView("Loading history…")
.appLoadingStyle()
} else if !history.isEmpty {
ForEach(history) { event in
VStack(alignment: .leading, spacing: 3) {
Text(event.date.formatted(date: .abbreviated, time: .omitted))
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
Text(event.summary)
.font(appDensity.font(.caption))
Text(event.source)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
} else if let historyError {
MessageRowView(text: historyError, isError: false)
} else if showsHistoryPlaceholder {
MessageRowView(text: "Ownership history available in Pro+", isError: false)
}
}
}
}
}
}
}
struct IntelligenceSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let report: DomainReport
let showsPlaceholder: Bool
var body: some View {
CollapsibleSectionView(title: "Data+ Intelligence", isCollapsed: $isCollapsed) {
CardView(allowsHorizontalScroll: false) {
if showsPlaceholder {
MessageRowView(text: "Richer intelligence history, hosting analysis, and risk signals are available in Pro+", isError: false)
} else {
if let provider = report.inferredProvider {
intelligenceBlock(title: "Infrastructure") {
LabeledValueRow(row: .init(label: "Provider", value: provider.name, tone: .primary))
if !provider.evidence.isEmpty {
MessageRowView(text: provider.evidence.joined(separator: " • "), isError: false)
}
if !report.priorProviders.isEmpty {
LabeledValueRow(row: .init(label: "Prior", value: report.priorProviders.joined(separator: ", "), tone: .secondary))
}
}
}
if let classification = report.domainClassification {
intelligenceBlock(title: "Classification") {
LabeledValueRow(row: .init(label: "Purpose", value: classification.kind.title, tone: .primary))
MessageRowView(text: classification.reasons.joined(separator: " • "), isError: false)
}
}
intelligenceBlock(title: "Risk Signals") {
if report.riskSignals.isEmpty {
MessageRowView(text: "No material historical risk signals detected", isError: false)
} else {
ForEach(report.riskSignals.prefix(4)) { signal in
VStack(alignment: .leading, spacing: 3) {
Text(signal.title)
.font(appDensity.font(.caption, weight: .semibold))
Text(signal.detail)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
}
intelligenceBlock(title: "Ownership History") {
if report.ownershipTransitions.isEmpty {
MessageRowView(text: "No ownership transitions observed locally", isError: false)
} else {
ForEach(report.ownershipTransitions.prefix(4)) { event in
intelligenceEventRow(date: event.date, title: event.summary)
}
}
}
intelligenceBlock(title: "Hosting History") {
if report.hostingTransitions.isEmpty {
MessageRowView(text: "No hosting transitions observed locally", isError: false)
} else {
ForEach(report.hostingTransitions.prefix(4)) { event in
intelligenceEventRow(date: event.date, title: event.summary)
}
}
}
intelligenceBlock(title: "Subdomain Intelligence") {
if report.subdomainHistory.isEmpty {
MessageRowView(text: "No subdomain history available", isError: false)
} else {
ForEach(report.subdomainHistory.prefix(5)) { item in
VStack(alignment: .leading, spacing: 3) {
HStack {
Text(item.hostname)
.font(appDensity.font(.caption))
Spacer()
if item.isEphemeral {
Text("Ephemeral")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.statusWarning))
}
}
Text("First \(item.firstSeen.formatted(date: .abbreviated, time: .omitted)) • Last \(item.lastSeen.formatted(date: .abbreviated, time: .omitted)) • Seen \(item.recurrenceCount)x")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
}
intelligenceBlock(title: "Timeline") {
if report.intelligenceTimeline.isEmpty {
MessageRowView(text: "No inferred intelligence events yet", isError: false)
} else {
ForEach(report.intelligenceTimeline.prefix(5)) { event in
intelligenceEventRow(date: event.date, title: "\(event.title): \(event.detail)")
}
}
}
}
}
}
}
@ViewBuilder
private func intelligenceBlock<Content: View>(title: String, @ViewBuilder content: () -> Content) -> some View {
VStack(alignment: .leading, spacing: 8) {
Text(title)
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
content()
}
}
private func intelligenceEventRow(date: Date, title: String) -> some View {
VStack(alignment: .leading, spacing: 3) {
Text(date.formatted(date: .abbreviated, time: .omitted))
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
Text(title)
.font(appDensity.font(.caption))
}
}
}
struct SubdomainsSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let rows: [SubdomainRowViewData]
let groups: [SubdomainGroup]
let loading: Bool
let error: String?
let provenance: SectionProvenance?
let confidence: ConfidenceLevel?
let showsExtendedPlaceholder: Bool
let extendedCount: Int
let extendedLoading: Bool
let extendedError: String?
let extendedCreditStatus: UsageCreditStatus?
let onLoadExtended: (() -> Void)?
init(
isCollapsed: Binding<Bool>,
rows: [SubdomainRowViewData],
groups: [SubdomainGroup],
loading: Bool,
error: String?,
provenance: SectionProvenance?,
confidence: ConfidenceLevel?,
showsExtendedPlaceholder: Bool,
extendedCount: Int = 0,
extendedLoading: Bool = false,
extendedError: String? = nil,
extendedCreditStatus: UsageCreditStatus? = nil,
onLoadExtended: (() -> Void)? = nil
) {
_isCollapsed = isCollapsed
self.rows = rows
self.groups = groups
self.loading = loading
self.error = error
self.provenance = provenance
self.confidence = confidence
self.showsExtendedPlaceholder = showsExtendedPlaceholder
self.extendedCount = extendedCount
self.extendedLoading = extendedLoading
self.extendedError = extendedError
self.extendedCreditStatus = extendedCreditStatus
self.onLoadExtended = onLoadExtended
}
var body: some View {
CollapsibleSectionView(title: "Subdomains", isCollapsed: $isCollapsed, subtitle: "\(rows.count) found") {
CardView(allowsHorizontalScroll: false) {
SectionTrustMetadataView(provenance: provenance, confidence: confidence)
if loading {
ProgressView("Checking certificate transparency…")
.appLoadingStyle()
} else if rows.isEmpty {
MessageRowView(text: error ?? "No passive subdomains found", isError: false)
if showsExtendedPlaceholder {
MessageRowView(text: "Extended subdomain discovery available in Pro+", isError: false)
.padding(.top, 4)
}
} else {
if let onLoadExtended, extendedCount == 0, !extendedLoading, !showsExtendedPlaceholder {
Button("Load extended results") {
onLoadExtended()
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption2))
}
if !groups.isEmpty {
Text("Groups")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
ForEach(groups) { group in
HStack {
Text("\(group.label).*")
.font(appDensity.font(.caption))
.foregroundStyle(Color(.statusInfo))
Spacer()
Text("\(group.subdomains.count)")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
ForEach(rows) { row in
HStack(spacing: 8) {
Text(row.hostname)
.font(appDensity.font(.caption))
.foregroundStyle(.primary)
.textSelection(.enabled)
Spacer()
if row.isInteresting {
Text("Interesting")
.font(.system(.caption2, design: .monospaced))
.foregroundStyle(Color(.statusWarning))
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(Color(.statusWarningSurface))
.clipShape(Capsule())
}
}
}
if extendedLoading {
ProgressView("Loading extended subdomains…")
.appLoadingStyle()
.padding(.top, 4)
} else if extendedCount > 0 {
MessageRowView(text: "\(extendedCount) extended results included", isError: false)
.padding(.top, 4)
} else if let extendedError {
MessageRowView(text: extendedError, isError: false)
.padding(.top, 4)
} else if showsExtendedPlaceholder {
MessageRowView(text: "Extended subdomain discovery available in Pro+", isError: false)
.padding(.top, 4)
}
}
}
}
}
}
struct DNSSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let dnssecLabel: String?
let patternSummary: DNSPatternSummary?
let sections: [DNSRecordSectionViewData]
let ptrMessage: SectionMessageViewData?
let loading: Bool
let dnsProvenance: SectionProvenance?
let ptrProvenance: SectionProvenance?
let sectionError: String?
let history: [DNSHistoryEvent]
let historyLoading: Bool
let historyError: String?
let showsHistoryPlaceholder: Bool
let historyCreditStatus: UsageCreditStatus?
let onLoadHistory: (() -> Void)?
init(
isCollapsed: Binding<Bool>,
dnssecLabel: String?,
patternSummary: DNSPatternSummary?,
sections: [DNSRecordSectionViewData],
ptrMessage: SectionMessageViewData?,
loading: Bool,
dnsProvenance: SectionProvenance?,
ptrProvenance: SectionProvenance?,
sectionError: String?,
history: [DNSHistoryEvent] = [],
historyLoading: Bool = false,
historyError: String? = nil,
showsHistoryPlaceholder: Bool = false,
historyCreditStatus: UsageCreditStatus? = nil,
onLoadHistory: (() -> Void)? = nil
) {
_isCollapsed = isCollapsed
self.dnssecLabel = dnssecLabel
self.patternSummary = patternSummary
self.sections = sections
self.ptrMessage = ptrMessage
self.loading = loading
self.dnsProvenance = dnsProvenance
self.ptrProvenance = ptrProvenance
self.sectionError = sectionError
self.history = history
self.historyLoading = historyLoading
self.historyError = historyError
self.showsHistoryPlaceholder = showsHistoryPlaceholder
self.historyCreditStatus = historyCreditStatus
self.onLoadHistory = onLoadHistory
}
var body: some View {
CollapsibleSectionView(title: "DNS", isCollapsed: $isCollapsed, subtitle: dnssecLabel) {
if loading {
LoadingCardView(text: "Querying DNS…")
} else if let sectionError, sections.isEmpty {
MessageCardView(text: sectionError, isError: true)
} else {
if dnsProvenance != nil {
CardView(allowsHorizontalScroll: false) {
SectionTrustMetadataView(provenance: dnsProvenance, confidence: nil)
if let patternSummary {
if !patternSummary.providers.isEmpty {
MessageRowView(text: "Providers: \(patternSummary.providers.joined(separator: ", "))", isError: false)
}
if !patternSummary.patterns.isEmpty {
ForEach(Array(patternSummary.patterns.enumerated()), id: \.offset) { _, pattern in
MessageRowView(text: pattern, isError: false)
}
}
}
}
}
ForEach(sections) { section in
CardView {
Text(section.title)
.font(.system(.subheadline, design: .monospaced))
.fontWeight(.semibold)
.foregroundStyle(Color(.statusInfo))
if let message = section.message {
MessageRowView(text: message.text, isError: message.isError)
}
ForEach(section.rows) { row in
LabeledValueRow(row: row)
}
if let wildcardTitle = section.wildcardTitle {
Text(wildcardTitle)
.font(.system(.caption, design: .monospaced))
.foregroundStyle(Color(.appTextSecondary))
.padding(.top, 4)
ForEach(section.wildcardRows) { row in
LabeledValueRow(row: row)
}
}
}
}
if let ptrMessage {
CardView {
Text("PTR")
.font(.system(.subheadline, design: .monospaced))
.fontWeight(.semibold)
.foregroundStyle(Color(.statusInfo))
SectionTrustMetadataView(provenance: ptrProvenance, confidence: nil)
MessageRowView(text: ptrMessage.text, isError: ptrMessage.isError)
}
}
CardView(allowsHorizontalScroll: false) {
HStack {
Text("History")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
Spacer()
if let onLoadHistory, history.isEmpty, !historyLoading, !showsHistoryPlaceholder {
Button("Load") {
onLoadHistory()
}
.buttonStyle(.bordered)
.font(appDensity.font(.caption2))
}
}
if historyLoading {
ProgressView("Loading DNS history…")
.appLoadingStyle()
} else if !history.isEmpty {
ForEach(history) { event in
VStack(alignment: .leading, spacing: 3) {
Text(event.date.formatted(date: .abbreviated, time: .omitted))
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
Text(event.summary)
.font(appDensity.font(.caption))
if !event.aRecords.isEmpty {
Text("A: \(event.aRecords.joined(separator: ", "))")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
if !event.nameservers.isEmpty {
Text("NS: \(event.nameservers.joined(separator: ", "))")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
} else if let historyError {
MessageRowView(text: historyError, isError: false)
} else if showsHistoryPlaceholder {
MessageRowView(text: "DNS history available in Pro+", isError: false)
}
}
}
}
}
}
struct WebSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let certificateRows: [InfoRowViewData]
let sslInfo: SSLCertificateInfo?
let tlsSummary: WebResultSummary?
let sslLoading: Bool
let sslError: String?
let tlsProvenance: SectionProvenance?
let responseRows: [InfoRowViewData]
let headers: [HTTPHeader]
let headersLoading: Bool
let headersError: String?
let httpProvenance: SectionProvenance?
let redirects: [RedirectHopViewData]
let redirectLoading: Bool
let redirectError: String?
let redirectProvenance: SectionProvenance?
let finalURL: String?
var body: some View {
CollapsibleSectionView(title: "Web", isCollapsed: $isCollapsed) {
CardView {
HStack {
Text("TLS")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
Spacer()
if !sslLoading {
AppStatusBadgeView(model: AppStatusFactory.tls(sslInfo: sslInfo, error: sslError))
}
}
SectionTrustMetadataView(provenance: tlsProvenance, confidence: nil)
if !sslLoading, let tlsSummary {
LabeledValueRow(row: InfoRowViewData(label: "TLS Grade", value: tlsSummary.tlsGrade.rawValue, tone: tlsSummary.tlsGrade.tone))
ForEach(Array(tlsSummary.tlsHighlights.enumerated()), id: \.offset) { _, highlight in
MessageRowView(text: highlight, isError: isTLSHighlightError(highlight))
}
}
if sslLoading {
ProgressView("Checking certificate…")
.appLoadingStyle()
} else if let sslError {
MessageRowView(text: sslError, isError: true)
} else {
ForEach(certificateRows) { row in
LabeledValueRow(row: row)
}
if let sslInfo, !sslInfo.subjectAltNames.isEmpty {
Text("SANs")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
ForEach(sslInfo.subjectAltNames, id: \.self) { san in
HStack(alignment: .top, spacing: 8) {
Text(san)
.font(appDensity.font(.caption))
.lineLimit(nil)
.fixedSize(horizontal: false, vertical: true)
.textSelection(.enabled)
Spacer()
AppCopyButton(value: san, label: "Copy certificate SAN")
}
}
}
}
}
CardView {
Text("Headers")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
SectionTrustMetadataView(provenance: httpProvenance, confidence: nil)
if headersLoading {
ProgressView("Fetching headers…")
.appLoadingStyle()
} else if let headersError {
MessageRowView(text: headersError, isError: true)
} else {
ForEach(responseRows) { row in
LabeledValueRow(row: row)
}
if headers.isEmpty {
MessageRowView(text: "No HTTP headers returned", isError: false)
} else {
ForEach(headers) { header in
HStack(alignment: .top, spacing: 4) {
Text(header.name + ":")
.font(appDensity.font(.caption))
.foregroundStyle(header.isSecurityHeader ? Color(.statusWarning) : Color(.statusInfo))
Text(header.value)
.font(appDensity.font(.caption))
.foregroundStyle(.primary)
.textSelection(.enabled)
}
}
}
}
}
CardView {
HStack {
Text("Redirects")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
Spacer()
if let finalURL {
AppCopyButton(value: finalURL, label: "Copy redirect URL")
}
}
SectionTrustMetadataView(provenance: redirectProvenance, confidence: nil)
if redirectLoading {
ProgressView("Tracing redirects…")
.appLoadingStyle()
} else if let redirectError {
MessageRowView(text: redirectError, isError: true)
} else if redirects.isEmpty {
MessageRowView(text: "No redirect data available", isError: false)
} else {
if let finalURL {
LabeledValueRow(row: InfoRowViewData(label: "Final URL", value: finalURL, tone: .secondary))
}
ForEach(redirects) { redirect in
HStack(alignment: .top, spacing: 6) {
Text(redirect.stepLabel)
.font(appDensity.font(.caption))
.foregroundStyle(Color(.appTextSecondary))
.frame(width: 16, alignment: .trailing)
Text(redirect.statusCode)
.font(appDensity.font(.caption))
.foregroundStyle(Color(.statusInfo))
.frame(width: 36, alignment: .leading)
Text(redirect.url)
.font(appDensity.font(.caption))
.textSelection(.enabled)
AppCopyButton(value: redirect.url, label: "Copy redirect URL")
if redirect.isFinal {
Text("(final)")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
}
}
}
}
private func isTLSHighlightError(_ highlight: String) -> Bool {
let normalized = highlight.lowercased()
if normalized.contains("no weak tls indicators were detected") {
return false
}
return normalized.contains("expires")
|| normalized.contains("weak")
|| normalized.contains("tls 1.0")
|| normalized.contains("tls 1.1")
}
}
struct EmailSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let rows: [EmailRowViewData]
let assessment: EmailSecuritySummary?
let loading: Bool
let provenance: SectionProvenance?
let confidence: ConfidenceLevel?
let error: String?
var body: some View {
CollapsibleSectionView(title: "Email", isCollapsed: $isCollapsed) {
CardView {
SectionTrustMetadataView(provenance: provenance, confidence: confidence)
HStack {
Spacer()
AppStatusBadgeView(model: AppStatusFactory.email(nil, error: error))
.opacity(loading ? 0 : 1)
}
if let assessment, let grade = assessment.grade {
LabeledValueRow(row: InfoRowViewData(label: "Grade", value: grade.rawValue, tone: grade.tone))
if !assessment.reasons.isEmpty {
Text(assessment.reasons.joined(separator: " | "))
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
if loading {
ProgressView("Checking email records…")
.appLoadingStyle()
} else if let error {
MessageRowView(text: error, isError: true)
} else if rows.isEmpty {
MessageRowView(text: "No email security records found", isError: false)
} else {
ForEach(rows) { row in
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 8) {
Text(row.label)
.font(appDensity.font(.caption))
.foregroundStyle(Color(.statusInfo))
.frame(width: 76, alignment: .leading)
AppStatusBadgeView(model: emailRowBadge(row))
}
Text(row.detail)
.font(appDensity.font(.caption2))
.foregroundStyle(.primary)
.textSelection(.enabled)
if let auxiliaryDetail = row.auxiliaryDetail {
Text(auxiliaryDetail)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
}
}
}
}
}
}
private func emailRowBadge(_ row: EmailRowViewData) -> AppStatusBadgeModel {
switch row.statusTone {
case .success:
return .init(title: row.status, systemImage: "checkmark.shield.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface))
case .warning:
return .init(title: row.status, systemImage: "shield.lefthalf.filled", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface))
case .failure:
return .init(title: row.status, systemImage: "minus.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated))
case .primary, .secondary:
return .init(title: row.status, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated))
}
}
}
struct NetworkSectionView: View {
@Environment(\.appDensity) private var appDensity
@Binding var isCollapsed: Bool
let reachabilityRows: [ReachabilityRowViewData]
let reachabilityLoading: Bool
let reachabilityError: String?
let reachabilityProvenance: SectionProvenance?
let locationRows: [InfoRowViewData]
let geolocation: IPGeolocation?
let geolocationLoading: Bool
let geolocationError: String?
let geolocationProvenance: SectionProvenance?
let geolocationConfidence: ConfidenceLevel?
let standardPortRows: [PortScanRowViewData]
let customPortRows: [PortScanRowViewData]
let portScanLoading: Bool
let portScanError: String?
let portScanProvenance: SectionProvenance?
let customPortScanLoading: Bool
let customPortScanError: String?
let isCloudflareProxied: Bool
@Binding var customPortsExpanded: Bool
@Binding var customPortInput: String
let onScanCustomPorts: () -> Void
var body: some View {
CollapsibleSectionView(title: "Network", isCollapsed: $isCollapsed) {
CardView {
Text("Reachability")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
SectionTrustMetadataView(provenance: reachabilityProvenance, confidence: nil)
if reachabilityLoading {
ProgressView("Checking ports…")
.appLoadingStyle()
} else if let reachabilityError {
MessageRowView(text: reachabilityError, isError: true)
} else {
ForEach(reachabilityRows) { row in
HStack {
Text(row.portLabel)
.font(appDensity.font(.caption))
Spacer()
Text(row.latencyLabel)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
AppStatusBadgeView(model: reachabilityBadge(row))
}
}
}
}
CardView(allowsHorizontalScroll: false) {
Text("Location")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
SectionTrustMetadataView(provenance: geolocationProvenance, confidence: geolocationConfidence)
if geolocationLoading {
ProgressView("Looking up location…")
.appLoadingStyle()
} else if let geolocationError, geolocation == nil {
MessageRowView(text: geolocationError, isError: geolocationError != "No A record available")
} else if let geolocation {
ForEach(locationRows) { row in
LabeledValueRow(row: row)
}
if let latitude = geolocation.latitude, let longitude = geolocation.longitude {
let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
Map(initialPosition: .region(MKCoordinateRegion(
center: coordinate,
span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1)
))) {
Marker(geolocation.ip, coordinate: coordinate)
}
.mapStyle(.standard)
.frame(maxWidth: .infinity)
.frame(height: 180)
.cornerRadius(8)
}
} else {
MessageRowView(text: "No location data available", isError: false)
}
}
CardView(allowsHorizontalScroll: false) {
Text("Port Scan")
.font(appDensity.font(.subheadline, weight: .semibold))
.foregroundStyle(Color(.statusInfo))
SectionTrustMetadataView(provenance: portScanProvenance, confidence: nil)
if isCloudflareProxied {
Text("Domain is behind Cloudflare's proxy. Results reflect the edge, not the origin.")
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.statusWarning))
.fixedSize(horizontal: false, vertical: true)
}
if portScanLoading {
ProgressView("Scanning ports…")
.appLoadingStyle()
} else if let portScanError, standardPortRows.isEmpty {
MessageRowView(text: portScanError, isError: true)
} else {
Text("Standard Ports")
.font(.system(.caption, design: .monospaced))
.foregroundStyle(Color(.appTextSecondary))
PortRowsView(rows: standardPortRows)
}
DisclosureGroup("Custom Ports", isExpanded: $customPortsExpanded) {
VStack(alignment: .leading, spacing: 10) {
TextField("8888, 9000, 27017", text: $customPortInput)
.font(appDensity.font(.caption))
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.keyboardType(.numberPad)
.padding(10)
.background(Color(.appSurface))
.clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
Button("Scan") {
AppHaptics.refresh()
onScanCustomPorts()
}
.buttonStyle(.borderedProminent)
.tint(Color(.accentFill))
.disabled(customPortScanLoading)
if customPortScanLoading {
ProgressView("Scanning custom ports…")
.appLoadingStyle()
} else if let customPortScanError {
MessageRowView(text: customPortScanError, isError: true)
} else {
PortRowsView(rows: customPortRows)
}
}
.padding(.top, 8)
}
.font(.system(.caption, design: .monospaced))
.tint(.secondary)
}
}
}
private func reachabilityBadge(_ row: ReachabilityRowViewData) -> AppStatusBadgeModel {
switch row.statusTone {
case .success:
return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface))
case .warning:
return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface))
case .failure:
return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface))
case .primary, .secondary:
return .init(title: row.statusLabel, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated))
}
}
}
struct PortRowsView: View {
@Environment(\.appDensity) private var appDensity
let rows: [PortScanRowViewData]
var body: some View {
if rows.isEmpty {
MessageRowView(text: "No results", isError: false)
} else {
ForEach(rows) { row in
VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing - 1) {
HStack {
Text(row.portLabel)
.font(appDensity.font(.caption))
.frame(width: 52, alignment: .leading)
Text(row.service)
.font(appDensity.font(.caption))
.foregroundStyle(.primary)
Spacer()
if let durationLabel = row.durationLabel {
Text(durationLabel)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
}
AppStatusBadgeView(model: portBadge(row))
}
if let banner = row.banner {
Text(banner)
.font(appDensity.font(.caption2))
.foregroundStyle(Color(.appTextSecondary))
.padding(.leading, 8)
}
}
.frame(minHeight: appDensity.metrics.rowMinHeight, alignment: .topLeading)
}
}
}
private func portBadge(_ row: PortScanRowViewData) -> AppStatusBadgeModel {
switch row.statusTone {
case .success:
return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface))
case .warning:
return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface))
case .failure:
return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface))
case .primary, .secondary:
return .init(title: row.statusLabel, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated))
}
}
}
|