@iam-protocol/pulse-sdk 0.3.5 → 0.3.7

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/index.js CHANGED
@@ -1441,7 +1441,8 @@ async function extractFeatures(data) {
1441
1441
  }
1442
1442
  const audioFeatures = await extractSpeakerFeatures(data.audio);
1443
1443
  const hasMotion = data.motion.length >= MIN_MOTION_SAMPLES;
1444
- const motionFeatures = hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1444
+ const hasTouch = data.touch.length >= MIN_TOUCH_SAMPLES;
1445
+ const motionFeatures = hasMotion && hasTouch ? extractMouseDynamics(data.touch) : hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1445
1446
  const touchFeatures = extractTouchFeatures(data.touch);
1446
1447
  return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
1447
1448
  }
@@ -1471,6 +1472,15 @@ async function processSensorData(sensorData, config, wallet, connection) {
1471
1472
  error: "No voice data detected. Please speak the phrase clearly during capture."
1472
1473
  };
1473
1474
  }
1475
+ const hasPreviousData = loadVerificationData() !== null;
1476
+ if (hasPreviousData && !hasMotion && !hasTouch) {
1477
+ return {
1478
+ success: false,
1479
+ commitment: new Uint8Array(32),
1480
+ isFirstVerification: false,
1481
+ error: "Insufficient sensor data for re-verification. Please trace the curve and allow motion access."
1482
+ };
1483
+ }
1474
1484
  const features = await extractFeatures(sensorData);
1475
1485
  const nonZero = features.filter((v) => v !== 0).length;
1476
1486
  console.log(
@@ -1713,15 +1723,6 @@ var PulseSDK = class {
1713
1723
  try {
1714
1724
  const session = this.createSession(touchElement);
1715
1725
  const stopPromises = [];
1716
- try {
1717
- await session.startAudio();
1718
- stopPromises.push(
1719
- new Promise((r) => setTimeout(r, DEFAULT_CAPTURE_MS)).then(() => session.stopAudio()).then(() => {
1720
- })
1721
- );
1722
- } catch (err) {
1723
- throw new Error(`Audio capture failed: ${err?.message ?? "microphone unavailable"}`);
1724
- }
1725
1726
  try {
1726
1727
  await session.startMotion();
1727
1728
  } catch {
@@ -1732,6 +1733,15 @@ var PulseSDK = class {
1732
1733
  })
1733
1734
  );
1734
1735
  }
1736
+ try {
1737
+ await session.startAudio();
1738
+ stopPromises.push(
1739
+ new Promise((r) => setTimeout(r, DEFAULT_CAPTURE_MS)).then(() => session.stopAudio()).then(() => {
1740
+ })
1741
+ );
1742
+ } catch (err) {
1743
+ throw new Error(`Audio capture failed: ${err?.message ?? "microphone unavailable"}`);
1744
+ }
1735
1745
  if (touchElement) {
1736
1746
  try {
1737
1747
  await session.startTouch();