@@ -145,25 +145,168 @@ export function getRSCScrollTarget(animState: {
145145 return 'browser' ;
146146}
147147
148- // Determine scroll target for Exploit step
149- export function getExploitScrollTarget ( animState : {
150- phase : string ;
151- payloadSent : boolean ;
152- serverCompromised : boolean ;
148+ // Exploit trigger times interface (matches ExploitKeyframeTriggers)
149+ export interface ExploitTriggerTimes {
150+ craftsRequest : number ;
151+ normalPayload : number ;
152+ prototypePollution : number ;
153+ protoKey : number ;
154+ serverReceives : number ;
155+ goesWrong : number ;
156+ noValidation : number ;
157+ modifiesPrototype : number ;
158+ poisoned : number ;
159+ gadgetChain : number ;
160+ constructorAccess : number ;
161+ functionConstructor : number ;
162+ executeCode : number ;
163+ serverRuns : number ;
164+ whoamiRoot : number ;
165+ completeControl : number ;
166+ consequences : number ;
167+ }
168+
169+ // Default exploit triggers (fallback if whisper data not loaded)
170+ const DEFAULT_EXPLOIT_TRIGGERS : ExploitTriggerTimes = {
171+ craftsRequest : 3 ,
172+ normalPayload : 6 ,
173+ prototypePollution : 10 ,
174+ protoKey : 18 ,
175+ serverReceives : 25 ,
176+ goesWrong : 28 ,
177+ noValidation : 31 ,
178+ modifiesPrototype : 38 ,
179+ poisoned : 42 ,
180+ gadgetChain : 50 ,
181+ constructorAccess : 58 ,
182+ functionConstructor : 63 ,
183+ executeCode : 67 ,
184+ serverRuns : 71 ,
185+ whoamiRoot : 75 ,
186+ completeControl : 80 ,
187+ consequences : 83
188+ } ;
189+
190+ // Determine scroll target for Exploit step based on current time and trigger points
191+ // This is narration-aware: scroll targets match what the narrator is describing
192+ // Flow: Attacker Browser (crafting) → Network (sending) → Server (processing/poisoned/compromised) → Explanation (consequences)
193+ export function getExploitScrollTarget ( params : {
194+ currentTime : number ;
195+ triggers ?: ExploitTriggerTimes | null ;
153196} ) : ScrollTarget {
154- if ( ! animState . payloadSent ) {
155- return 'browser' ; // Attacker browser
197+ const { currentTime, triggers } = params ;
198+ const t = triggers ?? DEFAULT_EXPLOIT_TRIGGERS ;
199+
200+ // Phase 1: Attacker crafting payload (0 to protoKey)
201+ // User should see the attacker browser and payload being constructed
202+ if ( currentTime < t . protoKey ) {
203+ return 'browser' ;
156204 }
157205
158- if ( animState . payloadSent && ! animState . serverCompromised ) {
206+ // Phase 2: Packet traveling to server (protoKey to serverReceives)
207+ // Brief network phase as request travels
208+ if ( currentTime < t . serverReceives ) {
159209 return 'network' ;
160210 }
161211
162- if ( animState . serverCompromised ) {
212+ // Phase 3: Server processing, poisoning, and exploitation (serverReceives to consequences)
213+ // Most of the narration focuses on what happens on the server
214+ // This includes: receiving, validation failure, prototype pollution, gadget chain, RCE
215+ if ( currentTime < t . consequences ) {
163216 return 'server' ;
164217 }
165218
166- return 'browser' ;
219+ // Phase 4: Consequences and impact (consequences onwards)
220+ // Show the real-world impact section at the end
221+ return 'explanation' ;
222+ }
223+
224+ // Fix step trigger times interface (matches FixKeyframeTriggers)
225+ export interface FixTriggerTimes {
226+ vulnerableCode : number ;
227+ bracketNotation : number ;
228+ fixAdds : number ;
229+ hasOwnProperty : number ;
230+ blocked : number ;
231+ patchApplication : number ;
232+ nextJs : number ;
233+ reactDirect : number ;
234+ verify : number ;
235+ millions : number ;
236+ }
237+
238+ // Default fix triggers (fallback if whisper data not loaded)
239+ const DEFAULT_FIX_TRIGGERS : FixTriggerTimes = {
240+ vulnerableCode : 5 ,
241+ bracketNotation : 10 ,
242+ fixAdds : 25 ,
243+ hasOwnProperty : 35 ,
244+ blocked : 48 ,
245+ patchApplication : 55 ,
246+ nextJs : 60 ,
247+ reactDirect : 70 ,
248+ verify : 80 ,
249+ millions : 90
250+ } ;
251+
252+ // Determine scroll target for Fix step based on current time and trigger points
253+ // Flow: Code diff (vulnerable → fixed) → Remediation cards
254+ export function getFixScrollTarget ( params : {
255+ currentTime : number ;
256+ triggers ?: FixTriggerTimes | null ;
257+ } ) : ScrollTarget {
258+ const { currentTime, triggers } = params ;
259+ const t = triggers ?? DEFAULT_FIX_TRIGGERS ;
260+
261+ // Phase 1: Code diff section - showing vulnerable and fixed code (0 to patchApplication)
262+ // User should see the before/after code diff
263+ if ( currentTime < t . patchApplication ) {
264+ return 'browser' ; // Code diff container
265+ }
266+
267+ // Phase 2: Remediation section (patchApplication onwards)
268+ // Show the patching instructions and version cards
269+ return 'explanation' ;
270+ }
271+
272+ // Lessons step trigger times interface (matches LessonsKeyframeTriggers)
273+ export interface LessonsTriggerTimes {
274+ firstLesson : number ;
275+ secondLesson : number ;
276+ thirdLesson : number ;
277+ fourthLesson : number ;
278+ remember : number ;
279+ bakedIn : number ;
280+ }
281+
282+ // Default lessons triggers (fallback if whisper data not loaded)
283+ const DEFAULT_LESSONS_TRIGGERS : LessonsTriggerTimes = {
284+ firstLesson : 4 ,
285+ secondLesson : 12 ,
286+ thirdLesson : 20 ,
287+ fourthLesson : 28 ,
288+ remember : 36 ,
289+ bakedIn : 44
290+ } ;
291+
292+ // Determine scroll target for Lessons step based on current time and trigger points
293+ // Flow: Lesson cards (1-4) → Final quote/summary → Resources
294+ export function getLessonsScrollTarget ( params : {
295+ currentTime : number ;
296+ triggers ?: LessonsTriggerTimes | null ;
297+ } ) : ScrollTarget {
298+ const { currentTime, triggers } = params ;
299+ const t = triggers ?? DEFAULT_LESSONS_TRIGGERS ;
300+
301+ // Phase 1: Lessons cards (0 to remember)
302+ // User should see the lesson cards being highlighted
303+ if ( currentTime < t . remember ) {
304+ return 'browser' ; // Lessons grid
305+ }
306+
307+ // Phase 2: Quote and resources (remember onwards)
308+ // Show the final summary and further reading
309+ return 'explanation' ;
167310}
168311
169312// Module-level state for scroll tracking
0 commit comments