cfsolve 0.1.3 → 0.1.5

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +30 -5
  4. data/UPSTREAM.md +24 -3
  5. data/lib/cfsolve/profiles/safari-26-ios/answers.json +805 -797
  6. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +909 -899
  7. data/lib/cfsolve/version.rb +2 -2
  8. data/lib/cfsolve.rb +21 -10
  9. data/vendor/cfsolve/examples/listing_dump.rs +24 -0
  10. data/vendor/cfsolve/examples/probe_similarity.rs +37 -0
  11. data/vendor/cfsolve/examples/rebase_reference.rs +96 -0
  12. data/vendor/cfsolve/examples/reread_capture.rs +31 -0
  13. data/vendor/cfsolve/examples/turnstile_smoke.rs +79 -0
  14. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +805 -797
  15. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +909 -899
  16. data/vendor/cfsolve/src/capture/sessions.rs +88 -4
  17. data/vendor/cfsolve/src/capture.rs +1 -0
  18. data/vendor/cfsolve/src/deobfuscate/ast.rs +16 -0
  19. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +1 -1
  20. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +33 -0
  21. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +24 -4
  22. data/vendor/cfsolve/src/embedding_page/extra_params.rs +3 -3
  23. data/vendor/cfsolve/src/embedding_page/page.rs +76 -65
  24. data/vendor/cfsolve/src/stage2/analysis/discovery.rs +7 -4
  25. data/vendor/cfsolve/src/stage2/benchmark.rs +29 -8
  26. data/vendor/cfsolve/src/stage2/call_stack.rs +134 -95
  27. data/vendor/cfsolve/src/stage2/challenge_page.rs +10 -3
  28. data/vendor/cfsolve/src/stage2/probes/parent_info.rs +345 -61
  29. data/vendor/cfsolve/src/stage2/probes/performance.rs +42 -5
  30. data/vendor/cfsolve/src/stage2/probes/stack.rs +41 -0
  31. data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +11 -2
  32. data/vendor/cfsolve/src/stage2/reference.json +1 -1
  33. data/vendor/cfsolve/src/stage2/reference.rs +70 -110
  34. data/vendor/cfsolve/src/stage2/registry.rs +4 -3
  35. data/vendor/cfsolve/src/stage2/trace.rs +1 -1
  36. data/vendor/cfsolve/src/vm/dataflow.rs +15 -6
  37. data/vendor/cfsolve/src/vm/disassemble.rs +2 -1
  38. data/vendor/cfsolve/src/vm/encoded_strings.rs +1553 -0
  39. data/vendor/cfsolve/src/vm/extract.rs +205 -152
  40. data/vendor/cfsolve/src/vm/interpret/access.rs +0 -2
  41. data/vendor/cfsolve/src/vm/interpret/builtin.rs +0 -13
  42. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +30 -7
  43. data/vendor/cfsolve/src/vm/interpret/mix32.rs +216 -86
  44. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +42 -21
  45. data/vendor/cfsolve/src/vm/interpret/pattern.rs +268 -67
  46. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +261 -30
  47. data/vendor/cfsolve/src/vm/machine.rs +14 -12
  48. data/vendor/cfsolve/src/vm/output.rs +4 -1
  49. data/vendor/cfsolve/src/vm/registers.rs +17 -23
  50. data/vendor/cfsolve/src/vm/session.rs +9 -4
  51. data/vendor/cfsolve/src/vm.rs +1 -0
  52. metadata +7 -1
@@ -1,29 +1,28 @@
1
1
  //! Reconstructs `new Error()` stacks from the original script: the checkbox click's, the stack
2
2
  //! probe's, and the challenge page's render call.
3
3
  //!
4
- //! The chain runs from the listener through the VM's runner and `run` method to the opcode
4
+ //! The chain runs from the listener through the VM's runner and run function to the opcode
5
5
  //! handler that constructs the error. Some builds use the runner directly as listener; others
6
6
  //! add an arity-specific wrapper. Forwarders, helper-object methods, and selector-based
7
7
  //! `Reflect.apply` helpers add their own frames. Recovery decodes only the string table,
8
8
  //! preserving original positions and method keys.
9
9
  //!
10
- //! V8 names frames by call form, such as `Class.run` or `HTMLInputElement.<anonymous>`, and
10
+ //! V8 names frames by call form, such as `Class.handler` or `HTMLInputElement.<anonymous>`, and
11
11
  //! uses callee positions. JavaScriptCore names them by definition, leaving many methods
12
12
  //! anonymous, uses the opening argument parenthesis, and includes native `Reflect.construct`
13
13
  //! frames. The script is sloppy code, so JavaScriptCore does not eliminate tail calls.
14
14
 
15
15
  use std::collections::{HashMap, HashSet};
16
- use std::mem;
17
16
  use std::sync::Arc;
18
17
 
19
18
  use anyhow::{Context, Result, bail};
20
19
  use oxc::ast::AstKind;
21
20
  use oxc::ast::ast::{
22
21
  Argument, ArrayExpression, ArrayExpressionElement, AssignmentExpression, AssignmentTarget,
23
- BindingPattern, CallExpression, Class, ClassElement, Expression, FormalParameter, Function,
24
- MemberExpression, MethodDefinition, MethodDefinitionKind, NewExpression, ObjectExpression,
25
- ObjectProperty, ObjectPropertyKind, PropertyKind, Statement, SwitchCase, SwitchStatement,
26
- ThrowStatement, TryStatement, VariableDeclarator,
22
+ BindingPattern, CallExpression, Class, Expression, FormalParameter, Function, MemberExpression,
23
+ MethodDefinition, NewExpression, ObjectExpression, ObjectProperty, ObjectPropertyKind,
24
+ PropertyKind, Statement, SwitchCase, SwitchStatement, ThrowStatement, TryStatement,
25
+ VariableDeclarator,
27
26
  };
28
27
  use oxc::ast_visit::{Visit, walk};
29
28
  use oxc::semantic::SymbolId;
@@ -238,12 +237,12 @@ pub fn recover_method_call(
238
237
  })
239
238
  }
240
239
 
241
- /// Dispatch loop called by `run`, with details used to check stack recovery offline.
240
+ /// Dispatch loop called by the run function, with details used to check stack recovery offline.
242
241
  #[derive(Debug, Serialize)]
243
242
  pub struct DispatchSummary {
244
243
  pub function: String,
245
244
  pub guarded: bool,
246
- /// V8 frames from the dispatch loop to `run`, innermost first.
245
+ /// V8 frames from the dispatch loop to the run function, innermost first.
247
246
  pub frames: Vec<String>,
248
247
  /// Number of opcodes dispatched by the loop.
249
248
  pub opcodes: usize,
@@ -251,7 +250,8 @@ pub struct DispatchSummary {
251
250
  pub unresolved: Vec<u8>,
252
251
  }
253
252
 
254
- /// Summarizes dispatch loops called by `run`, including whether each case resolves to a function.
253
+ /// Summarizes dispatch loops called by the run function, including whether each case resolves to
254
+ /// a function.
255
255
  pub fn dispatch_summary(source: &str, cases: &CaseOpcodes) -> Result<Vec<DispatchSummary>> {
256
256
  let decoded = deobfuscate::decode(source.to_owned())?;
257
257
  let machine = Machine::new(decoded.script(), cases)?;
@@ -277,7 +277,7 @@ pub fn dispatch_summary(source: &str, cases: &CaseOpcodes) -> Result<Vec<Dispatc
277
277
  unresolved.push(opcode);
278
278
  }
279
279
  }
280
- let frames = dispatch_loop.call.frames(Name::same("run".to_owned()));
280
+ let frames = dispatch_loop.call.frames(machine.run.frame());
281
281
  summaries.push(DispatchSummary {
282
282
  function: name.to_owned(),
283
283
  guarded: dispatch_loop.guarded,
@@ -399,42 +399,48 @@ impl Callee<'_> {
399
399
  }
400
400
  }
401
401
 
402
- /// The VM dispatch method, its runner, and listeners that wrap the runner for each closure
403
- /// parameter count.
402
+ /// The VM's run function, the closure runner that calls it, and listeners that wrap the closure
403
+ /// runner for each closure parameter count.
404
404
  struct Machine<'a, 'cases> {
405
405
  script: Script<'a>,
406
- dispatch: DispatchMethod<'a>,
407
- /// The dispatch loops `run` calls.
406
+ run: RunFunction<'a>,
407
+ /// The dispatch loops the run function calls.
408
408
  loops: Vec<DispatchLoop<'a>>,
409
409
  cases: &'cases CaseOpcodes,
410
- runner: Call,
410
+ /// Frames from the call to the run function out to the closure runner, innermost first.
411
+ runner: Vec<Call>,
411
412
  listeners: Vec<Invocation<'a>>,
412
413
  }
413
414
 
414
415
  impl<'a, 'cases> Machine<'a, 'cases> {
415
416
  fn new(js: ast::Script<'a>, cases: &'cases CaseOpcodes) -> Result<Self> {
416
- let mut script = Script::new(js);
417
- let classes = mem::take(&mut script.classes);
418
- // The runner passes the closure's program counter, key, and arguments to `run`,
419
- // copying arguments when required by the VM function.
417
+ let script = Script::new(js);
418
+ let run = RunFunction::installed(&script)?;
419
+ // The closure runner passes the machine and the closure's program counter, key, and
420
+ // arguments to the run function, copying arguments when required by the VM function.
420
421
  let mut runners = Vec::new();
421
422
  for (name, function) in &script.functions {
423
+ let caller = Callee::Binding(*name);
424
+ let caller_name = script.appliers.name(caller);
425
+ let scope = Scope::new(caller_name, function, &script.appliers);
422
426
  for call in calls_of(js, function) {
423
- let calls_run = member(&call.callee)
424
- .is_some_and(|member| ast::member_str(member) == Some("run"));
425
- if calls_run
426
- && call.arguments.len() == 3
427
+ let Ok(target) = scope.target(call) else {
428
+ continue;
429
+ };
430
+ if target.callee == Some(run.name)
431
+ && let Some(handed) = handed(Arguments::of(call), &target)
432
+ && let [_, _, _, Operand::Expression(cells)] = handed[..]
427
433
  && matches!(
428
- ast::argument_expression(&call.arguments[2]),
434
+ cells.without_parentheses(),
429
435
  Expression::ConditionalExpression(_)
430
436
  )
431
437
  {
432
- runners.push((*name, call));
438
+ runners.push((caller, target.frames(Name::same(caller_name.to_owned()))));
433
439
  }
434
440
  }
435
441
  }
436
- let (runner, run_call) = candidates::exactly_one(runners, "closure-to-VM runner call")?;
437
- let runner = Callee::Binding(runner);
442
+ let (runner, runner_frames) =
443
+ candidates::exactly_one(runners, "closure-to-VM runner call")?;
438
444
  let mut listeners = Listeners {
439
445
  runner,
440
446
  appliers: &script.appliers,
@@ -442,18 +448,14 @@ impl<'a, 'cases> Machine<'a, 'cases> {
442
448
  };
443
449
  listeners.visit_program(js.program);
444
450
  let listeners: Vec<Invocation> = listeners.found.into_iter().collect::<Result<_>>()?;
445
- let dispatches = classes.into_iter().filter_map(|dispatch| {
446
- let loops = dispatch_loops(&script, &dispatch.run);
447
- (!loops.is_empty()).then_some((dispatch, loops))
448
- });
449
- let (dispatch, loops) = candidates::exactly_one(dispatches, "VM dispatch method")?;
451
+ let loops = dispatch_loops(&script, &run);
452
+ if loops.is_empty() {
453
+ bail!("the run function calls no dispatch loop");
454
+ }
450
455
  Ok(Self {
451
- runner: Call {
452
- name: Name::same(script.appliers.name(runner).to_owned()),
453
- site: Site::new(run_call),
454
- },
456
+ runner: runner_frames,
455
457
  listeners,
456
- dispatch,
458
+ run,
457
459
  loops,
458
460
  script,
459
461
  cases,
@@ -482,7 +484,7 @@ impl<'a, 'cases> Machine<'a, 'cases> {
482
484
  let name = appliers.name(handler);
483
485
  let frame = Name {
484
486
  v8: if dispatch.method {
485
- format!("{}.{name}", self.dispatch.class)
487
+ format!("{}.{name}", self.run.class)
486
488
  } else {
487
489
  name.to_owned()
488
490
  },
@@ -498,17 +500,14 @@ impl<'a, 'cases> Machine<'a, 'cases> {
498
500
  bail!("no dispatch of opcode {opcode} (guarded: {guarded})")
499
501
  }
500
502
 
501
- /// Appends frames from the call to `handler` through the dispatch loop, `run`, and the runner.
503
+ /// Appends frames from the call to `handler` through the dispatch loop, the run function, and
504
+ /// the closure runner.
502
505
  fn entered(&self, handler: &Handler<'a, '_>, mut frames: Vec<Call>) -> Vec<Call> {
503
- let DispatchMethod { class, key, .. } = &self.dispatch;
504
506
  let dispatch_loop = handler.dispatch_loop;
505
507
  let name = self.script.appliers.name(dispatch_loop.name);
506
508
  frames.extend(handler.dispatch.frames(Name::same(name.to_owned())));
507
- frames.extend(dispatch_loop.call.frames(Name {
508
- v8: format!("{class}.run"),
509
- jsc: key.unwrap_or_default().to_owned(),
510
- }));
511
- frames.push(self.runner.clone());
509
+ frames.extend(dispatch_loop.call.frames(self.run.frame()));
510
+ frames.extend(self.runner.iter().cloned());
512
511
  frames
513
512
  }
514
513
 
@@ -620,7 +619,7 @@ impl<'a, 'cases> Machine<'a, 'cases> {
620
619
  }
621
620
  }
622
621
 
623
- /// The function `run` calls for an opcode.
622
+ /// The function a dispatch loop calls for an opcode.
624
623
  struct Handler<'a, 'machine> {
625
624
  /// Call from the dispatch loop to this handler.
626
625
  dispatch: Invocation<'a>,
@@ -629,10 +628,10 @@ struct Handler<'a, 'machine> {
629
628
  dispatch_loop: &'machine DispatchLoop<'a>,
630
629
  }
631
630
 
632
- /// Function called by `run` with the machine to dispatch opcodes.
631
+ /// Function called by the run function with the machine to dispatch opcodes.
633
632
  struct DispatchLoop<'a> {
634
633
  name: Callee<'a>,
635
- /// Call from `run`, either direct or through a helper.
634
+ /// Call from the run function, either direct or through a helper.
636
635
  call: Invocation<'a>,
637
636
  /// Whether the call occurs in a `try` block that handles exceptions.
638
637
  guarded: bool,
@@ -642,10 +641,11 @@ struct DispatchLoop<'a> {
642
641
  /// helper switch.
643
642
  const DISPATCH_CASES: usize = 40;
644
643
 
645
- /// Finds functions with dispatch switches that `run` calls with the machine.
646
- fn dispatch_loops<'a>(script: &Script<'a>, run: &Body<'a>) -> Vec<DispatchLoop<'a>> {
644
+ /// Finds functions with dispatch switches that the run function calls with the machine.
645
+ fn dispatch_loops<'a>(script: &Script<'a>, run: &RunFunction<'a>) -> Vec<DispatchLoop<'a>> {
647
646
  struct Calls<'a> {
648
647
  js: ast::Script<'a>,
648
+ machine: SymbolId,
649
649
  found: Vec<(&'a CallExpression<'a>, bool)>,
650
650
  guarded: bool,
651
651
  }
@@ -671,10 +671,8 @@ fn dispatch_loops<'a>(script: &Script<'a>, run: &Body<'a>) -> Vec<DispatchLoop<'
671
671
  fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
672
672
  if !is_optional_call(call)
673
673
  && call.arguments.iter().any(|argument| {
674
- matches!(
675
- ast::argument_expression(argument),
676
- Expression::ThisExpression(_)
677
- )
674
+ self.js
675
+ .refers_to(ast::argument_expression(argument), self.machine)
678
676
  })
679
677
  {
680
678
  let call = self.js.lend(call, AstKind::as_call_expression);
@@ -685,11 +683,12 @@ fn dispatch_loops<'a>(script: &Script<'a>, run: &Body<'a>) -> Vec<DispatchLoop<'
685
683
  }
686
684
  let mut calls = Calls {
687
685
  js: script.js(),
686
+ machine: run.machine,
688
687
  found: Vec::new(),
689
688
  guarded: false,
690
689
  };
691
- run.visit(&mut calls);
692
- let scope = Scope::new("", run, &script.appliers);
690
+ run.body.visit(&mut calls);
691
+ let scope = Scope::new(run.frame_name, &run.body, &script.appliers);
693
692
  calls
694
693
  .found
695
694
  .into_iter()
@@ -773,11 +772,10 @@ impl<'a> Body<'a> {
773
772
  }
774
773
  }
775
774
 
776
- /// The script's declared and assigned functions, VM dispatch methods, and aliases for
777
- /// `Reflect.construct` and `Reflect.apply`.
775
+ /// The script's declared and assigned functions, and aliases for `Reflect.construct` and
776
+ /// `Reflect.apply`.
778
777
  struct Script<'a> {
779
778
  functions: Vec<(Binding<'a>, Body<'a>)>,
780
- classes: Vec<DispatchMethod<'a>>,
781
779
  constructs: Vec<Callee<'a>>,
782
780
  /// Array slots containing `Reflect.construct`, indexed by array and slot.
783
781
  construct_slots: Vec<(Binding<'a>, usize)>,
@@ -993,12 +991,70 @@ fn number<'a>(expression: &Expression<'a>, constants: &Constants<'a>) -> Option<
993
991
  })
994
992
  }
995
993
 
996
- /// Finds the VM class method `run` that calls the dispatch loops.
997
- struct DispatchMethod<'a> {
994
+ /// The VM's run function, which calls the dispatch loops. The program runner installs it as
995
+ /// `<global>.<name> = function(p) { return <run>(new <Class>(p), pc, key, []); }`, possibly
996
+ /// calling it through a helper.
997
+ struct RunFunction<'a> {
998
+ /// The VM class, which V8 names handlers called as methods of the machine after.
998
999
  class: &'a str,
999
- run: Body<'a>,
1000
- /// The method's literal property key, if present.
1001
- key: Option<&'a str>,
1000
+ name: Callee<'a>,
1001
+ /// The run function's name in the source, which both engines name its frame after.
1002
+ frame_name: &'a str,
1003
+ body: Body<'a>,
1004
+ /// The parameter receiving the machine.
1005
+ machine: SymbolId,
1006
+ }
1007
+
1008
+ impl<'a> RunFunction<'a> {
1009
+ /// Finds the run function from the one program runner.
1010
+ fn installed(script: &Script<'a>) -> Result<Self> {
1011
+ let js = script.js();
1012
+ let mut found = Vec::new();
1013
+ for function in js.functions() {
1014
+ let body = Body::of(function);
1015
+ let Some(Statement::ReturnStatement(returned)) = body.only_statement() else {
1016
+ continue;
1017
+ };
1018
+ let Some(Expression::CallExpression(call)) = &returned.argument else {
1019
+ continue;
1020
+ };
1021
+ let Ok(target) = Scope::new("", &body, &script.appliers).target(call) else {
1022
+ continue;
1023
+ };
1024
+ if let Some(name) = target.callee
1025
+ && let Some(handed) = handed(Arguments::of(call), &target)
1026
+ && let [
1027
+ Operand::Expression(machine),
1028
+ _,
1029
+ _,
1030
+ Operand::Expression(cells),
1031
+ ] = handed[..]
1032
+ && let Expression::NewExpression(machine) = machine.without_parentheses()
1033
+ && let Expression::Identifier(class) = &machine.callee
1034
+ && array(cells).is_some_and(|cells| cells.elements.is_empty())
1035
+ {
1036
+ found.push((name, class.name.as_str()));
1037
+ }
1038
+ }
1039
+ let (name, class) = candidates::exactly_one(found, "program runner")?;
1040
+ let body = script.function(name)?;
1041
+ let machine = body
1042
+ .parameters()
1043
+ .and_then(|parameters| parameters.first().copied())
1044
+ .context("the run function takes no machine")?;
1045
+ Ok(Self {
1046
+ class,
1047
+ name,
1048
+ frame_name: script.appliers.name(name),
1049
+ body,
1050
+ machine,
1051
+ })
1052
+ }
1053
+
1054
+ /// The run function's frame.
1055
+ fn frame(&self) -> Name {
1056
+ Name::same(self.frame_name.to_owned())
1057
+ }
1002
1058
  }
1003
1059
 
1004
1060
  impl<'a> Script<'a> {
@@ -1013,7 +1069,6 @@ impl<'a> Script<'a> {
1013
1069
  let appliers = Appliers::new(js, &functions);
1014
1070
  let mut script = Self {
1015
1071
  functions,
1016
- classes: Vec::new(),
1017
1072
  constructs: Vec::new(),
1018
1073
  construct_slots: Vec::new(),
1019
1074
  applies: Vec::new(),
@@ -1021,10 +1076,8 @@ impl<'a> Script<'a> {
1021
1076
  appliers,
1022
1077
  };
1023
1078
  for node in js.nodes.iter() {
1024
- match node.kind() {
1025
- AstKind::AssignmentExpression(assignment) => script.assignment(assignment),
1026
- AstKind::Class(class) if class.is_declaration() => script.class(class),
1027
- _ => {}
1079
+ if let AstKind::AssignmentExpression(assignment) = node.kind() {
1080
+ script.assignment(assignment);
1028
1081
  }
1029
1082
  }
1030
1083
  script
@@ -1069,28 +1122,6 @@ impl<'a> Script<'a> {
1069
1122
  }
1070
1123
  }
1071
1124
 
1072
- /// Records a class declaration's `run` method.
1073
- fn class(&mut self, class: &'a Class<'a>) {
1074
- let run = class.body.body.iter().find_map(|element| match element {
1075
- ClassElement::MethodDefinition(method)
1076
- if method.kind != MethodDefinitionKind::Constructor
1077
- && ast::static_key_str(&method.key, method.computed) == Some("run") =>
1078
- {
1079
- Some(method)
1080
- }
1081
- _ => None,
1082
- });
1083
- if let Some(method) = run
1084
- && let Some(name) = &class.id
1085
- {
1086
- self.classes.push(DispatchMethod {
1087
- class: name.name.as_str(),
1088
- run: Body::of(&method.value),
1089
- key: ast::key_str(&method.key, method.computed),
1090
- });
1091
- }
1092
- }
1093
-
1094
1125
  fn function(&self, callee: Callee<'a>) -> Result<Body<'a>> {
1095
1126
  match callee {
1096
1127
  Callee::Binding(binding) => self
@@ -1983,8 +2014,9 @@ impl<'a, 's> Scope<'a, 's> {
1983
2014
  }
1984
2015
  }
1985
2016
 
1986
- /// Records forwarders defined by an object literal assigned to `holder`. Uses property keys as
1987
- /// function names, including computed keys.
2017
+ /// Records forwarders defined by an object literal assigned to `holder`. V8 names functions
2018
+ /// by their property keys, including computed keys. JavaScriptCore leaves functions under
2019
+ /// computed keys anonymous: obfuscation computes them with string decoder calls.
1988
2020
  fn literal(&mut self, holder: Holder<'a>, object: &'a ObjectExpression<'a>) {
1989
2021
  // Matches `key: function` properties and methods, but not accessors.
1990
2022
  for property in &object.properties {
@@ -1992,7 +2024,14 @@ impl<'a, 's> Scope<'a, 's> {
1992
2024
  && let Expression::FunctionExpression(function) = &property.value
1993
2025
  && property.kind == PropertyKind::Init
1994
2026
  && let Some(key) = ast::static_key_str(&property.key, property.computed)
1995
- && let Some(frames) = self.forwarder(function, Name::same(key.to_owned()))
2027
+ && let Some(frames) = self.forwarder(
2028
+ function,
2029
+ if property.computed {
2030
+ Name::anonymous(key.to_owned())
2031
+ } else {
2032
+ Name::same(key.to_owned())
2033
+ },
2034
+ )
1996
2035
  {
1997
2036
  let forwarder = Forwarder {
1998
2037
  method: frames.clone(),
@@ -11,7 +11,6 @@ use anyhow::{Context, Result, bail, ensure};
11
11
  use indexmap::IndexMap;
12
12
  use url::Url;
13
13
 
14
- use crate::candidates;
15
14
  use crate::js::{JsObject, JsValue, Options, Payload, Window, json};
16
15
  use crate::listing::fold::DECODER_CELL;
17
16
  use crate::listing::query::Store;
@@ -22,6 +21,7 @@ use crate::stage2::payload::{
22
21
  };
23
22
  use crate::stage2::queries;
24
23
  use crate::vm::{Constant, Effect, Listing, Term};
24
+ use crate::{candidates, challenge};
25
25
 
26
26
  /// Widget parameters passed to `turnstile.render`, excluding callbacks.
27
27
  const RENDER_PARAMETERS: [&str; 8] = [
@@ -322,7 +322,7 @@ impl Reader<'_> {
322
322
  })
323
323
  }
324
324
 
325
- /// Recovers outcome fields from callbacks. Expiry writes `"expired"` and clears the token;
325
+ /// Recovers outcome fields from callbacks. Expiry writes its status and clears the token;
326
326
  /// success writes the token. Both call shared finishing functions.
327
327
  fn outcome(&self, callbacks: &BTreeMap<String, u32>, started: &str) -> Result<SettledFields> {
328
328
  let entry = |name: &str| {
@@ -334,9 +334,16 @@ impl Reader<'_> {
334
334
  let expired: Vec<&Store> = self
335
335
  .stores_in(self.index.function_at(entry("expired-callback")?))
336
336
  .collect();
337
+ // The status is `"expired"`, or in builds with hex names, one of those names.
337
338
  let status = expired
338
339
  .iter()
339
- .find(|store| self.origin(store.pc, &store.value) == Some(literal(json!("expired"))))
340
+ .find(|store| {
341
+ matches!(
342
+ self.origin(store.pc, &store.value),
343
+ Some(Expression::Literal { value: JsValue::String(text) })
344
+ if text == "expired" || challenge::is_hex_name(&text)
345
+ )
346
+ })
340
347
  .context("expiry callback writes no status")?
341
348
  .key
342
349
  .clone();