@sebastienrousseau/crypto-react 0.0.34 → 0.0.36
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.
- package/README.md +24 -19
- package/dist/hooks/useKeypair.d.ts +1 -0
- package/dist/hooks/useKeypair.d.ts.map +1 -1
- package/dist/hooks/useKeypair.js +6 -1
- package/dist/provider.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -118,12 +118,12 @@ Crypto Service provides a complete cryptography stack across 14 specialized pack
|
|
|
118
118
|
|
|
119
119
|
| Package | Role | Description |
|
|
120
120
|
| :-------------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :----------------------------------------------------------------------------------------------------------------------------- |
|
|
121
|
-
| [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API
|
|
121
|
+
| [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API docs | Postman collection types and a Postman-to-Markdown converter; the server's API contract is its OpenAPI document. |
|
|
122
122
|
| [`@sebastienrousseau/crypto-benchmarks`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-benchmarks) | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. |
|
|
123
123
|
| [`@sebastienrousseau/crypto-cbom`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cbom) | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). |
|
|
124
124
|
| [`@sebastienrousseau/crypto-cli`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cli) | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. |
|
|
125
125
|
| [`@sebastienrousseau/crypto-edge`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
|
|
126
|
-
| [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS and local providers
|
|
126
|
+
| [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS, Google Cloud KMS, Vault Transit and local providers; Azure is a stub. |
|
|
127
127
|
| [`@sebastienrousseau/crypto-lib`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lib) | Core Library | Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript. |
|
|
128
128
|
| [`@sebastienrousseau/crypto-lsp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lsp) | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. |
|
|
129
129
|
| [`@sebastienrousseau/crypto-mcp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-mcp) | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. |
|
|
@@ -158,21 +158,26 @@ Wrap your component tree with `<CryptoProvider>` to supply shared
|
|
|
158
158
|
configuration to all hooks.
|
|
159
159
|
|
|
160
160
|
```tsx
|
|
161
|
-
<CryptoProvider
|
|
162
|
-
defaultKey="a1b2c3d4...64-hex-chars"
|
|
163
|
-
serverUrl="https://crypto.example.com"
|
|
164
|
-
apiKey="my-api-key"
|
|
165
|
-
>
|
|
161
|
+
<CryptoProvider defaultKey={keyTheUserUnlocked}>
|
|
166
162
|
<App />
|
|
167
163
|
</CryptoProvider>
|
|
168
164
|
```
|
|
169
165
|
|
|
170
|
-
| Prop | Type | Description
|
|
171
|
-
| :----------- | :---------- |
|
|
172
|
-
| `defaultKey` | `string` | Hex-encoded 256-bit key for `useEncrypt`
|
|
173
|
-
| `serverUrl` | `string` |
|
|
174
|
-
| `apiKey` | `string` | API key
|
|
175
|
-
| `children` | `ReactNode` | Child components
|
|
166
|
+
| Prop | Type | Description |
|
|
167
|
+
| :----------- | :---------- | :------------------------------------------------------------------ |
|
|
168
|
+
| `defaultKey` | `string` | Hex-encoded 256-bit key for `useEncrypt` |
|
|
169
|
+
| `serverUrl` | `string` | Deprecated: no hook reads it |
|
|
170
|
+
| `apiKey` | `string` | Deprecated: no hook reads it, and an API key in a browser is public |
|
|
171
|
+
| `children` | `ReactNode` | Child components |
|
|
172
|
+
|
|
173
|
+
Everything these hooks hold runs in the browser. A key written into your
|
|
174
|
+
bundle, such as a literal `defaultKey`, is public; pass keys the user
|
|
175
|
+
supplies or unlocks at runtime. Keys in hook state, such as
|
|
176
|
+
`useKeypair`'s `privateKey`, can be read by any script on the page and by
|
|
177
|
+
React DevTools, and JavaScript cannot wipe them: call `clear()` when you
|
|
178
|
+
are done, and keep long-lived keys on a server (for example
|
|
179
|
+
crypto-server's `/v2/keys/generate`, which never returns the private key
|
|
180
|
+
unless asked).
|
|
176
181
|
|
|
177
182
|
Access the context from any child via `useCryptoContext()`.
|
|
178
183
|
|
|
@@ -180,12 +185,12 @@ Access the context from any child via `useCryptoContext()`.
|
|
|
180
185
|
|
|
181
186
|
## Hooks Reference
|
|
182
187
|
|
|
183
|
-
| Hook | Purpose | Returns
|
|
184
|
-
| :------------- | :----------------------------------- |
|
|
185
|
-
| `useKeypair` | Key pair generation (all algorithms) | `{ publicKey, privateKey, algorithm, generate, isGenerating }` |
|
|
186
|
-
| `useEncrypt` | Symmetric encryption (secretbox) | `{ encrypt, decrypt, ciphertext, plaintext, isProcessing }`
|
|
187
|
-
| `useHash` | Cryptographic hashing | `{ hash, digest, isHashing }`
|
|
188
|
-
| `useSignature` | Digital signatures (sign + verify) | `{ sign, verify, signature, isValid, isProcessing }`
|
|
188
|
+
| Hook | Purpose | Returns |
|
|
189
|
+
| :------------- | :----------------------------------- | :-------------------------------------------------------------------- |
|
|
190
|
+
| `useKeypair` | Key pair generation (all algorithms) | `{ publicKey, privateKey, algorithm, generate, isGenerating, clear }` |
|
|
191
|
+
| `useEncrypt` | Symmetric encryption (secretbox) | `{ encrypt, decrypt, ciphertext, plaintext, isProcessing }` |
|
|
192
|
+
| `useHash` | Cryptographic hashing | `{ hash, digest, isHashing }` |
|
|
193
|
+
| `useSignature` | Digital signatures (sign + verify) | `{ sign, verify, signature, isValid, isProcessing }` |
|
|
189
194
|
|
|
190
195
|
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
191
196
|
|
|
@@ -5,6 +5,7 @@ export interface UseKeypairResult {
|
|
|
5
5
|
algorithm: string | null;
|
|
6
6
|
generate: (algorithm?: KeyAlgorithm) => void;
|
|
7
7
|
isGenerating: boolean;
|
|
8
|
+
clear: () => void;
|
|
8
9
|
}
|
|
9
10
|
export declare function useKeypair(defaultAlgorithm?: KeyAlgorithm): UseKeypairResult;
|
|
10
11
|
//# sourceMappingURL=useKeypair.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAOzB,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;IAEtB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAeD,wBAAgB,UAAU,CACxB,gBAAgB,GAAE,YAAwB,GACzC,gBAAgB,CA4BlB"}
|
package/dist/hooks/useKeypair.js
CHANGED
|
@@ -20,6 +20,11 @@ function useKeypair(defaultAlgorithm = "ed25519") {
|
|
|
20
20
|
setIsGenerating(false);
|
|
21
21
|
}
|
|
22
22
|
}, [defaultAlgorithm]);
|
|
23
|
-
|
|
23
|
+
const clear = (0, react_1.useCallback)(() => {
|
|
24
|
+
setPublicKey(null);
|
|
25
|
+
setPrivateKey(null);
|
|
26
|
+
setAlgorithm(null);
|
|
27
|
+
}, []);
|
|
28
|
+
return { publicKey, privateKey, algorithm, generate, isGenerating, clear };
|
|
24
29
|
}
|
|
25
30
|
//# sourceMappingURL=useKeypair.js.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAU3E,MAAM,WAAW,kBAAkB;IAEjC,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAU3E,MAAM,WAAW,kBAAkB;IAEjC,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAYD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAE7D,QAAQ,EAAE,SAAS,CAAC;CACrB;AAgBD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,mBAAmB,+BAM1E;AAaD,wBAAgB,gBAAgB,IAAI,kBAAkB,CAErD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebastienrousseau/crypto-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "React hooks for client-side cryptography: key generation, encryption, signing, hashing and post-quantum hybrid streaming encryption (ML-KEM-768).",
|
|
5
5
|
"author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist/**/*.d.ts.map"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@sebastienrousseau/crypto-lib": "0.0.
|
|
37
|
+
"@sebastienrousseau/crypto-lib": "0.0.36"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^19.3.0"
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"build": "tsc --build tsconfig.json",
|
|
77
77
|
"clean": "rimraf ./coverage ./dist ./docs",
|
|
78
78
|
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --reporter=lcov --reporter=text mocha --config=.mocharc.cjs",
|
|
79
|
+
"test:run": "mocha --config=.mocharc.cjs",
|
|
79
80
|
"docs": "typedoc",
|
|
80
81
|
"lint": "eslint src __tests__",
|
|
81
82
|
"lint:fix": "eslint --cache --fix src __tests__",
|