Skip to content

Commit 8b0d40c

Browse files
authored
Prepare for v0.5.0 (#880)
* Prepare for v0.5.0 * Review fix * Review fix * Update doc * Review fix
1 parent 56a3f22 commit 8b0d40c

17 files changed

Lines changed: 118 additions & 110 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
## 0.4.18
55

66
- Bump dependencies
7+
- Prepare for v0.5.0
8+
- API change: Return a Node.js `Buffer` only when available (otherwise a `Uint8Array`)
79

810
## 0.4.17
911

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ See [Configuration](#configuration) to control with more granularity.
5656

5757
## API
5858

59-
### `encrypt(receiverRawPK: string | Uint8Array, data: Uint8Array): Buffer`
59+
### `encrypt(receiverRawPK: string | Uint8Array, data: Uint8Array): Uint8Array`
6060

6161
Parameters:
6262

6363
- `receiverRawPK` - Receiver's public key, hex `string` or `Uint8Array`
6464
- `data` - Data to encrypt
6565

66-
Returns: `Buffer`
66+
Returns: `Uint8Array`
6767

68-
### `decrypt(receiverRawSK: string | Uint8Array, data: Uint8Array): Buffer`
68+
### `decrypt(receiverRawSK: string | Uint8Array, data: Uint8Array): Uint8Array`
6969

7070
Parameters:
7171

7272
- `receiverRawSK` - Receiver's private key, hex `string` or `Uint8Array`
7373
- `data` - Data to decrypt
7474

75-
Returns: `Buffer`
75+
Returns: `Uint8Array`
7676

7777
### `PrivateKey`
7878

@@ -90,7 +90,7 @@ equals(other: PrivateKey): boolean;
9090
- Properties
9191

9292
```typescript
93-
get secret(): Buffer;
93+
get secret(): Uint8Array;
9494
readonly publicKey: PublicKey;
9595
```
9696

@@ -107,15 +107,6 @@ decapsulate(sk: PrivateKey, compressed?: boolean): Uint8Array;
107107
equals(other: PublicKey): boolean;
108108
```
109109

110-
- Properties
111-
112-
```typescript
113-
/** @deprecated - use `PublicKey.toBytes(false)` instead. You may also need `Buffer.from`. */
114-
get uncompressed(): Buffer;
115-
/** @deprecated - use `PublicKey.toBytes()` instead. You may also need `Buffer.from`. */
116-
get compressed(): Buffer;
117-
```
118-
119110
## Configuration
120111

121112
Following configurations are available.
@@ -190,8 +181,6 @@ Via [`@ecies/ciphers`](https://github.com/ecies/js-ciphers), `node:crypto`'s nat
190181

191182
This library is browser-friendly, check the [`example/browser`](./example/browser) directory for details. You can check [the online demo](https://js-demo.ecies.org/) as well.
192183

193-
Currently it's necessary to polyfill `Buffer` for backward compatibility. From v0.5.0, it can run in browsers as is.
194-
195184
If you want a WASM version to run directly in modern browsers or on some blockchains, you can also try [`ecies-wasm`](https://github.com/ecies/rs-wasm).
196185

197186
### Bun/Deno

example/browser/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"author": "",
1313
"license": "MIT",
1414
"dependencies": {
15-
"buffer": "^6.0.3",
1615
"eciesjs": "file:../.."
1716
},
1817
"devDependencies": {

example/browser/pnpm-lock.yaml

Lines changed: 13 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/browser/script.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { Buffer } from "buffer";
21
import { bytesToHex } from "@noble/ciphers/utils";
32
import { ECIES_CONFIG, PrivateKey, decrypt, encrypt } from "eciesjs";
43

54
import "./style.css";
65

7-
globalThis.Buffer = Buffer; // polyfill manually
8-
96
ECIES_CONFIG.ellipticCurve = "x25519";
107
ECIES_CONFIG.symmetricAlgorithm = "xchacha20";
118

@@ -69,5 +66,5 @@ setup(
6966
document.querySelector("#text-input"),
7067
document.querySelector("#text"),
7168
document.querySelector("#encrypted"),
72-
document.querySelector("#decrypted")
69+
document.querySelector("#decrypted"),
7370
);

example/browser/vite.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export default defineConfig({
1111
return "noble-ciphers";
1212
} else if (id.includes("@noble/hashes")) {
1313
return "noble-hashes";
14-
} else if (id.includes("buffer")) {
15-
return "buffer";
1614
}
1715
},
1816
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
},
6666
"devDependencies": {
6767
"@biomejs/biome": "2.4.5",
68-
"@types/node": "^25.3.3",
68+
"@types/node": "^25.3.5",
6969
"@vitest/coverage-v8": "^4.0.18",
7070
"typescript": "^5.9.3",
7171
"undici": "^7.22.0",
@@ -77,5 +77,5 @@
7777
"esbuild"
7878
]
7979
},
80-
"packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
80+
"packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017"
8181
}

0 commit comments

Comments
 (0)