@sebastienrousseau/crypto-react 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useEncrypt.d.ts","sourceRoot":"","sources":["../../src/hooks/useEncrypt.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAE/B,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAElE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,YAAY,EAAE,OAAO,CAAC;CACvB;AAgBD,wBAAgB,UAAU,IAAI,gBAAgB,CAgD7C"}
1
+ {"version":3,"file":"useEncrypt.d.ts","sourceRoot":"","sources":["../../src/hooks/useEncrypt.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAE/B,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAElE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,YAAY,EAAE,OAAO,CAAC;CACvB;AAgBD,wBAAgB,UAAU,IAAI,gBAAgB,CAgD7C"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useEncrypt = useEncrypt;
4
4
  const react_1 = require("react");
5
- const secretbox_1 = require("@sebastienrousseau/crypto-lib/dist/high-level/secretbox");
5
+ const high_level_1 = require("@sebastienrousseau/crypto-lib/high-level");
6
6
  const provider_1 = require("../provider");
7
7
  function useEncrypt() {
8
8
  const { defaultKey } = (0, provider_1.useCryptoContext)();
@@ -16,7 +16,7 @@ function useEncrypt() {
16
16
  }
17
17
  setIsProcessing(true);
18
18
  try {
19
- const result = (0, secretbox_1.seal)(k, pt);
19
+ const result = high_level_1.secretbox.seal(k, pt);
20
20
  setCiphertext(result.sealed);
21
21
  return result.sealed;
22
22
  }
@@ -31,7 +31,7 @@ function useEncrypt() {
31
31
  }
32
32
  setIsProcessing(true);
33
33
  try {
34
- const raw = (0, secretbox_1.open)(k, ct);
34
+ const raw = high_level_1.secretbox.open(k, ct);
35
35
  const text = Buffer.from(raw).toString("utf8");
36
36
  setPlaintext(text);
37
37
  return text;
@@ -1,4 +1,4 @@
1
- import { type HashAlgorithm } from "@sebastienrousseau/crypto-lib/dist/modern/hash";
1
+ import { type HashAlgorithm } from "@sebastienrousseau/crypto-lib/modern";
2
2
  export interface UseHashResult {
3
3
  hash: (data: string | Uint8Array, algorithm?: HashAlgorithm) => string;
4
4
  digest: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"useHash.d.ts","sourceRoot":"","sources":["../../src/hooks/useHash.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,gDAAgD,CAAC;AAUxD,MAAM,WAAW,aAAa;IAE5B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,SAAS,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAEvE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB,SAAS,EAAE,OAAO,CAAC;CACpB;AAeD,wBAAgB,OAAO,CACrB,gBAAgB,GAAE,aAAwB,GACzC,aAAa,CAsBf"}
1
+ {"version":3,"file":"useHash.d.ts","sourceRoot":"","sources":["../../src/hooks/useHash.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,sCAAsC,CAAC;AAU9C,MAAM,WAAW,aAAa;IAE5B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,SAAS,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAEvE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB,SAAS,EAAE,OAAO,CAAC;CACpB;AAeD,wBAAgB,OAAO,CACrB,gBAAgB,GAAE,aAAwB,GACzC,aAAa,CAsBf"}
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useHash = useHash;
4
4
  const react_1 = require("react");
5
- const hash_1 = require("@sebastienrousseau/crypto-lib/dist/modern/hash");
5
+ const modern_1 = require("@sebastienrousseau/crypto-lib/modern");
6
6
  function useHash(defaultAlgorithm = "sha256") {
7
7
  const [digest, setDigest] = (0, react_1.useState)(null);
8
8
  const [isHashing, setIsHashing] = (0, react_1.useState)(false);
9
9
  const hash = (0, react_1.useCallback)((data, algorithm) => {
10
10
  setIsHashing(true);
11
11
  try {
12
- const result = (0, hash_1.hash)({
12
+ const result = (0, modern_1.hash)({
13
13
  algorithm: algorithm ?? defaultAlgorithm,
14
14
  data,
15
15
  });
@@ -1,4 +1,4 @@
1
- import { type KeyAlgorithm } from "@sebastienrousseau/crypto-lib/dist/keys/keygen";
1
+ import { type KeyAlgorithm } from "@sebastienrousseau/crypto-lib/keys";
2
2
  export interface UseKeypairResult {
3
3
  publicKey: string | null;
4
4
  privateKey: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"useKeypair.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeypair.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,gDAAgD,CAAC;AAUxD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAE7C,YAAY,EAAE,OAAO,CAAC;CACvB;AAeD,wBAAgB,UAAU,CACxB,gBAAgB,GAAE,YAAwB,GACzC,gBAAgB,CAsBlB"}
1
+ {"version":3,"file":"useKeypair.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeypair.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,oCAAoC,CAAC;AAU5C,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAE7C,YAAY,EAAE,OAAO,CAAC;CACvB;AAeD,wBAAgB,UAAU,CACxB,gBAAgB,GAAE,YAAwB,GACzC,gBAAgB,CAsBlB"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useKeypair = useKeypair;
4
4
  const react_1 = require("react");
5
- const keygen_1 = require("@sebastienrousseau/crypto-lib/dist/keys/keygen");
5
+ const keys_1 = require("@sebastienrousseau/crypto-lib/keys");
6
6
  function useKeypair(defaultAlgorithm = "ed25519") {
7
7
  const [publicKey, setPublicKey] = (0, react_1.useState)(null);
8
8
  const [privateKey, setPrivateKey] = (0, react_1.useState)(null);
@@ -11,7 +11,7 @@ function useKeypair(defaultAlgorithm = "ed25519") {
11
11
  const generate = (0, react_1.useCallback)((algo = defaultAlgorithm) => {
12
12
  setIsGenerating(true);
13
13
  try {
14
- const kp = (0, keygen_1.generateKeyPair)(algo);
14
+ const kp = (0, keys_1.generateKeyPair)(algo);
15
15
  setPublicKey(kp.publicKey);
16
16
  setPrivateKey(kp.privateKey);
17
17
  setAlgorithm(kp.algorithm);
@@ -1,4 +1,4 @@
1
- import { type SignAlgorithm } from "@sebastienrousseau/crypto-lib/dist/crypto";
1
+ import { type SignAlgorithm } from "@sebastienrousseau/crypto-lib";
2
2
  export interface UseSignatureResult {
3
3
  sign: (privateKey: string, message: string | Uint8Array, algorithm?: SignAlgorithm) => string;
4
4
  verify: (publicKey: string, message: string | Uint8Array, signature: string, algorithm?: SignAlgorithm) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useSignature.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignature.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,2CAA2C,CAAC;AAUnD,MAAM,WAAW,kBAAkB;IAEjC,IAAI,EAAE,CACJ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,CAAC,EAAE,aAAa,KACtB,MAAM,CAAC;IAEZ,MAAM,EAAE,CACN,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,aAAa,KACtB,OAAO,CAAC;IAEb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAExB,YAAY,EAAE,OAAO,CAAC;CACvB;AAgBD,wBAAgB,YAAY,CAC1B,gBAAgB,GAAE,aAAyB,GAC1C,kBAAkB,CAoDpB"}
1
+ {"version":3,"file":"useSignature.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignature.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAU3E,MAAM,WAAW,kBAAkB;IAEjC,IAAI,EAAE,CACJ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,CAAC,EAAE,aAAa,KACtB,MAAM,CAAC;IAEZ,MAAM,EAAE,CACN,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,aAAa,KACtB,OAAO,CAAC;IAEb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAExB,YAAY,EAAE,OAAO,CAAC;CACvB;AAgBD,wBAAgB,YAAY,CAC1B,gBAAgB,GAAE,aAAyB,GAC1C,kBAAkB,CAoDpB"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSignature = useSignature;
4
4
  const react_1 = require("react");
5
- const crypto_1 = require("@sebastienrousseau/crypto-lib/dist/crypto");
5
+ const crypto_lib_1 = require("@sebastienrousseau/crypto-lib");
6
6
  function useSignature(defaultAlgorithm = "ed25519") {
7
7
  const [signature, setSignature] = (0, react_1.useState)(null);
8
8
  const [isValid, setIsValid] = (0, react_1.useState)(null);
@@ -10,7 +10,7 @@ function useSignature(defaultAlgorithm = "ed25519") {
10
10
  const sign = (0, react_1.useCallback)((privateKey, message, algorithm) => {
11
11
  setIsProcessing(true);
12
12
  try {
13
- const sig = crypto_1.crypto.sign(algorithm ?? defaultAlgorithm, privateKey, message);
13
+ const sig = crypto_lib_1.crypto.sign(algorithm ?? defaultAlgorithm, privateKey, message);
14
14
  setSignature(sig);
15
15
  return sig;
16
16
  }
@@ -21,7 +21,7 @@ function useSignature(defaultAlgorithm = "ed25519") {
21
21
  const verify = (0, react_1.useCallback)((publicKey, message, sig, algorithm) => {
22
22
  setIsProcessing(true);
23
23
  try {
24
- const valid = crypto_1.crypto.verify(algorithm ?? defaultAlgorithm, publicKey, message, sig);
24
+ const valid = crypto_lib_1.crypto.verify(algorithm ?? defaultAlgorithm, publicKey, message, sig);
25
25
  setIsValid(valid);
26
26
  return valid;
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebastienrousseau/crypto-react",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "React hooks for client-side cryptography -- key generation, encryption, signing, and hashing in a single import.",
5
5
  "author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
6
6
  "license": "MIT OR Apache-2.0",
@@ -16,38 +16,40 @@
16
16
  "engines": {
17
17
  "node": ">=22.0.0"
18
18
  },
19
+ "type": "commonjs",
19
20
  "main": "./dist/index.js",
20
21
  "types": "./dist/index.d.ts",
21
- "sideEffects": false,
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./dist/index.d.ts",
25
25
  "require": "./dist/index.js",
26
- "import": "./dist/index.js"
27
- }
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./package.json": "./package.json"
28
29
  },
30
+ "sideEffects": false,
29
31
  "files": [
30
32
  "dist/**/*.js",
31
33
  "dist/**/*.d.ts",
32
34
  "dist/**/*.d.ts.map"
33
35
  ],
34
36
  "dependencies": {
35
- "@sebastienrousseau/crypto-lib": "0.0.8"
37
+ "@sebastienrousseau/crypto-lib": "0.0.9"
36
38
  },
37
39
  "peerDependencies": {
38
40
  "react": "^19.3.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@sebastienrousseau/mocha-config": "^0.0.5",
42
- "@types/chai": "^4.3.7",
44
+ "@types/chai": "^5.2.3",
43
45
  "@types/chai-as-promised": "^8.0.2",
44
- "@types/mocha": "^10.0.2",
46
+ "@types/mocha": "^10.0.10",
45
47
  "@types/node": "^26.6.3",
46
48
  "@types/react": "^19.3.0",
47
49
  "c8": "^12.0.0",
48
- "chai": "^4.5.0",
49
- "chai-as-promised": "^7.1.2",
50
- "mocha": "^10.8.2",
50
+ "chai": "^6.3.0",
51
+ "chai-as-promised": "^8.0.2",
52
+ "mocha": "^12.0.3",
51
53
  "react": "^19.3.0",
52
54
  "rimraf": "^6.1.3",
53
55
  "ts-node": "^10.9.2",
@@ -73,8 +75,8 @@
73
75
  "clean": "rimraf ./coverage ./dist ./docs",
74
76
  "test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --reporter=lcov --reporter=text mocha --config=.mocharc.cjs",
75
77
  "docs": "typedoc",
76
- "lint": "eslint --ext .ts src __tests__",
77
- "lint:fix": "eslint --cache --fix --ext .ts src __tests__",
78
+ "lint": "eslint src __tests__",
79
+ "lint:fix": "eslint --cache --fix src __tests__",
78
80
  "format": "prettier --write src/**/*.ts",
79
81
  "format:check": "prettier --check \"src/**/*.ts\""
80
82
  }