
    ^j$                     X    d dl Z d dlZd dlZddlmZ ddlmZ  G d de      Z e        y)    N   )JavaScriptInterpreter)templatec                   $     e Zd Z fdZd Z xZS )ChallengeInterpreterc                 ,    t         t        |   d       y )Nnodejs)superr   __init__)self	__class__s    [/var/www/lego-monitor/venv/lib/python3.12/site-packages/cloudscraper/interpreters/nodejs.pyr   zChallengeInterpreter.__init__   s    "D28<    c                 H   	 dt        j                  t        ||      j                  d            j	                  d      z  }t        j                  dd|g      S # t        $ r }|j                  dk(  rt        d       d }~wt        $ r dt        _        t        d	      w xY w)
Na1  var atob = function(str) {return Buffer.from(str, "base64").toString("binary");};var challenge = atob("%s");var context = {atob: atob};var options = {filename: "iuam-challenge.js", timeout: 4000};var answer = require("vm").runInNewContext(challenge, context, options);process.stdout.write(String(answer));zUTF-8asciinodez-e   al  Missing Node.js runtime. Node is required and must be in the PATH (check with `node -v`).

Your Node binary may be called `nodejs` rather than `node`, in which case you may need to run `apt-get install nodejs-legacy` on some Debian-based systems.

(Please read the cloudscraper README's Dependencies section: https://github.com/VeNoMouS/cloudscraper#dependencies.)r   z4Error executing Cloudflare IUAM Javascript in nodejs)base64	b64encoder   encodedecode
subprocesscheck_outputOSErrorerrnoEnvironmentError	ExceptionsystracebacklimitRuntimeError)r   bodydomainjses        r   evalzChallengeInterpreter.eval   s    	W9 ##HT6$:$A$A'$JKRRSZ[\B **FD"+=>> 		ww!|&N   	W!"CUVV	Ws   AA 	B!#A>>#B!)__name__
__module____qualname__r   r%   __classcell__)r   s   @r   r   r      s    =
Wr   r   )r   r   r    r   encapsulatedr   r    r   r   <module>r-      s,      
 # "
!W0 !WL  r   