vesant-sdk 1.3.1 → 1.4.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/dist/compliance/index.js +23 -4
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +23 -4
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.js +10 -3
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +10 -3
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.js +23 -4
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +23 -4
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -4
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.js +10 -3
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +10 -3
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.js +10 -3
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +10 -3
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.js +21 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +21 -5
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.js +10 -3
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +10 -3
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.js +10 -3
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +10 -3
- package/dist/scores/index.mjs.map +1 -1
- package/package.json +1 -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
|
+
var SDK_VERSION = "1.4.0";
|
|
8
8
|
|
|
9
9
|
// src/shared/browser-utils.ts
|
|
10
10
|
function generateUUID() {
|
|
@@ -199,9 +199,13 @@ function encodePayload(payload) {
|
|
|
199
199
|
async function generateCipherText(options, config) {
|
|
200
200
|
const warnings = [];
|
|
201
201
|
let requestLocation = options.requestLocation ?? false;
|
|
202
|
+
let gpsRequiredByConfig = false;
|
|
202
203
|
if (config?.require_gps) {
|
|
203
204
|
const reason = options.reason;
|
|
204
205
|
if (reason === "login" && config.require_gps.login || reason === "registration" && config.require_gps.registration || reason === "transaction" && config.require_gps.transaction) {
|
|
206
|
+
if (!requestLocation) {
|
|
207
|
+
gpsRequiredByConfig = true;
|
|
208
|
+
}
|
|
205
209
|
requestLocation = true;
|
|
206
210
|
}
|
|
207
211
|
}
|
|
@@ -214,6 +218,10 @@ async function generateCipherText(options, config) {
|
|
|
214
218
|
);
|
|
215
219
|
if (location) {
|
|
216
220
|
locationData = location;
|
|
221
|
+
} else if (gpsRequiredByConfig) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied`
|
|
224
|
+
);
|
|
217
225
|
} else {
|
|
218
226
|
warnings.push("GPS location not available or permission denied");
|
|
219
227
|
}
|
|
@@ -368,18 +376,19 @@ function createDeviceFingerprint() {
|
|
|
368
376
|
};
|
|
369
377
|
}
|
|
370
378
|
function useCipherText(client) {
|
|
371
|
-
const [config, setConfig] = useState(void 0);
|
|
372
379
|
const [configLoading, setConfigLoading] = useState(!!client);
|
|
373
380
|
const [configError, setConfigError] = useState(null);
|
|
374
381
|
const configRef = useRef(void 0);
|
|
375
|
-
|
|
382
|
+
const configPromiseRef = useRef(null);
|
|
376
383
|
useEffect(() => {
|
|
377
384
|
if (!client) return;
|
|
378
385
|
let cancelled = false;
|
|
379
386
|
setConfigLoading(true);
|
|
380
|
-
client.getGPSConfig()
|
|
387
|
+
const promise = client.getGPSConfig();
|
|
388
|
+
configPromiseRef.current = promise;
|
|
389
|
+
promise.then((cfg) => {
|
|
381
390
|
if (!cancelled) {
|
|
382
|
-
|
|
391
|
+
configRef.current = cfg;
|
|
383
392
|
setConfigLoading(false);
|
|
384
393
|
}
|
|
385
394
|
}).catch((err) => {
|
|
@@ -395,6 +404,13 @@ function useCipherText(client) {
|
|
|
395
404
|
const generate = useCallback(
|
|
396
405
|
async (options) => {
|
|
397
406
|
try {
|
|
407
|
+
if (configPromiseRef.current) {
|
|
408
|
+
try {
|
|
409
|
+
const cfg = await configPromiseRef.current;
|
|
410
|
+
configRef.current = cfg;
|
|
411
|
+
} catch {
|
|
412
|
+
}
|
|
413
|
+
}
|
|
398
414
|
return await generateCipherText(options, configRef.current);
|
|
399
415
|
} catch (error) {
|
|
400
416
|
console.error("[CGS SDK] Failed to generate cipherText:", error);
|