Skip to content

feat(api-tokens): migrate to v2 token endpoints with shocker control, unified create page, and pause toggle#208

Merged
LucHeart merged 2 commits into
developfrom
feature/rework-api-tokens
Jun 5, 2026
Merged

feat(api-tokens): migrate to v2 token endpoints with shocker control, unified create page, and pause toggle#208
LucHeart merged 2 commits into
developfrom
feature/rework-api-tokens

Conversation

@LucHeart
Copy link
Copy Markdown
Member

@LucHeart LucHeart commented Jun 4, 2026

Summary

Integrates the new v2 token endpoints and reworks the API-tokens UI around the new
required shockerControl object. Also unifies token creation into a single page, moves
token dialogs onto the dialog manager, and adds per-token pause/resume.

Changes

v2 token endpoints

  • Switched the canonical token exports to v2: tokensCreateTokenV2, tokensEditTokenV2,
    tokensListTokensV2, tokensGetTokenByIdV2, tokensSelfGetSelfTokenV2,
    tokensSetTokenPaused, and v2 tokensReportTokens.
  • Kept v1 tokenDeleteDeleteToken (no v2 delete endpoint exists).
  • Regenerated API client (sdk/types/transformers) for the v2 token surface.

Shocker control editor (new)

  • Reusable shocker-control-settings.svelte: paused switch, intensity & duration ranges,
    and a Clamp/Lerp mode toggle per range with tooltips explaining each mode.
  • Bounds reuse the existing ControlConstants (intensity 0–100%, duration 0.3–30s),
    converting seconds→ms at the boundary. Fixes a 400 where duration.min defaulted to 0
    (backend requires ≥ 300 ms).

Unified token creation

  • Removed the in-app create modal. /settings/api-tokens/new is now the single surface
    for both in-app self-service and external (OAuth-style) consent.
  • All parameters are prefillable via query params and reviewable/adjustable before
    granting: name, redirect_uri, permissions, expiration (ISO datetime), and shocker
    control limits (intensity_min/max/mode, duration_min/max/mode). Values are clamped to
    valid ranges defensively.
  • Clear success states: self-service shows the one-time token to copy; external shows
    "Access granted" with auto-redirect plus Retry/Finish fallbacks.

Dialog manager

  • Edit and delete now go through the shared dialog manager (dialog.open / dialog.confirm).

Pause/resume

  • Per-token pause toggle via tokensSetTokenPaused: a visible button in the row plus a
    menu item, and a Status column (Active/Paused).

ExpirationPicker

  • Temporal.Instant is now the single source of truth; @internationalized/date
    ZonedDateTime is confined to one getter/setter at the calendar boundary. Supports a
    prefilled custom datetime.

Removed

  • dialog-token-create.svelte, dialog-token-created.svelte, dialog-token-delete.svelte,
    and new/queryParamsType.ts (no longer used).

Notes

  • Backend permits duration up to 65535 ms, but the UI keeps the app-wide 30 s cap via the
    shared constants. restrictions-selector.svelte (share limits) still hardcodes
    min={0} for duration inline — same latent issue, left out of scope.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying openshockapp with  Cloudflare Pages  Cloudflare Pages

Latest commit: fc23aa3
Status: ✅  Deploy successful!
Preview URL: https://22df66b3.openshockapp.pages.dev
Branch Preview URL: https://feature-rework-api-tokens.openshockapp.pages.dev

View logs

@LucHeart LucHeart merged commit 78f2c38 into develop Jun 5, 2026
11 checks passed
@LucHeart LucHeart deleted the feature/rework-api-tokens branch June 5, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant