In previous implementation `client` package provided access to nested
response fields as pointers to them. This caused clients to handle nil
cases even when the field presence in the response is required.
Avoid returning pointers to required fields in response getters. This
also reduces reference counter load and allows fields to be decoded
directly without additional assignment.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Session token and signature isn't presented in `Container` and
`EACLTable` messages of NeoFS API V2 protocol. These entities are needed
for access control and doesn't carry payload of these messages.
Remove `SetSessionToken` / `SessionToken` methods of
`container.Container` and `eacl.Table` types. Provide methods to specify
these components in corresponding `Client` operations.
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>
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>
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>
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>
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>
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>
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>
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>