unitlab 2.3.15__tar.gz → 2.3.16__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitlab
3
- Version: 2.3.15
3
+ Version: 2.3.16
4
4
  Home-page: https://github.com/teamunitlab/unitlab-sdk
5
5
  Author: Unitlab Inc.
6
6
  Author-email: team@unitlab.ai
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="unitlab",
5
- version="2.3.15",
5
+ version="2.3.16",
6
6
  license="MIT",
7
7
  author="Unitlab Inc.",
8
8
  author_email="team@unitlab.ai",
@@ -231,9 +231,12 @@ class CloudflareAPITunnel:
231
231
  # Create new tunnel
232
232
  print(f"📦 Creating new tunnel: {tunnel_name}")
233
233
  create_url = f"{self.api_base}/accounts/{self.account_id}/tunnels"
234
+ # Generate secret first
235
+ tunnel_secret = os.urandom(32).hex()
236
+
234
237
  create_data = {
235
238
  "name": tunnel_name,
236
- "tunnel_secret": os.urandom(32).hex() # Generate random secret
239
+ "tunnel_secret": tunnel_secret
237
240
  }
238
241
 
239
242
  create_response = requests.post(create_url, headers=self.headers, json=create_data)
@@ -242,6 +245,9 @@ class CloudflareAPITunnel:
242
245
  existing_tunnel = create_response.json()['result']
243
246
  print(f"✅ Created tunnel: {tunnel_name}")
244
247
 
248
+ # Add the secret to the tunnel info (API doesn't return it)
249
+ existing_tunnel['tunnel_secret'] = tunnel_secret
250
+
245
251
  # Save credentials for this tunnel
246
252
  self._save_tunnel_credentials(existing_tunnel)
247
253
 
@@ -308,19 +314,32 @@ class CloudflareAPITunnel:
308
314
  def _save_tunnel_credentials(self, tunnel_info):
309
315
  """
310
316
  Save tunnel credentials locally for this device
317
+ Credentials must be base64 encoded for cloudflared
311
318
  """
319
+ import base64
320
+ import json
321
+
312
322
  creds_dir = Path.home() / '.cloudflared'
313
323
  creds_dir.mkdir(exist_ok=True)
314
324
 
315
325
  creds_file = creds_dir / f"{tunnel_info['id']}.json"
316
326
 
327
+ # Get the secret - it should be hex string
328
+ secret_hex = tunnel_info.get('tunnel_secret') or tunnel_info.get('secret')
329
+ if secret_hex:
330
+ # Convert hex to bytes then to base64
331
+ secret_bytes = bytes.fromhex(secret_hex)
332
+ secret_b64 = base64.b64encode(secret_bytes).decode('ascii')
333
+ else:
334
+ print("⚠️ No tunnel secret found")
335
+ return None
336
+
317
337
  credentials = {
318
338
  "AccountTag": self.account_id,
319
- "TunnelSecret": tunnel_info.get('tunnel_secret') or tunnel_info.get('secret'),
339
+ "TunnelSecret": secret_b64, # Must be base64!
320
340
  "TunnelID": tunnel_info['id']
321
341
  }
322
342
 
323
- import json
324
343
  with open(creds_file, 'w') as f:
325
344
  json.dump(credentials, f)
326
345
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitlab
3
- Version: 2.3.15
3
+ Version: 2.3.16
4
4
  Home-page: https://github.com/teamunitlab/unitlab-sdk
5
5
  Author: Unitlab Inc.
6
6
  Author-email: team@unitlab.ai
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes