[PR #297] [MERGED] refactor: centralize CORS + CLI auth token #314

Closed
opened 2026-02-15 17:16:51 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/297
Author: @steipete
Created: 2/14/2026
Status: Merged
Merged: 2/14/2026
Merged by: @steipete

Base: mainHead: refactor/http-cors-cli-token


📝 Commits (2)

  • 73b18a8 refactor(convex): centralize CORS headers
  • 2e20b3b refactor(cli): centralize auth token lookup

📊 Changes

23 files changed (+158 additions, -294 deletions)

View changed files

📝 convex/downloads.ts (+18 -18)
📝 convex/http.ts (+1 -1)
📝 convex/httpApi.ts (+15 -10)
📝 convex/httpApiV1.ts (+16 -187)
convex/httpPreflight.ts (+37 -0)
convex/lib/httpHeaders.ts (+19 -0)
📝 convex/lib/httpRateLimit.ts (+2 -5)
packages/clawdhub/src/cli/authToken.ts (+14 -0)
📝 packages/clawdhub/src/cli/commands/auth.ts (+2 -3)
📝 packages/clawdhub/src/cli/commands/delete.test.ts (+2 -2)
📝 packages/clawdhub/src/cli/commands/delete.ts (+3 -10)
📝 packages/clawdhub/src/cli/commands/inspect.test.ts (+3 -3)
📝 packages/clawdhub/src/cli/commands/inspect.ts (+2 -4)
📝 packages/clawdhub/src/cli/commands/moderation.test.ts (+2 -2)
📝 packages/clawdhub/src/cli/commands/moderation.ts (+3 -10)
📝 packages/clawdhub/src/cli/commands/publish.test.ts (+2 -2)
📝 packages/clawdhub/src/cli/commands/publish.ts (+2 -4)
📝 packages/clawdhub/src/cli/commands/skills.test.ts (+4 -4)
📝 packages/clawdhub/src/cli/commands/skills.ts (+3 -5)
📝 packages/clawdhub/src/cli/commands/star.ts (+2 -9)

...and 3 more files

📄 Description

Refactor-only.

Convex:

  • Add convex/lib/httpHeaders.ts (mergeHeaders, corsHeaders).
  • Move OPTIONS preflight into convex/httpPreflight.ts.
  • Remove duplicated rate-limit implementation from convex/httpApiV1.ts (use convex/lib/httpRateLimit.ts).

CLI:

  • Add packages/clawdhub/src/cli/authToken.ts and use it across commands (install/update/inspect/sync + admin/star/delete).
  • Update tests accordingly.

Verified: bun run lint, bun run test, bun run build.

Greptile Overview

Greptile Summary

Consolidated CORS headers and HTTP utilities into centralized modules, and extracted CLI auth token logic into a dedicated helper. The changes reduced code duplication by moving mergeHeaders and corsHeaders functions to convex/lib/httpHeaders.ts, extracting OPTIONS preflight handling to convex/httpPreflight.ts, and reusing the rate-limit implementation from convex/lib/httpRateLimit.ts. The CLI now uses packages/clawdhub/src/cli/authToken.ts for token retrieval across all commands requiring authentication. All changes maintain existing behavior while improving maintainability.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • This is a pure refactoring that extracts duplicated code into centralized utilities without changing behavior. The CORS headers logic, HTTP header merging, rate limiting, and CLI auth token retrieval are all moved to dedicated modules and reused consistently. All test files are updated to mock the new modules appropriately. The changes follow the repository's coding conventions and the author verified lint, test, and build passes.
  • No files require special attention

Last reviewed commit: 2e20b3b


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/297 **Author:** [@steipete](https://github.com/steipete) **Created:** 2/14/2026 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@steipete](https://github.com/steipete) **Base:** `main` ← **Head:** `refactor/http-cors-cli-token` --- ### 📝 Commits (2) - [`73b18a8`](https://github.com/openclaw/clawhub/commit/73b18a883e0fb4a96a00d5161f582ced10608ab6) refactor(convex): centralize CORS headers - [`2e20b3b`](https://github.com/openclaw/clawhub/commit/2e20b3bda5f7008f7bcd3c9e811e7c3c0c1eb022) refactor(cli): centralize auth token lookup ### 📊 Changes **23 files changed** (+158 additions, -294 deletions) <details> <summary>View changed files</summary> 📝 `convex/downloads.ts` (+18 -18) 📝 `convex/http.ts` (+1 -1) 📝 `convex/httpApi.ts` (+15 -10) 📝 `convex/httpApiV1.ts` (+16 -187) ➕ `convex/httpPreflight.ts` (+37 -0) ➕ `convex/lib/httpHeaders.ts` (+19 -0) 📝 `convex/lib/httpRateLimit.ts` (+2 -5) ➕ `packages/clawdhub/src/cli/authToken.ts` (+14 -0) 📝 `packages/clawdhub/src/cli/commands/auth.ts` (+2 -3) 📝 `packages/clawdhub/src/cli/commands/delete.test.ts` (+2 -2) 📝 `packages/clawdhub/src/cli/commands/delete.ts` (+3 -10) 📝 `packages/clawdhub/src/cli/commands/inspect.test.ts` (+3 -3) 📝 `packages/clawdhub/src/cli/commands/inspect.ts` (+2 -4) 📝 `packages/clawdhub/src/cli/commands/moderation.test.ts` (+2 -2) 📝 `packages/clawdhub/src/cli/commands/moderation.ts` (+3 -10) 📝 `packages/clawdhub/src/cli/commands/publish.test.ts` (+2 -2) 📝 `packages/clawdhub/src/cli/commands/publish.ts` (+2 -4) 📝 `packages/clawdhub/src/cli/commands/skills.test.ts` (+4 -4) 📝 `packages/clawdhub/src/cli/commands/skills.ts` (+3 -5) 📝 `packages/clawdhub/src/cli/commands/star.ts` (+2 -9) _...and 3 more files_ </details> ### 📄 Description Refactor-only. Convex: - Add `convex/lib/httpHeaders.ts` (`mergeHeaders`, `corsHeaders`). - Move OPTIONS preflight into `convex/httpPreflight.ts`. - Remove duplicated rate-limit implementation from `convex/httpApiV1.ts` (use `convex/lib/httpRateLimit.ts`). CLI: - Add `packages/clawdhub/src/cli/authToken.ts` and use it across commands (install/update/inspect/sync + admin/star/delete). - Update tests accordingly. Verified: `bun run lint`, `bun run test`, `bun run build`. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Consolidated CORS headers and HTTP utilities into centralized modules, and extracted CLI auth token logic into a dedicated helper. The changes reduced code duplication by moving `mergeHeaders` and `corsHeaders` functions to `convex/lib/httpHeaders.ts`, extracting OPTIONS preflight handling to `convex/httpPreflight.ts`, and reusing the rate-limit implementation from `convex/lib/httpRateLimit.ts`. The CLI now uses `packages/clawdhub/src/cli/authToken.ts` for token retrieval across all commands requiring authentication. All changes maintain existing behavior while improving maintainability. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - This is a pure refactoring that extracts duplicated code into centralized utilities without changing behavior. The CORS headers logic, HTTP header merging, rate limiting, and CLI auth token retrieval are all moved to dedicated modules and reused consistently. All test files are updated to mock the new modules appropriately. The changes follow the repository's coding conventions and the author verified lint, test, and build passes. - No files require special attention <sub>Last reviewed commit: 2e20b3b</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:51 -05:00
yindo closed this issue 2026-02-15 17:16:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#314