xfile

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Overview

Package xfile defines the provider-neutral contract for opening externally stored files. References are opaque identifiers, never operating-system paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpectedDigest

type ExpectedDigest string

ExpectedDigest is an optional algorithm-prefixed digest supplied by a caller as an integrity hint (for example, "sha256:<hex>"). Resolvers must verify it against the opened object when it is non-empty.

type ExpectedSize

type ExpectedSize int64

ExpectedSize is an optional size supplied by a caller as an integrity hint. Resolvers must verify it against the opened object when it is non-zero.

type ID

type ID string

ID is an opaque provider-scoped file identifier. It must not contain or be interpreted as an operating-system path.

type Info

type Info struct {
	Provider Provider
	ID       ID
	Version  Version
	Size     int64
	Digest   string
}

Info contains metadata confirmed for the object actually opened. Provider, ID, Version, Size, and Digest identify the resolved object; Size and Digest are authoritative results, distinct from Ref's caller-supplied expectations. Digest uses an explicit algorithm prefix (for example, "sha256:<hex>").

type Provider

type Provider string

Provider identifies the storage provider that owns a file. Its value is a routing hint, not an authorization credential.

type Ref

type Ref struct {
	Provider       Provider
	ID             ID
	Version        Version
	ExpectedSize   ExpectedSize
	ExpectedDigest ExpectedDigest
}

Ref identifies a file without exposing a storage path. All fields are untrusted input: in particular, none of them grants access to the file.

type Resolver

type Resolver interface {
	Open(context.Context, Ref) (io.ReadCloser, Info, error)
}

Resolver opens a referenced file. Implementations must derive caller and tenant authorization exclusively from ctx (using ScopeFromContext); Ref is untrusted selection/integrity data and must never be used as authorization. Implementations should classify errors with kernel/xerr. On success, the caller owns and must close the returned reader.

type Scope

type Scope struct {
	CallerID string
	TenantID string
}

Scope is the authenticated caller and tenant associated with an operation. Its values are copied from xctx so they remain stable if the request scope is later released to the scope pool.

func ScopeFromContext

func ScopeFromContext(ctx context.Context) (Scope, error)

ScopeFromContext extracts the authenticated caller and tenant from the request scope. Resolvers should call this before authorizing an open and must never infer either value from a Ref.

Missing caller or tenant scope is classified as Unauthorized, consistent with Kernel's request authorization guards.

type Version

type Version string

Version identifies a provider's immutable file version when available.

Jump to

Keyboard shortcuts

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