feat: Merge isohash functionality into smarthash for cross-environment hash support
- Updated test files to use new tapbundle import from @git.zone/tstest. - Created a new plan for merging isohash into smarthash, detailing objectives and implementation steps. - Added browser-specific tests for SHA256 hashing functions in test/test.browser.ts. - Implemented browser-compatible hashing functions in ts_web/index.ts using Web Crypto API. - Introduced plugins for environment detection and JSON handling in ts_web/plugins.ts. - Ensured that existing smarthash functionality remains intact and consistent across environments.
This commit is contained in:
40
readme.plan.md
Normal file
40
readme.plan.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Merge Plan: isohash into smarthash
|
||||
|
||||
**First line: Command to reread CLAUDE.md**: `cat ~/.claude/CLAUDE.md`
|
||||
|
||||
## Objective
|
||||
Merge the functionality from @push.rocks/isohash into @push.rocks/smarthash to provide cross-environment hash support (browser and Node.js).
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### 1. Create ts_web directory structure ✓
|
||||
- Create `./ts_web` directory for browser-specific code
|
||||
- This will house the Web Crypto API implementation
|
||||
|
||||
### 2. Add required dependencies ✓
|
||||
- Add `@push.rocks/smartenv` to package.json dependencies
|
||||
- This is needed for environment detection
|
||||
|
||||
### 3. Create web-specific plugin file ✓
|
||||
- Create `ts_web/plugins.ts` with smartenv import
|
||||
- Follow the plugins pattern used in the Node.js version
|
||||
|
||||
### 4. Implement browser-compatible hash functions ✓
|
||||
- Copy and adapt `index.ts` from isohash to `ts_web/index.ts`
|
||||
- Remove circular dependency (isohash importing smarthash)
|
||||
- Use native Web Crypto API for SHA256 in browser
|
||||
- Maintain compatibility with existing smarthash API
|
||||
|
||||
### 5. Build and verify ✓
|
||||
- Run `pnpm build` to ensure TypeScript compilation succeeds
|
||||
- Check that both Node.js and browser builds are created
|
||||
|
||||
### 6. Test functionality ✓
|
||||
- Run `pnpm test` to ensure all tests pass
|
||||
- Verify browser compatibility through web tests
|
||||
|
||||
## Key Considerations
|
||||
- The web version uses native Web Crypto API for performance
|
||||
- The Node.js version continues using the existing crypto implementation
|
||||
- API remains consistent across both environments
|
||||
- No breaking changes to existing smarthash functionality
|
Reference in New Issue
Block a user