doc: update for latest changes
This commit is contained in:
parent
d9d2ec98db
commit
3b1792e613
2 changed files with 77 additions and 17 deletions
61
README.md
61
README.md
|
|
@ -81,8 +81,10 @@ console.log(response.choices[0].message.content);
|
|||
- **Automatic key loading**: Existing keys are loaded automatically from `client_keys/` directory (Node.js only)
|
||||
- **No manual intervention required**: The library handles key management automatically
|
||||
- **Optional persistence**: Keys can be saved to `client_keys/` directory for reuse across sessions (Node.js only)
|
||||
- **Password protection**: Optional password encryption for private keys (recommended for production)
|
||||
- **Password protection**: Optional password encryption for private keys (minimum 8 characters required)
|
||||
- **Secure permissions**: Private keys stored with restricted permissions (600 - owner-only access)
|
||||
- **Automatic key rotation**: Keys are rotated on a configurable interval (default: 24 hours) to limit fingerprint lifetime
|
||||
- **Explicit lifecycle management**: Call `dispose()` to immediately zero in-memory key material and stop the rotation timer
|
||||
|
||||
### Secure Memory Protection
|
||||
|
||||
|
|
@ -242,11 +244,38 @@ await client.loadKeys(
|
|||
);
|
||||
```
|
||||
|
||||
### Resource Management
|
||||
|
||||
Always call `dispose()` when finished to zero key material and stop the background rotation timer:
|
||||
|
||||
```javascript
|
||||
const client = new SecureChatCompletion({
|
||||
baseUrl: 'https://api.nomyo.ai:12434',
|
||||
keyRotationInterval: 3600000, // rotate every hour
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await client.create({ model: 'Qwen/Qwen3-0.6B', messages: [...] });
|
||||
console.log(response.choices[0].message.content);
|
||||
} finally {
|
||||
client.dispose();
|
||||
}
|
||||
```
|
||||
|
||||
To disable key rotation entirely (e.g. short-lived scripts):
|
||||
|
||||
```javascript
|
||||
const client = new SecureChatCompletion({
|
||||
baseUrl: 'https://api.nomyo.ai:12434',
|
||||
keyRotationInterval: 0, // disabled
|
||||
});
|
||||
```
|
||||
|
||||
## 🧪 Platform Support
|
||||
|
||||
### Node.js
|
||||
|
||||
- **Minimum version**: Node.js 15+ (for `crypto.webcrypto`)
|
||||
- **Minimum version**: Node.js 14.17+
|
||||
- **Recommended**: Node.js 18 LTS or later
|
||||
- **Key storage**: File system (`client_keys/` directory)
|
||||
- **Security**: Full implementation with automatic key persistence
|
||||
|
|
@ -269,10 +298,15 @@ await client.loadKeys(
|
|||
|
||||
```typescript
|
||||
new SecureChatCompletion(config?: {
|
||||
baseUrl?: string; // Default: 'https://api.nomyo.ai:12434'
|
||||
allowHttp?: boolean; // Default: false
|
||||
apiKey?: string; // Default: undefined
|
||||
secureMemory?: boolean; // Default: true
|
||||
baseUrl?: string; // Default: 'https://api.nomyo.ai:12434'
|
||||
allowHttp?: boolean; // Default: false
|
||||
apiKey?: string; // Default: undefined
|
||||
secureMemory?: boolean; // Default: true
|
||||
timeout?: number; // Request timeout ms. Default: 60000
|
||||
debug?: boolean; // Enable verbose logging. Default: false
|
||||
keyRotationInterval?: number; // Key rotation ms. 0 = disabled. Default: 86400000 (24h)
|
||||
keyRotationDir?: string; // Directory for rotated keys. Default: 'client_keys'
|
||||
keyRotationPassword?: string; // Password for rotated key files
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -280,6 +314,7 @@ new SecureChatCompletion(config?: {
|
|||
|
||||
- `create(request: ChatCompletionRequest): Promise<ChatCompletionResponse>`
|
||||
- `acreate(request: ChatCompletionRequest): Promise<ChatCompletionResponse>` (alias)
|
||||
- `dispose(): void` — zero key material and stop rotation timer
|
||||
|
||||
### SecureCompletionClient
|
||||
|
||||
|
|
@ -289,10 +324,15 @@ Lower-level API for advanced use cases.
|
|||
|
||||
```typescript
|
||||
new SecureCompletionClient(config?: {
|
||||
routerUrl?: string; // Default: 'https://api.nomyo.ai:12434'
|
||||
allowHttp?: boolean; // Default: false
|
||||
secureMemory?: boolean; // Default: true
|
||||
keySize?: 2048 | 4096; // Default: 4096
|
||||
routerUrl?: string; // Default: 'https://api.nomyo.ai:12434'
|
||||
allowHttp?: boolean; // Default: false
|
||||
secureMemory?: boolean; // Default: true
|
||||
keySize?: 2048 | 4096; // Default: 4096
|
||||
timeout?: number; // Request timeout ms. Default: 60000
|
||||
debug?: boolean; // Enable verbose logging. Default: false
|
||||
keyRotationInterval?: number; // Key rotation ms. 0 = disabled. Default: 86400000 (24h)
|
||||
keyRotationDir?: string; // Directory for rotated keys. Default: 'client_keys'
|
||||
keyRotationPassword?: string; // Password for rotated key files
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -304,6 +344,7 @@ new SecureCompletionClient(config?: {
|
|||
- `encryptPayload(payload: object): Promise<ArrayBuffer>`
|
||||
- `decryptResponse(encrypted: ArrayBuffer, payloadId: string): Promise<object>`
|
||||
- `sendSecureRequest(payload: object, payloadId: string, apiKey?: string): Promise<object>`
|
||||
- `dispose(): void` — zero key material and stop rotation timer
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue