@iam-protocol/pulse-sdk 0.2.0 → 0.2.1

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.2.0",
3
+ "version": "0.2.1",
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",
@@ -54,3 +54,32 @@ export function generateLissajousPoints(params: LissajousParams): Point2D[] {
54
54
 
55
55
  return result;
56
56
  }
57
+
58
+ /**
59
+ * Generate a sequence of Lissajous curves for dynamic mid-session switching.
60
+ * Each curve uses different parameters, preventing pre-computation.
61
+ */
62
+ export function generateLissajousSequence(
63
+ count: number = 2
64
+ ): { params: LissajousParams; points: Point2D[] }[] {
65
+ const allRatios: [number, number][] = [
66
+ [1, 2], [2, 3], [3, 4], [3, 5], [4, 5],
67
+ [1, 3], [2, 5], [5, 6], [3, 7], [4, 7],
68
+ ];
69
+
70
+ const shuffled = [...allRatios].sort(() => Math.random() - 0.5);
71
+ const sequence: { params: LissajousParams; points: Point2D[] }[] = [];
72
+
73
+ for (let i = 0; i < count; i++) {
74
+ const pair = shuffled[i % shuffled.length]!;
75
+ const params: LissajousParams = {
76
+ a: pair[0],
77
+ b: pair[1],
78
+ delta: Math.PI * (0.1 + Math.random() * 0.8),
79
+ points: 200,
80
+ };
81
+ sequence.push({ params, points: generateLissajousPoints(params) });
82
+ }
83
+
84
+ return sequence;
85
+ }
@@ -17,7 +17,7 @@ const SYLLABLES = [
17
17
  export function generatePhrase(wordCount: number = 5): string {
18
18
  const words: string[] = [];
19
19
  for (let w = 0; w < wordCount; w++) {
20
- const syllableCount = 2 + Math.floor(Math.random() * 2); // 2-3 syllables per word
20
+ const syllableCount = 2 + Math.floor(Math.random() * 2);
21
21
  let word = "";
22
22
  for (let s = 0; s < syllableCount; s++) {
23
23
  const idx = Math.floor(Math.random() * SYLLABLES.length);
@@ -27,3 +27,36 @@ export function generatePhrase(wordCount: number = 5): string {
27
27
  }
28
28
  return words.join(" ");
29
29
  }
30
+
31
+ /**
32
+ * Generate a sequence of phrases for dynamic mid-session switching.
33
+ * Each phrase uses a different syllable subset to prevent pre-computation.
34
+ */
35
+ export function generatePhraseSequence(
36
+ count: number = 3,
37
+ wordCount: number = 4
38
+ ): string[] {
39
+ const subsetSize = Math.floor(SYLLABLES.length / count);
40
+ const phrases: string[] = [];
41
+
42
+ for (let p = 0; p < count; p++) {
43
+ const start = (p * subsetSize) % SYLLABLES.length;
44
+ const subset = [
45
+ ...SYLLABLES.slice(start, start + subsetSize),
46
+ ...SYLLABLES.slice(0, Math.max(0, (start + subsetSize) - SYLLABLES.length)),
47
+ ];
48
+
49
+ const words: string[] = [];
50
+ for (let w = 0; w < wordCount; w++) {
51
+ const syllableCount = 2 + Math.floor(Math.random() * 2);
52
+ let word = "";
53
+ for (let s = 0; s < syllableCount; s++) {
54
+ word += subset[Math.floor(Math.random() * subset.length)];
55
+ }
56
+ words.push(word);
57
+ }
58
+ phrases.push(words.join(" "));
59
+ }
60
+
61
+ return phrases;
62
+ }
package/src/index.ts CHANGED
@@ -38,6 +38,6 @@ export { fetchIdentityState, storeVerificationData, loadVerificationData } from
38
38
  export type { AudioCapture, MotionSample, TouchSample, SensorData, CaptureOptions, CaptureStage, StageState } from "./sensor/types";
39
39
 
40
40
  // Challenge
41
- export { generatePhrase } from "./challenge/phrase";
42
- export { randomLissajousParams, generateLissajousPoints } from "./challenge/lissajous";
41
+ export { generatePhrase, generatePhraseSequence } from "./challenge/phrase";
42
+ export { randomLissajousParams, generateLissajousPoints, generateLissajousSequence } from "./challenge/lissajous";
43
43
  export type { LissajousParams, Point2D } from "./challenge/lissajous";