@safekeylab/sdk 1.0.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/README.md +212 -0
- package/dist/index.d.mts +100 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +241 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +231 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrations/anthropic.d.mts +65 -0
- package/dist/integrations/anthropic.d.ts +65 -0
- package/dist/integrations/anthropic.js +347 -0
- package/dist/integrations/anthropic.js.map +1 -0
- package/dist/integrations/anthropic.mjs +341 -0
- package/dist/integrations/anthropic.mjs.map +1 -0
- package/dist/integrations/langchain.d.mts +106 -0
- package/dist/integrations/langchain.d.ts +106 -0
- package/dist/integrations/langchain.js +415 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/langchain.mjs +406 -0
- package/dist/integrations/langchain.mjs.map +1 -0
- package/dist/integrations/openai.d.mts +72 -0
- package/dist/integrations/openai.d.ts +72 -0
- package/dist/integrations/openai.js +327 -0
- package/dist/integrations/openai.js.map +1 -0
- package/dist/integrations/openai.mjs +321 -0
- package/dist/integrations/openai.mjs.map +1 -0
- package/dist/integrations/vercel-ai.d.mts +80 -0
- package/dist/integrations/vercel-ai.d.ts +80 -0
- package/dist/integrations/vercel-ai.js +377 -0
- package/dist/integrations/vercel-ai.js.map +1 -0
- package/dist/integrations/vercel-ai.mjs +371 -0
- package/dist/integrations/vercel-ai.mjs.map +1 -0
- package/dist/types-CtDYLaOX.d.mts +129 -0
- package/dist/types-CtDYLaOX.d.ts +129 -0
- package/package.json +106 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SafeKeyLab SDK Types
|
|
3
|
+
*/
|
|
4
|
+
interface SafeKeyLabConfig {
|
|
5
|
+
/** API key for authentication */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Base URL for the API (default: https://api.safekeylab.com) */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Enable debug logging (default: false) */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface PIIDetection {
|
|
15
|
+
/** Type of PII detected (EMAIL, PHONE, SSN, etc.) */
|
|
16
|
+
type: string;
|
|
17
|
+
/** The detected value */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Start position in text */
|
|
20
|
+
start: number;
|
|
21
|
+
/** End position in text */
|
|
22
|
+
end: number;
|
|
23
|
+
/** Confidence score (0-1) */
|
|
24
|
+
confidence: number;
|
|
25
|
+
}
|
|
26
|
+
interface DetectRequest {
|
|
27
|
+
/** Text to scan for PII */
|
|
28
|
+
text: string;
|
|
29
|
+
/** Types of PII to detect (default: all) */
|
|
30
|
+
types?: string[];
|
|
31
|
+
/** Minimum confidence threshold (default: 0.5) */
|
|
32
|
+
minConfidence?: number;
|
|
33
|
+
}
|
|
34
|
+
interface DetectResponse {
|
|
35
|
+
success: boolean;
|
|
36
|
+
detections: PIIDetection[];
|
|
37
|
+
count: number;
|
|
38
|
+
processing_time_ms: number;
|
|
39
|
+
}
|
|
40
|
+
interface ProtectRequest {
|
|
41
|
+
/** Text to redact PII from */
|
|
42
|
+
text: string;
|
|
43
|
+
/** Types of PII to redact (default: all) */
|
|
44
|
+
types?: string[];
|
|
45
|
+
/** Redaction style: 'placeholder' | 'mask' | 'hash' (default: placeholder) */
|
|
46
|
+
style?: 'placeholder' | 'mask' | 'hash';
|
|
47
|
+
}
|
|
48
|
+
interface Redaction {
|
|
49
|
+
type: string;
|
|
50
|
+
original: string;
|
|
51
|
+
start: number;
|
|
52
|
+
end: number;
|
|
53
|
+
}
|
|
54
|
+
interface ProtectResponse {
|
|
55
|
+
success: boolean;
|
|
56
|
+
redacted_text: string;
|
|
57
|
+
redactions: Redaction[];
|
|
58
|
+
redactions_count: number;
|
|
59
|
+
original_length: number;
|
|
60
|
+
redacted_length: number;
|
|
61
|
+
processing_time_ms: number;
|
|
62
|
+
}
|
|
63
|
+
interface ValidatePromptRequest {
|
|
64
|
+
/** Prompt to validate */
|
|
65
|
+
prompt: string;
|
|
66
|
+
/** Additional context for validation */
|
|
67
|
+
context?: string;
|
|
68
|
+
}
|
|
69
|
+
interface Threat {
|
|
70
|
+
type: string;
|
|
71
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
72
|
+
description: string;
|
|
73
|
+
matched?: string;
|
|
74
|
+
}
|
|
75
|
+
interface ValidatePromptResponse {
|
|
76
|
+
success: boolean;
|
|
77
|
+
is_safe: boolean;
|
|
78
|
+
threats: Threat[];
|
|
79
|
+
threats_detected: number;
|
|
80
|
+
recommendation: 'allow' | 'review' | 'block';
|
|
81
|
+
processing_time_ms: number;
|
|
82
|
+
}
|
|
83
|
+
interface ScanOutputRequest {
|
|
84
|
+
/** LLM output to scan */
|
|
85
|
+
output: string;
|
|
86
|
+
/** Original prompt for context */
|
|
87
|
+
prompt?: string;
|
|
88
|
+
}
|
|
89
|
+
interface ScanOutputResponse {
|
|
90
|
+
success: boolean;
|
|
91
|
+
is_safe: boolean;
|
|
92
|
+
issues: Array<{
|
|
93
|
+
type: string;
|
|
94
|
+
severity: string;
|
|
95
|
+
description: string;
|
|
96
|
+
}>;
|
|
97
|
+
processing_time_ms: number;
|
|
98
|
+
}
|
|
99
|
+
interface WrapperConfig {
|
|
100
|
+
/** Block requests containing PII (default: false, will redact instead) */
|
|
101
|
+
blockOnPII?: boolean;
|
|
102
|
+
/** Block requests with detected threats (default: true) */
|
|
103
|
+
blockOnThreat?: boolean;
|
|
104
|
+
/** Types of PII to detect/redact */
|
|
105
|
+
piiTypes?: string[];
|
|
106
|
+
/** Scan LLM outputs for issues (default: true) */
|
|
107
|
+
scanOutputs?: boolean;
|
|
108
|
+
/** Custom error handler */
|
|
109
|
+
onError?: (error: Error) => void;
|
|
110
|
+
/** Callback when PII is detected */
|
|
111
|
+
onPIIDetected?: (detections: PIIDetection[]) => void;
|
|
112
|
+
/** Callback when threat is detected */
|
|
113
|
+
onThreatDetected?: (threats: Threat[]) => void;
|
|
114
|
+
}
|
|
115
|
+
declare class SafeKeyLabError extends Error {
|
|
116
|
+
code: string;
|
|
117
|
+
statusCode?: number | undefined;
|
|
118
|
+
constructor(message: string, code: string, statusCode?: number | undefined);
|
|
119
|
+
}
|
|
120
|
+
declare class PIIBlockedError extends SafeKeyLabError {
|
|
121
|
+
detections: PIIDetection[];
|
|
122
|
+
constructor(detections: PIIDetection[]);
|
|
123
|
+
}
|
|
124
|
+
declare class ThreatBlockedError extends SafeKeyLabError {
|
|
125
|
+
threats: Threat[];
|
|
126
|
+
constructor(threats: Threat[]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { type DetectRequest as D, type ProtectRequest as P, type Redaction as R, type SafeKeyLabConfig as S, type Threat as T, type ValidatePromptRequest as V, type WrapperConfig as W, type DetectResponse as a, type ProtectResponse as b, type ValidatePromptResponse as c, type ScanOutputRequest as d, type ScanOutputResponse as e, type PIIDetection as f, SafeKeyLabError as g, PIIBlockedError as h, ThreatBlockedError as i };
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@safekeylab/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SafeKeyLab SDK - AI Security & PII Protection for JavaScript/TypeScript",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./openai": {
|
|
15
|
+
"require": "./dist/integrations/openai.js",
|
|
16
|
+
"import": "./dist/integrations/openai.mjs",
|
|
17
|
+
"types": "./dist/integrations/openai.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./anthropic": {
|
|
20
|
+
"require": "./dist/integrations/anthropic.js",
|
|
21
|
+
"import": "./dist/integrations/anthropic.mjs",
|
|
22
|
+
"types": "./dist/integrations/anthropic.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./langchain": {
|
|
25
|
+
"require": "./dist/integrations/langchain.js",
|
|
26
|
+
"import": "./dist/integrations/langchain.mjs",
|
|
27
|
+
"types": "./dist/integrations/langchain.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./vercel-ai": {
|
|
30
|
+
"require": "./dist/integrations/vercel-ai.js",
|
|
31
|
+
"import": "./dist/integrations/vercel-ai.mjs",
|
|
32
|
+
"types": "./dist/integrations/vercel-ai.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"test:coverage": "vitest --coverage",
|
|
44
|
+
"lint": "eslint src --ext .ts",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"safekeylab",
|
|
50
|
+
"pii",
|
|
51
|
+
"privacy",
|
|
52
|
+
"security",
|
|
53
|
+
"ai",
|
|
54
|
+
"llm",
|
|
55
|
+
"openai",
|
|
56
|
+
"anthropic",
|
|
57
|
+
"langchain",
|
|
58
|
+
"vercel-ai",
|
|
59
|
+
"data-protection",
|
|
60
|
+
"gdpr",
|
|
61
|
+
"hipaa",
|
|
62
|
+
"compliance"
|
|
63
|
+
],
|
|
64
|
+
"author": "SafeKey Lab Inc. <team@safekeylab.com>",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/safekeylab/javascript-sdk"
|
|
69
|
+
},
|
|
70
|
+
"homepage": "https://safekeylab.com",
|
|
71
|
+
"bugs": {
|
|
72
|
+
"url": "https://github.com/safekeylab/javascript-sdk/issues"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=16.0.0"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"openai": ">=4.0.0",
|
|
79
|
+
"@anthropic-ai/sdk": ">=0.9.0",
|
|
80
|
+
"langchain": ">=0.1.0",
|
|
81
|
+
"ai": ">=3.0.0"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"openai": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@anthropic-ai/sdk": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"langchain": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"ai": {
|
|
94
|
+
"optional": true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"devDependencies": {
|
|
98
|
+
"@types/node": "^20.10.0",
|
|
99
|
+
"tsup": "^8.0.1",
|
|
100
|
+
"typescript": "^5.3.0",
|
|
101
|
+
"vitest": "^1.0.0",
|
|
102
|
+
"eslint": "^8.55.0",
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
104
|
+
"@typescript-eslint/parser": "^6.13.0"
|
|
105
|
+
}
|
|
106
|
+
}
|