Skip to content

Commit 5f95c80

Browse files
sirdeggenclaude
andauthored
refactor: extract shared helper for duplicated logic (#46) (#55)
* refactor: extract StorageClientBase to dedupe StorageClient and StorageMobile (#46) Both StorageClient (with logger support) and StorageMobile (lightweight variant) were ~420-line near-identical classes. Extract all shared WalletStorageProvider method implementations and entity-validation helpers into StorageClientBase. Each subclass now only implements the rpcCall method that differs between them. Partial fix for #46. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update pnpm-lock.yaml to include tsx in ts-p2p devDependencies Fixes frozen-lockfile CI failure introduced in c4db522 which added tsx to ts-p2p devDependencies without regenerating the lockfile. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract entity validation helpers to remove cross-file duplication Extract validateDate, validateEntity, and validateEntities from both StorageClientBase and StorageServer into a shared entityValidationHelpers.ts. Both classes now delegate to the standalone functions, removing the duplicate implementation that SonarCloud flagged between the two files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract validateSyncChunkEntities helper to remove getSyncChunk duplication Both StorageClientBase.getSyncChunk and StorageServer's processSyncChunk case had the same 13-line SyncChunk entity-validation block. Extract it into validateSyncChunkEntities() in entityValidationHelpers.ts and replace both sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: add Array.isArray guard in validateEntities to prevent loop-bound injection CodeQL flags js/loop-bound-injection when iterating with .length on a user-controlled value. Guard with Array.isArray() so non-array inputs (e.g. JSON objects with a spoofed .length) are returned unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3d8ee54 commit 5f95c80

5 files changed

Lines changed: 557 additions & 995 deletions

File tree

0 commit comments

Comments
 (0)