Documentation
¶
Overview ¶
Package javascript evaluates Spectre payload normaliser scripts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModuleDeclaration ¶ added in v0.19.0
func ModuleDeclaration() string
ModuleDeclaration returns the TypeScript declaration of the spectre module.
func WriteModuleDeclaration ¶ added in v0.19.0
WriteModuleDeclaration writes the module declaration to output, creating its parent directory.
Types ¶
type Direction ¶ added in v0.13.0
type Direction string
Direction names the proxy that decodes an endpoint's traffic.
type Endpoint ¶ added in v0.12.0
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint maps a protocol-specific request pattern to a payload type, or marks it ignored so matching requests are skipped instead of compared.
func (Endpoint) Ignore ¶ added in v0.23.0
Ignore reports whether matching requests are skipped instead of compared.
func (Endpoint) Pattern ¶ added in v0.12.0
Pattern returns the protocol-specific 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 FieldTarget, value Option[any]) (Option[any], error)
NormaliseField invokes the normaliser registered for a JSON field path. None stands for an absent field in both the argument and the result.
type FieldTarget ¶ added in v0.19.0
type FieldTarget struct {
// contains filtered or unexported fields
}
FieldTarget identifies a JSON field path relative to an explicitly named type. The two components remain separate because namespace names can overlap field paths.
func NewFieldTarget ¶ added in v0.19.0
func NewFieldTarget(typeName schema.TypeRef, path string) FieldTarget
NewFieldTarget creates a target without resolving it against a schema.
func (FieldTarget) Path ¶ added in v0.19.0
func (t FieldTarget) Path() string
Path returns the JSON field path relative to the root type.
func (FieldTarget) String ¶ added in v0.19.0
func (t FieldTarget) String() string
String returns a human-readable target name, not a unique identity.
func (FieldTarget) Type ¶ added in v0.19.0
func (t FieldTarget) Type() schema.TypeRef
Type returns the fully qualified name of the target's root object type.
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, evaluationTimeout time.Duration, declarations fs.FS, scripts fs.FS) (*Program, error)
NewProgram type-checks every TypeScript script against the schema declarations, links them, then evaluates them once within evaluationTimeout to collect their registrations.
func (*Program) Endpoints ¶ added in v0.12.0
Endpoints returns the endpoints declared for a direction, in declaration order.
func (*Program) Fields ¶
func (p *Program) Fields() []FieldTarget
Fields returns the declared type names and JSON field paths, sorted by type then path.
func (*Program) NewEvaluator ¶
NewEvaluator creates an isolated evaluator for one payload normalisation. Re-evaluation must reproduce the registrations used to build the schema plan.