Skip to content

Simplify licensing: make region optional and support bare tokens#539

Merged
jmtts merged 4 commits into
mainfrom
claude/werk24-init-token-handling-e79e38
Jul 3, 2026
Merged

Simplify licensing: make region optional and support bare tokens#539
jmtts merged 4 commits into
mainfrom
claude/werk24-init-token-handling-e79e38

Conversation

@werk24

@werk24 werk24 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR modernizes the licensing system by making the region field optional and adding support for bare token format (as issued during registration), while maintaining backwards compatibility with legacy dotenv-style license files.

Key Changes

  • Made region optional: The region field in the License model is now optional (Optional[str] = None), reflecting that modern registration only issues tokens without regions
  • Added bare token support: parse_license_text() now supports two formats:
    • Legacy dotenv format: W24TECHREAD_AUTH_TOKEN=... (with optional W24TECHREAD_AUTH_REGION=...)
    • New bare token format: A plain token string, as issued during registration
  • Added token validation: Implemented @field_validator to ensure tokens are not empty or whitespace-only
  • Extracted environment variable keys: Created TOKEN_ENV_KEY and REGION_ENV_KEY constants to reduce duplication and improve maintainability
  • Updated license file persistence: Only writes the region to license files if one is present (for backwards compatibility)
  • Updated CLI messaging: Changed terminology from "license file" to "token" throughout the CLI to reflect the new registration flow
  • Updated settings: Renamed trial_license_url to signup_url in Settings class
  • Updated error messages: Simplified error messages to reflect that only a valid token is required
  • Added comprehensive tests: New test cases for bare token parsing, whitespace handling, and token-only licenses

Implementation Details

  • The find_license_in_envs() function now only requires the token environment variable to be set (region is optional)
  • parse_license_text() intelligently detects format by checking for the presence of TOKEN_ENV_KEY in the input
  • Bare token parsing uses the first non-empty line and rejects lines containing "=" to avoid accepting malformed dotenv blocks
  • Version bumped to 2.5.0 to reflect the licensing system changes

https://claude.ai/code/session_012mTmqkybmwU1e19ePJs4qC

claude added 4 commits July 3, 2026 07:25
Registration now issues only an auth token rather than a full dotenv
license block. Update the init workflow and license handling to accept a
bare token while remaining backwards compatible with the legacy
W24TECHREAD_AUTH_TOKEN/W24TECHREAD_AUTH_REGION format.

- Make the region optional on the License model (it is never used for the
  API connection, only the token is sent in the auth header) and reject
  empty tokens.
- Teach parse_license_text to accept a bare token in addition to the
  legacy dotenv block.
- Only persist the region to the license file when one is present.
- Treat a missing region as optional in env-var discovery.
- Reword the init CLI prompts to ask for a token, and update the invalid
  license message.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mTmqkybmwU1e19ePJs4qC
Werk24 no longer offers a trial license; users sign up for a
pay-as-you-go license instead. Rename the setting and init workflow
references accordingly (the signup URL value is unchanged).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mTmqkybmwU1e19ePJs4qC
Users can sign up for any type of license, so drop the pay-as-you-go
specific wording in favour of a generic signup flow. Rename the setting
to signup_url and the helper to sign_up_for_license (signup URL value
unchanged).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mTmqkybmwU1e19ePJs4qC
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mTmqkybmwU1e19ePJs4qC
@jmtts jmtts merged commit 6436261 into main Jul 3, 2026
7 checks passed
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.

3 participants