2.2 KiB
2.2 KiB
Installation
Prerequisites
- Node.js: 14.17 or higher (18 LTS recommended)
- npm / yarn / pnpm
- For TypeScript projects: TypeScript 4.7+
Install from npm
npm install nomyo-js
yarn add nomyo-js
pnpm add nomyo-js
Browser (CDN)
<script type="module">
import { SecureChatCompletion } from 'https://unpkg.com/nomyo-js/dist/browser/index.js';
// ...
</script>
Verify Installation
Node.js
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
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.
cd node_modules/nomyo-js/native
npm install
npm run build
Or if you installed nomyo-native separately:
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.
import {
SecureChatCompletion,
ChatCompletionRequest,
ChatCompletionResponse,
getMemoryProtectionInfo,
} from 'nomyo-js';
Environment Variables
Store secrets outside source code:
# .env (never commit this file)
NOMYO_API_KEY=your-api-key
NOMYO_SERVER_URL=https://api.nomyo.ai
NOMYO_KEY_PASSWORD=your-key-password
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,
});