Help us shape the future of Go! Take the 2026 Go Developer Survey

javascript

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package javascript evaluates Spectre payload normaliser scripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator owns the JavaScript runtime for one payload normalisation. It is confined to its caller because Sobek runtime access is not synchronized.

func (*Evaluator) Close

func (e *Evaluator) Close()

Close releases the evaluator's context watcher.

func (*Evaluator) NormaliseField added in v0.11.0

func (e *Evaluator) NormaliseField(
	target string,
	value any,
	present bool,
) (normalised any, normalisedPresent bool, err error)

NormaliseField invokes the normaliser registered for a protobuf field.

func (*Evaluator) NormaliseMessage added in v0.11.0

func (e *Evaluator) NormaliseMessage(
	target string,
	value any,
	present bool,
) (normalised any, normalisedPresent bool, err error)

NormaliseMessage invokes the normaliser registered for a protobuf message.

func (*Evaluator) NormaliseRPC added in v0.11.0

func (e *Evaluator) NormaliseRPC(
	target string,
	value any,
	present bool,
) (normalised any, normalisedPresent bool, err error)

NormaliseRPC invokes the normaliser registered for an RPC method.

type Program

type Program struct {
	// contains filtered or unexported fields
}

Program is an immutable script shared by all payload normalisations. It retains no runtime-local callback state.

func NewProgram

func NewProgram(ctx context.Context, name, source string) (*Program, error)

NewProgram parses and links a script, then evaluates it once to validate registrations.

func (*Program) Fields

func (p *Program) Fields() []string

Fields returns the protobuf fields declared by the script.

func (*Program) Messages

func (p *Program) Messages() []string

Messages returns the protobuf messages declared by the script.

func (*Program) NewEvaluator

func (p *Program) NewEvaluator(ctx context.Context) (*Evaluator, error)

NewEvaluator creates an isolated evaluator for one payload normalisation. Re-evaluation must reproduce the registrations used to build the schema plan.

func (*Program) RPCs

func (p *Program) RPCs() []string

RPCs returns the RPC methods declared by the script.

Jump to

Keyboard shortcuts

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