vesant-sdk 1.7.0 → 1.7.1-dev.301c6df
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-DtH2RLuy.d.ts → client-B3DCAHlg.d.ts} +2 -2
- package/dist/{client-DrjgZoH_.d.mts → client-BwXMQA2a.d.mts} +64 -42
- package/dist/{client-B0qhE2kr.d.mts → client-D23KhWeh.d.mts} +2 -2
- package/dist/{client-DF7hlMEz.d.ts → client-fy3trF2K.d.ts} +64 -42
- package/dist/{client-BolQlL5e.d.mts → client-q9fN8Hhf.d.mts} +103 -1
- package/dist/{client-BolQlL5e.d.ts → client-q9fN8Hhf.d.ts} +103 -1
- package/dist/compliance/index.d.mts +3 -3
- package/dist/compliance/index.d.ts +3 -3
- package/dist/compliance/index.js +181 -91
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +181 -91
- 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 +69 -8
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +69 -8
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +68 -7
- package/dist/geolocation/index.d.ts +68 -7
- package/dist/geolocation/index.js +186 -91
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +183 -92
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-C3zUKydT.d.mts +264 -0
- package/dist/index-DSDgS09k.d.ts +264 -0
- package/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.js +354 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +346 -121
- 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 +75 -14
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +75 -14
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +4 -4
- package/dist/kyc/index.d.ts +4 -4
- package/dist/kyc/index.js +75 -14
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +75 -14
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +7 -3
- package/dist/react.d.ts +7 -3
- package/dist/react.js +70 -33
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +70 -33
- 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 +69 -8
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +69 -8
- 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 +69 -8
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +69 -8
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +2 -2
- package/dist/tax/index.d.ts +2 -2
- package/dist/tax/index.js +74 -10
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +74 -10
- 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
package/dist/react.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createRoot } from 'react-dom/client';
|
|
|
4
4
|
// src/geolocation/hooks.ts
|
|
5
5
|
|
|
6
6
|
// src/core/version.ts
|
|
7
|
-
var SDK_VERSION = "1.7.
|
|
7
|
+
var SDK_VERSION = "1.7.1";
|
|
8
8
|
|
|
9
9
|
// src/core/errors.ts
|
|
10
10
|
var VesantError = class _VesantError extends Error {
|
|
@@ -87,27 +87,63 @@ function getBrowserInfo() {
|
|
|
87
87
|
return { browser, browser_version: browserVersion, os, os_version: osVersion };
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// src/geolocation/
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
// src/geolocation/integrity.ts
|
|
91
|
+
var isNil = (v) => v === null || v === void 0;
|
|
92
|
+
function assessGpsIntegrity(input, opts = {}) {
|
|
93
|
+
const flags = [];
|
|
94
|
+
const now = opts.now ?? (() => Date.now());
|
|
95
|
+
const maxAgeMs = opts.maxAgeMs ?? 6e4;
|
|
96
|
+
const minAccuracy = opts.minAccuracyMeters ?? 1;
|
|
97
|
+
const { accuracy, altitude, altitudeAccuracy, heading, speed, timestamp } = input;
|
|
98
|
+
if (isNil(accuracy)) {
|
|
99
|
+
flags.push("accuracy_missing");
|
|
100
|
+
} else if (accuracy === 0) {
|
|
101
|
+
flags.push("accuracy_zero");
|
|
102
|
+
} else if (accuracy < minAccuracy) {
|
|
103
|
+
flags.push("accuracy_implausibly_small");
|
|
104
|
+
}
|
|
105
|
+
const hasMotion = !isNil(heading) || !isNil(speed);
|
|
106
|
+
if (hasMotion && (isNil(accuracy) || accuracy === 0)) {
|
|
107
|
+
flags.push("motion_without_accuracy");
|
|
108
|
+
}
|
|
109
|
+
if (!isNil(altitude) && isNil(altitudeAccuracy)) {
|
|
110
|
+
flags.push("altitude_without_accuracy");
|
|
111
|
+
}
|
|
112
|
+
if (timestamp !== void 0 && now() - timestamp > maxAgeMs) {
|
|
113
|
+
flags.push("stale_timestamp");
|
|
114
|
+
}
|
|
115
|
+
if (opts.permissionState === "denied" || opts.permissionState === "prompt") {
|
|
116
|
+
flags.push(`permission_${opts.permissionState}`);
|
|
117
|
+
}
|
|
118
|
+
return { suspicious: flags.length > 0, flags };
|
|
119
|
+
}
|
|
120
|
+
function gpsIntegrityInputFromPosition(position) {
|
|
121
|
+
const c = position.coords;
|
|
122
|
+
return {
|
|
123
|
+
latitude: c.latitude,
|
|
124
|
+
longitude: c.longitude,
|
|
125
|
+
accuracy: c.accuracy,
|
|
126
|
+
altitude: c.altitude,
|
|
127
|
+
altitudeAccuracy: c.altitudeAccuracy,
|
|
128
|
+
heading: c.heading,
|
|
129
|
+
speed: c.speed,
|
|
130
|
+
timestamp: position.timestamp
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async function probeGeolocationPermission() {
|
|
134
|
+
try {
|
|
135
|
+
if (typeof navigator === "undefined" || !navigator.permissions?.query) {
|
|
136
|
+
return "unavailable";
|
|
137
|
+
}
|
|
138
|
+
const status = await navigator.permissions.query({ name: "geolocation" });
|
|
139
|
+
return status.state;
|
|
140
|
+
} catch {
|
|
141
|
+
return "unavailable";
|
|
107
142
|
}
|
|
108
|
-
const { createHmac } = await import('crypto');
|
|
109
|
-
return createHmac("sha256", key).update(message).digest("hex");
|
|
110
143
|
}
|
|
144
|
+
|
|
145
|
+
// src/geolocation/ciphertext.ts
|
|
146
|
+
var CIPHER_TEXT_EXPIRY_MINUTES = 5;
|
|
111
147
|
function getWebGLInfo() {
|
|
112
148
|
if (typeof document === "undefined") return null;
|
|
113
149
|
try {
|
|
@@ -139,6 +175,7 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
139
175
|
if (typeof navigator === "undefined" || !navigator.geolocation) {
|
|
140
176
|
return null;
|
|
141
177
|
}
|
|
178
|
+
const permissionState = await probeGeolocationPermission();
|
|
142
179
|
return new Promise((resolve) => {
|
|
143
180
|
navigator.geolocation.getCurrentPosition(
|
|
144
181
|
(position) => {
|
|
@@ -155,6 +192,7 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
155
192
|
resolve(null);
|
|
156
193
|
return;
|
|
157
194
|
}
|
|
195
|
+
const { flags } = assessGpsIntegrity(gpsIntegrityInputFromPosition(position), { permissionState });
|
|
158
196
|
resolve({
|
|
159
197
|
latitude,
|
|
160
198
|
longitude,
|
|
@@ -163,7 +201,8 @@ async function requestGPSLocation(timeout = 1e4, highAccuracy = true) {
|
|
|
163
201
|
altitude_accuracy: position.coords.altitudeAccuracy ?? void 0,
|
|
164
202
|
heading: position.coords.heading ?? void 0,
|
|
165
203
|
speed: position.coords.speed ?? void 0,
|
|
166
|
-
timestamp: position.timestamp
|
|
204
|
+
timestamp: position.timestamp,
|
|
205
|
+
integrity_flags: flags.length ? flags : void 0
|
|
167
206
|
});
|
|
168
207
|
},
|
|
169
208
|
() => {
|
|
@@ -230,6 +269,9 @@ async function generateCipherText(options, config) {
|
|
|
230
269
|
);
|
|
231
270
|
if (location) {
|
|
232
271
|
locationData = location;
|
|
272
|
+
if (location.integrity_flags?.length) {
|
|
273
|
+
warnings.push(`GPS integrity flags (advisory): ${location.integrity_flags.join(", ")}`);
|
|
274
|
+
}
|
|
233
275
|
} else if (gpsRequiredByConfig) {
|
|
234
276
|
throw new VesantError(
|
|
235
277
|
`GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied`,
|
|
@@ -259,15 +301,7 @@ async function generateCipherText(options, config) {
|
|
|
259
301
|
};
|
|
260
302
|
const encoded = encodePayload(payload);
|
|
261
303
|
const timestamp = now.getTime().toString(36);
|
|
262
|
-
|
|
263
|
-
const hmacKey = options.signingKey || options.apiKey;
|
|
264
|
-
if (hmacKey) {
|
|
265
|
-
const message = `02.${timestamp}.${encoded}`;
|
|
266
|
-
const hmac = await computeHMAC(hmacKey, message);
|
|
267
|
-
cipherText = `${message}.${hmac}`;
|
|
268
|
-
} else {
|
|
269
|
-
cipherText = `01.${timestamp}.${encoded}`;
|
|
270
|
-
}
|
|
304
|
+
const cipherText = `01.${timestamp}.${encoded}`;
|
|
271
305
|
return {
|
|
272
306
|
cipherText,
|
|
273
307
|
locationCaptured: !!locationData,
|
|
@@ -332,8 +366,6 @@ function useGeolocation(client, options = {}) {
|
|
|
332
366
|
if (optionsRef.current.autoVerify) {
|
|
333
367
|
const detectAndVerify = async () => {
|
|
334
368
|
try {
|
|
335
|
-
const ipResponse = await fetch("https://api.ipify.org?format=json");
|
|
336
|
-
const { ip } = await ipResponse.json();
|
|
337
369
|
let deviceFingerprint;
|
|
338
370
|
if (optionsRef.current.includeDeviceFingerprint && typeof window !== "undefined") {
|
|
339
371
|
const deviceId = generateDeviceId();
|
|
@@ -347,7 +379,6 @@ function useGeolocation(client, options = {}) {
|
|
|
347
379
|
};
|
|
348
380
|
}
|
|
349
381
|
await verifyIP({
|
|
350
|
-
ip_address: ip,
|
|
351
382
|
user_id: optionsRef.current.userId || "",
|
|
352
383
|
event_type: optionsRef.current.eventType || "page_view",
|
|
353
384
|
device_fingerprint: deviceFingerprint
|
|
@@ -661,6 +692,12 @@ function useLocationCapture(client, options) {
|
|
|
661
692
|
if (accuracy !== null && accuracy !== void 0 && accuracy > 0) {
|
|
662
693
|
capture.accuracy = accuracy;
|
|
663
694
|
}
|
|
695
|
+
const { flags } = assessGpsIntegrity(gpsIntegrityInputFromPosition(position), {
|
|
696
|
+
permissionState: await probeGeolocationPermission()
|
|
697
|
+
});
|
|
698
|
+
if (flags.length) {
|
|
699
|
+
capture.integrity_flags = flags;
|
|
700
|
+
}
|
|
664
701
|
}
|
|
665
702
|
}
|
|
666
703
|
if (gpsError) {
|