vesant-sdk 1.6.0 → 1.6.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.
- package/dist/{client-C4g596fI.d.mts → client-BlCxjbY2.d.mts} +8 -2
- package/dist/{client-Bd9a5o0C.d.ts → client-C_A7QLcB.d.ts} +8 -2
- package/dist/{client-CIon-bGS.d.mts → client-ePzhQKp9.d.mts} +2 -0
- package/dist/{client-CIon-bGS.d.ts → client-ePzhQKp9.d.ts} +2 -0
- package/dist/compliance/index.d.mts +12 -5
- package/dist/compliance/index.d.ts +12 -5
- package/dist/compliance/index.js +201 -69
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +201 -69
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +1 -1
- package/dist/decisions/index.d.ts +1 -1
- package/dist/decisions/index.js +14 -1
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +14 -1
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +3 -3
- package/dist/geolocation/index.d.ts +3 -3
- package/dist/geolocation/index.js +56 -14
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +56 -14
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -376
- package/dist/index.d.ts +6 -376
- package/dist/index.js +268 -278
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +268 -278
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +1 -1
- package/dist/kyc/core.d.ts +1 -1
- package/dist/kyc/core.js +14 -1
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +14 -1
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +1 -1
- package/dist/kyc/index.d.ts +1 -1
- package/dist/kyc/index.js +14 -1
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +14 -1
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +1 -1
- package/dist/risk-profile/index.d.ts +1 -1
- package/dist/risk-profile/index.js +14 -1
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +14 -1
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +1 -1
- package/dist/scores/index.d.ts +1 -1
- package/dist/scores/index.js +14 -1
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +14 -1
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +255 -0
- package/dist/tax/index.d.ts +255 -0
- package/dist/tax/index.js +652 -0
- package/dist/tax/index.js.map +1 -0
- package/dist/tax/index.mjs +650 -0
- package/dist/tax/index.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-ePzhQKp9.mjs';
|
|
2
2
|
import { P as PaginationParams } from './types-B4Ezqo7V.mjs';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
@@ -195,6 +195,7 @@ interface ValidateCipherTextResponse {
|
|
|
195
195
|
is_vpn: boolean;
|
|
196
196
|
is_proxy: boolean;
|
|
197
197
|
is_tor: boolean;
|
|
198
|
+
is_hosting?: boolean;
|
|
198
199
|
/** Whether access is blocked based on tenant's geofence rules configuration */
|
|
199
200
|
is_blocked: boolean;
|
|
200
201
|
/** Reasons for blocking (only present if is_blocked is true) */
|
|
@@ -205,6 +206,11 @@ interface ValidateCipherTextResponse {
|
|
|
205
206
|
location_mismatch_distance_km?: number;
|
|
206
207
|
};
|
|
207
208
|
errors?: string[];
|
|
209
|
+
is_compliant?: boolean;
|
|
210
|
+
jurisdiction?: JurisdictionConfig;
|
|
211
|
+
geofence_evaluation?: GeofenceEvaluation;
|
|
212
|
+
record_id?: string;
|
|
213
|
+
gps_required?: boolean;
|
|
208
214
|
}
|
|
209
215
|
interface VerifyIPRequest {
|
|
210
216
|
ip_address: string;
|
|
@@ -1010,4 +1016,4 @@ declare class GeolocationClient extends BaseClient {
|
|
|
1010
1016
|
generateCipherText(options: Omit<CipherTextOptions, 'apiKey' | 'signingKey'>, gpsConfig?: GeolocationConfigResponse): Promise<CipherTextResult>;
|
|
1011
1017
|
}
|
|
1012
1018
|
|
|
1013
|
-
export { type
|
|
1019
|
+
export { type UseLocationRequestsOptions as $, type AlertStatus as A, type APIError as B, type CipherTextPayload as C, type DeviceFingerprintRequest as D, type GeolocationConfigResponse as E, type GeolocationClientConfig as F, GeolocationClient as G, type UseGeolocationOptions as H, type UseGeolocationResult as I, type JurisdictionConfig as J, type UseAlertsOptions as K, type LocationVerification as L, type UseAlertsResult as M, type LocationRequestStatus as N, type LocationRequestChannel as O, type LocationRequest as P, type CreateLocationRequestRequest as Q, type LocationRequestResult as R, type LocationRequestFilters as S, type LocationRequestListResponse as T, type UpdateJurisdictionRequest as U, type ValidateCipherTextRequest as V, type ResendLocationRequestRequest as W, type WiFiNetwork as X, type LocationCaptureRequest as Y, type LocationShareInfo as Z, type LocationCaptureResponse as _, type CipherTextReason as a, type UseLocationRequestsResult as a0, type UseLocationCaptureOptions as a1, type UseLocationCaptureResult as a2, type CipherTextOptions as b, type CipherTextResult as c, type DecryptedCipherText as d, type CipherTextCustomerData as e, type ValidateCipherTextResponse as f, type VerifyIPRequest as g, type GeoIPResult as h, type GeofenceEvaluation as i, type DeviceFingerprint as j, type DeviceTrustResult as k, type ComplianceCheckResponse as l, type AlertSeverity as m, type AlertType as n, type GeolocationAlert as o, type AlertFilters as p, type AlertListResponse as q, type DashboardMetrics as r, type CreateJurisdictionRequest as s, type GeofenceRuleType as t, type GeofenceAction as u, type GeofenceRule as v, type CreateGeofenceRuleRequest as w, type UpdateGeofenceRuleRequest as x, type UpdateDeviceTrustRequest as y, type GeolocationRecord as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-ePzhQKp9.js';
|
|
2
2
|
import { P as PaginationParams } from './types-B4Ezqo7V.js';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
@@ -195,6 +195,7 @@ interface ValidateCipherTextResponse {
|
|
|
195
195
|
is_vpn: boolean;
|
|
196
196
|
is_proxy: boolean;
|
|
197
197
|
is_tor: boolean;
|
|
198
|
+
is_hosting?: boolean;
|
|
198
199
|
/** Whether access is blocked based on tenant's geofence rules configuration */
|
|
199
200
|
is_blocked: boolean;
|
|
200
201
|
/** Reasons for blocking (only present if is_blocked is true) */
|
|
@@ -205,6 +206,11 @@ interface ValidateCipherTextResponse {
|
|
|
205
206
|
location_mismatch_distance_km?: number;
|
|
206
207
|
};
|
|
207
208
|
errors?: string[];
|
|
209
|
+
is_compliant?: boolean;
|
|
210
|
+
jurisdiction?: JurisdictionConfig;
|
|
211
|
+
geofence_evaluation?: GeofenceEvaluation;
|
|
212
|
+
record_id?: string;
|
|
213
|
+
gps_required?: boolean;
|
|
208
214
|
}
|
|
209
215
|
interface VerifyIPRequest {
|
|
210
216
|
ip_address: string;
|
|
@@ -1010,4 +1016,4 @@ declare class GeolocationClient extends BaseClient {
|
|
|
1010
1016
|
generateCipherText(options: Omit<CipherTextOptions, 'apiKey' | 'signingKey'>, gpsConfig?: GeolocationConfigResponse): Promise<CipherTextResult>;
|
|
1011
1017
|
}
|
|
1012
1018
|
|
|
1013
|
-
export { type
|
|
1019
|
+
export { type UseLocationRequestsOptions as $, type AlertStatus as A, type APIError as B, type CipherTextPayload as C, type DeviceFingerprintRequest as D, type GeolocationConfigResponse as E, type GeolocationClientConfig as F, GeolocationClient as G, type UseGeolocationOptions as H, type UseGeolocationResult as I, type JurisdictionConfig as J, type UseAlertsOptions as K, type LocationVerification as L, type UseAlertsResult as M, type LocationRequestStatus as N, type LocationRequestChannel as O, type LocationRequest as P, type CreateLocationRequestRequest as Q, type LocationRequestResult as R, type LocationRequestFilters as S, type LocationRequestListResponse as T, type UpdateJurisdictionRequest as U, type ValidateCipherTextRequest as V, type ResendLocationRequestRequest as W, type WiFiNetwork as X, type LocationCaptureRequest as Y, type LocationShareInfo as Z, type LocationCaptureResponse as _, type CipherTextReason as a, type UseLocationRequestsResult as a0, type UseLocationCaptureOptions as a1, type UseLocationCaptureResult as a2, type CipherTextOptions as b, type CipherTextResult as c, type DecryptedCipherText as d, type CipherTextCustomerData as e, type ValidateCipherTextResponse as f, type VerifyIPRequest as g, type GeoIPResult as h, type GeofenceEvaluation as i, type DeviceFingerprint as j, type DeviceTrustResult as k, type ComplianceCheckResponse as l, type AlertSeverity as m, type AlertType as n, type GeolocationAlert as o, type AlertFilters as p, type AlertListResponse as q, type DashboardMetrics as r, type CreateJurisdictionRequest as s, type GeofenceRuleType as t, type GeofenceAction as u, type GeofenceRule as v, type CreateGeofenceRuleRequest as w, type UpdateGeofenceRuleRequest as x, type UpdateDeviceTrustRequest as y, type GeolocationRecord as z };
|
|
@@ -64,6 +64,8 @@ interface RequestOptions {
|
|
|
64
64
|
signal?: AbortSignal;
|
|
65
65
|
/** Idempotency key for POST/PUT/PATCH requests */
|
|
66
66
|
idempotencyKey?: string;
|
|
67
|
+
/** Response type — defaults to 'json'. Use 'arraybuffer' for binary downloads (PDF, etc.) */
|
|
68
|
+
responseType?: 'json' | 'arraybuffer';
|
|
67
69
|
}
|
|
68
70
|
interface RequestInterceptor {
|
|
69
71
|
/** Called before each request. Can modify headers or options. */
|
|
@@ -64,6 +64,8 @@ interface RequestOptions {
|
|
|
64
64
|
signal?: AbortSignal;
|
|
65
65
|
/** Idempotency key for POST/PUT/PATCH requests */
|
|
66
66
|
idempotencyKey?: string;
|
|
67
|
+
/** Response type — defaults to 'json'. Use 'arraybuffer' for binary downloads (PDF, etc.) */
|
|
68
|
+
responseType?: 'json' | 'arraybuffer';
|
|
67
69
|
}
|
|
68
70
|
interface RequestInterceptor {
|
|
69
71
|
/** Called before each request. Can modify headers or options. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification,
|
|
2
|
-
export {
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, f as ValidateCipherTextResponse, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-BlCxjbY2.mjs';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-BlCxjbY2.mjs';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.mjs';
|
|
4
|
-
import { V as VesantConfig, R as RequestOptions } from '../client-
|
|
4
|
+
import { V as VesantConfig, R as RequestOptions } from '../client-ePzhQKp9.mjs';
|
|
5
5
|
import { C as CustomerProfile } from '../types-1RzYeSal.mjs';
|
|
6
6
|
import { E as EntityType, P as PaginationParams } from '../types-B4Ezqo7V.mjs';
|
|
7
7
|
|
|
@@ -38,7 +38,7 @@ interface LoginVerificationRequest {
|
|
|
38
38
|
interface LoginVerificationResponse {
|
|
39
39
|
allowed: boolean;
|
|
40
40
|
geolocation: LocationVerification;
|
|
41
|
-
profile: CustomerProfile;
|
|
41
|
+
profile: CustomerProfile | null;
|
|
42
42
|
requiresStepUp: boolean;
|
|
43
43
|
blockReasons: string[];
|
|
44
44
|
processingTime: number;
|
|
@@ -57,7 +57,7 @@ interface TransactionVerificationRequest {
|
|
|
57
57
|
interface TransactionVerificationResponse {
|
|
58
58
|
allowed: boolean;
|
|
59
59
|
geolocation: LocationVerification;
|
|
60
|
-
profile: CustomerProfile;
|
|
60
|
+
profile: CustomerProfile | null;
|
|
61
61
|
transactionRisk: TransactionRiskResult;
|
|
62
62
|
requiresApproval: boolean;
|
|
63
63
|
blockReasons: string[];
|
|
@@ -277,6 +277,13 @@ declare class ComplianceClient {
|
|
|
277
277
|
* Returns undefined if cipherText is not provided or validation fails.
|
|
278
278
|
*/
|
|
279
279
|
private executeCipherTextValidation;
|
|
280
|
+
/**
|
|
281
|
+
* Build a LocationVerification from a ValidateCipherTextResponse.
|
|
282
|
+
* The validate-ciphertext endpoint now returns the full geo-verification data
|
|
283
|
+
* (is_compliant, jurisdiction, geofence_evaluation, record_id, gps_required),
|
|
284
|
+
* so a separate verifyIP call is unnecessary.
|
|
285
|
+
*/
|
|
286
|
+
private buildLocationFromCipherText;
|
|
280
287
|
private calculateTransactionRisk;
|
|
281
288
|
private checkJurisdictionLimits;
|
|
282
289
|
private normalizeToUSD;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification,
|
|
2
|
-
export {
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, f as ValidateCipherTextResponse, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-C_A7QLcB.js';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-C_A7QLcB.js';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.js';
|
|
4
|
-
import { V as VesantConfig, R as RequestOptions } from '../client-
|
|
4
|
+
import { V as VesantConfig, R as RequestOptions } from '../client-ePzhQKp9.js';
|
|
5
5
|
import { C as CustomerProfile } from '../types-X5Md_dD_.js';
|
|
6
6
|
import { E as EntityType, P as PaginationParams } from '../types-B4Ezqo7V.js';
|
|
7
7
|
|
|
@@ -38,7 +38,7 @@ interface LoginVerificationRequest {
|
|
|
38
38
|
interface LoginVerificationResponse {
|
|
39
39
|
allowed: boolean;
|
|
40
40
|
geolocation: LocationVerification;
|
|
41
|
-
profile: CustomerProfile;
|
|
41
|
+
profile: CustomerProfile | null;
|
|
42
42
|
requiresStepUp: boolean;
|
|
43
43
|
blockReasons: string[];
|
|
44
44
|
processingTime: number;
|
|
@@ -57,7 +57,7 @@ interface TransactionVerificationRequest {
|
|
|
57
57
|
interface TransactionVerificationResponse {
|
|
58
58
|
allowed: boolean;
|
|
59
59
|
geolocation: LocationVerification;
|
|
60
|
-
profile: CustomerProfile;
|
|
60
|
+
profile: CustomerProfile | null;
|
|
61
61
|
transactionRisk: TransactionRiskResult;
|
|
62
62
|
requiresApproval: boolean;
|
|
63
63
|
blockReasons: string[];
|
|
@@ -277,6 +277,13 @@ declare class ComplianceClient {
|
|
|
277
277
|
* Returns undefined if cipherText is not provided or validation fails.
|
|
278
278
|
*/
|
|
279
279
|
private executeCipherTextValidation;
|
|
280
|
+
/**
|
|
281
|
+
* Build a LocationVerification from a ValidateCipherTextResponse.
|
|
282
|
+
* The validate-ciphertext endpoint now returns the full geo-verification data
|
|
283
|
+
* (is_compliant, jurisdiction, geofence_evaluation, record_id, gps_required),
|
|
284
|
+
* so a separate verifyIP call is unnecessary.
|
|
285
|
+
*/
|
|
286
|
+
private buildLocationFromCipherText;
|
|
280
287
|
private calculateTransactionRisk;
|
|
281
288
|
private checkJurisdictionLimits;
|
|
282
289
|
private normalizeToUSD;
|
package/dist/compliance/index.js
CHANGED
|
@@ -224,7 +224,7 @@ function createConsoleLogger() {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/core/version.ts
|
|
227
|
-
var SDK_VERSION = "1.6.
|
|
227
|
+
var SDK_VERSION = "1.6.2";
|
|
228
228
|
|
|
229
229
|
// src/shared/browser-utils.ts
|
|
230
230
|
function generateUUID() {
|
|
@@ -398,6 +398,19 @@ var BaseClient = class {
|
|
|
398
398
|
if (this.rateLimitTracker) {
|
|
399
399
|
this.rateLimitTracker.updateFromHeaders(response.headers);
|
|
400
400
|
}
|
|
401
|
+
if (requestOptions?.responseType === "arraybuffer") {
|
|
402
|
+
if (!response.ok) {
|
|
403
|
+
let errData = {};
|
|
404
|
+
try {
|
|
405
|
+
errData = await response.json();
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
this.handleErrorResponse(response.status, errData, requestId);
|
|
409
|
+
}
|
|
410
|
+
this.circuitBreaker?.onSuccess();
|
|
411
|
+
const buffer = await response.arrayBuffer();
|
|
412
|
+
return buffer;
|
|
413
|
+
}
|
|
401
414
|
let data;
|
|
402
415
|
try {
|
|
403
416
|
data = await response.json();
|
|
@@ -1025,22 +1038,51 @@ var GeolocationClient = class extends BaseClient {
|
|
|
1025
1038
|
void 0,
|
|
1026
1039
|
requestOptions
|
|
1027
1040
|
);
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1041
|
+
const loc = cipherTextResult.location;
|
|
1042
|
+
const risk = cipherTextResult.risk;
|
|
1043
|
+
if (!risk) {
|
|
1044
|
+
const locationResult = await this.verifyIP({
|
|
1045
|
+
ip_address: ipAddress,
|
|
1046
|
+
user_id: userId,
|
|
1047
|
+
event_type: eventType
|
|
1048
|
+
}, requestOptions);
|
|
1049
|
+
return {
|
|
1050
|
+
ciphertext_valid: cipherTextResult.valid,
|
|
1051
|
+
ciphertext_result: cipherTextResult,
|
|
1052
|
+
location: locationResult
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
const location = {
|
|
1056
|
+
ip_address: cipherTextResult.ip_address,
|
|
1057
|
+
location: {
|
|
1058
|
+
country: loc?.country ?? "",
|
|
1059
|
+
country_iso: loc?.country_iso ?? "",
|
|
1060
|
+
city: loc?.city ?? "",
|
|
1061
|
+
region: loc?.region ?? "",
|
|
1062
|
+
postal_code: "",
|
|
1063
|
+
latitude: loc?.latitude ?? 0,
|
|
1064
|
+
longitude: loc?.longitude ?? 0,
|
|
1065
|
+
timezone: "",
|
|
1066
|
+
is_vpn: risk.is_vpn ?? false,
|
|
1067
|
+
is_proxy: risk.is_proxy ?? false,
|
|
1068
|
+
is_tor: risk.is_tor ?? false,
|
|
1069
|
+
is_hosting: risk.is_hosting ?? false,
|
|
1070
|
+
is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
|
|
1071
|
+
},
|
|
1072
|
+
is_compliant: cipherTextResult.is_compliant ?? !risk.is_blocked,
|
|
1073
|
+
is_blocked: risk.is_blocked ?? false,
|
|
1074
|
+
risk_level: risk.level ?? "low",
|
|
1075
|
+
risk_score: risk.score ?? 0,
|
|
1076
|
+
risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
|
|
1077
|
+
jurisdiction: cipherTextResult.jurisdiction,
|
|
1078
|
+
geofence_evaluation: cipherTextResult.geofence_evaluation,
|
|
1079
|
+
record_id: cipherTextResult.record_id ?? "",
|
|
1080
|
+
gps_required: cipherTextResult.gps_required
|
|
1081
|
+
};
|
|
1040
1082
|
return {
|
|
1041
1083
|
ciphertext_valid: cipherTextResult.valid,
|
|
1042
1084
|
ciphertext_result: cipherTextResult,
|
|
1043
|
-
location
|
|
1085
|
+
location
|
|
1044
1086
|
};
|
|
1045
1087
|
}
|
|
1046
1088
|
// ============================================================================
|
|
@@ -1445,28 +1487,34 @@ var ComplianceClient = class {
|
|
|
1445
1487
|
if (this.config.debug) {
|
|
1446
1488
|
this.logger.debug("Starting registration verification", { customerId: request.customerId });
|
|
1447
1489
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
email: request.emailAddress,
|
|
1451
|
-
phone: request.phoneNumber,
|
|
1452
|
-
date_of_birth: request.dateOfBirth
|
|
1453
|
-
} : void 0;
|
|
1454
|
-
[cipherTextResult, geoVerification] = await Promise.all([
|
|
1455
|
-
this.executeCipherTextValidation(
|
|
1490
|
+
if (request.cipherText) {
|
|
1491
|
+
cipherTextResult = await this.executeCipherTextValidation(
|
|
1456
1492
|
request.cipherText,
|
|
1457
1493
|
request.customerId,
|
|
1458
1494
|
"registration",
|
|
1459
1495
|
request.ipAddress,
|
|
1460
|
-
|
|
1496
|
+
{
|
|
1497
|
+
full_name: request.fullName,
|
|
1498
|
+
email: request.emailAddress,
|
|
1499
|
+
phone: request.phoneNumber,
|
|
1500
|
+
date_of_birth: request.dateOfBirth
|
|
1501
|
+
},
|
|
1461
1502
|
requestOptions
|
|
1462
|
-
)
|
|
1463
|
-
this.geoClient.verifyIP({
|
|
1503
|
+
);
|
|
1504
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1464
1505
|
ip_address: request.ipAddress,
|
|
1465
1506
|
user_id: request.customerId,
|
|
1466
1507
|
event_type: "registration",
|
|
1467
1508
|
device_fingerprint: request.deviceFingerprint
|
|
1468
|
-
}, requestOptions)
|
|
1469
|
-
|
|
1509
|
+
}, requestOptions);
|
|
1510
|
+
} else {
|
|
1511
|
+
geoVerification = await this.geoClient.verifyIP({
|
|
1512
|
+
ip_address: request.ipAddress,
|
|
1513
|
+
user_id: request.customerId,
|
|
1514
|
+
event_type: "registration",
|
|
1515
|
+
device_fingerprint: request.deviceFingerprint
|
|
1516
|
+
}, requestOptions);
|
|
1517
|
+
}
|
|
1470
1518
|
const blockReasons = this.evaluateRegistrationBlock(geoVerification, cipherTextResult);
|
|
1471
1519
|
if (blockReasons.length > 0) {
|
|
1472
1520
|
if (this.config.debug) {
|
|
@@ -1547,7 +1595,7 @@ var ComplianceClient = class {
|
|
|
1547
1595
|
evaluateRegistrationBlock(geoVerification, cipherTextResult) {
|
|
1548
1596
|
const blockReasons = [];
|
|
1549
1597
|
if (geoVerification.is_blocked) {
|
|
1550
|
-
blockReasons.push(...geoVerification.risk_reasons);
|
|
1598
|
+
blockReasons.push(...geoVerification.risk_reasons ?? []);
|
|
1551
1599
|
}
|
|
1552
1600
|
if (!geoVerification.is_compliant) {
|
|
1553
1601
|
if (!blockReasons.includes("non_compliant_jurisdiction")) {
|
|
@@ -1571,7 +1619,7 @@ var ComplianceClient = class {
|
|
|
1571
1619
|
}
|
|
1572
1620
|
}
|
|
1573
1621
|
if (geoVerification.geofence_evaluation?.blocked) {
|
|
1574
|
-
blockReasons.push(...geoVerification.geofence_evaluation.reasons);
|
|
1622
|
+
blockReasons.push(...geoVerification.geofence_evaluation.reasons ?? []);
|
|
1575
1623
|
}
|
|
1576
1624
|
if (geoVerification.risk_level === "critical") {
|
|
1577
1625
|
if (!blockReasons.includes("critical_risk_level")) {
|
|
@@ -1722,24 +1770,40 @@ var ComplianceClient = class {
|
|
|
1722
1770
|
if (this.config.debug) {
|
|
1723
1771
|
this.logger.debug("Starting login verification", { customerId: request.customerId });
|
|
1724
1772
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1773
|
+
let cipherTextResult;
|
|
1774
|
+
let geoVerification;
|
|
1775
|
+
let profileResult;
|
|
1776
|
+
if (request.cipherText) {
|
|
1777
|
+
[cipherTextResult, profileResult] = await Promise.all([
|
|
1778
|
+
this.executeCipherTextValidation(
|
|
1779
|
+
request.cipherText,
|
|
1780
|
+
request.customerId,
|
|
1781
|
+
"login",
|
|
1782
|
+
request.ipAddress,
|
|
1783
|
+
void 0,
|
|
1784
|
+
requestOptions
|
|
1785
|
+
),
|
|
1786
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1787
|
+
]);
|
|
1788
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1735
1789
|
ip_address: request.ipAddress,
|
|
1736
1790
|
user_id: request.customerId,
|
|
1737
1791
|
event_type: "login",
|
|
1738
1792
|
device_fingerprint: request.deviceFingerprint
|
|
1739
|
-
}, requestOptions)
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1793
|
+
}, requestOptions);
|
|
1794
|
+
} else {
|
|
1795
|
+
[, geoVerification, profileResult] = await Promise.all([
|
|
1796
|
+
Promise.resolve(void 0),
|
|
1797
|
+
this.geoClient.verifyIP({
|
|
1798
|
+
ip_address: request.ipAddress,
|
|
1799
|
+
user_id: request.customerId,
|
|
1800
|
+
event_type: "login",
|
|
1801
|
+
device_fingerprint: request.deviceFingerprint
|
|
1802
|
+
}, requestOptions),
|
|
1803
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1804
|
+
]);
|
|
1805
|
+
}
|
|
1806
|
+
const loginBlockReasons = this.getBlockReasons(geoVerification, profileResult, cipherTextResult);
|
|
1743
1807
|
const isBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
|
|
1744
1808
|
if (isBlocked && !profileResult) {
|
|
1745
1809
|
return {
|
|
@@ -1823,23 +1887,39 @@ var ComplianceClient = class {
|
|
|
1823
1887
|
currency: request.currency
|
|
1824
1888
|
});
|
|
1825
1889
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1890
|
+
let cipherTextResult;
|
|
1891
|
+
let geoVerification;
|
|
1892
|
+
let profileResult;
|
|
1893
|
+
if (request.cipherText) {
|
|
1894
|
+
[cipherTextResult, profileResult] = await Promise.all([
|
|
1895
|
+
this.executeCipherTextValidation(
|
|
1896
|
+
request.cipherText,
|
|
1897
|
+
request.customerId,
|
|
1898
|
+
"transaction",
|
|
1899
|
+
request.ipAddress,
|
|
1900
|
+
void 0,
|
|
1901
|
+
requestOptions
|
|
1902
|
+
),
|
|
1903
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1904
|
+
]);
|
|
1905
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1836
1906
|
ip_address: request.ipAddress,
|
|
1837
1907
|
user_id: request.customerId,
|
|
1838
1908
|
event_type: "transaction",
|
|
1839
1909
|
device_fingerprint: request.deviceFingerprint
|
|
1840
|
-
}, requestOptions)
|
|
1841
|
-
|
|
1842
|
-
|
|
1910
|
+
}, requestOptions);
|
|
1911
|
+
} else {
|
|
1912
|
+
[, geoVerification, profileResult] = await Promise.all([
|
|
1913
|
+
Promise.resolve(void 0),
|
|
1914
|
+
this.geoClient.verifyIP({
|
|
1915
|
+
ip_address: request.ipAddress,
|
|
1916
|
+
user_id: request.customerId,
|
|
1917
|
+
event_type: "transaction",
|
|
1918
|
+
device_fingerprint: request.deviceFingerprint
|
|
1919
|
+
}, requestOptions),
|
|
1920
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1921
|
+
]);
|
|
1922
|
+
}
|
|
1843
1923
|
const geoBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
|
|
1844
1924
|
if (geoBlocked && !profileResult) {
|
|
1845
1925
|
return {
|
|
@@ -1858,6 +1938,9 @@ var ComplianceClient = class {
|
|
|
1858
1938
|
cipherTextValidation: cipherTextResult
|
|
1859
1939
|
};
|
|
1860
1940
|
}
|
|
1941
|
+
if (!profileResult) {
|
|
1942
|
+
throw new ComplianceError("Customer profile not found", request.customerId);
|
|
1943
|
+
}
|
|
1861
1944
|
const profile = profileResult;
|
|
1862
1945
|
const transactionRisk = this.calculateTransactionRisk(
|
|
1863
1946
|
request.amount,
|
|
@@ -1900,22 +1983,31 @@ var ComplianceClient = class {
|
|
|
1900
1983
|
async verifyEvent(request, requestOptions) {
|
|
1901
1984
|
const startTime = Date.now();
|
|
1902
1985
|
this.validateEventRequest(request);
|
|
1903
|
-
|
|
1904
|
-
|
|
1986
|
+
let cipherTextResult;
|
|
1987
|
+
let geoVerification;
|
|
1988
|
+
if (request.cipherText) {
|
|
1989
|
+
cipherTextResult = await this.executeCipherTextValidation(
|
|
1905
1990
|
request.cipherText,
|
|
1906
1991
|
request.customerId,
|
|
1907
1992
|
request.eventType,
|
|
1908
1993
|
request.ipAddress,
|
|
1909
1994
|
void 0,
|
|
1910
1995
|
requestOptions
|
|
1911
|
-
)
|
|
1912
|
-
this.geoClient.verifyIP({
|
|
1996
|
+
);
|
|
1997
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1913
1998
|
ip_address: request.ipAddress,
|
|
1914
1999
|
user_id: request.customerId,
|
|
1915
2000
|
event_type: request.eventType,
|
|
1916
2001
|
device_fingerprint: request.deviceFingerprint
|
|
1917
|
-
}, requestOptions)
|
|
1918
|
-
|
|
2002
|
+
}, requestOptions);
|
|
2003
|
+
} else {
|
|
2004
|
+
geoVerification = await this.geoClient.verifyIP({
|
|
2005
|
+
ip_address: request.ipAddress,
|
|
2006
|
+
user_id: request.customerId,
|
|
2007
|
+
event_type: request.eventType,
|
|
2008
|
+
device_fingerprint: request.deviceFingerprint
|
|
2009
|
+
}, requestOptions);
|
|
2010
|
+
}
|
|
1919
2011
|
if (this.config.autoCreateProfiles) {
|
|
1920
2012
|
try {
|
|
1921
2013
|
const profile = await this.riskClient.getProfile(request.customerId, requestOptions);
|
|
@@ -1929,7 +2021,7 @@ var ComplianceClient = class {
|
|
|
1929
2021
|
}
|
|
1930
2022
|
}
|
|
1931
2023
|
const cipherTextBlocked = cipherTextResult ? !cipherTextResult.valid || cipherTextResult.risk?.is_blocked === true : false;
|
|
1932
|
-
const blockReasons = [...geoVerification.risk_reasons];
|
|
2024
|
+
const blockReasons = [...geoVerification.risk_reasons ?? []];
|
|
1933
2025
|
if (cipherTextResult) {
|
|
1934
2026
|
if (!cipherTextResult.valid) {
|
|
1935
2027
|
blockReasons.push("ciphertext_validation_failed");
|
|
@@ -1998,6 +2090,44 @@ var ComplianceClient = class {
|
|
|
1998
2090
|
return void 0;
|
|
1999
2091
|
}
|
|
2000
2092
|
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Build a LocationVerification from a ValidateCipherTextResponse.
|
|
2095
|
+
* The validate-ciphertext endpoint now returns the full geo-verification data
|
|
2096
|
+
* (is_compliant, jurisdiction, geofence_evaluation, record_id, gps_required),
|
|
2097
|
+
* so a separate verifyIP call is unnecessary.
|
|
2098
|
+
*/
|
|
2099
|
+
buildLocationFromCipherText(ct, ipAddress) {
|
|
2100
|
+
const loc = ct.location;
|
|
2101
|
+
const risk = ct.risk;
|
|
2102
|
+
if (!risk) return null;
|
|
2103
|
+
return {
|
|
2104
|
+
ip_address: ct.ip_address || ipAddress,
|
|
2105
|
+
location: {
|
|
2106
|
+
country: loc?.country ?? "",
|
|
2107
|
+
country_iso: loc?.country_iso ?? "",
|
|
2108
|
+
city: loc?.city ?? "",
|
|
2109
|
+
region: loc?.region ?? "",
|
|
2110
|
+
postal_code: "",
|
|
2111
|
+
latitude: loc?.latitude ?? 0,
|
|
2112
|
+
longitude: loc?.longitude ?? 0,
|
|
2113
|
+
timezone: "",
|
|
2114
|
+
is_vpn: risk.is_vpn,
|
|
2115
|
+
is_proxy: risk.is_proxy,
|
|
2116
|
+
is_tor: risk.is_tor,
|
|
2117
|
+
is_hosting: risk.is_hosting ?? false,
|
|
2118
|
+
is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
|
|
2119
|
+
},
|
|
2120
|
+
is_compliant: ct.is_compliant ?? !risk.is_blocked,
|
|
2121
|
+
is_blocked: risk.is_blocked,
|
|
2122
|
+
risk_level: risk.level,
|
|
2123
|
+
risk_score: risk.score,
|
|
2124
|
+
risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
|
|
2125
|
+
jurisdiction: ct.jurisdiction,
|
|
2126
|
+
geofence_evaluation: ct.geofence_evaluation,
|
|
2127
|
+
record_id: ct.record_id ?? "",
|
|
2128
|
+
gps_required: ct.gps_required
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2001
2131
|
calculateTransactionRisk(amount, currency, geoVerification, profile, cipherTextResult) {
|
|
2002
2132
|
if (!this._currencyRatesCustomized && !this._currencyRatesWarned) {
|
|
2003
2133
|
this._currencyRatesWarned = true;
|
|
@@ -2068,13 +2198,15 @@ var ComplianceClient = class {
|
|
|
2068
2198
|
getBlockReasons(geoVerification, profile, cipherTextResult) {
|
|
2069
2199
|
const reasons = [];
|
|
2070
2200
|
if (geoVerification.is_blocked) {
|
|
2071
|
-
reasons.push(...geoVerification.risk_reasons);
|
|
2201
|
+
reasons.push(...geoVerification.risk_reasons ?? []);
|
|
2072
2202
|
}
|
|
2073
|
-
if (profile
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2203
|
+
if (profile) {
|
|
2204
|
+
if (profile.customer_status === "suspended") {
|
|
2205
|
+
reasons.push("account_suspended");
|
|
2206
|
+
}
|
|
2207
|
+
if (profile.has_sanctions) {
|
|
2208
|
+
reasons.push("sanctions_match");
|
|
2209
|
+
}
|
|
2078
2210
|
}
|
|
2079
2211
|
if (cipherTextResult) {
|
|
2080
2212
|
if (!cipherTextResult.valid) {
|