SPB Git

Repository Public License

WorkflowLibrary.swift 4.3 KB 76 lines swift

1// ORIX Secure2// File: Packages/ORIXReporting/Sources/ORIXWorkflow/WorkflowLibrary.swift3// Description: The built-in ORIX Secure Actions workflows: storage cleanup, security check-up, suspicious link triage,4//              network check and full device review.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import Foundation9import ORIXSecureModel1011public enum WorkflowLibrary {12    /// Stable identifiers, so that history and shortcuts keep pointing at the same built-in workflow across launches.13    private static func identifier(_ workflow: UInt8, _ step: UInt8 = 0) -> UUID {14        UUID(uuid: (0x0A, 0x1B, 0x5E, 0xC0, 0x4F, 0x52, 0x49, 0x58, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, workflow, step))15    }1617    private static func make(_ number: UInt8, _ name: String, _ summary: String, _ systemImage: String, _ steps: [WorkflowStep]) -> WorkflowDefinition {18        var numbered = steps19        for index in numbered.indices { numbered[index].id = identifier(number, UInt8(truncatingIfNeeded: index + 1)) }20        return WorkflowDefinition(unchecked: identifier(number), name: name, summary: summary, systemImage: systemImage, steps: numbered, isBuiltIn: true)21    }2223    private static func report() -> WorkflowStep {24        WorkflowStep(kind: .reportGenerate, title: L("Generate the report"))25    }2627    public static var storageCleanup: WorkflowDefinition {28        make(1, L("Storage cleanup"), L("Measures storage, finds duplicate and oversized photos, lets you review them, then deletes only what you confirmed."), "externaldrive.badge.minus", [29            WorkflowStep(kind: .storageOverview, title: L("Measure storage")),30            WorkflowStep(kind: .photosScan, title: L("Scan the photo library")),31            WorkflowStep(kind: .photosReview, title: L("Review the suggested photos")),32            WorkflowStep(kind: .photosDelete, title: L("Delete the selected photos"), requiresConfirmation: true, isDestructive: true, stopsWorkflowWhenDeclined: false),33            report(),34        ])35    }3637    public static var securityCheckUp: WorkflowDefinition {38        make(2, L("Security check-up"), L("Assesses what the app can read about this device, walks through the settings only you can check, then tests the current network."), "checkmark.shield", [39            WorkflowStep(kind: .securityAssessment, title: L("Assess the device")),40            WorkflowStep(kind: .checklistReview, title: L("Review the settings checklist")),41            WorkflowStep(kind: .networkDiagnostics, title: L("Test the current network"), continueOnFailure: true),42            report(),43        ])44    }4546    public static var suspiciousLinkTriage: WorkflowDefinition {47        make(3, L("Suspicious link triage"), L("Inspects a link without opening it, then checks the network it would be opened from."), "link.badge.plus", [48            WorkflowStep(kind: .urlInspect, title: L("Inspect the link")),49            WorkflowStep(kind: .networkDiagnostics, title: L("Test the current network"), continueOnFailure: true),50            report(),51        ])52    }5354    public static var networkCheck: WorkflowDefinition {55        make(4, L("Network check"), L("Runs the network diagnostics on the current connection and writes the result down."), "network", [56            WorkflowStep(kind: .networkDiagnostics, title: L("Test the current network")),57            report(),58        ])59    }6061    public static var fullDeviceReview: WorkflowDefinition {62        make(5, L("Full device review"), L("Runs every read-only diagnostic in one pass: device assessment, settings checklist, storage and network. Nothing is deleted."), "iphone.gen3.badge.checkmark", [63            WorkflowStep(kind: .securityAssessment, title: L("Assess the device"), continueOnFailure: true),64            WorkflowStep(kind: .checklistReview, title: L("Review the settings checklist"), continueOnFailure: true),65            WorkflowStep(kind: .storageOverview, title: L("Measure storage"), continueOnFailure: true),66            WorkflowStep(kind: .networkDiagnostics, title: L("Test the current network"), continueOnFailure: true),67            report(),68        ])69    }7071    /// The built-in workflows, in the current language.72    public static var builtIn: [WorkflowDefinition] {73        [storageCleanup, securityCheckUp, suspiciousLinkTriage, networkCheck, fullDeviceReview]74    }75}76
Files main
Menu

Theme