Skip to content

fix: derive telemetry endpoint from license JWT - #34

Merged
minarc merged 1 commit into
mainfrom
dev
Apr 16, 2026
Merged

minarc merged 1 commit into
mainfrom
dev

Conversation

@minarc

@minarc minarc commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Derive the backend URL from the telemetry_endpoint claim in the license JWT (falls back to https://meter.skillbench.com), replacing the hardcoded SKILLMETER_BACKEND_URL.
  • Require a license token for hooks to run — transfers and hook execution are skipped with a clear log message when the token is missing.
  • Make Authorization: Bearer <jwt> unconditional on event-log and transcript uploads.

Test plan

  • Run a hook with a valid license JWT and confirm events POST to the endpoint encoded in the telemetry_endpoint claim
  • Run a hook with a JWT that has no telemetry_endpoint claim and confirm it falls back to https://meter.skillbench.com
  • Run a hook with no license token and confirm the hook exits early with the skip warning
  • Confirm transcript uploads hit ${endpoint}/logs/claude/transcript

🤖 Generated with Claude Code

Summary by CodeRabbit

Improvements

  • Upload operations for events and transcripts now require license token authentication for enhanced security
  • Backend endpoint configuration is now dynamically determined from license token instead of using a fixed URL
  • Error logging enhanced for better handling of missing or invalid credentials
  • License token validation enforced before processing operations

@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1e2752b-c68c-451e-a53e-280c0836765e

📥 Commits

Reviewing files that changed from the base of the PR and between 3a32182 and 7a60b19.

📒 Files selected for processing (1)
  • skillmeter/scripts/logger.js

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

Modified logger.js to extract telemetry endpoints dynamically from JWT license token payloads instead of using a fixed backend URL. Added JWT decoding helpers, enforced license token and endpoint requirements for uploads, and included Bearer token authorization headers in requests.

Changes

Cohort / File(s) Summary
JWT Token & Endpoint Resolution
skillmeter/scripts/logger.js
Added decodeJwtPayload and getEndpointFromToken helper functions to extract telemetry endpoint claims from license tokens. Removed hardcoded BACKEND_URL constant and replaced with dynamic endpoint resolution. Event and transcript uploads now require valid license token and resolved endpoint; requests include Authorization: Bearer ${token} header. Modified runHook to validate license token presence before proceeding.

Sequence Diagram

sequenceDiagram
    participant Script as Logger Script
    participant Token as License Token
    participant Decoder as JWT Decoder
    participant Resolver as Endpoint Resolver
    participant Upload as Upload Service

    Script->>Script: Call runHook/uploadEvent
    Script->>Token: Check token exists
    alt Token Missing
        Script->>Script: Log error, exit early
    else Token Present
        Script->>Decoder: decodeJwtPayload(token)
        alt Decode Success
            Decoder-->>Script: JWT payload decoded
            Script->>Resolver: getEndpointFromToken(payload)
            alt telemetry_endpoint Claim Found
                Resolver-->>Script: Return extracted endpoint
            else Claim Missing/Invalid
                Resolver-->>Script: Return DEFAULT_ENDPOINT
            end
            Script->>Script: Construct URL from endpoint
            Script->>Upload: POST request with Bearer token
            Upload-->>Script: Response
        else Decode Fails
            Decoder-->>Script: Fallback to DEFAULT_ENDPOINT
            Script->>Upload: POST request with Bearer token
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A token arrives with secrets to tell,
Our clever decoder breaks through the shell,
An endpoint emerges, dynamic and new,
Bearer credentials make uploads ring true!
No fixed URLs here—just wisdom so spry, 🔐✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Comment @coderabbitai help to get the list of available commands and usage tips.

@minarc
minarc merged commit 3668132 into main Apr 16, 2026
1 check was pending
@TheStarkor
TheStarkor deleted the dev branch September 21, 2026 18:39
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