@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 +20 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pulse.ts +37 -15
package/dist/index.mjs
CHANGED
|
@@ -1362,7 +1362,8 @@ async function extractFeatures(data) {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
const audioFeatures = await extractSpeakerFeatures(data.audio);
|
|
1364
1364
|
const hasMotion = data.motion.length >= MIN_MOTION_SAMPLES;
|
|
1365
|
-
const
|
|
1365
|
+
const hasTouch = data.touch.length >= MIN_TOUCH_SAMPLES;
|
|
1366
|
+
const motionFeatures = hasMotion && hasTouch ? extractMouseDynamics(data.touch) : hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
|
|
1366
1367
|
const touchFeatures = extractTouchFeatures(data.touch);
|
|
1367
1368
|
return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
|
|
1368
1369
|
}
|
|
@@ -1392,6 +1393,15 @@ async function processSensorData(sensorData, config, wallet, connection) {
|
|
|
1392
1393
|
error: "No voice data detected. Please speak the phrase clearly during capture."
|
|
1393
1394
|
};
|
|
1394
1395
|
}
|
|
1396
|
+
const hasPreviousData = loadVerificationData() !== null;
|
|
1397
|
+
if (hasPreviousData && !hasMotion && !hasTouch) {
|
|
1398
|
+
return {
|
|
1399
|
+
success: false,
|
|
1400
|
+
commitment: new Uint8Array(32),
|
|
1401
|
+
isFirstVerification: false,
|
|
1402
|
+
error: "Insufficient sensor data for re-verification. Please trace the curve and allow motion access."
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1395
1405
|
const features = await extractFeatures(sensorData);
|
|
1396
1406
|
const nonZero = features.filter((v) => v !== 0).length;
|
|
1397
1407
|
console.log(
|
|
@@ -1634,15 +1644,6 @@ var PulseSDK = class {
|
|
|
1634
1644
|
try {
|
|
1635
1645
|
const session = this.createSession(touchElement);
|
|
1636
1646
|
const stopPromises = [];
|
|
1637
|
-
try {
|
|
1638
|
-
await session.startAudio();
|
|
1639
|
-
stopPromises.push(
|
|
1640
|
-
new Promise((r) => setTimeout(r, DEFAULT_CAPTURE_MS)).then(() => session.stopAudio()).then(() => {
|
|
1641
|
-
})
|
|
1642
|
-
);
|
|
1643
|
-
} catch (err) {
|
|
1644
|
-
throw new Error(`Audio capture failed: ${err?.message ?? "microphone unavailable"}`);
|
|
1645
|
-
}
|
|
1646
1647
|
try {
|
|
1647
1648
|
await session.startMotion();
|
|
1648
1649
|
} catch {
|
|
@@ -1653,6 +1654,15 @@ var PulseSDK = class {
|
|
|
1653
1654
|
})
|
|
1654
1655
|
);
|
|
1655
1656
|
}
|
|
1657
|
+
try {
|
|
1658
|
+
await session.startAudio();
|
|
1659
|
+
stopPromises.push(
|
|
1660
|
+
new Promise((r) => setTimeout(r, DEFAULT_CAPTURE_MS)).then(() => session.stopAudio()).then(() => {
|
|
1661
|
+
})
|
|
1662
|
+
);
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
throw new Error(`Audio capture failed: ${err?.message ?? "microphone unavailable"}`);
|
|
1665
|
+
}
|
|
1656
1666
|
if (touchElement) {
|
|
1657
1667
|
try {
|
|
1658
1668
|
await session.startTouch();
|