@uipath/agent-tool 1.206.0-preview.296 → 1.206.0-preview.298

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,117 +1,28 @@
1
+ import {
2
+ UIPATH_HOME_DIR,
3
+ AUTH_FILENAME,
4
+ DEFAULT_BASE_URL,
5
+ DEFAULT_REDIRECT_URI
6
+ } from "./packager-tool-1qg04b7q.js";
1
7
  import {
2
8
  getFileSystem
3
9
  } from "./packager-tool-0ajs8pnk.js";
4
10
  import {
5
11
  __require
6
12
  } from "./packager-tool-epsr41wx.js";
7
-
8
- // ../auth/src/catch-error.ts
9
- function isPromiseLike(value) {
10
- return value !== null && typeof value === "object" && typeof value.then === "function";
11
- }
12
- function catchError(fnOrPromise) {
13
- if (isPromiseLike(fnOrPromise)) {
14
- return settlePromiseLike(fnOrPromise);
15
- }
16
- try {
17
- const result = fnOrPromise();
18
- if (isPromiseLike(result)) {
19
- return settlePromiseLike(result);
20
- }
21
- return [undefined, result];
22
- } catch (error) {
23
- return [
24
- error instanceof Error ? error : new Error(String(error)),
25
- undefined
26
- ];
27
- }
28
- }
29
- function settlePromiseLike(thenable) {
30
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
31
- error instanceof Error ? error : new Error(String(error)),
32
- undefined
33
- ]);
34
- }
35
-
36
- // ../auth/src/constants.ts
37
- var UIPATH_HOME_DIR = ".uipath";
38
- var AUTH_FILENAME = ".auth";
39
- var DEFAULT_BASE_URL = "https://cloud.uipath.com";
40
- var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
41
-
42
- // ../auth/src/authProfile.ts
43
- var DEFAULT_AUTH_PROFILE = "default";
44
- var PROFILE_DIR = "profiles";
45
- var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
46
- var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
47
- var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
48
- var globalSlot = globalThis;
49
- function isAuthProfileStorage(value) {
50
- return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
51
- }
52
- function createProfileStorage() {
53
- const [error, mod] = catchError(() => __require("node:async_hooks"));
54
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
55
- return {
56
- getStore: () => {
57
- return;
58
- },
59
- run: (_store, fn) => fn()
60
- };
61
- }
62
- return new mod.AsyncLocalStorage;
63
- }
64
- function getProfileStorage() {
65
- const existing = globalSlot[AUTH_PROFILE_STORAGE_KEY];
66
- if (isAuthProfileStorage(existing)) {
67
- return existing;
68
- }
69
- const storage = createProfileStorage();
70
- globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage;
71
- return storage;
72
- }
73
- var profileStorage = getProfileStorage();
74
-
75
- class AuthProfileValidationError extends Error {
76
- constructor(message) {
77
- super(message);
78
- this.name = "AuthProfileValidationError";
79
- }
80
- }
81
- function normalizeAuthProfileName(profile) {
82
- if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
83
- return;
84
- }
85
- if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
86
- throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
87
- }
88
- return profile;
89
- }
90
- function getActiveAuthProfile() {
91
- const scopedState = profileStorage.getStore();
92
- if (scopedState !== undefined) {
93
- return scopedState.profile;
94
- }
95
- return globalSlot[ACTIVE_AUTH_PROFILE_KEY]?.profile;
96
- }
97
- function resolveAuthProfileFilePath(profile) {
98
- const normalized = normalizeAuthProfileName(profile);
99
- if (normalized === undefined) {
100
- throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
101
- }
102
- const fs = getFileSystem();
103
- return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
104
- }
105
- function getActiveAuthProfileFilePath() {
106
- const profile = getActiveAuthProfile();
107
- return profile ? resolveAuthProfileFilePath(profile) : undefined;
108
- }
13
+ import {
14
+ isBrowser2,
15
+ getGlobalThis
16
+ } from "./packager-tool-zdqbp34f.js";
17
+ import {
18
+ catchError2
19
+ } from "./packager-tool-xd2w5pct.js";
109
20
 
110
21
  // ../auth/src/config.ts
111
22
  var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
112
23
  var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
113
- var globalSlot2 = globalThis;
114
- var getAuthFileConfig = () => globalSlot2[AUTH_FILE_CONFIG_KEY] ?? {};
24
+ var globalSlot = globalThis;
25
+ var getAuthFileConfig = () => globalSlot[AUTH_FILE_CONFIG_KEY] ?? {};
115
26
 
116
27
  class InvalidBaseUrlError extends Error {
117
28
  url;
@@ -147,7 +58,7 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
147
58
  baseUrl = `https://${baseUrl}`;
148
59
  }
149
60
  const resolvedBaseUrl = baseUrl;
150
- const [urlError, url] = catchError(() => new URL(resolvedBaseUrl));
61
+ const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
151
62
  if (urlError) {
152
63
  const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
153
64
  throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
@@ -195,9 +106,425 @@ var resolveConfigAsync = async ({
195
106
  };
196
107
  };
197
108
 
198
- // ../auth/src/utils/platform.ts
199
- function isBrowser() {
200
- return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
109
+ // ../../node_modules/oauth4webapi/build/index.js
110
+ var USER_AGENT;
111
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
112
+ const NAME = "oauth4webapi";
113
+ const VERSION = "v3.8.6";
114
+ USER_AGENT = `${NAME}/${VERSION}`;
115
+ }
116
+ var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
117
+ var ERR_INVALID_ARG_TYPE = "ERR_INVALID_ARG_TYPE";
118
+ function CodedTypeError(message, code, cause) {
119
+ const err = new TypeError(message, { cause });
120
+ Object.assign(err, { code });
121
+ return err;
122
+ }
123
+ var allowInsecureRequests = Symbol();
124
+ var clockSkew = Symbol();
125
+ var clockTolerance = Symbol();
126
+ var customFetch = Symbol();
127
+ var modifyAssertion = Symbol();
128
+ var jweDecrypt = Symbol();
129
+ var jwksCache = Symbol();
130
+ var encoder = new TextEncoder;
131
+ var decoder = new TextDecoder;
132
+ function buf(input) {
133
+ if (typeof input === "string") {
134
+ return encoder.encode(input);
135
+ }
136
+ return decoder.decode(input);
137
+ }
138
+ var encodeBase64Url;
139
+ if (Uint8Array.prototype.toBase64) {
140
+ encodeBase64Url = (input) => {
141
+ if (input instanceof ArrayBuffer) {
142
+ input = new Uint8Array(input);
143
+ }
144
+ return input.toBase64({ alphabet: "base64url", omitPadding: true });
145
+ };
146
+ } else {
147
+ const CHUNK_SIZE = 32768;
148
+ encodeBase64Url = (input) => {
149
+ if (input instanceof ArrayBuffer) {
150
+ input = new Uint8Array(input);
151
+ }
152
+ const arr = [];
153
+ for (let i = 0;i < input.byteLength; i += CHUNK_SIZE) {
154
+ arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
155
+ }
156
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
157
+ };
158
+ }
159
+ var decodeBase64Url;
160
+ if (Uint8Array.fromBase64) {
161
+ decodeBase64Url = (input) => {
162
+ try {
163
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
164
+ } catch (cause) {
165
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
166
+ }
167
+ };
168
+ } else {
169
+ decodeBase64Url = (input) => {
170
+ try {
171
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
172
+ const bytes = new Uint8Array(binary.length);
173
+ for (let i = 0;i < binary.length; i++) {
174
+ bytes[i] = binary.charCodeAt(i);
175
+ }
176
+ return bytes;
177
+ } catch (cause) {
178
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
179
+ }
180
+ };
181
+ }
182
+ function b64u(input) {
183
+ if (typeof input === "string") {
184
+ return decodeBase64Url(input);
185
+ }
186
+ return encodeBase64Url(input);
187
+ }
188
+ class OperationProcessingError extends Error {
189
+ code;
190
+ constructor(message, options) {
191
+ super(message, options);
192
+ this.name = this.constructor.name;
193
+ if (options?.code) {
194
+ this.code = options?.code;
195
+ }
196
+ Error.captureStackTrace?.(this, this.constructor);
197
+ }
198
+ }
199
+ function OPE(message, code, cause) {
200
+ return new OperationProcessingError(message, { code, cause });
201
+ }
202
+ function assertString(input, it, code, cause) {
203
+ try {
204
+ if (typeof input !== "string") {
205
+ throw CodedTypeError(`${it} must be a string`, ERR_INVALID_ARG_TYPE, cause);
206
+ }
207
+ if (input.length === 0) {
208
+ throw CodedTypeError(`${it} must not be empty`, ERR_INVALID_ARG_VALUE, cause);
209
+ }
210
+ } catch (err) {
211
+ if (code) {
212
+ throw OPE(err.message, code, cause);
213
+ }
214
+ throw err;
215
+ }
216
+ }
217
+ function randomBytes() {
218
+ return b64u(crypto.getRandomValues(new Uint8Array(32)));
219
+ }
220
+ function generateRandomCodeVerifier() {
221
+ return randomBytes();
222
+ }
223
+ function generateRandomState() {
224
+ return randomBytes();
225
+ }
226
+ async function calculatePKCECodeChallenge(codeVerifier) {
227
+ assertString(codeVerifier, "codeVerifier");
228
+ return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
229
+ }
230
+ function ClientSecretPost(clientSecret) {
231
+ assertString(clientSecret, '"clientSecret"');
232
+ return (_as, client, body, _headers) => {
233
+ body.set("client_id", client.client_id);
234
+ body.set("client_secret", clientSecret);
235
+ };
236
+ }
237
+ function None() {
238
+ return (_as, client, body, _headers) => {
239
+ body.set("client_id", client.client_id);
240
+ };
241
+ }
242
+ var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
243
+ try {
244
+ return new URL(url, base);
245
+ } catch {
246
+ return null;
247
+ }
248
+ };
249
+ var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
250
+ var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
251
+ var quotedMatch = '"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
252
+ var quotedParamMatcher = "(" + tokenMatch + ")\\s*=\\s*" + quotedMatch;
253
+ var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*(" + tokenMatch + ")";
254
+ var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
255
+ var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
256
+ var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
257
+ var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
258
+ var skipSubjectCheck = Symbol();
259
+ var idTokenClaims = new WeakMap;
260
+ var jwtRefs = new WeakMap;
261
+ var branded = new WeakSet;
262
+ var nopkce = Symbol();
263
+ var expectNoNonce = Symbol();
264
+ var skipAuthTimeCheck = Symbol();
265
+ var skipStateCheck = Symbol();
266
+ var expectNoState = Symbol();
267
+ var _nodiscoverycheck = Symbol();
268
+ var _expectedIssuer = Symbol();
269
+
270
+ // ../../node_modules/openid-client/build/index.js
271
+ var headers;
272
+ var USER_AGENT2;
273
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
274
+ const NAME = "openid-client";
275
+ const VERSION = "v6.8.4";
276
+ USER_AGENT2 = `${NAME}/${VERSION}`;
277
+ headers = { "user-agent": USER_AGENT2 };
278
+ }
279
+ var int = (config) => {
280
+ return props.get(config);
281
+ };
282
+ var props;
283
+ var tbi;
284
+ function ClientSecretPost2(clientSecret) {
285
+ if (clientSecret !== undefined) {
286
+ return ClientSecretPost(clientSecret);
287
+ }
288
+ tbi ||= new WeakMap;
289
+ return (as, client, body, headers) => {
290
+ let auth;
291
+ if (!(auth = tbi.get(client))) {
292
+ assertString2(client.client_secret, '"metadata.client_secret"');
293
+ auth = ClientSecretPost(client.client_secret);
294
+ tbi.set(client, auth);
295
+ }
296
+ return auth(as, client, body, headers);
297
+ };
298
+ }
299
+ function assertString2(input, it) {
300
+ if (typeof input !== "string") {
301
+ throw CodedTypeError2(`${it} must be a string`, ERR_INVALID_ARG_TYPE2);
302
+ }
303
+ if (input.length === 0) {
304
+ throw CodedTypeError2(`${it} must not be empty`, ERR_INVALID_ARG_VALUE2);
305
+ }
306
+ }
307
+ function None2() {
308
+ return None();
309
+ }
310
+ var customFetch2 = customFetch;
311
+ var ERR_INVALID_ARG_VALUE2 = "ERR_INVALID_ARG_VALUE";
312
+ var ERR_INVALID_ARG_TYPE2 = "ERR_INVALID_ARG_TYPE";
313
+ function CodedTypeError2(message, code, cause) {
314
+ const err = new TypeError(message, { cause });
315
+ Object.assign(err, { code });
316
+ return err;
317
+ }
318
+ function calculatePKCECodeChallenge2(codeVerifier) {
319
+ return calculatePKCECodeChallenge(codeVerifier);
320
+ }
321
+ function randomPKCECodeVerifier() {
322
+ return generateRandomCodeVerifier();
323
+ }
324
+ function randomState() {
325
+ return generateRandomState();
326
+ }
327
+ var decoder2 = new TextDecoder;
328
+ function getServerHelpers(metadata) {
329
+ return {
330
+ supportsPKCE: {
331
+ __proto__: null,
332
+ value(method = "S256") {
333
+ return metadata.code_challenge_methods_supported?.includes(method) === true;
334
+ }
335
+ }
336
+ };
337
+ }
338
+ function addServerHelpers(metadata) {
339
+ Object.defineProperties(metadata, getServerHelpers(metadata));
340
+ }
341
+ var kEntraId = Symbol();
342
+
343
+ class Configuration {
344
+ constructor(server, clientId, metadata, clientAuthentication) {
345
+ if (typeof clientId !== "string" || !clientId.length) {
346
+ throw CodedTypeError2('"clientId" must be a non-empty string', ERR_INVALID_ARG_TYPE2);
347
+ }
348
+ if (typeof metadata === "string") {
349
+ metadata = { client_secret: metadata };
350
+ }
351
+ if (metadata?.client_id !== undefined && clientId !== metadata.client_id) {
352
+ throw CodedTypeError2('"clientId" and "metadata.client_id" must be the same', ERR_INVALID_ARG_VALUE2);
353
+ }
354
+ const client = {
355
+ ...structuredClone(metadata),
356
+ client_id: clientId
357
+ };
358
+ client[clockSkew] = metadata?.[clockSkew] ?? 0;
359
+ client[clockTolerance] = metadata?.[clockTolerance] ?? 30;
360
+ let auth;
361
+ if (clientAuthentication) {
362
+ auth = clientAuthentication;
363
+ } else {
364
+ if (typeof client.client_secret === "string" && client.client_secret.length) {
365
+ auth = ClientSecretPost2(client.client_secret);
366
+ } else {
367
+ auth = None2();
368
+ }
369
+ }
370
+ let c = Object.freeze(client);
371
+ const clone = structuredClone(server);
372
+ if (kEntraId in server) {
373
+ clone[_expectedIssuer] = ({ claims: { tid } }) => server.issuer.replace("{tenantid}", tid);
374
+ }
375
+ let as = Object.freeze(clone);
376
+ props ||= new WeakMap;
377
+ props.set(this, {
378
+ __proto__: null,
379
+ as,
380
+ c,
381
+ auth,
382
+ tlsOnly: true,
383
+ jwksCache: {}
384
+ });
385
+ }
386
+ serverMetadata() {
387
+ const metadata = structuredClone(int(this).as);
388
+ addServerHelpers(metadata);
389
+ return metadata;
390
+ }
391
+ clientMetadata() {
392
+ const metadata = structuredClone(int(this).c);
393
+ return metadata;
394
+ }
395
+ get timeout() {
396
+ return int(this).timeout;
397
+ }
398
+ set timeout(value) {
399
+ int(this).timeout = value;
400
+ }
401
+ get [customFetch2]() {
402
+ return int(this).fetch;
403
+ }
404
+ set [customFetch2](value) {
405
+ int(this).fetch = value;
406
+ }
407
+ }
408
+ Object.freeze(Configuration.prototype);
409
+ var retry = Symbol();
410
+
411
+ // ../auth/src/oidc.ts
412
+ var getOidcParams = async () => {
413
+ const code_verifier = randomPKCECodeVerifier();
414
+ const code_challenge = await calculatePKCECodeChallenge2(code_verifier);
415
+ const state = randomState();
416
+ return {
417
+ code_verifier,
418
+ code_challenge,
419
+ state
420
+ };
421
+ };
422
+
423
+ // ../auth/src/tokenExchange.ts
424
+ var exchangeCodeForTokens = async ({
425
+ code,
426
+ codeVerifier,
427
+ redirectUri,
428
+ clientId,
429
+ clientSecret,
430
+ tokenEndpoint
431
+ }) => {
432
+ const params = {
433
+ grant_type: "authorization_code",
434
+ code,
435
+ redirect_uri: redirectUri.toString(),
436
+ client_id: clientId,
437
+ code_verifier: codeVerifier
438
+ };
439
+ if (clientSecret) {
440
+ params.client_secret = clientSecret;
441
+ }
442
+ const tokenParams = new URLSearchParams(params);
443
+ const tokenResponse = await fetch(tokenEndpoint, {
444
+ method: "POST",
445
+ headers: {
446
+ "Content-Type": "application/x-www-form-urlencoded"
447
+ },
448
+ body: tokenParams
449
+ });
450
+ const tokenData = await tokenResponse.json();
451
+ if (!tokenResponse.ok) {
452
+ throw new Error(`Token exchange failed: ${String(tokenData.error ?? "unknown_error")} — ${String(tokenData.error_description ?? "no description")}`);
453
+ }
454
+ const accessToken = tokenData.access_token;
455
+ const refreshToken = tokenData.refresh_token;
456
+ if (typeof accessToken !== "string" || typeof refreshToken !== "string") {
457
+ throw new Error("Token exchange response is missing access_token or refresh_token");
458
+ }
459
+ return { accessToken, refreshToken };
460
+ };
461
+
462
+ // ../auth/src/authProfile.ts
463
+ var DEFAULT_AUTH_PROFILE = "default";
464
+ var PROFILE_DIR = "profiles";
465
+ var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
466
+ var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
467
+ var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
468
+ var globalSlot2 = globalThis;
469
+ function isAuthProfileStorage(value) {
470
+ return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
471
+ }
472
+ function createProfileStorage() {
473
+ const [error, mod] = catchError2(() => __require("node:async_hooks"));
474
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
475
+ return {
476
+ getStore: () => {
477
+ return;
478
+ },
479
+ run: (_store, fn) => fn()
480
+ };
481
+ }
482
+ return new mod.AsyncLocalStorage;
483
+ }
484
+ function getProfileStorage() {
485
+ const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
486
+ if (isAuthProfileStorage(existing)) {
487
+ return existing;
488
+ }
489
+ const storage = createProfileStorage();
490
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
491
+ return storage;
492
+ }
493
+ var profileStorage = getProfileStorage();
494
+
495
+ class AuthProfileValidationError extends Error {
496
+ constructor(message) {
497
+ super(message);
498
+ this.name = "AuthProfileValidationError";
499
+ }
500
+ }
501
+ function normalizeAuthProfileName(profile) {
502
+ if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
503
+ return;
504
+ }
505
+ if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
506
+ throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
507
+ }
508
+ return profile;
509
+ }
510
+ function getActiveAuthProfile() {
511
+ const scopedState = profileStorage.getStore();
512
+ if (scopedState !== undefined) {
513
+ return scopedState.profile;
514
+ }
515
+ return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
516
+ }
517
+ function resolveAuthProfileFilePath(profile) {
518
+ const normalized = normalizeAuthProfileName(profile);
519
+ if (normalized === undefined) {
520
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
521
+ }
522
+ const fs = getFileSystem();
523
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
524
+ }
525
+ function getActiveAuthProfileFilePath() {
526
+ const profile = getActiveAuthProfile();
527
+ return profile ? resolveAuthProfileFilePath(profile) : undefined;
201
528
  }
202
529
 
203
530
  // ../auth/src/utils/jwt.ts
@@ -216,7 +543,7 @@ class InvalidIssuerError extends Error {
216
543
  this.name = "InvalidIssuerError";
217
544
  }
218
545
  }
219
- var parseJWT = (token) => {
546
+ var parseJWT2 = (token) => {
220
547
  try {
221
548
  const parts = token.split(".");
222
549
  const base64Url = parts[1];
@@ -225,7 +552,7 @@ var parseJWT = (token) => {
225
552
  }
226
553
  const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
227
554
  let decodedString;
228
- if (isBrowser() && typeof atob !== "undefined") {
555
+ if (isBrowser2() && typeof atob !== "undefined") {
229
556
  decodedString = atob(base64);
230
557
  } else {
231
558
  decodedString = Buffer.from(base64, "base64").toString();
@@ -240,7 +567,7 @@ var parseJWT = (token) => {
240
567
  var assertIssuerMatchesAuthority = (token, authority) => {
241
568
  let payload;
242
569
  try {
243
- payload = parseJWT(token);
570
+ payload = parseJWT2(token);
244
571
  } catch (error) {
245
572
  throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
246
573
  }
@@ -274,7 +601,7 @@ var getTokenExpiration = (accessToken) => {
274
601
  // ../auth/src/sessionIdentity.ts
275
602
  var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
276
603
  var decodeClaims = (accessToken) => {
277
- const [error, claims] = catchError(() => parseJWT(accessToken));
604
+ const [error, claims] = catchError2(() => parseJWT2(accessToken));
278
605
  return error ? undefined : claims;
279
606
  };
280
607
  var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
@@ -321,7 +648,7 @@ var pickScopes = (claims) => {
321
648
  const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
322
649
  return scopes.length > 0 ? scopes : undefined;
323
650
  };
324
- var resolveSessionIdentity = (accessToken, authFlow) => {
651
+ var resolveSessionIdentity2 = (accessToken, authFlow) => {
325
652
  const claims = accessToken ? decodeClaims(accessToken) : undefined;
326
653
  const email = pickEmail(claims);
327
654
  const type = resolveIdentityType(claims, authFlow, email);
@@ -384,7 +711,7 @@ var requireEnv = (name) => {
384
711
  };
385
712
  var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
386
713
  var resolveBaseUrl = (rawUrl, failureContext) => {
387
- const [baseUrlError, baseUrl] = catchError(() => normalizeAndValidateBaseUrl(rawUrl));
714
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
388
715
  if (baseUrlError) {
389
716
  if (baseUrlError instanceof InvalidBaseUrlError) {
390
717
  throw baseUrlError;
@@ -399,7 +726,7 @@ var readAuthFromEnv = () => {
399
726
  const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
400
727
  const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
401
728
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
402
- const [parseError, payload] = catchError(() => parseJWT(accessToken));
729
+ const [parseError, payload] = catchError2(() => parseJWT2(accessToken));
403
730
  if (parseError) {
404
731
  const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
405
732
  const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
@@ -426,7 +753,7 @@ var readAuthFromEnv = () => {
426
753
  const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
427
754
  const expiration = getTokenExpiration(accessToken);
428
755
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
429
- const identity = resolveSessionIdentity(accessToken);
756
+ const identity = resolveSessionIdentity2(accessToken);
430
757
  const scopes = readTokenScopes(accessToken);
431
758
  return {
432
759
  loginStatus,
@@ -520,13 +847,13 @@ var defaultIsRobotIpcAvailable = async () => {
520
847
  if (process.platform === "win32") {
521
848
  return true;
522
849
  }
523
- const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
850
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
524
851
  if (pipeNamesError || !pipeNames) {
525
852
  return false;
526
853
  }
527
854
  const fs = getFileSystem();
528
855
  for (const pipeName of pipeNames) {
529
- const [existsError, exists] = await catchError(fs.exists(pipeName));
856
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
530
857
  if (!existsError && exists === true) {
531
858
  return true;
532
859
  }
@@ -544,7 +871,7 @@ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
544
871
  });
545
872
  });
546
873
  var parseResourceUrl = (url) => {
547
- const [error, parsed] = catchError(() => new URL(url));
874
+ const [error, parsed] = catchError2(() => new URL(url));
548
875
  if (error || !parsed)
549
876
  return;
550
877
  const segments = parsed.pathname.split("/").filter(Boolean);
@@ -564,14 +891,14 @@ var defaultLoadModule = async () => {
564
891
  if (!hostLoader) {
565
892
  return;
566
893
  }
567
- const [error, mod] = await catchError(() => hostLoader());
894
+ const [error, mod] = await catchError2(() => hostLoader());
568
895
  if (error || !mod) {
569
896
  return;
570
897
  }
571
898
  return mod;
572
899
  };
573
900
  var tryRobotClientFallback = async (options = {}) => {
574
- if (isBrowser())
901
+ if (isBrowser2())
575
902
  return;
576
903
  if (!options.force) {
577
904
  if (process.env.CI || process.env.GITHUB_ACTIONS) {
@@ -590,7 +917,7 @@ var tryRobotClientFallback = async (options = {}) => {
590
917
  const mod = await loadModule();
591
918
  if (!mod)
592
919
  return;
593
- const [ctorError, proxy] = catchError(() => new mod.RobotProxyConstructor);
920
+ const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
594
921
  if (ctorError || !proxy) {
595
922
  return;
596
923
  }
@@ -613,7 +940,7 @@ var tryRobotClientFallback = async (options = {}) => {
613
940
  let organizationIdFromToken;
614
941
  let tenantIdFromToken;
615
942
  let issuerFromToken;
616
- const [jwtError, claims] = catchError(() => parseJWT(accessToken));
943
+ const [jwtError, claims] = catchError2(() => parseJWT2(accessToken));
617
944
  if (!jwtError && claims) {
618
945
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
619
946
  if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
@@ -640,7 +967,7 @@ var tryRobotClientFallback = async (options = {}) => {
640
967
  } catch {
641
968
  return;
642
969
  } finally {
643
- await catchError(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
970
+ await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
644
971
  }
645
972
  };
646
973
 
@@ -671,7 +998,7 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId,
671
998
  const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
672
999
  throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
673
1000
  }
674
- const [parseError, data] = await catchError(response.json());
1001
+ const [parseError, data] = await catchError2(response.json());
675
1002
  if (parseError) {
676
1003
  throw new Error(describeNonJsonResponse(organizationId, response, parseError));
677
1004
  }
@@ -895,7 +1222,7 @@ var saveEnvFileAsync = async ({
895
1222
  // ../auth/src/loginStatus.ts
896
1223
  var defaultRobotTenantIdCache = new Map;
897
1224
  var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
898
- var getLoginStatusAsync = async (options = {}) => {
1225
+ var getLoginStatusAsync2 = async (options = {}) => {
899
1226
  return getLoginStatusWithDeps(options);
900
1227
  };
901
1228
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
@@ -1123,7 +1450,7 @@ async function buildFileStatus(tokens, credentials, globalHint) {
1123
1450
  return result;
1124
1451
  }
1125
1452
  function identityFields(accessToken, credentials) {
1126
- const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
1453
+ const identity = resolveSessionIdentity2(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
1127
1454
  const scopes = readTokenScopes(accessToken);
1128
1455
  return {
1129
1456
  ...identity ? { identity } : {},
@@ -1131,7 +1458,7 @@ function identityFields(accessToken, credentials) {
1131
1458
  };
1132
1459
  }
1133
1460
  async function buildRobotStatus(robotCreds, deps) {
1134
- const identity = resolveSessionIdentity(robotCreds.accessToken);
1461
+ const identity = resolveSessionIdentity2(robotCreds.accessToken);
1135
1462
  const scopes = readTokenScopes(robotCreds.accessToken);
1136
1463
  const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
1137
1464
  return {
@@ -1159,7 +1486,7 @@ async function resolveRobotTenantId(robotCreds, deps) {
1159
1486
  const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
1160
1487
  let pending = deps.cache.get(key);
1161
1488
  if (!pending) {
1162
- pending = catchError(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
1489
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
1163
1490
  const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
1164
1491
  if (!settled.tenantId) {
1165
1492
  deps.cache.delete(key);
@@ -1172,7 +1499,7 @@ async function resolveRobotTenantId(robotCreds, deps) {
1172
1499
  }
1173
1500
  async function lookupRobotTenantId(target, deps) {
1174
1501
  const { baseUrl, accessToken, organization, tenantName } = target;
1175
- const [error, data] = await catchError(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
1502
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
1176
1503
  if (error) {
1177
1504
  const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
1178
1505
  return { hint: tenantLookupFailureHint(tenantName, reason) };
@@ -1194,7 +1521,7 @@ function tenantLookupFailureHint(tenantName, reason) {
1194
1521
  return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
1195
1522
  }
1196
1523
  function decodePathSegment(segment) {
1197
- const [error, decoded] = catchError(() => decodeURIComponent(segment));
1524
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
1198
1525
  return error ? segment : decoded;
1199
1526
  }
1200
1527
  var isFileNotFoundError = (error) => {
@@ -1446,8 +1773,8 @@ class AuthContextUnavailableError extends Error {
1446
1773
  this.name = "AuthContextUnavailableError";
1447
1774
  }
1448
1775
  }
1449
- var getAuthContext = async (options = {}) => {
1450
- const status = await getLoginStatusAsync({
1776
+ var getAuthContext2 = async (options = {}) => {
1777
+ const status = await getLoginStatusAsync2({
1451
1778
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
1452
1779
  envFilePath: options.envFilePath
1453
1780
  });
@@ -1484,6 +1811,86 @@ var TENANT_SELECTION_CODES = new Set([
1484
1811
  TENANT_SELECTION_REQUIRED_CODE,
1485
1812
  INVALID_TENANT_CODE
1486
1813
  ]);
1487
- export { parseJWT, resolveSessionIdentity, getLoginStatusAsync, getAuthContext };
1488
1814
 
1489
- //# debugId=727098F7E81F378864756E2164756E21
1815
+ // ../auth/src/index.ts
1816
+ var authenticate2 = async ({
1817
+ baseUrl,
1818
+ clientId,
1819
+ clientSecret,
1820
+ redirectUri,
1821
+ scope,
1822
+ organization,
1823
+ timeoutMs,
1824
+ noBrowser,
1825
+ onAuthUrl,
1826
+ signal,
1827
+ onPortReclaimed
1828
+ }) => {
1829
+ const config = await resolveConfigAsync({
1830
+ customAuthority: baseUrl,
1831
+ customClientId: clientId,
1832
+ customClientSecret: clientSecret,
1833
+ customScopes: scope
1834
+ });
1835
+ const {
1836
+ authorizationEndpoint,
1837
+ tokenEndpoint,
1838
+ clientId: resolvedClientId,
1839
+ clientSecret: resolvedClientSecret,
1840
+ scopes: resolvedScopes
1841
+ } = config;
1842
+ const { code_challenge, code_verifier, state } = await getOidcParams();
1843
+ let effectiveRedirectUri;
1844
+ if (redirectUri) {
1845
+ effectiveRedirectUri = redirectUri.toString();
1846
+ } else if (isBrowser2()) {
1847
+ const origin = getGlobalThis()?.window?.location?.origin ?? "";
1848
+ effectiveRedirectUri = `${origin}/oidc/login`;
1849
+ } else {
1850
+ effectiveRedirectUri = DEFAULT_REDIRECT_URI;
1851
+ }
1852
+ const effectiveRedirectUriUrl = new URL(effectiveRedirectUri);
1853
+ const authParams = new URLSearchParams({
1854
+ client_id: resolvedClientId,
1855
+ redirect_uri: effectiveRedirectUriUrl.toString(),
1856
+ response_type: "code",
1857
+ scope: resolvedScopes.join(" "),
1858
+ code_challenge,
1859
+ code_challenge_method: "S256",
1860
+ state
1861
+ });
1862
+ if (organization) {
1863
+ if (/[\s:]/.test(organization)) {
1864
+ throw new Error(`Invalid organization name: "${organization}". Whitespace and colons are not allowed; use the organization's logical name (e.g. "my-org").`);
1865
+ }
1866
+ authParams.set("acr_values", `tenantName:${organization}`);
1867
+ }
1868
+ const authUrl = `${authorizationEndpoint}?${authParams.toString()}`;
1869
+ let strategy;
1870
+ if (isBrowser2()) {
1871
+ const { BrowserAuthStrategy } = await import("./browser-strategy-gnftxwsf.js");
1872
+ strategy = new BrowserAuthStrategy;
1873
+ } else {
1874
+ const { NodeAuthStrategy } = await import("./node-strategy-fk02jqd8.js");
1875
+ strategy = new NodeAuthStrategy;
1876
+ }
1877
+ const code = await strategy.execute(authUrl, effectiveRedirectUriUrl, state, {
1878
+ timeoutMs,
1879
+ noBrowser,
1880
+ onAuthUrl,
1881
+ signal,
1882
+ onPortReclaimed
1883
+ });
1884
+ return await exchangeCodeForTokens({
1885
+ code,
1886
+ codeVerifier: code_verifier,
1887
+ redirectUri: effectiveRedirectUriUrl,
1888
+ clientId: resolvedClientId,
1889
+ clientSecret: resolvedClientSecret,
1890
+ tokenEndpoint
1891
+ });
1892
+ };
1893
+
1894
+ export { parseJWT2, resolveSessionIdentity2, getLoginStatusAsync2, getAuthContext2, authenticate2 };
1895
+
1896
+ //# debugId=3E7A537F8FBBBDE964756E2164756E21