js

package
v0.0.0-...-229507d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Run executes a self-contained JavaScript script and returns the result from stdout.
	Run(script string) (string, error)
}

Engine defines the interface for a JavaScript runtime.

type ExternalEngine

type ExternalEngine struct {
	Command string
}

ExternalEngine uses an external command-line JS runtime (node, deno, bun).

func NewExternalEngine

func NewExternalEngine(command string) (*ExternalEngine, error)

NewExternalEngine creates a new engine that shells out to an external command.

func (*ExternalEngine) Run

func (e *ExternalEngine) Run(script string) (string, error)

Run executes a script by piping it to the external runtime's stdin.

type OttoEngine

type OttoEngine struct{}

OttoEngine uses the embedded otto interpreter.

func NewOttoEngine

func NewOttoEngine() *OttoEngine

NewOttoEngine creates a new engine that uses the built-in otto interpreter.

func (*OttoEngine) Run

func (e *OttoEngine) Run(script string) (string, error)

Run executes a script in otto. It captures output by overriding console.log.

func (*OttoEngine) SolveV2Challenge

func (e *OttoEngine) SolveV2Challenge(body, domain string, scriptMatches [][]string, logger *log.Logger) (string, error)

SolveV2Challenge uses the original synchronous method to solve v2 challenges, as otto does not support asynchronous operations like setTimeout.

type Runtime

type Runtime string

Runtime represents the name of a supported JavaScript runtime.

const (
	// Otto is the built-in Go-based interpreter.
	Otto Runtime = "otto"
	// Node uses the external Node.js runtime.
	Node Runtime = "node"
	// Deno uses the external Deno runtime.
	Deno Runtime = "deno"
	// Bun uses the external Bun runtime.
	Bun Runtime = "bun"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL