uipath 2.1.3__py3-none-any.whl → 2.1.4__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.
@@ -1,10 +1,12 @@
1
+ import asyncio
1
2
  import http.server
2
3
  import json
3
4
  import os
4
5
  import socketserver
6
+ import threading
5
7
  import time
8
+ from typing import Optional
6
9
 
7
- import click
8
10
  from dotenv import load_dotenv
9
11
 
10
12
  from ._oidc_utils import get_auth_config
@@ -117,9 +119,11 @@ class HTTPServer:
117
119
  """
118
120
  self.current_path = os.path.dirname(os.path.abspath(__file__))
119
121
  self.port = port
120
- self.httpd = None
122
+ self.httpd: Optional[socketserver.TCPServer] = None
121
123
  self.token_data = None
122
124
  self.should_shutdown = False
125
+ self.token_received_event: Optional[asyncio.Event] = None
126
+ self.loop = None
123
127
 
124
128
  def token_received_callback(self, token_data):
125
129
  """Callback for when a token is received.
@@ -128,7 +132,8 @@ class HTTPServer:
128
132
  token_data (dict): The received token data.
129
133
  """
130
134
  self.token_data = token_data
131
- self.should_shutdown = True
135
+ if self.token_received_event and self.loop:
136
+ self.loop.call_soon_threadsafe(self.token_received_event.set)
132
137
 
133
138
  def create_server(self, state, code_verifier, domain):
134
139
  """Create and configure the HTTP server.
@@ -149,7 +154,16 @@ class HTTPServer:
149
154
  self.httpd = socketserver.TCPServer(("", self.port), handler)
150
155
  return self.httpd
151
156
 
152
- def start(self, state, code_verifier, domain):
157
+ def _run_server(self):
158
+ """Run server loop in thread."""
159
+ try:
160
+ while not self.should_shutdown and self.httpd:
161
+ self.httpd.handle_request()
162
+ except Exception:
163
+ # Server might be closed, that's fine
164
+ pass
165
+
166
+ async def start(self, state, code_verifier, domain):
153
167
  """Start the server.
154
168
 
155
169
  Args:
@@ -163,12 +177,16 @@ class HTTPServer:
163
177
  if not self.httpd:
164
178
  self.create_server(state, code_verifier, domain)
165
179
 
180
+ self.token_received_event = asyncio.Event()
181
+ self.loop = asyncio.get_event_loop()
182
+
183
+ # Run server in daemon thread
184
+ server_thread = threading.Thread(target=self._run_server, daemon=True)
185
+ server_thread.start()
186
+
166
187
  try:
167
- if self.httpd:
168
- while not self.should_shutdown:
169
- self.httpd.handle_request()
170
- except KeyboardInterrupt:
171
- click.echo("Process interrupted by user")
188
+ # Wait indefinitely for token received event or interrupt
189
+ await self.token_received_event.wait()
172
190
  finally:
173
191
  self.stop()
174
192
 
@@ -176,6 +194,7 @@ class HTTPServer:
176
194
 
177
195
  def stop(self):
178
196
  """Stop the server gracefully and cleanup resources."""
197
+ self.should_shutdown = True
179
198
  if self.httpd:
180
199
  self.httpd.server_close()
181
200
  self.httpd = None
@@ -6,19 +6,452 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>UiPath CLI Authentication</title>
8
8
  <style>
9
- button {
10
- opacity: 0;
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ box-sizing: border-box;
13
+ }
14
+
15
+ body {
16
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
17
+ background-color: rgb(241, 246, 248);
18
+ color: #24292e;
19
+ line-height: 1.5;
20
+ min-height: 100vh;
21
+ display: flex;
22
+ flex-direction: column;
23
+ }
24
+
25
+ .header {
26
+ background-color: #ffffff;
27
+ border-bottom: 1px solid #e1e4e8;
28
+ padding: 16px 0;
29
+ }
30
+
31
+ .header-content {
32
+ max-width: 1200px;
33
+ margin: 0 auto;
34
+ padding: 0 16px;
35
+ display: flex;
36
+ align-items: center;
37
+ }
38
+
39
+ .logo {
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ margin: 32px 0;
44
+ font-size: 20px;
45
+ font-weight: 600;
46
+ color: #24292e;
47
+ text-decoration: none;
48
+ }
49
+
50
+ .logo-icon {
51
+ width: 120px;
52
+ height: 40px;
53
+ margin-right: 12px;
54
+ }
55
+
56
+ .container {
57
+ flex: 1;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ padding: 40px 16px;
62
+ }
63
+
64
+ .auth-card {
65
+ background: #ffffff;
66
+ border: 1px solid #e1e4e8;
67
+ border-radius: 6px;
68
+ padding: 32px;
69
+ max-width: 440px;
70
+ width: 100%;
71
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
72
+ }
73
+
74
+ .auth-header {
75
+ text-align: center;
76
+ margin-bottom: 24px;
77
+ }
78
+
79
+ .auth-title {
80
+ font-size: 24px;
81
+ font-weight: 600;
82
+ color: #24292e;
83
+ margin-bottom: 8px;
84
+ }
85
+
86
+ .auth-subtitle {
87
+ font-size: 16px;
88
+ color: #586069;
89
+ }
90
+
91
+ .status-section {
92
+ margin: 24px 0;
93
+ }
94
+
95
+ .status-indicator {
96
+ display: flex;
97
+ align-items: center;
98
+ justify-content: center;
99
+ margin-bottom: 16px;
100
+ }
101
+
102
+ .spinner {
103
+ width: 24px;
104
+ height: 24px;
105
+ border: 3px solid #e1e4e8;
106
+ border-top: 3px solid #fa4616;
107
+ border-radius: 50%;
108
+ animation: spin 1s linear infinite;
109
+ display: none;
110
+ }
111
+
112
+ @keyframes spin {
113
+ 0% {
114
+ transform: rotate(0deg);
115
+ }
116
+
117
+ 100% {
118
+ transform: rotate(360deg);
119
+ }
120
+ }
121
+
122
+ .success-check {
123
+ width: 48px;
124
+ height: 48px;
125
+ background-color: #28a745;
126
+ border-radius: 50%;
127
+ display: none;
128
+ align-items: center;
129
+ justify-content: center;
130
+ color: white;
131
+ font-size: 24px;
132
+ font-weight: bold;
133
+ }
134
+
135
+ .error-x {
136
+ width: 48px;
137
+ height: 48px;
138
+ background-color: #d73a49;
139
+ border-radius: 50%;
140
+ display: none;
141
+ align-items: center;
142
+ justify-content: center;
143
+ color: white;
144
+ font-size: 20px;
145
+ font-weight: bold;
146
+ }
147
+
148
+ .status-message {
149
+ text-align: center;
150
+ font-size: 16px;
151
+ color: #586069;
152
+ margin-bottom: 16px;
153
+ }
154
+
155
+ .status-message.success {
156
+ color: #28a745;
157
+ }
158
+
159
+ .status-message.error {
160
+ color: #d73a49;
161
+ }
162
+
163
+ .progress-container {
164
+ margin: 16px 0;
165
+ }
166
+
167
+ .progress-bar {
168
+ width: 100%;
169
+ height: 8px;
170
+ background-color: #e1e4e8;
171
+ border-radius: 4px;
172
+ overflow: hidden;
173
+ }
174
+
175
+ .progress-fill {
176
+ height: 100%;
177
+ background-color: #fa4616;
178
+ border-radius: 4px;
179
+ width: 0%;
180
+ transition: width 0.3s ease;
181
+ }
182
+
183
+ .info-box {
184
+ background-color: #f6f8fa;
185
+ border: 1px solid #e1e4e8;
186
+ border-radius: 6px;
187
+ padding: 16px;
188
+ margin: 16px 0;
189
+ font-size: 14px;
190
+ color: #586069;
191
+ display: none;
192
+ }
193
+
194
+ .info-box.show {
195
+ display: block;
196
+ }
197
+
198
+ .info-box strong {
199
+ color: #24292e;
200
+ }
201
+
202
+ .action-buttons {
203
+ text-align: center;
204
+ margin-top: 24px;
205
+ }
206
+
207
+ .btn {
208
+ display: inline-block;
209
+ padding: 8px 16px;
210
+ font-size: 14px;
211
+ font-weight: 500;
212
+ line-height: 20px;
213
+ white-space: nowrap;
214
+ vertical-align: middle;
215
+ cursor: pointer;
216
+ border: 1px solid;
217
+ border-radius: 6px;
218
+ text-decoration: none;
219
+ transition: all 0.15s ease-in-out;
220
+ }
221
+
222
+ .btn-primary {
223
+ color: #ffffff;
224
+ background-color: #fa4616;
225
+ border-color: #fa4616;
226
+ }
227
+
228
+ .btn-primary:hover {
229
+ background-color: #e63e14;
230
+ border-color: #e63e14;
231
+ }
232
+
233
+ .btn-secondary {
234
+ color: #24292e;
235
+ background-color: #f6f8fa;
236
+ border-color: #e1e4e8;
237
+ }
238
+
239
+ .btn-secondary:hover {
240
+ background-color: #e1e4e8;
241
+ border-color: #d0d7de;
242
+ }
243
+
244
+ .debug-section {
245
+ margin-top: 24px;
246
+ border-top: 1px solid #e1e4e8;
247
+ padding-top: 16px;
248
+ }
249
+
250
+ .debug-toggle {
251
+ font-size: 12px;
252
+ color: #586069;
253
+ background: none;
254
+ border: none;
255
+ cursor: pointer;
256
+ text-decoration: underline;
257
+ }
258
+
259
+ .debug-toggle:hover {
260
+ color: #24292e;
261
+ }
262
+
263
+ .debug-log {
264
+ background-color: #f6f8fa;
265
+ border: 1px solid #e1e4e8;
266
+ border-radius: 6px;
267
+ padding: 12px;
268
+ margin-top: 8px;
269
+ font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
270
+ font-size: 12px;
271
+ color: #24292e;
272
+ max-height: 200px;
273
+ overflow-y: auto;
274
+ white-space: pre-wrap;
275
+ display: none;
276
+ }
277
+
278
+ .debug-log.show {
279
+ display: block;
280
+ }
281
+
282
+ @media (max-width: 544px) {
283
+ .auth-card {
284
+ border: none;
285
+ box-shadow: none;
286
+ padding: 24px 16px;
287
+ }
288
+
289
+ .auth-title {
290
+ font-size: 20px;
291
+ }
292
+ }
293
+
294
+ /* Fade in animation */
295
+ .fade-in {
296
+ animation: fadeIn 0.3s ease-in;
297
+ }
298
+
299
+ @keyframes fadeIn {
300
+ from {
301
+ opacity: 0;
302
+ transform: translateY(10px);
303
+ }
304
+
305
+ to {
306
+ opacity: 1;
307
+ transform: translateY(0);
308
+ }
11
309
  }
12
310
  </style>
13
311
  </head>
14
312
 
15
313
  <body>
16
- <h1>UiPath CLI Authentication</h1>
17
- <button type="button" onclick="window.open('', '_self', ''); window.close();">Discard</button>
18
- <pre id="log"></pre>
314
+
315
+
316
+ <main class="container">
317
+ <div class="auth-card fade-in">
318
+ <div class="logo">
319
+ <svg class="logo-icon" focusable="false" aria-hidden="false" role="img" viewBox="0 0 62 21" width="120"
320
+ height="40" fill="none" xmlns="http://www.w3.org/2000/svg">
321
+ <path
322
+ d="M10.5847 6.01996H10.2875C9.51138 6.01996 9.0293 6.49219 9.0293 7.25215V13.3657C9.0293 16.2642 8.12889 17.4465 5.92142 17.4465C3.71394 17.4465 2.81351 16.2589 2.81351 13.3474V7.25216C2.81351 6.49219 2.33141 6.01996 1.55545 6.01996H1.2581C0.482103 6.01996 0 6.49219 0 7.25216V13.3657C0 17.7812 1.9923 20.02 5.92142 20.02C9.85054 20.02 11.8427 17.7812 11.8427 13.3657V7.25216C11.8427 6.49219 11.3606 6.01996 10.5847 6.01996Z"
323
+ fill="#000000"></path>
324
+ <path
325
+ d="M15.3983 9.7298H15.152C14.3567 9.7298 13.8628 10.2204 13.8628 11.0098V18.74C13.8628 19.5294 14.3567 20.02 15.152 20.02H15.3983C16.1934 20.02 16.6874 19.5294 16.6874 18.74V11.0098C16.6874 10.2203 16.1934 9.7298 15.3983 9.7298Z"
326
+ fill="#fa4616"></path>
327
+ <path
328
+ d="M18.8096 4.9445C17.0123 4.66045 15.594 3.26496 15.3053 1.49653C15.2999 1.46315 15.2559 1.46315 15.2504 1.49653C14.9618 3.26496 13.5435 4.66045 11.7462 4.9445C11.7122 4.94985 11.7122 4.99314 11.7462 4.99849C13.5435 5.28248 14.9618 6.67803 15.2504 8.44646C15.2559 8.47984 15.2999 8.47984 15.3053 8.44646C15.594 6.67803 17.0123 5.28248 18.8096 4.99849C18.8435 4.99314 18.8435 4.94985 18.8096 4.9445ZM17.0437 4.98499C16.1451 5.12699 15.4359 5.82476 15.2916 6.70898C15.2889 6.72567 15.2669 6.72567 15.2642 6.70898C15.1198 5.82476 14.4107 5.12699 13.512 4.98499C13.495 4.98231 13.495 4.96067 13.512 4.958C14.4107 4.81597 15.1198 4.11822 15.2642 3.23401C15.2669 3.21732 15.2889 3.21732 15.2916 3.23401C15.4359 4.11822 16.1451 4.81597 17.0437 4.958C17.0607 4.96067 17.0607 4.98231 17.0437 4.98499Z"
329
+ fill="#fa4616"></path>
330
+ <path
331
+ d="M19.8865 2.18349C18.9878 2.32548 18.2787 3.02325 18.1343 3.90747C18.1316 3.92416 18.1096 3.92416 18.1069 3.90747C17.9626 3.02325 17.2534 2.32548 16.3548 2.18349C16.3378 2.18081 16.3378 2.15917 16.3548 2.15649C17.2534 2.01447 17.9626 1.31672 18.1069 0.432502C18.1096 0.41581 18.1316 0.41581 18.1343 0.432502C18.2787 1.31672 18.9878 2.01446 19.8865 2.15649C19.9035 2.15917 19.9035 2.18081 19.8865 2.18349Z"
332
+ fill="#fa4616"></path>
333
+ <path
334
+ d="M22.8632 6.01996H20.1216C19.3373 6.01996 18.8501 6.49722 18.8501 7.26531V18.7746C18.8501 19.5427 19.3374 20.02 20.1216 20.02H20.4222C21.2064 20.02 21.6937 19.5427 21.6937 18.7746V16.0502H22.8819C27.6395 16.0502 29.5801 14.5973 29.5801 11.0351C29.5801 7.47291 27.6341 6.01996 22.8632 6.01996ZM26.6991 10.9983C26.6991 12.8309 25.8116 13.4493 23.1823 13.4493H21.6937V8.5657H23.1823C25.8116 8.5657 26.6991 9.17948 26.6991 10.9983Z"
335
+ fill="#000000"></path>
336
+ <path
337
+ d="M40.1401 8.6104H39.9147C39.1305 8.6104 38.6433 9.08767 38.6433 9.85576V9.85735C37.8378 8.94386 36.5902 8.4082 35.1642 8.4082C33.7113 8.4082 32.3975 8.93097 31.4648 9.88042C30.4488 10.9143 29.9119 12.4066 29.9119 14.1957C29.9119 15.9926 30.452 17.4935 31.4739 18.536C32.4119 19.4929 33.7291 20.02 35.1829 20.02C36.5819 20.02 37.8388 19.4777 38.6443 18.5774C38.6443 18.5783 38.6444 18.8369 38.6444 18.8378C38.6705 19.5689 39.1522 20.02 39.9147 20.02H40.1401C40.9244 20.02 41.4117 19.5429 41.4117 18.7748V9.85576C41.4117 9.08768 40.9244 8.6104 40.1401 8.6104ZM38.6996 14.1957C38.6996 16.2973 37.5536 17.6029 35.7087 17.6029C33.8407 17.6029 32.6803 16.2973 32.6803 14.1957C32.6803 12.1053 33.8263 10.8068 35.6712 10.8068C37.5108 10.8068 38.6996 12.1371 38.6996 14.1957Z"
338
+ fill="#000000"></path>
339
+ <path
340
+ d="M56.5101 8.41922C55.0376 8.41922 53.9872 8.99357 53.3294 9.7174V7.2661C53.3294 6.49753 52.8419 6.01996 52.0571 6.01996H51.8317C51.0469 6.01996 50.5593 6.49753 50.5593 7.2661V18.7738C50.5593 19.5424 51.0469 20.02 51.8317 20.02H52.0571C52.8419 20.02 53.3294 19.5424 53.3294 18.7738V14.1551C53.3294 11.1982 54.7693 10.8562 55.8525 10.8562C57.6713 10.8562 58.4131 11.7428 58.4131 13.916V18.7738C58.4131 19.5424 58.9007 20.02 59.6855 20.02H59.911C60.6957 20.02 61.1832 19.5424 61.1832 18.7738V13.7503C61.1832 10.163 59.6547 8.41922 56.5101 8.41922Z"
341
+ fill="#000000"></path>
342
+ <path
343
+ d="M49.7629 18.6115C49.724 18.2411 49.4976 17.7119 48.4196 17.7119C47.1449 17.7119 46.5383 17.3228 46.5383 15.112V10.8563H48.4383C49.2218 10.8563 49.7086 10.421 49.7086 9.72061C49.7086 9.03146 49.2218 8.60325 48.4383 8.60325H46.5406V7.2661C46.5406 6.49753 46.0501 6.01996 45.2606 6.01996H45.0338C44.2443 6.01996 43.7538 6.49753 43.7538 7.2661V8.60325H43.317C42.626 8.60325 42.1968 9.03147 42.1968 9.72061C42.1968 10.421 42.6836 10.8563 43.4671 10.8563H43.7538V15.3513C43.7538 18.6237 45.0538 20.02 48.1007 20.02C48.1056 20.02 48.1106 20.0198 48.1155 20.0197C48.2927 20.0195 48.4824 20.0168 48.6757 19.9999C49.0598 19.9643 49.3503 19.8316 49.5392 19.6053C49.7274 19.38 49.8027 18.9843 49.7629 18.6115Z"
344
+ fill="#000000"></path>
345
+ </svg>
346
+ </div>
347
+
348
+ <div class="auth-header">
349
+ <h1 class="auth-title" id="main-title">Authenticate CLI</h1>
350
+ <p class="auth-subtitle" id="subtitle">Completing authentication flow...</p>
351
+ </div>
352
+
353
+ <div class="status-section">
354
+ <div class="status-indicator">
355
+ <div class="spinner" id="spinner"></div>
356
+ <div class="success-check" id="success-check">&check;</div>
357
+ <div class="error-x" id="error-x">&times;</div>
358
+ </div>
359
+
360
+ <div class="progress-container" id="progress-container">
361
+ <div class="progress-bar">
362
+ <div class="progress-fill" id="progress-fill"></div>
363
+ </div>
364
+ </div>
365
+
366
+ <div class="status-message" id="status-message">
367
+ Processing authentication request...
368
+ </div>
369
+ </div>
370
+
371
+ <div class="info-box" id="info-box">
372
+ <strong>Authenticating...</strong><br>
373
+ Securely exchanging authorization code for access tokens.
374
+ </div>
375
+
376
+ <div class="debug-section">
377
+ <button class="debug-toggle" onclick="toggleDebug()">Show debug info</button>
378
+ <div class="debug-log" id="debug-log"></div>
379
+ </div>
380
+ </div>
381
+ </main>
382
+
19
383
  <script>
20
384
  const baseUrl = '__PY_REPLACE_REDIRECT_URI__'.replace('/oidc/login', '');
21
385
  const logs = [];
386
+ let debugMode = false;
387
+
388
+ // UI Helper Functions
389
+ function showSpinner() {
390
+ document.getElementById('spinner').style.display = 'block';
391
+ document.getElementById('progress-container').style.display = 'block';
392
+ updateProgress(20);
393
+ }
394
+
395
+ function hideSpinner() {
396
+ document.getElementById('spinner').style.display = 'none';
397
+ }
398
+
399
+ function showSuccess() {
400
+ hideSpinner();
401
+ document.getElementById('success-check').style.display = 'flex';
402
+ document.getElementById('progress-container').style.display = 'none';
403
+ }
404
+
405
+ function showError() {
406
+ hideSpinner();
407
+ document.getElementById('error-x').style.display = 'flex';
408
+ document.getElementById('progress-container').style.display = 'none';
409
+ }
410
+
411
+ function updateProgress(percent) {
412
+ document.getElementById('progress-fill').style.width = percent + '%';
413
+ }
414
+
415
+ function updateStatus(message, type = 'normal') {
416
+ const statusEl = document.getElementById('status-message');
417
+ statusEl.textContent = message;
418
+ statusEl.className = `status-message ${type}`;
419
+ }
420
+
421
+ function showInfoBox(content) {
422
+ const infoBox = document.getElementById('info-box');
423
+ infoBox.innerHTML = content;
424
+ infoBox.classList.add('show');
425
+ }
426
+
427
+ function hideInfoBox() {
428
+ document.getElementById('info-box').classList.remove('show');
429
+ }
430
+
431
+ function toggleDebug() {
432
+ debugMode = !debugMode;
433
+ const logEl = document.getElementById('debug-log');
434
+ const toggleBtn = document.querySelector('.debug-toggle');
435
+
436
+ if (debugMode) {
437
+ logEl.textContent = JSON.stringify(logs, null, 2);
438
+ logEl.classList.add('show');
439
+ toggleBtn.textContent = 'Hide debug info';
440
+ } else {
441
+ logEl.classList.remove('show');
442
+ toggleBtn.textContent = 'Show debug info';
443
+ }
444
+ }
445
+
446
+ function closeWindow() {
447
+ try {
448
+ window.open('', '_self', '');
449
+ window.close();
450
+ } catch (e) {
451
+ window.location.href = 'about:blank';
452
+ }
453
+ }
454
+
22
455
  // Parse URL query parameters
23
456
  function getQueryParams() {
24
457
  const params = {};
@@ -34,7 +467,9 @@
34
467
  // Exchange authorization code for tokens
35
468
  async function exchangeCodeForToken(code, codeVerifier) {
36
469
  try {
37
- // Prepare form data for token request
470
+ updateProgress(50);
471
+ updateStatus('Exchanging authorization code...');
472
+
38
473
  const formData = new URLSearchParams();
39
474
  formData.append('grant_type', 'authorization_code');
40
475
  formData.append('code', code);
@@ -42,7 +477,6 @@
42
477
  formData.append('client_id', '__PY_REPLACE_CLIENT_ID__');
43
478
  formData.append('code_verifier', codeVerifier);
44
479
 
45
- // Make token request
46
480
  const response = await fetch('https://__PY_REPLACE_DOMAIN__.uipath.com/identity_/connect/token', {
47
481
  method: 'POST',
48
482
  headers: {
@@ -57,7 +491,7 @@
57
491
  }
58
492
 
59
493
  const tokenData = await response.json();
60
-
494
+ updateProgress(80);
61
495
  return tokenData;
62
496
  } catch (error) {
63
497
  console.error('Error exchanging code for token:', error);
@@ -70,27 +504,6 @@
70
504
  }
71
505
  }
72
506
 
73
- // Parse JWT token
74
- function parseJwt(token) {
75
- try {
76
- const base64Url = token.split('.')[1];
77
- const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
78
- const jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
79
- return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
80
- }).join(''));
81
-
82
- return JSON.parse(jsonPayload);
83
- } catch (e) {
84
- console.error('Error parsing JWT:', e);
85
- logs.push({
86
- timestamp: new Date().toISOString(),
87
- message: 'Error parsing JWT:',
88
- error: e.message
89
- });
90
- return null;
91
- }
92
- }
93
-
94
507
  async function delay(ms) {
95
508
  return new Promise(resolve => setTimeout(resolve, ms));
96
509
  }
@@ -102,66 +515,94 @@
102
515
  });
103
516
  }
104
517
 
105
- // Main function to handle the authentication flow
518
+ // Main authentication handler
106
519
  async function handleAuthentication() {
107
520
  const params = getQueryParams();
521
+ showSpinner();
108
522
 
109
523
  logs.push({
110
524
  timestamp: new Date().toISOString(),
111
- message: 'Params:',
525
+ message: 'Authentication started',
112
526
  params: params
113
527
  });
114
528
 
115
529
  try {
116
- // Check if we have an authorization code
117
530
  if (params.code && params.state) {
118
- // Get code verifier from session storage
531
+ updateStatus('Validating authorization...');
532
+ await delay(300);
533
+
119
534
  const codeVerifier = "__PY_REPLACE_CODE_VERIFIER__";
120
535
  const state = "__PY_REPLACE_EXPECTED_STATE__";
121
536
 
122
537
  if (!codeVerifier) {
123
- throw new Error('Code verifier not found in session storage');
538
+ throw new Error('Code verifier not found');
124
539
  }
125
540
 
126
541
  if (!params.state || params.state != state) {
127
- throw new Error('Invalid state parameter. Possible CSRF attack.');
542
+ throw new Error('Invalid state parameter');
128
543
  }
129
544
 
130
- // Exchange code for token
545
+ updateProgress(30);
131
546
  const tokenData = await exchangeCodeForToken(params.code, codeVerifier);
132
547
 
548
+ updateStatus('Sending credentials to CLI...');
549
+ updateProgress(90);
550
+
133
551
  await sendLogs(logs);
134
- const setTokenResult = await fetch(`${baseUrl}/set_token`, {
552
+ await fetch(`${baseUrl}/set_token`, {
135
553
  method: 'POST',
136
554
  body: JSON.stringify(tokenData)
137
555
  });
138
- // Show success message
139
- document.querySelector('h1').textContent = 'If this windows does not close automatically, you may close it now';
140
- setTimeout(() => {
141
- document.querySelector('button').click();
142
- }, 500);
143
556
 
144
- sessionStorage.removeItem('oidc_state');
145
- sessionStorage.removeItem('oidc_code_verifier');
557
+ updateProgress(100);
558
+ await delay(300);
559
+
560
+ // Success state
561
+ showSuccess();
562
+ document.getElementById('main-title').textContent = 'Authentication Complete';
563
+ document.getElementById('subtitle').textContent = 'Your CLI is now authenticated and ready to use';
564
+ updateStatus('You can close this tab', 'success');
565
+
566
+ // Auto-close after 3 seconds
567
+ setTimeout(closeWindow, 3000);
146
568
 
147
- // Remove code and state from URL to prevent refresh issues
148
569
  window.history.replaceState({}, document.title, window.location.pathname);
570
+
571
+ } else if (params.error) {
572
+ throw new Error(`OAuth error: ${params.error} - ${params.error_description || 'Unknown error'}`);
573
+ } else {
574
+ updateStatus('Waiting for authentication...');
575
+ showInfoBox(`
576
+ <strong>Waiting...</strong><br>
577
+ Complete the authentication process to continue.
578
+ `);
149
579
  }
150
580
  } catch (error) {
151
- console.error('Error during authentication:', error);
581
+ console.error('Authentication error:', error);
152
582
  logs.push({
153
583
  timestamp: new Date().toISOString(),
154
- message: 'Error during authentication:',
584
+ message: 'Authentication failed',
155
585
  error: error.message
156
586
  });
587
+
157
588
  await sendLogs(logs);
158
- document.querySelector('h1').textContent = 'Authentication failed. Please try again.';
589
+
590
+ showError();
591
+ document.getElementById('main-title').textContent = 'Authentication Failed';
592
+ document.getElementById('subtitle').textContent = 'Unable to complete authentication';
593
+ updateStatus(error.message, 'error');
594
+
595
+ showInfoBox(`
596
+ <strong>Error:</strong><br>
597
+ ${error.message}<br><br>
598
+ Please try running the authentication command again.
599
+ `);
159
600
  }
160
601
  }
161
602
 
162
- // Start authentication process when page loads
163
- handleAuthentication();
603
+ // Start when page loads
604
+ document.addEventListener('DOMContentLoaded', handleAuthentication);
164
605
  </script>
165
606
  </body>
166
607
 
167
- </html>
608
+ </html>
uipath/_cli/cli_auth.py CHANGED
@@ -1,4 +1,5 @@
1
1
  # type: ignore
2
+ import asyncio
2
3
  import json
3
4
  import os
4
5
  import socket
@@ -159,10 +160,16 @@ def auth(
159
160
  auth_url,
160
161
  )
161
162
 
162
- server = HTTPServer(port=auth_config["port"])
163
- token_data = server.start(state, code_verifier, domain)
163
+ try:
164
+ server = HTTPServer(port=auth_config["port"])
165
+ token_data = asyncio.run(server.start(state, code_verifier, domain))
166
+
167
+ if not token_data:
168
+ console.error(
169
+ "Authentication failed. Please try again.",
170
+ )
171
+ return
164
172
 
165
- if token_data:
166
173
  portal_service.update_token_data(token_data)
167
174
  update_auth_file(token_data)
168
175
  access_token = token_data["access_token"]
@@ -181,7 +188,7 @@ def auth(
181
188
  console.error(
182
189
  "Could not prepare the environment. Please try again.",
183
190
  )
184
- else:
191
+ except KeyboardInterrupt:
185
192
  console.error(
186
- "Authentication failed. Please try again.",
193
+ "Authentication cancelled by user.",
187
194
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath
3
- Version: 2.1.3
3
+ Version: 2.1.4
4
4
  Summary: Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools.
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-python
@@ -6,7 +6,7 @@ uipath/_uipath.py,sha256=ZfEcqpY7NRSm6rB2OPgyVXBl9DCnn750ikq8VzzTO_s,4146
6
6
  uipath/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  uipath/_cli/README.md,sha256=GLtCfbeIKZKNnGTCsfSVqRQ27V1btT1i2bSAyW_xZl4,474
8
8
  uipath/_cli/__init__.py,sha256=vGz3vJHkUvgK9_lKdzqiwwHkge1TCALRiOzGGwyr-8E,1885
9
- uipath/_cli/cli_auth.py,sha256=kWk0tznOxmU6xwhJgUAMipTevH2iTIotcNiIwmPlpYI,6507
9
+ uipath/_cli/cli_auth.py,sha256=RUSBHfmqhBtITrx52FeXMlVCuNyo8vrjTdjEhmM1Khw,6734
10
10
  uipath/_cli/cli_deploy.py,sha256=KPCmQ0c_NYD5JofSDao5r6QYxHshVCRxlWDVnQvlp5w,645
11
11
  uipath/_cli/cli_init.py,sha256=SmB7VplpXRSa5sgqgzojNsZDw0zfsEi2TfkMx3eQpTo,5132
12
12
  uipath/_cli/cli_invoke.py,sha256=FurosrZNGlmANIrplKWhw3EQ1b46ph5Z2rPwVaYJgmc,4001
@@ -16,14 +16,14 @@ uipath/_cli/cli_publish.py,sha256=QT17JTClAyLve6ZjB-WvQaJ-j4DdmNneV_eDRyXjeeQ,65
16
16
  uipath/_cli/cli_run.py,sha256=cTZYWJkGk2ruk6RRJBXII9J6VjpgGmysv_KlKI1JMHo,6446
17
17
  uipath/_cli/middlewares.py,sha256=CN-QqV69zZPI-hvizvEIb-zTcNh9WjsZIYCF3_nHSio,4915
18
18
  uipath/_cli/spinner.py,sha256=bS-U_HA5yne11ejUERu7CQoXmWdabUD2bm62EfEdV8M,1107
19
- uipath/_cli/_auth/_auth_server.py,sha256=p93_EvJpdoLLkiVmLygHRKo9ru1-PZOEAaEhNFN3j6c,6424
19
+ uipath/_cli/_auth/_auth_server.py,sha256=Wx3TaK5QvGzaJytp2cnYO3NFVIvTsNqxfVMwBquEyQs,7162
20
20
  uipath/_cli/_auth/_client_credentials.py,sha256=eENVb54-uzEqi7bC5VNjsiULW4fSfs-sK0kgUjRKorA,5412
21
21
  uipath/_cli/_auth/_models.py,sha256=sYMCfvmprIqnZxStlD_Dxx2bcxgn0Ri4D7uwemwkcNg,948
22
22
  uipath/_cli/_auth/_oidc_utils.py,sha256=WaX9jDlXrlX6yD8i8gsocV8ngjaT72Xd1tvsZMmSbco,2127
23
23
  uipath/_cli/_auth/_portal_service.py,sha256=iAxEDEY7OcEbIUSKNZnURAuNsimNmU90NLHkkTLqREY,8079
24
24
  uipath/_cli/_auth/_utils.py,sha256=9nb76xe5XmDZ0TAncp-_1SKqL6FdwRi9eS3C2noN1lY,1591
25
25
  uipath/_cli/_auth/auth_config.json,sha256=xwh6paXwW3TDIsz2UHP_q3TxmBW-njFXh1q4Nd0knUA,411
26
- uipath/_cli/_auth/index.html,sha256=ML_xDOcKs0ETYucufJskiYfWSvdrD_E26C0Qd3qpGj8,6280
26
+ uipath/_cli/_auth/index.html,sha256=_Q2OtqPfapG_6vumbQYqtb2PfFe0smk7TlGERKEBvB4,22518
27
27
  uipath/_cli/_auth/localhost.crt,sha256=oGl9oLLOiouHubAt39B4zEfylFvKEtbtr_43SIliXJc,1226
28
28
  uipath/_cli/_auth/localhost.key,sha256=X31VYXD8scZtmGA837dGX5l6G-LXHLo5ItWJhZXaz3c,1679
29
29
  uipath/_cli/_runtime/_contracts.py,sha256=j81Ou6Xz24K2UwEsxU-efvd775xKnZt08Rit94VZEYg,15251
@@ -95,8 +95,8 @@ uipath/tracing/_traced.py,sha256=qeVDrds2OUnpdUIA0RhtF0kg2dlAZhyC1RRkI-qivTM,185
95
95
  uipath/tracing/_utils.py,sha256=ZeensQexnw69jVcsVrGyED7mPlAU-L1agDGm6_1A3oc,10388
96
96
  uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
97
97
  uipath/utils/_endpoints_manager.py,sha256=hiGEu6vyfQJoeiiql6w21TNiG6tADUfXlVBimxPU1-Q,4160
98
- uipath-2.1.3.dist-info/METADATA,sha256=c6ZrTqWnqHX5IxItucH3tjrPgEWysnmw7xFrFvBGXl0,6366
99
- uipath-2.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
100
- uipath-2.1.3.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
101
- uipath-2.1.3.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
102
- uipath-2.1.3.dist-info/RECORD,,
98
+ uipath-2.1.4.dist-info/METADATA,sha256=YW4-sr1WlE6N4mXyvHYGqKEeYrpqwONhFvbpje0uwXg,6366
99
+ uipath-2.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
100
+ uipath-2.1.4.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
101
+ uipath-2.1.4.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
102
+ uipath-2.1.4.dist-info/RECORD,,
File without changes