@lockllm/sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +146 -5
- package/README.md +238 -39
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +46 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +104 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +100 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/scan.d.ts +20 -5
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +55 -5
- package/dist/scan.js.map +1 -1
- package/dist/scan.mjs +55 -5
- package/dist/types/common.d.ts +85 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/errors.d.ts +33 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/scan.d.ts +102 -3
- package/dist/types/scan.d.ts.map +1 -1
- package/dist/utils/proxy-headers.d.ts +24 -0
- package/dist/utils/proxy-headers.d.ts.map +1 -0
- package/dist/utils/proxy-headers.js +175 -0
- package/dist/utils/proxy-headers.js.map +1 -0
- package/dist/utils/proxy-headers.mjs +170 -0
- package/dist/utils.d.ts +24 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +27 -0
- package/dist/wrappers/anthropic-wrapper.d.ts +10 -1
- package/dist/wrappers/anthropic-wrapper.d.ts.map +1 -1
- package/dist/wrappers/anthropic-wrapper.js +17 -2
- package/dist/wrappers/anthropic-wrapper.js.map +1 -1
- package/dist/wrappers/anthropic-wrapper.mjs +17 -2
- package/dist/wrappers/generic-wrapper.d.ts +5 -0
- package/dist/wrappers/generic-wrapper.d.ts.map +1 -1
- package/dist/wrappers/generic-wrapper.js +12 -1
- package/dist/wrappers/generic-wrapper.js.map +1 -1
- package/dist/wrappers/generic-wrapper.mjs +12 -1
- package/dist/wrappers/openai-wrapper.d.ts +10 -1
- package/dist/wrappers/openai-wrapper.d.ts.map +1 -1
- package/dist/wrappers/openai-wrapper.js +17 -2
- package/dist/wrappers/openai-wrapper.js.map +1 -1
- package/dist/wrappers/openai-wrapper.mjs +17 -2
- package/package.json +2 -18
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* // With this:
|
|
15
15
|
* import { createOpenAI } from '@lockllm/sdk/wrappers';
|
|
16
16
|
* const openai = createOpenAI({
|
|
17
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
17
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
18
|
+
* proxyOptions: {
|
|
19
|
+
* scanMode: 'combined',
|
|
20
|
+
* scanAction: 'block'
|
|
21
|
+
* }
|
|
18
22
|
* });
|
|
19
23
|
*
|
|
20
24
|
* // Everything else stays the same!
|
|
@@ -27,6 +31,7 @@
|
|
|
27
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
32
|
exports.getOpenAIConstructor = getOpenAIConstructor;
|
|
29
33
|
exports.createOpenAI = createOpenAI;
|
|
34
|
+
const proxy_headers_1 = require("../utils/proxy-headers");
|
|
30
35
|
/**
|
|
31
36
|
* Create an OpenAI client that routes through LockLLM proxy
|
|
32
37
|
*
|
|
@@ -65,11 +70,21 @@ function getOpenAIConstructor(requireFn = require) {
|
|
|
65
70
|
function createOpenAI(config) {
|
|
66
71
|
// Get OpenAI SDK constructor
|
|
67
72
|
const OpenAIConstructor = getOpenAIConstructor();
|
|
68
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
73
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
74
|
+
// Build LockLLM headers from proxy options
|
|
75
|
+
const lockllmHeaders = (0, proxy_headers_1.buildLockLLMHeaders)(proxyOptions);
|
|
76
|
+
// Merge with existing headers
|
|
77
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
78
|
+
const mergedHeaders = {
|
|
79
|
+
...defaultHeaders,
|
|
80
|
+
...lockllmHeaders,
|
|
81
|
+
...(proxyOptions?.headers || {}),
|
|
82
|
+
};
|
|
69
83
|
// Create OpenAI client with LockLLM proxy
|
|
70
84
|
return new OpenAIConstructor({
|
|
71
85
|
apiKey,
|
|
72
86
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/openai',
|
|
87
|
+
defaultHeaders: mergedHeaders,
|
|
73
88
|
...otherOptions,
|
|
74
89
|
});
|
|
75
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"openai-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA0B7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAS,GAAG,OAAO;IACtD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;IAEjD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAElE,2CAA2C;IAC3C,MAAM,cAAc,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEzD,8BAA8B;IAC9B,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,EAAE,CAAC;IACzD,MAAM,aAAa,GAAG;QACpB,GAAG,cAAc;QACjB,GAAG,cAAc;QACjB,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC;KACjC,CAAC;IAEF,0CAA0C;IAC1C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,MAAM;QACN,OAAO,EAAE,OAAO,IAAI,yCAAyC;QAC7D,cAAc,EAAE,aAAa;QAC7B,GAAG,YAAY;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* // With this:
|
|
14
14
|
* import { createOpenAI } from '@lockllm/sdk/wrappers';
|
|
15
15
|
* const openai = createOpenAI({
|
|
16
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
16
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
17
|
+
* proxyOptions: {
|
|
18
|
+
* scanMode: 'combined',
|
|
19
|
+
* scanAction: 'block'
|
|
20
|
+
* }
|
|
17
21
|
* });
|
|
18
22
|
*
|
|
19
23
|
* // Everything else stays the same!
|
|
@@ -23,6 +27,7 @@
|
|
|
23
27
|
* });
|
|
24
28
|
* ```
|
|
25
29
|
*/
|
|
30
|
+
import { buildLockLLMHeaders } from '../utils/proxy-headers';
|
|
26
31
|
/**
|
|
27
32
|
* Create an OpenAI client that routes through LockLLM proxy
|
|
28
33
|
*
|
|
@@ -61,11 +66,21 @@ export function getOpenAIConstructor(requireFn = require) {
|
|
|
61
66
|
export function createOpenAI(config) {
|
|
62
67
|
// Get OpenAI SDK constructor
|
|
63
68
|
const OpenAIConstructor = getOpenAIConstructor();
|
|
64
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
69
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
70
|
+
// Build LockLLM headers from proxy options
|
|
71
|
+
const lockllmHeaders = buildLockLLMHeaders(proxyOptions);
|
|
72
|
+
// Merge with existing headers
|
|
73
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
74
|
+
const mergedHeaders = {
|
|
75
|
+
...defaultHeaders,
|
|
76
|
+
...lockllmHeaders,
|
|
77
|
+
...(proxyOptions?.headers || {}),
|
|
78
|
+
};
|
|
65
79
|
// Create OpenAI client with LockLLM proxy
|
|
66
80
|
return new OpenAIConstructor({
|
|
67
81
|
apiKey,
|
|
68
82
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/openai',
|
|
83
|
+
defaultHeaders: mergedHeaders,
|
|
69
84
|
...otherOptions,
|
|
70
85
|
});
|
|
71
86
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lockllm/sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Enterprise-grade AI security SDK providing real-time protection against prompt injection, jailbreaks, and adversarial attacks. Drop-in replacement for OpenAI, Anthropic, and
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Enterprise-grade AI security SDK providing real-time protection against prompt injection, jailbreaks, and adversarial attacks. Drop-in replacement for OpenAI, Anthropic, and 17+ providers with zero code changes. Includes REST API, proxy mode, browser extension, and webhook support. Free BYOK model with unlimited scanning.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -74,22 +74,6 @@
|
|
|
74
74
|
"url": "https://github.com/lockllm/lockllm-npm"
|
|
75
75
|
},
|
|
76
76
|
"homepage": "https://lockllm.com",
|
|
77
|
-
"peerDependencies": {
|
|
78
|
-
"@anthropic-ai/sdk": "^0.20.0",
|
|
79
|
-
"cohere-ai": "^7.0.0",
|
|
80
|
-
"openai": "^4.0.0"
|
|
81
|
-
},
|
|
82
|
-
"peerDependenciesMeta": {
|
|
83
|
-
"openai": {
|
|
84
|
-
"optional": true
|
|
85
|
-
},
|
|
86
|
-
"@anthropic-ai/sdk": {
|
|
87
|
-
"optional": true
|
|
88
|
-
},
|
|
89
|
-
"cohere-ai": {
|
|
90
|
-
"optional": true
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
77
|
"devDependencies": {
|
|
94
78
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
95
79
|
"@types/node": "^20.19.30",
|