Skip to content

Commit b26a842

Browse files
authored
Prepare for ESM (#9)
1 parent 997b2cf commit b26a842

File tree

12 files changed

+311
-288
lines changed

12 files changed

+311
-288
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
- name: check main.js
7676
run: |
7777
./scripts/check-runtime.sh example/main.js
78+
./scripts/check-runtime.sh example/quick-start.js
7879
7980
- name: check main.js on mininum supported node version
8081
run: |

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
## 0.2.5
4+
5+
- Bump dependencies
6+
- Prepare for ESM
7+
38
## 0.2.4
49

510
- Bump dependencies

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ Otherwise (e.g. browser, react native), it'll use [`@noble/ciphers`](https://git
2828
>
2929
> This library is tree-shakeable, unused code will be excluded by bundlers.
3030
31-
Check the [example](./example/) folder for bun/deno usage.
31+
Check the [example](./example/) folder for more usages.
3232

3333
## Quick start
3434

3535
```js
36+
// example/quick-start.js
3637
import { aes256gcm } from "@ecies/ciphers/aes";
3738
import { randomBytes } from "@noble/ciphers/webcrypto";
3839

@@ -61,10 +62,10 @@ The API follows `@noble/ciphers`'s API for ease of use, you can check their [exa
6162
- `xchacha20-poly1305`
6263
- Nonce is always 24 bytes.
6364

64-
If key is fixed and nonce is less than 16 bytes, avoid randomly generated nonce.
65+
If key is fixed and nonce is less than 16 bytes, **avoid randomly generated nonce**.
6566

6667
## Known limitations
6768

6869
- `xchacha20-poly1305` is implemented with pure JS [`hchacha20`](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2) function and `node:crypto`'s `chacha20-poly1305` on node.
69-
- Currently (Mar 2025), `node:crypto`'s `chacha20-poly1305` is not supported on deno and [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.
70-
- Some old versions of `deno` [do not support](https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259) **indirect** conditional exports. If you use this library to build another library, client code of your library may fall back to the `node:crypto` implementation and not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`. If you found such a problem, you need to upgrade deno and run with `--conditions deno` (>=2.4.0) or `--unstable-node-conditions deno`(>=2.3.6,<2.4.0).
70+
- Currently (Nov 2025), `node:crypto`'s `chacha20-poly1305` is neither supported on [deno](https://github.com/denoland/deno/issues/28411) nor [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.
71+
- Some old versions of `deno` [did not support](https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259) **indirect** conditional exports. If you used this library to build another library, client code of your library might have fell back to the `node:crypto` implementation and would not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`. If you found such a problem, upgrade deno and run with `--conditions deno` (>=2.4.0) or `--unstable-node-conditions deno`(>=2.3.6,<2.4.0).

biome.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"formatter": {
1616
"enabled": true,
1717
"indentStyle": "space",
18-
"lineWidth": 90
18+
"lineWidth": 92
1919
},
2020
"assist": {
2121
"actions": {

example/quick-start.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { aes256gcm } from "@ecies/ciphers/aes";
2+
import { randomBytes } from "@noble/ciphers/webcrypto";
3+
4+
const TEXT = "hello world🌍!";
5+
const encoder = new TextEncoder();
6+
const decoder = new TextDecoder();
7+
const msg = encoder.encode(TEXT);
8+
9+
const key = randomBytes();
10+
const nonce = randomBytes(16);
11+
const cipher = aes256gcm(key, nonce);
12+
console.log("decrypted:", decoder.decode(cipher.decrypt(cipher.encrypt(msg))));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
},
6363
"devDependencies": {
6464
"@biomejs/biome": "2.3.2",
65-
"@types/node": "^24.9.2",
65+
"@types/node": "^24.10.0",
6666
"@vitest/coverage-v8": "^4.0.6",
67-
"typescript": "^5.8.3",
67+
"typescript": "^5.9.3",
6868
"vitest": "^4.0.6"
6969
},
7070
"pnpm": {

0 commit comments

Comments
 (0)