mobile

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mobile contains the simplified mobile APIs to Storj Network.

For API limitations see https://github.com/ethereum/go-ethereum/blob/461291882edce0ac4a28f64c4e8725b7f57cbeae/mobile/doc.go#L23

build loop for development

watchrun gobind -lang=java -outdir=../mobile-out storj.io/storj/mobile == pt skipped ../mobile-out

gomobile bind -target android

To use:

gomobile bind -target android

Create a new project in AndroidStudio

Copy mobile-source.jar and mobile.aar into `AndroidStudioProjects\MyApplication\app\libs\`

Modify build.gradle to also find *.aar files:

implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

See example Java file

Index

Constants

View Source
const (
	// CipherSuiteEncUnspecified indicates no encryption suite has been selected.
	CipherSuiteEncUnspecified = byte(storj.EncUnspecified)
	// CipherSuiteEncNull indicates use of the NULL cipher; that is, no encryption is
	// done. The ciphertext is equal to the plaintext.
	CipherSuiteEncNull = byte(storj.EncNull)
	// CipherSuiteEncAESGCM indicates use of AES128-GCM encryption.
	CipherSuiteEncAESGCM = byte(storj.EncAESGCM)
	// CipherSuiteEncSecretBox indicates use of XSalsa20-Poly1305 encryption, as provided
	// by the NaCl cryptography library under the name "Secretbox".
	CipherSuiteEncSecretBox = byte(storj.EncSecretBox)

	// DirectionForward lists forwards from cursor, including cursor
	DirectionForward = int(storj.Forward)

	// DirectionAfter lists forwards from cursor, without cursor
	DirectionAfter = int(storj.After)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

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

APIKey represents an access credential to certain resources

func ParseAPIKey

func ParseAPIKey(val string) (*APIKey, error)

ParseAPIKey parses an API key

func (*APIKey) IsZero

func (a *APIKey) IsZero() bool

IsZero returns if the api key is an uninitialized value

func (APIKey) Restrict

func (a APIKey) Restrict(caveat *Caveat) (*APIKey, error)

Restrict generates a new APIKey with the provided Caveat attached.

func (APIKey) Serialize

func (a APIKey) Serialize() string

Serialize serializes the API key to a string

type Bucket

type Bucket struct {
	Name string
	// contains filtered or unexported fields
}

Bucket represents operations you can perform on a bucket

func (*Bucket) Close

func (bucket *Bucket) Close() error

Close closes the Bucket session.

func (*Bucket) DeleteObject

func (bucket *Bucket) DeleteObject(objectPath string) error

DeleteObject removes an object, if authorized.

func (*Bucket) ListObjects

func (bucket *Bucket) ListObjects(options *ListOptions) (*ObjectList, error)

ListObjects list objects in bucket, if authorized.

func (*Bucket) NewRangeReader added in v0.24.0

func (bucket *Bucket) NewRangeReader(path storj.Path, start, limit int64, options *ReaderOptions) (*Reader, error)

NewRangeReader returns new reader for downloading a range from the object.

func (*Bucket) NewReader

func (bucket *Bucket) NewReader(path storj.Path, options *ReaderOptions) (*Reader, error)

NewReader returns new reader for downloading object.

func (*Bucket) NewWriter

func (bucket *Bucket) NewWriter(path storj.Path, options *WriterOptions) (*Writer, error)

NewWriter creates instance of Writer

func (*Bucket) OpenObject

func (bucket *Bucket) OpenObject(objectPath string) (*ObjectInfo, error)

OpenObject returns an Object handle, if authorized.

type BucketConfig

type BucketConfig struct {
	// PathCipher indicates which cipher suite is to be used for path
	// encryption within the new Bucket. If not set, AES-GCM encryption
	// will be used.
	PathCipher byte

	// EncryptionParameters specifies the default encryption parameters to
	// be used for data encryption of new Objects in this bucket.
	EncryptionParameters *EncryptionParameters

	// RedundancyScheme defines the default Reed-Solomon and/or
	// Forward Error Correction encoding parameters to be used by
	// objects in this Bucket.
	RedundancyScheme *RedundancyScheme
	// SegmentsSize is the default segment size to use for new
	// objects in this Bucket.
	SegmentsSize int64
}

BucketConfig bucket configuration

type BucketInfo

type BucketInfo struct {
	Name                 string
	Created              int64
	PathCipher           byte
	SegmentsSize         int64
	RedundancyScheme     *RedundancyScheme
	EncryptionParameters *EncryptionParameters
}

BucketInfo bucket meta struct

type BucketList

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

BucketList is a list of buckets

func (*BucketList) Item

func (bl *BucketList) Item(index int) (*BucketInfo, error)

Item gets item from specific index

func (*BucketList) Length

func (bl *BucketList) Length() int

Length returns number of returned items

func (*BucketList) More

func (bl *BucketList) More() bool

More returns true if list request was not able to return all results

type Caveat

type Caveat struct {
	DisallowReads   bool
	DisallowWrites  bool
	DisallowLists   bool
	DisallowDeletes bool
	AllowedPaths    []*CaveatPath
	// if set, the validity time window
	NotAfter  int64
	NotBefore int64
	// nonce is set to some random bytes so that you can make arbitrarily
	// many restricted macaroons with the same (or no) restrictions.
	Nonce []byte
}

Caveat TODO

func NewCaveat

func NewCaveat() *Caveat

NewCaveat TODO

func (Caveat) AddCaveatPath

func (caveat Caveat) AddCaveatPath(path *CaveatPath)

AddCaveatPath TODO

type CaveatPath

type CaveatPath struct {
	Bucket              []byte
	EncryptedPathPrefix []byte
}

CaveatPath If any entries exist, require all access to happen in at least one of them.

type Config

type Config struct {

	// MaxInlineSize determines whether the uplink will attempt to
	// store a new object in the satellite's metainfo. Objects at
	// or below this size will be marked for inline storage, and
	// objects above this size will not. (The satellite may reject
	// the inline storage and require remote storage, still.)
	MaxInlineSize int64

	// MaxMemory is the default maximum amount of memory to be
	// allocated for read buffers while performing decodes of
	// objects. (This option is overrideable per Bucket if the user
	// so desires.) If set to zero, the library default (4 MiB) will
	// be used. If set to a negative value, the system will use the
	// smallest amount of memory it can.
	MaxMemory int64

	// SkipPeerCAWhitelist determines whether to require all
	// remote hosts to have identity certificates signed by
	// Certificate Authorities in the default whitelist. If
	// set to true, the whitelist will be ignored.
	SkipPeerCAWhitelist bool
}

Config represents configuration options for an Uplink

type EncryptionAccess

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

EncryptionAccess holds data about encryption keys for a bucket.

func NewEncryptionAccess

func NewEncryptionAccess() *EncryptionAccess

NewEncryptionAccess constructs an empty encryption context.

func NewEncryptionAccessWithDefaultKey

func NewEncryptionAccessWithDefaultKey(defaultKey []byte) (_ *EncryptionAccess, err error)

NewEncryptionAccessWithDefaultKey creates an encryption access context with a default key set. Use Project.SaltedKeyFromPassphrase to generate a default key

func NewEncryptionAccessWithRoot

func NewEncryptionAccessWithRoot(bucket, unencryptedPath, encryptedPath string, keyData []byte) (*EncryptionAccess, error)

NewEncryptionAccessWithRoot constructs an encryption access with a key rooted at the provided path inside of a bucket.

func ParseEncryptionAccess

func ParseEncryptionAccess(b58data string) (*EncryptionAccess, error)

ParseEncryptionAccess parses the base58 encoded encryption context data and returns the resulting context.

func (*EncryptionAccess) Import added in v0.24.0

func (e *EncryptionAccess) Import(other *EncryptionAccess) error

Import merges the other encryption access context into this one. In cases of conflicting path decryption settings (including if both accesses have a default key), the new settings are kept.

func (*EncryptionAccess) Restrict added in v0.24.0

func (e *EncryptionAccess) Restrict(satelliteAddr string, apiKey *APIKey, restrictions *EncryptionRestrictions) (_ *Scope, err error)

Restrict creates a new EncryptionAccess with no default key, where the key material in the new access is just enough to allow someone to access all of the given restrictions but no more.

func (*EncryptionAccess) Serialize

func (e *EncryptionAccess) Serialize() (b58data string, err error)

Serialize returns a base58-serialized encryption access for use with later parsing.

func (*EncryptionAccess) SetDefaultKey

func (e *EncryptionAccess) SetDefaultKey(keyData []byte) error

SetDefaultKey sets the default key to use when no matching keys are found for the encryption context.

type EncryptionParameters

type EncryptionParameters struct {
	// CipherSuite specifies the cipher suite to be used for encryption.
	CipherSuite byte
	// BlockSize determines the unit size at which encryption is performed.
	// It is important to distinguish this from the block size used by the
	// cipher suite (probably 128 bits). There is some small overhead for
	// each encryption unit, so BlockSize should not be too small, but
	// smaller sizes yield shorter first-byte latency and better seek times.
	// Note that BlockSize itself is the size of data blocks _after_ they
	// have been encrypted and the authentication overhead has been added.
	// It is _not_ the size of the data blocks to _be_ encrypted.
	BlockSize int32
}

EncryptionParameters is the cipher suite and parameters used for encryption

type EncryptionRestriction added in v0.24.0

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

EncryptionRestriction represents a scenario where some set of objects may need to be encrypted/decrypted

func NewEncryptionRestriction added in v0.24.0

func NewEncryptionRestriction(bucket, path string) *EncryptionRestriction

NewEncryptionRestriction creates new EncryptionRestriction

type EncryptionRestrictions added in v0.24.0

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

EncryptionRestrictions combines EncryptionRestriction to overcome gomobile limitation (no arrays)

func NewEncryptionRestrictions added in v0.24.0

func NewEncryptionRestrictions() *EncryptionRestrictions

NewEncryptionRestrictions creates new EncryptionRestrictions

func (*EncryptionRestrictions) Add added in v0.24.0

func (e *EncryptionRestrictions) Add(restriction *EncryptionRestriction)

Add adds EncryptionRestriction

type ListOptions

type ListOptions struct {
	Prefix    string
	Cursor    string // Cursor is relative to Prefix, full path is Prefix + Cursor
	Delimiter int32
	Recursive bool
	Direction int
	Limit     int
}

ListOptions options for listing objects

type ObjectInfo

type ObjectInfo struct {
	Version     int32
	Bucket      string
	Path        string
	IsPrefix    bool
	Size        int64
	ContentType string
	Created     int64
	Modified    int64
	Expires     int64
	// contains filtered or unexported fields
}

ObjectInfo object metadata

func (*ObjectInfo) GetMetadata

func (bl *ObjectInfo) GetMetadata(key string) string

GetMetadata gets objects custom metadata

type ObjectList

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

ObjectList represents list of objects

func (*ObjectList) Bucket

func (bl *ObjectList) Bucket() string

Bucket returns bucket name

func (*ObjectList) Item

func (bl *ObjectList) Item(index int) (*ObjectInfo, error)

Item gets item from specific index

func (*ObjectList) Length

func (bl *ObjectList) Length() int

Length returns number of returned items

func (*ObjectList) More

func (bl *ObjectList) More() bool

More returns true if list request was not able to return all results

func (*ObjectList) Prefix

func (bl *ObjectList) Prefix() string

Prefix prefix for objects from list

type Project

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

Project represents a specific project access session.

func (*Project) Close

func (project *Project) Close() error

Close closes the Project

func (*Project) CreateBucket

func (project *Project) CreateBucket(bucketName string, opts *BucketConfig) (*BucketInfo, error)

CreateBucket creates buckets in project

func (*Project) DeleteBucket

func (project *Project) DeleteBucket(bucketName string) error

DeleteBucket deletes a bucket if authorized. If the bucket contains any Objects at the time of deletion, they may be lost permanently.

func (*Project) GetBucketInfo

func (project *Project) GetBucketInfo(bucketName string) (*BucketInfo, error)

GetBucketInfo returns info about the requested bucket if authorized.

func (*Project) ListBuckets

func (project *Project) ListBuckets(after string, limit int) (*BucketList, error)

ListBuckets will list authorized buckets.

func (*Project) OpenBucket

func (project *Project) OpenBucket(bucketName string, access *EncryptionAccess) (*Bucket, error)

OpenBucket returns a Bucket handle with the given EncryptionAccess information.

func (*Project) SaltedKeyFromPassphrase

func (project *Project) SaltedKeyFromPassphrase(passphrase string) (keyData []byte, err error)

SaltedKeyFromPassphrase returns a key generated from the given passphrase using a stable, project-specific salt

type Reader

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

Reader reader for downloading object

func (*Reader) Cancel

func (r *Reader) Cancel()

Cancel cancels read operation

func (*Reader) Close

func (r *Reader) Close() error

Close closes reader

func (*Reader) Read

func (r *Reader) Read(data []byte, offset, length int32) (n int32, err error)

Read reads data into byte array

type ReaderOptions

type ReaderOptions struct {
}

ReaderOptions options for reading

type RedundancyScheme

type RedundancyScheme struct {
	// Algorithm determines the algorithm to be used for redundancy.
	Algorithm byte

	// ShareSize is the size to use for new redundancy shares.
	ShareSize int32

	// RequiredShares is the minimum number of shares required to recover a
	// segment.
	RequiredShares int16
	// RepairShares is the minimum number of safe shares that can remain
	// before a repair is triggered.
	RepairShares int16
	// OptimalShares is the desired total number of shares for a segment.
	OptimalShares int16
	// TotalShares is the number of shares to encode. If it is larger than
	// OptimalShares, slower uploads of the excess shares will be aborted in
	// order to improve performance.
	TotalShares int16
}

RedundancyScheme specifies the parameters and the algorithm for redundancy

type Scope

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

Scope is a serializable type that represents all of the credentials you need to open a project and some amount of buckets

func NewScope added in v0.24.0

func NewScope(satelliteAddr string, apiKey *APIKey, encryptionAccess *EncryptionAccess) *Scope

NewScope creates new Scope

func ParseScope

func ParseScope(scopeb58 string) (*Scope, error)

ParseScope unmarshals a base58 encoded scope protobuf and decodes the fields into the Scope convenience type. It will return an error if the protobuf is malformed or field validation fails.

func (*Scope) APIKey

func (s *Scope) APIKey() *APIKey

APIKey return APIKey

func (*Scope) EncryptionAccess

func (s *Scope) EncryptionAccess() *EncryptionAccess

EncryptionAccess returns encryption address

func (*Scope) SatelliteAddr

func (s *Scope) SatelliteAddr() string

SatelliteAddr return satellite address

func (*Scope) Serialize

func (s *Scope) Serialize() (string, error)

Serialize serializes a Scope to a base58-encoded string

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

Uplink represents the main entrypoint to Storj V3. An Uplink connects to a specific Satellite and caches connections and resources, allowing one to create sessions delineated by specific access controls.

func NewUplink(config *Config, tempDir string) (*Uplink, error)

NewUplink creates a new Uplink. This is the first step to create an uplink session with a user specified config or with default config, if nil config. Uplink needs also writable temporary directory.

func (*Uplink) Close

func (uplink *Uplink) Close() error

Close closes the Uplink. This may not do anything at present, but should still be called to allow forward compatibility. No Project or Bucket objects using this Uplink should be used after calling Close.

func (*Uplink) OpenProject

func (uplink *Uplink) OpenProject(satellite string, apikey string) (*Project, error)

OpenProject returns a Project handle with the given APIKey

type Writer

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

Writer writes data into object

func (*Writer) Cancel

func (w *Writer) Cancel()

Cancel cancels writing operation

func (*Writer) Close

func (w *Writer) Close() error

Close closes writer

func (*Writer) Write

func (w *Writer) Write(data []byte, offset, length int32) (int32, error)

Write writes data.length bytes from data to the underlying data stream.

type WriterOptions

type WriterOptions struct {
	// ContentType, if set, gives a MIME content-type for the Object.
	ContentType string
	// Metadata contains additional information about an Object. It can
	// hold arbitrary textual fields and can be retrieved together with the
	// Object. Field names can be at most 1024 bytes long. Field values are
	// not individually limited in size, but the total of all metadata
	// (fields and values) can not exceed 4 kiB.
	Metadata map[string]string
	// Expires is the time at which the new Object can expire (be deleted
	// automatically from storage nodes).
	Expires int

	// EncryptionParameters determines the cipher suite to use for
	// the Object's data encryption. If not set, the Bucket's
	// defaults will be used.
	EncryptionParameters *EncryptionParameters

	// RedundancyScheme determines the Reed-Solomon and/or Forward
	// Error Correction encoding parameters to be used for this
	// Object.
	RedundancyScheme *RedundancyScheme
}

WriterOptions controls options about writing a new Object

func NewWriterOptions

func NewWriterOptions() *WriterOptions

NewWriterOptions creates writer options

Jump to

Keyboard shortcuts

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