@iam-protocol/pulse-sdk 0.2.2 → 0.2.3
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/pulse.ts +34 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13855,7 +13855,32 @@ function extractFeatures(data) {
|
|
|
13855
13855
|
const touchFeatures = extractTouchFeatures(data.touch);
|
|
13856
13856
|
return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
|
|
13857
13857
|
}
|
|
13858
|
+
var MIN_AUDIO_SAMPLES = 16e3;
|
|
13859
|
+
var MIN_MOTION_SAMPLES = 10;
|
|
13860
|
+
var MIN_TOUCH_SAMPLES = 10;
|
|
13858
13861
|
async function processSensorData(sensorData, config, wallet, connection) {
|
|
13862
|
+
const audioSamples = sensorData.audio?.samples.length ?? 0;
|
|
13863
|
+
const motionSamples = sensorData.motion.length;
|
|
13864
|
+
const touchSamples = sensorData.touch.length;
|
|
13865
|
+
const hasAudio = audioSamples >= MIN_AUDIO_SAMPLES;
|
|
13866
|
+
const hasMotion = motionSamples >= MIN_MOTION_SAMPLES;
|
|
13867
|
+
const hasTouch = touchSamples >= MIN_TOUCH_SAMPLES;
|
|
13868
|
+
if (!hasAudio && !hasMotion && !hasTouch) {
|
|
13869
|
+
return {
|
|
13870
|
+
success: false,
|
|
13871
|
+
commitment: new Uint8Array(32),
|
|
13872
|
+
isFirstVerification: true,
|
|
13873
|
+
error: "Insufficient behavioral data. Please speak the phrase and trace the curve during capture."
|
|
13874
|
+
};
|
|
13875
|
+
}
|
|
13876
|
+
if (!hasAudio) {
|
|
13877
|
+
return {
|
|
13878
|
+
success: false,
|
|
13879
|
+
commitment: new Uint8Array(32),
|
|
13880
|
+
isFirstVerification: true,
|
|
13881
|
+
error: "No voice data detected. Please speak the phrase clearly during capture."
|
|
13882
|
+
};
|
|
13883
|
+
}
|
|
13859
13884
|
const features = extractFeatures(sensorData);
|
|
13860
13885
|
const fingerprint = simhash(features);
|
|
13861
13886
|
const tbh = await generateTBH(fingerprint);
|
|
@@ -13902,7 +13927,7 @@ async function processSensorData(sensorData, config, wallet, connection) {
|
|
|
13902
13927
|
submission = await submitViaRelayer(
|
|
13903
13928
|
solanaProof ?? { proofBytes: new Uint8Array(0), publicInputs: [] },
|
|
13904
13929
|
tbh.commitmentBytes,
|
|
13905
|
-
{ relayerUrl: config.relayerUrl, isFirstVerification }
|
|
13930
|
+
{ relayerUrl: config.relayerUrl, apiKey: config.relayerApiKey, isFirstVerification }
|
|
13906
13931
|
);
|
|
13907
13932
|
} else {
|
|
13908
13933
|
return {
|