@kokuin/crypto-napi 0.7.3 → 0.7.4

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.
Files changed (2) hide show
  1. package/lib/provider.js +6 -12
  2. package/package.json +11 -11
package/lib/provider.js CHANGED
@@ -1,16 +1,10 @@
1
+ import { assertUnsharedBytes } from '@kokuin/crypto';
1
2
  import { nodeCrypto } from '@kokuin/crypto-node';
2
3
  import { loadNapiBinding } from './binding.js';
3
- function assertBytes(value) {
4
- if (!(value instanceof Uint8Array) || !(value.buffer instanceof ArrayBuffer)) {
5
- throw new TypeError('Expected an unshared Uint8Array');
6
- }
7
- // Throws TypeError on a detached buffer.
8
- new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
9
- }
10
4
  function assertSigning(alg, seed, message) {
11
5
  if (alg !== 'EdDSA') throw new TypeError('Unsupported signing algorithm');
12
- assertBytes(seed);
13
- assertBytes(message);
6
+ assertUnsharedBytes(seed);
7
+ assertUnsharedBytes(message);
14
8
  if (seed.length !== 32) throw new TypeError('Expected a 32-byte Ed25519 seed');
15
9
  }
16
10
  function assertVerifying({ alg, signature, message, publicKey }) {
@@ -19,7 +13,7 @@ function assertVerifying({ alg, signature, message, publicKey }) {
19
13
  signature,
20
14
  message,
21
15
  publicKey
22
- ])assertBytes(bytes);
16
+ ])assertUnsharedBytes(bytes);
23
17
  }
24
18
  function assertOutputLength(dkLen) {
25
19
  if (!Number.isInteger(dkLen) || dkLen < 1 || dkLen > 65536) throw new RangeError('Invalid blake3 output length');
@@ -149,7 +143,7 @@ function assertResultCount(results, count) {
149
143
  });
150
144
  },
151
145
  async blake3 ({ input, dkLen }) {
152
- assertBytes(input);
146
+ assertUnsharedBytes(input);
153
147
  assertOutputLength(dkLen);
154
148
  return binding.blake3({
155
149
  input,
@@ -158,7 +152,7 @@ function assertResultCount(results, count) {
158
152
  },
159
153
  async blake3Batch ({ inputs, dkLen }) {
160
154
  assertOutputLength(dkLen);
161
- for (const input of inputs)assertBytes(input);
155
+ for (const input of inputs)assertUnsharedBytes(input);
162
156
  if (inputs.length === 0) return [];
163
157
  const total = inputs.reduce((sum, input)=>sum + input.length, 0);
164
158
  if (total <= BLAKE3_SYNC_BATCH_BYTES) return inputs.map((input)=>binding.blake3({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokuin/crypto-napi",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Strict asynchronous crypto provider backed by the Rust core through Node-API, falling back to @kokuin/crypto-node",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,8 +20,8 @@
20
20
  "LICENSE"
21
21
  ],
22
22
  "dependencies": {
23
- "@kokuin/crypto": "^0.7.0",
24
- "@kokuin/crypto-node": "^0.7.0"
23
+ "@kokuin/crypto": "^0.7.1",
24
+ "@kokuin/crypto-node": "^0.7.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@kokuin/crypto-conformance": "^0.0.0",
@@ -31,14 +31,14 @@
31
31
  "@types/node": "^26.6.6"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@kokuin/crypto-napi-darwin-arm64": "0.7.3",
35
- "@kokuin/crypto-napi-darwin-x64": "0.7.3",
36
- "@kokuin/crypto-napi-linux-arm64-gnu": "0.7.3",
37
- "@kokuin/crypto-napi-linux-arm64-musl": "0.7.3",
38
- "@kokuin/crypto-napi-linux-x64-gnu": "0.7.3",
39
- "@kokuin/crypto-napi-linux-x64-musl": "0.7.3",
40
- "@kokuin/crypto-napi-win32-arm64-msvc": "0.7.3",
41
- "@kokuin/crypto-napi-win32-x64-msvc": "0.7.3"
34
+ "@kokuin/crypto-napi-darwin-arm64": "0.7.4",
35
+ "@kokuin/crypto-napi-darwin-x64": "0.7.4",
36
+ "@kokuin/crypto-napi-linux-arm64-gnu": "0.7.4",
37
+ "@kokuin/crypto-napi-linux-arm64-musl": "0.7.4",
38
+ "@kokuin/crypto-napi-linux-x64-gnu": "0.7.4",
39
+ "@kokuin/crypto-napi-linux-x64-musl": "0.7.4",
40
+ "@kokuin/crypto-napi-win32-arm64-msvc": "0.7.4",
41
+ "@kokuin/crypto-napi-win32-x64-msvc": "0.7.4"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=22"