Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeContent(content []byte) ([]byte, error)
- func EncodeContent(content []byte, compress bool) ([]byte, error)
- func HashAPIKeyToken(token string) string
- func IsZSTDCompressed(data []byte) bool
- func NewAPIKeyToken() (token string, hash string, err error)
- func NormalizeName(name string) (string, error)
- type APIKey
- type File
- type PublicKey
- type Revision
- type User
Constants ¶
View Source
const ( FileTypeBinary = "binary" FileTypeMarkdown = "markdown" )
View Source
const ( // APIKeyTokenPrefix prefixes every minted token so keys are recognizable // (and grep-able) in configs and secret scanners. APIKeyTokenPrefix = "snips_" )
View Source
const (
// NameMaxLength is the maximum length of a file's name.
NameMaxLength = 40
)
Variables ¶
View Source
var (
ErrInvalidName = fmt.Errorf("names must be 1-%d alphanumeric characters (hyphen, dot, or underscore separators allowed)", NameMaxLength)
)
Functions ¶
func DecodeContent ¶ added in v0.13.0
func EncodeContent ¶ added in v0.13.0
func HashAPIKeyToken ¶ added in v0.13.0
HashAPIKeyToken returns the hex-encoded SHA-384 digest of a token, the only form in which tokens are stored.
A fast hash is deliberate: unlike a password, a 256-bit random token can't be brute forced, and lookups stay indexable.
func IsZSTDCompressed ¶ added in v0.10.0
IsZSTDCompressed checks if the data starts with the zstd magic number. https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#zstandard-frames
func NewAPIKeyToken ¶ added in v0.13.0
NewAPIKeyToken mints a new random API token and returns it alongside the hash to persist.
func NormalizeName ¶ added in v0.12.0
Types ¶
type APIKey ¶ added in v0.13.0
type APIKey struct {
ID string
CreatedAt time.Time
UpdatedAt time.Time
Name string
TokenHash string
UserID string
LastUsedAt *time.Time
ExpiresAt *time.Time // nil = never expires
}
APIKey grants REST API access as a user. Only a hash of the token is stored; the token itself is shown once at mint time.
func (*APIKey) DisplayName ¶ added in v0.13.0
DisplayName returns the key's name, falling back to its ID when unnamed.
type File ¶
type File struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Size uint64 `json:"size"`
Private bool `json:"private"`
Type string `json:"type"`
UserID string `json:"-"`
Name string `json:"name,omitempty"`
}
func (*File) DisplayName ¶ added in v0.12.0
func (*File) GetSignedURL ¶
func (*File) IsMarkdown ¶
func (*File) Visibility ¶
Click to show internal directories.
Click to hide internal directories.