diff --git a/client/errors.go b/client/errors.go index 367f31f..5880a4d 100644 --- a/client/errors.go +++ b/client/errors.go @@ -17,6 +17,8 @@ var ( ErrMissingObject = errors.New("missing object") // ErrMissingAccount is returned when account/owner is not provided. ErrMissingAccount = errors.New("missing account") + // ErrMissingSigner is returned when signer is not provided. + ErrMissingSigner = errors.New("missing signer") // ErrMissingEACL is returned when eACL table is not provided. ErrMissingEACL = errors.New("missing eACL table") // ErrMissingEACLContainer is returned when container info is not provided in eACL table. diff --git a/client/session.go b/client/session.go index b749202..a56f810 100644 --- a/client/session.go +++ b/client/session.go @@ -66,9 +66,21 @@ func (x ResSessionCreate) PublicKey() []byte { // see [apistatus] package for NeoFS-specific error types. // // Context is required and must not be nil. It is used for network communication. +// +// Return errors: +// - [ErrMissingSigner] func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResSessionCreate, error) { + signer := prm.signer + if signer == nil { + signer = c.prm.signer + } + + if signer == nil { + return nil, ErrMissingSigner + } + var ownerID user.ID - if err := user.IDFromSigner(&ownerID, prm.signer); err != nil { + if err := user.IDFromSigner(&ownerID, signer); err != nil { return nil, fmt.Errorf("IDFromSigner: %w", err) } @@ -93,11 +105,7 @@ func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResS ) c.initCallContext(&cc) - cc.signer = prm.signer - if cc.signer == nil { - cc.signer = c.prm.signer - } - + cc.signer = signer cc.meta = prm.prmCommonMeta cc.req = &req cc.call = func() (responseV2, error) {