Skip to content

Conversation

@mondoreale
Copy link
Contributor

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 createCipheriv and createDecipheriv functions to browser/crypto.ts using browserify-aes for AES support in the browser, with input validation for supported suites.

  • Added corresponding createCipheriv and createDecipheriv functions to nodejs/crypto.ts using Node's native crypto module for Node.js support.

  • Exported the new cryptographic functions from exports.ts for use in other modules.

Dependency management:

  • Added browserify-aes and md5.js to dependencies, and @rollup/plugin-commonjs and @rollup/plugin-json to devDependencies in package.json to support new crypto utilities and bundling. [1] [2]

Build configuration:

  • Updated rollup.config.mts to include CommonJS and JSON plugins, and modified the external configuration to ensure required dependencies (like browserify-aes and md5.js) are bundled, avoiding outdated versions from other packages. [1] [2]

Next steps

  • Use createCipheriv and createDecipheriv in StreamrTV's tv-engine package, and in the SDK.

@github-actions github-actions bot added the utils label Jan 9, 2026
Copy link
Contributor

Copilot AI left a 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 createCipheriv and createDecipheriv functions for both browser (using browserify-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-aes library

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)/,
Copy link

Copilot AI Jan 9, 2026

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.

Suggested change
/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)/,

Copilot uses AI. Check for mistakes.
@mondoreale mondoreale merged commit d490e1e into bundles Jan 9, 2026
40 of 41 checks passed
@mondoreale mondoreale deleted the cipher-utils branch January 9, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants