Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : SP Wallet for macOS9// File : Features/TradingAgents/TradingAPIView.swift10// Description : The trading API tab: keys (reading permissions and11// financial permissions kept apart, mandate binding, limits,12// last use), their creation / change / rotation through a13// review of the verified key intent and the passkey,14// revocation without one, the one-time secret sheet,15// webhooks with their deliveries, usage and rate limits, and16// the link to the server's API reference. The server lock on17// live execution is shown with its reason.18// Module : Features19// Repository : https://git.spboucher.ai/sp-wallet-macos20// Created : 2026-11-1821// Last Modified : 2026-11-1822//23// =============================================================================24// AUTHOR & PROFESSIONAL AFFILIATION25// =============================================================================26//27// Author : Simon-Pierre Boucher28// Position : Professor of Finance29// Institution : Université du Québec en Outaouais (UQO)30// Department : Département des sciences administratives31// Organization : SP Boucher32//33// Website : https://spboucher.ai34// Git : https://git.spboucher.ai35//36// =============================================================================37// OFFICIAL CONTACT DIRECTORY38// =============================================================================39//40// General : info@spboucher.ai41// Professional : contact@spboucher.ai42// Direct : simon@spboucher.ai43// Research : research@spboucher.ai44// Development : dev@spboucher.ai45// Support : support@spboucher.ai46// Security/Admin : admin@spboucher.ai47// Notifications : notifications@spboucher.ai48//49// Preferred Contact: support@spboucher.ai50//51// =============================================================================52// COPYRIGHT & INTELLECTUAL PROPERTY53// =============================================================================54//55// Copyright (c) 202656// Simon-Pierre Boucher57//58// All rights reserved where applicable.59//60// This file is governed by the applicable project license,61// copyright notices, institutional agreements and relevant law.62//63// Unless expressly authorized by the applicable license or64// rights holder, copying, redistribution, sublicensing,65// publication and commercial exploitation are not permitted.66//67// Existing third-party rights and notices remain unaffected.68//69// =============================================================================70// CONFIDENTIALITY & SECURITY71// =============================================================================72//73// Classification : Public74// Distribution : Public repository; use is governed by the project license75// Security Contact : admin@spboucher.ai76//77// Access to this source does not independently grant permission78// to redistribute or disclose confidential materials.79//80// Do not embed credentials, private keys, access tokens,81// certificates or confidential personal information.82//83// =============================================================================84// LICENSE & MAINTENANCE85// =============================================================================86//87// License : None specified (no license file in this repository)88// Maintainer : Simon-Pierre Boucher89// Technical Contact: dev@spboucher.ai90//91// =============================================================================92// END OF SP BOUCHER SOURCE HEADER93// =============================================================================9495import SwiftUI96import SPWalletCore9798struct TradingAPIView: View {99 let model: AppModel100 let locks: [ExecutionLock]?101 enum Tab: String, CaseIterable { case keys = "Clés", webhooks = "Webhooks", usage = "Utilisation et état" }102 @State private var store: TradingAPIStore?103 @State private var tab: Tab = .keys104 @State private var editing: KeyEdit?105106 struct KeyEdit: Identifiable { let id = UUID(); let key: APIKey? }107108 var body: some View {109 Group {110 if let store {111 executionCard(store)112 Picker("Section", selection: $tab) { ForEach(Tab.allCases, id: \.self) { Text($0.rawValue).tag($0) } }.pickerStyle(.segmented).labelsHidden().frame(maxWidth: 420)113 if let n = store.notice { Banner(.info, n) }114 if let e = store.actionError, store.pending == nil { Banner(.danger, e) }115 switch tab {116 case .keys: keysCard(store)117 case .webhooks: WebhooksView(model: model, store: store)118 case .usage: APIUsageView(store: store)119 }120 } else { ProgressView() }121 }122 .task { if store == nil { store = TradingAPIStore(model: model) }; await store?.poll() }123 .sheet(item: $editing) { e in if let store, let info = store.keys { APIKeyFormSheet(model: model, store: store, info: info, key: e.key) { editing = nil } } }124 .sheet(isPresented: Binding(get: { store?.pending != nil && editing == nil }, set: { _ in })) { if let store, let p = store.pending { APIKeyApprovalSheet(model: model, store: store, pending: p, info: store.keys) } }125 .sheet(isPresented: Binding(get: { store?.shown != nil && store?.pending == nil && editing == nil }, set: { if !$0 { store?.dismissSecret() } })) { if let store, let s = store.shown { OneTimeSecretSheet(shown: s) { store.dismissSecret() } } }126 }127128 @ViewBuilder private func executionCard(_ store: TradingAPIStore) -> some View {129 Card("API de trading programmable") {130 Text("Des programmes à vous peuvent lire le portefeuille et, avec une permission financière ET un mandat lié à la clé, passer des ordres dans les bornes de ce mandat. Une clé ne peut jamais dépasser son mandat ni retirer des fonds.").fixedSize(horizontal: false, vertical: true)131 if let x = store.keys?.execution {132 LockRow(name: "trading_api_execution", open: x.liveEnabled == true, reason: x.note ?? x.code ?? (x.liveEnabled == nil ? "état non publié par le serveur" : nil))133 if !x.wired { Text("L’exécution n’est pas câblée sur ce serveur : les permissions financières ne peuvent rien exécuter.").font(.caption).foregroundStyle(Theme.warning) }134 } else if let l = locks?.first(where: { $0.id == "trading_api_execution" }) { LockRow(name: l.id, open: l.on, reason: l.why) }135 if store.keys?.execution?.liveEnabled == false { Text("Verrou fermé : aucun nouvel ordre RÉEL ne passe par l’API ; le papier, les annulations et les ordres strictement réducteurs passent encore.").font(.caption).foregroundStyle(.secondary) }136 let url = model.configuration.origin.appendingPathComponent("api/v1/trading/docs")137 HStack(spacing: 8) {138 Image(systemName: "book")139 if url.scheme == "https" { Link("Référence de l’API sur le serveur", destination: url) } else { Text("Référence de l’API : \(url.absoluteString)").textSelection(.enabled); Text("(lien non https : non ouvert par l’app)").font(.caption).foregroundStyle(.secondary) }140 }141 Text("La référence exige une session du portefeuille dans le navigateur ou une clé d’API valide.").font(.caption).foregroundStyle(.secondary)142 }143 }144145 @ViewBuilder private func keysCard(_ store: TradingAPIStore) -> some View {146 Card("Clés d’API", trailing: AnyView(HStack {147 if store.busy != nil { ProgressView().controlSize(.small) }148 Button { editing = KeyEdit(key: nil) } label: { Label("Nouvelle clé…", systemImage: "plus") }.disabled(!model.canOperate || store.keys == nil || store.busy != nil)149 })) {150 if let info = store.keys {151 let financial = Set(info.scopes.filter(\.execution).map(\.scope))152 if info.keys.isEmpty { EmptyState(symbol: "key", title: "Aucune clé", detail: "Une clé se crée avec votre passkey ; sa valeur secrète n’est montrée qu’une seule fois.") }153 ForEach(info.keys) { k in keyRow(k, financial, store) ; Divider() }154 Text("Bornes du serveur : \(info.bounds.maxKeys) clés au plus · validité ≤ \(info.bounds.maxDays) jours · cadence ≤ \(info.bounds.maxRatePerMin) requêtes/min\(info.bounds.maxNotionalUsd.map { " · plafonds ≤ \(AgentCreateForm.plain($0)) USD" } ?? "").").font(.caption).foregroundStyle(.secondary)155 } else { Unavailable(what: "Clés", error: store.errors["keys"]) }156 }157 }158159 @ViewBuilder private func keyRow(_ k: APIKey, _ financial: Set<String>, _ store: TradingAPIStore) -> some View {160 let read = k.scopes.filter { !financial.contains($0) }, fin = k.scopes.filter { financial.contains($0) }161 VStack(alignment: .leading, spacing: 5) {162 HStack(spacing: 8) {163 Text(k.name).font(.headline)164 Text(k.id).font(Theme.monoSmall).foregroundStyle(.secondary).textSelection(.enabled)165 Text(k.status == "active" ? "active" : k.status == "revoked" ? "révoquée" : k.status == "expired" ? "expirée" : k.status).font(.caption.weight(.semibold)).foregroundStyle(k.isActive ? Theme.positive : Theme.negative)166 .padding(.horizontal, 7).padding(.vertical, 2).background((k.isActive ? Theme.positive : Theme.negative).opacity(0.13), in: Capsule())167 Spacer()168 if k.isActive {169 Button("Modifier…") { editing = KeyEdit(key: k) }170 Button("Renouveler…") { Task { await store.prepareRotate(k) } }.help("Nouvel identifiant et nouveau secret, mêmes permissions ; l’ancienne clé cesse de fonctionner. Passkey requise.")171 Button("Révoquer", role: .destructive) { Task { await store.revoke(k) } }.help("Immédiat, sans passkey : révoquer ne fait que retirer une autorité.")172 }173 }.disabled(model.phase != .signedIn || store.busy != nil)174 scopeLine("Lecture", read, .secondary)175 if !fin.isEmpty {176 scopeLine("Financières", fin, Theme.negative)177 if !k.inertScopes.isEmpty { Label("Inertes (aucun mandat lié) : \(k.inertScopes.joined(separator: ", "))", systemImage: "moon.zzz").font(.caption).foregroundStyle(Theme.warning) }178 }179 Text("Mandat lié : \(k.mandateId.map { id in store.mandates(for: k.id).first { $0.id == id }.map { "\(id) — \($0.mode) · \($0.state)/\($0.phase)" } ?? id } ?? "aucun")").font(.callout).textSelection(.enabled)180 Text("Plafonds : par ordre \(k.limits.maxOrderNotionalUsd.value.map { AgentCreateForm.plain($0) + " USD" } ?? "non défini") · par jour \(k.limits.maxDailyNotionalUsd.value.map { AgentCreateForm.plain($0) + " USD" } ?? "non défini") · \(k.rateLimitPerMin) requêtes/min").font(.callout)181 let r = k.restrictions182 if !(r.networks.isEmpty && r.venues.isEmpty && r.instruments.isEmpty && r.ipAllow.isEmpty) {183 Text("Restrictions : " + [r.networks.isEmpty ? nil : "réseaux \(r.networks.joined(separator: ", "))", r.venues.isEmpty ? nil : "plateformes \(r.venues.joined(separator: ", "))", r.instruments.isEmpty ? nil : "marchés \(r.instruments.joined(separator: ", "))", r.ipAllow.isEmpty ? nil : "adresses IP \(r.ipAllow.joined(separator: ", "))"].compactMap { $0 }.joined(separator: " · ")).font(.caption).foregroundStyle(.secondary)184 }185 Text("Créée \(Fmt.date(AgentText.ms(k.createdAt))) · expire \(Fmt.date(AgentText.ms(k.expiresAt))) · dernière utilisation : \(k.lastUsedAt.map { Fmt.relative(AgentText.ms($0)) + (k.lastUsedIp.map { " depuis \($0)" } ?? "") } ?? "jamais")\(k.rotatedFrom.map { " · renouvelée depuis \($0)" } ?? "")\(k.revokedAt.map { " · révoquée \(Fmt.date(AgentText.ms($0)))\(k.revokedReason.map { " (\($0))" } ?? "")" } ?? "")").font(.caption).foregroundStyle(.secondary)186 }187 }188189 private func scopeLine(_ title: String, _ scopes: [String], _ color: Color) -> some View {190 HStack(alignment: .firstTextBaseline, spacing: 6) {191 Text(title).font(.caption.weight(.semibold)).foregroundStyle(color).frame(width: 80, alignment: .leading)192 Text(scopes.isEmpty ? "—" : scopes.joined(separator: " · ")).font(Theme.monoSmall).foregroundStyle(color == .secondary ? Color.primary : color)193 }194 }195}196197// MARK: key form198199struct APIKeyFormSheet: View {200 let model: AppModel201 let store: TradingAPIStore202 let info: APIKeyList203 let key: APIKey?204 let close: () -> Void205 @State private var form = APIKeyForm()206 @State private var accepted = 0207208 var body: some View {209 let financialOffered = info.scopes.filter(\.execution), readOffered = info.scopes.filter { !$0.execution }210 let financial = !form.scopes.isDisjoint(with: Set(financialOffered.map(\.scope)))211 SheetScaffold(title: key == nil ? "Nouvelle clé d’API" : "Modifier la clé \(key!.id)", width: 700, height: 760) {212 Form {213 TextField("Nom", text: $form.name)214 if key == nil { TextField("Expiration (jours, 1 à \(info.bounds.maxDays))", text: $form.days, prompt: Text("à indiquer")) }215 TextField("Cadence (requêtes par minute, 1 à \(info.bounds.maxRatePerMin))", text: $form.rate, prompt: Text("à indiquer — suggestion du serveur : \(info.bounds.defaultRatePerMin)"))216 }.formStyle(.grouped).scrollDisabled(true)217 scopeGroup("Permissions de LECTURE", "Elles ne peuvent ni déplacer de fonds ni créer d’exposition.", readOffered, .secondary)218 scopeGroup("Permissions FINANCIÈRES (exécution)", "Elles peuvent engager des fonds ou de l’exposition — uniquement sous un mandat lié à la clé, et dans ses bornes. Sans mandat elles sont inertes.", financialOffered, Theme.negative)219 Form {220 SwiftUI.Section(financial ? "Plafonds — obligatoires pour une clé financière" : "Plafonds (facultatifs pour une clé de lecture)") {221 TextField("Plafond par ordre (USD notionnel)", text: $form.maxOrder)222 TextField("Plafond quotidien (USD notionnel)", text: $form.maxDaily)223 }224 SwiftUI.Section("Restrictions (listes séparées par des virgules ; vide = aucune restriction de ce type)") {225 TextField("Réseaux", text: $form.networks); TextField("Plateformes", text: $form.venues); TextField("Marchés", text: $form.instruments); TextField("Adresses IP autorisées", text: $form.ipAllow)226 }227 if let key {228 SwiftUI.Section("Mandat lié") {229 let options = store.mandates(for: key.id)230 Picker("Mandat", selection: $form.mandateId) {231 Text("Aucun").tag("")232 ForEach(options) { m in Text("\(m.label ?? m.id) — \(m.mode) · \(m.state)/\(m.phase)").tag(m.id) }233 if !form.mandateId.isEmpty, !options.contains(where: { $0.id == form.mandateId }) { Text(form.mandateId).tag(form.mandateId) }234 }235 Text(options.isEmpty ? "Aucun mandat ne nomme cette clé. Un mandat de trading pour une clé se crée et s’approuve (passkey) depuis l’écran de risque du portefeuille." : "Seuls les mandats qui nomment cette clé peuvent lui être liés.").font(.caption).foregroundStyle(.secondary)236 }237 }238 }.formStyle(.grouped).scrollDisabled(true)239 if key == nil { Text("Un mandat nomme l’identifiant d’une clé : il ne peut être lié qu’après la création. D’ici là, les permissions financières de la clé sont inertes.").font(.caption).foregroundStyle(.secondary) }240 else { Text("Un changement qui réduit l’autorité de la clé passe avec la session seule. Tout élargissement (permission, plafond, cadence, restriction retirée, mandat) vous sera présenté et exigera votre passkey.").font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true) }241 } footer: {242 if let e = store.actionError { Banner(.danger, e) }243 HStack {244 if let p = form.problem(info, creating: key == nil) { Text(p).font(.callout).foregroundStyle(.secondary) }245 Spacer()246 if store.busy != nil { ProgressView().controlSize(.small) }247 Button("Annuler") { close() }248 Button(key == nil ? "Préparer et vérifier…" : "Enregistrer…") { Task { if let key { await store.update(key, form: form) } else { await store.prepareCreate(form) } } }249 .buttonStyle(.borderedProminent).controlSize(.large).disabled(form.problem(info, creating: key == nil) != nil || !model.canOperate || store.busy != nil)250 }251 }252 .onAppear { if let key { form = APIKeyForm(key: key) }; accepted = store.formAccepted }253 .onChange(of: store.formAccepted) { _, v in if v != accepted { close() } }254 }255256 private func scopeGroup(_ title: String, _ note: String, _ scopes: [APIKeyList.ScopeInfo], _ color: Color) -> some View {257 VStack(alignment: .leading, spacing: 6) {258 Text(title).font(.callout.weight(.semibold)).foregroundStyle(color == .secondary ? Color.primary : color)259 Text(note).font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)260 if scopes.isEmpty { Text("Aucune offerte par ce serveur.").font(.caption).foregroundStyle(.secondary) }261 LazyVGrid(columns: [GridItem(.adaptive(minimum: 190), alignment: .leading)], alignment: .leading, spacing: 4) {262 ForEach(scopes, id: \.scope) { s in263 Toggle(isOn: Binding(get: { form.scopes.contains(s.scope) }, set: { if $0 { form.scopes.insert(s.scope) } else { form.scopes.remove(s.scope) } })) { Text(s.scope).font(Theme.monoSmall) }.toggleStyle(.checkbox)264 }265 }266 }267 .padding(10).frame(maxWidth: .infinity, alignment: .leading).background(color.opacity(0.06), in: RoundedRectangle(cornerRadius: 8))268 .overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(color.opacity(0.3)))269 }270}271272// MARK: approval of a key intent273274struct APIKeyApprovalSheet: View {275 let model: AppModel276 let store: TradingAPIStore277 let pending: TradingAPIStore.Pending278 let info: APIKeyList?279 @State private var understood = false280281 var body: some View {282 let a = pending.approval, i = a.intent283 let financial = Set(info?.scopes.filter(\.execution).map(\.scope) ?? [])284 let grantsFinancial = !(Set(i.key?.scopes ?? []).union(i.changes?.scopes ?? [])).isDisjoint(with: financial)285 let needsAck = grantsFinancial || !(i.widening ?? []).isEmpty || i.action == "rotate"286 SheetScaffold(title: title(i.action), width: 720, height: 760) {287 ReviewLines(lines: lines(i, financial))288 if let w = i.widening, !w.isEmpty { Banner(.warning, "Ce changement ÉLARGIT l’autorité de la clé sur : \(w.joined(separator: ", ")).") }289 if grantsFinancial { Banner(.warning, "Cette clé porte des permissions FINANCIÈRES. Elles n’agissent que sous un mandat lié à la clé et dans ses bornes ; quiconque détient le secret de la clé peut les utiliser.") }290 if info?.scopes.isEmpty != false { Banner(.warning, "La liste des permissions du serveur n’a pas pu être relue : la distinction lecture / financière n’est pas affichée ici.") }291 BindingProof(digest: a.approval.digest, expiry: a.expiry)292 if needsAck { AckToggle(isOn: $understood, text: i.action == "rotate" ? "Je comprends que l’ancienne clé cessera de fonctionner et que le nouveau secret ne sera montré qu’une fois." : "Je comprends l’autorité accordée à cette clé et que son secret doit rester confidentiel.") }293 } footer: {294 if let e = store.actionError { Banner(.danger, e) }295 HStack {296 Button("Annuler — rien n’est approuvé") { store.cancelPending() }.disabled(store.approving)297 Spacer()298 if store.approving { ProgressView().controlSize(.small); Text("Passkey…").foregroundStyle(.secondary) }299 Button { Task { await store.approve() } } label: { Label("Approuver avec la passkey", systemImage: "touchid") }300 .buttonStyle(.borderedProminent).controlSize(.large).disabled((needsAck && !understood) || store.approving || !model.canOperate)301 }302 }303 .interactiveDismissDisabled()304 }305306 private func title(_ action: String) -> String {307 switch action { case "create": "Approuver la création de la clé"; case "rotate": "Approuver le renouvellement de la clé"; case "update": "Approuver l’élargissement de la clé"; default: "Approuver l’opération sur la clé" }308 }309310 private func split(_ scopes: [String], _ financial: Set<String>) -> String {311 let r = scopes.filter { !financial.contains($0) }, f = scopes.filter { financial.contains($0) }312 return "Lecture : \(r.isEmpty ? "aucune" : r.joined(separator: ", "))\nFINANCIÈRES : \(f.isEmpty ? "aucune" : f.joined(separator: ", "))"313 }314 private func limits(_ l: APIKeyLimits) -> String { "par ordre \(l.maxOrderNotionalUsd.value.map { AgentCreateForm.plain($0) + " USD" } ?? "NON DÉFINI") · par jour \(l.maxDailyNotionalUsd.value.map { AgentCreateForm.plain($0) + " USD" } ?? "NON DÉFINI")" }315 private func restrictions(_ r: APIKeyRestrictions) -> String {316 "réseaux : \(r.networks.isEmpty ? "tous" : r.networks.joined(separator: ", "))\nplateformes : \(r.venues.isEmpty ? "toutes" : r.venues.joined(separator: ", "))\nmarchés : \(r.instruments.isEmpty ? "tous" : r.instruments.joined(separator: ", "))\nadresses IP : \(r.ipAllow.isEmpty ? "toutes" : r.ipAllow.joined(separator: ", "))"317 }318319 private func lines(_ i: APIKeyIntent, _ financial: Set<String>) -> [ReviewLine] {320 var out: [ReviewLine] = [321 ReviewLine(label: "Opération", value: i.action == "create" ? "Création d’une clé d’API" : i.action == "rotate" ? "Renouvellement d’une clé d’API" : i.action == "update" ? "Modification d’une clé d’API" : i.action, style: .strong),322 ReviewLine(label: "Portefeuille (origine)", value: i.origin),323 ReviewLine(label: "Préparée le", value: i.preparedAt),324 ReviewLine(label: "Identifiant de l’intention", value: i.intentId, style: .address),325 ]326 if let id = i.keyId { out.append(ReviewLine(label: "Clé visée", value: id, style: .address)) }327 if let n = i.newKeyId { out.append(ReviewLine(label: "Nouvel identifiant", value: n, style: .address)) }328 if let k = i.key {329 out += [ReviewLine(label: "Identifiant de la clé", value: k.id, style: .address), ReviewLine(label: "Nom", value: k.name, style: .strong),330 ReviewLine(label: "Permissions", value: split(k.scopes, financial), style: .strong), ReviewLine(label: "Expire le", value: k.expiresAt, style: .strong),331 ReviewLine(label: "Plafonds (notionnel)", value: limits(k.limits)), ReviewLine(label: "Restrictions", value: restrictions(k.restrictions)),332 ReviewLine(label: "Cadence", value: "\(k.rateLimitPerMin) requêtes par minute"), ReviewLine(label: "Mandat lié", value: k.mandateId.value ?? "aucun (permissions financières inertes)")]333 }334 if let c = i.changes {335 if let n = c.name { out.append(ReviewLine(label: "Nouveau nom", value: n)) }336 if let s = c.scopes { out.append(ReviewLine(label: "Nouvelles permissions", value: split(s, financial), style: .strong)) }337 if let e = c.expiresAt { out.append(ReviewLine(label: "Nouvelle expiration", value: e, style: .strong)) }338 if let l = c.limits { out.append(ReviewLine(label: "Nouveaux plafonds", value: limits(l), style: .strong)) }339 if let r = c.restrictions { out.append(ReviewLine(label: "Nouvelles restrictions", value: restrictions(r))) }340 if let r = c.rateLimitPerMin { out.append(ReviewLine(label: "Nouvelle cadence", value: "\(r) requêtes par minute")) }341 switch c.mandate { case .unchanged: break; case .unbind: out.append(ReviewLine(label: "Mandat", value: "délié")); case .bind(let id): out.append(ReviewLine(label: "Mandat à lier", value: id, style: .address)) }342 }343 return out344 }345}346347// MARK: the secret, once348349/// Shows a secret exactly once. The value exists only in this sheet's lifetime: closing it drops it from the app's memory.350struct OneTimeSecretSheet: View {351 let shown: TradingAPIStore.Shown352 let close: () -> Void353 @State private var saved = false354 @State private var copied = false355356 var body: some View {357 SheetScaffold(title: shown.title, width: 680, height: 520) {358 ForEach(shown.problems, id: \.self) { Banner(.danger, $0) }359 Banner(.danger, "Ce secret n’est affiché QU’UNE SEULE FOIS. L’app ne le conserve pas et le serveur ne peut pas le redonner : copiez-le maintenant dans votre gestionnaire de secrets. Quiconque le détient agit avec l’autorité de la clé.")360 Field(label: "Objet", value: shown.subject)361 Text(shown.secret.reveal()).font(.system(.body, design: .monospaced)).textSelection(.enabled).fixedSize(horizontal: false, vertical: true)362 .padding(12).frame(maxWidth: .infinity, alignment: .leading).background(Color.secondary.opacity(0.1), in: RoundedRectangle(cornerRadius: 8))363 .privacySensitive()364 HStack {365 Button { copyToPasteboard(shown.secret.reveal()); copied = true } label: { Label(copied ? "Copié" : "Copier le secret", systemImage: copied ? "checkmark" : "doc.on.doc") }.buttonStyle(.borderedProminent)366 if copied { Text("Le presse-papiers contient maintenant le secret : collez-le en lieu sûr, puis copiez autre chose.").font(.caption).foregroundStyle(Theme.warning) }367 }368 ForEach(shown.notes, id: \.self) { Text($0).font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true).textSelection(.enabled) }369 AckToggle(isOn: $saved, text: "J’ai enregistré ce secret en lieu sûr. Je comprends qu’il ne sera plus jamais affiché.")370 } footer: {371 HStack { Spacer(); Button("Fermer et oublier le secret") { close() }.buttonStyle(.borderedProminent).controlSize(.large).disabled(!saved) }372 }373 .interactiveDismissDisabled()374 }375}376