@vobs/captcha 1.1.0 → 1.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/dist/index.cjs +1240 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1235 -0
- package/dist/index.js.map +1 -0
- package/dist/slider.cjs +1239 -0
- package/dist/slider.cjs.map +1 -0
- package/dist/slider.d.cts +160 -0
- package/dist/slider.d.ts +160 -0
- package/dist/slider.js +1235 -0
- package/dist/slider.js.map +1 -0
- package/dist/styles/styles.css +437 -0
- package/package.json +21 -6
package/dist/slider.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Signal, VobsNode } from '@vobs/vobs';
|
|
2
|
+
|
|
3
|
+
type SliderShape = 'puzzle' | 'circle' | 'square' | 'triangle';
|
|
4
|
+
interface SliderCaptchaChallenge {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly payload: SliderCaptchaPayload;
|
|
7
|
+
readonly expiresAt: number;
|
|
8
|
+
}
|
|
9
|
+
interface SliderCaptchaPayload {
|
|
10
|
+
readonly image?: string;
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly height: number;
|
|
13
|
+
readonly startX?: number;
|
|
14
|
+
readonly targetX: number;
|
|
15
|
+
readonly targetY: number;
|
|
16
|
+
readonly rotation?: number;
|
|
17
|
+
readonly decoys?: readonly SliderCaptchaDecoy[];
|
|
18
|
+
readonly decoyX?: number;
|
|
19
|
+
readonly decoyY?: number;
|
|
20
|
+
readonly decoyRotation?: number;
|
|
21
|
+
readonly pieceWidth: number;
|
|
22
|
+
readonly pieceHeight: number;
|
|
23
|
+
readonly tolerance?: number;
|
|
24
|
+
readonly shape?: SliderShape;
|
|
25
|
+
}
|
|
26
|
+
interface SliderCaptchaDecoy {
|
|
27
|
+
readonly x: number;
|
|
28
|
+
readonly y: number;
|
|
29
|
+
readonly rotation?: number;
|
|
30
|
+
}
|
|
31
|
+
interface SliderTrailPoint {
|
|
32
|
+
readonly x: number;
|
|
33
|
+
readonly y: number;
|
|
34
|
+
readonly t: number;
|
|
35
|
+
}
|
|
36
|
+
interface SliderTrailAnalysis {
|
|
37
|
+
readonly pointCount: number;
|
|
38
|
+
readonly duration: number;
|
|
39
|
+
readonly distance: number;
|
|
40
|
+
readonly averageSpeed: number;
|
|
41
|
+
readonly maxSpeed: number;
|
|
42
|
+
readonly directionChanges: number;
|
|
43
|
+
readonly verticalTravel: number;
|
|
44
|
+
readonly averageInterval: number;
|
|
45
|
+
readonly looksHuman: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface CaptchaDeviceSignals {
|
|
48
|
+
readonly sessionId: string;
|
|
49
|
+
readonly userAgent?: string;
|
|
50
|
+
readonly platform?: string;
|
|
51
|
+
readonly language?: string;
|
|
52
|
+
readonly languages?: readonly string[];
|
|
53
|
+
readonly timezone?: string;
|
|
54
|
+
readonly screen?: {
|
|
55
|
+
readonly width: number;
|
|
56
|
+
readonly height: number;
|
|
57
|
+
readonly pixelRatio: number;
|
|
58
|
+
};
|
|
59
|
+
readonly viewport?: {
|
|
60
|
+
readonly width: number;
|
|
61
|
+
readonly height: number;
|
|
62
|
+
};
|
|
63
|
+
readonly touchPoints?: number;
|
|
64
|
+
readonly hardwareConcurrency?: number;
|
|
65
|
+
readonly deviceMemory?: number;
|
|
66
|
+
readonly webdriver?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface SliderCaptchaResult {
|
|
69
|
+
readonly x: number;
|
|
70
|
+
readonly y: number;
|
|
71
|
+
readonly trail: readonly SliderTrailPoint[];
|
|
72
|
+
readonly duration: number;
|
|
73
|
+
readonly analysis: SliderTrailAnalysis;
|
|
74
|
+
readonly deviceSignals?: CaptchaDeviceSignals;
|
|
75
|
+
}
|
|
76
|
+
interface SliderCaptchaProps {
|
|
77
|
+
readonly challenge?: SliderCaptchaValue<SliderCaptchaChallenge | null>;
|
|
78
|
+
readonly status?: SliderCaptchaValue<CaptchaStatus>;
|
|
79
|
+
readonly disabled?: SliderCaptchaValue<boolean>;
|
|
80
|
+
readonly collectDeviceSignals?: SliderCaptchaValue<boolean>;
|
|
81
|
+
readonly onSubmit?: (result: SliderCaptchaResult, challenge: SliderCaptchaChallenge) => void | PromiseLike<unknown>;
|
|
82
|
+
readonly onRetry?: () => void;
|
|
83
|
+
readonly onCancel?: () => void;
|
|
84
|
+
readonly retryLabel?: SliderCaptchaValue<string>;
|
|
85
|
+
readonly refreshingLabel?: SliderCaptchaValue<string>;
|
|
86
|
+
readonly retryIcon?: VobsNode | (() => VobsNode | null | undefined);
|
|
87
|
+
readonly cancelLabel?: SliderCaptchaValue<string>;
|
|
88
|
+
readonly loadingLabel?: SliderCaptchaValue<string>;
|
|
89
|
+
readonly emptyLabel?: SliderCaptchaValue<string>;
|
|
90
|
+
readonly expiredLabel?: SliderCaptchaValue<string>;
|
|
91
|
+
readonly error?: SliderCaptchaValue<unknown>;
|
|
92
|
+
readonly errorLabel?: SliderCaptchaValue<string>;
|
|
93
|
+
readonly label?: SliderCaptchaValue<string>;
|
|
94
|
+
readonly dragLabel?: SliderCaptchaValue<string>;
|
|
95
|
+
readonly successDuration?: SliderCaptchaValue<number>;
|
|
96
|
+
readonly onSuccessDismiss?: () => void;
|
|
97
|
+
readonly class?: SliderCaptchaValue<string>;
|
|
98
|
+
readonly className?: SliderCaptchaValue<string>;
|
|
99
|
+
readonly id?: SliderCaptchaValue<string>;
|
|
100
|
+
readonly title?: SliderCaptchaValue<string>;
|
|
101
|
+
readonly role?: SliderCaptchaValue<string>;
|
|
102
|
+
readonly [name: `aria-${string}`]: string | number | boolean | undefined;
|
|
103
|
+
readonly [name: `data-${string}`]: string | number | boolean | undefined;
|
|
104
|
+
}
|
|
105
|
+
type SliderCaptchaValue<T> = T | Signal<T> | (() => T);
|
|
106
|
+
declare function collectCaptchaDeviceSignals(): CaptchaDeviceSignals;
|
|
107
|
+
declare function SliderCaptcha(props?: SliderCaptchaProps): VobsNode;
|
|
108
|
+
declare function analyzeSliderTrail(trail: readonly SliderTrailPoint[]): SliderTrailAnalysis;
|
|
109
|
+
|
|
110
|
+
type CaptchaStatus = 'idle' | 'loading' | 'ready' | 'verifying' | 'verified' | 'expired' | 'error';
|
|
111
|
+
type CaptchaAnswer = string | Readonly<Record<string, unknown>> | null | undefined;
|
|
112
|
+
type CaptchaValue<T> = T | Signal<T> | (() => T);
|
|
113
|
+
interface CaptchaChallenge<T = unknown> {
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly type?: string;
|
|
116
|
+
readonly payload?: T;
|
|
117
|
+
readonly expiresAt: number;
|
|
118
|
+
}
|
|
119
|
+
interface CaptchaSubmitContext<Challenge = unknown> {
|
|
120
|
+
readonly challenge: CaptchaChallenge<Challenge>;
|
|
121
|
+
readonly status: CaptchaStatus;
|
|
122
|
+
readonly disabled: boolean;
|
|
123
|
+
submit(answer: CaptchaAnswer): void | PromiseLike<unknown>;
|
|
124
|
+
}
|
|
125
|
+
type CaptchaChallengeRenderer<Challenge = unknown> = (context: CaptchaSubmitContext<Challenge>) => VobsNode | null | undefined;
|
|
126
|
+
interface CaptchaProps<Challenge = unknown> {
|
|
127
|
+
readonly challenge?: CaptchaValue<CaptchaChallenge<Challenge> | null>;
|
|
128
|
+
readonly status?: CaptchaValue<CaptchaStatus>;
|
|
129
|
+
readonly error?: CaptchaValue<unknown>;
|
|
130
|
+
readonly disabled?: CaptchaValue<boolean>;
|
|
131
|
+
readonly renderChallenge?: CaptchaChallengeRenderer<Challenge>;
|
|
132
|
+
readonly onSubmit?: (answer: CaptchaAnswer, challenge: CaptchaChallenge<Challenge>) => void | PromiseLike<unknown>;
|
|
133
|
+
readonly onRetry?: () => void;
|
|
134
|
+
readonly onCancel?: () => void;
|
|
135
|
+
readonly retryLabel?: CaptchaValue<string>;
|
|
136
|
+
readonly cancelLabel?: CaptchaValue<string>;
|
|
137
|
+
readonly loadingLabel?: CaptchaValue<string>;
|
|
138
|
+
readonly emptyLabel?: CaptchaValue<string>;
|
|
139
|
+
readonly expiredLabel?: CaptchaValue<string>;
|
|
140
|
+
readonly errorLabel?: CaptchaValue<string>;
|
|
141
|
+
readonly label?: CaptchaValue<string>;
|
|
142
|
+
readonly messagePlacement?: 'challenge' | 'footer' | 'none';
|
|
143
|
+
readonly keepChallengeOnError?: boolean;
|
|
144
|
+
readonly keepChallengeOnLoading?: boolean;
|
|
145
|
+
readonly keepChallengeOnVerifying?: boolean;
|
|
146
|
+
readonly showRetry?: boolean;
|
|
147
|
+
readonly showRetryWhileLoading?: boolean;
|
|
148
|
+
readonly showCancel?: boolean;
|
|
149
|
+
readonly retryIcon?: VobsNode | (() => VobsNode | null | undefined);
|
|
150
|
+
readonly class?: CaptchaValue<string>;
|
|
151
|
+
readonly className?: CaptchaValue<string>;
|
|
152
|
+
readonly id?: CaptchaValue<string>;
|
|
153
|
+
readonly title?: CaptchaValue<string>;
|
|
154
|
+
readonly role?: CaptchaValue<string>;
|
|
155
|
+
readonly [name: `aria-${string}`]: string | number | boolean | undefined;
|
|
156
|
+
readonly [name: `data-${string}`]: string | number | boolean | undefined;
|
|
157
|
+
}
|
|
158
|
+
declare function Captcha<Challenge = unknown>(props?: CaptchaProps<Challenge>): VobsNode;
|
|
159
|
+
|
|
160
|
+
export { Captcha as C, type CaptchaDeviceSignals, SliderCaptcha, type SliderCaptchaChallenge, type SliderCaptchaDecoy, type SliderCaptchaPayload, type SliderCaptchaProps, type SliderCaptchaResult, type SliderCaptchaValue, type SliderShape, type SliderTrailAnalysis, type SliderTrailPoint, type CaptchaAnswer as a, analyzeSliderTrail, type CaptchaChallenge as b, type CaptchaChallengeRenderer as c, collectCaptchaDeviceSignals, type CaptchaProps as d, type CaptchaStatus as e, type CaptchaSubmitContext as f, type CaptchaValue as g };
|