SPB Git

Repository Public

IdentityContactView.swift 4.6 KB 94 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : QYVORA7// File             : App/Sources/Security/IdentityContactView.swift8// Module           : Security9// Repository       : https://git.spboucher.ai/qyvora10// Project Website  : Not specified11// Created          : 2026-12-0412// 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 QyvoraIdentity43import QyvoraUI4445/// Reads a contact's public identity (pasted or scanned) and shows its fingerprint so that it can be compared before46/// a device-to-device transfer. QYVORA keeps no address book: nothing is stored.47struct IdentityContactView: View {48    @State private var text = ""49    @State private var scanning = false5051    var trimmed: String { text.trimmingCharacters(in: .whitespacesAndNewlines) }52    var identity: PublicIdentity? { try? PublicIdentity(text: trimmed) }5354    var body: some View {55        SecurityScroll {56            Explanation("Scan or paste the public identity shown by the other device. Check its fingerprint with the owner, by eye or by voice, before sending anything to it.")57            VStack(alignment: .leading, spacing: 6) {58                QEyebrow("Public identity (qyvora-id:…)")59                TextEditor(text: $text)60                    .font(QFont.mono)61                    .textInputAutocapitalization(.never)62                    .autocorrectionDisabled()63                    .frame(minHeight: 90)64                    .scrollContentBackground(.hidden)65                    .padding(8)66                    .background(QColor.surface, in: RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous))67                    .overlay(RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous).strokeBorder(QColor.stroke, lineWidth: 1))68                    .accessibilityLabel("Public identity")69            }70            Button { scanning = true } label: { Label("Scan the identity", systemImage: "qrcode.viewfinder") }71                .buttonStyle(.qSecondary)72            if let identity {73                QListSection("Fingerprint of this identity", separatorInset: QMetric.padding) {74                    FingerprintView(text: identity.fingerprintText).padding(.vertical, QSpace.m)75                    SecFactRow(label: "Created", value: SecurityFormat.date(Date(timeIntervalSince1970: TimeInterval(identity.createdAt))))76                }77                QListSection(footnote: "Nothing is saved: this identity is forgotten when you leave the screen.") {78                    SecLinkRow(title: "Transfer the wallet to this identity", subtitle: "Encrypted for it, signed by this wallet", systemImage: "iphone.and.arrow.forward",79                               value: SecurityRoute.transferSend(receiver: trimmed))80                }81            } else if !trimmed.isEmpty {82                WarningBanner(.warning, message: "This is not a valid public identity. It starts with \u{201C}qyvora-id:\u{201D} and must be complete.")83            }84        }85        .navigationTitle("Contact identity")86        .navigationBarTitleDisplayMode(.inline)87        .sheet(isPresented: $scanning) {88            PayloadScannerSheet(title: "Scan an identity", prompt: "Keep the animated code in the frame") { frames in89                if let scanned = PayloadText.text(from: frames) { text = scanned }90            }91        }92    }93}94
Files main
Menu

Theme