Skip to content

Refactor MistDemo auth-token inlined HTML/JS #289

@leogdion

Description

@leogdion

Context

Tracking issue from PR review on #287 — the auth-flow page is inlined as a Swift raw string spread across AuthTokenIndexHTML.swift and three AuthTokenIndexHTML+Script*.swift constants.

Why

The current shape is intentional but suboptimal:

  • The original comment in AuthTokenIndexHTML.swift notes the HTML was held as a Swift raw string because a SwiftPM resource bundle would fail iOS-family CodeSign in CI even though the auth-token CLI flow only runs on macOS / Linux.
  • That worked, but PR Test suite improvements for v1.0.0-beta.1 (#286) #287 had to split the JS into multiple Swift constants composed via \#(…) interpolation just to keep the per-file size sensible. The script constants disable line_length and indentation_width because they hold raw JS, not Swift code.
  • The split is a workaround, not a design.

What

Either:

  1. Conditionally bundle the HTML/JS as a SwiftPM resource for non-iOS platforms (since the CLI flow is macOS / Linux only) and load it at runtime from Bundle.module, gated by #if !os(iOS) …. This removes the file_length / line_length / indentation_width pressure entirely.
  2. If (1) is still blocked by CodeSign realities, move the HTML+JS into a single non-split Swift file and accept a per-file swiftlint exclusion config-side (rather than per-file disable directives).

Out of scope for the existing PR — captured here so we can come back to it.

Affected files

  • Examples/MistDemo/Sources/MistDemoKit/Commands/AuthTokenIndexHTML.swift
  • Examples/MistDemo/Sources/MistDemoKit/Commands/AuthTokenIndexHTML+ScriptAuth.swift
  • Examples/MistDemo/Sources/MistDemoKit/Commands/AuthTokenIndexHTML+ScriptDisplay.swift
  • Examples/MistDemo/Sources/MistDemoKit/Commands/AuthTokenIndexHTML+ScriptInit.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions