fix:
Added DisposedError Wrapped zeroMemory() in its own try/catch in finally Generic error message; fixed ArrayBufferLike TypeScript type issue Generic error message; password/salt/IV wrapped in SecureByteContext Password ≥8 chars enforced; zeroKeys(); rotateKeys(); debug-gated logs; TS type fix Zero source ArrayBuffer after req.write() Added timeout, debug, keyRotationInterval, keyRotationDir, keyRotationPassword dispose(), assertNotDisposed(), startKeyRotationTimer(), rotateKeys(); Promise-mutex on ensureKeys(); new URL() validation; CR/LF API key check; server error detail truncation; response schema validation; all console.log behind debugMode Propagates new config fields; dispose() Tests for dispose, timer, header injection, URL validation, error sanitization, debug flag Tests for generic error messages, password validation, zeroKeys()
This commit is contained in:
parent
76703e2e3e
commit
d9d2ec98db
11 changed files with 582 additions and 129 deletions
|
|
@ -17,6 +17,11 @@ export class SecureChatCompletion {
|
|||
allowHttp = false,
|
||||
apiKey,
|
||||
secureMemory = true,
|
||||
timeout,
|
||||
debug,
|
||||
keyRotationInterval,
|
||||
keyRotationDir,
|
||||
keyRotationPassword,
|
||||
} = config;
|
||||
|
||||
this.apiKey = apiKey;
|
||||
|
|
@ -24,6 +29,11 @@ export class SecureChatCompletion {
|
|||
routerUrl: baseUrl,
|
||||
allowHttp,
|
||||
secureMemory,
|
||||
...(timeout !== undefined && { timeout }),
|
||||
...(debug !== undefined && { debug }),
|
||||
...(keyRotationInterval !== undefined && { keyRotationInterval }),
|
||||
...(keyRotationDir !== undefined && { keyRotationDir }),
|
||||
...(keyRotationPassword !== undefined && { keyRotationPassword }),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -68,4 +78,11 @@ export class SecureChatCompletion {
|
|||
async acreate(request: ChatCompletionRequest): Promise<ChatCompletionResponse> {
|
||||
return this.create(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release resources: stop key rotation timer and zero in-memory key material.
|
||||
*/
|
||||
dispose(): void {
|
||||
this.client.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue