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

javascript

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 10 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 Endpoint added in v0.12.0

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

Endpoint maps a raw HTTP request pattern to the RPC method that types it.

func (Endpoint) Method added in v0.12.0

func (e Endpoint) Method() string

Method returns the full name of the RPC method that types the endpoint.

func (Endpoint) Pattern added in v0.12.0

func (e Endpoint) Pattern() string

Pattern returns the net/http.ServeMux pattern the endpoint matches.

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.

type Program

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

Program is one immutable set of scripts, shared by all payload normalisations. It retains no runtime-local callback state.

func NewProgram

func NewProgram(ctx context.Context, scripts fs.FS) (*Program, error)

NewProgram parses and links every .js file in scripts, then evaluates them once in one runtime to validate their combined registrations.

func (*Program) Endpoints added in v0.12.0

func (p *Program) Endpoints() []Endpoint

Endpoints returns the declared raw HTTP endpoints, in declaration order.

func (*Program) Fields

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

Fields returns the protobuf fields declared by the scripts.

func (*Program) Messages

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

Messages returns the protobuf messages declared by the scripts.

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.

Jump to

Keyboard shortcuts

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