(janitor/dedupe): consolidate base64url encode/decode helpers in worker-utils - #6462
Merged
Merged
Conversation
`bytesToBase64url`/`base64urlToBytes` were duplicated verbatim in `sandbox-id.ts` and `hostname-label.ts`. Extract them into a single `base64url.ts` module and add it as a `worker-utils` subpath export.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryVerified the base64url helper extraction preserves encode/decode semantics in Files Reviewed (5 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
pandemicsyn
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deduplicate the
bytesToBase64url/base64urlToByteshelpers, which were defined verbatim in bothpackages/worker-utils/src/sandbox-id.tsandpackages/worker-utils/src/hostname-label.ts.Change
packages/worker-utils/src/base64url.ts../base64urlsubpath export.sandbox-id.tsimports the shared helpers directly.hostname-label.tsimports the shared helpers and keeps its roundtrip-validating, null-returning wrapper (base64urlToBytesOrNull) local, since that validation is hostname-label-specific behavior.base64url.test.ts.Scope notes
The same helper also exists in
apps/web/src/lib/kiloclaw/sandbox-id.tsand is re-exported fromservices/kiloclaw/src/auth/*. Those are intentional, documented duplicates:apps/webinlines it because Next.jsmoduleResolutioncannot resolve theworker-utilssubpath export, andservices/kiloclawalready re-exports the canonicalworker-utilsmodule. Left as-is to avoid cross-runtime coupling.Verification
pnpm --filter @kilocode/worker-utils test— 743 passedpnpm --filter @kilocode/worker-utils typecheck— cleanpnpm --filter @kilocode/worker-utils lint— 0 warnings/errors