From 84eae58317cae5d2639bf3f52aad75d05653c337 Mon Sep 17 00:00:00 2001 From: alpha nerd Date: Sun, 19 Jul 2026 10:59:28 +0200 Subject: [PATCH] fix: restore build and tests under TypeScript 6 The dependency bumps on main left `npm test` and `npm run build:types` broken independently of any feature work; both fail on a clean checkout of origin/main. TypeScript 6 no longer auto-includes @types packages the way node10 resolution did, so every test suite failed to compile with "Cannot find name 'describe'/'expect'". Declare the needed @types explicitly instead: - tsconfig.json: types: ["node"] - jest.config.js: types: ["jest", "node"] TypeScript 6 also errors on two settings this config relied on: - moduleResolution "node" (node10) is deprecated -> "bundler", which matches how the package is actually consumed (rollup-bundled, with "module": "ESNext") - an implicit rootDir is now an error when outDir/declarationDir are set -> rootDir: "./src" Drop three unused imports that noUnusedLocals turns into hard errors, failing --emitDeclarationOnly. Finally, NodeSecureMemory logged to stdout unconditionally on construction. This was dormant while the native addon failed to load; once it loads, it broke the "no console.log when debug=false" test. A library must not write to stdout uninvited, and the client already reports this via getProtectionInfo() behind its own debug flag. Co-Authored-By: Claude Opus 4.8 --- jest.config.js | 1 + src/core/crypto/encryption.ts | 2 +- src/core/crypto/rsa.ts | 2 +- src/core/memory/node.ts | 5 ++--- tsconfig.json | 6 +++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jest.config.js b/jest.config.js index eeacd80..dbf98bf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,6 +15,7 @@ module.exports = { skipLibCheck: true, moduleResolution: 'node', resolveJsonModule: true, + types: ['jest', 'node'], allowSyntheticDefaultImports: true, // Relax unused-var rules in tests noUnusedLocals: false, diff --git a/src/core/crypto/encryption.ts b/src/core/crypto/encryption.ts index f511e96..772fe02 100644 --- a/src/core/crypto/encryption.ts +++ b/src/core/crypto/encryption.ts @@ -3,7 +3,7 @@ * Matches the Python implementation using AES-256-GCM with random nonces */ -import { getCrypto, arrayBufferToBase64, base64ToArrayBuffer, generateRandomBytes } from './utils'; +import { getCrypto, generateRandomBytes } from './utils'; export class AESEncryption { private subtle: SubtleCrypto; diff --git a/src/core/crypto/rsa.ts b/src/core/crypto/rsa.ts index a4feb12..2b741bd 100644 --- a/src/core/crypto/rsa.ts +++ b/src/core/crypto/rsa.ts @@ -3,7 +3,7 @@ * Matches the Python implementation using RSA-OAEP with SHA-256 */ -import { getCrypto, pemToArrayBuffer, arrayBufferToPem, stringToArrayBuffer, arrayBufferToString, generateRandomBytes } from './utils'; +import { getCrypto, pemToArrayBuffer, arrayBufferToPem, stringToArrayBuffer, generateRandomBytes } from './utils'; import { SecureByteContext } from '../memory/secure'; export class RSAOperations { diff --git a/src/core/memory/node.ts b/src/core/memory/node.ts index d3a11df..bb20e4e 100644 --- a/src/core/memory/node.ts +++ b/src/core/memory/node.ts @@ -37,10 +37,9 @@ export class NodeSecureMemory implements SecureMemory { private readonly hasNative: boolean; constructor() { + // Deliberately silent: a library must not write to stdout on construction. + // Callers surface this via getProtectionInfo() under their own debug flag. this.hasNative = nativeAddon !== null; - if (this.hasNative) { - console.log('nomyo-native addon loaded: mlock + secure-zero available'); - } } /** diff --git a/tsconfig.json b/tsconfig.json index 562efd9..6360148 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,11 +9,15 @@ "declaration": true, "declarationDir": "./dist/types", "outDir": "./dist", + "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", + "moduleResolution": "bundler", + "types": [ + "node" + ], "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "noUnusedLocals": true,