@iam-protocol/pulse-sdk 0.3.6 → 0.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iam-protocol/pulse-sdk",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "Client-side SDK for IAM Protocol — sensor capture, TBH generation, ZK proof construction",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/pulse.ts CHANGED
@@ -40,9 +40,18 @@ async function extractFeatures(data: SensorData): Promise<number[]> {
40
40
  const audioFeatures = await extractSpeakerFeatures(data.audio);
41
41
 
42
42
  const hasMotion = data.motion.length >= MIN_MOTION_SAMPLES;
43
- const motionFeatures = hasMotion
44
- ? extractMotionFeatures(data.motion)
45
- : extractMouseDynamics(data.touch);
43
+ const hasTouch = data.touch.length >= MIN_TOUCH_SAMPLES;
44
+
45
+ // On mobile (both IMU and touch available), use touch/pointer dynamics for
46
+ // kinematic features. Stationary IMU reads constant gravity — the derivatives
47
+ // are near-zero and produce identical features across sessions. Finger tracing
48
+ // has natural inter-session variance because no two paths are identical.
49
+ const motionFeatures =
50
+ hasMotion && hasTouch
51
+ ? extractMouseDynamics(data.touch)
52
+ : hasMotion
53
+ ? extractMotionFeatures(data.motion)
54
+ : extractMouseDynamics(data.touch);
46
55
 
47
56
  const touchFeatures = extractTouchFeatures(data.touch);
48
57
  return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
@@ -160,13 +169,25 @@ async function processSensorData(
160
169
  };
161
170
  }
162
171
 
163
- const { proof, publicSignals } = await generateProof(
164
- circuitInput,
165
- wasmPath,
166
- zkeyPath
167
- );
168
-
169
- solanaProof = serializeProof(proof, publicSignals);
172
+ try {
173
+ const { proof, publicSignals } = await generateProof(
174
+ circuitInput,
175
+ wasmPath,
176
+ zkeyPath
177
+ );
178
+ solanaProof = serializeProof(proof, publicSignals);
179
+ } catch (proofErr: any) {
180
+ // Include diagnostics in error for mobile debugging (no devtools)
181
+ const audioNZ = features.slice(0, 44).filter((v) => v !== 0).length;
182
+ const motionNZ = features.slice(44, 98).filter((v) => v !== 0).length;
183
+ const touchNZ = features.slice(98, 134).filter((v) => v !== 0).length;
184
+ return {
185
+ success: false,
186
+ commitment: tbh.commitmentBytes,
187
+ isFirstVerification: false,
188
+ error: `Proof failed (distance=${distance}, audio=${audioNZ}/44, motion=${motionNZ}/54, touch=${touchNZ}/36): ${proofErr?.message ?? proofErr}`,
189
+ };
190
+ }
170
191
  }
171
192
 
172
193
  // Submit