Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : App/Sources/Security/WatchOnlyFingerprintView.swift8// Module : Security9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0512// Last Modified : 2026-12-0513//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 QyvoraWallet43import QyvoraUI4445/// The code of a watch-only package, in large grouped characters (QYV-APP-080). The signing device shows the five46/// groups next to the package it displays; the device that imports it shows the first four and asks for the fifth, as47/// read on the signing device (`hidesLastGroup`).48struct WatchOnlyFingerprintCard: View {49 let preview: WatchOnlyPreview50 var hidesLastGroup = false5152 private var groups: [String] { hidesLastGroup ? Array(preview.fingerprintGroups.dropLast()) : preview.fingerprintGroups }5354 var body: some View {55 QCard(padding: 20) {56 VStack(alignment: .leading, spacing: QSpace.m) {57 QEyebrow("Package code")58 FlowLayout(spacing: QSpace.s) {59 ForEach(Array(groups.enumerated()), id: \.offset) { _, group in60 Text(group)61 .font(Font.system(.title2, design: .monospaced).weight(.semibold))62 .foregroundStyle(QColor.textPrimary)63 .padding(.horizontal, 10)64 .padding(.vertical, 8)65 .background(QColor.surfaceRaised, in: RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous))66 }67 if hidesLastGroup {68 Text("????")69 .font(Font.system(.title2, design: .monospaced).weight(.semibold))70 .foregroundStyle(QColor.textTertiary)71 .padding(.horizontal, 10)72 .padding(.vertical, 8)73 .overlay(RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous).strokeBorder(QColor.strokeStrong, style: StrokeStyle(lineWidth: 1, dash: [4, 3])))74 }75 }76 .accessibilityElement(children: .ignore)77 .accessibilityLabel("Package code: " + groups.map { $0.map(String.init).joined(separator: " ") }.joined(separator: ", ")78 + (hidesLastGroup ? ". The last group is read on the signing device." : ""))79 Text(hidesLastGroup80 ? "Computed on this device from what was scanned. The signing device shows five groups next to its package: the first four must be these."81 : "Computed from every account of the package. The device that imports the package shows the same code for the same package, and asks for the last group.")82 .font(QFont.caption).foregroundStyle(QColor.textSecondary).fixedSize(horizontal: false, vertical: true)83 }84 .frame(maxWidth: .infinity, alignment: .leading)85 }86 }87}8889/// The first address of every account a watch-only package carries, with its network: what both devices show so90/// that a package naming other accounts is visible (QYV-APP-080).91struct WatchOnlyAccountsSection: View {92 let preview: WatchOnlyPreview93 let title: String94 let footnote: String9596 var body: some View {97 ReviewSection(title, footnote: footnote) {98 ForEach(preview.accounts) { account in99 VStack(alignment: .leading, spacing: 6) {100 HStack(spacing: QSpace.s) {101 if let network = ChainRegistry.descriptor(account.chain)?.qNetwork { ChainGlyph(network, size: .small) }102 Text(account.name).font(QFont.subheadline).foregroundStyle(QColor.textPrimary)103 if !account.isMainnet { QTestTag() }104 Spacer(minLength: 0)105 }106 ChunkedAddressText(account.address, font: QFont.mono.weight(.medium))107 Text(account.detail).font(QFont.caption).foregroundStyle(QColor.textSecondary)108 }109 .frame(maxWidth: .infinity, alignment: .leading)110 .padding(.vertical, QSpace.s)111 .accessibilityElement(children: .combine)112 }113 ForEach(preview.unreadable, id: \.self) { item in114 SecTextRow(text: "\(item): this build cannot derive an address from it. It is part of the package and of its code.",115 systemImage: "exclamationmark.triangle", tone: .warning)116 }117 }118 .privacySensitive()119 }120}121