Documentation
¶
Overview ¶
Package resource turns MDD references into opaque, tamper-proof URL tokens and serves the bytes behind them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadToken = errors.New("invalid resource token")
ErrBadToken means the token was malformed, truncated, or not produced by this process.
var ErrNoSpeexDecoder = errors.New("speex decoder not available")
ErrNoSpeexDecoder means an Ogg-Speex asset was requested but no decoder is installed. The service degrades to reporting the asset as unavailable rather than substituting synthesized speech.
Functions ¶
This section is empty.
Types ¶
type Ref ¶
type Ref struct {
// DictionaryID scopes the reference. A token minted for one dictionary can
// never address another.
DictionaryID string `json:"d"`
// ResourceRef is the MDD-internal key, e.g. "sound://synthetic/uk/example.mp3" in tests.
// It is an index key, never a filesystem path.
ResourceRef string `json:"r"`
}
Ref is the payload a token carries.
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
Tokenizer mints and verifies resource tokens.
Tokens are AES-GCM sealed with a key generated fresh at every start, so they are opaque to the client, cannot be forged, and cannot be rewritten to point at a different dictionary or resource. Because a token decodes to a dictionary ID plus an MDD index key — and resolution only ever consults that dictionary's in-memory resource index — path traversal, symlink escape and arbitrary local file reads are structurally impossible rather than filtered.
func NewTokenizer ¶
NewTokenizer creates a tokenizer with a random per-process key.
type Transcoder ¶
type Transcoder struct {
// contains filtered or unexported fields
}
Transcoder converts Ogg-Speex pronunciation assets to WAV, which macOS and Bob can play, and caches the result on disk so each asset is decoded once.
func NewTranscoder ¶
func NewTranscoder(cacheDir string) *Transcoder
NewTranscoder creates a transcoder writing into cacheDir/audio.
func (*Transcoder) DecoderName ¶
func (t *Transcoder) DecoderName() string
DecoderName returns the decoder binary in use, or "" when none is installed.
func (*Transcoder) SpeexAvailable ¶
func (t *Transcoder) SpeexAvailable() bool
SpeexAvailable reports whether Speex assets can be served.
func (*Transcoder) SpeexToWAV ¶
func (t *Transcoder) SpeexToWAV(data []byte) ([]byte, error)
SpeexToWAV decodes Ogg-Speex bytes to WAV, using the disk cache when warm.