SPB Git

Repository Public

ShieldNetworkSection.swift 5.3 KB 113 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : QYVORA7// File             : App/Sources/Security/ShieldNetworkSection.swift8// Module           : Security9// Repository       : https://git.spboucher.ai/qyvora10// Project Website  : Not specified11// Created          : 2026-12-0412// Last Modified    : 2026-12-0413//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import QyvoraQuantumShield43import QyvoraWallet44import QyvoraUI4546/// Section 3: what each network of the wallet validates today — its signature scheme and the factual statement — and47/// the capabilities that wait for a protocol change. Independent of this wallet and of this device.48struct ShieldNetworkSection: View {49    let resistance: NetworkResistance50    @State private var open: Set<String> = []5152    var body: some View {53        VStack(alignment: .leading, spacing: QSpace.m) {54            ForEach(resistance.chains) { chain in55                card(chain).id("network-\(chain.id)")56            }57            if let advice = resistance.findings.compactMap(\.recommendation).first {58                Text(advice)59                    .font(QFont.caption)60                    .foregroundStyle(QColor.textSecondary)61                    .fixedSize(horizontal: false, vertical: true)62                    .padding(.horizontal, 2)63            }64        }65        .task {66            if SecShield.startsExpanded { open = Set(resistance.chains.map(\.id)) }67        }68    }6970    func card(_ chain: NetworkResistance.ChainStatus) -> some View {71        let isOpen = open.contains(chain.id)72        return QListSection(separatorInset: QMetric.padding) {73            header(chain)74            Label(chain.offersQuantumResistance ? "Offers a quantum-resistant mechanism" : "No quantum-resistant mechanism today",75                  systemImage: chain.offersQuantumResistance ? "checkmark.shield" : "xmark.shield")76                .font(QFont.callout.weight(.semibold))77                .foregroundStyle(chain.offersQuantumResistance ? QColor.positive : QColor.negative)78                .fixedSize(horizontal: false, vertical: true)79                .frame(maxWidth: .infinity, alignment: .leading)80                .padding(.vertical, QSpace.m)81            SecFactRow(label: "Signatures validated today", value: chain.signatureSchemes.isEmpty ? "Not stated" : chain.signatureSchemes.joined(separator: ", "))82            if let scheme = chain.walletSignatureScheme { SecFactRow(label: "QYVORA signs with", value: scheme) }83            SecTextRow(text: chain.statement)84            if let note = chain.walletSignatureNote { SecTextRow(text: note, systemImage: "info.circle") }85            if !chain.awaitingProtocol.isEmpty {86                Button {87                    if isOpen { open.remove(chain.id) } else { open.insert(chain.id) }88                } label: {89                    SecShieldDisclosureLabel(title: "Awaiting a protocol change", count: chain.awaitingProtocol.count, isOpen: isOpen)90                }91                .buttonStyle(.qRow)92                .accessibilityHint("Disabled capabilities: QYVORA cannot enable them before the network supports them.")93                if isOpen {94                    ForEach(chain.awaitingProtocol) { ProtocolCapabilityRow(capability: $0) }95                    SecTextRow(text: "Disabled. QYVORA cannot enable these before the network supports them.", systemImage: "lock")96                }97            }98        }99        .qHaptic(.selection, trigger: isOpen)100    }101102    @ViewBuilder func header(_ chain: NetworkResistance.ChainStatus) -> some View {103        // by the registry identifier the report carries; by name for a report that has none104        if let network = chain.networkID.flatMap({ ChainID($0).descriptor?.qNetwork }) ?? SecShield.network(named: chain.networkName) {105            SecChainHeader(network: network, detail: chain.signatureSchemes.joined(separator: " · "))106        } else {107            Text(chain.networkName).font(QFont.headline).foregroundStyle(QColor.textPrimary)108                .accessibilityAddTraits(.isHeader)109                .padding(.vertical, QSpace.m)110        }111    }112}113
Files main
Menu

Theme