Documentation ¶
Index ¶
- Variables
- func AddPendingPreview(ctx context.Context, g *globals.Context, obr *chat1.OutboxRecord) error
- func AssetFromMessage(ctx context.Context, g *globals.Context, uid gregor1.UID, ...) (res chat1.Asset, err error)
- func DetectMIMEType(ctx context.Context, src ReadResetter, filename string) (res string, err error)
- func Download(ctx context.Context, g *globals.Context, uid gregor1.UID, ...) error
- func Quarantine(ctx context.Context, path string) error
- func SinkFromFilename(ctx context.Context, g *globals.Context, uid gregor1.UID, ...) (string, io.WriteCloser, error)
- type AttachmentInfo
- type AttachmentStash
- type BufReadResetter
- type Decrypter
- type Dimension
- type Encrypter
- type ErrorWrapper
- type FileReadResetter
- type FileStash
- type Gallery
- type NextMessageOptions
- type PendingPreviews
- type Preprocess
- type PreviewRes
- type PutS3Result
- type ReadResetter
- type S3Signer
- type S3Store
- func (a *S3Store) DecryptAsset(ctx context.Context, w io.Writer, body io.Reader, asset chat1.Asset, ...) error
- func (a *S3Store) DeleteAsset(ctx context.Context, params chat1.S3Params, signer s3.Signer, ...) error
- func (a *S3Store) DeleteAssets(ctx context.Context, params chat1.S3Params, signer s3.Signer, ...) error
- func (a *S3Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer, ...) error
- func (a *S3Store) GetAssetReader(ctx context.Context, params chat1.S3Params, asset chat1.Asset, ...) (io.ReadCloser, error)
- func (a *S3Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, ...) (res *PutS3Result, err error)
- func (a *S3Store) StreamAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, ...) (io.ReadSeeker, error)
- func (a *S3Store) UploadAsset(ctx context.Context, task *UploadTask, encryptedOut io.Writer) (res chat1.Asset, err error)
- type Sender
- func (s *Sender) MakePreview(ctx context.Context, filename string, outboxID chat1.OutboxID) (res chat1.MakePreviewRes, err error)
- func (s *Sender) PostFileAttachment(ctx context.Context, sender types.Sender, uid gregor1.UID, ...) (outboxID chat1.OutboxID, msgID *chat1.MessageID, err error)
- func (s *Sender) PostFileAttachmentMessage(ctx context.Context, sender types.Sender, convID chat1.ConversationID, ...) (outboxID chat1.OutboxID, msgID *chat1.MessageID, err error)
- type SignDecrypter
- type SignEncrypter
- func (s *SignEncrypter) Encrypt(r io.Reader) (io.Reader, error)
- func (s *SignEncrypter) EncryptKey() []byte
- func (s *SignEncrypter) EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, ...) (io.Reader, error)
- func (s *SignEncrypter) EncryptWithNonce(r io.Reader, nonce signencrypt.Nonce) (io.Reader, error)
- func (s *SignEncrypter) EncryptedLen(size int64) int64
- func (s *SignEncrypter) SignKey() []byte
- func (s *SignEncrypter) VerifyKey() []byte
- type StashKey
- type Store
- type UploadTask
- type Uploader
- func (u *Uploader) Cancel(ctx context.Context, outboxID chat1.OutboxID) (err error)
- func (u *Uploader) Complete(ctx context.Context, outboxID chat1.OutboxID)
- func (u *Uploader) GetUploadTempFile(ctx context.Context, outboxID chat1.OutboxID, filename string) (string, error)
- func (u *Uploader) Register(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, ...) (res types.AttachmentUploaderResultCb, err error)
- func (u *Uploader) Retry(ctx context.Context, outboxID chat1.OutboxID) (res types.AttachmentUploaderResultCb, err error)
- func (u *Uploader) SetPreviewTempDir(dir string)
- func (u *Uploader) Status(ctx context.Context, outboxID chat1.OutboxID) (status types.AttachmentUploaderTaskStatus, res types.AttachmentUploadResult, ...)
Constants ¶
This section is empty.
Variables ¶
var ErrAbortOnPartMismatch = errors.New("local part mismatch, aborting upload")
ErrAbortOnPartMismatch is returned when there is a mismatch between a current part and a previous attempt part. If ErrAbortOnPartMismatch is returned, the caller should abort the upload attempt and start from scratch.
var ErrPartNotFound = errors.New("part does not exist in stash")
Functions ¶
func AddPendingPreview ¶
func AssetFromMessage ¶
func DetectMIMEType ¶
Types ¶
type AttachmentInfo ¶
type AttachmentInfo struct { ObjectKey string // s3 destination EncKey signencrypt.SecretboxKey // encryption key SignKey signencrypt.SignKey // signing key VerifyKey signencrypt.VerifyKey // verification key Parts map[int]string // map of parts uploaded to S3, key == part number, value == hash of ciphertext StartedAt time.Time // when the upload started }
type AttachmentStash ¶
type BufReadResetter ¶
type BufReadResetter struct {
// contains filtered or unexported fields
}
func NewBufReadResetter ¶
func NewBufReadResetter(buf []byte) *BufReadResetter
func (*BufReadResetter) Reset ¶
func (b *BufReadResetter) Reset() error
type Decrypter ¶
type Decrypter interface { // Decrypt takes a ciphertext reader, encryption and verify keys. // It returns a plaintext reader. It uses the constant nonce. Decrypt(ciphertext io.Reader, encKey, verifyKey []byte) (plaintext io.Reader) // DecryptWithNonce takes a ciphertext reader, nonce, encryption and verify keys. // It returns a plaintext reader. DecryptWithNonce(ciphertext io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader) }
type Encrypter ¶
type Encrypter interface { // EncryptedLen returns the number of bytes that the ciphertext of // size plaintext bytes will be. EncryptedLen(size int) int // Encrypt takes a plaintext reader and returns a ciphertext reader. // It generates new keys every time it is called and uses a // constant nonce. Encrypt(plaintext io.Reader) (ciphertext io.Reader, err error) // EncryptWithNonce takes a plaintext reader and returns a ciphertext reader. // It generates new keys every time it is called and uses // the provided nonce. EncryptWithNonce(plaintext io.Reader, nonce signencrypt.Nonce) (ciphertext io.Reader, err error) // EncryptResume takes a plaintext reader and a set of keys. It // returns a ciphertext reader. It *does not* generate new keys // but uses the parameter keys. These keys should *only* be used // to encrypt the same plaintext as a previous attempt. EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error) // EncryptKey returns the ephemeral key that was used during the // last invocation of Encrypt. EncryptKey() []byte // VerifyKey returns the public portion of the signing key used during // the last invocation of Encrypt. It can be used for signature // verification. VerifyKey() []byte }
type ErrorWrapper ¶
type ErrorWrapper struct {
// contains filtered or unexported fields
}
func NewErrorWrapper ¶
func NewErrorWrapper(prefix string, err error) *ErrorWrapper
func (*ErrorWrapper) Details ¶
func (e *ErrorWrapper) Details() string
func (*ErrorWrapper) Error ¶
func (e *ErrorWrapper) Error() string
type FileReadResetter ¶
type FileReadResetter struct {
// contains filtered or unexported fields
}
func NewFileReadResetter ¶
func NewFileReadResetter(name string) (*FileReadResetter, error)
func (*FileReadResetter) Close ¶
func (f *FileReadResetter) Close() error
func (*FileReadResetter) Reset ¶
func (f *FileReadResetter) Reset() error
type Gallery ¶
type Gallery struct { globals.Contextified utils.DebugLabeler PrevStride, NextStride int }
func NewGallery ¶
func (*Gallery) NextMessage ¶
func (g *Gallery) NextMessage(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, msgID chat1.MessageID, opts NextMessageOptions) (res *chat1.MessageUnboxed, err error)
type NextMessageOptions ¶
type NextMessageOptions struct { BackInTime bool AssetTypes []chat1.AssetMetadataType }
type PendingPreviews ¶
type PendingPreviews struct { globals.Contextified utils.DebugLabeler }
func NewPendingPreviews ¶
func NewPendingPreviews(g *globals.Context) *PendingPreviews
func (*PendingPreviews) Get ¶
func (p *PendingPreviews) Get(ctx context.Context, outboxID chat1.OutboxID) (res Preprocess, err error)
func (*PendingPreviews) Put ¶
func (p *PendingPreviews) Put(ctx context.Context, outboxID chat1.OutboxID, pre Preprocess) (err error)
type Preprocess ¶
type Preprocess struct { ContentType string Preview []byte PreviewContentType string BaseDim *Dimension BaseDurationMs int PreviewDim *Dimension PreviewDurationMs int }
func PreprocessAsset ¶
func PreprocessAsset(ctx context.Context, log utils.DebugLabeler, src ReadResetter, filename string, nvh types.NativeVideoHelper, callerPreview *chat1.MakePreviewRes) (p Preprocess, err error)
func (*Preprocess) BaseMetadata ¶
func (p *Preprocess) BaseMetadata() chat1.AssetMetadata
func (*Preprocess) Export ¶
func (p *Preprocess) Export(getLocation func() *chat1.PreviewLocation) (res chat1.MakePreviewRes, err error)
func (*Preprocess) PreviewMetadata ¶
func (p *Preprocess) PreviewMetadata() chat1.AssetMetadata
type PreviewRes ¶
type PreviewRes struct { Source []byte ContentType string BaseWidth int BaseHeight int BaseDurationMs int PreviewWidth int PreviewHeight int PreviewDurationMs int }
func Preview ¶
func Preview(ctx context.Context, log utils.DebugLabeler, src ReadResetter, contentType, basename string, nvh types.NativeVideoHelper) (*PreviewRes, error)
Preview creates preview assets from src. It returns an in-memory BufferSource and the content type of the preview asset.
type PutS3Result ¶
PutS3Result is the success result of calling PutS3.
type ReadResetter ¶
type S3Signer ¶
type S3Signer struct {
// contains filtered or unexported fields
}
func NewS3Signer ¶
func NewS3Signer(ri func() chat1.RemoteInterface) *S3Signer
type S3Store ¶
type S3Store struct { utils.DebugLabeler // contains filtered or unexported fields }
func NewS3Store ¶
NewS3Store creates a standard Store that uses a real S3 connection.
func NewStoreTesting ¶
NewStoreTesting creates an Store suitable for testing purposes. It is not exposed outside this package. It uses an in-memory s3 interface, reports enc/sig keys, and allows limiting the number of blocks uploaded.
func (*S3Store) DecryptAsset ¶
func (*S3Store) DeleteAsset ¶
func (*S3Store) DeleteAssets ¶
func (*S3Store) DownloadAsset ¶
func (a *S3Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer, signer s3.Signer, progress types.ProgressReporter) error
DownloadAsset gets an object from S3 as described in asset.
func (*S3Store) GetAssetReader ¶
func (*S3Store) PutS3 ¶
func (a *S3Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, previous *AttachmentInfo) (res *PutS3Result, err error)
PutS3 uploads the data in Reader r to S3. It chooses whether to use putSingle or putMultiPipeline based on the size of the object.
func (*S3Store) StreamAsset ¶
type Sender ¶
type Sender struct { globals.Contextified utils.DebugLabeler }
func (*Sender) MakePreview ¶
func (*Sender) PostFileAttachment ¶
func (s *Sender) PostFileAttachment(ctx context.Context, sender types.Sender, uid gregor1.UID, convID chat1.ConversationID, tlfName string, vis keybase1.TLFVisibility, inOutboxID *chat1.OutboxID, filename, title string, md []byte, clientPrev chat1.MessageID, ephemeralLifetime *gregor1.DurationSec, callerPreview *chat1.MakePreviewRes) (outboxID chat1.OutboxID, msgID *chat1.MessageID, err error)
func (*Sender) PostFileAttachmentMessage ¶
func (s *Sender) PostFileAttachmentMessage(ctx context.Context, sender types.Sender, convID chat1.ConversationID, tlfName string, vis keybase1.TLFVisibility, inOutboxID *chat1.OutboxID, filename, title string, md []byte, clientPrev chat1.MessageID, ephemeralLifetime *gregor1.DurationSec, callerPreview *chat1.MakePreviewRes) (outboxID chat1.OutboxID, msgID *chat1.MessageID, err error)
type SignDecrypter ¶
type SignDecrypter struct{}
func NewSignDecrypter ¶
func NewSignDecrypter() *SignDecrypter
func (*SignDecrypter) DecryptWithNonce ¶
func (s *SignDecrypter) DecryptWithNonce(r io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader)
type SignEncrypter ¶
type SignEncrypter struct {
// contains filtered or unexported fields
}
func NewSignEncrypter ¶
func NewSignEncrypter() *SignEncrypter
func (*SignEncrypter) EncryptKey ¶
func (s *SignEncrypter) EncryptKey() []byte
func (*SignEncrypter) EncryptResume ¶
func (s *SignEncrypter) EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error)
EncryptResume is used to create a SignEncrypter to resume an interrupted attachment upload. It is *very* important that the keys passed in are not used to encrypt different plaintext than their original usage.
func (*SignEncrypter) EncryptWithNonce ¶
func (s *SignEncrypter) EncryptWithNonce(r io.Reader, nonce signencrypt.Nonce) (io.Reader, error)
func (*SignEncrypter) EncryptedLen ¶
func (s *SignEncrypter) EncryptedLen(size int64) int64
func (*SignEncrypter) SignKey ¶
func (s *SignEncrypter) SignKey() []byte
func (*SignEncrypter) VerifyKey ¶
func (s *SignEncrypter) VerifyKey() []byte
type Store ¶
type Store interface { UploadAsset(ctx context.Context, task *UploadTask, encryptedOut io.Writer) (chat1.Asset, error) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer, signer s3.Signer, progress types.ProgressReporter) error GetAssetReader(ctx context.Context, params chat1.S3Params, asset chat1.Asset, signer s3.Signer) (io.ReadCloser, error) StreamAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, signer s3.Signer) (io.ReadSeeker, error) DecryptAsset(ctx context.Context, w io.Writer, body io.Reader, asset chat1.Asset, progress types.ProgressReporter) error DeleteAsset(ctx context.Context, params chat1.S3Params, signer s3.Signer, asset chat1.Asset) error DeleteAssets(ctx context.Context, params chat1.S3Params, signer s3.Signer, assets []chat1.Asset) error }
type UploadTask ¶
type UploadTask struct { S3Params chat1.S3Params Filename string FileSize int64 Plaintext ReadResetter S3Signer s3.Signer ConversationID chat1.ConversationID UserID gregor1.UID OutboxID chat1.OutboxID Preview bool Progress types.ProgressReporter // contains filtered or unexported fields }
func (*UploadTask) Nonce ¶
func (u *UploadTask) Nonce() signencrypt.Nonce
type Uploader ¶
type Uploader struct { globals.Contextified utils.DebugLabeler sync.Mutex // contains filtered or unexported fields }