From 7df00fb0eb6b592030249e901fffb508b544d0bd Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 16 Feb 2022 16:57:18 +0300 Subject: [PATCH] [#137] Add exp to ResSessionCreate Signed-off-by: Denis Kirillov --- client/session.go | 12 ++++++++++++ pool/pool.go | 1 + 2 files changed, 13 insertions(+) diff --git a/client/session.go b/client/session.go index ca490eb1..d6051be9 100644 --- a/client/session.go +++ b/client/session.go @@ -28,6 +28,8 @@ type ResSessionCreate struct { id []byte sessionKey []byte + + exp uint64 } func (x *ResSessionCreate) setID(id []byte) { @@ -50,6 +52,15 @@ func (x ResSessionCreate) PublicKey() []byte { return x.sessionKey } +func (x *ResSessionCreate) setExp(exp uint64) { + x.exp = exp +} + +// Expiration returns epoch number of the token expiration. +func (x ResSessionCreate) Expiration() uint64 { + return x.exp +} + // SessionCreate opens a session with the node server on the remote endpoint. // The session lifetime coincides with the server lifetime. Results can be written // to session token which can be later attached to the requests. @@ -104,6 +115,7 @@ func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResS res.setID(body.GetID()) res.setSessionKey(body.GetSessionKey()) + res.setExp(reqBody.GetExpiration()) } // process call diff --git a/pool/pool.go b/pool/pool.go index 51c88eec..372566f5 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -1671,6 +1671,7 @@ func sessionTokenForOwner(id *owner.ID, cliRes *sdkClient.ResSessionCreate) *ses st.SetOwnerID(id) st.SetID(cliRes.ID()) st.SetSessionKey(cliRes.PublicKey()) + st.SetExp(cliRes.Expiration()) return st }