Skip to content

Commit

Permalink
Revamp browser compatibility by removing Buffer-specific invokation
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas committed Aug 25, 2023
1 parent 70313fb commit 6175c31
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 490 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: "8.6.12"
version: "latest"
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
registry-url: "https://registry.npmjs.org"
- run: pnpm install
- run: npm test -- --bail --ci
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ jobs:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: "8.6.12"
version: "latest"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- run: pnpm install && npm test -- --bail --ci
- run: pnpm install
- run: npm test -- --bail --ci
- uses: codecov/codecov-action@v3
- run: npm run build && npm publish --dry-run
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Run the code below with `npx ts-node`.

```typescript
> import { encrypt, decrypt, PrivateKey } from 'eciesjs'
> const k1 = new PrivateKey()
> const data = Buffer.from('this is a test')
> decrypt(k1.toHex(), encrypt(k1.publicKey.toHex(), data)).toString()
'this is a test'
> const sk = new PrivateKey()
> const data = Buffer.from('hello world🌍')
> decrypt(sk.toHex(), encrypt(sk.publicKey.toHex(), data)).toString()
'hello world🌍'
```

## API

### `encrypt(receiverRawPK: string | Buffer, msg: Buffer): Buffer`
### `encrypt(receiverRawPK: string | Uint8Array, msg: Uint8Array): Buffer`

Parameters:

Expand All @@ -41,7 +41,7 @@ Parameters:

Returns: **Buffer**

### `decrypt(receiverRawSK: string | Buffer, msg: Buffer): Buffer`
### `decrypt(receiverRawSK: string | Uint8Array, msg: Uint8Array): Buffer`

Parameters:

Expand All @@ -59,7 +59,7 @@ static fromHex(hex: string): PrivateKey;
constructor(secret?: Uint8Array);
toHex(): string;
encapsulate(pk: PublicKey): Uint8Array;
multiply(pub: PublicKey, compressed?: boolean): Uint8Array;
multiply(pk: PublicKey, compressed?: boolean): Uint8Array;
equals(other: PrivateKey): boolean;
```

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
},
"dependencies": {
"@noble/ciphers": "^0.2.0",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1"
"@noble/curves": "^1.2.0",
"@noble/hashes": "^1.3.2"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.9",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.6",
"@types/node-fetch": "^2.6.4",
"https-proxy-agent": "^7.0.1",
"jest": "^29.6.2",
"node-fetch": "^2.6.12",
"jest": "^29.6.4",
"node-fetch": "^2.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit 6175c31

Please sign in to comment.