vesant-sdk 1.7.0-dev.6f300f7 → 1.7.0-dev.6f4bf05
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-D9JZgN3X.d.ts → client-0NOPDnT0.d.ts} +15 -25
- package/dist/{client-BG8KtVMc.d.mts → client-CvWNRwwg.d.mts} +15 -25
- package/dist/{client-CRZea-eJ.d.mts → client-Dps40EtF.d.mts} +1 -1
- package/dist/{client-749WqhDT.d.ts → client-SMxqod4j.d.ts} +1 -1
- package/dist/compliance/index.d.mts +2 -2
- package/dist/compliance/index.d.ts +2 -2
- package/dist/compliance/index.js +71 -12
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +71 -12
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.js +6 -0
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +6 -0
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +58 -3
- package/dist/geolocation/index.d.ts +58 -3
- package/dist/geolocation/index.js +74 -12
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +72 -13
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-CPOrMRaH.d.ts +264 -0
- package/dist/index-CimDmgZb.d.mts +264 -0
- package/dist/index.d.mts +23 -6
- package/dist/index.d.ts +23 -6
- package/dist/index.js +186 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -34
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.js +6 -0
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +6 -0
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.js +6 -0
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +6 -0
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +6 -2
- package/dist/react.d.ts +6 -2
- package/dist/react.js +68 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +68 -4
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.js +6 -0
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +6 -0
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.js +6 -0
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +6 -0
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.js +6 -0
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +6 -0
- package/dist/tax/index.mjs.map +1 -1
- package/dist/webhooks/index.d.mts +2 -189
- package/dist/webhooks/index.d.ts +2 -189
- package/dist/webhooks/index.js +85 -21
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/index.mjs +85 -22
- package/dist/webhooks/index.mjs.map +1 -1
- package/package.json +4 -1
|
@@ -392,6 +392,12 @@ var BaseClient = class {
|
|
|
392
392
|
if (!config.tenantId?.trim()) {
|
|
393
393
|
throw new ValidationError("tenantId is required and must be a non-empty string", ["tenantId"]);
|
|
394
394
|
}
|
|
395
|
+
if (typeof fetch === "undefined") {
|
|
396
|
+
throw new VesantError(
|
|
397
|
+
"The Vesant SDK requires a global fetch (Node.js >= 18). Upgrade Node or provide a fetch polyfill.",
|
|
398
|
+
"RUNTIME_UNSUPPORTED"
|
|
399
|
+
);
|
|
400
|
+
}
|
|
395
401
|
this.interceptors = config.interceptors || [];
|
|
396
402
|
this.logger = config.logger || createConsoleLogger();
|
|
397
403
|
let environment = config.environment;
|
|
@@ -736,6 +742,61 @@ var BaseClient = class {
|
|
|
736
742
|
}
|
|
737
743
|
};
|
|
738
744
|
|
|
745
|
+
// src/geolocation/integrity.ts
|
|
746
|
+
var isNil = (v) => v === null || v === void 0;
|
|
747
|
+
function assessGpsIntegrity(input, opts = {}) {
|
|
748
|
+
const flags = [];
|
|
749
|
+
const now = opts.now ?? (() => Date.now());
|
|
750
|
+
const maxAgeMs = opts.maxAgeMs ?? 6e4;
|
|
751
|
+
const minAccuracy = opts.minAccuracyMeters ?? 1;
|
|
752
|
+
const { accuracy, altitude, altitudeAccuracy, heading, speed, timestamp } = input;
|
|
753
|
+
if (isNil(accuracy)) {
|
|
754
|
+
flags.push("accuracy_missing");
|
|
755
|
+
} else if (accuracy === 0) {
|
|
756
|
+
flags.push("accuracy_zero");
|
|
757
|
+
} else if (accuracy < minAccuracy) {
|
|
758
|
+
flags.push("accuracy_implausibly_small");
|
|
759
|
+
}
|
|
760
|
+
const hasMotion = !isNil(heading) || !isNil(speed);
|
|
761
|
+
if (hasMotion && (isNil(accuracy) || accuracy === 0)) {
|
|
762
|
+
flags.push("motion_without_accuracy");
|
|
763
|
+
}
|
|
764
|
+
if (!isNil(altitude) && isNil(altitudeAccuracy)) {
|
|
765
|
+
flags.push("altitude_without_accuracy");
|
|
766
|
+
}
|
|
767
|
+
if (timestamp !== void 0 && now() - timestamp > maxAgeMs) {
|
|
768
|
+
flags.push("stale_timestamp");
|
|
769
|
+
}
|
|
770
|
+
if (opts.permissionState === "denied" || opts.permissionState === "prompt") {
|
|
771
|
+
flags.push(`permission_${opts.permissionState}`);
|
|
772
|
+
}
|
|
773
|
+
return { suspicious: flags.length > 0, flags };
|
|
774
|
+
}
|
|
775
|
+
function gpsIntegrityInputFromPosition(position) {
|
|
776
|
+
const c = position.coords;
|
|
777
|
+
return {
|
|
778
|
+
latitude: c.latitude,
|
|
779
|
+
longitude: c.longitude,
|
|
780
|
+
accuracy: c.accuracy,
|
|
781
|
+
altitude: c.altitude,
|
|
782
|
+
altitudeAccuracy: c.altitudeAccuracy,
|
|
783
|
+
heading: c.heading,
|
|
784
|
+
speed: c.speed,
|
|
785
|
+
timestamp: position.timestamp
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
async function probeGeolocationPermission() {
|
|
789
|
+
try {
|
|
790
|
+
if (typeof navigator === "undefined" || !navigator.permissions?.query) {
|
|
791
|
+
return "unavailable";
|
|
792
|
+
}
|
|
793
|
+
const status = await navigator.permissions.query({ name: "geolocation" });
|
|
794
|
+
return status.state;
|
|
795
|
+
} catch {
|
|
796
|
+
return "unavailable";
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
739
800
|
// src/geolocation/ciphertext.ts
|
|
740
801
|
var CIPHER_TEXT_EXPIRY_MINUTES = 5;
|
|
741
802
|
async function computeHMAC(key, message) {
|
|
@@ -788,6 +849,7 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
788
849
|
if (typeof navigator === "undefined" || !navigator.geolocation) {
|
|
789
850
|
return null;
|
|
790
851
|
}
|
|
852
|
+
const permissionState = await probeGeolocationPermission();
|
|
791
853
|
return new Promise((resolve) => {
|
|
792
854
|
navigator.geolocation.getCurrentPosition(
|
|
793
855
|
(position) => {
|
|
@@ -804,6 +866,7 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
804
866
|
resolve(null);
|
|
805
867
|
return;
|
|
806
868
|
}
|
|
869
|
+
const { flags } = assessGpsIntegrity(gpsIntegrityInputFromPosition(position), { permissionState });
|
|
807
870
|
resolve({
|
|
808
871
|
latitude,
|
|
809
872
|
longitude,
|
|
@@ -812,7 +875,8 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
812
875
|
altitude_accuracy: position.coords.altitudeAccuracy ?? void 0,
|
|
813
876
|
heading: position.coords.heading ?? void 0,
|
|
814
877
|
speed: position.coords.speed ?? void 0,
|
|
815
|
-
timestamp: position.timestamp
|
|
878
|
+
timestamp: position.timestamp,
|
|
879
|
+
integrity_flags: flags.length ? flags : void 0
|
|
816
880
|
});
|
|
817
881
|
},
|
|
818
882
|
() => {
|
|
@@ -879,6 +943,9 @@ async function generateCipherText(options, config) {
|
|
|
879
943
|
);
|
|
880
944
|
if (location) {
|
|
881
945
|
locationData = location;
|
|
946
|
+
if (location.integrity_flags?.length) {
|
|
947
|
+
warnings.push(`GPS integrity flags (advisory): ${location.integrity_flags.join(", ")}`);
|
|
948
|
+
}
|
|
882
949
|
} else if (gpsRequiredByConfig) {
|
|
883
950
|
throw new VesantError(
|
|
884
951
|
`GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied`,
|
|
@@ -973,8 +1040,8 @@ var GeolocationClient = class extends BaseClient {
|
|
|
973
1040
|
* ```
|
|
974
1041
|
*/
|
|
975
1042
|
async verifyIP(request, requestOptions) {
|
|
976
|
-
if (!request.ip_address
|
|
977
|
-
throw new ValidationError("ip_address
|
|
1043
|
+
if (request.ip_address !== void 0 && !request.ip_address.trim()) {
|
|
1044
|
+
throw new ValidationError("ip_address, when provided, must be a non-empty string", ["ip_address"]);
|
|
978
1045
|
}
|
|
979
1046
|
return this.requestWithRetry("/api/v1/geo/verify", {
|
|
980
1047
|
method: "POST",
|
|
@@ -1324,20 +1391,12 @@ var GeolocationClient = class extends BaseClient {
|
|
|
1324
1391
|
*
|
|
1325
1392
|
* @example
|
|
1326
1393
|
* ```typescript
|
|
1327
|
-
* //
|
|
1394
|
+
* // GPS (the web SDK is GPS + IP only; the server handles the IP fallback)
|
|
1328
1395
|
* const result = await client.captureLocation(token, {
|
|
1329
1396
|
* latitude: 37.7749,
|
|
1330
1397
|
* longitude: -122.4194,
|
|
1331
1398
|
* accuracy: 10
|
|
1332
1399
|
* });
|
|
1333
|
-
*
|
|
1334
|
-
* // Using WiFi positioning (fallback)
|
|
1335
|
-
* const result = await client.captureLocation(token, {
|
|
1336
|
-
* wifi_networks: [
|
|
1337
|
-
* { macAddress: "00:11:22:33:44:55", signalStrength: -50 },
|
|
1338
|
-
* { macAddress: "AA:BB:CC:DD:EE:FF", signalStrength: -70 }
|
|
1339
|
-
* ]
|
|
1340
|
-
* });
|
|
1341
1400
|
* ```
|
|
1342
1401
|
*/
|
|
1343
1402
|
async captureLocation(token, capture, requestOptions) {
|