singlestoredb 1.4.2__py3-none-any.whl → 1.4.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of singlestoredb might be problematic. Click here for more details.

singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.4.2'
16
+ __version__ = '1.4.3'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -123,14 +123,14 @@ class NamedList(List[T]):
123
123
  def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
124
124
  """Setup authentication info event handler."""
125
125
 
126
- authentication_info: List[Tuple[str, Any]] = []
126
+ authentication_info: Dict[str, Any] = {}
127
127
 
128
128
  def handle_authentication_info(msg: Dict[str, Any]) -> None:
129
129
  """Handle authentication info events."""
130
130
  nonlocal authentication_info
131
131
  if msg.get('name', '') != 'singlestore.portal.authentication_updated':
132
132
  return
133
- authentication_info = list(msg.get('data', {}).items())
133
+ authentication_info = dict(msg.get('data', {}))
134
134
 
135
135
  events.subscribe(handle_authentication_info)
136
136
 
@@ -145,11 +145,27 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
145
145
  out['user'] = data['user']
146
146
  if 'password' in data:
147
147
  out['password'] = data['password']
148
- authentication_info = list(out.items())
148
+ authentication_info = out
149
149
 
150
150
  events.subscribe(handle_authentication_info)
151
151
 
152
+ def retrieve_current_authentication_info() -> List[Tuple[str, Any]]:
153
+ """Retrieve JWT if not expired."""
154
+ nonlocal authentication_info
155
+ password = authentication_info.get('password')
156
+ if password:
157
+ expires = datetime.datetime.fromtimestamp(
158
+ jwt.decode(
159
+ password,
160
+ options={'verify_signature': False},
161
+ )['exp'],
162
+ )
163
+ if datetime.datetime.now() > expires:
164
+ authentication_info = {}
165
+ return list(authentication_info.items())
166
+
152
167
  def get_env() -> List[Tuple[str, Any]]:
168
+ """Retrieve JWT from environment."""
153
169
  conn = {}
154
170
  url = os.environ.get('SINGLESTOREDB_URL') or get_option('host')
155
171
  if url:
@@ -170,7 +186,7 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
170
186
  return dict(
171
187
  itertools.chain(
172
188
  (get_env() if include_env else []),
173
- authentication_info,
189
+ retrieve_current_authentication_info(),
174
190
  ),
175
191
  )
176
192
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: Interface to the SingleStoreDB database and workspace management APIs
5
5
  Home-page: https://github.com/singlestore-labs/singlestoredb-python
6
6
  Author: SingleStore
@@ -1,4 +1,4 @@
1
- singlestoredb/__init__.py,sha256=SfeLqsR2jOT4we91ZMxK9oJ2C9sUVj10O_kZ_Z2SyOo,1634
1
+ singlestoredb/__init__.py,sha256=NTrIpxhbm7oMxrNbbjVKdK-4ShuyvUChQlP3z-kL9Ko,1634
2
2
  singlestoredb/auth.py,sha256=u8D9tpKzrqa4ssaHjyZnGDX1q8XBpGtuoOkTkSv7B28,7599
3
3
  singlestoredb/config.py,sha256=H4pQxqBEGGCmVHg40VEnAdqGXHun8ougZzj-Ed6ZLH4,11822
4
4
  singlestoredb/connection.py,sha256=WL_TSSHhhjLV0pnJOtaeMAf0o1DI-PJv9xnLFf_cM08,45173
@@ -37,7 +37,7 @@ singlestoredb/management/cluster.py,sha256=i23Smr1PBrDZ8NO_VPd_-bEYkyHvVe9CCRGUj
37
37
  singlestoredb/management/manager.py,sha256=sFP1vZGS8WpN8E0XLu1N7Mxtq6Sixalln44HlTQEyXI,8800
38
38
  singlestoredb/management/organization.py,sha256=Y0JFSxYF_UOjip53gcbBXWPCe_t92zo3d99jZNrhkx4,4995
39
39
  singlestoredb/management/region.py,sha256=HnLcWUh7r_aLECliplCDHak4a_F3B7LOSXEYMW66qD0,1611
40
- singlestoredb/management/utils.py,sha256=nTsGTDgl8lmjwcfl2nMS6feRn5P-jUjHlkVGzG5qrXM,10783
40
+ singlestoredb/management/utils.py,sha256=t-O6NRb4Wad1qJJ1afxtFR1IX-0bezEqplKllnm8tto,11398
41
41
  singlestoredb/management/workspace.py,sha256=9oamNIaE5vLZNAlpl5SK-xu27qPqx2Ff3ZIdKckNfmc,61673
42
42
  singlestoredb/mysql/__init__.py,sha256=olUTAvkiERhDW41JXQMawkg-i0tvBEkoTkII1tt6lxU,4492
43
43
  singlestoredb/mysql/_auth.py,sha256=AugRitoUwgRIDFuJxuAH4MWIAmckY7Ji2pP6r_Ng9dY,8043
@@ -114,9 +114,9 @@ singlestoredb/utils/events.py,sha256=9IB84T3pKQjs7aaoSSJCw7soNngnhoTDWIC52M51R9Y
114
114
  singlestoredb/utils/mogrify.py,sha256=-a56IF70U6CkfadeaZgfjRSVsAD3PuqRrzPpjZlgbwY,4050
115
115
  singlestoredb/utils/results.py,sha256=bJtaUaDiFq26IsPAKZ2FHGB7csMn94EAxLKrP4HaEEA,15277
116
116
  singlestoredb/utils/xdict.py,sha256=S9HKgrPrnu_6b7iOwa2KrW8CmU1Uqx0BWdEyogFzWbE,12896
117
- singlestoredb-1.4.2.dist-info/LICENSE,sha256=Mlq78idURT-9G026aMYswwwnnrLcgzTLuXeAs5hjDLM,11341
118
- singlestoredb-1.4.2.dist-info/METADATA,sha256=zlYnLLjR9xrlJNZv-RBFelx0IM_iinyWKGwoKIC8udI,5570
119
- singlestoredb-1.4.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
120
- singlestoredb-1.4.2.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
121
- singlestoredb-1.4.2.dist-info/top_level.txt,sha256=eet8bVPNRqiGeY0PrO5ERH2UpamwlrKHEQCffz4dOh8,14
122
- singlestoredb-1.4.2.dist-info/RECORD,,
117
+ singlestoredb-1.4.3.dist-info/LICENSE,sha256=Mlq78idURT-9G026aMYswwwnnrLcgzTLuXeAs5hjDLM,11341
118
+ singlestoredb-1.4.3.dist-info/METADATA,sha256=sNKDftR6stTzMfX0NjKgcevlLjU9SQKhU6861nPiXQE,5570
119
+ singlestoredb-1.4.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
120
+ singlestoredb-1.4.3.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
121
+ singlestoredb-1.4.3.dist-info/top_level.txt,sha256=eet8bVPNRqiGeY0PrO5ERH2UpamwlrKHEQCffz4dOh8,14
122
+ singlestoredb-1.4.3.dist-info/RECORD,,