@surbee/cipher 0.1.0 → 0.2.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 +95 -0
- package/dist/checks/index.d.mts +215 -0
- package/dist/checks/index.d.ts +215 -0
- package/dist/checks/index.js +1157 -0
- package/dist/checks/index.mjs +60 -0
- package/dist/chunk-P2MIOVFQ.mjs +1104 -0
- package/dist/index.d.mts +38 -244
- package/dist/index.d.ts +38 -244
- package/dist/index.js +1716 -35
- package/dist/index.mjs +649 -35
- package/dist/types-C8t_T3bP.d.mts +251 -0
- package/dist/types-C8t_T3bP.d.ts +251 -0
- package/package.json +16 -4
- package/src/checks/behavioral.ts +0 -527
- package/src/checks/content.ts +0 -372
- package/src/checks/device.ts +0 -384
- package/src/checks/index.ts +0 -59
- package/src/checks/timing.ts +0 -256
- package/src/cipher.ts +0 -225
- package/src/index.ts +0 -75
- package/src/tiers.ts +0 -507
- package/src/types.ts +0 -366
- package/test/cipher.test.ts +0 -245
- package/test/fixtures.ts +0 -627
- package/tsconfig.json +0 -20
package/dist/index.d.mts
CHANGED
|
@@ -1,241 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Core type definitions for the Cipher response validation system.
|
|
5
|
-
* Implementation details are hidden - the SDK communicates with Surbee's
|
|
6
|
-
* secure validation engine.
|
|
7
|
-
*/
|
|
8
|
-
type CipherTier = 1 | 2 | 3 | 4 | 5;
|
|
9
|
-
type CheckId = 'rapid_completion' | 'uniform_timing' | 'low_interaction' | 'straight_line_answers' | 'impossibly_fast' | 'minimal_effort' | 'excessive_paste' | 'pointer_spikes' | 'webdriver_detected' | 'automation_detected' | 'no_plugins' | 'suspicious_user_agent' | 'device_fingerprint_mismatch' | 'screen_anomaly' | 'suspicious_pauses' | 'robotic_typing' | 'mouse_teleporting' | 'no_corrections' | 'excessive_tab_switching' | 'window_focus_loss' | 'ai_content_basic' | 'contradiction_basic' | 'hover_behavior' | 'scroll_patterns' | 'mouse_acceleration' | 'vpn_detection' | 'datacenter_ip' | 'plagiarism_basic' | 'quality_assessment' | 'semantic_analysis' | 'ai_content_full' | 'contradiction_full' | 'plagiarism_full' | 'fraud_ring_detection' | 'answer_sharing' | 'coordinated_timing' | 'device_sharing' | 'tor_detection' | 'proxy_detection' | 'timezone_validation' | 'baseline_deviation' | 'perplexity_analysis' | 'burstiness_analysis';
|
|
10
|
-
interface CheckResult {
|
|
11
|
-
/** The check that was run */
|
|
12
|
-
checkId: CheckId;
|
|
13
|
-
/** Whether the check passed */
|
|
14
|
-
passed: boolean;
|
|
15
|
-
/** Suspicion score (0-1, higher = more suspicious) */
|
|
16
|
-
score: number;
|
|
17
|
-
/** Human-readable details */
|
|
18
|
-
details?: string;
|
|
19
|
-
}
|
|
20
|
-
interface ResponseInput {
|
|
21
|
-
/** The question text */
|
|
22
|
-
question: string;
|
|
23
|
-
/** The user's answer */
|
|
24
|
-
answer: string;
|
|
25
|
-
/** Question type for context */
|
|
26
|
-
questionType?: 'text' | 'multiple_choice' | 'rating' | 'scale' | 'boolean';
|
|
27
|
-
/** Time spent on this question in milliseconds */
|
|
28
|
-
responseTimeMs?: number;
|
|
29
|
-
/** Question index in the survey */
|
|
30
|
-
questionIndex?: number;
|
|
31
|
-
}
|
|
32
|
-
interface ValidationInput {
|
|
33
|
-
/** Array of question/answer pairs */
|
|
34
|
-
responses: ResponseInput[];
|
|
35
|
-
/** Behavioral metrics from client-side tracking */
|
|
36
|
-
behavioralMetrics?: BehavioralMetrics;
|
|
37
|
-
/** Device/browser information */
|
|
38
|
-
deviceInfo?: DeviceInfo;
|
|
39
|
-
/** Survey context */
|
|
40
|
-
context?: SurveyContext;
|
|
41
|
-
}
|
|
42
|
-
interface SurveyContext {
|
|
43
|
-
/** Survey ID for cross-respondent analysis */
|
|
44
|
-
surveyId?: string;
|
|
45
|
-
/** Expected completion time in seconds */
|
|
46
|
-
expectedDurationSeconds?: number;
|
|
47
|
-
/** Actual completion time in seconds */
|
|
48
|
-
actualDurationSeconds?: number;
|
|
49
|
-
/** Survey type for context-aware analysis */
|
|
50
|
-
surveyType?: 'nps' | 'csat' | 'research' | 'feedback' | 'quiz';
|
|
51
|
-
/** Total number of questions */
|
|
52
|
-
totalQuestions?: number;
|
|
53
|
-
}
|
|
54
|
-
interface BehavioralMetrics {
|
|
55
|
-
sessionId: string;
|
|
56
|
-
startedAt: number;
|
|
57
|
-
duration: number;
|
|
58
|
-
lastActiveAt: number;
|
|
59
|
-
mouseMovements: MouseMovement[];
|
|
60
|
-
mouseClicks: MouseClick[];
|
|
61
|
-
mouseMovementCount: number;
|
|
62
|
-
avgMouseVelocity: number;
|
|
63
|
-
keystrokeDynamics: KeystrokeEvent[];
|
|
64
|
-
keypressCount: number;
|
|
65
|
-
backspaceCount: number;
|
|
66
|
-
avgKeystrokeDwell: number;
|
|
67
|
-
keystrokeVariance: number;
|
|
68
|
-
scrollEvents: ScrollEvent[];
|
|
69
|
-
scrollEventCount: number;
|
|
70
|
-
focusEvents: FocusEvent[];
|
|
71
|
-
tabSwitchCount: number;
|
|
72
|
-
totalBlurDuration: number;
|
|
73
|
-
pasteEvents: number;
|
|
74
|
-
copyEvents: number;
|
|
75
|
-
hoverEvents: HoverEvent[];
|
|
76
|
-
responseTime: number[];
|
|
77
|
-
questionStartTimes: Record<string, number>;
|
|
78
|
-
}
|
|
79
|
-
interface MouseMovement {
|
|
80
|
-
x: number;
|
|
81
|
-
y: number;
|
|
82
|
-
t: number;
|
|
83
|
-
velocity: number;
|
|
84
|
-
}
|
|
85
|
-
interface MouseClick {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
t: number;
|
|
89
|
-
hadHover: boolean;
|
|
90
|
-
}
|
|
91
|
-
interface KeystrokeEvent {
|
|
92
|
-
key: string;
|
|
93
|
-
downAt: number;
|
|
94
|
-
upAt: number;
|
|
95
|
-
dwell: number;
|
|
96
|
-
flightTime: number;
|
|
97
|
-
}
|
|
98
|
-
interface ScrollEvent {
|
|
99
|
-
y: number;
|
|
100
|
-
t: number;
|
|
101
|
-
velocity: number;
|
|
102
|
-
}
|
|
103
|
-
interface FocusEvent {
|
|
104
|
-
type: 'focus' | 'blur' | 'hidden' | 'visible';
|
|
105
|
-
t: number;
|
|
106
|
-
}
|
|
107
|
-
interface HoverEvent {
|
|
108
|
-
element: string;
|
|
109
|
-
duration: number;
|
|
110
|
-
t: number;
|
|
111
|
-
}
|
|
112
|
-
interface DeviceInfo {
|
|
113
|
-
userAgent: string;
|
|
114
|
-
platform: string;
|
|
115
|
-
language: string;
|
|
116
|
-
languages: string[];
|
|
117
|
-
timezone: string;
|
|
118
|
-
timezoneOffset: number;
|
|
119
|
-
screenWidth: number;
|
|
120
|
-
screenHeight: number;
|
|
121
|
-
screenAvailWidth: number;
|
|
122
|
-
screenAvailHeight: number;
|
|
123
|
-
colorDepth: number;
|
|
124
|
-
pixelRatio: number;
|
|
125
|
-
touchSupport: boolean;
|
|
126
|
-
maxTouchPoints: number;
|
|
127
|
-
hardwareConcurrency: number;
|
|
128
|
-
deviceMemory: number;
|
|
129
|
-
cookiesEnabled: boolean;
|
|
130
|
-
webDriver: boolean;
|
|
131
|
-
automationDetected: boolean;
|
|
132
|
-
canvasFingerprint: string | null;
|
|
133
|
-
webglVendor: string | null;
|
|
134
|
-
webglRenderer: string | null;
|
|
135
|
-
pluginCount: number;
|
|
136
|
-
collectedAt: number;
|
|
137
|
-
}
|
|
138
|
-
interface ValidationResult {
|
|
139
|
-
/** Overall quality score (0-1, higher = better quality) */
|
|
140
|
-
score: number;
|
|
141
|
-
/** Whether the response passed validation */
|
|
142
|
-
passed: boolean;
|
|
143
|
-
/** Recommendation for the response */
|
|
144
|
-
recommendation: 'keep' | 'review' | 'discard';
|
|
145
|
-
/** Confidence in the assessment (0-1) */
|
|
146
|
-
confidence: number;
|
|
147
|
-
/** Flags that were triggered */
|
|
148
|
-
flags: string[];
|
|
149
|
-
/** Human-readable summary analysis */
|
|
150
|
-
summary: ValidationSummary;
|
|
151
|
-
/** Detailed check results */
|
|
152
|
-
checks: CheckResult[];
|
|
153
|
-
/** Processing metadata */
|
|
154
|
-
meta: ValidationMeta;
|
|
155
|
-
}
|
|
156
|
-
interface ValidationSummary {
|
|
157
|
-
/** Short verdict (e.g., "Likely legitimate", "Suspected bot") */
|
|
158
|
-
verdict: string;
|
|
159
|
-
/** List of issues found */
|
|
160
|
-
issues: string[];
|
|
161
|
-
/** List of positive signals */
|
|
162
|
-
positives: string[];
|
|
163
|
-
/** Actionable suggestion for the user */
|
|
164
|
-
suggestion: string;
|
|
165
|
-
}
|
|
166
|
-
interface ValidationMeta {
|
|
167
|
-
/** Tier used for validation */
|
|
168
|
-
tier: CipherTier;
|
|
169
|
-
/** Processing time in milliseconds */
|
|
170
|
-
processingTimeMs: number;
|
|
171
|
-
/** Number of checks run */
|
|
172
|
-
checksRun: number;
|
|
173
|
-
/** Number of checks passed */
|
|
174
|
-
checksPassed: number;
|
|
175
|
-
/** Request ID for support */
|
|
176
|
-
requestId: string;
|
|
177
|
-
/** Timestamp */
|
|
178
|
-
timestamp: number;
|
|
179
|
-
}
|
|
180
|
-
interface CipherConfig {
|
|
181
|
-
/**
|
|
182
|
-
* API key from Surbee dashboard (Settings > API Keys)
|
|
183
|
-
* Format: cipher_sk_...
|
|
184
|
-
*/
|
|
185
|
-
apiKey: string;
|
|
186
|
-
/**
|
|
187
|
-
* Validation tier (1-5)
|
|
188
|
-
* - Tier 1-2: Basic checks (~free)
|
|
189
|
-
* - Tier 3: Enhanced analysis
|
|
190
|
-
* - Tier 4: Advanced validation
|
|
191
|
-
* - Tier 5: Maximum accuracy
|
|
192
|
-
*/
|
|
193
|
-
tier?: CipherTier;
|
|
194
|
-
/** Custom thresholds */
|
|
195
|
-
thresholds?: {
|
|
196
|
-
/** Score below this = fail (default: 0.4) */
|
|
197
|
-
fail?: number;
|
|
198
|
-
/** Score below this = review (default: 0.7) */
|
|
199
|
-
review?: number;
|
|
200
|
-
};
|
|
201
|
-
/** Enable debug logging */
|
|
202
|
-
debug?: boolean;
|
|
203
|
-
/** Custom API endpoint (for enterprise/self-hosted) */
|
|
204
|
-
endpoint?: string;
|
|
205
|
-
}
|
|
206
|
-
interface BatchValidationInput {
|
|
207
|
-
submissions: ValidationInput[];
|
|
208
|
-
/** Enable cross-submission fraud detection (tier 5) */
|
|
209
|
-
crossAnalysis?: boolean;
|
|
210
|
-
}
|
|
211
|
-
interface BatchValidationResult {
|
|
212
|
-
results: ValidationResult[];
|
|
213
|
-
summary: {
|
|
214
|
-
total: number;
|
|
215
|
-
passed: number;
|
|
216
|
-
review: number;
|
|
217
|
-
failed: number;
|
|
218
|
-
avgScore: number;
|
|
219
|
-
};
|
|
220
|
-
/** Cross-submission fraud indicators (tier 5 only) */
|
|
221
|
-
fraudIndicators?: FraudIndicators;
|
|
222
|
-
}
|
|
223
|
-
interface FraudIndicators {
|
|
224
|
-
/** Response IDs with duplicate answers */
|
|
225
|
-
duplicateAnswers: string[];
|
|
226
|
-
/** Whether coordinated timing was detected */
|
|
227
|
-
coordinatedTiming: boolean;
|
|
228
|
-
/** Whether device sharing was detected */
|
|
229
|
-
deviceSharing: boolean;
|
|
230
|
-
/** Fraud ring score (0-1) */
|
|
231
|
-
fraudRingScore: number;
|
|
232
|
-
}
|
|
233
|
-
interface CipherError {
|
|
234
|
-
code: CipherErrorCode;
|
|
235
|
-
message: string;
|
|
236
|
-
details?: Record<string, unknown>;
|
|
237
|
-
}
|
|
238
|
-
type CipherErrorCode = 'INVALID_API_KEY' | 'RATE_LIMITED' | 'INSUFFICIENT_CREDITS' | 'INVALID_INPUT' | 'TIER_NOT_AVAILABLE' | 'SERVER_ERROR' | 'NETWORK_ERROR';
|
|
1
|
+
import { C as CipherConfig, V as ValidationInput, a as ValidationResult, B as BatchValidationInput, b as BatchValidationResult, c as CipherTier, d as CheckId } from './types-C8t_T3bP.mjs';
|
|
2
|
+
export { e as BehavioralMetrics, h as CheckResult, i as CipherError, j as CipherErrorCode, D as DeviceInfo, m as FocusEvent, F as FraudIndicators, H as HoverEvent, K as KeystrokeEvent, k as MouseClick, M as MouseMovement, R as ResponseInput, l as ScrollEvent, S as SurveyContext, g as ValidationMeta, f as ValidationSummary } from './types-C8t_T3bP.mjs';
|
|
239
3
|
|
|
240
4
|
/**
|
|
241
5
|
* Cipher - AI-powered survey response validation
|
|
@@ -256,31 +20,61 @@ type CipherErrorCode = 'INVALID_API_KEY' | 'RATE_LIMITED' | 'INSUFFICIENT_CREDIT
|
|
|
256
20
|
*/
|
|
257
21
|
declare class Cipher {
|
|
258
22
|
private config;
|
|
259
|
-
constructor(config
|
|
23
|
+
constructor(config?: CipherConfig);
|
|
260
24
|
/**
|
|
261
|
-
* Validate a single response
|
|
25
|
+
* Validate a single response.
|
|
26
|
+
*
|
|
27
|
+
* Runs locally when `offline: true`, otherwise calls Surbee's validation
|
|
28
|
+
* engine (which can run the AI-powered checks for tiers 3–5).
|
|
262
29
|
*/
|
|
263
30
|
validate(input: ValidationInput): Promise<ValidationResult>;
|
|
264
31
|
/**
|
|
265
|
-
* Validate
|
|
32
|
+
* Validate a single response synchronously, fully on-device.
|
|
33
|
+
*
|
|
34
|
+
* Only the offline checks for the configured tier are evaluated; AI-powered
|
|
35
|
+
* checks (tiers 3+) are skipped. No API key or network access required.
|
|
36
|
+
*/
|
|
37
|
+
validateSync(input: ValidationInput): ValidationResult;
|
|
38
|
+
/**
|
|
39
|
+
* Validate multiple responses in batch.
|
|
40
|
+
*
|
|
41
|
+
* Runs locally when `offline: true`, otherwise calls Surbee's batch endpoint.
|
|
266
42
|
*/
|
|
267
43
|
validateBatch(input: BatchValidationInput): Promise<BatchValidationResult>;
|
|
268
44
|
/**
|
|
269
|
-
*
|
|
45
|
+
* Run the offline checks that apply to the configured tier.
|
|
46
|
+
*/
|
|
47
|
+
private runOfflineChecks;
|
|
48
|
+
/**
|
|
49
|
+
* Estimate the per-response API cost for a number of responses at the
|
|
50
|
+
* configured tier (tiers 1–2 are free).
|
|
51
|
+
*/
|
|
52
|
+
estimateCost(responses?: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Get tier information, including the list of checks it runs.
|
|
270
55
|
*/
|
|
271
56
|
getTierInfo(tier?: CipherTier): {
|
|
57
|
+
tier: CipherTier;
|
|
272
58
|
name: string;
|
|
273
59
|
description: string;
|
|
60
|
+
checks: CheckId[];
|
|
274
61
|
checksCount: number;
|
|
62
|
+
aiModel: string | null;
|
|
63
|
+
offline: boolean;
|
|
64
|
+
estimatedCostPerResponse: number;
|
|
275
65
|
};
|
|
276
66
|
/**
|
|
277
67
|
* Get all available tiers
|
|
278
68
|
*/
|
|
279
69
|
getAllTiers(): {
|
|
70
|
+
tier: CipherTier;
|
|
280
71
|
name: string;
|
|
281
72
|
description: string;
|
|
73
|
+
checks: CheckId[];
|
|
282
74
|
checksCount: number;
|
|
283
|
-
|
|
75
|
+
aiModel: string | null;
|
|
76
|
+
offline: boolean;
|
|
77
|
+
estimatedCostPerResponse: number;
|
|
284
78
|
}[];
|
|
285
79
|
/**
|
|
286
80
|
* Check API key validity and credits
|
|
@@ -338,4 +132,4 @@ declare class Cipher {
|
|
|
338
132
|
|
|
339
133
|
declare const VERSION = "0.1.0";
|
|
340
134
|
|
|
341
|
-
export {
|
|
135
|
+
export { BatchValidationInput, BatchValidationResult, CheckId, Cipher, CipherConfig, CipherTier, VERSION, ValidationInput, ValidationResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,241 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Core type definitions for the Cipher response validation system.
|
|
5
|
-
* Implementation details are hidden - the SDK communicates with Surbee's
|
|
6
|
-
* secure validation engine.
|
|
7
|
-
*/
|
|
8
|
-
type CipherTier = 1 | 2 | 3 | 4 | 5;
|
|
9
|
-
type CheckId = 'rapid_completion' | 'uniform_timing' | 'low_interaction' | 'straight_line_answers' | 'impossibly_fast' | 'minimal_effort' | 'excessive_paste' | 'pointer_spikes' | 'webdriver_detected' | 'automation_detected' | 'no_plugins' | 'suspicious_user_agent' | 'device_fingerprint_mismatch' | 'screen_anomaly' | 'suspicious_pauses' | 'robotic_typing' | 'mouse_teleporting' | 'no_corrections' | 'excessive_tab_switching' | 'window_focus_loss' | 'ai_content_basic' | 'contradiction_basic' | 'hover_behavior' | 'scroll_patterns' | 'mouse_acceleration' | 'vpn_detection' | 'datacenter_ip' | 'plagiarism_basic' | 'quality_assessment' | 'semantic_analysis' | 'ai_content_full' | 'contradiction_full' | 'plagiarism_full' | 'fraud_ring_detection' | 'answer_sharing' | 'coordinated_timing' | 'device_sharing' | 'tor_detection' | 'proxy_detection' | 'timezone_validation' | 'baseline_deviation' | 'perplexity_analysis' | 'burstiness_analysis';
|
|
10
|
-
interface CheckResult {
|
|
11
|
-
/** The check that was run */
|
|
12
|
-
checkId: CheckId;
|
|
13
|
-
/** Whether the check passed */
|
|
14
|
-
passed: boolean;
|
|
15
|
-
/** Suspicion score (0-1, higher = more suspicious) */
|
|
16
|
-
score: number;
|
|
17
|
-
/** Human-readable details */
|
|
18
|
-
details?: string;
|
|
19
|
-
}
|
|
20
|
-
interface ResponseInput {
|
|
21
|
-
/** The question text */
|
|
22
|
-
question: string;
|
|
23
|
-
/** The user's answer */
|
|
24
|
-
answer: string;
|
|
25
|
-
/** Question type for context */
|
|
26
|
-
questionType?: 'text' | 'multiple_choice' | 'rating' | 'scale' | 'boolean';
|
|
27
|
-
/** Time spent on this question in milliseconds */
|
|
28
|
-
responseTimeMs?: number;
|
|
29
|
-
/** Question index in the survey */
|
|
30
|
-
questionIndex?: number;
|
|
31
|
-
}
|
|
32
|
-
interface ValidationInput {
|
|
33
|
-
/** Array of question/answer pairs */
|
|
34
|
-
responses: ResponseInput[];
|
|
35
|
-
/** Behavioral metrics from client-side tracking */
|
|
36
|
-
behavioralMetrics?: BehavioralMetrics;
|
|
37
|
-
/** Device/browser information */
|
|
38
|
-
deviceInfo?: DeviceInfo;
|
|
39
|
-
/** Survey context */
|
|
40
|
-
context?: SurveyContext;
|
|
41
|
-
}
|
|
42
|
-
interface SurveyContext {
|
|
43
|
-
/** Survey ID for cross-respondent analysis */
|
|
44
|
-
surveyId?: string;
|
|
45
|
-
/** Expected completion time in seconds */
|
|
46
|
-
expectedDurationSeconds?: number;
|
|
47
|
-
/** Actual completion time in seconds */
|
|
48
|
-
actualDurationSeconds?: number;
|
|
49
|
-
/** Survey type for context-aware analysis */
|
|
50
|
-
surveyType?: 'nps' | 'csat' | 'research' | 'feedback' | 'quiz';
|
|
51
|
-
/** Total number of questions */
|
|
52
|
-
totalQuestions?: number;
|
|
53
|
-
}
|
|
54
|
-
interface BehavioralMetrics {
|
|
55
|
-
sessionId: string;
|
|
56
|
-
startedAt: number;
|
|
57
|
-
duration: number;
|
|
58
|
-
lastActiveAt: number;
|
|
59
|
-
mouseMovements: MouseMovement[];
|
|
60
|
-
mouseClicks: MouseClick[];
|
|
61
|
-
mouseMovementCount: number;
|
|
62
|
-
avgMouseVelocity: number;
|
|
63
|
-
keystrokeDynamics: KeystrokeEvent[];
|
|
64
|
-
keypressCount: number;
|
|
65
|
-
backspaceCount: number;
|
|
66
|
-
avgKeystrokeDwell: number;
|
|
67
|
-
keystrokeVariance: number;
|
|
68
|
-
scrollEvents: ScrollEvent[];
|
|
69
|
-
scrollEventCount: number;
|
|
70
|
-
focusEvents: FocusEvent[];
|
|
71
|
-
tabSwitchCount: number;
|
|
72
|
-
totalBlurDuration: number;
|
|
73
|
-
pasteEvents: number;
|
|
74
|
-
copyEvents: number;
|
|
75
|
-
hoverEvents: HoverEvent[];
|
|
76
|
-
responseTime: number[];
|
|
77
|
-
questionStartTimes: Record<string, number>;
|
|
78
|
-
}
|
|
79
|
-
interface MouseMovement {
|
|
80
|
-
x: number;
|
|
81
|
-
y: number;
|
|
82
|
-
t: number;
|
|
83
|
-
velocity: number;
|
|
84
|
-
}
|
|
85
|
-
interface MouseClick {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
t: number;
|
|
89
|
-
hadHover: boolean;
|
|
90
|
-
}
|
|
91
|
-
interface KeystrokeEvent {
|
|
92
|
-
key: string;
|
|
93
|
-
downAt: number;
|
|
94
|
-
upAt: number;
|
|
95
|
-
dwell: number;
|
|
96
|
-
flightTime: number;
|
|
97
|
-
}
|
|
98
|
-
interface ScrollEvent {
|
|
99
|
-
y: number;
|
|
100
|
-
t: number;
|
|
101
|
-
velocity: number;
|
|
102
|
-
}
|
|
103
|
-
interface FocusEvent {
|
|
104
|
-
type: 'focus' | 'blur' | 'hidden' | 'visible';
|
|
105
|
-
t: number;
|
|
106
|
-
}
|
|
107
|
-
interface HoverEvent {
|
|
108
|
-
element: string;
|
|
109
|
-
duration: number;
|
|
110
|
-
t: number;
|
|
111
|
-
}
|
|
112
|
-
interface DeviceInfo {
|
|
113
|
-
userAgent: string;
|
|
114
|
-
platform: string;
|
|
115
|
-
language: string;
|
|
116
|
-
languages: string[];
|
|
117
|
-
timezone: string;
|
|
118
|
-
timezoneOffset: number;
|
|
119
|
-
screenWidth: number;
|
|
120
|
-
screenHeight: number;
|
|
121
|
-
screenAvailWidth: number;
|
|
122
|
-
screenAvailHeight: number;
|
|
123
|
-
colorDepth: number;
|
|
124
|
-
pixelRatio: number;
|
|
125
|
-
touchSupport: boolean;
|
|
126
|
-
maxTouchPoints: number;
|
|
127
|
-
hardwareConcurrency: number;
|
|
128
|
-
deviceMemory: number;
|
|
129
|
-
cookiesEnabled: boolean;
|
|
130
|
-
webDriver: boolean;
|
|
131
|
-
automationDetected: boolean;
|
|
132
|
-
canvasFingerprint: string | null;
|
|
133
|
-
webglVendor: string | null;
|
|
134
|
-
webglRenderer: string | null;
|
|
135
|
-
pluginCount: number;
|
|
136
|
-
collectedAt: number;
|
|
137
|
-
}
|
|
138
|
-
interface ValidationResult {
|
|
139
|
-
/** Overall quality score (0-1, higher = better quality) */
|
|
140
|
-
score: number;
|
|
141
|
-
/** Whether the response passed validation */
|
|
142
|
-
passed: boolean;
|
|
143
|
-
/** Recommendation for the response */
|
|
144
|
-
recommendation: 'keep' | 'review' | 'discard';
|
|
145
|
-
/** Confidence in the assessment (0-1) */
|
|
146
|
-
confidence: number;
|
|
147
|
-
/** Flags that were triggered */
|
|
148
|
-
flags: string[];
|
|
149
|
-
/** Human-readable summary analysis */
|
|
150
|
-
summary: ValidationSummary;
|
|
151
|
-
/** Detailed check results */
|
|
152
|
-
checks: CheckResult[];
|
|
153
|
-
/** Processing metadata */
|
|
154
|
-
meta: ValidationMeta;
|
|
155
|
-
}
|
|
156
|
-
interface ValidationSummary {
|
|
157
|
-
/** Short verdict (e.g., "Likely legitimate", "Suspected bot") */
|
|
158
|
-
verdict: string;
|
|
159
|
-
/** List of issues found */
|
|
160
|
-
issues: string[];
|
|
161
|
-
/** List of positive signals */
|
|
162
|
-
positives: string[];
|
|
163
|
-
/** Actionable suggestion for the user */
|
|
164
|
-
suggestion: string;
|
|
165
|
-
}
|
|
166
|
-
interface ValidationMeta {
|
|
167
|
-
/** Tier used for validation */
|
|
168
|
-
tier: CipherTier;
|
|
169
|
-
/** Processing time in milliseconds */
|
|
170
|
-
processingTimeMs: number;
|
|
171
|
-
/** Number of checks run */
|
|
172
|
-
checksRun: number;
|
|
173
|
-
/** Number of checks passed */
|
|
174
|
-
checksPassed: number;
|
|
175
|
-
/** Request ID for support */
|
|
176
|
-
requestId: string;
|
|
177
|
-
/** Timestamp */
|
|
178
|
-
timestamp: number;
|
|
179
|
-
}
|
|
180
|
-
interface CipherConfig {
|
|
181
|
-
/**
|
|
182
|
-
* API key from Surbee dashboard (Settings > API Keys)
|
|
183
|
-
* Format: cipher_sk_...
|
|
184
|
-
*/
|
|
185
|
-
apiKey: string;
|
|
186
|
-
/**
|
|
187
|
-
* Validation tier (1-5)
|
|
188
|
-
* - Tier 1-2: Basic checks (~free)
|
|
189
|
-
* - Tier 3: Enhanced analysis
|
|
190
|
-
* - Tier 4: Advanced validation
|
|
191
|
-
* - Tier 5: Maximum accuracy
|
|
192
|
-
*/
|
|
193
|
-
tier?: CipherTier;
|
|
194
|
-
/** Custom thresholds */
|
|
195
|
-
thresholds?: {
|
|
196
|
-
/** Score below this = fail (default: 0.4) */
|
|
197
|
-
fail?: number;
|
|
198
|
-
/** Score below this = review (default: 0.7) */
|
|
199
|
-
review?: number;
|
|
200
|
-
};
|
|
201
|
-
/** Enable debug logging */
|
|
202
|
-
debug?: boolean;
|
|
203
|
-
/** Custom API endpoint (for enterprise/self-hosted) */
|
|
204
|
-
endpoint?: string;
|
|
205
|
-
}
|
|
206
|
-
interface BatchValidationInput {
|
|
207
|
-
submissions: ValidationInput[];
|
|
208
|
-
/** Enable cross-submission fraud detection (tier 5) */
|
|
209
|
-
crossAnalysis?: boolean;
|
|
210
|
-
}
|
|
211
|
-
interface BatchValidationResult {
|
|
212
|
-
results: ValidationResult[];
|
|
213
|
-
summary: {
|
|
214
|
-
total: number;
|
|
215
|
-
passed: number;
|
|
216
|
-
review: number;
|
|
217
|
-
failed: number;
|
|
218
|
-
avgScore: number;
|
|
219
|
-
};
|
|
220
|
-
/** Cross-submission fraud indicators (tier 5 only) */
|
|
221
|
-
fraudIndicators?: FraudIndicators;
|
|
222
|
-
}
|
|
223
|
-
interface FraudIndicators {
|
|
224
|
-
/** Response IDs with duplicate answers */
|
|
225
|
-
duplicateAnswers: string[];
|
|
226
|
-
/** Whether coordinated timing was detected */
|
|
227
|
-
coordinatedTiming: boolean;
|
|
228
|
-
/** Whether device sharing was detected */
|
|
229
|
-
deviceSharing: boolean;
|
|
230
|
-
/** Fraud ring score (0-1) */
|
|
231
|
-
fraudRingScore: number;
|
|
232
|
-
}
|
|
233
|
-
interface CipherError {
|
|
234
|
-
code: CipherErrorCode;
|
|
235
|
-
message: string;
|
|
236
|
-
details?: Record<string, unknown>;
|
|
237
|
-
}
|
|
238
|
-
type CipherErrorCode = 'INVALID_API_KEY' | 'RATE_LIMITED' | 'INSUFFICIENT_CREDITS' | 'INVALID_INPUT' | 'TIER_NOT_AVAILABLE' | 'SERVER_ERROR' | 'NETWORK_ERROR';
|
|
1
|
+
import { C as CipherConfig, V as ValidationInput, a as ValidationResult, B as BatchValidationInput, b as BatchValidationResult, c as CipherTier, d as CheckId } from './types-C8t_T3bP.js';
|
|
2
|
+
export { e as BehavioralMetrics, h as CheckResult, i as CipherError, j as CipherErrorCode, D as DeviceInfo, m as FocusEvent, F as FraudIndicators, H as HoverEvent, K as KeystrokeEvent, k as MouseClick, M as MouseMovement, R as ResponseInput, l as ScrollEvent, S as SurveyContext, g as ValidationMeta, f as ValidationSummary } from './types-C8t_T3bP.js';
|
|
239
3
|
|
|
240
4
|
/**
|
|
241
5
|
* Cipher - AI-powered survey response validation
|
|
@@ -256,31 +20,61 @@ type CipherErrorCode = 'INVALID_API_KEY' | 'RATE_LIMITED' | 'INSUFFICIENT_CREDIT
|
|
|
256
20
|
*/
|
|
257
21
|
declare class Cipher {
|
|
258
22
|
private config;
|
|
259
|
-
constructor(config
|
|
23
|
+
constructor(config?: CipherConfig);
|
|
260
24
|
/**
|
|
261
|
-
* Validate a single response
|
|
25
|
+
* Validate a single response.
|
|
26
|
+
*
|
|
27
|
+
* Runs locally when `offline: true`, otherwise calls Surbee's validation
|
|
28
|
+
* engine (which can run the AI-powered checks for tiers 3–5).
|
|
262
29
|
*/
|
|
263
30
|
validate(input: ValidationInput): Promise<ValidationResult>;
|
|
264
31
|
/**
|
|
265
|
-
* Validate
|
|
32
|
+
* Validate a single response synchronously, fully on-device.
|
|
33
|
+
*
|
|
34
|
+
* Only the offline checks for the configured tier are evaluated; AI-powered
|
|
35
|
+
* checks (tiers 3+) are skipped. No API key or network access required.
|
|
36
|
+
*/
|
|
37
|
+
validateSync(input: ValidationInput): ValidationResult;
|
|
38
|
+
/**
|
|
39
|
+
* Validate multiple responses in batch.
|
|
40
|
+
*
|
|
41
|
+
* Runs locally when `offline: true`, otherwise calls Surbee's batch endpoint.
|
|
266
42
|
*/
|
|
267
43
|
validateBatch(input: BatchValidationInput): Promise<BatchValidationResult>;
|
|
268
44
|
/**
|
|
269
|
-
*
|
|
45
|
+
* Run the offline checks that apply to the configured tier.
|
|
46
|
+
*/
|
|
47
|
+
private runOfflineChecks;
|
|
48
|
+
/**
|
|
49
|
+
* Estimate the per-response API cost for a number of responses at the
|
|
50
|
+
* configured tier (tiers 1–2 are free).
|
|
51
|
+
*/
|
|
52
|
+
estimateCost(responses?: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Get tier information, including the list of checks it runs.
|
|
270
55
|
*/
|
|
271
56
|
getTierInfo(tier?: CipherTier): {
|
|
57
|
+
tier: CipherTier;
|
|
272
58
|
name: string;
|
|
273
59
|
description: string;
|
|
60
|
+
checks: CheckId[];
|
|
274
61
|
checksCount: number;
|
|
62
|
+
aiModel: string | null;
|
|
63
|
+
offline: boolean;
|
|
64
|
+
estimatedCostPerResponse: number;
|
|
275
65
|
};
|
|
276
66
|
/**
|
|
277
67
|
* Get all available tiers
|
|
278
68
|
*/
|
|
279
69
|
getAllTiers(): {
|
|
70
|
+
tier: CipherTier;
|
|
280
71
|
name: string;
|
|
281
72
|
description: string;
|
|
73
|
+
checks: CheckId[];
|
|
282
74
|
checksCount: number;
|
|
283
|
-
|
|
75
|
+
aiModel: string | null;
|
|
76
|
+
offline: boolean;
|
|
77
|
+
estimatedCostPerResponse: number;
|
|
284
78
|
}[];
|
|
285
79
|
/**
|
|
286
80
|
* Check API key validity and credits
|
|
@@ -338,4 +132,4 @@ declare class Cipher {
|
|
|
338
132
|
|
|
339
133
|
declare const VERSION = "0.1.0";
|
|
340
134
|
|
|
341
|
-
export {
|
|
135
|
+
export { BatchValidationInput, BatchValidationResult, CheckId, Cipher, CipherConfig, CipherTier, VERSION, ValidationInput, ValidationResult };
|