-
Notifications
You must be signed in to change notification settings - Fork 43
feat: Expose cross-env cipher utils from utils package
#3342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8c20e7d to
8f9f777
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds cross-environment AES encryption/decryption utilities to the @streamr/utils package, enabling both browser and Node.js environments to use cipher operations through a unified API.
Key Changes
- Added
createCipherivandcreateDecipherivfunctions for both browser (usingbrowserify-aes) and Node.js (using native crypto module) - Updated build configuration to bundle necessary cryptographic dependencies for browser environments
- Added TypeScript type definitions for
browserify-aeslibrary
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/utils/src/browser/crypto.ts | Implements AES cipher functions for browsers using browserify-aes with algorithm validation |
| packages/utils/src/nodejs/crypto.ts | Implements cipher functions as thin wrappers around Node.js native crypto module |
| packages/utils/src/browserify-aes.d.ts | Adds TypeScript type definitions for browserify-aes library |
| packages/utils/src/exports.ts | Exports new cipher functions from the crypto module |
| packages/utils/package.json | Adds browserify-aes, md5.js dependencies and CommonJS/JSON rollup plugins |
| packages/utils/rollup.config.mts | Configures bundling to include specific crypto dependencies for browser builds |
| package-lock.json | Updates lockfile with new dependencies and their transitive dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * and not the one shipped with `create-hash` (which is outdated and has issues with | ||
| * modern bundlers). | ||
| */ | ||
| /node_modules\/(?!browserify-aes|cipher-base|evp_bytestokey|md5.js|hash-base)/, |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regular expression pattern excludes buffer-xor from bundling, but buffer-xor is a dependency of browserify-aes. This may cause runtime errors if the bundler doesn't automatically include it. Consider adding buffer-xor to the list of bundled dependencies in the negative lookahead pattern.
| /node_modules\/(?!browserify-aes|cipher-base|evp_bytestokey|md5.js|hash-base)/, | |
| /node_modules\/(?!browserify-aes|buffer-xor|cipher-base|evp_bytestokey|md5.js|hash-base)/, |
This pull request adds support for AES encryption and decryption utilities for both browser and Node.js environments, updates the build configuration to bundle necessary dependencies, and ensures that new cryptographic functions are exported for use throughout the codebase.
Changes
Cryptography utilities:
Added
createCipherivandcreateDecipherivfunctions tobrowser/crypto.tsusingbrowserify-aesfor AES support in the browser, with input validation for supported suites.Added corresponding
createCipherivandcreateDecipherivfunctions tonodejs/crypto.tsusing Node's nativecryptomodule for Node.js support.Exported the new cryptographic functions from
exports.tsfor use in other modules.Dependency management:
browserify-aesandmd5.jsto dependencies, and@rollup/plugin-commonjsand@rollup/plugin-jsonto devDependencies inpackage.jsonto support new crypto utilities and bundling. [1] [2]Build configuration:
rollup.config.mtsto include CommonJS and JSON plugins, and modified theexternalconfiguration to ensure required dependencies (likebrowserify-aesandmd5.js) are bundled, avoiding outdated versions from other packages. [1] [2]Next steps
createCipherivandcreateDecipherivin StreamrTV'stv-enginepackage, and in the SDK.