Skip to content

Feat/device fingerprint header#7

Merged
malinosqui merged 4 commits intomainfrom
feat/device-fingerprint-header
Feb 20, 2026
Merged

Feat/device fingerprint header#7
malinosqui merged 4 commits intomainfrom
feat/device-fingerprint-header

Conversation

@malinosqui
Copy link
Member

@malinosqui malinosqui commented Feb 20, 2026

This pull request introduces a device fingerprinting mechanism and enhances authentication handling within the CLI.

Key changes include:

  • Device Identity Management: A new utility (src/utils/device.ts) is added to generate, store, and retrieve a unique device ID and an associated device token. This information is persistently stored in ~/.kodus/device.json.
  • Device Fingerprint Headers: All API requests made through the RealApi service and the auth team-key command now include X-Kodus-Device-Id and X-Kodus-Device-Token headers, if available.
  • Device Token Updates: The CLI now listens for x-kodus-device-token in API response headers and automatically updates the stored device token.
  • Authentication Fallback: The review service now implements an authentication fallback. If an API request using a personal token fails with a 401 Unauthorized error, the CLI will automatically retry the request using the configured team key.
  • Improved Error Messaging: User-facing error messages for API responses have been enhanced, specifically providing a more descriptive message for DEVICE_LIMIT_REACHED errors, including details about active devices and the limit.

malinosqui and others added 2 commits February 19, 2026 08:17
Merge main into feat/device-fingerprint-header, combining:
- Device identity headers and DEVICE_LIMIT_REACHED handling (HEAD)
- Improved API error normalization and auth dedup (main)
- Fix duplicate import and clearCredentials in team-key action

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kody-ai

This comment has been minimized.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19c6f8bc3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 90 to 94
cachedDevice = created;

try {
await writeDeviceData(created);
} catch {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist stable device identity when file writes fail

If ~/.kodus/device.json cannot be written (common in read-only HOME/CI environments), this catch suppresses the failure and keeps only an in-memory random UUID, so each new CLI process generates a different deviceId. That causes repeated invocations to look like new devices and can quickly exhaust the organization's device limit for a single user.

Useful? React with 👍 / 👎.

Comment on lines 187 to 189
const errorData = isJson
? await response.json().catch(() => ({ message: 'Request failed' })) as { message?: string }
? await response.json().catch(() => ({ message: 'Request failed' })) as ApiErrorPayload
: { message: `Request failed with status ${response.status}` };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Unwrap error payload before device-limit message mapping

This path forwards the raw JSON body as errorData without unwrapping the API envelope, so responses shaped like { data: { code: 'DEVICE_LIMIT_REACHED', ... } } will never hit the device-limit branch and will fall back to a generic auth message. That makes the new user-facing device-limit error handling depend on backend payload shape instead of working consistently.

Useful? React with 👍 / 👎.

@kody-ai
Copy link

kody-ai bot commented Feb 20, 2026

kody code-review Kody Rules critical

This PR modifies code that uses the environment variable process.env.KODUS_VERBOSE. As per the repository guidelines, please check with @Wellington01 to ensure any necessary configuration updates are applied to the self-hosted environment. Kody Rule violation: Verificar atualizações de variáveis de ambiente

@kody-ai
Copy link

kody-ai bot commented Feb 20, 2026

kody code-review Kody Rules critical

The pull request description is empty and does not reference a related issue. Please update the description to include a closing statement like 'Closes #123' or 'Fixes #456' to automatically link and close the corresponding issue upon merging. Kody Rule violation: Ensure PR closes referenced issues

- Deduplicate concurrent getDeviceIdentity() calls via shared promise
  to prevent generating multiple device IDs on startup
- Unwrap API error envelope ({ data: { code, ... } }) so
  DEVICE_LIMIT_REACHED is detected consistently

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kody-ai

This comment has been minimized.

@kody-ai
Copy link

kody-ai bot commented Feb 20, 2026

kody code-review Kody Rules critical

The pull request description does not reference any issues. To improve tracking and context, please link this PR to the relevant issue by adding a closing statement like Closes #123 or Fixes #456 to the description. Kody Rule violation: Ensure PR closes referenced issues

Prevents discarding a direct error message when the response has both
a top-level message and a data object with unrelated context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kody-ai
Copy link

kody-ai bot commented Feb 20, 2026

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Cross File

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Feb 20, 2026

kody code-review Kody Rules critical

The pull request description does not contain a reference to a GitHub issue. Please add a closing statement like 'Closes #123' or 'Fixes #123' to automatically link and close the relevant issue upon merging. Kody Rule violation: Ensure PR closes referenced issues

@malinosqui malinosqui merged commit a184f10 into main Feb 20, 2026
5 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.

1 participant