Skip to content

Commit c3e86c5

Browse files
nullcoderclaude
andauthored
feat: implement binary format encoding/decoding for multi-file support (#37) (#45)
- Create lib/binary.ts with complete binary format implementation - Add encodeFiles() function with magic number "GPST" and version support - Add decodeFiles() function with comprehensive validation - Add validateBinaryFormat() for quick format validation - Add extractHeader() to read header without full decode - Implement efficient binary packing with proper size limit enforcement - Use specific error types instead of generic ValidationError - Add comprehensive test suite with 35 tests covering: - Normal operations (single/multiple files) - Edge cases (empty files, Unicode, special characters) - Error conditions and size limits - Format validation and corruption detection Binary format structure: - 4 bytes: Magic number "GPST" (0x47505354) - 1 byte: Version - 2 bytes: File count - 4 bytes: Total size - Per file: filename length + name + content length + content + language This implementation provides efficient multi-file packing while maintaining data integrity and enforcing security limits. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 044a61c commit c3e86c5

File tree

3 files changed

+1152
-4
lines changed

3 files changed

+1152
-4
lines changed

docs/TODO.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ This document tracks the implementation progress of GhostPaste. Check off tasks
7878

7979
### Binary Format (`lib/binary.ts`)
8080

81-
- [ ] Implement file encoding to binary format - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
82-
- [ ] Implement binary format decoding - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
83-
- [ ] Add format validation - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
84-
- [ ] Create unit tests for binary operations - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
81+
- [x] Implement file encoding to binary format - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
82+
- [x] Implement binary format decoding - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
83+
- [x] Add format validation - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
84+
- [x] Create unit tests for binary operations - [#37](https://github.com/nullcoder/ghostpaste/issues/37)
8585

8686
### PIN Authentication (`lib/auth.ts`)
8787

0 commit comments

Comments
 (0)