vesant-sdk 1.4.5 → 1.5.2

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.
Files changed (66) hide show
  1. package/README.md +5 -3
  2. package/dist/{client-BlAt791q.d.ts → client-B8pFrXx_.d.ts} +11 -5
  3. package/dist/{client-oo_3-0YW.d.mts → client-BZxzOidG.d.mts} +11 -5
  4. package/dist/{client-CY41e2Z_.d.mts → client-CIon-bGS.d.mts} +9 -5
  5. package/dist/{client-CY41e2Z_.d.ts → client-CIon-bGS.d.ts} +9 -5
  6. package/dist/compliance/index.d.mts +7 -7
  7. package/dist/compliance/index.d.ts +7 -7
  8. package/dist/compliance/index.js +46 -51
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +46 -51
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.d.mts +2 -2
  13. package/dist/decisions/index.d.ts +2 -2
  14. package/dist/decisions/index.js +32 -33
  15. package/dist/decisions/index.js.map +1 -1
  16. package/dist/decisions/index.mjs +32 -33
  17. package/dist/decisions/index.mjs.map +1 -1
  18. package/dist/geolocation/index.d.mts +4 -4
  19. package/dist/geolocation/index.d.ts +4 -4
  20. package/dist/geolocation/index.js +33 -34
  21. package/dist/geolocation/index.js.map +1 -1
  22. package/dist/geolocation/index.mjs +33 -34
  23. package/dist/geolocation/index.mjs.map +1 -1
  24. package/dist/index.d.mts +553 -21
  25. package/dist/index.d.ts +553 -21
  26. package/dist/index.js +320 -161
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +318 -159
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/kyc/core.d.mts +3 -3
  31. package/dist/kyc/core.d.ts +3 -3
  32. package/dist/kyc/core.js +32 -33
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +32 -33
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +11 -7
  37. package/dist/kyc/index.d.ts +11 -7
  38. package/dist/kyc/index.js +32 -33
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +32 -33
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +6 -6
  43. package/dist/react.d.ts +6 -6
  44. package/dist/react.js +5 -5
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +5 -5
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/risk-profile/index.d.mts +4 -4
  49. package/dist/risk-profile/index.d.ts +4 -4
  50. package/dist/risk-profile/index.js +35 -36
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +35 -36
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.d.mts +2 -2
  55. package/dist/scores/index.d.ts +2 -2
  56. package/dist/scores/index.js +32 -33
  57. package/dist/scores/index.js.map +1 -1
  58. package/dist/scores/index.mjs +32 -33
  59. package/dist/scores/index.mjs.map +1 -1
  60. package/dist/{types-jaLuzruy.d.mts → types-1RzYeSal.d.mts} +2 -2
  61. package/dist/{types-DZHongaK.d.mts → types-B4Ezqo7V.d.mts} +2 -2
  62. package/dist/{types-DZHongaK.d.ts → types-B4Ezqo7V.d.ts} +2 -2
  63. package/dist/{types-DLC7Sfy5.d.ts → types-X5Md_dD_.d.ts} +2 -2
  64. package/dist/webhooks/index.d.mts +1 -1
  65. package/dist/webhooks/index.d.ts +1 -1
  66. package/package.json +6 -1
@@ -1,9 +1,9 @@
1
- import { c as RiskLevel, P as PaginationParams } from '../types-DZHongaK.mjs';
2
- import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-jaLuzruy.mjs';
3
- import { B as BaseClient } from '../client-CY41e2Z_.mjs';
1
+ import { R as RiskLevel, P as PaginationParams } from '../types-B4Ezqo7V.mjs';
2
+ import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-1RzYeSal.mjs';
3
+ import { B as BaseClient } from '../client-CIon-bGS.mjs';
4
4
 
5
5
  /**
6
- * TypeScript type definitions for CGS KYC Service API
6
+ * TypeScript type definitions for Vesant KYC Service API
7
7
  *
8
8
  * These types match the Go API structures in:
9
9
  * - services/kyc-service/internal/domain/
@@ -232,6 +232,8 @@ interface CreateReuseKycSessionRequest {
232
232
  reference: string;
233
233
  /** customer ID to associate with the KYC session */
234
234
  customer_id: string;
235
+ /** where the re-use-kyc using 'login' | 'transactions' */
236
+ path?: string;
235
237
  /** URL to redirect user after validate the facial submission (optional) */
236
238
  redirect_url?: string;
237
239
  /** URL to receive callback notifications via POST request when reuse KYC status changes (optional) */
@@ -256,6 +258,8 @@ interface CreateReuseKycSessionResponse {
256
258
  token: string;
257
259
  /** reuse KYC session reference */
258
260
  reference: string;
261
+ /** re-use-kyc required for the action or not */
262
+ is_required: boolean;
259
263
  }
260
264
  interface CheckKycStatusRequest {
261
265
  /** User ID to check KYC status for */
@@ -266,7 +270,7 @@ interface CheckKycStatusRequest {
266
270
  interface CheckKycStatusResponse {
267
271
  /** User ID */
268
272
  user_id?: string;
269
- /** Token generated from cgs-server */
273
+ /** Token generated from the server */
270
274
  kyc_id: string;
271
275
  /** Current KYC status */
272
276
  status: string;
@@ -394,7 +398,7 @@ interface UseKycPreferencesResult extends BaseHookState {
394
398
  }
395
399
 
396
400
  /**
397
- * KycClient - TypeScript SDK for CGS KYC (Know Your Customer) Service
401
+ * KycClient - TypeScript SDK for Vesant KYC (Know Your Customer) Service
398
402
  *
399
403
  * Provides type-safe methods to interact with the KYC service API.
400
404
  * Extends BaseClient for consistent retry logic, timeout handling, and error management.
@@ -403,7 +407,7 @@ interface UseKycPreferencesResult extends BaseHookState {
403
407
  /**
404
408
  * KycClient extends BaseClient for:
405
409
  * - Consistent retry logic with exponential backoff
406
- * - Unified error handling (CGSError, NetworkError, TimeoutError, etc.)
410
+ * - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
407
411
  * - Automatic timeout management
408
412
  * - Debug logging
409
413
  *
@@ -1,9 +1,9 @@
1
- import { c as RiskLevel, P as PaginationParams } from '../types-DZHongaK.js';
2
- import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-DLC7Sfy5.js';
3
- import { B as BaseClient } from '../client-CY41e2Z_.js';
1
+ import { R as RiskLevel, P as PaginationParams } from '../types-B4Ezqo7V.js';
2
+ import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-X5Md_dD_.js';
3
+ import { B as BaseClient } from '../client-CIon-bGS.js';
4
4
 
5
5
  /**
6
- * TypeScript type definitions for CGS KYC Service API
6
+ * TypeScript type definitions for Vesant KYC Service API
7
7
  *
8
8
  * These types match the Go API structures in:
9
9
  * - services/kyc-service/internal/domain/
@@ -232,6 +232,8 @@ interface CreateReuseKycSessionRequest {
232
232
  reference: string;
233
233
  /** customer ID to associate with the KYC session */
234
234
  customer_id: string;
235
+ /** where the re-use-kyc using 'login' | 'transactions' */
236
+ path?: string;
235
237
  /** URL to redirect user after validate the facial submission (optional) */
236
238
  redirect_url?: string;
237
239
  /** URL to receive callback notifications via POST request when reuse KYC status changes (optional) */
@@ -256,6 +258,8 @@ interface CreateReuseKycSessionResponse {
256
258
  token: string;
257
259
  /** reuse KYC session reference */
258
260
  reference: string;
261
+ /** re-use-kyc required for the action or not */
262
+ is_required: boolean;
259
263
  }
260
264
  interface CheckKycStatusRequest {
261
265
  /** User ID to check KYC status for */
@@ -266,7 +270,7 @@ interface CheckKycStatusRequest {
266
270
  interface CheckKycStatusResponse {
267
271
  /** User ID */
268
272
  user_id?: string;
269
- /** Token generated from cgs-server */
273
+ /** Token generated from the server */
270
274
  kyc_id: string;
271
275
  /** Current KYC status */
272
276
  status: string;
@@ -394,7 +398,7 @@ interface UseKycPreferencesResult extends BaseHookState {
394
398
  }
395
399
 
396
400
  /**
397
- * KycClient - TypeScript SDK for CGS KYC (Know Your Customer) Service
401
+ * KycClient - TypeScript SDK for Vesant KYC (Know Your Customer) Service
398
402
  *
399
403
  * Provides type-safe methods to interact with the KYC service API.
400
404
  * Extends BaseClient for consistent retry logic, timeout handling, and error management.
@@ -403,7 +407,7 @@ interface UseKycPreferencesResult extends BaseHookState {
403
407
  /**
404
408
  * KycClient extends BaseClient for:
405
409
  * - Consistent retry logic with exponential backoff
406
- * - Unified error handling (CGSError, NetworkError, TimeoutError, etc.)
410
+ * - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
407
411
  * - Automatic timeout management
408
412
  * - Debug logging
409
413
  *
package/dist/kyc/index.js CHANGED
@@ -1,46 +1,46 @@
1
1
  'use strict';
2
2
 
3
3
  // src/core/errors.ts
4
- var CGSError = class _CGSError extends Error {
4
+ var VesantError = class _VesantError extends Error {
5
5
  constructor(message, code, statusCode, details) {
6
6
  super(message);
7
7
  this.code = code;
8
8
  this.statusCode = statusCode;
9
9
  this.details = details;
10
- this.name = "CGSError";
11
- Object.setPrototypeOf(this, _CGSError.prototype);
10
+ this.name = "VesantError";
11
+ Object.setPrototypeOf(this, _VesantError.prototype);
12
12
  }
13
13
  };
14
- var NetworkError = class _NetworkError extends CGSError {
14
+ var NetworkError = class _NetworkError extends VesantError {
15
15
  constructor(message, originalError) {
16
- super(message, "NETWORK_ERROR", void 0, { originalError });
16
+ super(message, "NETWORK_ERROR");
17
17
  this.originalError = originalError;
18
18
  this.name = "NetworkError";
19
19
  Object.setPrototypeOf(this, _NetworkError.prototype);
20
20
  }
21
21
  };
22
- var ValidationError = class _ValidationError extends CGSError {
22
+ var ValidationError = class _ValidationError extends VesantError {
23
23
  constructor(message, fields) {
24
24
  super(message, "VALIDATION_ERROR", 400, { fields });
25
25
  this.name = "ValidationError";
26
26
  Object.setPrototypeOf(this, _ValidationError.prototype);
27
27
  }
28
28
  };
29
- var ServiceUnavailableError = class _ServiceUnavailableError extends CGSError {
30
- constructor(message) {
31
- super(`${message} is unavailable`, "SERVICE_UNAVAILABLE", 503, { service: message });
29
+ var ServiceUnavailableError = class _ServiceUnavailableError extends VesantError {
30
+ constructor(message = "Service unavailable") {
31
+ super(message, "SERVICE_UNAVAILABLE", 503);
32
32
  this.name = "ServiceUnavailableError";
33
33
  Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
34
34
  }
35
35
  };
36
- var AuthenticationError = class _AuthenticationError extends CGSError {
36
+ var AuthenticationError = class _AuthenticationError extends VesantError {
37
37
  constructor(message = "Authentication failed") {
38
38
  super(message, "AUTHENTICATION_ERROR", 401);
39
39
  this.name = "AuthenticationError";
40
40
  Object.setPrototypeOf(this, _AuthenticationError.prototype);
41
41
  }
42
42
  };
43
- var RateLimitError = class _RateLimitError extends CGSError {
43
+ var RateLimitError = class _RateLimitError extends VesantError {
44
44
  constructor(retryAfter) {
45
45
  super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
46
46
  this.retryAfter = retryAfter;
@@ -48,7 +48,7 @@ var RateLimitError = class _RateLimitError extends CGSError {
48
48
  Object.setPrototypeOf(this, _RateLimitError.prototype);
49
49
  }
50
50
  };
51
- var TimeoutError = class _TimeoutError extends CGSError {
51
+ var TimeoutError = class _TimeoutError extends VesantError {
52
52
  constructor(timeout) {
53
53
  super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
54
54
  this.timeout = timeout;
@@ -56,7 +56,7 @@ var TimeoutError = class _TimeoutError extends CGSError {
56
56
  Object.setPrototypeOf(this, _TimeoutError.prototype);
57
57
  }
58
58
  };
59
- var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends CGSError {
59
+ var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
60
60
  constructor() {
61
61
  super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
62
62
  this.name = "CircuitBreakerOpenError";
@@ -201,22 +201,22 @@ var RateLimitTracker = class {
201
201
  function createConsoleLogger() {
202
202
  return {
203
203
  debug(message, meta) {
204
- console.log(`[CGS SDK] ${message}`, meta !== void 0 ? meta : "");
204
+ console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
205
205
  },
206
206
  info(message, meta) {
207
- console.info(`[CGS SDK] ${message}`, meta !== void 0 ? meta : "");
207
+ console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
208
208
  },
209
209
  warn(message, meta) {
210
- console.warn(`[CGS SDK] ${message}`, meta !== void 0 ? meta : "");
210
+ console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
211
211
  },
212
212
  error(message, meta) {
213
- console.error(`[CGS SDK] ${message}`, meta !== void 0 ? meta : "");
213
+ console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
214
214
  }
215
215
  };
216
216
  }
217
217
 
218
218
  // src/core/version.ts
219
- var SDK_VERSION = "1.4.5";
219
+ var SDK_VERSION = "1.5.2";
220
220
 
221
221
  // src/shared/browser-utils.ts
222
222
  function generateUUID() {
@@ -251,7 +251,7 @@ var BaseClient = class {
251
251
  }
252
252
  environment = "sandbox";
253
253
  } else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
254
- this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 the X-Sandbox header will be sent for backward compatibility');
254
+ this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
255
255
  }
256
256
  this.config = {
257
257
  ...config,
@@ -323,10 +323,7 @@ var BaseClient = class {
323
323
  }
324
324
  }
325
325
  if (this.config.debug) {
326
- this.logger.debug(`${finalOptions.method || "GET"} ${url}`, {
327
- headers: finalOptions.headers,
328
- body: finalOptions.body
329
- });
326
+ this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
330
327
  }
331
328
  const response = await fetch(url, {
332
329
  ...finalOptions,
@@ -360,17 +357,17 @@ var BaseClient = class {
360
357
  }
361
358
  }
362
359
  if (this.config.debug) {
363
- this.logger.debug("Response:", { data: result });
360
+ this.logger.debug(`Response: ${response.status}`);
364
361
  }
365
362
  return result;
366
363
  } catch (error) {
367
364
  clearTimeout(timeoutId);
368
- if (error instanceof CGSError && error.statusCode && error.statusCode >= 500) {
365
+ if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
369
366
  this.circuitBreaker?.onFailure();
370
367
  } else if (error instanceof NetworkError || error instanceof TimeoutError) {
371
368
  this.circuitBreaker?.onFailure();
372
369
  }
373
- if (error instanceof CGSError && !error.requestId) {
370
+ if (error instanceof VesantError && !error.requestId) {
374
371
  error.requestId = requestId;
375
372
  }
376
373
  if (error instanceof Error) {
@@ -383,7 +380,7 @@ var BaseClient = class {
383
380
  if (error instanceof Error) {
384
381
  if (error.name === "AbortError") {
385
382
  if (requestOptions?.signal?.aborted) {
386
- const abortError = new CGSError("Request aborted", "REQUEST_ABORTED");
383
+ const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
387
384
  abortError.requestId = requestId;
388
385
  throw abortError;
389
386
  }
@@ -392,7 +389,7 @@ var BaseClient = class {
392
389
  timeoutError.requestId = requestId;
393
390
  throw timeoutError;
394
391
  }
395
- if (error instanceof CGSError) {
392
+ if (error instanceof VesantError) {
396
393
  throw error;
397
394
  }
398
395
  }
@@ -415,7 +412,7 @@ var BaseClient = class {
415
412
  if (requestOptions?.signal?.aborted) {
416
413
  throw lastError;
417
414
  }
418
- if (lastError instanceof CGSError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
415
+ if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
419
416
  throw lastError;
420
417
  }
421
418
  if (attempt === retries) {
@@ -443,13 +440,15 @@ var BaseClient = class {
443
440
  const createError = () => {
444
441
  switch (status) {
445
442
  case 400:
446
- return new CGSError(message, "BAD_REQUEST", 400, data);
443
+ return new VesantError(message, "BAD_REQUEST", 400);
447
444
  case 401:
448
445
  return new AuthenticationError(message);
449
446
  case 403:
450
- return new CGSError(message, "FORBIDDEN", 403, data);
447
+ return new VesantError(message, "FORBIDDEN", 403);
451
448
  case 404:
452
- return new CGSError(message, "NOT_FOUND", 404, data);
449
+ return new VesantError(message, "NOT_FOUND", 404);
450
+ case 409:
451
+ return new VesantError(message, "DUPLICATE_PROFILE", 409);
453
452
  case 429: {
454
453
  const retryAfter = data.retry_after || data.retryAfter;
455
454
  return new RateLimitError(retryAfter);
@@ -460,7 +459,7 @@ var BaseClient = class {
460
459
  case 504:
461
460
  return new ServiceUnavailableError(message);
462
461
  default:
463
- return new CGSError(message, "UNKNOWN_ERROR", status, data);
462
+ return new VesantError(message, "UNKNOWN_ERROR", status);
464
463
  }
465
464
  };
466
465
  const error = createError();