Skip to content

Commit

Permalink
Export config
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas committed Jul 29, 2023
1 parent dd0f131 commit f3b1f0e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

# Changelog

## 0.4.1 ~ 0.4.3
## 0.4.1 ~ 0.4.4

- Export config
- Fix symmetric encryption internal types
- Add XChacha20 as an optional encryption backend
- Add configuration for more compatibility
Expand Down
2 changes: 1 addition & 1 deletion 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.3",
"version": "0.4.4",
"engines": {
"node": ">=16.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function decrypt(receiverRawSK: string | Buffer, msg: Buffer): Buffer {
return aesDecrypt(aesKey, encrypted);
}

export { ECIES_CONFIG } from "./config";
export { PrivateKey, PublicKey } from "./keys";

export const utils = {
Expand Down
16 changes: 12 additions & 4 deletions tests/crypt.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { ECIES_CONFIG } from "../src/config";
import { decrypt, encrypt } from "../src/index";
import { PrivateKey, PublicKey } from "../src/keys";
import { decodeHex } from "../src/utils";
import {
ECIES_CONFIG,
PrivateKey,
PublicKey,
decrypt,
encrypt,
utils,
} from "../src/index";

const decodeHex = utils.decodeHex;

const TEXT = "helloworld🌍";

Expand Down Expand Up @@ -44,6 +50,7 @@ describe("test encrypt and decrypt", () => {
it("tests config can be changed", () => {
ECIES_CONFIG.isEphemeralKeyCompressed = true;
ECIES_CONFIG.isHkdfKeyCompressed = true;
ECIES_CONFIG.symmetricNonceLength = 12;

const prv1 = new PrivateKey();
check(prv1);
Expand All @@ -53,6 +60,7 @@ describe("test encrypt and decrypt", () => {

ECIES_CONFIG.isEphemeralKeyCompressed = false;
ECIES_CONFIG.isHkdfKeyCompressed = false;
ECIES_CONFIG.symmetricNonceLength = 16;
});

it("tests encrypt/decrypt chacha", () => {
Expand Down
5 changes: 2 additions & 3 deletions tests/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import axios from "axios";
import { stringify } from "querystring";
import { PrivateKey, decrypt, encrypt, utils } from "../src/index";

import { decrypt, encrypt } from "../src/index";
import { PrivateKey } from "../src/keys";
import { decodeHex } from "../src/utils";
const decodeHex = utils.decodeHex;

const PYTHON_BACKEND = "https://eciespydemo-1-d5397785.deta.app/";

Expand Down
6 changes: 3 additions & 3 deletions tests/keys.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ECIES_CONFIG } from "../src/config";
import { PrivateKey, PublicKey } from "../src/keys";
import { decodeHex } from "../src/utils";
import { ECIES_CONFIG, PrivateKey, PublicKey, utils } from "../src/index";

const decodeHex = utils.decodeHex;

const PRV_HEX = "0x95d3c5e483e9b1d4f5fc8e79b2deaf51362980de62dbb082a9a4257eef653d7d";
const PUB_HEX =
Expand Down
13 changes: 3 additions & 10 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { randomBytes } from "crypto";
import { ECIES_CONFIG, utils } from "../src/index";
import { deriveKey, isValidPrivateKey } from "../src/utils";

import { ECIES_CONFIG } from "../src/config";
import {
aesDecrypt,
aesEncrypt,
decodeHex,
deriveKey,
getValidSecret,
isValidPrivateKey,
remove0x,
} from "../src/utils";
const { aesDecrypt, aesEncrypt, decodeHex, getValidSecret, remove0x } = utils;

const TEXT = "helloworld🌍";

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,9 @@ diff@^4.0.1:
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==

electron-to-chromium@^1.4.431:
version "1.4.475"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.475.tgz#2fee0e2a70cc1538b94f7f90aabcc436e4dcc827"
integrity sha512-mTye5u5P98kSJO2n7zYALhpJDmoSQejIGya0iR01GpoRady8eK3bw7YHHnjA1Rfi4ZSLdpuzlAC7Zw+1Zu7Z6A==
version "1.4.477"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.477.tgz#05669aa6f161ee9076a6805457e9bd9fe6d0dfd1"
integrity sha512-shUVy6Eawp33dFBFIoYbIwLHrX0IZ857AlH9ug2o4rvbWmpaCUdBpQ5Zw39HRrfzAFm4APJE9V+E2A/WB0YqJw==

emittery@^0.13.1:
version "0.13.1"
Expand Down

0 comments on commit f3b1f0e

Please sign in to comment.