Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# Runs on push to master: install deps, test, build, then publish to npm (if version bumped).
# Requires: NPM_TOKEN secret in repo Settings > Secrets and variables > Actions.

name: NPM publish

Expand All @@ -8,25 +8,37 @@ on:
branches: [ master ]

jobs:
build:

build-and-publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build

- id: publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN}}
- if: steps.publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
env:
HUSKY: 0

- name: Build
run: npm run build

- name: Publish to npm
id: publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}

- if: steps.publish.outputs.type != 'none'
run: |
echo "Published version ${{ steps.publish.outputs.version }} (previous: ${{ steps.publish.outputs.old-version }})"
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
19 changes: 19 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"types": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "perf", "section": "Performance Improvements" },
{ "type": "revert", "section": "Reverts" },
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "style", "section": "Styles", "hidden": true },
{ "type": "chore", "section": "Miscellaneous Chores", "hidden": true },
{ "type": "refactor", "section": "Code Refactoring", "hidden": false },
{ "type": "test", "section": "Tests", "hidden": true },
{ "type": "build", "section": "Build System", "hidden": false }
],
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"userUrlFormat": "{{host}}/{{user}}",
"releaseCommitMessageFormat": "chore(release): {{currentTag}}"
}
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
All notable changes to this project will be documented in this file.

**Generating the changelog**

- **From commits (since last tag):** `npm run changelog` — updates CHANGELOG.md from [conventional commits](https://www.conventionalcommits.org/) (e.g. `feat:`, `fix:`, `BREAKING CHANGE:`).
- **Full release (bump version + changelog + tag):** `npm run release -- --release-as major|minor|patch` — uses [standard-version](https://github.com/conventional-changelog/standard-version); bump and changelog are driven by commit messages.

## [4.0.0](https://github.com/miladezzat/encrypt-rsa/compare/v3.3.0...v4.0.0) - 2025-02-01

### BREAKING CHANGES

- **Async API**: All crypto methods now return Promises instead of synchronous values. Migrate by adding `await` or `.then()` to every call to:
- `encryptStringWithRsaPublicKey`
- `decryptStringWithRsaPrivateKey`
- `encrypt`
- `decrypt`
- `createPrivateAndPublicKeys`
- `encryptBufferWithRsaPublicKey`
- `decryptBufferWithRsaPrivateKey`
- **Entry points**: Package now ships separate Node and Web builds. `main`/`module`/`types` point to `./build/node/node/index.js`; `browser` and conditional `exports` point to the Web build. The old single entry `./build/index.js` is no longer published.
- **Buffer return type**: `decryptBufferWithRsaPrivateKey` return type is now `Promise<Uint8Array>` (was `Buffer`). In Node the runtime value is still a `Buffer`; use `Uint8Array` in shared or cross-environment code.

### Features

- **Node and Web builds**: Same package works in Node.js and in the browser. Conditional exports select the correct build; same `NodeRSA` class and `INodeRSA` interface in both environments.
- **Web Crypto (browser)**: Browser build uses the Web Crypto API (RSA-OAEP, SHA-1) for encrypt/decrypt with public/private key and for key generation. `encrypt(privateKey)` / `decrypt(publicKey)` throw in the browser (not supported by Web Crypto).
- **Shared interface**: Both builds implement the shared `INodeRSA` interface; buffer methods use `Uint8Array` in the type signature.

## [3.3.0](https://github.com/miladezzat/encrypt-rsa/compare/v3.1.0...v3.3.0) (2024-10-12)

Expand Down
Loading