@wishknish/knishio-client-ts 0.9.0 → 0.9.1
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/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3292 -326
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/src/core/Wallet.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wishknish/knishio-client-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"productName": "Knish.IO TypeScript SDK Client",
|
|
5
5
|
"description": "TypeScript implementation of the Knish.IO SDK to consume Knish.IO GraphQL APIs with enhanced type safety.",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -72,17 +72,18 @@
|
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
74
74
|
"@types/jssha": "^3.0.0",
|
|
75
|
-
"@types/node": "^22
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
77
|
-
"@typescript-eslint/parser": "^8.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"vite
|
|
85
|
-
"
|
|
75
|
+
"@types/node": "^22",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.63.0",
|
|
77
|
+
"@typescript-eslint/parser": "^8.63.0",
|
|
78
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
79
|
+
"eslint": "^9",
|
|
80
|
+
"prettier": "^3",
|
|
81
|
+
"tsup": "^8.5.1",
|
|
82
|
+
"tsx": "^4.23.0",
|
|
83
|
+
"typescript": "^5",
|
|
84
|
+
"vite": "^7",
|
|
85
|
+
"vite-plugin-dts": "^5.0.3",
|
|
86
|
+
"vitest": "^4.1.10"
|
|
86
87
|
},
|
|
87
88
|
"browserslist": [
|
|
88
89
|
"> 1%",
|
package/src/core/Wallet.ts
CHANGED
|
@@ -437,6 +437,18 @@ export default class Wallet {
|
|
|
437
437
|
const messageString = JSON.stringify(message)
|
|
438
438
|
const messageUint8 = new TextEncoder().encode(messageString)
|
|
439
439
|
const deserializedPubkey = this.deserializeKey(recipientPubkey)
|
|
440
|
+
// ML-KEM-768 public keys are exactly 1184 bytes. A wrong-length key here almost always means the
|
|
441
|
+
// node did not advertise an ML-KEM public key in its auth `key` field (e.g. a validator predating
|
|
442
|
+
// the PQ-transport build). Fail with an actionable message rather than @noble's cryptic
|
|
443
|
+
// `"publicKey" expected Uint8Array of length 1184, got length=N` assertion.
|
|
444
|
+
const ML_KEM_768_PUBLIC_KEY_BYTES = 1184
|
|
445
|
+
if (deserializedPubkey.length !== ML_KEM_768_PUBLIC_KEY_BYTES) {
|
|
446
|
+
throw new Error(
|
|
447
|
+
`KnishIO: cannot ML-KEM-encrypt — recipient public key is ${deserializedPubkey.length} bytes, ` +
|
|
448
|
+
`expected ${ML_KEM_768_PUBLIC_KEY_BYTES} (ML-KEM-768). The node likely did not advertise an ML-KEM ` +
|
|
449
|
+
`public key (upgrade the validator to a PQ-transport build), or authenticate with { encrypt: false }.`
|
|
450
|
+
)
|
|
451
|
+
}
|
|
440
452
|
const { cipherText, sharedSecret } = ml_kem768.encapsulate(deserializedPubkey)
|
|
441
453
|
const encryptedMessage = await this.encryptWithSharedSecret(messageUint8, sharedSecret)
|
|
442
454
|
return {
|