# Installation ## Prerequisites - **Node.js**: 14.17 or higher (18 LTS recommended) - **npm** / **yarn** / **pnpm** - For TypeScript projects: TypeScript 4.7+ ## Install from npm ```bash npm install nomyo-js ``` ```bash yarn add nomyo-js ``` ```bash pnpm add nomyo-js ``` ## Browser (CDN) ```html ``` --- ## Verify Installation ### Node.js ```javascript import { SecureChatCompletion, getMemoryProtectionInfo } from 'nomyo-js'; const info = getMemoryProtectionInfo(); console.log('Memory protection:', info.method); // e.g. "zero-only" console.log('Can lock:', info.canLock); // true if native addon present const client = new SecureChatCompletion({ apiKey: 'test' }); console.log('nomyo-js installed successfully'); client.dispose(); ``` ### CommonJS ```javascript const { SecureChatCompletion } = require('nomyo-js'); ``` ## Optional: Native Memory Addon The pure-JS implementation zeroes buffers immediately after use but cannot prevent the OS from paging sensitive data to swap. The optional native addon adds `mlock`/`VirtualLock` support for true OS-level memory locking. ```bash cd node_modules/nomyo-js/native npm install npm run build ``` Or if you installed `nomyo-native` separately: ```bash npm install nomyo-native ``` When the addon is present `getMemoryProtectionInfo()` will report `method: 'mlock'` and `canLock: true`. ## TypeScript All public APIs ship with bundled type declarations — no `@types/` package required. ```typescript import { SecureChatCompletion, ChatCompletionRequest, ChatCompletionResponse, getMemoryProtectionInfo, } from 'nomyo-js'; ``` ## Environment Variables Store secrets outside source code: ```bash # .env (never commit this file) NOMYO_API_KEY=your-api-key NOMYO_SERVER_URL=https://api.nomyo.ai NOMYO_KEY_PASSWORD=your-key-password ``` ```javascript import 'dotenv/config'; // or use process.env directly import { SecureChatCompletion } from 'nomyo-js'; const client = new SecureChatCompletion({ baseUrl: process.env.NOMYO_SERVER_URL, apiKey: process.env.NOMYO_API_KEY, }); ```