In previous implementation `processResponse` returned `true` if
`resolveAPIFailures` is set and status failure is received. This led to
post-processing of the results, which no longer pays attention to the
status. For example, `ObjectHead` returned `unexpected header type`
error due to empty body.
Make `contextCall.processResponse` to return success flag regardless of
`resolveAPIFailures` setting. Make `contextCall.processCall` to return
`err` field presence flag on `processResponse` false return.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
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>