webref

package module
v0.0.0-...-3984f81 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MPL-2.0 Imports: 18 Imported by: 1

README

WebRefs

WebRefs are general purpose references to data, available over the network, in the filesystem etc. They extend the concept of a URL to include read-time transformations on the data being retrieved. This allows encryption, compression, and cryptographic checksumming to be performed on the data.

This project evolved out of the WebRefs in WebFS Blobcache uses WebRefs to index externally available data.

Documentation

Index

Constants

View Source
const (
	Cipher_AES256_CTR = "AES256_CTR"
	Cipher_CHACHA20   = "CHACHA20"
	Cipher_XCHACHAX20 = "XCHACHA20"
)
View Source
const (
	AEAD_AES256_GCM      = "AES256_GCM"
	AEAD_XCHACHAPOLY1305 = "XCHACHAPOLY1305"
)
View Source
const (
	GZIP   = "gzip"
	SNAPPY = "snap"
)
View Source
const (
	Hash_SHA256 = "SHA256"

	Hash_SHA3_256 = "SHA3_256"

	Hash_BLAKE2B = "BLAKE2B"
	Hash_BLAKE2S = "BLAKE2S"
	Hash_BLAKE3  = "BLAKE3"
)

Variables

This section is empty.

Functions

func AES256CTRDecrypt

func AES256CTRDecrypt(x io.ReadCloser, key, nonce []byte) (io.ReadCloser, error)

func ChaCha20Decrypt

func ChaCha20Decrypt(x io.ReadCloser, key, nonce []byte) (io.ReadCloser, error)

func EncodePEM

func EncodePEM(out []byte, x Ref) []byte

EncodePEM appends the canonical PEM encoding of the Ref x to out.

func GZIPDecompress

func GZIPDecompress(x io.ReadCloser) (io.ReadCloser, error)

Types

type AEADAlgo

type AEADAlgo string

type AEADStage

type AEADStage struct {
	Algo  AEADAlgo `json:"algo"`
	Key   []byte   `json:"key"`
	Nonce []byte   `json:"nonce"`
}

type AnySource

type AnySource []Ref

type CipherAlgo

type CipherAlgo string

type CipherStage

type CipherStage struct {
	Algo  CipherAlgo `json:"algo"`
	Key   []byte     `json:"key"`
	Nonce []byte     `json:"nonce"`
}

type CompressAlgo

type CompressAlgo string

type CompressStage

type CompressStage struct {
	Algo CompressAlgo `json:"algo"`
}

type Decompressor

type Decompressor = func(x io.ReadCloser) (io.ReadCloser, error)

type Decryptor

type Decryptor = func(x io.ReadCloser, key, nonce []byte) (io.ReadCloser, error)

type ErrAlgoUnsupported

type ErrAlgoUnsupported struct {
	Algo string
	Type string
}

func (ErrAlgoUnsupported) Error

func (e ErrAlgoUnsupported) Error() string

type ErrEmptyStage

type ErrEmptyStage struct{}

func (ErrEmptyStage) Error

func (e ErrEmptyStage) Error() string

type ErrSliceOOB

type ErrSliceOOB struct {
	SliceStage
}

func (ErrSliceOOB) Error

func (e ErrSliceOOB) Error() string

type FileSource

type FileSource string

type HTTPSource

type HTTPSource struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

type HashAlgo

type HashAlgo string

type HashCheck

type HashCheck struct {
	Algo HashAlgo `json:"algo"`
	Sum  []byte   `json:"sum"`
}

type IPFSSource

type IPFSSource string

type Option

type Option func(*Resolver)

func WithCipher

func WithCipher(algo CipherAlgo, fn Decryptor) Option

func WithCompression

func WithCompression(algo CompressAlgo, fn Decompressor) Option

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

func WithHash

func WithHash(algo HashAlgo, fn func() hash.Hash) Option

func WithOpenFile

func WithOpenFile(fn func(string) (io.ReadSeekCloser, error)) Option

type Ref

type Ref []Stage

func DecodePEM

func DecodePEM(x []byte) (*Ref, error)

DecodePEM decodes a Ref from it's canonical PEM encoding in x.

func (Ref) IsMutable

func (r Ref) IsMutable() bool

func (Ref) Validate

func (r Ref) Validate() error

type Resolver

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

func NewResolver

func NewResolver(opts ...Option) Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, x Ref) (io.ReadCloser, error)

type SliceStage

type SliceStage struct {
	Begin int `json:"begin"`
	End   int `json:"end"`
}

type Stage

type Stage struct {
	File *FileSource `json:"file,omitempty"`
	HTTP *HTTPSource `json:"http,omitempty"`
	IPFS *IPFSSource `json:"ipfs,omitempty"`

	Cipher   *CipherStage   `json:"cipher,omitempty"`
	AEAD     *AEADStage     `json:"aead,omitempty`
	Compress *CompressStage `json:"compress,omitempty`
	Slice    *SliceStage    `json:"slice,omitempty"`

	Hash *HashCheck `json:"hash,omitempty"`

	Any   AnySource   `json:"any,omitempty"`
	Table TableSource `json:"table,omitempty"`
}

func (Stage) IsSource

func (s Stage) IsSource() bool

func (Stage) String

func (s Stage) String() string

type TableEntry

type TableEntry struct {
	Offset uint64
	Target Ref
}

type TableSource

type TableSource []TableEntry

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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