Skip to content

Commit

Permalink
Revamp browser compatibility (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas authored Aug 11, 2023
1 parent e5a6c1e commit 70313fb
Show file tree
Hide file tree
Showing 22 changed files with 2,802 additions and 2,565 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: "8.6.12"
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- run: yarn install
- run: pnpm install
- run: npm test -- --bail --ci
- run: npm run build && npm publish
env:
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,15 @@ jobs:
node: [16, 18, 20]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: "8.6.12"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}

- run: yarn install && npm test -- --bail --ci

- run: pnpm install && npm test -- --bail --ci
- uses: codecov/codecov-action@v3

- run: npm run build && npm publish --dry-run
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

# Changelog

## 0.4.1 ~ 0.4.4
## 0.4.1 ~ 0.4.5

- Revamp browser compatibility
- Export config
- Fix symmetric encryption internal types
- Add XChacha20 as an optional encryption backend
- Add XChaCha20 as an optional encryption backend
- Add configuration for more compatibility
- Bump dependencies

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Returns: **Buffer**

```typescript
static fromHex(hex: string): PrivateKey;
constructor(secret?: Buffer);
constructor(secret?: Uint8Array);
toHex(): string;
encapsulate(pub: PublicKey): Buffer;
multiply(pub: PublicKey): Buffer;
encapsulate(pk: PublicKey): Uint8Array;
multiply(pub: PublicKey, compressed?: boolean): Uint8Array;
equals(other: PrivateKey): boolean;
```

Expand All @@ -76,9 +76,9 @@ readonly publicKey: PublicKey;

```typescript
static fromHex(hex: string): PublicKey;
constructor(buffer: Buffer);
constructor(buffer: Uint8Array);
toHex(compressed?: boolean): string;
decapsulate(priv: PrivateKey): Buffer;
decapsulate(sk: PrivateKey): Uint8Array;
equals(other: PublicKey): boolean;
```

Expand Down Expand Up @@ -111,9 +111,9 @@ For example, if you set `isEphemeralKeyCompressed = true`, the payload would be

If you set `isHkdfKeyCompressed = true`, the hkdf key would be derived from `ephemeral public key (compressed) + shared public key (compressed)` instead of `ephemeral public key (uncompressed) + shared public key (uncompressed)`.

If you set `symmetricAlgorithm = "xchacha20"`, plaintext data will encrypted with XChacha20-Poly1305.
If you set `symmetricAlgorithm = "xchacha20"`, plaintext data will encrypted with XChaCha20-Poly1305.

If you set `symmetricNonceLength = 12`, then the nonce of aes-256-gcm would be 12 bytes. XChacha20-Poly1305's nonce is always 24 bytes.
If you set `symmetricNonceLength = 12`, then the nonce of aes-256-gcm would be 12 bytes. XChaCha20-Poly1305's nonce is always 24 bytes.

For compatibility, make sure different applications share the same configuration.

Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/ecies/js.git"
},
"version": "0.4.4",
"version": "0.4.5",
"engines": {
"node": ">=16.0.0"
},
Expand All @@ -34,16 +34,19 @@
"test": "jest"
},
"dependencies": {
"@noble/ciphers": "^0.1.4",
"@noble/curves": "^1.1.0"
"@noble/ciphers": "^0.2.0",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1"
},
"devDependencies": {
"@types/jest": "^29.5.2",
"@types/node": "^20.4.2",
"axios": "^1.4.0",
"jest": "^29.6.1",
"ts-jest": "^29.1.0",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.9",
"@types/node-fetch": "^2.6.4",
"https-proxy-agent": "^7.0.1",
"jest": "^29.6.2",
"node-fetch": "^2.6.12",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.5"
"typescript": "^5.1.6"
}
}
Loading

0 comments on commit 70313fb

Please sign in to comment.