@keverdjs/fraud-sdk-angular 1.0.0 → 2.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/dist/index.d.mts CHANGED
@@ -1,60 +1,217 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { ModuleWithProviders } from '@angular/core';
2
3
 
3
4
  /**
4
- * Types for Angular SDK
5
- * TODO: Copy and adapt types from React SDK
5
+ * Keverd Fraud SDK Angular - Type Definitions
6
6
  */
7
- interface KeverdConfig {
8
- apiKey: string;
9
- endpoint?: string;
10
- }
11
- interface KeverdLoadOptions {
12
- apiKey: string;
13
- endpoint?: string;
7
+ interface KeverdDeviceInfo {
8
+ deviceId: string;
9
+ fingerprint: string;
10
+ manufacturer?: string;
11
+ model?: string;
12
+ brand?: string;
13
+ device?: string;
14
+ product?: string;
15
+ hardware?: string;
16
+ sdkVersion?: string;
17
+ osVersion?: string;
18
+ screenWidth?: string;
19
+ screenHeight?: string;
20
+ screenDensity?: string;
21
+ locale?: string;
22
+ timezone: string;
14
23
  }
15
- interface KeverdVisitorData {
24
+ interface KeverdSessionInfo {
25
+ sessionId?: string;
26
+ installId?: string;
27
+ sessionCount?: string;
28
+ firstSession?: string;
29
+ timestamp?: string;
16
30
  }
17
- interface KeverdVisitorDataOptions {
31
+ interface KeverdBehavioralSequence {
32
+ featureNames: string[];
33
+ windowSize: number;
34
+ maskValue: number;
35
+ sequence: number[][];
18
36
  }
19
- interface KeverdVisitorDataResult {
37
+ interface KeverdBehavioralData {
38
+ typing_dwell_ms?: number[];
39
+ typing_flight_ms?: number[];
40
+ swipe_velocity?: number;
41
+ session_entropy?: number;
42
+ suspicious_swipe_velocity?: number;
43
+ behavioral_vectors?: KeverdBehavioralSequence;
20
44
  }
21
45
  interface KeverdFingerprintRequest {
46
+ userId?: string;
47
+ device: KeverdDeviceInfo;
48
+ session?: KeverdSessionInfo;
49
+ behavioral?: KeverdBehavioralData;
50
+ }
51
+ interface KeverdSimSwapEngine {
52
+ userId?: string;
53
+ risk: number;
54
+ flags: {
55
+ sim_changed?: boolean;
56
+ device_changed?: boolean;
57
+ behavior_anomaly?: boolean;
58
+ time_anomaly?: boolean;
59
+ velocity_anomaly?: boolean;
60
+ };
61
+ updatedProfile?: Record<string, unknown>;
22
62
  }
23
63
  interface KeverdFingerprintResponse {
64
+ risk_score: number;
65
+ score: number;
66
+ action: 'allow' | 'soft_challenge' | 'hard_challenge' | 'block';
67
+ reason: string[];
68
+ session_id: string;
69
+ requestId: string;
70
+ sim_swap_engine?: KeverdSimSwapEngine;
24
71
  }
25
- interface KeverdDeviceInfo {
72
+ interface KeverdPrivacySignals {
73
+ isIncognito?: boolean;
74
+ isVPN?: boolean;
75
+ isAutomated?: boolean;
76
+ hasAdBlocker?: boolean;
26
77
  }
27
- interface KeverdSessionInfo {
78
+ interface KeverdVisitorData {
79
+ visitorId: string;
80
+ riskScore: number;
81
+ score: number;
82
+ action: 'allow' | 'soft_challenge' | 'hard_challenge' | 'block';
83
+ reasons: string[];
84
+ sessionId: string;
85
+ requestId: string;
86
+ simSwapEngine?: KeverdSimSwapEngine;
87
+ confidence?: number;
88
+ fingerprintjsVisitorId?: string;
89
+ privacySignals?: KeverdPrivacySignals;
90
+ deviceMatch?: boolean;
91
+ fraudProbability?: number;
92
+ recommendedAction?: string;
28
93
  }
29
- interface KeverdBehavioralData {
94
+ interface KeverdConfig {
95
+ apiKey: string;
96
+ userId?: string;
97
+ debug?: boolean;
98
+ extendedResult?: boolean;
99
+ ignoreCache?: boolean;
100
+ }
101
+ interface KeverdLoadOptions {
102
+ apiKey: string;
103
+ debug?: boolean;
104
+ }
105
+ interface KeverdVisitorDataOptions {
106
+ extendedResult?: boolean;
107
+ ignoreCache?: boolean;
108
+ tag?: string;
30
109
  }
31
110
  interface KeverdError {
111
+ message: string;
112
+ code?: string;
113
+ statusCode?: number;
32
114
  }
33
115
 
34
116
  /**
35
117
  * Angular service for Keverd SDK
36
- * TODO: Implement Angular service
118
+ * Provides RxJS observables for reactive data access
119
+ * Wraps the web SDK to provide Angular-specific interface with all enhanced signals
37
120
  */
38
121
 
39
122
  declare class KeverdService {
40
123
  private config;
124
+ private isInitialized;
125
+ constructor(config?: KeverdConfig);
126
+ /**
127
+ * Initialize the SDK with configuration
128
+ * Wraps the web SDK initialization
129
+ */
41
130
  init(config: KeverdConfig): void;
131
+ /**
132
+ * Get visitor data (fingerprint and risk assessment)
133
+ * Returns an RxJS Observable
134
+ */
42
135
  getVisitorData(options?: KeverdVisitorDataOptions): Observable<KeverdVisitorData>;
136
+ /**
137
+ * Collect data and send fingerprint request
138
+ * Uses the web SDK which includes all enhanced signals including FingerprintJS
139
+ */
140
+ private collectAndSendFingerprint;
141
+ /**
142
+ * Transform API response to visitor data format
143
+ */
144
+ private transformResponse;
145
+ /**
146
+ * Generate a session ID
147
+ */
148
+ private generateSessionId;
149
+ /**
150
+ * Start a new session (called automatically on init, but can be called manually)
151
+ */
152
+ startSession(userId?: string, deviceHash?: string, metadata?: Record<string, unknown>): Observable<void>;
153
+ /**
154
+ * End the current session
155
+ */
156
+ endSession(): Observable<void>;
157
+ /**
158
+ * Pause the current session (e.g., when app goes to background)
159
+ */
160
+ pauseSession(): Observable<void>;
161
+ /**
162
+ * Resume a paused session (e.g., when app comes to foreground)
163
+ */
164
+ resumeSession(): Observable<void>;
165
+ /**
166
+ * Get current session status
167
+ */
168
+ getSessionStatus(): Observable<{
169
+ session_id: string;
170
+ status: string;
171
+ is_active: boolean;
172
+ is_paused: boolean;
173
+ event_count: number;
174
+ started_at: string;
175
+ last_activity_at: string;
176
+ duration_seconds: number | null;
177
+ } | null>;
178
+ /**
179
+ * Destroy the SDK instance
180
+ */
181
+ destroy(): void;
182
+ /**
183
+ * Get current configuration
184
+ */
185
+ getConfig(): KeverdConfig | null;
186
+ /**
187
+ * Check if SDK is initialized
188
+ */
189
+ isReady(): boolean;
43
190
  }
44
191
 
45
192
  /**
46
193
  * Angular module for Keverd SDK
47
- * TODO: Implement Angular module
194
+ * Provides module configuration for easy setup
48
195
  */
49
196
 
50
197
  declare class KeverdModule {
51
- static forRoot(config: any): {
52
- ngModule: typeof KeverdModule;
53
- providers: (typeof KeverdService | {
54
- provide: string;
55
- useValue: any;
56
- })[];
57
- };
198
+ /**
199
+ * Configure the module with SDK settings
200
+ * Call this in your app.module.ts imports array
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * @NgModule({
205
+ * imports: [
206
+ * KeverdModule.forRoot({
207
+ * apiKey: 'your-api-key',
208
+ * })
209
+ * ]
210
+ * })
211
+ * export class AppModule {}
212
+ * ```
213
+ */
214
+ static forRoot(config: KeverdConfig): ModuleWithProviders<KeverdModule>;
58
215
  }
59
216
 
60
- export { type KeverdBehavioralData, type KeverdConfig, type KeverdDeviceInfo, type KeverdError, type KeverdFingerprintRequest, type KeverdFingerprintResponse, type KeverdLoadOptions, KeverdModule, KeverdService, type KeverdSessionInfo, type KeverdVisitorData, type KeverdVisitorDataOptions, type KeverdVisitorDataResult };
217
+ export { type KeverdBehavioralData, type KeverdConfig, type KeverdDeviceInfo, type KeverdError, type KeverdFingerprintRequest, type KeverdFingerprintResponse, type KeverdLoadOptions, KeverdModule, KeverdService, type KeverdSessionInfo, type KeverdVisitorData, type KeverdVisitorDataOptions };
package/dist/index.d.ts CHANGED
@@ -1,60 +1,217 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { ModuleWithProviders } from '@angular/core';
2
3
 
3
4
  /**
4
- * Types for Angular SDK
5
- * TODO: Copy and adapt types from React SDK
5
+ * Keverd Fraud SDK Angular - Type Definitions
6
6
  */
7
- interface KeverdConfig {
8
- apiKey: string;
9
- endpoint?: string;
10
- }
11
- interface KeverdLoadOptions {
12
- apiKey: string;
13
- endpoint?: string;
7
+ interface KeverdDeviceInfo {
8
+ deviceId: string;
9
+ fingerprint: string;
10
+ manufacturer?: string;
11
+ model?: string;
12
+ brand?: string;
13
+ device?: string;
14
+ product?: string;
15
+ hardware?: string;
16
+ sdkVersion?: string;
17
+ osVersion?: string;
18
+ screenWidth?: string;
19
+ screenHeight?: string;
20
+ screenDensity?: string;
21
+ locale?: string;
22
+ timezone: string;
14
23
  }
15
- interface KeverdVisitorData {
24
+ interface KeverdSessionInfo {
25
+ sessionId?: string;
26
+ installId?: string;
27
+ sessionCount?: string;
28
+ firstSession?: string;
29
+ timestamp?: string;
16
30
  }
17
- interface KeverdVisitorDataOptions {
31
+ interface KeverdBehavioralSequence {
32
+ featureNames: string[];
33
+ windowSize: number;
34
+ maskValue: number;
35
+ sequence: number[][];
18
36
  }
19
- interface KeverdVisitorDataResult {
37
+ interface KeverdBehavioralData {
38
+ typing_dwell_ms?: number[];
39
+ typing_flight_ms?: number[];
40
+ swipe_velocity?: number;
41
+ session_entropy?: number;
42
+ suspicious_swipe_velocity?: number;
43
+ behavioral_vectors?: KeverdBehavioralSequence;
20
44
  }
21
45
  interface KeverdFingerprintRequest {
46
+ userId?: string;
47
+ device: KeverdDeviceInfo;
48
+ session?: KeverdSessionInfo;
49
+ behavioral?: KeverdBehavioralData;
50
+ }
51
+ interface KeverdSimSwapEngine {
52
+ userId?: string;
53
+ risk: number;
54
+ flags: {
55
+ sim_changed?: boolean;
56
+ device_changed?: boolean;
57
+ behavior_anomaly?: boolean;
58
+ time_anomaly?: boolean;
59
+ velocity_anomaly?: boolean;
60
+ };
61
+ updatedProfile?: Record<string, unknown>;
22
62
  }
23
63
  interface KeverdFingerprintResponse {
64
+ risk_score: number;
65
+ score: number;
66
+ action: 'allow' | 'soft_challenge' | 'hard_challenge' | 'block';
67
+ reason: string[];
68
+ session_id: string;
69
+ requestId: string;
70
+ sim_swap_engine?: KeverdSimSwapEngine;
24
71
  }
25
- interface KeverdDeviceInfo {
72
+ interface KeverdPrivacySignals {
73
+ isIncognito?: boolean;
74
+ isVPN?: boolean;
75
+ isAutomated?: boolean;
76
+ hasAdBlocker?: boolean;
26
77
  }
27
- interface KeverdSessionInfo {
78
+ interface KeverdVisitorData {
79
+ visitorId: string;
80
+ riskScore: number;
81
+ score: number;
82
+ action: 'allow' | 'soft_challenge' | 'hard_challenge' | 'block';
83
+ reasons: string[];
84
+ sessionId: string;
85
+ requestId: string;
86
+ simSwapEngine?: KeverdSimSwapEngine;
87
+ confidence?: number;
88
+ fingerprintjsVisitorId?: string;
89
+ privacySignals?: KeverdPrivacySignals;
90
+ deviceMatch?: boolean;
91
+ fraudProbability?: number;
92
+ recommendedAction?: string;
28
93
  }
29
- interface KeverdBehavioralData {
94
+ interface KeverdConfig {
95
+ apiKey: string;
96
+ userId?: string;
97
+ debug?: boolean;
98
+ extendedResult?: boolean;
99
+ ignoreCache?: boolean;
100
+ }
101
+ interface KeverdLoadOptions {
102
+ apiKey: string;
103
+ debug?: boolean;
104
+ }
105
+ interface KeverdVisitorDataOptions {
106
+ extendedResult?: boolean;
107
+ ignoreCache?: boolean;
108
+ tag?: string;
30
109
  }
31
110
  interface KeverdError {
111
+ message: string;
112
+ code?: string;
113
+ statusCode?: number;
32
114
  }
33
115
 
34
116
  /**
35
117
  * Angular service for Keverd SDK
36
- * TODO: Implement Angular service
118
+ * Provides RxJS observables for reactive data access
119
+ * Wraps the web SDK to provide Angular-specific interface with all enhanced signals
37
120
  */
38
121
 
39
122
  declare class KeverdService {
40
123
  private config;
124
+ private isInitialized;
125
+ constructor(config?: KeverdConfig);
126
+ /**
127
+ * Initialize the SDK with configuration
128
+ * Wraps the web SDK initialization
129
+ */
41
130
  init(config: KeverdConfig): void;
131
+ /**
132
+ * Get visitor data (fingerprint and risk assessment)
133
+ * Returns an RxJS Observable
134
+ */
42
135
  getVisitorData(options?: KeverdVisitorDataOptions): Observable<KeverdVisitorData>;
136
+ /**
137
+ * Collect data and send fingerprint request
138
+ * Uses the web SDK which includes all enhanced signals including FingerprintJS
139
+ */
140
+ private collectAndSendFingerprint;
141
+ /**
142
+ * Transform API response to visitor data format
143
+ */
144
+ private transformResponse;
145
+ /**
146
+ * Generate a session ID
147
+ */
148
+ private generateSessionId;
149
+ /**
150
+ * Start a new session (called automatically on init, but can be called manually)
151
+ */
152
+ startSession(userId?: string, deviceHash?: string, metadata?: Record<string, unknown>): Observable<void>;
153
+ /**
154
+ * End the current session
155
+ */
156
+ endSession(): Observable<void>;
157
+ /**
158
+ * Pause the current session (e.g., when app goes to background)
159
+ */
160
+ pauseSession(): Observable<void>;
161
+ /**
162
+ * Resume a paused session (e.g., when app comes to foreground)
163
+ */
164
+ resumeSession(): Observable<void>;
165
+ /**
166
+ * Get current session status
167
+ */
168
+ getSessionStatus(): Observable<{
169
+ session_id: string;
170
+ status: string;
171
+ is_active: boolean;
172
+ is_paused: boolean;
173
+ event_count: number;
174
+ started_at: string;
175
+ last_activity_at: string;
176
+ duration_seconds: number | null;
177
+ } | null>;
178
+ /**
179
+ * Destroy the SDK instance
180
+ */
181
+ destroy(): void;
182
+ /**
183
+ * Get current configuration
184
+ */
185
+ getConfig(): KeverdConfig | null;
186
+ /**
187
+ * Check if SDK is initialized
188
+ */
189
+ isReady(): boolean;
43
190
  }
44
191
 
45
192
  /**
46
193
  * Angular module for Keverd SDK
47
- * TODO: Implement Angular module
194
+ * Provides module configuration for easy setup
48
195
  */
49
196
 
50
197
  declare class KeverdModule {
51
- static forRoot(config: any): {
52
- ngModule: typeof KeverdModule;
53
- providers: (typeof KeverdService | {
54
- provide: string;
55
- useValue: any;
56
- })[];
57
- };
198
+ /**
199
+ * Configure the module with SDK settings
200
+ * Call this in your app.module.ts imports array
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * @NgModule({
205
+ * imports: [
206
+ * KeverdModule.forRoot({
207
+ * apiKey: 'your-api-key',
208
+ * })
209
+ * ]
210
+ * })
211
+ * export class AppModule {}
212
+ * ```
213
+ */
214
+ static forRoot(config: KeverdConfig): ModuleWithProviders<KeverdModule>;
58
215
  }
59
216
 
60
- export { type KeverdBehavioralData, type KeverdConfig, type KeverdDeviceInfo, type KeverdError, type KeverdFingerprintRequest, type KeverdFingerprintResponse, type KeverdLoadOptions, KeverdModule, KeverdService, type KeverdSessionInfo, type KeverdVisitorData, type KeverdVisitorDataOptions, type KeverdVisitorDataResult };
217
+ export { type KeverdBehavioralData, type KeverdConfig, type KeverdDeviceInfo, type KeverdError, type KeverdFingerprintRequest, type KeverdFingerprintResponse, type KeverdLoadOptions, KeverdModule, KeverdService, type KeverdSessionInfo, type KeverdVisitorData, type KeverdVisitorDataOptions };