@push.rocks/smartcrypto 2.4.1 → 2.5.0

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartcrypto',
6
- version: '2.4.1',
6
+ version: '2.5.0',
7
7
  description: 'A library providing easy methods for cryptographic operations, including key pair generation.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLCtGQUErRjtDQUM3RyxDQUFBIn0=
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@push.rocks/smartcrypto",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "private": false,
5
5
  "description": "A library providing easy methods for cryptographic operations, including key pair generation.",
6
6
  "main": "dist_ts/index.js",
7
7
  "typings": "dist_ts/index.d.ts",
8
8
  "exports": {
9
9
  ".": "./dist_ts/index.js",
10
+ "./hash": "./dist_ts/smartcrypto.hash.js",
10
11
  "./node": "./dist_ts_node/index.js"
11
12
  },
12
13
  "author": "Task Venture Capital GmbH",
package/readme.md CHANGED
@@ -141,6 +141,22 @@ const streamDigest = await sha256FromStream(response.body!);
141
141
 
142
142
  `createSha256Hasher()` returns an `ISha256Hasher`. `update()` accepts `ArrayBuffer` or `Uint8Array` values and returns the hasher for chaining; `digest()` finalizes it, and any later `update()` or `digest()` call fails with `INVALID_STATE`. `sha256FromStream()` reads a `ReadableStream<Uint8Array>` chunk by chunk with bounded memory and always releases the reader lock; a non-byte chunk cancels the stream and fails with `INVALID_ARGUMENT`, and a source error is rethrown unchanged.
143
143
 
144
+ ### Hashing Entry
145
+
146
+ `@push.rocks/smartcrypto/hash` exports exactly the package-entry hashing functions and `ISha256Hasher`, and its module graph contains no third-party code. Use it in browser code that reaches the hashing functions through a re-exported namespace, such as a `plugins.ts` import hub:
147
+
148
+ ```typescript
149
+ // plugins.ts
150
+ import * as smartcrypto from '@push.rocks/smartcrypto/hash';
151
+ export { smartcrypto };
152
+
153
+ // elsewhere
154
+ import * as plugins from './plugins.js';
155
+ const digest = plugins.smartcrypto.createSha256Hasher().update(bytes).digest();
156
+ ```
157
+
158
+ esbuild does not tree-shake a namespace that is re-exported and then read through two property accesses (`plugins.smartcrypto.createSha256Hasher`); it keeps every export of the imported module. Through the package entry that includes the `nodeForge` export and therefore all of `node-forge` (about 310 KB minified); through `/hash` the same pattern stays a few kilobytes. Named imports from the package entry are tree-shaken either way.
159
+
144
160
  ### Node.js Entry
145
161
 
146
162
  `@push.rocks/smartcrypto/node` exports the same hashing functions backed by `node:crypto`, plus file and MD5 hashing. It runs in Node.js and Deno.
@@ -162,7 +178,7 @@ const checksum = await md5FromString('legacy payload');
162
178
 
163
179
  `sha256FromStream()` here accepts a Node.js `Readable` or a WHATWG `ReadableStream<Uint8Array>`. Node.js readables may emit bytes or strings (hashed as UTF-8); any other chunk fails with `INVALID_ARGUMENT` and destroys the stream. `sha256FromFile()` streams the file, so file-system errors such as `ENOENT` are rethrown unchanged. MD5 is cryptographically broken; use `md5FromString()` only for checksums that an external protocol requires.
164
180
 
165
- | Function | `@push.rocks/smartcrypto` | `@push.rocks/smartcrypto/node` |
181
+ | Function | `@push.rocks/smartcrypto` and `/hash` | `@push.rocks/smartcrypto/node` |
166
182
  |---|---|---|
167
183
  | `sha256FromString(string)` | WebCrypto | `node:crypto` |
168
184
  | `sha256FromStringSync(string)` | built-in SHA-256 | `node:crypto` |
@@ -227,7 +243,7 @@ The package declares `"sideEffects": false`, and no module does work at import t
227
243
 
228
244
  ## Migration from @push.rocks/smarthash
229
245
 
230
- `@push.rocks/smarthash` is deprecated; its hashing functions live in this package with the same names and byte-identical digests. Node.js code imports from `@push.rocks/smartcrypto/node`, browser code (formerly `@push.rocks/smarthash/web`) from `@push.rocks/smartcrypto`.
246
+ `@push.rocks/smarthash` is deprecated; its hashing functions live in this package with the same names and byte-identical digests. Node.js code imports from `@push.rocks/smartcrypto/node`, browser code (formerly `@push.rocks/smarthash/web`) from `@push.rocks/smartcrypto`, or from `@push.rocks/smartcrypto/hash` when it re-exports the import as a namespace (see [Hashing Entry](#hashing-entry)).
231
247
 
232
248
  | `@push.rocks/smarthash` | `@push.rocks/smartcrypto` |
233
249
  |---|---|
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartcrypto',
6
- version: '2.4.1',
6
+ version: '2.5.0',
7
7
  description: 'A library providing easy methods for cryptographic operations, including key pair generation.'
8
8
  }