Container contract expects signature of container ID value,
which is SHA256 of container body. Not the signature of stable
marshaled container.ID structure.
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Object service of NeoFS API contains one client-side stream method:
object.Put. In client-side streams, server can return an error after
processing stream message. In this case write method returns `io.EOF`
and actual error reason is encoded in response status, which is
obtained after `Close()`. Client library should process such case.
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Remove `signature` and `util/signature` packages. Re-implement their
functionality in new `crypto` package. Generalize the approach of
digital signature computation and verification by adding `Signer` and
`PublicKey` primitives similar to standard `crypto` package. Support
already exising in protocol signature schemes.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Get rid of `Option` pattern. Define `Init`, `Dial` and `Close` methods
for the corresponding stages of use.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Some callbacks, such as `close()` -> `result(v2)` may
generate new errors, so `processCall` should not ignore
them.
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Extend docs with supported status returns. Add several helper functions
which allow to check the particular status.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define `SessionTokenNotFound`/`SessionTokenExpired` types for
`TOKEN_NOT_FOUND`/`TOKEN_EXPIRED` codes.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define `ObjectAccessDenied` type for `ACCESS_DENIED` code. Provide
method to write/read human-readable reason.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Add `TypeLock` value to `Type` enum. Implement `Lock` type compatible
with corresponding message. Implement `ObjectLocked` and
`IrregularObjectLock` errors in `apistatus` package.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Allow `SignOption` to set 2 parameters:
1. Default signature scheme, which is used in case scheme is
unspecified.
2. Restrict scheme option which also checks that scheme is either
unspecified or equal to the restricted scheme. This is only used
for verification and is necessary because some of the signatures
are used in smart-contracts.
Also provide signature struct to sign/verify functions in helpers.
The constant names differ a bit from those in API because of linter
complaints.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
In previous implementation `Close` method of `ObjectReader` /
`ObjectRangeReader` could incorrectly return `io.ErrUnexpectedEOF` of
payload wasn't read by `Read` method (in this case
`remainingPayloadLen` state var is not updated).
Return `io.ErrUnexpectedEOF` from `Read` method only.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation all `Read` methods read single response
per-call, so buffer could be incompletely filled w/o an error. In order
to follow `io.Reader` docs we need to continue filling the buffer while
it is possible.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation `ObjectListReader.Read` returned `false` on
server responded with empty ID list. This could cause premature end of
reading since the protocol does not forbid intermediate empty lists.
Do not stop if ID list from response body is empty.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation payload chunks were split into pieces with
512B length. This led to sending a large number of messages with a large
amount of payload.
Increase per-message payload chunk limit to 3MB.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
We should provide the ability to customize private of object HEAD /
DELETE ops.
Implement `UseKey` method on `PrmObjectHead` / `PrmObjectDelete` types.
Sign requests with the specified key if called.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Add helper function which accepts container and object identifiers and
returns object instance read to the memory.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
From now session token for `SetEACL` operation should be written into
eACL table structure (similar to `PutContainer`).
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Make `ObjectReader` / `ObjectRangeReader` to track number of bytes read
and return:
* `io.ErrUnexpectedEOF` if the stream finished by the server before
the last byte of the payload was read.
* an error if more object payload size bytes was read.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
PutContainer method takes `container.Container` structure
as an argument. This structure already contains session
token field, so there is no need in `prmSession` because it
duplicates session token definition.
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This is done to prevent import cycles when `object` package needs any other
that requires `object.ID` or `object.Address`.
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Define `WrongMagicNumber` type for which encapsulates the work with
incorrect network magic. Provide method to read/write the correct magic
(which is a status detail in NeoFS API V2 protocol).
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define `XPrm` type for each `X` client operation which structures
parameters. Export setters of each parameterized value. Emphasize that
some parameters are required. Make the client panic when the parameters
are incorrectly set. Get rid of vadiadic call options and `CallOption`
type. Improve documentation of client behavior.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In the latest NeoFS protocol update, each request is provided with a
network magic number. We have to provide the ability to set it on
the client.
Add `WithNetworkMagic` option constructor which accepts magic number.
Write the number to meta header of the all requests.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This option make client parse all NeoFS error statuses and return them as
errors from method calls (not as part of result structure). This is done
for applications that want to handle errors as it is customary in golang.
Default behaviour (construction client without new option) has not been
changed.
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Make all `Client` methods to return structured values and error. Parse v2
status messages in all RPC and provide status getter from all result
structures. Returns status failures as status result instead of error.
Interface changes:
* all methods return `<method>Res` structure;
* rename some methods to be more clear;
* unify TZ and SHA256 objecy payload hashing in single method.
Behavior changes:
* client doesn't verify object header structure received via Object.Head.
If the caller was tied to verification, now it must do it explicitly.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define base `Status` interface. Provide the functionality to distinguish
success and failure returns. Provide functionality to transport statuses
over NeoFS API V2 protocol. Support success `OK` and failure `INTERNAL`
returns.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>