cgs-compliance-sdk 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/README.md +278 -0
- package/dist/compliance/index.js +1478 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/index.mjs +1475 -0
- package/dist/compliance/index.mjs.map +1 -0
- package/dist/geolocation/index.js +784 -0
- package/dist/geolocation/index.js.map +1 -0
- package/dist/geolocation/index.mjs +777 -0
- package/dist/geolocation/index.mjs.map +1 -0
- package/dist/index.js +1810 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1790 -0
- package/dist/index.mjs.map +1 -0
- package/dist/risk-profile/index.js +548 -0
- package/dist/risk-profile/index.js.map +1 -0
- package/dist/risk-profile/index.mjs +546 -0
- package/dist/risk-profile/index.mjs.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/errors.ts
|
|
4
|
+
var CGSError = class _CGSError extends Error {
|
|
5
|
+
constructor(message, code, statusCode, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
this.details = details;
|
|
10
|
+
this.name = "CGSError";
|
|
11
|
+
Object.setPrototypeOf(this, _CGSError.prototype);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var NetworkError = class _NetworkError extends CGSError {
|
|
15
|
+
constructor(message, originalError) {
|
|
16
|
+
super(message, "NETWORK_ERROR", void 0, { originalError });
|
|
17
|
+
this.originalError = originalError;
|
|
18
|
+
this.name = "NetworkError";
|
|
19
|
+
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var ServiceUnavailableError = class _ServiceUnavailableError extends CGSError {
|
|
23
|
+
constructor(service) {
|
|
24
|
+
super(`${service} is unavailable`, "SERVICE_UNAVAILABLE", 503, { service });
|
|
25
|
+
this.name = "ServiceUnavailableError";
|
|
26
|
+
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var AuthenticationError = class _AuthenticationError extends CGSError {
|
|
30
|
+
constructor(message = "Authentication failed") {
|
|
31
|
+
super(message, "AUTHENTICATION_ERROR", 401);
|
|
32
|
+
this.name = "AuthenticationError";
|
|
33
|
+
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var RateLimitError = class _RateLimitError extends CGSError {
|
|
37
|
+
constructor(retryAfter) {
|
|
38
|
+
super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
|
|
39
|
+
this.retryAfter = retryAfter;
|
|
40
|
+
this.name = "RateLimitError";
|
|
41
|
+
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var TimeoutError = class _TimeoutError extends CGSError {
|
|
45
|
+
constructor(timeout) {
|
|
46
|
+
super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
|
|
47
|
+
this.timeout = timeout;
|
|
48
|
+
this.name = "TimeoutError";
|
|
49
|
+
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/core/client.ts
|
|
54
|
+
var BaseClient = class {
|
|
55
|
+
constructor(config) {
|
|
56
|
+
this.config = {
|
|
57
|
+
baseURL: config.baseURL,
|
|
58
|
+
tenantId: config.tenantId,
|
|
59
|
+
apiKey: config.apiKey || "",
|
|
60
|
+
headers: config.headers || {},
|
|
61
|
+
timeout: config.timeout || 1e4,
|
|
62
|
+
retries: config.retries || 3,
|
|
63
|
+
debug: config.debug || false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Make an HTTP request with timeout and error handling
|
|
68
|
+
*/
|
|
69
|
+
async request(endpoint, options = {}, serviceURL) {
|
|
70
|
+
const url = `${serviceURL || this.config.baseURL}${endpoint}`;
|
|
71
|
+
const headers = {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
"X-Tenant-ID": this.config.tenantId,
|
|
74
|
+
...this.config.headers,
|
|
75
|
+
...options.headers || {}
|
|
76
|
+
};
|
|
77
|
+
if (this.config.apiKey) {
|
|
78
|
+
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
79
|
+
}
|
|
80
|
+
const controller = new AbortController();
|
|
81
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
82
|
+
try {
|
|
83
|
+
if (this.config.debug) {
|
|
84
|
+
console.log(`[CGS SDK] ${options.method || "GET"} ${url}`, {
|
|
85
|
+
headers,
|
|
86
|
+
body: options.body
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const response = await fetch(url, {
|
|
90
|
+
...options,
|
|
91
|
+
headers,
|
|
92
|
+
signal: controller.signal
|
|
93
|
+
});
|
|
94
|
+
clearTimeout(timeoutId);
|
|
95
|
+
const data = await response.json();
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
this.handleErrorResponse(response.status, data);
|
|
98
|
+
}
|
|
99
|
+
if (this.config.debug) {
|
|
100
|
+
console.log(`[CGS SDK] Response:`, data);
|
|
101
|
+
}
|
|
102
|
+
return data;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
clearTimeout(timeoutId);
|
|
105
|
+
if (error instanceof Error) {
|
|
106
|
+
if (error.name === "AbortError") {
|
|
107
|
+
throw new TimeoutError(this.config.timeout);
|
|
108
|
+
}
|
|
109
|
+
if (error instanceof CGSError) {
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
throw new NetworkError("Network request failed", error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Make an HTTP request with retry logic
|
|
118
|
+
*/
|
|
119
|
+
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries) {
|
|
120
|
+
let lastError;
|
|
121
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
122
|
+
try {
|
|
123
|
+
return await this.request(endpoint, options, serviceURL);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
126
|
+
if (lastError instanceof CGSError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500) {
|
|
127
|
+
throw lastError;
|
|
128
|
+
}
|
|
129
|
+
if (attempt === retries) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
const delay = Math.min(1e3 * Math.pow(2, attempt) + Math.random() * 1e3, 1e4);
|
|
133
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
134
|
+
if (this.config.debug) {
|
|
135
|
+
console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
throw new NetworkError(`Request failed after ${retries} retries`, lastError);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handle error responses from API
|
|
143
|
+
*/
|
|
144
|
+
handleErrorResponse(status, data) {
|
|
145
|
+
const message = data.error || data.message || `HTTP ${status}`;
|
|
146
|
+
switch (status) {
|
|
147
|
+
case 400:
|
|
148
|
+
throw new CGSError(message, "BAD_REQUEST", 400, data);
|
|
149
|
+
case 401:
|
|
150
|
+
throw new AuthenticationError(message);
|
|
151
|
+
case 403:
|
|
152
|
+
throw new CGSError(message, "FORBIDDEN", 403, data);
|
|
153
|
+
case 404:
|
|
154
|
+
throw new CGSError(message, "NOT_FOUND", 404, data);
|
|
155
|
+
case 429:
|
|
156
|
+
const retryAfter = data.retry_after || data.retryAfter;
|
|
157
|
+
throw new RateLimitError(retryAfter);
|
|
158
|
+
case 500:
|
|
159
|
+
case 502:
|
|
160
|
+
case 503:
|
|
161
|
+
case 504:
|
|
162
|
+
throw new ServiceUnavailableError(message);
|
|
163
|
+
default:
|
|
164
|
+
throw new CGSError(message, "UNKNOWN_ERROR", status, data);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Build query string from parameters
|
|
169
|
+
*/
|
|
170
|
+
buildQueryString(params) {
|
|
171
|
+
const query = new URLSearchParams();
|
|
172
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
173
|
+
if (value !== void 0 && value !== null) {
|
|
174
|
+
if (Array.isArray(value)) {
|
|
175
|
+
value.forEach((item) => query.append(key, String(item)));
|
|
176
|
+
} else {
|
|
177
|
+
query.append(key, String(value));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
const queryString = query.toString();
|
|
182
|
+
return queryString ? `?${queryString}` : "";
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Update client configuration
|
|
186
|
+
*/
|
|
187
|
+
updateConfig(config) {
|
|
188
|
+
this.config = {
|
|
189
|
+
...this.config,
|
|
190
|
+
...config,
|
|
191
|
+
headers: {
|
|
192
|
+
...this.config.headers,
|
|
193
|
+
...config.headers || {}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get current configuration (readonly)
|
|
199
|
+
*/
|
|
200
|
+
getConfig() {
|
|
201
|
+
return { ...this.config };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Health check endpoint
|
|
205
|
+
*/
|
|
206
|
+
async healthCheck() {
|
|
207
|
+
return this.request("/api/v1/health");
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/risk-profile/client.ts
|
|
212
|
+
var RiskProfileClient = class extends BaseClient {
|
|
213
|
+
constructor(config) {
|
|
214
|
+
super(config);
|
|
215
|
+
}
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Profile Management
|
|
218
|
+
// ============================================================================
|
|
219
|
+
/**
|
|
220
|
+
* Create a new customer risk profile
|
|
221
|
+
*
|
|
222
|
+
* @param request - Profile creation data
|
|
223
|
+
* @returns Created customer profile
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const profile = await client.createProfile({
|
|
228
|
+
* customer_id: 'CUST-12345',
|
|
229
|
+
* entity_type: 'individual',
|
|
230
|
+
* customer_status: 'active',
|
|
231
|
+
* full_name: 'John Doe',
|
|
232
|
+
* email_address: 'john@example.com',
|
|
233
|
+
* date_of_birth: '1990-01-15',
|
|
234
|
+
* country_of_residence: 'US'
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
async createProfile(request) {
|
|
239
|
+
return this.request("/api/v1/profiles", {
|
|
240
|
+
method: "POST",
|
|
241
|
+
body: JSON.stringify(request)
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Get customer profile by customer ID
|
|
246
|
+
*
|
|
247
|
+
* Note: This searches for the profile using the customer_id field.
|
|
248
|
+
* Returns the first matching profile for the tenant.
|
|
249
|
+
*
|
|
250
|
+
* @param customerId - Customer ID to search for
|
|
251
|
+
* @returns Customer profile
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* const profile = await client.getProfile('CUST-12345');
|
|
256
|
+
* console.log('Risk score:', profile.risk_score);
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
async getProfile(customerId) {
|
|
260
|
+
const response = await this.queryProfiles({
|
|
261
|
+
search: customerId,
|
|
262
|
+
page: 1,
|
|
263
|
+
page_size: 1
|
|
264
|
+
});
|
|
265
|
+
if (response.data.length === 0) {
|
|
266
|
+
throw new Error(`Profile not found for customer ID: ${customerId}`);
|
|
267
|
+
}
|
|
268
|
+
return response.data[0];
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get profile by UUID
|
|
272
|
+
*
|
|
273
|
+
* @param profileId - Profile UUID
|
|
274
|
+
* @returns Customer profile
|
|
275
|
+
*/
|
|
276
|
+
async getProfileById(profileId) {
|
|
277
|
+
const details = await this.getProfileDetails(profileId);
|
|
278
|
+
return details.profile;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Get detailed profile information including risk factors and history
|
|
282
|
+
*
|
|
283
|
+
* @param profileId - Profile UUID
|
|
284
|
+
* @returns Detailed profile response with risk factors and history
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* const details = await client.getProfileDetails(profileId);
|
|
289
|
+
* console.log('Risk factors:', details.risk_factors);
|
|
290
|
+
* console.log('Risk history:', details.risk_history);
|
|
291
|
+
* console.log('Alert counts:', {
|
|
292
|
+
* watchlist: details.watchlist_alert_count,
|
|
293
|
+
* fraud: details.fraud_alert_count,
|
|
294
|
+
* geo: details.geolocation_alert_count
|
|
295
|
+
* });
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
async getProfileDetails(profileId) {
|
|
299
|
+
return this.request(
|
|
300
|
+
`/api/v1/risk-dashboard/profiles/${profileId}`
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Update customer profile
|
|
305
|
+
*
|
|
306
|
+
* @param profileId - Profile UUID
|
|
307
|
+
* @param updates - Fields to update
|
|
308
|
+
* @returns Updated customer profile
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const updated = await client.updateProfile(profileId, {
|
|
313
|
+
* location: 'New York, USA',
|
|
314
|
+
* location_compliance: 'compliant',
|
|
315
|
+
* last_recorded_activity: new Date().toISOString()
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
async updateProfile(profileId, updates) {
|
|
320
|
+
return this.request(`/api/v1/profiles/${profileId}`, {
|
|
321
|
+
method: "PUT",
|
|
322
|
+
body: JSON.stringify(updates)
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Manually recalculate risk score for a profile
|
|
327
|
+
*
|
|
328
|
+
* Triggers immediate risk score recalculation based on current risk factors.
|
|
329
|
+
*
|
|
330
|
+
* @param profileId - Profile UUID
|
|
331
|
+
* @param reason - Optional reason for recalculation
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* await client.recalculateRiskScore(profileId, 'Manual review completed');
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
async recalculateRiskScore(profileId, reason) {
|
|
339
|
+
const body = reason ? JSON.stringify({ reason }) : void 0;
|
|
340
|
+
await this.request(`/api/v1/profiles/recalculate/${profileId}`, {
|
|
341
|
+
method: "POST",
|
|
342
|
+
body
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
// ============================================================================
|
|
346
|
+
// Query & Search
|
|
347
|
+
// ============================================================================
|
|
348
|
+
/**
|
|
349
|
+
* Query profiles with advanced filters
|
|
350
|
+
*
|
|
351
|
+
* @param filters - Filter criteria and pagination
|
|
352
|
+
* @returns Paginated list of profiles
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```typescript
|
|
356
|
+
* const results = await client.queryProfiles({
|
|
357
|
+
* risk_category: ['high', 'critical'],
|
|
358
|
+
* kyc_status: ['pending'],
|
|
359
|
+
* is_pep: true,
|
|
360
|
+
* page: 1,
|
|
361
|
+
* page_size: 20,
|
|
362
|
+
* sort_by: 'risk_score',
|
|
363
|
+
* sort_order: 'desc'
|
|
364
|
+
* });
|
|
365
|
+
*
|
|
366
|
+
* console.log(`Found ${results.total} high-risk profiles`);
|
|
367
|
+
* results.data.forEach(profile => {
|
|
368
|
+
* console.log(`${profile.full_name}: ${profile.risk_score}`);
|
|
369
|
+
* });
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
async queryProfiles(filters = {}) {
|
|
373
|
+
const queryString = this.buildQueryString(filters);
|
|
374
|
+
return this.request(
|
|
375
|
+
`/api/v1/risk-dashboard/profiles${queryString}`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Search profiles by text (searches name, email, customer_id, account_number)
|
|
380
|
+
*
|
|
381
|
+
* @param searchText - Text to search for
|
|
382
|
+
* @param limit - Maximum results to return (default: 10)
|
|
383
|
+
* @returns Array of matching profiles
|
|
384
|
+
*/
|
|
385
|
+
async searchProfiles(searchText, limit = 10) {
|
|
386
|
+
const response = await this.queryProfiles({
|
|
387
|
+
search: searchText,
|
|
388
|
+
page: 1,
|
|
389
|
+
page_size: limit
|
|
390
|
+
});
|
|
391
|
+
return response.data;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Get all high-risk profiles (high + critical)
|
|
395
|
+
*
|
|
396
|
+
* @param limit - Maximum results to return (default: 50)
|
|
397
|
+
* @returns Array of high-risk profiles
|
|
398
|
+
*/
|
|
399
|
+
async getHighRiskProfiles(limit = 50) {
|
|
400
|
+
const response = await this.queryProfiles({
|
|
401
|
+
risk_category: ["high", "critical"],
|
|
402
|
+
page: 1,
|
|
403
|
+
page_size: limit,
|
|
404
|
+
sort_by: "risk_score",
|
|
405
|
+
sort_order: "desc"
|
|
406
|
+
});
|
|
407
|
+
return response.data;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Get profiles requiring PEP review
|
|
411
|
+
*
|
|
412
|
+
* @param limit - Maximum results to return (default: 50)
|
|
413
|
+
* @returns Array of PEP profiles
|
|
414
|
+
*/
|
|
415
|
+
async getPEPProfiles(limit = 50) {
|
|
416
|
+
const response = await this.queryProfiles({
|
|
417
|
+
is_pep: true,
|
|
418
|
+
page: 1,
|
|
419
|
+
page_size: limit
|
|
420
|
+
});
|
|
421
|
+
return response.data;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Get profiles with sanctions matches
|
|
425
|
+
*
|
|
426
|
+
* @param limit - Maximum results to return (default: 50)
|
|
427
|
+
* @returns Array of sanctioned profiles
|
|
428
|
+
*/
|
|
429
|
+
async getSanctionedProfiles(limit = 50) {
|
|
430
|
+
const response = await this.queryProfiles({
|
|
431
|
+
has_sanctions: true,
|
|
432
|
+
page: 1,
|
|
433
|
+
page_size: limit
|
|
434
|
+
});
|
|
435
|
+
return response.data;
|
|
436
|
+
}
|
|
437
|
+
// ============================================================================
|
|
438
|
+
// Dashboard & Metrics
|
|
439
|
+
// ============================================================================
|
|
440
|
+
/**
|
|
441
|
+
* Get risk dashboard metrics and statistics
|
|
442
|
+
*
|
|
443
|
+
* @param startDate - Optional start date for metrics (ISO format)
|
|
444
|
+
* @param endDate - Optional end date for metrics (ISO format)
|
|
445
|
+
* @returns Dashboard metrics
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const metrics = await client.getDashboardMetrics();
|
|
450
|
+
* console.log('Total risky profiles:', metrics.total_risky_profiles);
|
|
451
|
+
* console.log('Critical profiles:', metrics.total_critical_profiles);
|
|
452
|
+
* console.log('Average risk score:', metrics.average_risk_score);
|
|
453
|
+
*
|
|
454
|
+
* metrics.risk_distribution.forEach(item => {
|
|
455
|
+
* console.log(`${item.category}: ${item.count} (${item.percentage}%)`);
|
|
456
|
+
* });
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
async getDashboardMetrics(startDate, endDate) {
|
|
460
|
+
const params = {};
|
|
461
|
+
if (startDate) params.start_date = startDate;
|
|
462
|
+
if (endDate) params.end_date = endDate;
|
|
463
|
+
const queryString = this.buildQueryString(params);
|
|
464
|
+
return this.request(
|
|
465
|
+
`/api/v1/risk-dashboard/metrics${queryString}`
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
// ============================================================================
|
|
469
|
+
// Bulk Operations
|
|
470
|
+
// ============================================================================
|
|
471
|
+
/**
|
|
472
|
+
* Get or create profile (idempotent operation)
|
|
473
|
+
*
|
|
474
|
+
* Attempts to get existing profile by customer_id, creates if not found.
|
|
475
|
+
*
|
|
476
|
+
* @param customerId - Customer ID
|
|
477
|
+
* @param createRequest - Profile data to use if creating new profile
|
|
478
|
+
* @returns Existing or newly created profile
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```typescript
|
|
482
|
+
* const profile = await client.getOrCreateProfile('CUST-123', {
|
|
483
|
+
* customer_id: 'CUST-123',
|
|
484
|
+
* entity_type: 'individual',
|
|
485
|
+
* full_name: 'John Doe',
|
|
486
|
+
* email_address: 'john@example.com'
|
|
487
|
+
* });
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
async getOrCreateProfile(customerId, createRequest) {
|
|
491
|
+
try {
|
|
492
|
+
return await this.getProfile(customerId);
|
|
493
|
+
} catch (error) {
|
|
494
|
+
return await this.createProfile(createRequest);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Batch get profiles by customer IDs
|
|
499
|
+
*
|
|
500
|
+
* @param customerIds - Array of customer IDs
|
|
501
|
+
* @returns Array of profiles (may be less than input if some not found)
|
|
502
|
+
*/
|
|
503
|
+
async batchGetProfiles(customerIds) {
|
|
504
|
+
const profiles = [];
|
|
505
|
+
for (const customerId of customerIds) {
|
|
506
|
+
try {
|
|
507
|
+
const profile = await this.getProfile(customerId);
|
|
508
|
+
profiles.push(profile);
|
|
509
|
+
} catch (error) {
|
|
510
|
+
if (this.config.debug) {
|
|
511
|
+
console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return profiles;
|
|
516
|
+
}
|
|
517
|
+
// ============================================================================
|
|
518
|
+
// Configuration
|
|
519
|
+
// ============================================================================
|
|
520
|
+
/**
|
|
521
|
+
* Get risk configuration for tenant
|
|
522
|
+
*
|
|
523
|
+
* Returns the risk scoring weights and thresholds configured for the tenant.
|
|
524
|
+
*
|
|
525
|
+
* @returns Risk configuration
|
|
526
|
+
*/
|
|
527
|
+
async getRiskConfiguration() {
|
|
528
|
+
return this.request("/api/v1/risk-config");
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Update risk configuration for tenant
|
|
532
|
+
*
|
|
533
|
+
* Updates risk scoring weights and/or thresholds.
|
|
534
|
+
*
|
|
535
|
+
* @param config - Configuration updates
|
|
536
|
+
* @returns Updated risk configuration
|
|
537
|
+
*/
|
|
538
|
+
async updateRiskConfiguration(config) {
|
|
539
|
+
return this.request("/api/v1/risk-config", {
|
|
540
|
+
method: "PUT",
|
|
541
|
+
body: JSON.stringify(config)
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
exports.RiskProfileClient = RiskProfileClient;
|
|
547
|
+
//# sourceMappingURL=index.js.map
|
|
548
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts","../../src/risk-profile/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EAClC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF,CAAA;AAEO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,QAAA,CAAS;AAAA,EACzC,WAAA,CAAY,SAAwB,aAAA,EAAyB;AAC3D,IAAA,KAAA,CAAM,OAAA,EAAS,eAAA,EAAiB,MAAA,EAAW,EAAE,eAAe,CAAA;AAD1B,IAAA,IAA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QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,MACvB,SAAS,KAAA,EAAO;AAEd,QAAA,IAAI,IAAA,CAAK,OAAO,KAAA,EAAO;AACrB,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,2CAAA,EAA8C,UAAU,CAAA,CAAE,CAAA;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,oBAAA,GAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAqB,CAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,wBACJ,MAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAA,EAAuB;AAAA,MAC5D,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAM;AAAA,KAC5B,CAAA;AAAA,EACH;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy for CGS SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class CGSError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'CGSError';\n Object.setPrototypeOf(this, CGSError.prototype);\n }\n}\n\nexport class NetworkError extends CGSError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR', undefined, { originalError });\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends CGSError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends CGSError {\n constructor(service: string) {\n super(`${service} is unavailable`, 'SERVICE_UNAVAILABLE', 503, { service });\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends CGSError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends CGSError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends CGSError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends CGSError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends CGSError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code, undefined, { originalError });\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n","/**\n * Base HTTP client for all CGS SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, RequiredBaseClientConfig } from './config';\nimport {\n CGSError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n} from './errors';\n\nexport abstract class BaseClient {\n protected config: RequiredBaseClientConfig;\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey || '',\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n };\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string\n ): Promise<T> {\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n if (this.config.debug) {\n console.log(`[CGS SDK] ${options.method || 'GET'} ${url}`, {\n headers,\n body: options.body,\n });\n }\n\n const response = await fetch(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const data = await response.json();\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data);\n }\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Response:`, data);\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new TimeoutError(this.config.timeout);\n }\n if (error instanceof CGSError) {\n throw error;\n }\n }\n\n throw new NetworkError('Network request failed', error);\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on client errors (4xx) or authentication errors\n if (\n lastError instanceof CGSError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Exponential backoff with jitter\n const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: any): never {\n const message = data.error || data.message || `HTTP ${status}`;\n\n switch (status) {\n case 400:\n throw new CGSError(message, 'BAD_REQUEST', 400, data);\n case 401:\n throw new AuthenticationError(message);\n case 403:\n throw new CGSError(message, 'FORBIDDEN', 403, data);\n case 404:\n throw new CGSError(message, 'NOT_FOUND', 404, data);\n case 429:\n const retryAfter = data.retry_after || data.retryAfter;\n throw new RateLimitError(retryAfter);\n case 500:\n case 502:\n case 503:\n case 504:\n throw new ServiceUnavailableError(message);\n default:\n throw new CGSError(message, 'UNKNOWN_ERROR', status, data);\n }\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","/**\n * RiskProfileClient - Customer Risk Profile Management\n *\n * Provides methods to create, retrieve, and manage customer risk profiles\n * in the CGS Compliance Platform.\n */\n\nimport { BaseClient } from '../core/client';\nimport type { BaseClientConfig } from '../core/config';\nimport type {\n CustomerProfile,\n CreateProfileRequest,\n UpdateProfileRequest,\n ProfileDetailsResponse,\n ProfileFilters,\n ProfileListResponse,\n RiskDashboardMetrics,\n RiskConfiguration,\n} from './types';\n\nexport class RiskProfileClient extends BaseClient {\n constructor(config: BaseClientConfig) {\n super(config);\n }\n\n // ============================================================================\n // Profile Management\n // ============================================================================\n\n /**\n * Create a new customer risk profile\n *\n * @param request - Profile creation data\n * @returns Created customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.createProfile({\n * customer_id: 'CUST-12345',\n * entity_type: 'individual',\n * customer_status: 'active',\n * full_name: 'John Doe',\n * email_address: 'john@example.com',\n * date_of_birth: '1990-01-15',\n * country_of_residence: 'US'\n * });\n * ```\n */\n async createProfile(request: CreateProfileRequest): Promise<CustomerProfile> {\n return this.request<CustomerProfile>('/api/v1/profiles', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * Get customer profile by customer ID\n *\n * Note: This searches for the profile using the customer_id field.\n * Returns the first matching profile for the tenant.\n *\n * @param customerId - Customer ID to search for\n * @returns Customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.getProfile('CUST-12345');\n * console.log('Risk score:', profile.risk_score);\n * ```\n */\n async getProfile(customerId: string): Promise<CustomerProfile> {\n const response = await this.queryProfiles({\n search: customerId,\n page: 1,\n page_size: 1,\n });\n\n if (response.data.length === 0) {\n throw new Error(`Profile not found for customer ID: ${customerId}`);\n }\n\n return response.data[0];\n }\n\n /**\n * Get profile by UUID\n *\n * @param profileId - Profile UUID\n * @returns Customer profile\n */\n async getProfileById(profileId: string): Promise<CustomerProfile> {\n // Note: The dashboard endpoint provides detailed profile view\n const details = await this.getProfileDetails(profileId);\n return details.profile;\n }\n\n /**\n * Get detailed profile information including risk factors and history\n *\n * @param profileId - Profile UUID\n * @returns Detailed profile response with risk factors and history\n *\n * @example\n * ```typescript\n * const details = await client.getProfileDetails(profileId);\n * console.log('Risk factors:', details.risk_factors);\n * console.log('Risk history:', details.risk_history);\n * console.log('Alert counts:', {\n * watchlist: details.watchlist_alert_count,\n * fraud: details.fraud_alert_count,\n * geo: details.geolocation_alert_count\n * });\n * ```\n */\n async getProfileDetails(profileId: string): Promise<ProfileDetailsResponse> {\n return this.request<ProfileDetailsResponse>(\n `/api/v1/risk-dashboard/profiles/${profileId}`\n );\n }\n\n /**\n * Update customer profile\n *\n * @param profileId - Profile UUID\n * @param updates - Fields to update\n * @returns Updated customer profile\n *\n * @example\n * ```typescript\n * const updated = await client.updateProfile(profileId, {\n * location: 'New York, USA',\n * location_compliance: 'compliant',\n * last_recorded_activity: new Date().toISOString()\n * });\n * ```\n */\n async updateProfile(\n profileId: string,\n updates: UpdateProfileRequest\n ): Promise<CustomerProfile> {\n return this.request<CustomerProfile>(`/api/v1/profiles/${profileId}`, {\n method: 'PUT',\n body: JSON.stringify(updates),\n });\n }\n\n /**\n * Manually recalculate risk score for a profile\n *\n * Triggers immediate risk score recalculation based on current risk factors.\n *\n * @param profileId - Profile UUID\n * @param reason - Optional reason for recalculation\n *\n * @example\n * ```typescript\n * await client.recalculateRiskScore(profileId, 'Manual review completed');\n * ```\n */\n async recalculateRiskScore(profileId: string, reason?: string): Promise<void> {\n const body = reason ? JSON.stringify({ reason }) : undefined;\n await this.request(`/api/v1/profiles/recalculate/${profileId}`, {\n method: 'POST',\n body,\n });\n }\n\n // ============================================================================\n // Query & Search\n // ============================================================================\n\n /**\n * Query profiles with advanced filters\n *\n * @param filters - Filter criteria and pagination\n * @returns Paginated list of profiles\n *\n * @example\n * ```typescript\n * const results = await client.queryProfiles({\n * risk_category: ['high', 'critical'],\n * kyc_status: ['pending'],\n * is_pep: true,\n * page: 1,\n * page_size: 20,\n * sort_by: 'risk_score',\n * sort_order: 'desc'\n * });\n *\n * console.log(`Found ${results.total} high-risk profiles`);\n * results.data.forEach(profile => {\n * console.log(`${profile.full_name}: ${profile.risk_score}`);\n * });\n * ```\n */\n async queryProfiles(filters: ProfileFilters = {}): Promise<ProfileListResponse> {\n const queryString = this.buildQueryString(filters);\n return this.request<ProfileListResponse>(\n `/api/v1/risk-dashboard/profiles${queryString}`\n );\n }\n\n /**\n * Search profiles by text (searches name, email, customer_id, account_number)\n *\n * @param searchText - Text to search for\n * @param limit - Maximum results to return (default: 10)\n * @returns Array of matching profiles\n */\n async searchProfiles(searchText: string, limit: number = 10): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n search: searchText,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get all high-risk profiles (high + critical)\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of high-risk profiles\n */\n async getHighRiskProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n risk_category: ['high', 'critical'],\n page: 1,\n page_size: limit,\n sort_by: 'risk_score',\n sort_order: 'desc',\n });\n return response.data;\n }\n\n /**\n * Get profiles requiring PEP review\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of PEP profiles\n */\n async getPEPProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n is_pep: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get profiles with sanctions matches\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of sanctioned profiles\n */\n async getSanctionedProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n has_sanctions: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n // ============================================================================\n // Dashboard & Metrics\n // ============================================================================\n\n /**\n * Get risk dashboard metrics and statistics\n *\n * @param startDate - Optional start date for metrics (ISO format)\n * @param endDate - Optional end date for metrics (ISO format)\n * @returns Dashboard metrics\n *\n * @example\n * ```typescript\n * const metrics = await client.getDashboardMetrics();\n * console.log('Total risky profiles:', metrics.total_risky_profiles);\n * console.log('Critical profiles:', metrics.total_critical_profiles);\n * console.log('Average risk score:', metrics.average_risk_score);\n *\n * metrics.risk_distribution.forEach(item => {\n * console.log(`${item.category}: ${item.count} (${item.percentage}%)`);\n * });\n * ```\n */\n async getDashboardMetrics(\n startDate?: string,\n endDate?: string\n ): Promise<RiskDashboardMetrics> {\n const params: Record<string, string> = {};\n if (startDate) params.start_date = startDate;\n if (endDate) params.end_date = endDate;\n\n const queryString = this.buildQueryString(params);\n return this.request<RiskDashboardMetrics>(\n `/api/v1/risk-dashboard/metrics${queryString}`\n );\n }\n\n // ============================================================================\n // Bulk Operations\n // ============================================================================\n\n /**\n * Get or create profile (idempotent operation)\n *\n * Attempts to get existing profile by customer_id, creates if not found.\n *\n * @param customerId - Customer ID\n * @param createRequest - Profile data to use if creating new profile\n * @returns Existing or newly created profile\n *\n * @example\n * ```typescript\n * const profile = await client.getOrCreateProfile('CUST-123', {\n * customer_id: 'CUST-123',\n * entity_type: 'individual',\n * full_name: 'John Doe',\n * email_address: 'john@example.com'\n * });\n * ```\n */\n async getOrCreateProfile(\n customerId: string,\n createRequest: CreateProfileRequest\n ): Promise<CustomerProfile> {\n try {\n return await this.getProfile(customerId);\n } catch (error) {\n // Profile doesn't exist, create it\n return await this.createProfile(createRequest);\n }\n }\n\n /**\n * Batch get profiles by customer IDs\n *\n * @param customerIds - Array of customer IDs\n * @returns Array of profiles (may be less than input if some not found)\n */\n async batchGetProfiles(customerIds: string[]): Promise<CustomerProfile[]> {\n // Note: Current API doesn't have batch endpoint, so we query with search\n // In production, this should use a dedicated batch endpoint\n const profiles: CustomerProfile[] = [];\n\n for (const customerId of customerIds) {\n try {\n const profile = await this.getProfile(customerId);\n profiles.push(profile);\n } catch (error) {\n // Profile not found, skip\n if (this.config.debug) {\n console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);\n }\n }\n }\n\n return profiles;\n }\n\n // ============================================================================\n // Configuration\n // ============================================================================\n\n /**\n * Get risk configuration for tenant\n *\n * Returns the risk scoring weights and thresholds configured for the tenant.\n *\n * @returns Risk configuration\n */\n async getRiskConfiguration(): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config');\n }\n\n /**\n * Update risk configuration for tenant\n *\n * Updates risk scoring weights and/or thresholds.\n *\n * @param config - Configuration updates\n * @returns Updated risk configuration\n */\n async updateRiskConfiguration(\n config: Partial<RiskConfiguration>\n ): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config', {\n method: 'PUT',\n body: JSON.stringify(config),\n });\n }\n}\n"]}
|